I'm working on a conversion, it's 99% complete but there is an issue with the controls. I think I have a solution but I'm a total 68K noob so I wanted to bounce this off some of the experts here on AP.
Overview of the problem:
The original hardware for the target game (the game I'm converting TO) had inputs mapped to an IO chip with all player 1 controls mapped to 1 byte, and all player 2 controls mapped to a different byte, joysticks in the upper nibble and buttons in the lower nibble
The new hardware from the donor game (the PCB I'm converting) has inputs mapped to the same IO chip but with joysticks for both players mapped to 1 byte and buttons for both players mapped to a different byte. with player 1 in the upper nibble and player 2in the lower nibble.
Unfortunately fixing this in hardware would require cutting half the traces and re-wiring :-/
the code in the target game currently looks like this (A5 = 108000):
0x30000F is the location of the IO address for joysticks, 0x300005 is the location of the IO address for buttons.
and 0x100000 is end memory location for Player 1 controls and 0x100001 is the end memory location for player 2 controls.
So the results is that when you play the game Player 1 has to use player 2's joysticks for buttons and player 2 has to use player 1's buttons as a joystick.
Simplification
basically we need to do this
#read value 0xAB from 0x30000F
#read value 0xCD from 0x300005
#write value 0xAC to 0x100000
#write value 0xBD to 0x100001
since the destination forms a single word we could also consider:
#write value 0xACBD to 0x100000
What I'm thinking for solutions
I don't think I'll be able to make a solution work in the space available for the original 2 lines of code, so I'll likely have to jump to an unused area of the program ROM:
I've identified an empty range here: 6E8E4 - 7FE00
IDEA #1
IDEA #2
I feel like option 2 would be more efficient but I'm not sure if it would actually work as it relies on being able to shift the first byte of D0 without moving the second byte (does shifting work that way or does it always shift the whole register?)
Questions for the experts...
Do either of these approaches make sense?
Are there efficiency problems here?
If so, what's more efficient method?
Are there problems with utilizing D0?
if so, there is a: "move.w D0, $300000.l" operation before the inputs are collected, so should I move 0x300000 back into D0 once I'm done?
Overview of the problem:
The original hardware for the target game (the game I'm converting TO) had inputs mapped to an IO chip with all player 1 controls mapped to 1 byte, and all player 2 controls mapped to a different byte, joysticks in the upper nibble and buttons in the lower nibble
The new hardware from the donor game (the PCB I'm converting) has inputs mapped to the same IO chip but with joysticks for both players mapped to 1 byte and buttons for both players mapped to a different byte. with player 1 in the upper nibble and player 2in the lower nibble.
Unfortunately fixing this in hardware would require cutting half the traces and re-wiring :-/
the code in the target game currently looks like this (A5 = 108000):
Code:
010F1A move.b $30000F.l, (-$8000,A5) 1B79 0030 0006 8000
010F22 move.b $300005.l, (-$7fff,A5) 1B79 0030 0005 8001
and 0x100000 is end memory location for Player 1 controls and 0x100001 is the end memory location for player 2 controls.
So the results is that when you play the game Player 1 has to use player 2's joysticks for buttons and player 2 has to use player 1's buttons as a joystick.
Simplification
basically we need to do this
#read value 0xAB from 0x30000F
#read value 0xCD from 0x300005
#write value 0xAC to 0x100000
#write value 0xBD to 0x100001
since the destination forms a single word we could also consider:
#write value 0xACBD to 0x100000
What I'm thinking for solutions
I don't think I'll be able to make a solution work in the space available for the original 2 lines of code, so I'll likely have to jump to an unused area of the program ROM:
I've identified an empty range here: 6E8E4 - 7FE00
IDEA #1
Code:
jmp $6E900 ; place this in location of original line
; starting at location 6E900
move.b $30000F.l, (-$8000,A5) ; move all joy data from IO to P1 Memory location
move.b $300005.l, (-$7fff,A5) ; move all button data from IO to P2 memory location
andi.w #$FF0, (-$8000,A5) ; use AND mask to clear P1 button data and P2 joy data
move.b $300005.l, D0 ; move all button data to D0
lsr.b #4, D0 ; shift data right to move p1 button data to correct spot and remove p2 button data
or.b D0, (-$8000,A5) ; OR result into P1 memory location
move.b $30000F.l, D0 ; move all joy data to D0
lsl.b #4, D0 ; shift data left to move P2 joy data to correct spot and remove p1 joy data
or.b D0, (-$7fff,A5) ; OR result into P2 memory location
jmp $10F2A ; jump back to original location
IDEA #2
Code:
jmp $6E900 ; place this in location of original line
; starting at location 6E900
move.b $30000F.l, D0 ; move all joy data from IO to D0
lsl.w #4, D0 ; shift all joy data up one nibble (00** -> 0**0)
lsr.b #4, D0 ; shift p2 joy data back down one nibble (*0 -> 0*)
lsl.w #4, D0 ; shift all joy data up one nibble (0*0*-> *0*0)
move.w D0, (-$8000,A5) ; move joy data to P1 and P2 memory with 00 for button data
move.w #$0, D0 ; clear the lower word of D0
move.b $300005.l, D0 ; move all button data from IO to D0
lsl.w #4, D0 ; shift all button data up one nibble (00** -> 0**0)
lsr.b #4, D0 ; shift p2 button data back down one nibble (*0 -> 0*)
or.w D0, (-$8000,A5) ; OR D0 button data with P1 and P2 joy data into memory
jmp $10F2A ; jump back to original location
Questions for the experts...
Do either of these approaches make sense?
Are there efficiency problems here?
If so, what's more efficient method?
Are there problems with utilizing D0?
if so, there is a: "move.w D0, $300000.l" operation before the inputs are collected, so should I move 0x300000 back into D0 once I'm done?