Skip to content

Commit

Permalink
shouse: default EEPROM values for horizontal games that will flip the…
Browse files Browse the repository at this point in the history
… image. Fixes #767
  • Loading branch information
jotego committed Sep 20, 2024
1 parent ae189d4 commit dc4548b
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 6 deletions.
Binary file added cores/shouse/cfg/bakutotu.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/berabohm.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/berabohmb.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/faceoff.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/mmaze.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/mmaze2.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/shadowld.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/splatter.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/splatter2.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/splatterj.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/youkaidk1.nvm
Binary file not shown.
Binary file added cores/shouse/cfg/youkaidk2.nvm
Binary file not shown.
4 changes: 3 additions & 1 deletion modules/jtframe/doc/jtframe-mra.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ order = [ "maincpu", "soundcpu", "gfx1", "gfx2" ]
# Default NVRAM contents, usually not needed
nvram = {
machines=[ "supports nvram..." ] # NVRAM on all machines by default
data=[
# if a file with the machine or setname and .nvm extension exists in the
# cfg folder, its data will be set as the default NVRAM content
defaults=[
{ machine="...", setname="...", data="00 22 33..." },...
]
# if a ROM region with the name "nvram" exists, and no default data
Expand Down
2 changes: 1 addition & 1 deletion modules/jtframe/src/jtframe/mra/mame2mra.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ func make_mra(machine *MachineXML, cfg Mame2MRA, args Args) (*XMLNode, string, i
}
}
}
make_nvram(&root,machine,cfg)
make_nvram(&root,machine,cfg,args.Def_cfg.Core)
// coreMOD
coremod := make_coreMOD(&root, machine, cfg, args.macros)
// DIP switches
Expand Down
32 changes: 28 additions & 4 deletions modules/jtframe/src/jtframe/mra/nvram.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package mra

import (
"fmt"
"path/filepath"
"os"
)

func make_nvram(root *XMLNode, machine *MachineXML, cfg Mame2MRA) {
func make_nvram(root *XMLNode, machine *MachineXML, cfg Mame2MRA, corename string) {
if cfg.ROM.Nvram.length == 0 { return }
add_nvram := len(cfg.ROM.Nvram.Machines) == 0
if !add_nvram {
Expand All @@ -15,15 +17,37 @@ func make_nvram(root *XMLNode, machine *MachineXML, cfg Mame2MRA) {
}
}
}
if !nvram_verbatim(root, machine,cfg) {
nvram_file(root,machine,cfg)
if !nvram_file(root,machine,cfg,corename) { // look in cfg folder for matching file
if !nvram_verbatim(root, machine,cfg) { // explicit defaults in the TOML
nvram_rom(root,machine,cfg) // get the defaults from MAME
}
}
if add_nvram {
n := root.AddNode("nvram").AddAttr("index", "2")
n.AddIntAttr("size", cfg.ROM.Nvram.length)
}
}

func nvram_file(root *XMLNode, machine *MachineXML, cfg Mame2MRA, core string) bool {
cfgdir := filepath.Join(os.Getenv("JTROOT"),"cores",core,"cfg")
fname := filepath.Join(cfgdir,machine.Name+".nvm")
f, e := os.Open(fname)
if e!=nil {
f.Close()
if machine.Cloneof=="" { return false }
fname := filepath.Join(cfgdir,machine.Cloneof+".nvm")
f, e = os.Open(fname)
if e!= nil {
f.Close()
return false // not found
}
}
f.Close()
rawbytes, e := os.ReadFile(fname)
root.AddNode("rom").AddAttr("index", "2").AddNode("part").SetText("\n" + hexdump(rawbytes, 16))
return true
}

func nvram_verbatim(root *XMLNode, machine *MachineXML, cfg Mame2MRA) bool {
var raw *RawData
for k, each := range cfg.ROM.Nvram.Defaults {
Expand All @@ -46,7 +70,7 @@ func nvram_verbatim(root *XMLNode, machine *MachineXML, cfg Mame2MRA) bool {
return false
}

func nvram_file(root *XMLNode, machine *MachineXML, cfg Mame2MRA) {
func nvram_rom(root *XMLNode, machine *MachineXML, cfg Mame2MRA) {
reg := find_region_cfg(machine,"nvram",cfg,false)
if reg==nil { return }
roms := extract_region(reg, machine.Rom, cfg.ROM.Remove)
Expand Down

0 comments on commit dc4548b

Please sign in to comment.