Merge branch 'master' into 'master'

Added SNES SuperFX hardware type and fixed save ram header issue with Super Mario World 2: Yoshi's Island and Stunt Race FX

Closes #58 and #35

See merge request InfiniteNesLives/INL-retro-progdump!30
This commit is contained in:
Paul Molloy 2020-06-13 22:21:56 +00:00
commit 7f21176c2f
2 changed files with 35 additions and 8 deletions

View File

View File

@ -1,4 +1,3 @@
-- create the module's table
local v2proto = {}
@ -17,15 +16,20 @@ local lorom_name = 'LoROM'
-- http://old.smwiki.net/wiki/Internal_ROM_Header
-- https://en.wikibooks.org/wiki/Super_NES_Programming/SNES_memory_map
-- https://patpend.net/technical/snes/sneskart.html
-- https://snesdev.mesen.ca/wiki/index.php
local hardware_type = {
[0x00] = "ROM Only",
[0x01] = "ROM and RAM",
[0x02] = "ROM and Save RAM",
[0x03] = "ROM and DSP1",
[0x13] = "ROM and SuperFX",
[0x15] = "ROM and SuperFX and Save RAM",
[0x1A] = "ROM and SuperFX and Save RAM (Stunt Race FX)",
[0x23] = "ROM and OBC1",
[0x33] = "ROM and SA-1",
[0x43] = "ROM and S-DD1",
[0xF3] = "ROM and CX4",
}
--[[
TODO: Investigate these configurations.
@ -60,11 +64,12 @@ local rom_size_kb_tbl = {
}
local ram_size_tbl = {
[0x00] = "No sram",
[0x00] = "None",
[0x01] = "16 kilobits",
[0x02] = "32 kilobits",
[0x03] = "64 kilobits",
[0x05] = "256 kilobits"
[0x05] = "256 kilobits",
[0x06] = "512 kilobits"
}
-- Translates ram size in header to KBytes.
@ -73,7 +78,8 @@ local ram_size_kb_tbl = {
[0x01] = 2,
[0x02] = 4,
[0x03] = 8,
[0x05] = 32
[0x05] = 32,
[0x06] = 64
}
local destination_code = {
@ -301,6 +307,9 @@ function print_header(internal_header)
local sram_size_str = "UNKNOWN - " .. hexfmt(internal_header["sram_size"])
if ram_size_tbl[internal_header["sram_size"]] then sram_size_str = ram_size_tbl[internal_header["sram_size"]] end
local exp_size_str = "UNKNOWN - " .. hexfmt(internal_header["exp_ram_size"])
if ram_size_tbl[internal_header["exp_ram_size"]] then exp_size_str = ram_size_tbl[internal_header["exp_ram_size"]] end
local destination_code_str = "UNKNOWN - " .. hexfmt(internal_header["destination_code"])
if destination_code[internal_header["destination_code"]] then
destination_code_str = destination_code[internal_header["destination_code"]]
@ -316,6 +325,7 @@ function print_header(internal_header)
print("Hardware Type:\t\t" .. rom_type_str)
print("Rom Size Upper Bound:\t" .. rom_size_str)
print("SRAM Size:\t\t" .. sram_size_str)
print("Expansion RAM Size:\t" .. exp_size_str)
print("Destination Code:\t" .. destination_code_str)
print("Developer:\t\t" .. developer_code_str)
print("Version:\t\t" .. hexfmt(internal_header["version"]))
@ -350,6 +360,7 @@ function get_header(map_adjust)
rom_type = dict.snes("SNES_ROM_RD", addr_rom_type),
rom_size = dict.snes("SNES_ROM_RD", addr_rom_size),
sram_size = dict.snes("SNES_ROM_RD", addr_sram_size),
exp_ram_size = dict.snes("SNES_ROM_RD", addr_expansion_ram_size),
destination_code = dict.snes("SNES_ROM_RD", addr_destination_code),
developer_code = dict.snes("SNES_ROM_RD", addr_developer_code),
version = dict.snes("SNES_ROM_RD", addr_version),
@ -869,10 +880,26 @@ local function process(process_opts, console_opts)
end
end
-- Autodetect missing ram size
if (ram_size == 0) or (ram_size == nil) then
ram_size = ram_size_kb_tbl[internal_header["sram_size"]]
assert(ram_size, "SRAM Size unknown and not provided, please add ram size to console_opts")
print("SRAM Size not provided, " .. ram_size_tbl[internal_header["sram_size"]] .. " detected.")
sram_table = ram_size_kb_tbl[internal_header["sram_size"]]
exp_ram_table = ram_size_kb_tbl[internal_header["exp_ram_size"]]
-- Some titles (Yoshi's Story, Stunt Race FX) use expansion ram header value
-- ram_size will use sram value unless a valid size is found in expansion ram header
if (sram_table == 0) or (sram_table == nil) then
if exp_ram_table == nil then
ram_size = sram_table
else
ram_size = exp_ram_table
end
else
ram_size = sram_table
end
assert(ram_size, "Save RAM Size unknown and not provided, please add ram size to console_opts")
print("Save RAM Size not provided, " .. ram_size .. " kilobytes detected.")
end
if (rom_size == 0) or (rom_size == nil) then