Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/Assets/Lua/SNES/Super Metroid.lua
2 views
1
--Author Pasky13
2
3
--Player
4
local px = 0x000AF6
5
local py = 0x000AFA
6
local plife = 0x0009C2
7
--Camera
8
local camx = 0x000911
9
local camy = 0x000915
10
--Text scaler
11
local xs
12
local ys
13
local function Samus()
14
local x = mainmemory.read_u16_le(px) - mainmemory.read_u16_le(camx)
15
local y = mainmemory.read_u16_le(py) - mainmemory.read_u16_le(camy)
16
local xrad = mainmemory.read_u8(0x0AFE)
17
local yrad = mainmemory.read_u8(0x0B00)
18
19
gui.drawBox(x + (xrad * -1), y + (yrad * -1), x+xrad,y+yrad,0xFF0000FF,0x350000FF)
20
21
end
22
23
local function EnemyBoxes()
24
local x = 0
25
local y = 0
26
local xrad = 0
27
local yrad = 0
28
local oend = 20
29
local base = 0xF7A
30
31
for i = 0, oend, 1 do
32
if i > 0 then
33
base = 0xF7A + (i * 0x40)
34
else
35
base = 0xF7A
36
end
37
38
x = mainmemory.read_u16_le(base) - mainmemory.read_u16_le(camx)
39
y = mainmemory.read_u16_le(base+ 4) - mainmemory.read_u16_le(camy)
40
xrad = mainmemory.read_u8(0x0F82 + (i * 0x40))
41
yrad = mainmemory.read_u8(0x0F84 + (i * 0x40))
42
hp = mainmemory.read_u16_le(base + 0x12)
43
44
gui.drawBox(x + (xrad * -1),y + (yrad * -1),x+xrad,y+yrad,0xFFFF0000,0x35FF0000)
45
gui.text((x-5) * xs,(y-5) * ys,"HP: " .. hp)
46
end
47
end
48
49
local function powerbomb()
50
local x = mainmemory.read_u16_le(0xCE2) - mainmemory.read_u16_le(camx)
51
local y = mainmemory.read_u16_le(0xCE4) - mainmemory.read_u16_le(camy)
52
local xrad
53
local yrad
54
55
xrad = bit.band(memory.readbyte(0xCEB),0xFF)
56
yrad = ((xrad / 2) + xrad) / 2
57
gui.drawBox(x + (xrad * -1), y + (yrad * -1),x+xrad,y+yrad,0xFF00FFFF,0x35F00FFF)
58
end
59
60
local function Projectiles()
61
local x
62
local y
63
local xrad
64
local yrad
65
local oend = 8
66
local projxbase = 0xB64
67
local projybase = 0xB78
68
local projxrbase = 0xBB4
69
local projyrbase = 0xBC8
70
71
for i = 0, oend, 1 do
72
73
74
x = mainmemory.read_u16_le(projxbase + (i*2)) - mainmemory.read_u16_le(camx)
75
y = mainmemory.read_u16_le(projybase + (i*2)) - mainmemory.read_u16_le(camy)
76
77
xrad = mainmemory.read_u8(projxrbase + (i * 2))
78
yrad = mainmemory.read_u8(projyrbase + (i * 2))
79
80
gui.drawBox(x + (xrad * -1), y + (yrad * -1), x+xrad,y+yrad,0xFFFFFFFF,0x35FFFFFF)
81
end
82
83
if bit.band(mainmemory.read_u16_le(0xCEB),0xFF) > 0 then
84
powerbomb()
85
end
86
end
87
88
local function scaler()
89
xs = client.screenwidth() / 256
90
ys = client.screenwidth() / 224
91
end
92
93
while true do
94
scaler()
95
Samus()
96
EnemyBoxes()
97
Projectiles()
98
emu.frameadvance()
99
end
100