Re: sega I/O

From: Clay Cowgill <clay_at_supra.com>
Date: Thu Oct 09 1997 - 13:19:25 EDT

>I looked it up quickly in a Z-280 reference book (a superset of the Z-80,
>so there's a chance this is wrong, but I believe it to be correct from my
>old Z-80 days), it looks like your going to have to check for:
>
> IN A,(C)
[...]
> IN (IY+dd),(C)
>
>And if there doing trick code:
[...]

Thanks Zonn!

I spent several hours digging through the disassemblies last night. I
decided to concentrate on Space Fury after getting a feel for all of them.
I thought for sure I'd found what I was after:

3A39 DB FB IN A,(FB) ; IN A,(FC) DB FC
3A3B CB 6F BIT 5,A ; fire BIT 3,A CB 5F
3A3D CA A8 3A JP Z,3AA8 ; CA A8 3A
3A40 DB FA IN A,(FA) ; IN A,(FC) DB FC
3A42 CB 67 BIT 4,A ; right BIT 5,A CB 6F
3A44 CA 8A 3A JP Z,3A8A ; CA 8A 3A
3A47 CB 6F BIT 5,A ; left BIT 4,A CB 67
3A49 CA 99 3A JP Z,3A99 ; CA 99 3A
3A4C DB FB IN A,(FB) ; IN A,(FC) DB FC
3A4E CB 67 BIT 4,A ; thrust BIT 2,A CB 57
3A50 20 C0 JR NZ,3A12-$

The mnemonics and opcode data on the right is my patch. Much to my
chagrin, the patch didn't work at all! I finally got annoyed and plugged
the logic analyzer in (luckily still configured for Z-80 work) and did a
trigger on "3A39 DB" (so the LA will start capture on the opcode fetch to
3A39).

IT NEVER GETS HIT during game play. Grrrrr... It must be the high-score
initials entry routine. Well, hey, maybe that'll be useful later on... ;-)

No other places in the code look explicitly at IO ports FA or FB. This
morning before I left for work though, I did go look at a suspicious piece
of code that was using the indirect IO port read. (in a,(c))

After locating what looked to be the entry points of the routines right
around the "IN A,(C)" I started searching the code for calls or jumps into
that area. [Sidebar: f---ing Sega. I swear, some of the code in the G-80
stuff is compiler output. Damn spaghetti.]

Turns out that the section that's using the indirect IO read (the only one,
I might add) is in the IRQ service routine. :-)

The bad news is that it's doing some pretty weird bit-gyrations that'll
take me a little while longer to figure out. The good news is that it
looks like all the games might use this same method for polling the ports
during ISR. Still though, it there's a lot of "other" direct calls that
might need patching too (like the high-score initials routine above) so
this might take a while...

-Clay

Clayton N. Cowgill Engineering Manager
_______________________________________________________________________
/\ Diamond Multimedia Systems, Inc. clay@supra.com
\/ Communications Division http://www.supra.com/
Received on Thu Oct 9 09:18:39 1997

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2003 - 00:32:37 EDT