map: maps are now 10x8 tiles
authorLukas Krickl <lukas@krickl.dev>
Wed, 26 Nov 2025 04:45:29 +0000 (05:45 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 26 Nov 2025 04:45:29 +0000 (05:45 +0100)
This will allow enough room for smooth scrolling to take palce
when loading a new map.

src/defs.s
src/levels.s
src/macros.inc
src/map.s
src/wram.s

index 83e876f097527b442c3855bd539374700899dd94..6234d0943317346cde6a447ef7a722e52ab7303e 100644 (file)
@@ -27,8 +27,8 @@
 #define UI_TILE_HEIGHT 4
        
        ; player position offset to get center of tile
-#define MAP_W 16
-#define MAP_H 16
+#define MAP_W 10
+#define MAP_H 8
 #define MAP_TILES (MAP_W * MAP_H)
 
   ; actor type enum
 .de act_cb_state, 1
 .de act_cb_size, 0
 
-  
+       ; map flags
+.se 1
+.de MAP_F_HOSTILE, 1
 
   ; map header struct
 .se 0
 .de map_flags, 1
        ; ptr to map routine
 .de map_routine, 2
+       ; ptr to actor table for this map
+.de map_acts, 2
+       ; ptr to encounter table
+.de map_encounters, 2
+       ; ptr to exit table
+.de map_exits, 2
   ; pointers to tile banks to be loaded 
   ; maps to map property tile_bank0, tile_bank1, tile_bank2, tile_bank3
   ; note that tile_bank1 and tile_bank2 are 128 bytes each
index 3f0f1cad062a231ad07941135cabdbbea37cf99e..3831820515bf964602ae67c289f6533dbbaef784 100644 (file)
        ; where each tile has values and its current state. The map can be drawn from this.
 
 l1:
-       mapdef 0, map_r_nop, bank8000, bank8800, bank8C00, bank9000
-       .db TWL, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TWL
+       mapdef 0, map_r_nop, 0, 0, 0, bank8000, bank8800, bank8C00, bank9000
+       .db TWL, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
+       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
+       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
+       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
+       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
+       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
+       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TWL
+       .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TWL
index 47483fda330c43caf0a40105a8289263503ab518..8c8ffa2a174cbd11a08ad841f5e3ea48292b3686 100644 (file)
@@ -154,10 +154,13 @@ $1:
        ; inputs:
        ;               $1: flags
        ;               $2: map routine
-       ;               $3: tile bank 0
-       ;               $4: tile bank 1
-       ;               $5: tile bank 2
-       ;               $6: tile bank 3
+       ;               $3: actors
+       ;               $4: encounters
+       ;               $5: exits
+       ;               $6: tile bank 0
+       ;               $7: tile bank 1
+       ;               $8: tile bank 2
+       ;               $9: tile bank 3
 #macro mapdef
        .db $1
        dw $2
@@ -165,6 +168,9 @@ $1:
        dw $4
        dw $5
        dw $6
+       dw $7
+       dw $8
+       dw $9
 #endmacro
        
        ; define a tile
index 2f3d4bced9d5ce7439aa212f9a00a3b19e246769..a457a802367b6d595f925dd9fa56363bff6f1b07 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -23,6 +23,11 @@ map_load:
        push de
        call map_tiles_load
        pop de
+
+       ; TODO: 
+       ; load actors
+       ; encounter table
+       ; exit table
        
        call map_full_draw
 
@@ -156,7 +161,7 @@ map_draw_tile:
 
        ; next row
        ; next row 
-       ld bc, (MAP_W * 2) - 1
+       ld bc, ((MAP_W * 2) + 12) - 1
        add hl, bc
 
        ld a, [de]
@@ -201,36 +206,6 @@ map_get_tile:
        ; hl = tile now
        ret
        
-       ; modifies the status gfx of a tile
-       ; based on flags
-       ; inputs:
-       ;               update_tile_ptr: ptr to tile
-       ;               a: current gfx
-       ;       returns:
-       ;               a: gfx to display
-map_draw_tile_modify_status:
-       push af
-       ld a, [update_tile_ptr]
-       ld h, a
-       ld a, [update_tile_ptr+1]
-       ld l, a
-       ; a = original gfx
-       pop af
-       
-       inc hl ; hl = flags
-       bit 0, [hl] ; test bit 0 (TF_INC)
-       jr nz, @inc REL
-
-       bit 1, [hl] ; test bit 1 (TF_DEC)
-       jr nz, @dec REL
-       ret
-@inc:
-       ld a, UI_TILE_PLUS
-       ret
-@dec:
-       ld a, UI_TILE_MINUS
-       ret
-       
        ; prepares tile draw
        ; by writing the expected tiles
        ; to tile_to_draw[0] to [3]
@@ -257,7 +232,7 @@ map_draw_tile_prep:
        push af ; save tile gfx
 
        ld hl, SCRN0
-       ld de, MAP_W * 4  ; * 4 because tiles are 8x8 
+       ld de, ((MAP_W * 2) + 12) * 2 ; * 4 because tiles are 8x8 
        
        ; skip y loop if b is 0
        ld a, b
@@ -292,17 +267,7 @@ map_draw_tile_prep:
        ; draw 2x2 tile
        ld [hl+], a
        inc a
-       
-       push af
-       ; top left corner of tile 
-       ; may display status effects
-       ; based on flags
-       push hl
-       call map_draw_tile_modify_status
-       pop hl
-
        ld [hl+], a
-       pop af
 
        
        ; move down one tile row as well
@@ -339,15 +304,9 @@ map_draw_row:
        map_draw_row_inc_c
        map_draw_row_inc_c
 
-       map_draw_row_inc_c
-       map_draw_row_inc_c
        map_draw_row_inc_c
        map_draw_row_inc_c
 
-       map_draw_row_inc_c
-       map_draw_row_inc_c
-       map_draw_row_inc_c
-       map_draw_row_inc_c
        ret
 
 #macro map_full_draw_inc_b
@@ -370,16 +329,6 @@ map_full_draw:
        map_full_draw_inc_b
        map_full_draw_inc_b
 
-       map_full_draw_inc_b
-       map_full_draw_inc_b
-       map_full_draw_inc_b
-       map_full_draw_inc_b
-
-       map_full_draw_inc_b
-       map_full_draw_inc_b
-       map_full_draw_inc_b
-       map_full_draw_inc_b
-
        ret
        
        ; nop map rotuine
index 4a57ad6cbce4b082bc3d407d9bc2fa312f211537..4dcc26c8a809645f606d32aa96493e38b5c41e6d 100644 (file)
@@ -91,19 +91,6 @@ tiles_end: .adv 0
 
        
        
-       ; the following valuess are set by ui_update
-       ; coordinates of current tile
-current_tile_y: .adv 1
-current_tile_x: .adv 1
-       ; ptr to current tile
-       ; selected by the player cursor
-current_tile: .adv 2
-
-       ; the following values are set by tile_next_update
-update_tile_y: .adv 1
-update_tile_x: .adv 1
-update_tile: .adv 2    
-       
        ; space for 4 tile ids
        ; that represent the current tile
        ; this gets drawn during the next blank