Last-Minute-Creations / AmiVikings2

Clean room implementation of Lost Vikings 2 for Classic Amigas
Mozilla Public License 2.0
3 stars 0 forks source link

How does the heightmap works? #2

Open tehKaiN opened 2 years ago

tehKaiN commented 2 years ago

Are there only 1px slopes (45deg) or some more variants?

tehKaiN commented 2 years ago

using SNES9x, I've found two memory offsets which contain the Erik's position:

7E0E31, 2 bytes: position component X 7E0F99, 2 bytes: position component Y

I've then made those address display and mapped the whole first level:

obraz

the height is as follows:

x -> y
0..143 -> 127

144 -> 128
146 -> 129
148 -> 130
150 -> 131
151 -> 132
152 -> 132
153 -> 132
154 -> 133
156 -> 134
158 -> 135
159 -> 135

160 -> 136
161 -> 136
162 -> 137
163 -> 137
164 -> 138
165 -> 138
166 -> 139
167 -> 139
168 -> 140
169 -> 140
170 -> 141
171 -> 141
172 -> 142
173 -> 142
174 -> 143
175 -> 143

176 -> 144
177 -> 145
178 -> 146
179 -> 147
180 -> 148
181 -> 149
182 -> 150
183 -> 151
184 -> 152
185 -> 153
186 -> 154
187 -> 155
188 -> 156
189 -> 157

190 -> 158
191 -> 159
192 -> 160
193 -> 160
194 -> 161
195 -> 161
196 -> 162
197 -> 162
198 -> 163
199 -> 163
200 -> 164
201 -> 165
202 -> 165
203 -> 165
204 -> 166
205 -> 166

206 -> 167
207 -> 167
208 -> 168
209 -> 168
210 -> 169
211 -> 169
212 -> 170
213 -> 170
214 -> 171
215 -> 171
216 -> 172
217 -> 172
218 -> 173
219 -> 173
220 -> 174
221 -> 174

222..271 -> 175

272 -> 175
273 -> 174
274 -> 173
275 -> 172
276 -> 171
277 -> 170
278 -> 169
279 -> 168
280 -> 167
281 -> 166
282 -> 165
283 -> 164
284 -> 163
285 -> 162
286 -> 161
287 -> 160

288 -> 159
289 -> 158
290 -> 157
291 -> 156
292 -> 155
293 -> 154
294 -> 153
295 -> 152
296 -> 151
297 -> 150
298 -> 149
299 -> 148
300 -> 147
301 -> 146
302 -> 145
303 -> 144

304 -> 143
305 -> 143
306 -> 142
307 -> 142
308 -> 141
309 -> 141
310 -> 140
311 -> 140
312 -> 139
313 -> 139
314 -> 138
315 -> 138
316 -> 137
317 -> 137
318 -> 136
319 -> 136

320 -> 135
321 -> 135
322 -> 134
323 -> 134
324 -> 133
325 -> 133
326 -> 132
327 -> 132
328 -> 131
329 -> 131
330 -> 130
331 -> 130
332 -> 129
333 -> 129
334 -> 128
335 -> 128

336 -> 127
337 -> 126
338 -> 125
339 -> 124
340 -> 123
341 -> 122
342 -> 121
343 -> 120
344 -> 119
345 -> 118
346 -> 117
345 -> 116
348 -> 115
349 -> 114
350 -> 113
351 -> 112

352..502 -> 111

Looks like there are different kinds of slopes:

The bumpy one shows that there may be more non-trivial slope shapes. Looks like there's no other way than either datamine those or map all the levels.

EDIT: also, 7E0BD9 seems to be a better watch - the y pos 96 at start seems to better suit the y position measured from the start of HUD. It changes in same pace as value at 7E0F99, it's just smaller by 31.

lv2_erik_pos.txt

tehKaiN commented 2 years ago

EDIT: also, 7E0BD9 seems to be a better watch - the y pos 96 at start seems to better suit the y position measured from the start of HUD. It changes in same pace as value at 7E0F99, it's just smaller by 31.

When taking a screen grab of Erik jumping in the first level, the Y distance between "?" box and the hud is exactly 96 pixels. This box starts exactly at the viking's height, thus the 96 value is viking Y position measured from his top.

Addition of 31 to get the 127 value indicates that the game probably checks the collision with the tile which the viking is displayed on, not the next tile. Or perhaps this value is used for some other check, not necessarily the Y collision.

Also, I've looked at the tilemap viewer in mesen and it appears that the vikings in start position aren't sinking in a ground tiles for 1px, they are perfectly tile-aligned.