Z-80 code question about a loop that depends on the contents of the refresh register

Alexis Kotlowy thrashbarg at kaput.homeunix.org
Wed Dec 14 01:08:23 CST 2016


On 14/12/2016 09:19, Ethan Dicks wrote:
> Hi, All,
>

> So far, this loop hangs on all three emulators I've tried - simh's
> altairz80, simcpm010 for AmigaDOS, and EMUZ80 for Raspberry Pi.  I'm
>  guessing none of these environments emulate specific behavior of the
>  Refresh register?
>
> Does anyone have any comments or insights about what this is really
> doing and what the right thing to do for emulators is?  I can patch
> this if that's what's needed, but I'd like to understand it first.
>
> Thanks,
>
> -ethan
>

Ethan,

Have you tried running it on ZEMU? (Windows only unfortunately, but
should run under WINE).

http://www.z80.info/z80emu.htm#EMU_CPU_W32

I tried single stepping through it just now and it looks like it's doing
its job, at least as a possible random number generator.

When was this game written? Perhaps it's supposed to lock up on
emulators that don't emulate the Z80 completely?

Not knowing what the game is, it could be a copy protection routine too.
Because R counts the number of instructions executed (modulus 128), if
the code was modified, theoretically the R register would be different
to what the routine expects, and would lock the machine.

I can't find any information on what the MSB is set to when the
accumulator is loaded with R, and what the Sign flag is set to. The
datasheet says the Sign and Zero flags are changed by the instruction.
If either of these flags are set, the routine enters an infinite loop.

Alexis.


More information about the cctech mailing list