Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/Assets/Lua/NES/Holy Diver.lua
2 views
1
-- Author Pasky13
2
3
local camx = 0x38F
4
local camy = 0x3CF
5
6
local plife = 0x440
7
local px = 0x370
8
local py = 0x3A0
9
10
local ex = 0x370
11
local ey = 0x3A0
12
13
--Configurable player box
14
local pxrad = 6 -- Only use multiples of 2 and no higher than 6
15
16
local function hex(val)
17
val = string.format("%X",val)
18
return val
19
end
20
21
local function draw_axis(x,y,color)
22
gui.line(x,y-4,x,y+4,color)
23
gui.line(x-4,y,x+4,y,color)
24
end
25
26
local function lookup(etype,i) -- this is really messy GIANT if else statement incoming
27
local box = {0,0,0,0} -- xoff,yoff,xrad,yrad
28
if etype == 0xF then
29
box = {0x06,0x18,0x0C,0x18}
30
elseif etype == 0x4A then
31
box = {0x1C,0x0C,0x38,0x18}
32
elseif etype == 0x1B then
33
box = {0x08,0x08,0x10,0x10}
34
elseif etype == 0x13 then
35
box = {0x08,0x10,0x10,0x20}
36
elseif etype == 0x3F then
37
box = {0x0C,0x38,0x18,0x38}
38
elseif etype == 0x40 then
39
box = {0x07,0x07,0x0E,0x0E}
40
elseif etype == 0x12 then
41
box = {0x04,0x04,0x08,0x08}
42
elseif etype == 0x36 then
43
box = {0x10,0x10,0x20,0x20}
44
elseif etype == 0x30 then
45
box = {0x0C,0x10,0x18,0x18}
46
elseif etype == 0x2C then
47
box = {0x04,0x08,0x08,0x08}
48
elseif etype == 0x2B then
49
box = {0x08,0x08,0x10,0x18}
50
elseif etype == 0x24 then
51
box = {0x08,0x08,0x10,0x10}
52
elseif etype == 0x25 then
53
box = {0x04,0x08,0x08,0x08}
54
elseif etype == 0x46 then
55
box = {0x18,0x20,0x28,0x20}
56
elseif etype == 0x1E then
57
box = {0x08,0x08,0x10,0x08}
58
elseif etype == 0x50 then
59
box = {0x10,0x00,0x40,0x60}
60
elseif etype == 0x51 then
61
box = {0x08,0x0A,0x10,0x0A}
62
elseif etype == 0x32 then
63
box = {0x08,0x10,0x10,0x10}
64
elseif etype == 0x33 then
65
box = {0x04,0x04,0x08,0x08}
66
elseif etype == 0x42 then
67
box = {0x04,0x04,0x08,0x08}
68
elseif etype == 0x26 then
69
box = {0x09,0x0D,0x15,0x15}
70
elseif etype == 0x27 then
71
box = {0x10,0x18,0x20,0x20}
72
elseif etype == 0x28 then
73
box = {0x04,0x04,0x08,0x08}
74
elseif etype == 0x53 then
75
box = {0x0C,0x20,0x18,0x28}
76
elseif etype == 0x54 then
77
box = {0x03,0x18,0x08,0x18}
78
elseif etype == 0x48 then
79
box = {0x0C,0x18,0x18,0x18}
80
elseif etype == 0x49 then
81
box = {0x08,0x08,0x08,0x08}
82
elseif etype == 0x4A then
83
box = {0x1C,0x0C,0x38,0x18}
84
elseif etype == 0x4B then
85
box = {0x05,0x04,0x08,0x08}
86
elseif etype == 0x3D then
87
box = {0x06,0x06,0x0C,0x0C}
88
elseif etype == 0x3E then
89
box = {0x06,0x06,0x0C,0x0C}
90
elseif etype == 0x38 then
91
box = {0x10,0x34,0x20,0x20}
92
elseif etype == 0x57 then
93
box = {0x00,0x00,0x48,0x60}
94
elseif etype == 0x4D then
95
box = {0x10,0x00,0x20,0x38}
96
elseif etype == 0x59 then
97
box = {0x0C,0x10,0x18,0x18}
98
elseif etype == 0x58 then
99
box = {0x08,0x08,0x10,0x10}
100
elseif etype == 0x5E then
101
box = {0x08,0x10,0x10,0x10}
102
elseif etype == 0x37 then
103
box = {0x10,0x28,0x24,0x50}
104
elseif etype == 0x5D then
105
box = {0x04,0x04,0x08,0x08}
106
elseif etype == 0x5C then
107
box = {0x08,0x08,0x10,0x10}
108
elseif etype == 0x5B then
109
box = {0x0C,0x00,0x18,0x10}
110
elseif etype == 0x4C then -- Mutating projectile
111
o = mainmemory.read_u8(0x470 + i)
112
dt = {0x08,0x0C,0x10,0x10,0x18,0x20}
113
box = {0x04,0x08,dt[1+o],dt[4+o]}
114
end
115
116
return box
117
end
118
119
local function player()
120
local pos = mainmemory.read_u8(0x300)
121
local cx = mainmemory.read_u8(camx) + (mainmemory.read_u8(camx + 0x10) * 256)
122
local cy = mainmemory.read_u8(camy) + (mainmemory.read_u8(camy + 0x10) * 256)
123
local x = mainmemory.read_u8(px) + (mainmemory.read_u8(px + 0x10) * 256) - cx
124
local y = mainmemory.read_u8(py) + (mainmemory.read_u8(py + 0x10) * 256) - cy
125
local pyrad = 0x1C
126
127
if pos == 0x03 or pos == 0x06 then
128
pyrad = 0x13
129
end
130
131
gui.drawBox(x - (pxrad / 2), y, x + (pxrad / 2), y - pyrad,0xFF0000FF,0x350000FF)
132
end
133
134
local function enemy()
135
local cx = mainmemory.read_u8(camx) + (mainmemory.read_u8(camx + 0x10) * 256)
136
local cy = mainmemory.read_u8(camy) + (mainmemory.read_u8(camy + 0x10) * 256)
137
local etype
138
local box = {0,0,0,0}
139
140
for i = 6, 14, 1 do
141
etype = mainmemory.read_u8(0x300 + i)
142
local fill = 0x40FF0000
143
local outl = 0xFFFF0000
144
145
if etype ~= 0xFF then
146
local x = mainmemory.read_u8(ex + i) + (mainmemory.read_u8(ex + i + 0x10) * 256) - cx
147
local y = mainmemory.read_u8(ey + i) + (mainmemory.read_u8(ey + i + 0x10) * 256) - cy
148
149
box = lookup(etype,i)
150
151
gui.drawBox(x - box[1],y-box[2],x-box[1]+box[3] - pxrad,y-box[2]+box[4],outl,fill)
152
153
if etype == 0x3F then-- 1st boss
154
--Draw his vuln box
155
local fill = 0x40FFFF00
156
local outl = 0xFFFFFF00
157
box = {0x0C,0x38,0x18,0x18}
158
gui.drawBox(x - box[1],y-box[2],x-box[1]+box[3] - pxrad,y-box[2]+box[4],outl, fill)
159
end
160
end
161
end
162
end
163
164
while true do
165
player()
166
enemy()
167
emu.frameadvance()
168
end
169