Z80 access and IO

For anything related to IO (joypad, serial, XE...)

Moderator: BigEvilCorporation

Post Reply
User avatar
ElBarto
Very interested
Posts: 158
Joined: Wed Dec 13, 2006 10:29 am
Contact:

Z80 access and IO

Post by ElBarto » Tue Mar 06, 2012 3:51 pm

Hello,

Two questions,

1) Is the bit #0 at 0xA11100 is the same as the bit #8 (I know that is the case for the IO, not sure about the Z80 control port) ?
2) Is there a need to request the Z80 bus before accessing the joypad ?

I ask that cause that's what the MegaCD bios does.

Thanks.

Chilly Willy
Very interested
Posts: 2619
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Mar 06, 2012 7:05 pm

1) Remember that these registers are words... the bit is bit 8 at the WORD at 0xA11100. Now remember that the bit commands on the 68000 operate on BYTES in memory, so you would need to mess with the MSB of the word register... which is 0xA11100 since the 68000 is big-endian (the MSB comes first at offset 0 from the address, and the LSB comes last at offset 1). So bit 0 of the BYTE at 0xA11100 is the same as bit 8 of the WORD at 0xA11100.

2) There is a bug in the IO controller such that if things occur just right (or wrong, depending on how you look at it), accessing the IO while the Z80 tries to access the ROM will cut the Z80 cycle short. Even worse, ALL Z80 ROM accesses from then on will be cut short. There are two official ways of handling it - the first is what SEGA recommends and does in all their sample code: request the Z80 bus before reading the IO. The second is to never do ROM reads from the Z80. The "fix" that EVERYONE actually uses is to make the rom fast enough that short cycles don't matter and then ignore the bug. :lol:

User avatar
ElBarto
Very interested
Posts: 158
Joined: Wed Dec 13, 2006 10:29 am
Contact:

Post by ElBarto » Tue Mar 06, 2012 7:28 pm

Thanks a lot :)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests