Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/Assets/Lua/SNES/Megaman X3.lua
2 views
1
--Author Pasky13
2
3
-- Some bogus boxes may appear
4
-- because background objects are
5
-- sometimes used where enemy structures
6
-- are present in memory.
7
8
---------------
9
----GLOBALS----
10
---------------
11
local pbase = 0x9D8
12
local px = pbase +0x5
13
local py = pbase +0x8
14
local cx = 0x1E5D
15
local cy = 0x1E60
16
local xm
17
local ym
18
19
---------------
20
----TOGGLES----
21
---------------
22
local draw_megaman = true
23
local draw_enemies = true
24
local draw_hpvalues = true
25
local draw_projectiles = true
26
27
memory.usememorydomain("CARTROM")
28
29
local function megaman()
30
31
local camx = mainmemory.read_u16_le(cx)
32
local camy = mainmemory.read_u16_le(cy)
33
local x = mainmemory.read_u16_le(px) - camx
34
local y = mainmemory.read_u16_le(py) - camy
35
local facing = mainmemory.read_u8(pbase + 0x11)
36
local boxpointer = mainmemory.read_u16_le(pbase + 0x20) + 0x28000
37
local xoff = memory.read_s8(boxpointer + 0)
38
local yoff = memory.read_s8(boxpointer + 1)
39
local xrad = memory.read_u8(boxpointer + 2)
40
local yrad = memory.read_u8(boxpointer + 3)
41
42
if facing > 0x45 then
43
xoff = xoff * -1
44
end
45
46
gui.drawBox(x + xoff +xrad,y + yoff + yrad, x + xoff - xrad, y + yoff - yrad,0xFF0000FF,0x400000FF)
47
end
48
49
local function enemies()
50
51
local x
52
local xoff
53
local xrad
54
local y
55
local yoff
56
local yrad
57
local camx = mainmemory.read_u16_le(cx)
58
local camy = mainmemory.read_u16_le(cy)
59
local base
60
local boxpointer
61
local facing
62
local fill
63
local outl
64
local start = 0xD18
65
local oend = 31
66
67
for i = 0, oend,1 do
68
69
base = start + (i * 0x40)
70
71
if i == 0 then
72
base = start
73
end
74
75
if mainmemory.read_u8(base) ~= 0 and mainmemory.read_u8(base + 0x27) ~= 128 then
76
77
if i > 14 and i < 25 then
78
if draw_projectiles == true then
79
fill = 0x40FFFFFF
80
outl = 0xFFFFFFFF
81
else
82
fill = 0x00000000
83
outl = 0x00000000
84
end
85
else
86
fill = 0x40FF0000
87
outl = 0xFFFF0000
88
end
89
90
if i > 23 then
91
fill = 0x40FFFF00
92
outl = 0xFFFFFF00
93
end
94
95
facing = mainmemory.read_u8(base + 0x11)
96
x = mainmemory.read_u16_le(base + 5) - camx
97
y = mainmemory.read_u16_le(base + 8) - camy
98
boxpointer = mainmemory.read_u16_le(base +0x20) + 0x28000
99
xoff = memory.read_s8(boxpointer + 0)
100
yoff = memory.read_s8(boxpointer + 1)
101
xrad = memory.read_u8(boxpointer + 2)
102
yrad = memory.read_u8(boxpointer + 3)
103
104
if facing > 0x45 then
105
xoff = xoff * -1
106
end
107
108
109
--gui.text(x,y,string.format("%X",base)) -- Debug
110
gui.drawBox(x + xoff +xrad,y + yoff + yrad, x + xoff - xrad, y + yoff - yrad,outl, fill)
111
112
if draw_hpvalues == true and mainmemory.read_u8(base+0x27) > 0 and mainmemory.read_u8(base+0x27) ~= 128 then
113
if i < 15 or i > 20 then
114
gui.text((x-5) * xm,(y-5) * ym,"HP: " .. mainmemory.read_u8(base+0x27))
115
end
116
end
117
end
118
end
119
end
120
121
local function scaler()
122
xm = client.screenwidth() / 256
123
ym = client.screenheight() / 224
124
end
125
126
while true do
127
scaler()
128
if draw_megaman == true then
129
megaman()
130
end
131
if draw_enemies == true then
132
enemies()
133
end
134
emu.frameadvance()
135
end
136