Filling in the header

SGDK only sub forum

Moderator: Stef

Post Reply
Very interested
Posts: 879
Joined: Thu Apr 10, 2008 3:03 pm

Filling in the header

Post by Sik » Mon Apr 18, 2016 7:37 am

Silly question, but does SGDK provide with an easy way to fill in the ROM header? (I doubt many people will want to edit the asm file with the boot code) I'm asking because I really don't like when homebrew uses a bogus header but I also doubt people will do it if it's hard to set up the information, and I know the vast majority of homebrew is made with SGDK so this alone would cover most of it.

Ideally what should be possible to change:
  • Name of the game
  • Copyright four letter code
  • ROM serial and number (hey some people keep track of this)
  • Supported peripherals
  • Whether SRAM is supported or not
  • Supported regions (maybe... I don't like anything that isn't "JUE" =P)
Also some of the information could be filled automatically on build time, e.g. the release date of the copyright field, or the ROM size fields. Anyway, is there an easy way to handle this in SGDK? If not, then I think it should provide a way for it.

And don't tell me "just put SEGA at 0x100 and ignore the rest", I want valid headers =P (and ideally, if we ever want to add extra hardware on the cartridge more commonly, I'd rather add the information in the free space of the ROM header so we don't resort to a new format for emulators to use)
Sik is pronounced as "seek", not as "sick".

Very interested
Posts: 259
Joined: Mon Nov 30, 2015 1:55 pm

Re: Filling in the header

Post by cero » Mon Apr 18, 2016 7:42 am

Have you looked at SGDK? The header is all in a convenient C file.

Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres

Re: Filling in the header

Post by Stef » Mon Apr 18, 2016 9:38 am

Actually yes, SGDK allows you to easily modify the rom header.
When you have a SGDK project, the makefile will automatically create you a "boot" folder in your source folder.
This folder contains both the sega.s boot source file so you can freely customize it and for the header itself you have a dedicated rom_head.c file which contains the ROM header in a C structure format, here's the content of this file that you can of course modify :

Code: Select all

const struct
    char console[16];               /* Console Name (16) */
    char copyright[16];             /* Copyright Information (16) */
    char title_local[48];           /* Domestic Name (48) */
    char title_int[48];             /* Overseas Name (48) */
    char serial[14];                /* Serial Number (2, 12) */
    u16 checksum;                   /* Checksum (2) */
    char IOSupport[16];             /* I/O Support (16) */
    u32 rom_start;                  /* ROM Start Address (4) */
    u32 rom_end;                    /* ROM End Address (4) */
    u32 ram_start;                  /* Start of Backup RAM (4) */
    u32 ram_end;                    /* End of Backup RAM (4) */
    char sram_sig[2];               /* "RA" for save ram (2) */
    u16 sram_type;                  /* 0xF820 for save ram on odd bytes (2) */
    u32 sram_start;                 /* SRAM start address - normally 0x200001 (4) */
    u32 sram_end;                   /* SRAM end address - start + 2*sram_size (4) */
    char modem_support[12];         /* Modem Support (24) */
    char notes[40];                 /* Memo (40) */
    char region[16];                /* Country Support (16) */
} rom_header = {
    "(C)FLEMTEAM 2013",
    "SAMPLE PROGRAM                                  ",
    "SAMPLE PROGRAM                                  ",
    "GM 00000000-00",
    "JD              ",
    "  ",
    "            ",
    "DEMONSTRATION PROGRAM                   ",
    "JUE             "

Post Reply