Noob questions: DEFINITIVE info about Z80 BUSREQ, RESET?
Posted: Mon Oct 26, 2015 4:57 pm
Hey folks, total noob here. I'm learning Genny programming with EASy68K and MAME debugger. (Unfortunately, I don't have access to a real Gen/MD at the moment.) I've been following along with the Big Evil Corp tutorials (really nice work on those, Matt!) and MarkeyJester's 68k tutorials (also really nice work, MarkeyJester!) I've also been regularly consulting the Genesis Technical Overview and the 68k Programmer's Reference Manual, and trying to search around Spritesmind for answers to some of my questions. I'm enjoying the process so far, trying to learn as much as I can on my own, but I've got myself all confused about how Z80 BUSREQ and RESET work, and I'm hoping you guys can set me straight.
These are the results of my testing in MAME debugger:
Some questions:
Also, if you'd like to make suggestions about different debugging or dev tools I should try out, go right ahead. I'm happy with the ones I'm using so far, but I like hearing different opinions.
These are the results of my testing in MAME debugger:
Code: Select all
EntryPoint: ; First thing that runs after powering on
move.b ($00a11100),d5 ; Get BUSREQ state
andi.l #1,d5 ; D5 = 1, MAME memory disassembly says Z80_HAS_BUS flag = 1 (true)
move.b ($00a11200),d4 ; Get RESET state, but this doesn't work, it always returns 0
; move.w ($00a11200),d4 ; Same thing, it always returns 0
; move.l ($00a11200),d4 ; Again, always 0
andi.l #1,d4 ; D4 = 0 no matter what, but memory disassembly says Z80_IS_RESET flag = 1 (true)
;-----This part doesn't work. No matter how long I wait, Bit #0 of BUSREQ never becomes 0, and Z80_HAS_BUS flag never becomes 0 (false)-----;
; move.w #$0100,($00a11100) ; Write 0100h to the BUSREQ port to REQUEST CONTROL of the Z80 bus
;.LocalLoop1:
; btst #0,($00a11100) ; Check Bit #0 of the byte at the BUSREQ port
; bne .LocalLoop1 ; Loop until Bit #0 of the byte at BUSREQ = 0, then we control the bus
;----------This part works fine.-----------;
move.w #$0100,($00a11200) ; Write 0100h to the RESET port to STOP HOLDING the Z80 in a reset state
; Memory disassembly now says Z80_IS_RESET flag = 0 (false)
move.w #$0100,($00a11100) ; Write 0100h to the BUSREQ port to REQUEST CONTROL of the Z80 bus
; Memory disassembly now says Z80_HAS_BUS flag = 0 (false)
.LocalLoop:
btst #0,($00a11100) ; Check Bit #0 of the byte at the BUSREQ port
bne .LocalLoop ; Loop until Bit #0 of the byte at BUSREQ = 0, then we control the bus
; Access Z80 memory here...
move.w #0,($00a11100) ; Write 0000h to the BUSREQ port to RELEASE CONTROL of the Z80 bus
; Memory disassembly says Z80_HAS_BUS flag = 1 (true)
- The Z80 manual says that the BUSREQ and RESET pins are both "active low." From what I've read, that seems to mean a low voltage signal (a "0" from a software standpoint) turns them ON, and a high signal (a "1" in software) turns them OFF. If that is correct, then it matches the way the RESET port works (0000h = RESET Z80 ON; 0100h = STOP RESETTING Z80), but it's the reverse of how the BUSREQ port works (0100h = REQUEST BUS; 0000h = LET GO OF BUS). Is the BUSREQ pin wired to the 68k backward or something?
- Do I need to check to make sure the Z80 regains control of the bus after I release control of it? If so, what should I do if the Z80 doesn't regain control? Write another release command to the port, or maybe reset the Z80?
- Is it necessary to write a word to these ports, or can I write bytes instead:
Code: Select all
move.b #1,($00a11100) ; Request bus move.b #0,($00a11200) ; Request reset
- The Z80 manual mentioned something about how lengthy DMA operations with BUSREQ active can prevent DRAM from being refreshed properly. Do I need to worry about that when using BUSREQ? (The Genesis Technical Overview mentions this DRAM refresh business, but it's talking about hardware dev kits or something like that.)
- Is there any reason besides accessing Z80 memory from the 68k that I would use BUSREQ?
- When/why would I need to reset the Z80 in the main body of my code? Every time the 68k writes to its memory?
- Can you read from the RESET port on real hardware? Or the BUSREQ port, for that matter (with a MOVE instruction, that is)?
Also, if you'd like to make suggestions about different debugging or dev tools I should try out, go right ahead. I'm happy with the ones I'm using so far, but I like hearing different opinions.