diff --git a/host/scripts/app/dict.lua b/host/scripts/app/dict.lua index 43fc8a5..1271288 100644 --- a/host/scripts/app/dict.lua +++ b/host/scripts/app/dict.lua @@ -249,7 +249,7 @@ local function io( opcode, operand, misc, data ) end -- external call for nes dictionary -local function nes( opcode, operand, misc, data ) +local function nes( opcode, operand, misc, data, test_opcode ) assert ( op_nes[opcode] , "\nERROR undefined opcode: " .. opcode .. " must be defined in shared_dict_nes.h") @@ -277,6 +277,16 @@ local function nes( opcode, operand, misc, data ) end --print("error:", error_code, "data_len:", data_len) + --hack to test if running old firmware version for NESmaker legacy compatability + if test_opcode then + --just want to report if opcode succeeded or not + if error_code == err_codes["SUCCESS"] then + return true + else + return false + end + end + assert ( (error_code == err_codes["SUCCESS"]), "\n ERROR!!! problem with opcode: " .. opcode .. " operand: " .. operand .. " misc: " .. misc .. " device error code: " .. error_code) if data_len and data_len ~= (wLength - RETURN_LEN_IDX) then diff --git a/host/scripts/inlretro2.lua b/host/scripts/inlretro2.lua index 6588d6e..f066405 100644 --- a/host/scripts/inlretro2.lua +++ b/host/scripts/inlretro2.lua @@ -73,6 +73,7 @@ function nes_exec(process_opts, console_opts) easynsf = require "scripts.nes.easyNSF", fme7 = require "scripts.nes.fme7", mapper30 = require "scripts.nes.mapper30", + mapper30v2 = require "scripts.nes.mapper30v2", mmc1 = require "scripts.nes.mmc1", mmc3 = require "scripts.nes.mmc3", mmc4 = require "scripts.nes.mmc4", diff --git a/host/scripts/nes/mapper30.lua b/host/scripts/nes/mapper30.lua index 5a59ec6..7a92a3d 100644 --- a/host/scripts/nes/mapper30.lua +++ b/host/scripts/nes/mapper30.lua @@ -7,6 +7,7 @@ local dict = require "scripts.app.dict" local nes = require "scripts.app.nes" local dump = require "scripts.app.dump" local flash = require "scripts.app.flash" +local time = require "scripts.app.time" -- file constants @@ -61,8 +62,8 @@ local function process(process_opts, console_opts) local file -- TODO: Cleanup needed here, support chrrom, make this look more like other mapper scripts. local size = console_opts["prg_rom_size_kb"] - --local filetype = "nes" - local filetype = "bin" + local filetype = "nes" + --local filetype = "bin" --initialize device i/o for NES dict.io("IO_RESET") @@ -203,7 +204,10 @@ local function process(process_opts, console_opts) --flash cart - flash.write_file( file, size, "MAP30", "PRGROM", true ) + print("\nFLASHING the PRG-ROM, will take ~20sec please wait...") + time.start() + flash.write_file( file, size, "MAP30", "PRGROM", false ) + time.report(size) --close file assert(file:close()) diff --git a/host/scripts/nes/mapper30v2.lua b/host/scripts/nes/mapper30v2.lua index 926c17e..a8c541d 100644 --- a/host/scripts/nes/mapper30v2.lua +++ b/host/scripts/nes/mapper30v2.lua @@ -12,6 +12,7 @@ local files = require "scripts.app.files" local ciccom = require "scripts.app.ciccom" local time = require "scripts.app.time" local swim = require "scripts.app.swim" +local mapper30_legacy = require "scripts.nes.mapper30" -- file constants & variables local mapname = "MAP30" @@ -390,6 +391,24 @@ local function flash_prgrom(file, rom_size_KB, debug) end +local function is_old_firmware( debug ) + + if debug then print("checking for old firmware") end + + --check if CIRAM_A10_MIRRORING opcode is present + --this was cut from later versions + local rv + rv = dict.nes("CIRAM_A10_MIRROR", nil, nil, nil, true) + + if debug then + if rv then print("old firmware sensed, running legacy mode") + else print("later firmware sensed, running default scripts") + end + end + + return rv + +end --Cart should be in reset state upon calling this function --this function processes all user requests for this specific board/mapper @@ -408,8 +427,15 @@ local function process(process_opts, console_opts) -- TODO: Cleanup needed here, support chrrom, make this look more like other mapper scripts. local prg_size = console_opts["prg_rom_size_kb"] - --local filetype = "nes" - local filetype = "bin" + local filetype = "nes" + --local filetype = "bin" + + if is_old_firmware(true) then + --call legacy mapper30 script +--local mapper30_legacy = require "scripts.nes.mapper30" + mapper30_legacy.process(process_opts, console_opts) + return + end --initialize device i/o for NES dict.io("IO_RESET") @@ -437,8 +463,8 @@ local function process(process_opts, console_opts) if not rv then return end --test software mirroring switch - rv = test_soft_mir_switch() - if not rv then return end + --rv = test_soft_mir_switch() + --if not rv then return end end @@ -532,7 +558,6 @@ local function process(process_opts, console_opts) --verify flashfile is on the cart if verify then - --for now let's just dump the file and verify manually file = assert(io.open(verifyfile, "wb"))