Disabling 2nd FDD by patching bios file ?

Door Sylver78

Rookie (18)

afbeelding van Sylver78

06-05-2022, 17:02

I've ported openMSX to the "recently" released Game & Watch, it's working great and I'm very happy with the result (more details here : https://www.msx.org/forum/msx-talk/emulation/msx-emulator-on... ).
But there are some games that requires the player to start the computer with CTRL press at boot to free some RAM by disabling the 2nd FDD. I'm trying to make the emulator as easy as possible to use, and I'd like to make this automatic so the player doesn't have to deal with this.
Programatically pressing CTRL at startup for x seconds could be a solution, but it's not a clean solution to me. So I wonder if anyone already tried to patch the bios files to automatically disable 2nd FDD with no needed action.
If no, I could have a look but I'd like to know in which rom file the check is done (in one of the MSX2(P).ROM/MSX2(P)EXT.rom files, or is it handled in the disk rom (In my case I use panasonicdisk.rom) ?
I'm not really aware of how the MSX startup is handled in rom files, so any hints/help is welcome :)

Aangemeld of registreer om reacties te plaatsen

Van wouter_

Champion (484)

afbeelding van wouter_

06-05-2022, 18:33

In openMSX you can press CTRL during the boot sequence with a small Tcl script like this (save this in a file, and pass it as an argument on the command line):

keymatrixdown 6 2 ;# press CTRL
after time 8 {keymatrixup 6 2} ;# release CTRL after 8 seconds

However didn't you say in your other post that you ported blueMSX instead of openMSX? As far as I know blueMSX has no scripting support (Tcl or other).

Modifying the ROM is also possible. The code is most likely located in the disk ROM. Where exactly in that ROM depends on the specific MSX machine (or even the revision of that machine). I'm also guessing that the way how the ROM checks for CTRL can be different between the different version (e.g. via the BIOS, or by directly reading the keyboard matrix via the PPI).

This project has disassembled source code for many msx ROMs, including various disk ROMs.
Maybe you can search in there for the place where CTRL is handled?

Van Sylver78

Rookie (18)

afbeelding van Sylver78

06-05-2022, 18:38

My bad, of course it's blueMSX that I have ported !
Thanks for the hints, I'll check that Smile

Van Sylver78

Rookie (18)

afbeelding van Sylver78

06-05-2022, 22:04

I've setup openMSX with the debugger, the disk rom I'm using in my blueMSX port is equivalent to the fs-a1wsx_disk.rom for openMSX, I guess I should be able to use the debugger to find the code that is looking for ctrl/shift press at startup, I just have to find how to set a breakpoint to the beginning of the disk bios !

Van sdsnatcher73

Prophet (3231)

afbeelding van sdsnatcher73

07-05-2022, 06:28

I am no expert but I always use this nifty MSX Z80 disassembler which is in Japanese but is manageable. It knows the MSX BIOS and identifies calls to it. If you load the disk ROM (which most likely uses the BIOS to read the keyboard) you will see the BIOS calls. Somewhere you will most likely see SNSMAT being called ;(it’s checking for a key in the matrix that is down). After that some arithmetic code and then some form of jump zero or non zero (depending on the arithmetic result). Just change the jump (eg JZ to JNZ). The BDOS (official name for the disk BIOS) has several keyboard checks (SHIFT for instance) so it may have several SNSMAT calls and you may have to try to change another jump if you got the wrong one at first.

Van Sylver78

Rookie (18)

afbeelding van Sylver78

07-05-2022, 11:00

Thanks for these great info I succeeded Smile

I managed to find the check for shift and ctrl press in the disk bios I'm using !
@57E8 this is the SNSMAT for the ctrl check, if ctrl is pressed, A register is FD, if no key is pressed, A register is FF.
So basically I replaced to the following code :
57EB : E6 02 and #02
57EB : 3E 00 ld a,#00
and now it always acting like if the system starts with ctrl pressed :)

edit : replacing AND #02 with AND #00 would be even simpler !

Thanks a lot again guys, it would have required me a lot more time to find this alone !