Bugs on a ROM to BIN conversion

Page 3/3
1 | 2 |

By donluca

Expert (75)

donluca's picture

05-05-2020, 17:16

I think that there's a typo in your post: arkanoid.bin is 40E1H in size unless I've done something wrong.

Also, I noticed that it does not remove the "AB" characters at address 4000H after starting which means that on a reset the game will start again instead of going back to Basic.
I can fix this myself by zeroing out the AB characters at the start of the ROM of course, just wanted to point this out. Smile

By donluca

Expert (75)

donluca's picture

05-05-2020, 19:30

Alright, got everything working out, or so it seems.

I've read that, for example, Knightmare, has some kind of protection. I admit I haven't really played it to the end, just reached second level, but it looks like that everything is working alright. Does it freeze/corrupt later on?

By gdx

Enlighted (5022)

gdx's picture

07-05-2020, 15:31

Right, it's 40E1h. About protections take a look at the following links.

https://www.msx.org/wiki/Konami_game_protections
https://www.msx.org/forum/msx-talk/software/roller-ball-copy...

There are probably other threads.

By donluca

Expert (75)

donluca's picture

08-05-2020, 00:23

Thanks, the second thread is very intriguing, a very nice read.

Anyway, looks like I got this sorted out! Onto the next challenge, I guess. Tongue

By gdx

Enlighted (5022)

gdx's picture

07-12-2021, 09:17

This weekend i programmed a routine to convert a 32K ROM to one binary file only. This routine is as follows in assembler.

; Loading routine for 32K ROM in one binary file (4000h~BFFFh with Header at 4000h)

; Load and execute the ROM with the BLOAD"name.bin",R
;
; Assembled with zasm cross assembler
; <a href="http://sourceforge.net/projects/zasm/" title="http://sourceforge.net/projects/zasm/">http://sourceforge.net/projects/zasm/</a>

ENASLT	equ	00024h	; Slot select
CHGMOD	equ	0005Fh	; Change screen mode

BDOS	equ	0F37Dh	; BDOS functions
FCBBASE	equ	0F353h	; Current FCB adresse
RAMAD0	equ	0F341h	; Main-RAM Slot (00000h~03FFFh)
RAMAD1	equ	0F342h	; Main-RAM Slot (04000h~07FFFh)
RAMAD2	equ	0F343h	; Main-RAM Slot (08000h~0BFFFh)
RAMAD3	equ	0F344h	; Main-RAM Slot (0C000h~0FFFFh)

LINL40	equ	0F3AEh	; Columns number in SCREEN 0
MNROM	equ	0FCC1h	; Slot de la Main-ROM

BINstart	equ	08500h

	org	08300h-7

; File header

	db	0feh
	dw	LdrStart,LdrEnd,LdrStart

LdrStart:

; Load the part 1 of the ROM

	ld	hl,(FCBBASE)	; HL = FCB address of the current opened file
	ld	de,14
	add	hl,de
	ld	(hl),1		; Record size = 1 byte

	ld	c,01Ah
	ld	de,LdrEnd
	call	BDOS		; DTA (Disk Transfer Area) = LdrEnd

	ld	hl,(FCBBASE)
	ld	d,h
	ld	e,l		; DE = FCB address
	ld	hl,04000h	; Block length = 04000h
	ld	c,027h
	call	BDOS		; Read the binary file
	cp	1
	ld	de,ReadError_TXT
	jp	z,BCK2DOS	; Jump if read error

	di
	ld	a,(RAMAD1)
	ld	h,40h
	call	ENASLT		; Select Main-RAM in page 1

	ld	hl,LdrEnd
	ld	de,04000h
	ld	bc,04000h
	ldir

	ld	a,(MNROM)
	ld	h,40h
	call	ENASLT		; Select Main-ROM in page 1

	ld	hl,LD_Part2
	ld	de,0C400h
	ld	bc,LdrEnd-LD_Part2
	ldir			; Move the second ROM part loader to C400h

	ei
	jp	0C400h

LD_Part2:

	ld	c,01Ah
	ld	de,08000h
	call	BDOS		; DTA = 08000h

	ld	hl,(FCBBASE)
	ld	d,h
	ld	e,l		; DE = FCB address
	ld	hl,04000h	; Block length = File size
	ld	c,027h
	call	BDOS		; Read the binary file
	cp	1
	ld	de,ReadError_TXT
	jp	z,BCK2DOS	; Jump if read error

	ld	hl,(FCBBASE)
	ld	d,h
	ld	e,l		; DE = FCB address
	ld	c,10H
	call	BDOS		; Close the file

	ld	a,1
	call	CHGMOD

	ld	b,255
LOOP_DRV:
	push	bc
	call	0fd9fh
	pop	bc
	djnz	LOOP_DRV	; Wait for the FDD LED to go out. 

	ld	a,0c9h
	ld	(0fd9fh),a

	ld	a,39
	ld	(LINL40),a	; Width 39 when the SCREEN 0 is set

	di
	ld	a,(RAMAD1)
	ld	h,40h
	call	ENASLT		; Select Main-RAM in MSX"s Bank 1

	ld	hl,(04002h)
	jp	(hl)		; Runs the ROM

BCK2DOS:
	push	de		; Store error message address
	ld	hl,(FCBBASE)
	ld	de,14
	add	hl,de
	ld	c,10H
	call	BDOS		; Close the file
	pop	de		; Restore error message address

	ld	c,9
	jp	BDOS		; Print the text and back to the BASIC

ReadError_TXT
	db	"Read error!",10,13,'$'

LdrEnd:
	db	0	; This space is need!

;	incbin	"ROMNAME.BIN"	; Replace "ROMNAME" by the ROM name

In machine language (length C6h bytes):

FE 00 83 BE 83 00 83 2A 53 F3 11 0E 00 19 36 01
0E 1A 11 BE 83 CD 7D F3 2A 53 F3 54 5D 21 00 40
0E 27 CD 7D F3 FE 01 11 B0 83 CA 9D 83 F3 3A 42
F3 26 40 CD 24 00 21 BE 83 11 00 40 01 00 40 ED
B0 3A C1 FC 26 40 CD 24 00 21 51 83 11 00 C4 01
6D 00 ED B0 FB C3 00 C4 0E 1A 11 00 80 CD 7D F3
2A 53 F3 54 5D 21 00 40 0E 27 CD 7D F3 FE 01 11
B0 83 CA 9D 83 2A 53 F3 54 5D 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 2A 53 F3 11 0E 00 19 0E 10 CD 7D
F3 D1 0E 09 C3 7D F3 52 65 61 64 20 65 72 72 6F
72 21 0A 0D 24 00

The conversion is simple because you just have to add the ROM behind the routine either with a hex editor or when assembly with incbin directive. Only ROMs from 4000h to BFFFh with the header at 4000h and without copy protection can be converted.

You can donwload an example here:
https://1fichier.com/?29z1pvx64d05sek5swjs

With this method you can put more ROMs in a single folder or on the Beer's disk for example. Just BLOAD"name.bin",R to run the ROM. :)

By gdx

Enlighted (5022)

gdx's picture

07-12-2021, 13:30

I forgot to delete that unnecessary line:

BINstart equ 08500h

and say that it is better to remove the CD 24 00 (that select the second part) from the ROMs otherwise they may not work on MSXs whose the Main-RAM is spread in multiple slots.

By gdx

Enlighted (5022)

gdx's picture

16-12-2021, 10:56

Finally this method works with Disk-Basic v1 only. I need to find a method that also works with the v2...

Page 3/3
1 | 2 |