Z-80 code question about a loop that depends on the contents of the refresh register
ethan.dicks at gmail.com
Wed Dec 14 10:33:30 CST 2016
On Wed, Dec 14, 2016 at 2:08 AM, Alexis Kotlowy
<thrashbarg at kaput.homeunix.org> wrote:
> On 14/12/2016 09:19, Ethan Dicks wrote:
>> 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?
> Have you tried running it on ZEMU?
I have not. Thanks for the suggestion. I don't know which emulators
might implement the refresh register.
> (Windows only unfortunately, but should run under WINE).
That's what it will take - I'm 100% UNIX/Linux (well... plus VAX and
PDP-11 and Amiga and PET...)
> 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.
Excellent. I expect it should work.
> When was this game written? Perhaps it's supposed to lock up on
> emulators that don't emulate the Z80 completely?
1979. Emulators weren't a factor then.
> Not knowing what the game is, it could be a copy protection routine too.
I don't think so. It's just generating a percentage which it's using
> 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.
Tony Duell pointed that out too. I suspect that this code works for
machines that existed at the time, with 16K DRAMs, and might or might
not have worked on later machines. A quick scan of InfoWorld links
and such and I can't find any S-100 cards with 4164s older than about
1983. I don't think there were many commercially available 64K DRAMs
prior to 1982.
More information about the cctech