-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinvaders.lua
More file actions
56 lines (44 loc) · 1.13 KB
/
Copy pathinvaders.lua
File metadata and controls
56 lines (44 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
--mame.exe -autoboot_script invaders.lua -window invaders.zip
local last_tick_time = -10
--local current_coins = 1
local cpu = manager.machine.devices[":maincpu"]
local mem = cpu.spaces["program"]
--print(mem:read_i8(0x20EB))
--mem:read_i8(0x20EB)
local current_coins = os.getenv("MAME_COINS")
local delay = 1
local count = 0
function tick()
-- check if first run / tick
if last_tick_time == -10 then
--mem:write_i8(0x20EB, 0x0001);
-- write $MAME_COINS env variable to credits memory address
mem:write_i8(0x20EB, tonumber(current_coins));
end
if emu.time() < last_tick_time + delay then
return
end
last_tick_time = emu.time()
local playing = mem:read_u8(0x2011)
print (playing)
if playing == 128 then
--print ("playing")
--print (playing)
local coins = mem:read_i8(0x20EB)
if coins ~= current_coins then
if coins == 0 then
--print ("coins")
--print (coins)
count = count + 1
end
end
end
if playing == 0 then
delay = 5
end
if count >= 10 then
manager.machine:exit()
end
current_coins = coins
end
emu.register_frame(tick)