Support N64,GBA,Genesis in inlretro2, add CLI -z option for ROM size in megabits
This commit is contained in:
parent
5b47ff3fe6
commit
6685122c09
|
|
@ -87,7 +87,7 @@ local function process(process_opts, console_opts)
|
||||||
|
|
||||||
local rv = nil
|
local rv = nil
|
||||||
local file
|
local file
|
||||||
local rom_size = console_opts["prg_rom_size_kb"]
|
local rom_size = console_opts["rom_size_mbit"] * 128
|
||||||
local wram_size = console_opts["wram_size_kb"]
|
local wram_size = console_opts["wram_size_kb"]
|
||||||
local mirror = console_opts["mirror"]
|
local mirror = console_opts["mirror"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ function main ()
|
||||||
--cart/mapper specific scripts
|
--cart/mapper specific scripts
|
||||||
|
|
||||||
--NES mappers
|
--NES mappers
|
||||||
local curcart = require "scripts.nes.nrom"
|
--local curcart = require "scripts.nes.nrom"
|
||||||
--local curcart = require "scripts.nes.mmc1"
|
--local curcart = require "scripts.nes.mmc1"
|
||||||
--local curcart = require "scripts.nes.unrom"
|
--local curcart = require "scripts.nes.unrom"
|
||||||
--local curcart = require "scripts.nes.cnrom"
|
--local curcart = require "scripts.nes.cnrom"
|
||||||
|
|
@ -97,15 +97,15 @@ function main ()
|
||||||
--local curcart = require "scripts.sega.genesis_v1"
|
--local curcart = require "scripts.sega.genesis_v1"
|
||||||
|
|
||||||
--N64
|
--N64
|
||||||
--local curcart = require "scripts.n64.basic"
|
local curcart = require "scripts.n64.basic"
|
||||||
|
|
||||||
-- =====================================================
|
-- =====================================================
|
||||||
-- USERS: set cart_console to the to point to the mapper script you would like to use here.
|
-- USERS: set cart_console to the to point to the mapper script you would like to use here.
|
||||||
-- =====================================================
|
-- =====================================================
|
||||||
local cart_console = "NES" --includes Famicom
|
--local cart_console = "NES" --includes Famicom
|
||||||
--local cart_console = "SNES"
|
--local cart_console = "SNES"
|
||||||
--local cart_console = "SEGA"
|
--local cart_console = "SEGA"
|
||||||
--local cart_console = "N64"
|
local cart_console = "N64"
|
||||||
--local cart_console = "DMG"
|
--local cart_console = "DMG"
|
||||||
--local cart_console = "GBA"
|
--local cart_console = "GBA"
|
||||||
--local cart_console = "SMS"
|
--local cart_console = "SMS"
|
||||||
|
|
@ -136,10 +136,10 @@ function main ()
|
||||||
-- =====================================================
|
-- =====================================================
|
||||||
local console_opts = {
|
local console_opts = {
|
||||||
mirror = nil, -- Only used by latest INL discrete flash boards, set to "H" or "V" to change board mirroring
|
mirror = nil, -- Only used by latest INL discrete flash boards, set to "H" or "V" to change board mirroring
|
||||||
prg_rom_size_kb = 32, -- Size of NES PRG-ROM in KByte
|
prg_rom_size_kb = 256 * 128, -- Size of NES PRG-ROM in KByte
|
||||||
--prg_rom_size_kb = 8*1024, -- 8MByte ROM size example
|
chr_rom_size_kb = 8, -- Size of NES CHR-ROM in KByte
|
||||||
chr_rom_size_kb = 8, -- Size of NES CHR-ROM in KByte
|
wram_size_kb = 0, -- Size of NES PRG-RAM/WRAM in KByte
|
||||||
wram_size_kb = 0, -- Size of NES PRG-RAM/WRAM in KByte
|
rom_size_mbit = 8, -- Size of ROM in Megabits, used for non-NES consoles.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,102 @@ local function isempty(s)
|
||||||
return s == nil or s == ''
|
return s == nil or s == ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Wrapper for managing GBA operations.
|
||||||
|
function gba_exec(process_opts, console_opts)
|
||||||
|
local gba = require "scripts.gba.basic"
|
||||||
|
|
||||||
|
-- Defensively filter out any console options that are irrelevant to GBA support.
|
||||||
|
local gba_opts = {
|
||||||
|
rom_size_mbit = console_opts["rom_size_mbit"],
|
||||||
|
wram_size_kb = console_opts["wram_size_kb"],
|
||||||
|
}
|
||||||
|
gba.process(process_opts, gba_opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Wrapper for managing Sega Genesis operations.
|
||||||
|
function genesis_exec(process_opts, console_opts)
|
||||||
|
local genesis = require "scripts.sega.genesis_v1"
|
||||||
|
|
||||||
|
-- Defensively filter out any console options that are irrelevant to Genesis support.
|
||||||
|
local genesis_opts = {
|
||||||
|
rom_size_mbit = console_opts["rom_size_mbit"],
|
||||||
|
wram_size_kb = console_opts["wram_size_kb"],
|
||||||
|
}
|
||||||
|
genesis.process(process_opts, genesis_opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Wrapper for managing N64 operations.
|
||||||
|
function n64_exec(process_opts, console_opts)
|
||||||
|
local n64 = require "scripts.n64.basic"
|
||||||
|
|
||||||
|
-- Defensively filter out any console options that are irrelevant to N64 support.
|
||||||
|
local n64_opts = {
|
||||||
|
rom_size_mbit = console_opts["rom_size_mbit"],
|
||||||
|
wram_size_kb = console_opts["wram_size_kb"],
|
||||||
|
}
|
||||||
|
n64.process(process_opts, n64_opts)
|
||||||
|
end
|
||||||
|
|
||||||
-- Wrapper for managing NES/Famicom operations.
|
-- Wrapper for managing NES/Famicom operations.
|
||||||
function nes_exec(mapper, dump_filename, flash_filename, verify_filename, ramdump_filename, ramwrite_filename, console_opts)
|
function nes_exec(process_opts, console_opts)
|
||||||
local dict = require "scripts.app.dict"
|
local dict = require "scripts.app.dict"
|
||||||
local nes = require "scripts.app.nes"
|
local nes = require "scripts.app.nes"
|
||||||
|
|
||||||
|
-- Defensively filter out any console options that are irrelevant to NES support.
|
||||||
|
-- This will matter more when software support exists for other consoles.
|
||||||
|
local nes_opts = {
|
||||||
|
wram_size_kb = console_opts["wram_size_kb"],
|
||||||
|
prg_rom_size_kb = console_opts["prg_rom_size_kb"],
|
||||||
|
chr_rom_size_kb = console_opts["chr_rom_size_kb"],
|
||||||
|
mirror = nil -- Used by NROM mapper only, "H" or "V".
|
||||||
|
}
|
||||||
|
|
||||||
|
local mappers = {
|
||||||
|
action53_tsop = require "scripts.nes.action53_tsop",
|
||||||
|
action53 = require "scripts.nes.action53",
|
||||||
|
bnrom = require "scripts.nes.bnrom",
|
||||||
|
cdream = require "scripts.nes.cdream",
|
||||||
|
cninja = require "scripts.nes.cninja",
|
||||||
|
cnrom = require "scripts.nes.cnrom",
|
||||||
|
dualport = require "scripts.nes.dualport",
|
||||||
|
easynsf = require "scripts.nes.easyNSF",
|
||||||
|
fme7 = require "scripts.nes.fme7",
|
||||||
|
mapper30 = require "scripts.nes.mapper30",
|
||||||
|
mmc1 = require "scripts.nes.mmc1",
|
||||||
|
mmc3 = require "scripts.nes.mmc3",
|
||||||
|
mmc4 = require "scripts.nes.mmc4",
|
||||||
|
nrom = require "scripts.nes.nrom",
|
||||||
|
unrom = require "scripts.nes.unrom"
|
||||||
|
}
|
||||||
|
|
||||||
|
dict.io("IO_RESET")
|
||||||
|
dict.io("NES_INIT")
|
||||||
|
nes.detect_mapper_mirroring(true)
|
||||||
|
|
||||||
|
m = mappers[console_opts[mapper]]
|
||||||
|
if m == nil then
|
||||||
|
print("UNSUPPORTED MAPPER")
|
||||||
|
else
|
||||||
|
-- Attempt requested operations with hardware!
|
||||||
|
|
||||||
|
-- TODO: Do plumbing for interacting with RAM.
|
||||||
|
m.process(process_opts, console_opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Point of entry from C language half of program.
|
||||||
|
function main()
|
||||||
|
|
||||||
|
-- Globals passed in from C:
|
||||||
|
-- console_name: string, name of console.
|
||||||
|
-- mapper_name: string, name of mapper.
|
||||||
|
-- dump_filename: string, filename used for writing dumped data.
|
||||||
|
-- flash_filename: string, filename containing data to write cartridge.
|
||||||
|
-- verify_filename: string, filename used for writing back data written to cartridge for verification.
|
||||||
|
-- nes_prg_rom_size_kb: int, size of cartridge PRG-ROM in kb.
|
||||||
|
-- nes_chr_rom_size_kb: int, size of cartridge CHR-ROM in kb.
|
||||||
|
-- nes_wram_size_kb: int, size of cartridge WRAM in kb.
|
||||||
|
|
||||||
-- TODO: This should probably be one level up.
|
-- TODO: This should probably be one level up.
|
||||||
-- TODO: Ram probably needs a verify file as well?
|
-- TODO: Ram probably needs a verify file as well?
|
||||||
|
|
||||||
|
|
@ -51,64 +141,12 @@ function nes_exec(mapper, dump_filename, flash_filename, verify_filename, ramdum
|
||||||
writeram_filename = ramwrite_filename,
|
writeram_filename = ramwrite_filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Defensively filter out any console options that are irrelevant to NES support.
|
|
||||||
-- This will matter more when software support exists for other consoles.
|
|
||||||
local nes_opts = {
|
|
||||||
wram_size_kb = console_opts["wram_size_kb"],
|
|
||||||
prg_rom_size_kb = console_opts["prg_rom_size_kb"],
|
|
||||||
chr_rom_size_kb = console_opts["chr_rom_size_kb"],
|
|
||||||
mirror = nil -- Used by NROM mapper only, "H" or "V".
|
|
||||||
}
|
|
||||||
|
|
||||||
local mappers = {
|
|
||||||
action53_tsop = require "scripts.nes.action53_tsop",
|
|
||||||
action53 = require "scripts.nes.action53",
|
|
||||||
bnrom = require "scripts.nes.bnrom",
|
|
||||||
cdream = require "scripts.nes.cdream",
|
|
||||||
cninja = require "scripts.nes.cninja",
|
|
||||||
cnrom = require "scripts.nes.cnrom",
|
|
||||||
dualport = require "scripts.nes.dualport",
|
|
||||||
easynsf = require "scripts.nes.easyNSF",
|
|
||||||
fme7 = require "scripts.nes.fme7",
|
|
||||||
mapper30 = require "scripts.nes.mapper30",
|
|
||||||
mmc1 = require "scripts.nes.mmc1",
|
|
||||||
mmc3 = require "scripts.nes.mmc3",
|
|
||||||
mmc4 = require "scripts.nes.mmc4",
|
|
||||||
nrom = require "scripts.nes.nrom",
|
|
||||||
unrom = require "scripts.nes.unrom"
|
|
||||||
}
|
|
||||||
|
|
||||||
dict.io("IO_RESET")
|
|
||||||
dict.io("NES_INIT")
|
|
||||||
nes.detect_mapper_mirroring(true)
|
|
||||||
|
|
||||||
m = mappers[mapper]
|
|
||||||
if m == nil then
|
|
||||||
print("UNSUPPORTED MAPPER")
|
|
||||||
else
|
|
||||||
-- Attempt requested operations with hardware!
|
|
||||||
|
|
||||||
-- TODO: Do plumbing for interacting with RAM.
|
|
||||||
m.process(process_opts, console_opts)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Point of entry from C language half of program.
|
|
||||||
function main()
|
|
||||||
|
|
||||||
-- Globals passed in from C:
|
|
||||||
-- console_name: string, name of console.
|
|
||||||
-- mapper_name: string, name of mapper.
|
|
||||||
-- dump_filename: string, filename used for writing dumped data.
|
|
||||||
-- flash_filename: string, filename containing data to write cartridge.
|
|
||||||
-- verify_filename: string, filename used for writing back data written to cartridge for verification.
|
|
||||||
-- nes_prg_rom_size_kb: int, size of cartridge PRG-ROM in kb.
|
|
||||||
-- nes_chr_rom_size_kb: int, size of cartridge CHR-ROM in kb.
|
|
||||||
-- nes_wram_size_kb: int, size of cartridge WRAM in kb.
|
|
||||||
|
|
||||||
-- TODO: Add SNES support, as it appears to be currently usable?
|
-- TODO: Add SNES support, as it appears to be currently usable?
|
||||||
local consoles = {
|
local consoles = {
|
||||||
|
GBA = gba_exec,
|
||||||
|
GENESIS = genesis_exec,
|
||||||
NES = nes_exec,
|
NES = nes_exec,
|
||||||
|
N64 = n64_exec,
|
||||||
}
|
}
|
||||||
f = consoles[console_name]
|
f = consoles[console_name]
|
||||||
if f == nil then
|
if f == nil then
|
||||||
|
|
@ -118,10 +156,12 @@ function main()
|
||||||
local console_opts = {
|
local console_opts = {
|
||||||
wram_size_kb = nes_wram_size_kb,
|
wram_size_kb = nes_wram_size_kb,
|
||||||
prg_rom_size_kb = nes_prg_rom_size_kb,
|
prg_rom_size_kb = nes_prg_rom_size_kb,
|
||||||
chr_rom_size_kb = nes_chr_rom_size_kb
|
chr_rom_size_kb = nes_chr_rom_size_kb,
|
||||||
|
rom_size_mbit = rom_size_mbit,
|
||||||
|
mapper = mapper,
|
||||||
}
|
}
|
||||||
|
|
||||||
f(mapper_name, dump_filename, flash_filename, verify_filename, ramdump_filename, ramwrite_filename, console_opts)
|
f(process_opts, console_opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
-- create the module's table
|
-- create the module's table
|
||||||
local genesis_v1 = {}
|
local n64 = {}
|
||||||
|
|
||||||
-- import required modules
|
-- import required modules
|
||||||
local dict = require "scripts.app.dict"
|
local dict = require "scripts.app.dict"
|
||||||
|
|
@ -72,7 +72,7 @@ local function process(process_opts, console_opts)
|
||||||
|
|
||||||
local rv = nil
|
local rv = nil
|
||||||
local file
|
local file
|
||||||
local rom_size = console_opts["prg_rom_size_kb"]
|
local rom_size = console_opts["rom_size_mbit"] * 128
|
||||||
local wram_size = console_opts["wram_size_kb"]
|
local wram_size = console_opts["wram_size_kb"]
|
||||||
local mirror = console_opts["mirror"]
|
local mirror = console_opts["mirror"]
|
||||||
|
|
||||||
|
|
@ -197,7 +197,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- functions other modules are able to call
|
-- functions other modules are able to call
|
||||||
genesis_v1.process = process
|
n64.process = process
|
||||||
|
|
||||||
-- return the module's table
|
-- return the module's table
|
||||||
return genesis_v1
|
return n64
|
||||||
|
|
@ -57,7 +57,7 @@ local function process(process_opts, console_opts)
|
||||||
|
|
||||||
local rv = nil
|
local rv = nil
|
||||||
local file
|
local file
|
||||||
local rom_size = console_opts["prg_rom_size_kb"]
|
local rom_size = console_opts["rom_size_mbit"] * 128
|
||||||
local wram_size = console_opts["wram_size_kb"]
|
local wram_size = console_opts["wram_size_kb"]
|
||||||
local mirror = console_opts["mirror"]
|
local mirror = console_opts["mirror"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ const char *HELP = "Usage: inlretro [options]\n\n"\
|
||||||
" -v [verify_filename]\tIf provided, writeback written rom to this filename\n"
|
" -v [verify_filename]\tIf provided, writeback written rom to this filename\n"
|
||||||
" -w [wram_size_kb]\tNES-only, size of WRAM in kb\n"\
|
" -w [wram_size_kb]\tNES-only, size of WRAM in kb\n"\
|
||||||
" -x [prg_rom_size_kb]\tNES-only, size of PRG-ROM in kb\n"\
|
" -x [prg_rom_size_kb]\tNES-only, size of PRG-ROM in kb\n"\
|
||||||
" -y [chr_rom_size_kb]\tNES-only, size of CHR-ROM in kb\n";
|
" -y [chr_rom_size_kb]\tNES-only, size of CHR-ROM in kb\n"\
|
||||||
|
" -z [rom_size_mbit]\tSize of ROM in megabits, non-NES systems.";
|
||||||
|
|
||||||
// Struct used to control functionality.
|
// Struct used to control functionality.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -47,6 +48,8 @@ typedef struct {
|
||||||
int prg_rom_size_kb;
|
int prg_rom_size_kb;
|
||||||
int wram_size_kb;
|
int wram_size_kb;
|
||||||
|
|
||||||
|
// General Functionality
|
||||||
|
int rom_size_mbit;
|
||||||
char *dump_filename;
|
char *dump_filename;
|
||||||
char *program_filename;
|
char *program_filename;
|
||||||
char *ramdump_filename;
|
char *ramdump_filename;
|
||||||
|
|
@ -66,7 +69,7 @@ int isValidROMSize(int x, int min) {
|
||||||
INLOptions* parseOptions(int argc, char *argv[]) {
|
INLOptions* parseOptions(int argc, char *argv[]) {
|
||||||
// lower case flags suggested for average user
|
// lower case flags suggested for average user
|
||||||
|
|
||||||
const char *FLAG_FORMAT = "a:b:hc:d:m:p:s:v:w:x:y:";
|
const char *FLAG_FORMAT = "a:b:hc:d:m:p:s:v:w:x:y:z:";
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
// opterr = 0;
|
// opterr = 0;
|
||||||
|
|
@ -101,6 +104,7 @@ INLOptions* parseOptions(int argc, char *argv[]) {
|
||||||
case 'w': opts->wram_size_kb = atoi(optarg); break;
|
case 'w': opts->wram_size_kb = atoi(optarg); break;
|
||||||
case 'x': opts->prg_rom_size_kb = atoi(optarg); break;
|
case 'x': opts->prg_rom_size_kb = atoi(optarg); break;
|
||||||
case 'y': opts->chr_rom_size_kb = atoi(optarg); break;
|
case 'y': opts->chr_rom_size_kb = atoi(optarg); break;
|
||||||
|
case 'z': opts->rom_size_mbit = atoi(optarg); break;
|
||||||
case '?':
|
case '?':
|
||||||
if(
|
if(
|
||||||
( optopt == 'c' )
|
( optopt == 'c' )
|
||||||
|
|
@ -198,6 +202,9 @@ lua_State *lua_init(INLOptions *opts) {
|
||||||
lua_pushstring(L, opts->ramwrite_filename);
|
lua_pushstring(L, opts->ramwrite_filename);
|
||||||
lua_setglobal(L, "ramwrite_filename");
|
lua_setglobal(L, "ramwrite_filename");
|
||||||
|
|
||||||
|
lua_pushinteger(L, opts->rom_size_mbit);
|
||||||
|
lua_setglobal(L, "rom_size_mbit");
|
||||||
|
|
||||||
lua_pushinteger(L, opts->wram_size_kb);
|
lua_pushinteger(L, opts->wram_size_kb);
|
||||||
lua_setglobal(L, "nes_wram_size_kb");
|
lua_setglobal(L, "nes_wram_size_kb");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue