From: Lukas Krickl Date: Fri, 19 Sep 2025 12:32:36 +0000 (+0200) Subject: map: Added def macros for various structs X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=bbd72ac2c7269027d60f32b8142e7168d3f6bcaf;p=gbrg%2F.git map: Added def macros for various structs --- diff --git a/src/defs.s b/src/defs.s index 4845099..43bdf52 100644 --- a/src/defs.s +++ b/src/defs.s @@ -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, 2 .de mo_size, 0 diff --git a/src/macros.inc b/src/macros.inc index 284c601..a12aabe 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -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 diff --git a/src/main.s b/src/main.s index 1a46e01..37473bc 100644 --- a/src/main.s +++ b/src/main.s @@ -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" diff --git a/src/map.s b/src/map.s index 435355d..6c25cf5 100644 --- 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 index 0000000..f9803c4 --- /dev/null +++ b/src/mapobj.s @@ -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 diff --git a/src/wram.s b/src/wram.s index 2ebcb35..7ad3c45 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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