Determining which MZ

Post Reply
User avatar
mz-80a
Posts: 403
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Determining which MZ

Post by mz-80a »

Hi,

Is there a decent 'failsafe' method of finding out which MZ computer your program is running on? Only one I know of is perhaps checking the Monitor text (e.g. "SA-1510" etc). But that's not 100% accurate and if somebody has a modified MROM which doesn't even display this text then the program would have to fall back to a default.
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
https: //mz-sharpworks.co.uk/
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Determining which MZ

Post by hlide »

There were a couple of answers (or rather ideas) here: viewtopic.php?f=6&t=431
hlide
Posts: 681
Joined: Thu Jan 25, 2018 9:31 pm

Re: Determining which MZ

Post by hlide »

I guess there are roughly three categories :
- MZ-80 K series (MZ-80 K/K2E/C)
- MZ-80 A series (MZ-1200)
- MZ-700 series (MZ-700/800/1500)

One possibility:
700 series: disallow VRAM access through "OUT A,($E5)" (with A = 0). Try to write the XORed byte at $D3FF and read it back. If not equal, it's MZ-700. Restore if needed then get back to normal mapping with "OUT A,($E6)".
A series: if not MZ-700, $D3FF shall NOT be mirrored in $D7FF.
K series: if not MZ-700, $D3FF shall be mirrored in $D7FF.

It should work as long VRAM is working.
User avatar
mz-80a
Posts: 403
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Re: Determining which MZ

Post by mz-80a »

Thanks! I forgot about that other thread! Looks like you have a decent method worked out. I might write a small program soon to try this out and try it on my various machines.
hlide wrote: Sat Oct 30, 2021 4:24 pm I guess there are roughly three categories :
- MZ-80 K series (MZ-80 K/K2E/C)
- MZ-80 A series (MZ-1200)
- MZ-700 series (MZ-700/800/1500)

One possibility:
700 series: disallow VRAM access through "OUT A,($E5)" (with A = 0). Try to write the XORed byte at $D3FF and read it back. If not equal, it's MZ-700. Restore if needed then get back to normal mapping with "OUT A,($E6)".
A series: if not MZ-700, $D3FF shall NOT be mirrored in $D7FF.
K series: if not MZ-700, $D3FF shall be mirrored in $D7FF.

It should work as long VRAM is working.
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
https: //mz-sharpworks.co.uk/
stefano
Posts: 6
Joined: Wed Feb 21, 2018 7:44 am

Re: Determining which MZ

Post by stefano »

I couldn't succeed with this method.
I haven't tried on the real machine, but on many emulators.

Is my code wrong ?
Here's my last attempt:

Code: Select all

mz_type:
_mz_type:

	ld   hl,$D3FF      ; A position in VRAM to probe
	ld   a,(hl)        ; pick a byte, we will try to alter the data in VRAM

	; 700 series have a function to disable the VRAM access, let's see if it works..
	out  ($e5),a       ; lock VRAM

	xor  $55           ; put some dirt
	ld   e,a           ; keep a copy of the value used to probe the VRAM

	ld	 (hl),a
	out  ($e6),a       ; unlock VRAM

	cp   (hl)          ; Z set if we have an older model (no VRAM protection)

	jr z,no_mz700

	;out  ($e6),a       ; unlock VRAM

	; If not equal, it's MZ-700, MZ-800, MZ-1500
	ld   hl,2
	ret


no_mz700:
	; No need to unlock VRAM if we get here, it was never locked !
	; Viceversa, we must restore the original value in VRAM
	push af
	xor  $55           ; wipe out the added dirt
	ld   (hl),a
	pop  af

	ld   a,($D7FF)     ; This is for the MZ80K
	cp   e             ; compare to see if data was mirrored
	
	; MZ80K: data was mirrored
	ld   hl,0
	ret  z
	
	; MZ80A, data was not mirrored
	inc hl
	ret

...this is my current, non optimal way to determine if we're on MZ700 or MZ800


; Probe the MONITOR to detect Sharp MZ model.
; $26 would probably identify the MZ80K.

ld a,($10)
cp $24 ; Are we on a MZ700 ?
jr z,no_patch
cp $58 ; Are we on a MZ800 ?
jr z,no_patch
Post Reply