wip: room loading routine
authorLukas Krickl <lukas@krickl.dev>
Thu, 3 Oct 2024 15:59:53 +0000 (17:59 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 3 Oct 2024 15:59:53 +0000 (17:59 +0200)
src/hw.inc
src/macros.inc
src/map.s
src/video.s
src/wram.s

index dc8ac7042ecd104148bdaff98b59752bcf9e8154..7d2c69e05a90cf6bc3881ca1f4cb6ee1e59213f5 100644 (file)
 ; memory map 
 .def int VRAM = 0x8000
 .def int VRAM9000 = VRAM+0x1000
+
+.def int SCRN_W = 32
+.def int SCRN_H = 32
+
 .def int SCRN0 = 0x9800
+.def int SCRN0_UI = SCRN0 + SCRN_W * 16 
+
 .def int SCRN1 = 0x9C00
 .def int OAMRAM = 0xFE00
 .def int OBJSIZE = 4
index e7686387e32e0bf1efb470682c818d354344b3b0..9edc2d01adc5c1f6ea61127abe99d425f82a2ece 100644 (file)
   pop af
 #endmacro
 
+  ; loads the lo part of an address 
+  ; inputs:
+  ;   $1: register
+  ;   $2: address
+#macro ldlo 
+  ld $1, ($2 & 0xFF)
+#endmacro 
+
+  ; loads the high part of an address
+  ; inputs:
+  ;   $1: register
+  ;   $2: address
+#macro ldhi
+  ld $1, ($2 >> 8) & 0xFF
+#endmacro
+
 ; relative jump: jr <label> RELB 
 #define REL - $ - 2 & 0xFF 
index dffa08a18c2c158fe19cea26915851eca8878a48..6ffb6e31396cbf0dd94b4577bef5f4747f1a1668 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -2,7 +2,7 @@
   ; tiles are 2x2 areas 
   ; this simply defines the first tile 
   ; in the set 
-#define TILE_FLOOR_1 14
+#define TFLOOR1 0x41
 
   ; maps are collections of rooms
 
   ; there is no scrolling
   ; rooms may have 4 regular exits and 1 secret exit
 
+
+
+  ; draws the entire room to the tilemap
+  ; disable rendering before drawing a room!
+  ; inputs:
+  ;   curr_toom: pointer to current room
 room_draw:
+  ; load current room ptr
+  ld a, [curr_room+1]
+  ld d, a
+  ld a, [curr_room]
+  ld e, a
+  ld hl, SCRN0
+
+@copy_meta_tile:
+  ld a, [de]
+  ld [hl+], a
+  inc de
+  
+
   ret
 
   ; base room 
   ; this can be copied and modified 
   ; by the map gen
 base_room:
-  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
+.db TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1,  TFLOOR1, TFLOOR1  
index f08c3aebbb50ac45bb79799e536edfbb69767459..7889b80bd35df06c1fb66d199513b25a44f2596c 100644 (file)
@@ -8,7 +8,7 @@ vblank:
 
   ; test puts 
   ld hl, STR_TITLE
-  ld de, SCRN0
+  ld de, SCRN0_UI
   call puts
 
   ld a, 1
@@ -48,6 +48,15 @@ video_init:
   ld bc, 1024
   ld d, EMPTY_TILE
   call memset
+
+
+  ; initial test map
+  ldlo a, base_room 
+  ld [curr_room], a
+  ldhi a, base_room
+  ld [curr_room+1], a
+  call room_draw
+
   
   ; set up bgp
   ld a, 0b11100100
index ec573c66df98e2e958d98cb0156f85598a5635da..0e69333e8c772c1f55b0a55b4af1d1dc8e09b70b 100644 (file)
@@ -43,9 +43,9 @@ player: .adv player_size
 .se 0
 .de map_size, 0
 
-  ; rooms are 18x18 
-#define ROOM_W 18
-#define ROOM_H 18
+  ; rooms are 9x9 meta tiles 
+#define ROOM_W 9
+#define ROOM_H 9
 
 ; struct room
 .se 0