map: Added def macros for various structs
authorLukas Krickl <lukas@krickl.dev>
Fri, 19 Sep 2025 12:32:36 +0000 (14:32 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 19 Sep 2025 12:32:36 +0000 (14:32 +0200)
src/defs.s
src/macros.inc
src/main.s
src/map.s
src/mapobj.s [new file with mode: 0644]
src/wram.s

index 484509944c80ff447829eb395b5b6cbe04be1cfd..43bdf5255c5b874ce56e4f4871bb2918e8f58ecb 100644 (file)
@@ -14,6 +14,7 @@
 #define NULL 0
 
 #define ACTS_MAX 32
+#define MAP_OBJ_MAX 32
 
 #define STACK_BEGIN 0xDFFF
 
@@ -90,7 +91,6 @@
 .se 0
 .de mo_type, 1
 .de mo_flags, 1
-.de mo_page, 1
 .de mo_row, 1
-.de mo_dat, 4
+.de mo_dat, 
 .de mo_size, 0
index 284c601ac55c26549a06be8e67dafbdb58f8621f..a12aabe06b8d057f629b1059bbcb3fa346cd5de7 100644 (file)
@@ -168,3 +168,29 @@ $1:
        dw $6
        dw $7
 #endmacro
+       
+       ; defines a new actor
+       ; inputs:
+       ;               $1: type
+       ;               $2: flags
+       ;               $3: p0
+       ;               $4: hp
+       ;               $5: armor
+#macro actdef
+       .db $1, $2, $3
+       ; placeholder for y and x
+       ; since those are set at runtime
+       .db 0, 0
+       .db $4, $5
+#endmacro
+       
+       ; defines a map object
+       ; inputs:
+       ;               $1: type
+       ;               $2: flags
+       ;               $3: row
+       ;               $4: dat1
+       ;               $5: dat2
+#macro modef
+       .db $1, $2, $3, $4, $5
+#endmacro
index 1a46e01e890b73f2cfa9d2f69b591acc9be7245b..37473bc5f94802f3a1e4865e6047fe2db6918077 100644 (file)
@@ -60,6 +60,7 @@ main:
 #include "ui.s"
 #include "audio.s"
 #include "map.s"
+#include "mapobj.s"
 #include "rowpatterns.s"
 #include "math.s"
 #include "game.s"
index 435355d4aca28df3c68fc6400b93e9bf45168f30..6c25cf5745d6d816c6b67f52e4937f1e0b3a019d 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -10,8 +10,15 @@ map_load:
        call next_vblank_wait
        call lcd_off
 
+       ld a, e 
+       ld [map], a
+       ld a, d
+       ld [map+1], a
+
        call map_tile_banks_load
 
+       call map_page_full_draw
+
        call lcd_on
        call vblank_wait
        call enableinterrupts
@@ -60,9 +67,15 @@ map_tile_banks_load:
        
        ; draws the current row pattern
        ; only call during blank
+       ; also triggers objects 
 map_draw_row:
        ret
-
+       
+       ; draws a full page of the currently selected map
+       ; inputs:
+       ;               [map]
+map_page_full_draw:
+       ret
 
 l1_map:
        mapdef 0, pat_empty, NULL, bank8000, bank8800, bank8C00, bank9000       
diff --git a/src/mapobj.s b/src/mapobj.s
new file mode 100644 (file)
index 0000000..f9803c4
--- /dev/null
@@ -0,0 +1,6 @@
+; map objects are a list of objects
+; a map has a static list of loadable objects
+; when a row is being drawn the next object
+; is checked
+; if the row matches it is loaded into ram and executed
+; when an object is off-screen it is unloded
index 2ebcb352ae92b5cf6e8757486a6d6dc9d3235eb2..7ad3c4543ed9d4425570a015a40a73594c5bb012 100644 (file)
@@ -59,10 +59,15 @@ srand: .adv 2
 ; player_unit (unit 0) is reserved
 player_unit: .adv 0 
 actors: .adv act_size * ACTS_MAX 
+map_objs: .adv mo_size * MAP_OBJ_MAX
 
-       ; current page the map is on
-map_current_page: .adv 1
        ; current row that is being drawn
 map_current_row: .adv 1
        ; current pattern to be drawn
 map_current_pattern: .adv 2
+       
+       ; current map ptr
+map: .adv 2
+       ; ptr to the next map object
+       ; that may be loaded
+map_obj_ptr: .adv 2