How to create a long ROM file

Page 1/2
| 2

By Juan Luis

Resident (34)

Juan Luis's picture

18-04-2019, 20:31

I have found in this forum this link expaining how to develop rom files:
https://www.msx.org/forum/msx-talk/development/how-to-create...

but this link doesn't explain how to create long ROM file with 1 or 2MBytes. I have seen in MSXDev Contest'18 several .rom files like Dream Puzzle with 4MBytes and Barbarian the duel with 1088Kbytes. How can I create .rom files with that size?

Is there any example with dummy data?

Login or register to post comments

By Grauw

Enlighted (7967)

Grauw's picture

18-04-2019, 22:57

ROM files are just sequentially containing banks of 8K or 16K data, raw, not any type of special header other than you would normally have for a ROM file. Typically one would choose a size that’s a power of two, since real ROM chips only come in those sizes.

The first 32K of that ROM file are mapped directly like a normal 32K ROM, and the remaining data can be banked in by using the mapper type of your choice (another link). I recommend ASCII8 for starters.

I have an example of a 16K ROM here, and for a 32K ROM you need to additionally determine the slot of page 1 and select it in page 2 on boot. Once you’ve done that, you can proceed to use larger ROMs by selecting different banks in the four (8K mapper) or two (16K mapper) memory areas within that 32K.

You need to instruct the emulator which mapper type the ROM uses with a command line argument (or from a GUI), although if you don’t provide this it will attempt to autodetect it (this does not always succeed).

By Manuel

Ascended (15289)

Manuel's picture

18-04-2019, 22:51

You are aware of ROM mappers?

By Juan Luis

Resident (34)

Juan Luis's picture

19-04-2019, 01:27

Grauw wrote:

ROM files are just sequentially containing banks of 8K or 16K data, raw, not any type of special header other than you would normally have for a ROM file. Typically one would choose a size that’s a power of two, since real ROM chips only come in those sizes.

The first 32K of that ROM file are mapped directly like a normal 32K ROM, and the remaining data can be banked in by using the mapper type of your choice (another link). I recommend ASCII8 for starters.

I have an example of a 16K ROM here, and for a 32K ROM you need to additionally determine the slot of page 1 and select it in page 2 on boot. Once you’ve done that, you can proceed to use larger ROMs by selecting different banks in the four (8K mapper) or two (16K mapper) memory areas within that 32K.

You need to instruct the emulator which mapper type the ROM uses with a command line argument (or from a GUI), although if you don’t provide this it will attempt to autodetect it (this does not always succeed).

Grauw, thanks one more time for your response. I'm studying the links you have provided.

By Juan Luis

Resident (34)

Juan Luis's picture

19-04-2019, 01:35

Manuel wrote:

You are aware of ROM mappers?

No Manuel. I have always developed using MSX-DOS 2.x.When I wanted to create a program larger than 64KByte, I created .bin files with the code in a specific origin address. Later I loaded .bin file in a segment using calls to ALL_SEG and ENASLT extended bios calls. I know that it's possible to select slots by ports, but I have always used BIOS calls because I find them easier.
Most of the people say that cartridge is the fastest method of loading a program and it avoid the installation in hard disk. I wanted to test the posibility of developing long programs in cartridge. I have to study rom mappers and their mechanisms.

Grauw, Manuel,
thanks for your help.

By RetroTechie

Paragon (1512)

RetroTechie's picture

19-04-2019, 20:12

Juan Luis wrote:

Most of the people say that cartridge is the fastest method of loading a program and it avoid the installation in hard disk.

A cartridge based program is NOT loaded. It is executed directly from memory, in the same way as code in the BIOS/BASIC ROM etc. It's already in the machine's memory map when the power is switched on. Unless with "load" you mean "plug into cartridge slot", "write to the flash EPROM of a MegaFlashROM style device", or "select .rom file in emulator". Wink

So eg. self-modifying code is out (unless you copy code to RAM first). But also you can execute X KB's of code while using 0 KB's of RAM (apart from stack & some variables of course). Code in the ROM sits in the cartridge & is executed directly from there, not first copied to RAM and executed as with DOS or BASIC programs. So the code (and static data) itself doesn't occupy any RAM. Which is the reason why most MegaROM's have such modest RAM requirements - the RAM is only needed as scratchpad.

By Juan Luis

Resident (34)

Juan Luis's picture

20-04-2019, 11:28

RetroTechie wrote:

A cartridge based program is NOT loaded...

It's true RetroTechie. With a cartridge, the program is already in memory and CPU can access directly. I had seen examples showing how to create rom files, but these examples didn't explain how to create long rom files. I'm studying the information about ROM mappers. I'm a little bit surprised about the great number of formats to create rom files: ASC8, ASC16, Konami w/o SCC, Generic8, Generic16, cartridge w/o SRAM, etc.

I thought there was a unique format. A problem I found is that I use to store variables into procedure body because I like to have variables close to the code where they are used, but you can't do that when you are developing rom files. All variables must be stored in a range of RAM memory address. I'll have to change my style of programming.

By Thom

Hero (534)

Thom's picture

20-04-2019, 15:00

Grauw wrote:

I recommend ASCII8 for starters.

I wonder why using ASCII8 is easier than using ASCII16. Perhaps a stupid question, but I'd rather be stupid than staying stupid, so I have to ask ;-)

What both linked documents about this subject lack in my opinion, is some code snippets in addition to explanations like "Blocks can be switched by writing to a few special addresses in the slot the cartridge is in."

By ARTRAG

Enlighted (6153)

ARTRAG's picture

20-04-2019, 15:52

The code would depend on the assembler and on the way this latter allocates things in the output file

By Manel46

Champion (388)

Manel46's picture

20-04-2019, 17:26

I use Ascii16 normally. It is the best for large graphics.
I add link to my google drive with an example rom, based on Artrag's sources, of which I have learned a lot. It is an image on screen8
The assembler is Sjasm.
https://drive.google.com/file/d/1NyKgUosodk-n9F1bNK_DZl2YJGp...

By Grauw

Enlighted (7967)

Grauw's picture

21-04-2019, 15:55

Thom wrote:
Grauw wrote:

I recommend ASCII8 for starters.

I wonder why using ASCII8 is easier than using ASCII16. Perhaps a stupid question, but I'd rather be stupid than staying stupid, so I have to ask ;-)

The benefit of ASCII8 is that you have more granularity for switching (four blocks of 8K rather than two bigger ones), which gives more flexibility how you use the RAM. E.g. keep a fixed code segment in the first block, code which varies depending on the game mode in the second, a tile map in the third and tile data or graphics in the fourth block.

The benefit of ASCII16 is mostly the maximum memory size, which is 4 MB instead of 2 MB.

Page 1/2
| 2
My MSX profile