Bugs on a ROM to BIN conversion

Page 2/3
1 | | 3

By donluca

Expert (75)

donluca's picture

04-05-2020, 17:21

I see, I thought the universal poke was meant to prevent that, though! Am I wrong? oO

By Manel46

Hero (627)

Manel46's picture

04-05-2020, 17:43

I only tell you what happens with a reset. As for the rom chargers, I don't know them.
This question I had to solve in:
https://www.msx.org/es/node/46404
There, it is always reset, to start the rom

By donluca

Expert (75)

donluca's picture

04-05-2020, 18:25

Manel46 wrote:

I only tell you what happens with a reset. As for the rom chargers, I don't know them.
This question I had to solve in:
https://www.msx.org/es/node/46404
There, it is always reset, to start the rom

I see, interesting. I'm using the openMSX debugger to monitor differences while trying some stuff.

For now, I'm concentrating on Arkanoid.
From what I can see, the first BIN gets loaded at H4000, but using the code provided by Grauw and tfh makes no difference.

Investigation continues...

By tfh

Prophet (2945)

tfh's picture

04-05-2020, 18:42

donluca][quote=Manel46 wrote:

From what I can see, the first BIN gets loaded at H4000, but using the code provided by Grauw and tfh makes no difference.

Investigation continues...

The tip I gave was just to give the diskdrive time to stop spinning before the game starts. So this is only usefull for Zanac, looking at your examples ;-)

By donluca

Expert (75)

donluca's picture

04-05-2020, 19:07

Yes, I knew that, although Grauw's post gave me hope that it would somehow fix Arkanoid as well Tongue

I'm now redoing this completely from scratch because I hate with a passion using software such as msxr2b which doesn't tell me exactly what it's doing.

So now I'm standing here:

I've taken a known good dump of Arkanoid
I've split the 32k file into two 16k files.
I've added the necessary headers to both:

arka1.bin:
FE
00 80 = Start loading at 8000H
00 C0 = Stop loading at C000H
00 00 = Start executing

arka2.bin
FE
00 80 = Start loading at 8000H
05 C0 = Stop loading at C005H (because of the added z80 program at the end to load the second binary)
00 C0 = Start executing

At the end of the second binary I've added at the end the small program suggested in this thread: https://www.msx.org/forum/msx-talk/software/converting-msx-r...

3E 02 D3 FE C9

Otherwise after BLOADing the second part it won't return to Basic to let me load the other half.

Finally, I BLOAD them, the MSX restarts and... there's still the visual bug.
Is this some kind of protection? :-?

By Manel46

Hero (627)

Manel46's picture

04-05-2020, 20:11

If you reset the MSX, the same thing will always happen to you.
The head of the rom, carries the edentifier first: 41h, 42h. Then it is followed by the start address of the same, in the next two bytes.
The correct thing is not to restart, if not to do this:
ld hl, (4002h)
jp (hl)
In my program I restart for other reasons.
The correct thing is to load each part above 8000h. At 8800h for example. So you don't step on the basic charger.
After the first, you position the ram on page 1 you pass it at 4000h. Retrieving the basic, you then load the second part. That must be placed at 8000h later. Both this and the previous with LDIR. Logically this work is done above every 16 KBs of rom (ram).
Finally place the ram on page 1 again, you can include the above, to enter the start directly.
So were the tape chargers from before.

By donluca

Expert (75)

donluca's picture

04-05-2020, 23:23

I've done some investigation and msxr2b does exactly what you said: it loads the ROM at 8800h and then passes it to 4000h.

The issue is indeed in the restart, which should not happen!
In fact, when I restart, the address 8000H is blanked out and that's probably what's causing the visual bug.

EDIT: yes, that's it. I've just manually edited the RAM with the openMSX debugger and putting it the correct values fixes the bug.

I'll try to "attack" the issue at its root: once I've loaded the binaries, there should be no restart, the game should start immediately just like all the others do.

OpenMSX unfortunately is not helping me in this.
Its behavior is extremely random.
It often just resets instead of giving me a black screen and sometimes, when it gives me the black screen, I find the RAM empty, except from the content of the first BIN.

EDIT 2: I finally got a memory dump of a "good" crash with black screen and RAM not emptied.
Well, it's a mess. I don't understand what's happening, the data I'm reading at 4000H isn't from anywhere it's not taken from the two binaries and I have no idea of how it was generated.
All of the data from 4000H to 8000H is completely messed up. Everything else is perfectly fine.

I'm clueless.

EDIT 3: and just to further confuse myself more, after a reboot the previously messed up data magically become correct. The game runs but of course there's the small bug due to the 8000H 4 bytes being blanked out by Basic.

EDIT 4: holy moly I finally did it. To hell with msxr2b, thanks to the thread I mentioned earlier I was able to load Arkanoid properly. Now not only does it work properly without reboot, but it also clears the AB characters at the start of 4000H so that when I reset the MSX it gets back to my main menu instead of getting right back into the game.
Next up: Zanac.

By gdx

Enlighted (4642)

gdx's picture

05-05-2020, 10:21

Here is a simple method to convert the Arkanoid Rom to binary files.

Cut the rom in 2 parts of 16K with an hexa editor. Name the first part "Arkanoid.bin" and the second part "Arkanoid.p2".

Add the header FE 00 85 DA C5 00 C5 at start of the first part and also the code below at end (with a copy/paste in your hexa editor).

F3 3A 42 F3 26 40 CD 24 00 21 00 85 11 00 40 01 00 40 ED B0 3A C1 FC 26 40 CD 24 00 FB 11 A9 C5 0E 0F CD 7D F3 21 01 00 22 B7 C5 11 89 C5 B7 C2 7A C5 0E 1A 11 00 80 CD 7D F3 2A B9 C5 0E 27 11 A9 C5 CD 7D F3 FE 01 11 9B C5 CA 7A C5 11 A9 C5 0E 10 CD 7D F3 3E 01 CD 5F 00 06 FF C5 CD 9F FD C1 10 F9 3E C9 32 9F FD 3E 27 32 AE F3 F3 3A 42 F3 26 40 CD 24 00 2A 02 40 E9 D5 11 A9 C5 0E 10 CD 7D F3 D1 0E 09 C3 7D F3 46 69 6C 65 20 6E 6F 74 20 66 6F 75 6E 64 21 0A 0D 24 52 65 61 64 20 65 72 72 6F 72 21 0A 0D 24 00 41 52 4B 41 4E 4F 49 44 50 32 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Arkanoid.bin should have a size of 40F1h bytes and, 4000h for Arkanoid.p2

Then to run it you can just entered BLOAD"Arkanoid.bin",R under Basic or use my binary file loader for MSX-DOS.

https://www.msx.org/downloads/binary-loader-v100

You can use the same way for all Roms located at 4000h~BFFFh by changing only the name of the second file into the code above. 41 52 4B 41 4E 4F 49 44 50 32 20 is for "ARKANOIDP2 ". Replace these 11 characters by 5A 41 4E 41 43 20 20 20 50 32 20 for "ZANAC P2 " for example.

This method works for games without copy protection and who start on page 1.
Both files must be in the same folder.

By donluca

Expert (75)

donluca's picture

05-05-2020, 15:10

Thanks GDX! (and thanks for the patches to start games with a joystick as well, already used them Smile )

I'll try that later.
I guess that works for 16k ROMs as well, I just need to remove the part of the code which loads the second binary and adjust the header, right?

By gdx

Enlighted (4642)

gdx's picture

05-05-2020, 16:01

For 16K Roms you have to add the same header at start of the Rom but one of the code below at end (depending of page location).

Code for 16K Rom on page 4000h~7FFFh:

18 01 00 06 FF C5 CD 9F FD C1 10 F9 3E C9 32 9F FD 3E 01 CD 5F 00 F3 3A 42 F3 26 40 CD 24 00 21 00 85 11 00 40 01 00 40 ED B0 2A 02 40 E9

Code for 16K Rom on page 8000h~BFFFh:

18 01 00 06 FF C5 CD 9F FD C1 10 F9 3E 01 CD 5F 00 F3 21 00 85 11 00 80 01 00 40 ED B0 2A 02 80 E9

Page 2/3
1 | | 3