Code: Select all
loc_FF0000:
; Disable all interrupts
move #$2700, sr
movea.l #GATE_ARRAY, a5
move.w #0, GA_OFF_MAINCOMM(a5)
move.w #$FD0C, GA_OFF_HINT_VECTOR(a5)
; Clear bytes $FF0FBE and byte_FF0FBF
bsr.w sub_FF02D4
; Clear RAM from long_FF0F80-$FF1000
lea (long_FF0F80).l, a0
move.w #$1F, d1
moveq #0, d0
@loc_FF0026:
move.l d0, (a0)+
dbf d1, @loc_FF0026
; Get the status of controller #1
move.w #$100, (Z80_BUSREQ).l
move.w #$100, (Z80_RESET).l
@loc_FF003C:
btst #0, (Z80_BUSREQ).l
bne.s @loc_FF003C
lea (JOYDATA1).l, a0
bsr.w readJoypad
move.w #0, (Z80_BUSREQ).l
; Test A button on controller 1
btst #6, d0
move.b d0, ($108000).l
lea (0).l, a0
move.w (a0), d0
addi.w #1, (a0)
cmp.w (a0), d0
beq.w loc_FF0150
move.w d0, (a0)
move.l #$210800C, (8).l
move.l #$310800C, ($C).l
move.l #$410800C, ($10).l
move.l #$510800C, ($14).l
move.l #$610800C, ($18).l
move.l #$710800C, ($1C).l
move.l #$810800C, ($20).l
move.l #$910800C, ($24).l
move.l #$108008, ($80).l
move.b d0, ($10F001).l
move.w #$4E40, (loc_FF02AE).l
<snip>
The first half of that makes sense to me, but it gets all wonky after reading the controller port. It doesn't release the Z80 from its RESET state, checks for a button press and does nothing with it, writes to a couple of locations (0x108000 and 0x10F001) that are in "Reserved by system" address space, and tries to overwrite the vector table (which is part of the boot ROM and thus read-only) with locations that are not in the 68k's addressable space (e.g., 0x210800C is higher than the 68k's maximum of 0xFFFFFF).
Can any of you guys make sense of this? It's driving me up the wall...