msx1 bios in a cartridge

Página 1/2
| 2

Por Vincent van Dam

Hero (513)

imagem de Vincent van Dam

11-12-2003, 22:24

Since I own a few cartridges that only run on a msx1 (due to invalid bios calls) I patched the msx.rom (msx1 bios) file so that it can run in a cartridge and burned this in an eprom which I mounted in an old cartridge. Basic idea is, put this bios-cartridge in slot 1, the game in slot 2, and let's go!

The project seems succesfull; in emulators the rom works perfectly, but in the real thing it only works when I put the bios-cartridge in a slotexpander. I am not sure why exactly, maybe somebody else could have a look at it. Here is the patch code:

ORG &H00

DB "CD"
DW &H02D7

ORG &H02D7

DI
IN A,(&HA8)
AND &B00000011
LD L,A
ADD A,A
ADD A,A
LD C,A
IN A,(&HA8)
AND &B11110011
OR C
OUT (&HA8),A

LD A,(&HFFFF)
CPL
AND &B00000011
ADD A,A
ADD A,A
LD B,A
LD A,(&HFFFF)
CPL
AND &B11110011
OR B
LD (&HFFFF),A

; The diskrom uses the value of FCC1 to
; determine the slot where the BIOS is
; located. The slot this BIOS is in,
; is hacked into that location.

LD A,&H80 ; is this the problem?
OR L
OR B
LD (&HFCC1),A

JP &H2680

HACK:
DI
LD C,0
LD DE,&HFCC1
LD HL,&HFCC9
JP &H7D81

ORG &H7D75
JP HACK

Entrar ou registrar-se para comentar

Por anonymous

incognito ergo sum (116)

imagem de anonymous

19-03-2012, 00:16

LD A,&H80 ; is this the problem?
OR L
OR B
LD (&HFCC1),A

You did localise the problem correctly and here's how it should be solved. You need to check whether the slot this rom is located is actually expanded:

LD C,L
IN A,(&HA8)
AND 3
LD E,A
LD D,0
LD HL,&HFCC1
ADD HL,DE
LD A,(HL)
OR C ; here's the original part again (C has old contents of L)
OR B
LD (&HFCC1),A

should do the trick...

Por Vincent van Dam

Hero (513)

imagem de Vincent van Dam

22-12-2003, 17:35

Apparently it was a hardware problem (the pragmatic hack I did with FCC1 is not a problem).

The problem was that I totally ignored the slot select signal which resulted that my rom was available in both slot 1 and 2 (overriding the one I put in slot 2). The slot expander apparently is smart enough to fix this. I fixed the problem by connecting the slot select to ce/oe on the rom. (Needless to say I have very little hardware expierence Wink)

Por vanfanel

Champion (446)

imagem de vanfanel

18-03-2012, 16:48

Talk about necro-posting!

I'm looking for a way to start-up my MSX2+ (1ChipMSX really) in MSX1 mode. 
So I found this thread: Is it possible to load the modified MSX1 BIOS with something like ROMLOAD, then boot an MSX2+ machine in MSX1 mode, raising MSX1 games compatibility?

thanks Big smile

Por NYYRIKKI

Enlighted (5877)

imagem de NYYRIKKI

19-03-2012, 21:21

Yes, in 1ChipMSX it is possible, how ever such a program does not exists AFAIK.

My OCM is not now here with me, so I leave doing such a program for someone else... Hmm, ok ok... I give almost ready program, but you still need to do some copy/paste & testing your self :

OCM memory page map: http://www.msx.org/forum/msx-talk/revival/one-chip-msx-improvement-project?page=1

Simple example core of the program:


OUTPUT "BIOSLOAD.COM"


	ORG #100

	LD DE,#4000	;FREE SPACE
	LD C,#1A	;SET DATA TRANSFER ADDRESS
	CALL 5

	LD DE,#5C	;FCB

	LD C,#F 	;Open
        PUSH DE
	CALL 5
	POP DE
	
	LD HL,1
	LD (FCB+#E),HL

	LD HL,#8000
	LD C,#27	;Read 32K
        PUSH DE
	CALL 5
	POP DE

	LD C,#10        ;Close
	CALL 5

	DI
	LD A,3
	OUT (#FF),A
	JP UP

	PHASE $+#C000
UP:
	CALL MoveBiosData		; Put new BIOS to OCM memory
	LD A,#F0
	OUT (#A8),A
	RST 0				; Reboot new BIOS

MoveBiosData:

	<This part you need to dig up from IPL source>

	RET

	DEPHASE

Disassembled version of original OCM IPL-ROM: (OLD)


	; One Chip MSX IPL-ROM
	; Disassembly & Comments By : NYYRIKKI

	ORG	0F000H

XF000:	DI
	JR	START


	; Load data
	; HL = Load address
	; B  = Number of sectors
	; CDE= Sector number (auto increase)

LOAD:	JP	SECLOAD
LOADADR:	EQU	$-2

	; Move code to RAM

START:	LD	BC,0200H
	LD	DE,XF000
	LD	HL,0000H
	LDIR

	; Init Palette
	LD	HL,VDPDATA
	LD	BC,0299H
	OTIR
	LD	BC,209AH
	OTIR
	JP	XF043
VDPDATA:
	DEFB #00,#90
	DEFB #00,#00,#00,#00,#11,#06,#33,#07,#17,#01,#27,#03,#51,#01,#27,#06
	DEFB #71,#01,#73,#03,#61,#06,#64,#06,#11,#04,#65,#02,#55,#05,#77,#07

XF043:	LD	SP,0FFFFH
	LD	A,40H
	LD	(6000H),A
	LD	BC,0100H
	LD	DE,0000H
	LD	HL,0C000H
	CALL	LOAD
	JR	C,XF07B
	CALL	CHKFAT
	JR	C,XF071
	CALL	CHKMBR
	JR	C,XF07B
	PUSH	DE
	PUSH	BC
	LD	B,01H
	LD	HL,0C000H
	CALL	LOAD
	POP	BC
	POP	DE
	JR	C,XF08D	; Bug? Should be XF07B?
XF071:	CALL	FINDROMFILE
	JR	C,XF07B
	CALL	COPYROMS
	JR	XF08D

XF07B:	LD	HL,ROMLOAD
	LD	(LOADADR),HL
	LD	A,60H
	LD	(6000H),A
	LD	DE,0200H
	LD	C,E
	CALL	COPYROMS
XF08D:	XOR	A
	LD	(6000H),A
	INC	A
	LD	(6800H),A
	LD	(7000H),A
	LD	(7800H),A
	LD	A,0C0H
	OUT	(0A8H),A
	RST	00H

COPYROMS:
	LD	B,10H
	LD	A,80H
XF0A4:	LD	(7000H),A
	INC	A
	LD	(7800H),A
	INC	A
	PUSH	AF
	PUSH	BC
	LD	B,20H
	LD	HL,8000H
	CALL	LOAD
	POP	BC
	POP	HL
	RET	C
	LD	A,H
	DJNZ	XF0A4
	RET

ROMLOAD:
	PUSH	DE
	PUSH	BC
	SLA	E
	RL	D
	LD	A,B
	ADD	A,A
	LD	C,A
	LD	B,00H
	PUSH	HL
	LD	HL,4000H
	LD	(HL),03H
	LD	(HL),D
	LD	(HL),E
	LD	(HL),B
	LD	A,(HL)
	POP	DE
XF0D3:	LD	A,(HL)
	LD	(DE),A
	INC	DE
	DJNZ	XF0D3
	DEC	C
	JR	NZ,XF0D3
	LD	A,(5000H)
	POP	BC
	POP	HL
	XOR	A
	LD	D,A
	LD	E,B
	ADD	HL,DE
	EX	DE,HL
	ADC	A,C
	LD	C,A
	RET

	; Sector load & subroutines

SNDCMD:	LD	A,(HL)
	SLA	E
	RL	D
	RL	C
	LD	(HL),B
	LD	(HL),C
	LD	(HL),D
	LD	(HL),E
	LD	(HL),00H
	LD	(HL),95H
	LD	A,(HL)
	LD	B,10H
XF0FA:	LD	A,(HL)
	CP	0FFH
	CCF
	RET	NC
	DJNZ	XF0FA
	SCF
	RET

XF103:	LD	B,0AH
XF105:	LD	A,(5000H)
	DJNZ	XF105
	LD	BC,4000H
	LD	E,C
	LD	D,C
	CALL	SNDCMD
	RET	C
	AND	0F7H
	CP	01H
	SCF
	RET	NZ
XF119:	LD	B,77H
	CALL	SNDCMD
	AND	04H
	JR	Z,XF129
	LD	B,41H
	CALL	SNDCMD
	JR	XF12E
XF129:	LD	B,69H
	CALL	SNDCMD
XF12E:	RET	C
	CP	01H
	JR	Z,XF119
	OR	A
	RET	Z
	SCF
	RET

XF137:	CALL	XF103
	POP	BC
	POP	DE
	POP	HL
	RET	C

SECLOAD:	
	PUSH	HL
	PUSH	DE
	PUSH	BC
	LD	B,51H
	LD	HL,4000H
	CALL	SNDCMD
	JR	C,XF137
	POP	BC
	POP	DE
	POP	HL
	OR	A
	SCF
	RET	NZ
	PUSH	DE
	PUSH	BC
	EX	DE,HL
	LD	BC,0200H
	LD	HL,4000H
XF15A:	LD	A,(HL)
	CP	0FEH
	JR	NZ,XF15A
	LDIR
	EX	DE,HL
	LD	A,(DE)
	POP	BC
	LD	A,(DE)
	POP	DE
	INC	DE
	LD	A,D
	OR	E
	JR	NZ,XF16C
	INC	C
XF16C:	DJNZ	SECLOAD
	RET

	; Search for "FAT"
	; C = Found

CHKFAT:	LD	HL,0C000H
	LD	BC,0080H
XF175:	LD	A,46H  ; F
	CPIR
	JR	Z,XF17D
	OR	A
	RET
XF17D:	PUSH	HL
	LD	D,(HL)
	INC	HL
	LD	E,(HL)
	LD	HL,4154H ; AT
	OR	A
	SBC	HL,DE
	POP	HL
	JR	NZ,XF175
	LD	C,00H
	LD	E,C
	LD	D,C
	SCF
	RET

	; Search Partition
	; C = Not Found

CHKMBR:	LD	B,04H
	LD	HL,0C1C6H
XF195:	PUSH	HL
	LD	E,(HL)
	INC	HL
	LD	D,(HL)
	INC	HL
	LD	C,(HL)
	LD	A,C
	OR	D
	OR	E
	POP	HL
	RET	NZ
	LD	DE,0010H
	ADD	HL,DE
	DJNZ	XF195
	SCF
	RET

FINDROMFILE:
	LD	IX,0C000H
	LD	L,(IX+0EH)	; Reserved sectors
	LD	H,(IX+0FH)
	LD	A,C
	ADD	HL,DE
	ADC	A,00H
	LD	C,A
	LD	E,(IX+11H) ; Root entries
	LD	D,(IX+12H)
	LD	A,E
	AND	0FH
	LD	B,04H
XF1C2:	SRL	D
	RR	E
	DJNZ	XF1C2
	OR	A
	JR	Z,XF1CC
	INC	DE
XF1CC:	PUSH	DE
	LD	B,(IX+10H) ; Number of FATs
	LD	E,(IX+16H) ; Sectors / FAT
	LD	D,(IX+17H)
	LD	A,C
XF1D7:	ADD	HL,DE
	ADC	A,00H
	DJNZ	XF1D7
	POP	DE
	ADD	HL,DE
	EX	DE,HL
	LD	C,A
	PUSH	DE
	PUSH	BC
	LD	B,01H
	LD	HL,0C000H
	CALL	LOAD
	RET	C
	LD	HL,(0C000H)
	LD	DE,4241H	; ROM header
	OR	A
	SBC	HL,DE
	POP	BC
	POP	DE
	RET	Z
	SCF
	RET

	DEFB 0,0,0,0,0,0,0

	END

Have fun...

~NYYRIKKI

Por vanfanel

Champion (446)

imagem de vanfanel

20-03-2012, 00:48

@NYYRIKKI: I'd have to dig up for my Z80 assembly notes from 199x to understand your program.
However, if you tell me what should I copy/paste from the IPL-ROM (what's an IPL-ROM anyway?), I can try to assemble it. Is there a good cross-assembler for Linux?

Thanks!

Por vanfanel

Champion (446)

imagem de vanfanel

20-03-2012, 00:46

I just remembered: my 1ChipMSX is an Altera DE1 board with Caro's port. Is it the same for the program you're proposing?

Por NYYRIKKI

Enlighted (5877)

imagem de NYYRIKKI

20-03-2012, 07:15

IPL (Initial Program loader) is the only code block (512 bytes) that is actually inside FPGA chip of OCM or DE1. It makes sure that VDP gets correct power on values and loads MSX-BIOS from flash / MMC to MSX slots so that the board can actually boot as MSX computer. This code is executed only when you physically power on the board.

Just modify the part that loads the BIOS in slot 0-0 and you are done. (Ok, you might want to add some error check routines, improve user interface etc. boring stuff.)

AFAIK ASMSX is good cross-assembler for Linux.

Por Sky_hawk

Champion (267)

imagem de Sky_hawk

20-03-2012, 09:00

Err, Bifi, I think vincent might have moved on after 9 years Smile

Gr,

Jan

Por Samor

Prophet (2106)

imagem de Samor

20-03-2012, 12:37

hm, some people appear to be time travelling here... look at the dates of first ~4 posts...

Por Huey

Prophet (2675)

imagem de Huey

20-03-2012, 12:53

hm, some people appear to be time travelling here... look at the dates of first ~4 posts...

it's a date conversion error. dd/mm/yy vs dd/yy/mm

Página 1/2
| 2