summaryrefslogtreecommitdiffstatshomepage
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/boot.lua2
-rw-r--r--plugins/cheat/init.lua238
-rw-r--r--plugins/cheatfind/init.lua6
-rw-r--r--plugins/hiscore/hiscore.dat24
4 files changed, 164 insertions, 106 deletions
diff --git a/plugins/boot.lua b/plugins/boot.lua
index 52c56912a0f..09be30ee401 100644
--- a/plugins/boot.lua
+++ b/plugins/boot.lua
@@ -22,7 +22,7 @@ function lfs.env_replace(str)
end
_G._ = emu.lang_translate
-
+_G.emu.plugin = {} -- table to contain plugin interfaces
-- substitute environment variables in the plugins path from options
local dirs = lfs.env_replace(manager:options().entries.pluginspath:value())
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua
index 4c97c321d6b..3fa625fb4d3 100644
--- a/plugins/cheat/init.lua
+++ b/plugins/cheat/init.lua
@@ -193,8 +193,6 @@ function cheat.startplugin()
return
end
- local function is_oneshot(cheat) return cheat.script and not cheat.script.run and not cheat.script.off end
-
local function run_if(cheat, func)
if func then
local stat, err = pcall(func)
@@ -293,7 +291,7 @@ function cheat.startplugin()
end
local function bpset(cheat, dev, addr, func)
- if is_oneshot(cheat) then
+ if cheat.is_oneshot then
error("bpset not permitted in oneshot cheat")
return
end
@@ -302,7 +300,7 @@ function cheat.startplugin()
end
local function wpset(cheat, dev, space, wptype, addr, len, func)
- if is_oneshot(cheat) then
+ if cheat.is_oneshot then
error("wpset not permitted in oneshot cheat")
return
end
@@ -333,7 +331,7 @@ function cheat.startplugin()
local function input_trans(list)
local xlate = { start = {}, stop = {}, last = 0 }
local function errout(port, field)
- cheat.enabled = false
+ cheat:set_enabled(false)
error(port .. field .. " not found")
return
end
@@ -369,7 +367,7 @@ function cheat.startplugin()
end
local function input_run(cheat, list)
- if not is_oneshot(cheat) then
+ if not cheat.is_oneshot then
cheat.enabled = false
error("input_run only allowed in one shot cheats")
return
@@ -379,6 +377,72 @@ function cheat.startplugin()
inputs[#inputs + 1] = list
end
+ local function param_calc(param)
+ if param.item then
+ if not param.item[param.index] then -- uh oh
+ param.index = 1
+ end
+ param.value = param.item[param.index].value
+ return
+ end
+ param.value = param.min + (param.step * (param.index - 1))
+ if param.value > param.max then
+ param.value = param.max
+ end
+ end
+
+ -- return is current state, ui change
+ local function set_enabled(cheat, state)
+ if cheat.is_oneshot then
+ if state then
+ if cheat.parameter and cheat.script.change and cheat.parameter.index ~= 0 then
+ param_calc(cheat.parameter)
+ cheat.cheat_env.param = cheat.parameter.value
+ cheat.script.change()
+ elseif not cheat.parameter and cheat.script.on then
+ cheat.script.on()
+ end
+ end
+ return false, false
+ end
+ if cheat.enabled == state then
+ return state, false
+ end
+ if not state then
+ cheat.enabled = false
+ run_if(cheat, cheat.script.off)
+ bwpclr(cheat)
+ else
+ cheat.enabled = true
+ run_if(cheat, cheat.script.on)
+ end
+ return state, true
+ end
+
+ -- return is current index, ui change
+ local function set_index(cheat, index)
+ local param = cheat.parameter
+ local oldindex = param.index
+ if (param.index < 0) or (param.index >= param.last) or (param.index == index) then
+ return param.index, false
+ end
+ param.index = index
+ if index == 0 then
+ cheat.cheat_env.param = param.min
+ cheat:set_enabled(false)
+ else
+ if oldindex == 0 then
+ cheat:set_enabled(true)
+ end
+ param_calc(param)
+ cheat.cheat_env.param = param.value
+ if not cheat.is_oneshot then
+ run_if(cheat, cheat.script.change)
+ end
+ end
+ return index, true
+ end
+
local function parse_cheat(cheat)
cheat.cheat_env = { draw_text = draw_text,
draw_line = draw_line,
@@ -396,6 +460,9 @@ function cheat.startplugin()
{ insert = table.insert,
remove = table.remove } }
cheat.enabled = false
+ cheat.set_enabled = set_enabled;
+ cheat.get_enabled = function(cheat) return cheat.enabled end
+ cheat.is_oneshot = cheat.script and not cheat.script.run and not cheat.script.off
-- verify scripts are valid first
if not cheat.script then
@@ -500,6 +567,17 @@ function cheat.startplugin()
if not param then
return
end
+ cheat.set_index = set_index;
+ cheat.set_value = function(cheat, value)
+ local idx = ((value - cheat.parameter.min) / cheat.parameter.step) + 1
+ local chg = false
+ if math.integer(idx) == idx then
+ idx, chg = cheat:set_index(idx)
+ end
+ return cheat.parameter.value, chg
+ end
+ cheat.get_index = function(cheat) return cheat.parameter.index end
+ cheat.get_value = function(cheat) return cheat.parameter.value end
param.min = tonumber(param.min) or 0
param.max = tonumber(param.max) or #param.item
param.step = tonumber(param.step) or 1
@@ -508,7 +586,7 @@ function cheat.startplugin()
if not item.value then
item.value = (count * param.step) + param.min
else
- item.value = tonumber(item.value)
+ item.value = tonumber(item.value)
end
end
param.last = #param.item
@@ -579,7 +657,7 @@ function cheat.startplugin()
end
menu[num][2] = ""
menu[num][3] = "off"
- elseif is_oneshot(cheat) then
+ elseif cheat.is_oneshot then
menu[num][2] = _("Set")
menu[num][3] = 0
else
@@ -593,7 +671,7 @@ function cheat.startplugin()
end
else
if cheat.parameter.index == 0 then
- if is_oneshot(cheat) then
+ if cheat.is_oneshot then
menu[num][2] = _("Set")
else
menu[num][2] = _("Off")
@@ -640,22 +718,12 @@ function cheat.startplugin()
hotkeymenu = true
elseif index == 3 then
for num, cheat in pairs(cheats) do
- if cheat.enabled then
- run_if(cheat, cheat.script.off)
- bwpclr(cheat)
- end
- cheat.enabled = false
- if cheat.parameter then
- cheat.parameter.value = cheat.parameter.min
- cheat.parameter.index = 0
- end
+ cheat:set_enabled(false)
+ cheat:set_index(0)
end
elseif index == 4 then
for num, cheat in pairs(cheats) do
- if cheat.enabled then
- run_if(cheat, cheat.script.off)
- bwpclr(cheat)
- end
+ cheat:set_enabled(false)
end
cheats = load_cheats()
for num, cheat in pairs(cheats) do
@@ -666,20 +734,6 @@ function cheat.startplugin()
return true
end
- local function param_calc(param)
- if param.item then
- if not param.item[param.index] then -- uh oh
- param.index = 1
- end
- param.value = param.item[param.index].value
- return
- end
- param.value = param.min + (param.step * (param.index - 1))
- if param.value > param.max then
- param.value = param.max
- end
- end
-
local cheat = cheats[index]
if not cheat then
return false
@@ -690,72 +744,37 @@ function cheat.startplugin()
end
elseif event == "left" then
if cheat.parameter then
- local param = cheat.parameter
- if param.index == 1 then
- param.index = 0
- cheat.enabled = false
- cheat.cheat_env.param = param.min
- run_if(cheat, cheat.script.off)
- bwpclr(cheat)
- return true
- elseif param.index == 0 then
- return false
- end
- param.index = param.index - 1
- param_calc(param)
- cheat.cheat_env.param = param.value
- if not is_oneshot(cheat) then
- run_if(cheat, cheat.script.change)
- end
- return true
+ local idx, chg = cheat:set_index(cheat:get_index() - 1)
+ return chg
else
- if cheat.enabled and not is_oneshot(cheat) then
- cheat.enabled = false
- run_if(cheat, cheat.script.off)
- bwpclr(cheat)
- return true
+ if not cheat.is_oneshot then
+ return cheat:set_enabled(false)
end
return false
end
elseif event == "right" then
if cheat.parameter then
- local param = cheat.parameter
- if param.index == 0 then
- cheat.enabled = true
- run_if(cheat, cheat.script.on)
- elseif param.index == param.last then
- return false
- end
- param.index = param.index + 1
- param_calc(param)
- cheat.cheat_env.param = param.value
- if not is_oneshot(cheat) then
- run_if(cheat, cheat.script.change)
- end
- return true
+ local idx, chg = cheat:set_index(cheat:get_index() + 1)
+ return chg
else
- if not cheat.enabled and not is_oneshot(cheat) then
- cheat.enabled = true
- run_if(cheat, cheat.script.on)
- return true
+ if not cheat.is_oneshot then
+ local state, chg = cheat:set_enabled(true)
+ return chg
end
return false
end
elseif event == "select" then
- if is_oneshot(cheat) then
- if cheat.parameter and cheat.script.change and cheat.parameter.index ~= 0 then
- param_calc(cheat.parameter)
- cheat.cheat_env.param = cheat.parameter.value
- cheat.script.change()
- local subtext
+ if cheat.is_oneshot then
+ cheat:set_enabled(true)
+ if cheat.parameter and cheat.script.change and cheat:get_index() ~= 0 then
+ local itemtext
if cheat.parameter.item then
- subtext = cheat.parameter.item[cheat.parameter.index]
+ itemtext = cheat.parameter.item[cheat.parameter.index].text
else
- subtext = cheat.parameter.value
+ itemtext = cheat.parameter.value
end
- manager:machine():popmessage(string.format(_("Activated: %s = %s"), cheat.desc, subtext))
+ manager:machine():popmessage(string.format(_("Activated: %s = %s"), cheat.desc, itemtext))
elseif not cheat.parameter and cheat.script.on then
- cheat.script.on()
manager:machine():popmessage(string.format(_("Activated: %s"), cheat.desc))
end
end
@@ -810,7 +829,7 @@ function cheat.startplugin()
if cheat.hotkeys and cheat.hotkeys.keys then
if manager:machine():input():seq_pressed(cheat.hotkeys.keys) then
if not cheat.hotkeys.pressed then
- if is_oneshot(cheat) then
+ if cheat.is_oneshot then
if not run_if(cheat, cheat.script.change) then
run_if(cheat, cheat.script.on)
end
@@ -886,7 +905,46 @@ function cheat.startplugin()
end
function ce.get(index)
- return cheats[index]
+ local cheat = cheats[index]
+ if not cheat then
+ return nil
+ end
+ local intf = {
+ get_enabled = function() return cheat:get_enabled() end,
+ set_enabled = function(status) return cheat:set_enabled(status) end,
+ desc = cheat.desc,
+ is_oneshot = cheat.is_oneshot,
+ comment = cheat.comment,
+ get_hotkeys = function() if cheat.hotkeys then return cheat.hotkeys.keys end return nil end,
+ set_hotkeys = function(seq) cheat.hotkeys = { pressed = false, keys = manager:machine():input():seq_clean(seq) } end
+ }
+ if cheat.script then
+ intf.script = {}
+ if cheat.script.on then intf.script.on = true end
+ if cheat.script.off then intf.script.off = true end
+ if cheat.script.run then intf.script.run = true end
+ if cheat.script.change then intf.script.change = true end
+ end
+
+ if cheat.parameter then
+ intf.parameter = {}
+ intf.get_value = function() return cheat:get_value() end
+ intf.set_value = function(value) return cheat:set_value(value) end
+ intf.get_index = function() return cheat:get_index() end
+ intf.set_index = function(index) return cheat:set_index(index) end
+ intf.parameter.min = cheat.parameter.min
+ intf.parameter.max = cheat.parameter.max
+ intf.parameter.step = cheat.parameter.step
+ if cheat.parameter.item then
+ intf.parameter.item = {}
+ for idx, item in pairs(cheat.parameter.item) do
+ intf.parameter.item[idx] = {}
+ intf.parameter.item[idx].text = cheat.parameter.item[idx].text
+ intf.parameter.item[idx].value = cheat.parameter.item[idx].value
+ end
+ end
+ end
+ return intf
end
function ce.list()
@@ -897,7 +955,7 @@ function cheat.startplugin()
return list
end
- _G.ce = ce
+ _G.emu.plugin.cheat = ce
end
diff --git a/plugins/cheatfind/init.lua b/plugins/cheatfind/init.lua
index 62b11e8970f..729aed26cb0 100644
--- a/plugins/cheatfind/init.lua
+++ b/plugins/cheatfind/init.lua
@@ -251,7 +251,7 @@ function cheatfind.startplugin()
return cheat.compnext(newdata, olddata, oldmatch, oper, format, val, bcd, step)
end
- _G.cf = cheat
+ _G.emu.plugin.cheatfind = cheat
local devtable = {}
local devsel = 1
local devcur = 1
@@ -937,10 +937,10 @@ function cheatfind.startplugin()
cheat.script.run = "cpu:write_" .. wid .. "(" .. match.addr .. "," .. pokevalue .. ")"
end
if match.mode == 1 then
- if not _G.ce then
+ if not emu.plugin.cheat then
manager:machine():popmessage(_("Cheat engine not available"))
else
- _G.ce.inject(cheat)
+ emu.plugin.cheat.inject(cheat)
end
elseif match.mode == 2 then
cheat_save = {}
diff --git a/plugins/hiscore/hiscore.dat b/plugins/hiscore/hiscore.dat
index 12d6a38c38e..05c2ee79b54 100644
--- a/plugins/hiscore/hiscore.dat
+++ b/plugins/hiscore/hiscore.dat
@@ -5434,9 +5434,9 @@ sidetrac:
venture:
-venture2:
-venture2b:
venture4:
+venture5a:
+venture5b:
@:maincpu,program,0380,23,00,53
@@ -5449,10 +5449,10 @@ fax2:
;@s:expro02.cpp
galsnew:
-galsnewu:
galsnewj:
galsnewk:
galsnewt:
+galsnewu:
@:maincpu,program,c825b6,64,30,31
@@ -7218,7 +7218,7 @@ hvyunitu:
roadf:
roadf2:
-roadfh
+roadfh:
roadfu:
@:maincpu,program,3bd0,10a,01,01
@:maincpu,program,3066,3,01,00
@@ -8202,8 +8202,8 @@ dbreed:
;dbreedm72:******dragon breed (m72 pcb version)
+dbreedjm72:
dbreedm72:
-dbreedm72j:
@:maincpu,program,9096a,03,58,00
@:maincpu,program,90990,82,58,2e
@:maincpu,program,90950,01,06,06
@@ -11246,7 +11246,7 @@ ketb:
@:maincpu,program,801093,1,30,30
-photoy2k102:
+photoy2k102j:
photoy2k104:
@:maincpu,program,80a306,1,12,12
@:maincpu,program,813452,78,49,40
@@ -11284,16 +11284,16 @@ orlegend105k:
@:maincpu,program,811918,d4,49,b0
-drgw2hk:
-@:maincpu,program,80f13a,46,49,40
-
-
;********Dragon World II (ver. 110X, Export)
drgw2:
-dw2v100x:
+drgw2100x:
@:maincpu,program,80caf8,46,49,40
+drgw2100hk:
+@:maincpu,program,80f13a,46,49,40
+
+
;@s:phoenix.cpp
; fenix is not working yet ;[Special thanks to Cananas for enhancing this entry]
@@ -18091,7 +18091,7 @@ maydayb:
;joustr:******joust (solid red label)
joust:
joustr:
-joustwr:
+jousty:
@:maincpu,program,cfa4,54,f1,f5