Howto : Build Saturn cartridge firmware from regular Saturn executable

Written by cafealpha no comments
Classified in : Saturn, Programming Tags : Saturn, mkfirm, utility
In this article, I will explain how to build Saturn cartridge firmware from Saturn executable file.

Note : it doesn't magically convert .iso files to cartridge format ! It only convert standalone executable (typically, a file that can be executed after being uploaded to 06004000 address), and doesn't support programs that use CDROM.
So, basically commercial games can't be converted, and only some (not all) homebrew programs can be converted.

Preliminary explanations :
Saturn homebrew programs are made in order to be run from a specific address, which is typically 06004000 address, located in Saturn H-RAM.
This start address can be freely modified by modifying Saturn application makefile and source code, but unfortunately can't be easily modified when only output executable file is available.

In my personal case, I need to make cartridge firmware that boots from cartridge ROM.
And, instead of directly modifying cartridge firmware sources, I made mkfirm, which is an utility that packs user program with special cartridge bootloader program
Additionally, mkfirm compresses user program when packing it to ROM image, (and of course uncompresses it before executing it), which makes (sometimes) possible to pack programs larger than target ROM chip !

For example, let's try to pack "Knuckles steals a ring" demo from Saturn contest 2003 to Action Replay firmware.
Executable size for Knuckles demo (0.bin file) is 795KB.
Action Replay flash ROM size is 256KB.

Will it fit ?
> mkfirm.exe test_knuckles.bin test_knuckles_fw.bin -address 0x06004000 -rom_size 256 -exec_max_size 240
--- Saturn FirmWare maker v0.4 by cafe-alpha. ---
 Input file   : test_knuckles.bin
 Output file  : test_knuckles_fw.bin
 Exec address : 0x06004000
 BIN size (KB): 240
 ROM size (KB): 256
 Compress data ...
 Input size      = 813792 bytes
 Compressed size = 178074 bytes (input size * 21.882004 %)
(snip)
 Wrote 256.000 KB to disk (Input = 794.718 KB, comp. = 173.900 KB -> input * 21.9 %, remain 66.099 KB)

Yeah, this 795KB executable could be packed into a 256KB flash ROM :)
Well, it was a "good" example because it contains a lot of graphic data that are compressed efficiently.
Typical compression results when dealing only with code data are actually poor, but it still saves some bytes, and decompression is fast enough to get user program booting in less than one second after bootloader started.

Hidden command :
The bootloader program includes recovery menu that allows to exit to Saturn multiplayer screen : thanks to this "emergency exit" feature, you can reflash cartridge Flash ROM by using arflash utility. (It requires a modchipped Saturn in order to boot arflash from CDROM).
In order to access this "emergency exit" feature, please disconnect controller from pad1 connector, connect a controller to pad2 connector and power on your Saturn.

This hidden screen will also be displayed when a non-standard controller (example : analog controller, mouse, keyboard, etc) is plugged to pad1 connector.
It's not a feature : it's due to the fact that SMPC direct polling doesn't support exotic controllers, and will be fixed in a future version of mkfirm.

Write a comment

What is the last character of the word 0au9my4?

Rss feed of the article's comments