From 030d5c54598e2a15eb69c335ca82eb2d82640f5d Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 3 Oct 2024 08:17:30 +0200 Subject: [PATCH] wip: Adding map code and test floor tiles --- src/main.s | 4 ++- src/map.s | 22 ++++++++++++++++ src/player.s | 12 ++++++--- src/wram.s | 17 ++++++++++++ tiles/tileset1.inc | 64 +++++++++++++++++++++++----------------------- 5 files changed, 83 insertions(+), 36 deletions(-) create mode 100644 src/map.s diff --git a/src/main.s b/src/main.s index 0f83161..fbe653d 100644 --- a/src/main.s +++ b/src/main.s @@ -31,7 +31,6 @@ main: ld [frame_ready], a jr @forever REL -#include "tiles.inc" #include "video.s" #include "mem.s" #include "strings.s" @@ -39,6 +38,9 @@ main: #include "input.s" #include "player.s" #include "update.s" +#include "map.s" + +#include "tiles.inc" ; fill bank .fill 0, 0x7FFF - $ diff --git a/src/map.s b/src/map.s new file mode 100644 index 0000000..dffa08a --- /dev/null +++ b/src/map.s @@ -0,0 +1,22 @@ + ; map tiles + ; tiles are 2x2 areas + ; this simply defines the first tile + ; in the set +#define TILE_FLOOR_1 14 + + ; maps are collections of rooms + + ; rooms are made up of 2x2 meta tiles + ; the bottom 2 tiles are reserved for the UI + ; a rooms is exactly 1 screen + ; there is no scrolling + ; rooms may have 4 regular exits and 1 secret exit + +room_draw: + ret + + ; base room + ; this can be copied and modified + ; by the map gen +base_room: + diff --git a/src/player.s b/src/player.s index ab54345..378bd73 100644 --- a/src/player.s +++ b/src/player.s @@ -16,6 +16,12 @@ player_update: ; d: player_y ; e: player_x + ; b: obj flags mask + + ; set up obj flag mask based on frame counter + ld a, [frame_count] + and a, 4 + ld b, 0 ; input handling input_held BTNDOWN @@ -83,7 +89,7 @@ player_update: ld [hl+], a ; flags - xor a, a + ld a, b ld [hl+], a ; obj 2 @@ -99,7 +105,7 @@ player_update: ld [hl+], a ; flags - xor a, a + ld a, b ld [hl+], a ; obj 3 @@ -115,7 +121,7 @@ player_update: ld [hl+], a ; flags - xor a, a + ld a, b ld [hl+], a diff --git a/src/wram.s b/src/wram.s index e96ab66..ec573c6 100644 --- a/src/wram.s +++ b/src/wram.s @@ -38,3 +38,20 @@ actor_table: .adv ACTORS_MAX * actor_size .de player_size, 0 player: .adv player_size + +; struct map +.se 0 +.de map_size, 0 + + ; rooms are 18x18 +#define ROOM_W 18 +#define ROOM_H 18 + +; struct room +.se 0 +.de tiles, ROOM_W * ROOM_H +.de room_size, 0 + + + ; pointer to current room struct +curr_room: .adv 2 diff --git a/tiles/tileset1.inc b/tiles/tileset1.inc index cbac2f4..405104d 100644 --- a/tiles/tileset1.inc +++ b/tiles/tileset1.inc @@ -584,23 +584,23 @@ .chr 00000000 .chr 00000000 ; tile 65 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 00011111 +.chr 00100000 +.chr 01000000 +.chr 10000000 +.chr 10000000 +.chr 10000000 +.chr 10000000 +.chr 10000001 ; tile 66 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 11111000 +.chr 00000100 +.chr 00000010 +.chr 00000001 +.chr 00000001 +.chr 00000001 +.chr 00000001 +.chr 10000001 ; tile 67 .chr 00000000 .chr 00000000 @@ -728,23 +728,23 @@ .chr 00000000 .chr 00000000 ; tile 81 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 10000001 +.chr 10000000 +.chr 10000000 +.chr 10000000 +.chr 10000000 +.chr 10000000 +.chr 01000000 +.chr 00111111 ; tile 82 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 10000001 +.chr 00000001 +.chr 00000001 +.chr 00000001 +.chr 00000001 +.chr 00000001 +.chr 00000010 +.chr 11111100 ; tile 83 .chr 00000000 .chr 00000000 -- 2.30.2