After a suggestion from [gdx] from MRC I took a look at the Rock'N'Roller (MSX1) and started to work on a patch for Ninja/Shinobi Tap multi controller adapter.
First step was to disassemble the game and figure out how the game deals with the controls. There are several calls to 3 of the BIOS routines that read the keyboard, the joysticks and the trigger buttons (from the joysticks) and decided that the best strategy was to emulate such BIOS routines and return correspondent values based on the buttons pressed on the controllers plugged in the multitap adapter.
Next step was to figure out a position in RAM out of the game execution to place the patch code -> address 0xdf00 to 0xe300 seemed nice
Following I have created the alternate routines:
- ALT_SNSMAT
- ALT_GTSTCK
- ALT_GTTRIG
The alternate routines fall back to the original BIOS call when the Ninja/Shinobi tap is not detected (a flag is reset) . for instance...
ALT_GTSTCK: ld b,a ; save row number ld a,(ninjaDetectFlag) ; test for ninja presence and a ; ld a,b ; restore row number jp z,0d5h ; (GTSTCK) ; if not present continue with BIOS routine ; ; read and return STICK value ...
Next step was to generate a list of addresses where the BIOS calls are called and write a quick and dirt and code to replace such calls with the alternate routines created. The +1 is the offset for the instruction code CD (call) at the addresses that call the bios routines.
; Patch Original game code ld hl, ALT_SNSMAT ; patch calls to 0141h (SNSMAT) ld (09648h+1),hl ld (0966bh+1),hl ld (09676h+1),hl ld (09685h+1),hl ld (09b7ch+1),hl ...
Then I have created a function that will be called in the game main loop to scan the joystick ports and detect the presence of a multitap adapter om port A. If an adapter is detected, a flag is marked and the four taps are read and converted as a mirror of a keyboard matrix and joystick directionals and triggers.
NINJAPATCH: ; check for presence of Tap call CHECKTAPS ; c = 0 0 0 0 a1 a0 b1 b0 cpl ; c = 1 1 1 1 /a1 /a0 /b1 /b0 and 08h ; isolate bit a1 -> a = 0 0 0 0 /a1 0 0 0 ld (ninjaDetectFlag),a ; /a1 should be 1 if a ninja or shinobi is detected ret z ; scan taps ; ld de,0fa7ah ; Tap connected to joy port 2 ld de,0ba3ah ; Tap connected to joy port 1 ld hl,ntapData call GETNIN ; read TAPS on port 1 ; process taps ************************************* ...
Button Mapping
Tap 1 is mapped as :
- Up, Down, Left, Right -> Ditto
- Trigger A - Z
- Trigger B - X
- Select - SEL
- Start - Escape
That was done to allow full access and control of Options menu from the game, but it is still possible to access and control the Optiosn menu using the MSX keyboard.
Tap 2 is mapped as the QSCS (Q, S, Control, Shift) controls
Tap 3 is mapped as Joystick 1
Tap 4 is mapped as Joystick 2
To be continued...
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.