How to create a ROM file?

Страница 1/4
| 2 | 3 | 4

By thegeps

Paragon (1260)

Аватар пользователя thegeps

24-01-2019, 14:51

Have I simply to rename the bin file after assembled my code? I tried it but both openMSX and BlueMSX return to BASIC after boot...

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By konamiman

Paragon (1211)

Аватар пользователя konamiman

24-01-2019, 15:24

MSX2 Technical Handbook is your friend :)

By thegeps

Paragon (1260)

Аватар пользователя thegeps

24-01-2019, 15:38

yep, I've copied and pasted code from there...
CHGET: .EQU $9F
JIFFY: .EQU $FC9E
RSLREG: .EQU $138
EXPTBL: .EQU $FCC1
BOTTOM: .EQU $FC48
HIMEM: .EQU $FC4A
SLTWRK: .EQU $FD09
ENASLT: .EQU $24
LDIRVM: .EQU $5C
CHGMOD: .EQU $5F
SCRMOD: .EQU $0CAF
CHSTART: .EQU $E5C0
COLSTART: .EQU $E5C2
LINECOUNTER: .EQU $E5C4
DBFLAG: .EQU $E5C5
NAMETABLE: .EQU $E5C6
.ORG $4000
.DB $AB
.DW BEGIN
.DW $0,$0,$0,$0,$0,$0
BEGIN:
CALL RSLREG ;read primary slot #
RRCA ;move it to bit 0,1 of [Acc]
RRCA
AND %00000011
LD C,A
LD B,0
LD HL,EXPTBL ;see if this slot is expanded or not
ADD HL,BC
LD C,A ;save primary slot #
LD A,(HL) ;See if the slot is expanded or not
AND $80
OR C ;set MSB if so
LD C,A ;save it to [C]
INC HL ;Point to SLTTBL entry
INC HL
INC HL
INC HL
LD A,(HL) ;Get what is currently output
;to expansion slot register
AND %00001100
OR C ;Finally form slot address
LD H,$80
JP ENASLT ;enable page 2
START:
LD A,7
LD (LINECOUNTER),A
LD HL,46007
LD (CHSTART),HL
LD HL,46503
LD (COLSTART),HL
LD HL,58112
LD (NAMETABLE),HL
LD A,0
LD (DBFLAG),A

By thegeps

Paragon (1260)

Аватар пользователя thegeps

24-01-2019, 15:39

Sorry, I don't know how to copy and paste indented code here...

By tvalenca

Paladin (747)

Аватар пользователя tvalenca

24-01-2019, 15:48

Not quite. But before my answer I would like you to read this thread, because it alredy contains a much better explanation than I could possibly produce.

A BINary file contains a 7-byte header used by BLOAD command on BASIC. A ROM file should contain a number of other informations, meant to BIOS properly detect that there's a cartridge connected to that slot and a number of pointers to allow cartridge (which could be a software or a hardware with BIOS drivers that could be used by BASIC) to work properly. I couldn't find a Wiki article with this information, so:

DEFB "AB" ; expansion ROM header
DEFW initcode ; start of the init code, 0 if no initcode
DEFW callstat; pointer to CALL statement handler, 0 if no such handler
DEFW device; pointer to expansion device handler, 0 if no such handler
DEFW basic ; pointer to the start of a tokenized basicprogram, 0 if no basicprogram
DEFS 6,0 ; room reserved for future extensions

Also, a ROM file shoud have exact size; meaning: if your program was meant to fit on a 16k cartridge, your ROM file should be padded to exactly 16384 bytes.

And if your program is bigger than 16k, there are a few other measures to be taken (on BASIC you have a bunch of ~16k files which contain loader program along the code to switch slots and copy the program to the right addresses within $4000~$7FFF area, and when you assemble a ROM file -either to run on emulator or to burn to a cartridge- you wouldn't need this loader, you can just place the code on the right order).

By thegeps

Paragon (1260)

Аватар пользователя thegeps

24-01-2019, 15:59

thegeps wrote:

.ORG $4000
.DB $AB
.DW BEGIN
.DW $0,$0,$0,$0,$0,$0
BEGIN:
CALL RSLREG ;read primary slot #
RRCA ;move it to bit 0,1 of [Acc]
RRCA
AND %00000011
LD C,A
LD B,0
LD HL,EXPTBL ;see if this slot is expanded or not
ADD HL,BC
LD C,A ;save primary slot #
LD A,(HL) ;See if the slot is expanded or not
AND $80
OR C ;set MSB if so
LD C,A ;save it to [C]
INC HL ;Point to SLTTBL entry
INC HL
INC HL
INC HL
LD A,(HL) ;Get what is currently output
;to expansion slot register
AND %00001100
OR C ;Finally form slot address
LD H,$80
JP ENASLT ;enable page 2

I did...

By NYYRIKKI

Enlighted (6095)

Аватар пользователя NYYRIKKI

24-01-2019, 21:19

First problem I saw:

thegeps wrote:
	.DB	$AB

This should be:

	.DB	"AB"

or...

	.DB	$41,$42

By thegeps

Paragon (1260)

Аватар пользователя thegeps

24-01-2019, 23:35

Thank you very much, I was going mad... I'll fix it tomorrow. It was my fault modify the bin header and assuming that AB is a hex number (like FE for bin file) instead of string value

By thegeps

Paragon (1260)

Аватар пользователя thegeps

24-01-2019, 23:37

One more thing. I'll fix It, then compile a bin file and then rename it as rom?

By RetroTechie

Paragon (1563)

Аватар пользователя RetroTechie

25-01-2019, 00:41

Can't your assembler do that in one go? Shocked! Like just specify "whatever.rom" as output file?

By gdx

Enlighted (6443)

Аватар пользователя gdx

25-01-2019, 01:16

konamiman wrote:

MSX2 Technical Handbook is your friend :)

MRC too.
https://www.msx.org/wiki/The_Memory
https://www.msx.org/wiki/Slots
Program sample to make a ROM:
https://www.msx.org/wiki/Assembler_for_Dummies_%28Z80%29#Pro...
This documentation is valid for all MSX generation.

Страница 1/4
| 2 | 3 | 4