Makebin: Warn if RAM banks specified and file size of ROM is less than the 64K required to enable them with in emulators

- Fix missing info that yoN and yaN are also used for SMS to actually set number of banks
- Notes in docs
This commit is contained in:
bbbbbr
2023-06-06 01:45:05 -07:00
parent cb93060016
commit 32c1e97239
4 changed files with 28 additions and 6 deletions

View File

@@ -80,6 +80,9 @@ The MBC settings below are available when using the makebin `-Wl-yt<N>` switch.
Source: Pandocs. Additional details available at [Pandocs](https://gbdev.io/pandocs/The_Cartridge_Header.html#0147---cartridge-type "Pandocs")
For SMS/GG, the ROM file size must be at least 64K to enable mapper support for RAM banks in emulators.
- If the generated ROM is too small then `-yo 4` for makebin (or `-Wm-yo4` for LCC) can be used to set the size to 64K.
## MBC Type Chart
```

View File

@@ -190,6 +190,8 @@ GB/AP
- VRAM and some other display data / registers should only be written to when the @ref STATF_B_BUSY bit of @ref STAT_REG is off. Most GBDK API calls manage this automatically.
SMS/GG
- The SMS/GG ROM file size must be at least 64K to enable mapper support for RAM banks in emulators.
- If the generated ROM is too small then `-yo 4` for makebin (or `-Wm-yo4` for LCC) can be used to set the size to 64K.
- Display Controller (VDP)
- Writing to the VDP should not be interrupted while an operation is already in progress (since that will interfere with the internal data pointer causing data to be written to the wrong location).
- Recommended approach: Avoid writing to the VDP (tiles, map, scrolling, colors, etc) during an interrupt routine (ISR).

View File

@@ -43,6 +43,8 @@ https://github.com/gbdk-2020/gbdk-2020/releases
- Fixed support for indexed color pngs with less than 8 bits color depth
- Fixed incorrect palettes when different colors have same luma value (use RGB values as less-significant bits)
- Changed to use cross-platform constants for metasprite properties (S_FLIPX, S_FLIPY and S_PAL)
- @ref makebin
- Warn if RAM banks specified and file size of ROM is less than the 64K required to enable them with in emulators
- Added sdld6808 (for NES)
- Examples
- Fixed mkdir broken in some compile.bat files (remove unsupported -p flag during bat file conversion)

View File

@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
@@ -98,10 +99,12 @@ usage (void)
" -o bytes skip amount of bytes in binary file\n"
"SMS format options (applicable only with -S option):\n"
" -xo n rom size (0xa-0x2) (default: 0xc)\n"
" -xo n header rom size (0xa-0x2) (default: 0xc)\n"
" -xj n set region code (3-7) (default: 4)\n"
//" -xc n product code (0-159999)\n"
" -xv n version number (0-15) (default: 0)\n"
" -yo n number of rom banks (default: 2) (autosize: A)\n"
" -ya n number of ram banks (default: 0)\n"
//" -xV n SDSC version number\n"
//" -xd n SDSC date\n"
//" -xA n SDSC author pointer\n"
@@ -148,9 +151,10 @@ struct gb_opt_s
struct sms_opt_s
{
BYTE rom_size; /* Doesn't have to be the real size, needed for checksum */
BYTE region_code; /* Region code Japan/Export/International and SMS/GG */
BYTE version; /* Game version */
uint8_t rom_size; /* Doesn't have to be the real size, needed for checksum */
uint8_t region_code; /* Region code Japan/Export/International and SMS/GG */
uint8_t version; /* Game version */
uint8_t nb_ram_banks; /* Number of ram banks (default: 0) */
};
struct nes_opt_s
@@ -394,6 +398,15 @@ sms_postproc (BYTE * rom, int size, int *real_size, struct sms_opt_s *o)
short header_base = 0x7ff0;
int chk = 0;
unsigned long i;
// Emulators use ROM file size (var:size) (64K or greater) to determine whether a mapper is present, and RAM banks only work if a mapper is present.
// So warn if that criteria is not met.
// This is separate from the ROM size indicated in the header (var:o->rom_size) which reportedly is _not_ used for that detection.
if ((o->nb_ram_banks > 0) && (size < 0xffffu)) {
fprintf (stderr, "\nWARNING: SMS/GG ROM size (%d) must be at least 64K to enable mapper support for RAM banks (%d specified) in emulators."
"\n \"-yo 4\" for makebin (or \"-Wm-yo4\" for LCC) can be used to set the size to 64K\n\n", size, o->nb_ram_banks);
}
// choose earlier positions for smaller roms
if (header_base > size)
header_base = 0x3ff0;
@@ -751,7 +764,8 @@ main (int argc, char **argv)
// 32KiB, SMS Export, version 0 <- should work with most emulaters (<32K was never used, GG accepts SMS)
struct sms_opt_s sms_opt = {.rom_size=0xc,
.region_code=4,
.version=0 };
.version=0,
.nb_ram_banks=0 };
struct nes_opt_s nes_opt = {
.mapper = 30,
@@ -831,7 +845,8 @@ main (int argc, char **argv)
usage ();
return 1;
}
gb_opt.nb_ram_banks = strtoul (*argv, NULL, 0);
gb_opt.nb_ram_banks = strtoul (*argv, NULL, 0);
sms_opt.nb_ram_banks = strtoul (*argv, NULL, 0);
break;
case 't':