defs: moved defs from wram.s to defs.s
authorLukas Krickl <lukas@krickl.dev>
Sun, 19 Jan 2025 15:59:18 +0000 (16:59 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 19 Jan 2025 15:59:18 +0000 (16:59 +0100)
src/actor.s
src/defs.s
src/wram.s

index b65d3772958f02a4608328e9b11073f2652bcc63..a02a9c158b349204ea1eef1f11036e476c3ea526 100644 (file)
@@ -184,7 +184,8 @@ anim_truncate_pos:
   
   ; macro version of actor_tile_update_rf_flag
   ; inputs:
-  ;   $1: RF FLAG to set / unset 
+  ;   $1: RF FLAG to set / unset
+  ;   $2: offset / tile
   ;   bc: original y/x position ptr
   ;  anim_target_y/x: target position
   ; returns:
index daae30180ca5f46b0e0b4d52aad978f7de42bd32..d676842b4a5941e53886499de51f273817cee007 100644 (file)
@@ -1,2 +1,197 @@
 ; This file contains struct defintions
+; and enums 
+
+.section defs
+
+.def int OAMDMAFN = 0xFF80 
+#define WRAM 0xC000
+#define WRAMLEN 0xFFF
+
+#define STACK_BEGIN 0xDFFF
+
+#define ACTORS_MAX 8
+#define ACTOR_TABLE_SIZE ACTORS_MAX * actor_size
+
+#define PLAYER_DEFAULT_HP 3
+#define PLAYER_DEFAULT_MP 3
+#define PLAYER_DEFAULT_DEF 0
+#define PLAYER_DEFAULT_ATK 1
+
+
+#define NORTH 0
+#define EAST 1
+#define SOUTH 2
+#define WEST 3
+#define EXIT_SPECIAL 4
+
+#define ROOMS_TOTAL 16
+
+  ; rooms are 9x9 meta tiles 
+#define ROOM_W 10
+#define ROOM_H 8
+#define ROOM_EXITS_MAX 5
+  ; table of ptrs
+#define ROOM_EXIT_TABLE_SIZE ROOM_EXITS_MAX * 2 
+
+#define ROOM_TILES_SIZE (ROOM_W * ROOM_H)
+#define ROOM_FLAGS_SIZE (ROOM_W * ROOM_H)
+
+#define TILE_POS_MASK 0xF0
+
+
+#define ANIM_MOVE_TILE_SIZE 16
+
+#define WHO_PLAYER 0xFF
+
+  ; seed for the rng
+  ; 8 bit signed int
+#define RAND_MAGIC 0x1B
+#define SRAND_INITIAL 0x19
+
+  ; -TILE_SIZE
+#define ANIM_MOVE_TILE_SIZE_N 0xFF - ANIM_MOVE_TILE_SIZE + 1
+#define ANIM_STEP_DOWN 1
+#define ANIM_STEP_LEFT 0xFF
+#define ANIM_STEP_UP 0xFF
+#define ANIM_STEP_RIGHT 1
+
+; actor type enum
+.se 0
+  ; null actor type = nop
+.de ACTOR_TYPE_NULL, 1
+.de ACTOR_TYPE_BAT, 1
+.de ACTOR_TYPE_ROCK, 1 
+
+
+; struct actor 
+.se 0
+.de actor_type, 1
+.de actor_y, 1
+.de actor_x, 1
+.de actor_flags, 1
+.de actor_size, 0
+
+
+; player flags bitfield 
+.se 1
+  ; when set this puts the player state into cursor mode
+  ; allowing the selection of a tile to 
+  ; perform an action in
+.de PLAYER_FCURSOR, 1
+
+; struct player
+.se 0
+.de player_y, 1
+.de player_x, 1
+.de player_flags, 1
+
+  ; player stats
+.de player_hp, 1
+.de player_hp_max, 1
+.de player_mp, 1
+.de player_mp_max, 1
+.de player_def, 1
+.de player_def_max, 1
+.de player_atk, 1
+.de player_atk_max, 1
+
+  ; player timer:
+  ;   differnt timers for the player
+  ;   iframe (i)
+  ;   layout:
+  ;     iiiiiiii
+.de player_timer_i, 1
+.de player_size, 0
+
+
+; struct room
+; FIXME: thse ptrs are currently in big endian...
+.se 0
+.de room_tiles, 2 ; be ptr to tiles
+.de room_flags, 2 ; be ptr to flags
+.de room_actor_table, 2 ; be ptr of actor table to be used
+.de room_exit_table, 2 ; list of ptrs to new rooms 
+.de room_size, 0
+
+; room flags
+.se 1
+  ; set if a tile is a wall
+.de RF_WALL, 1
+  ; set if a tile is a door
+.de RF_DOOR, 2
+  ; set if a tile is blocked by an actor
+  ; if this flag is set 
+  ; collision resolution will 
+  ; need to look up the actor in question by
+  ; iterating over the actor table + player 
+  ; and checking each position
+  ; note: if RF_ACTOR is set the highest 4 bits of RF flags will
+  ;       be set to the actor's id
+.de RF_ACTOR, 4
+  ; same as RF_ACTOR, but for the player 
+.de RF_PLAYER, 8
+
+
+  ; total size of a room including the struct header 
+  ; tiles, flags, actors and exits
+  ; rooms are always in the order specified here:
+  ; room_header, tiles, flags, actor_table, exit_table
+
+  ; room body including all tiles, flags, actors
+  ; and exits
+.se 0
+.de roomb_header, room_size
+.de roomb_tiles, ROOM_TILES_SIZE
+.de roomb_flags, ROOM_FLAGS_SIZE
+.de roomb_actors, ACTOR_TABLE_SIZE
+.de roomb_exits, ROOM_EXIT_TABLE_SIZE
+.de roomb_size, 0
+
+#define SAVE_GAME_VER 0
+
+  ; save game struct 
+.se 0
+  ; checksum of save game
+  ; this is simply all bytes in the save game added 
+.de save_game_chksm, 1
+  ; version of save game
+.de save_game_version, 1
+  ; saving rng seed
+.de save_game_srand, 1
+  ; saving floor number 
+.de save_game_floor, 1
+  ; saving all room headers
+  ; it is important to ensure 
+  ; that the rooms are loaded back in their intended memory space
+  ; to not corrupt room header pointers
+  ; saving player state
+.de save_game_rooms, roomb_size * ROOMS_TOTAL
+.de save_game_player, player_size
+  ; this is a canary value to detect out of bounds reads in sram
+  ; if this value is not SRAM_MAGIC then the save game is corrupted
+.de save_game_canary, 1
+.de save_game_size, 0
+
+  ; drawing related flags
+
+  ; UI flags 
+.se 1
+.de UI_REDRAW_HP, 1
+.de UI_REDRAW_MP, 2
+.de UI_REDRAW_ATK, 4
+.de UI_REDRAW_DEF, 8
+
+  ; engine flags 
+.se 1
+  ; if set to 1, call room_goto_player_pos in next blank
+.de EG_FLOAD_ROOM, 1
+
+  ; game modes
+  ; this is a direct index
+  ; into a pointer array
+  ; for update functions
+.se 0
+.de GM_GAME, 1
+.de GM_PAUSE, 1
+.de GAME_OVER, 1
 
index 95ede26cabbbc2232b195384379971d70dd04199..ccbe87ed616f9470520db0f0ed1ce9bb6e9fb3c1 100644 (file)
@@ -1,83 +1,22 @@
-#define WRAM 0xC000
-#define WRAMLEN 0xFFF
-
-#define STACK_BEGIN 0xDFFF
-
 .org WRAM
 .section wram 
 
-.def int OAMDMAFN = 0xFF80 
-
 shadow_oam: .adv OBJSMAX * oamsize 
 
 frame_ready: .adv 1
 frame_count: .adv 1
 
-#define ACTORS_MAX 8
-
   ; current frame's inputs 
 curr_inputs: .adv 1
   ; previous frame's inputs
 prev_inputs: .adv 1
 
-; actor type enum
-.se 0
-  ; null actor type = nop
-.de ACTOR_TYPE_NULL, 1
-.de ACTOR_TYPE_BAT, 1
-.de ACTOR_TYPE_ROCK, 1
-
-; struct actor 
-.se 0
-.de actor_type, 1
-.de actor_y, 1
-.de actor_x, 1
-.de actor_flags, 1
-.de actor_size, 0
-
-#define ACTOR_TABLE_SIZE ACTORS_MAX * actor_size
 
   ; static actor table space
 actor_table: .adv ACTOR_TABLE_SIZE 
 
 actor_soam_ptr: .adv 2
 
-#define PLAYER_DEFAULT_HP 3
-#define PLAYER_DEFAULT_MP 3
-#define PLAYER_DEFAULT_DEF 0
-#define PLAYER_DEFAULT_ATK 1
-
-; player flags bitfield 
-.se 1
-  ; when set this puts the player state into cursor mode
-  ; allowing the selection of a tile to 
-  ; perform an action in
-.de PLAYER_FCURSOR, 1
-
-; struct player
-.se 0
-.de player_y, 1
-.de player_x, 1
-.de player_flags, 1
-
-  ; player stats
-.de player_hp, 1
-.de player_hp_max, 1
-.de player_mp, 1
-.de player_mp_max, 1
-.de player_def, 1
-.de player_def_max, 1
-.de player_atk, 1
-.de player_atk_max, 1
-
-  ; player timer:
-  ;   differnt timers for the player
-  ;   iframe (i)
-  ;   layout:
-  ;     iiiiiiii
-.de player_timer_i, 1
-.de player_size, 0
-
 player: .adv player_size
 
   ; play a damage animation
@@ -87,52 +26,6 @@ damage_anim: .adv 1
 
 ; map region 
 
-#define NORTH 0
-#define EAST 1
-#define SOUTH 2
-#define WEST 3
-#define EXIT_SPECIAL 4
-
-#define ROOMS_TOTAL 16
-
-  ; rooms are 9x9 meta tiles 
-#define ROOM_W 10
-#define ROOM_H 8
-#define ROOM_EXITS_MAX 5
-  ; table of ptrs
-#define ROOM_EXIT_TABLE_SIZE ROOM_EXITS_MAX * 2 
-
-#define ROOM_TILES_SIZE (ROOM_W * ROOM_H)
-#define ROOM_FLAGS_SIZE (ROOM_W * ROOM_H)
-
-; struct room
-; FIXME: thse ptrs are currently in big endian...
-.se 0
-.de room_tiles, 2 ; be ptr to tiles
-.de room_flags, 2 ; be ptr to flags
-.de room_actor_table, 2 ; be ptr of actor table to be used
-.de room_exit_table, 2 ; list of ptrs to new rooms 
-.de room_size, 0
-
-#define TILE_POS_MASK 0xF0
-
-; room flags
-.se 1
-  ; set if a tile is a wall
-.de RF_WALL, 1
-  ; set if a tile is a door
-.de RF_DOOR, 2
-  ; set if a tile is blocked by an actor
-  ; if this flag is set 
-  ; collision resolution will 
-  ; need to look up the actor in question by
-  ; iterating over the actor table + player 
-  ; and checking each position
-  ; note: if RF_ACTOR is set the highest 4 bits of RF flags will
-  ;       be set to the actor's id
-.de RF_ACTOR, 4
-  ; same as RF_ACTOR, but for the player 
-.de RF_PLAYER, 8 
 
   ; current room struct 
   ; same layout as room struct itself 
@@ -156,62 +49,10 @@ curr_room_exits: .adv 2
   ; the floors (levels) the player has beaten already
 floor: .adv 1
 
-  ; total size of a room including the struct header 
-  ; tiles, flags, actors and exits
-  ; rooms are always in the order specified here:
-  ; room_header, tiles, flags, actor_table, exit_table
-
-  ; room body including all tiles, flags, actors
-  ; and exits
-.se 0
-.de roomb_header, room_size
-.de roomb_tiles, ROOM_TILES_SIZE
-.de roomb_flags, ROOM_FLAGS_SIZE
-.de roomb_actors, ACTOR_TABLE_SIZE
-.de roomb_exits, ROOM_EXIT_TABLE_SIZE
-.de roomb_size, 0
-
-#define SAVE_GAME_VER 0
-
-  ; save game struct 
-.se 0
-  ; checksum of save game
-  ; this is simply all bytes in the save game added 
-.de save_game_chksm, 1
-  ; version of save game
-.de save_game_version, 1
-  ; saving rng seed
-.de save_game_srand, 1
-  ; saving floor number 
-.de save_game_floor, 1
-  ; saving all room headers
-  ; it is important to ensure 
-  ; that the rooms are loaded back in their intended memory space
-  ; to not corrupt room header pointers
-  ; saving player state
-.de save_game_rooms, roomb_size * ROOMS_TOTAL
-.de save_game_player, player_size
-  ; this is a canary value to detect out of bounds reads in sram
-  ; if this value is not SRAM_MAGIC then the save game is corrupted
-.de save_game_canary, 1
-.de save_game_size, 0
-
-  ; drawing related flags
-
-  ; UI flags 
-.se 1
-.de UI_REDRAW_HP, 1
-.de UI_REDRAW_MP, 2
-.de UI_REDRAW_ATK, 4
-.de UI_REDRAW_DEF, 8
 
 ui_flags: .adv 1
 draw_flags: .adv 1
 
-  ; engine flags 
-.se 1
-  ; if set to 1, call room_goto_player_pos in next blank
-.de EG_FLOAD_ROOM, 1
 
 engine_flags: .adv 1
 
@@ -226,24 +67,10 @@ itmp: .adv 16
   ; it reaches 0 re-start game
 game_over_timer: .adv 1
 
-  ; game modes
-  ; this is a direct index
-  ; into a pointer array
-  ; for update functions
-.se 0
-.de GM_GAME, 1
-.de GM_PAUSE, 1
-.de GAME_OVER, 1
-
 game_mode: .adv 1
 
-  ; seed for the rng
-  ; 8 bit signed int
-#define RAND_MAGIC 0x1B
-#define SRAND_INITIAL 0x19
 srand: .adv 1
 
-#define WHO_PLAYER 0xFF
   ; who is currently in control of the game
   ; if set to FF
   ; the player is active 
@@ -258,14 +85,6 @@ end_turn: .adv 1
   ; current actor that is being updated 
 act: .adv 1
 
-#define ANIM_MOVE_TILE_SIZE 16
-
-  ; -TILE_SIZE
-#define ANIM_MOVE_TILE_SIZE_N 0xFF - ANIM_MOVE_TILE_SIZE + 1
-#define ANIM_STEP_DOWN 1
-#define ANIM_STEP_LEFT 0xFF
-#define ANIM_STEP_UP 0xFF
-#define ANIM_STEP_RIGHT 1
 
 ; animation params storage 
 anim_move_y: .adv 1