Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/Assets/Lua/SNES/Super Castlevania 4.lua
2 views
1
----------------------------
2
----Super Castlevania IV----
3
----------------------------
4
5
--Author Pasky13
6
7
---------------
8
----TOGGLES----
9
---------------
10
11
--Box type toggles
12
local candle = true
13
local enemy = true
14
local player = true
15
16
17
--Center axis toggles
18
local player_axis = false
19
local whip_axis = false
20
local projectile_axis = true
21
local enemy_axis = true
22
local candle_axis = false
23
24
--Hitpoint display
25
local playerhp = true
26
local enemyhp = true
27
28
--Cheats
29
local cheats = false
30
31
------------------
32
---END TOGGLES----
33
------------------
34
35
36
---------------
37
----GLOBALS----
38
---------------
39
40
local pbase = 0x540
41
local ebase = 0x580
42
local wbase = 0x200
43
local pjbase = 0x440
44
45
local ux = 0xA
46
local uy = 0xE
47
48
local uxrad = 0x28
49
local uyrad = 0x2A
50
51
local eactive = 0x10
52
53
local camx = 0x1280
54
local camy = 0x1298
55
56
local elife = 0x06
57
58
local plife = 0x13F4
59
local hearts = 0x13F2
60
local facing = 0x0578
61
local timer = 0x13F0
62
63
local xs = client.screenwidth() / 256
64
local ys = client.screenheight() / 224
65
-------------------
66
----END GLOBALS----
67
-------------------
68
69
local function centeraxis(x,y)
70
gui.drawLine(x,y+2,x,y-2,0xFFFFFFFF)
71
gui.drawLine(x+2,y,x-2,y,0xFFFFFFFF)
72
end
73
74
local function player_hitbox()
75
local x = mainmemory.read_u16_le(pbase+ux) - mainmemory.read_u16_le(camx)
76
local y = mainmemory.read_u16_le(pbase+uy) - mainmemory.read_u16_le(camy)
77
local cr = mainmemory.read_u8(0x576)
78
79
if cr ~= 0x0F then
80
gui.drawBox(x+7,y+27,x-7,y-19,0xFF0000FF,0x400000FF)
81
if playerhp == true then
82
gui.text((x-10) * xs,(y-26) * ys,"HP:" .. mainmemory.read_u8(plife))
83
end
84
else
85
gui.drawBox(x+7,y+cr,x-7,y-cr,0xFF0000FF,0x400000FF)
86
if playerhp == true then
87
gui.text((x-10) * xs,(y-cr-7) * ys,"HP:" .. mainmemory.read_u8(plife))
88
end
89
end
90
91
92
93
if player_axis == true then
94
centeraxis(x,y)
95
end
96
97
end
98
99
local function player_projectiles()
100
local base = 0
101
local x
102
local y
103
local xrad
104
local yrad
105
local oend = 3
106
107
for i = 0,oend,1 do
108
109
base = pjbase + (i * 0x40)
110
111
if i == 0 then
112
base = pjbase
113
end
114
115
if mainmemory.read_u16_le(base) ~= 0 then
116
x = mainmemory.read_u16_le(base+ux) - mainmemory.read_u16_le(camx)
117
y = mainmemory.read_u16_le(base+uy) - mainmemory.read_u16_le(camy)
118
xrad = mainmemory.read_u16_le(base+uxrad)
119
yrad = mainmemory.read_u16_le(base+uyrad)
120
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFFFFFF,0x40FFFFFF)
121
122
if projectile_axis == true then
123
centeraxis(x,y)
124
end
125
126
end
127
128
end
129
end
130
131
local function player_whip()
132
133
local base = 0
134
local x
135
local y
136
local xrad
137
local yrad
138
local oend = 8
139
140
for i = 0,oend,1 do
141
142
base = wbase + (i * 0x40)
143
144
if i == 0 then
145
base = wbase
146
end
147
148
if mainmemory.read_u16_le(base) ~= 0 then
149
x = mainmemory.read_u16_le(base+ux) - mainmemory.read_u16_le(camx)
150
y = mainmemory.read_u16_le(base+uy) - mainmemory.read_u16_le(camy)
151
xrad = mainmemory.read_u16_le(base+uxrad)
152
yrad = mainmemory.read_u16_le(base+uyrad)
153
154
if xrad == 0 and yrad == 0 then
155
if base == 0x0400 then
156
gui.drawBox(x-0x10,y-0x04,x+0x10,y+0x04,0xFFFFFFFF,0x40FFFFFF)
157
else
158
gui.drawBox(x-0x04,y-0x04,x+0x04,y+0x04,0xFFFFFFFF,0x40FFFFFF)
159
end
160
else
161
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFFFFFF,0x40FFFFFF)
162
end
163
164
if whip_axis == true then
165
centeraxis(x,y)
166
end
167
end
168
169
end
170
end
171
172
local function object_hitbox()
173
local base = 0
174
local x
175
local y
176
local xrad
177
local yrad
178
local oend = 36
179
local drawn
180
local life
181
for i = 0,oend,1 do
182
183
base = ebase + (i * 0x40)
184
drawn = false
185
186
if i == 0 then
187
base = ebase
188
elseif
189
base == 0x540 then
190
drawn = true
191
end
192
193
if mainmemory.read_u16_le(base+0x10) == 0x0E then
194
if candle == true then
195
x = mainmemory.read_u16_le(base+ux) - mainmemory.read_u16_le(camx)
196
y = mainmemory.read_u16_le(base+uy) - mainmemory.read_u16_le(camy)
197
xrad = mainmemory.read_u16_le(base+uxrad)
198
yrad = mainmemory.read_u16_le(base+uyrad)
199
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFFD000,0x40FFD000)
200
drawn = true
201
202
if candle_axis == true then
203
centeraxis(x,y)
204
end
205
end
206
207
end
208
209
if mainmemory.read_u16_le(base+0x10) ~= 0 and drawn == false then
210
211
x = mainmemory.read_u16_le(base+ux) - mainmemory.read_u16_le(camx)
212
y = mainmemory.read_u16_le(base+uy) - mainmemory.read_u16_le(camy)
213
xrad = mainmemory.read_u16_le(base+uxrad)
214
yrad = mainmemory.read_u16_le(base+uyrad)
215
life = mainmemory.read_u16_le(base+elife)
216
217
gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFF0000,0x40FF0000)
218
drawn = true
219
220
if enemyhp == true then
221
if life > 0 and life ~= 255 then
222
gui.text((x-10) * xs,(y-yrad-7) * ys,"HP:" .. life)
223
end
224
end
225
if enemy_axis == true then
226
centeraxis(x,y)
227
end
228
end
229
230
231
end
232
end
233
234
local function cheat()
235
memory.writebyte(plife,16)
236
memory.writeword(timer,1024)
237
memory.writebyte(hearts,32)
238
end
239
240
local function scaler()
241
xs = client.screenwidth() / 256
242
ys = client.screenheight() / 224
243
end
244
245
while true do
246
scaler()
247
if player == true then
248
player_hitbox()
249
player_whip()
250
player_projectiles()
251
end
252
253
if enemy == true then
254
object_hitbox()
255
end
256
if cheats == true then
257
cheat()
258
end
259
emu.frameadvance()
260
end
261