map: Mapgen now loads the table entries correctly.
authorLukas Krickl <lukas@krickl.dev>
Mon, 6 Jan 2025 07:14:10 +0000 (08:14 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 6 Jan 2025 07:14:10 +0000 (08:14 +0100)
Before this was rather broken and the fact that it did not crash was
just luck. It was not reading room pointers correctly nor was the room
max mask not masking correctly due to an off-by-one-error :^)

maps/base_room4.s
src/map.s

index ec20fa699bbb4ba0ccb06b712d5619334cf09e65..0f5422ade73a438caaa09369cfcc63e6d136777e 100644 (file)
@@ -9,10 +9,10 @@ base_room4_actors:
 .db  1 , 48 , 24 , 0
 .db  1 , 48 , 136 , 0
 .db  1 , 112 , 40 , 0
-.db  1 , 32 , 72 , 0
-.db  1 , 112 , 104 , 0
-.db  1 , 32 , 88 , 0
-.db  1 , 32 , 56 , 0
+.db  0 , 16 , 8 , 0
+.db  0 , 16 , 8 , 0
+.db  0 , 16 , 8 , 0
+.db  0 , 16 , 8 , 0
 base_room4_bg:
 .db 0x60, 0x62, 0x62, 0x64, 0x62, 0x62, 0x66, 0x62, 0x62, 0x68, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x46, 0x40, 0x40, 0x82, 0x82, 0x82, 0x82, 0x40, 0x40, 0xe0, 0x4c, 0x40, 0x82, 0x40, 0x40, 0x40, 0x40, 0x82, 0x40, 0x6a, 0x4c, 0x40, 0x82, 0x40, 0x40, 0x40, 0x40, 0x82, 0x40, 0x6a, 0x48, 0x40, 0x40, 0x40, 0x82, 0x82, 0x40, 0x40, 0x40, 0xe2, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x6c, 0x4a, 0x4a, 0x42, 0x4a, 0x4a, 0x44, 0x4a, 0x4a, 0x6e
 base_room4_flags:
index 61df12e473ddf14103d60cd09ddd4656d752b9e2..9f2be4dad629b341d302999cab9ada6da4f3bb22 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -544,6 +544,7 @@ map_gen_next:
   ld h, a
   ld l, b ; hl = room table max length
   ld a, [hl+] ; hl = first room entry 
+  dec a ; -1 for mask 
   ld b, a ; b = max length of room table
 
   ; c = previous room selection 
@@ -562,6 +563,7 @@ map_gen_next:
   ; store for next iteration 
   ld [mapgen_last_room], a
 
+  add a, a ; a * 2 for ptr offset
   ld b, 0
   ld c, a
   add hl, bc ; base + random offset