From 7e89d76751758f6e9425deae190033b2df8a792a Mon Sep 17 00:00:00 2001 From: nmlgc Date: Fri, 27 Oct 2023 23:28:28 +0200 Subject: [PATCH] [Maintenance] [th03] Define a player ID type Luckily, C has nothing against `typedef`s being repeatedly defined to the same value. Part of P0261, funded by [Anonymous] and Yanga. --- th03/common.h | 5 ++++- th03/main/collmap.hpp | 2 +- th03/main/player/combo.h | 4 ++-- th03/main/player/player.hpp | 6 +++--- th03/main/player/shot.hpp | 2 +- th03/main_011.cpp | 1 + th03/resident.hpp | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/th03/common.h b/th03/common.h index 24218d85..f5b264f0 100644 --- a/th03/common.h +++ b/th03/common.h @@ -1,6 +1,9 @@ /* ReC98 * ----- - * Common, essential macros for TH03. No types here! + * Common, essential macros for TH03. No structures here! */ +// Player ID +typedef unsigned char pid_t; + #define PLAYER_COUNT 2 diff --git a/th03/main/collmap.hpp b/th03/main/collmap.hpp index 17e06e9a..a0c84aee 100644 --- a/th03/main/collmap.hpp +++ b/th03/main/collmap.hpp @@ -40,7 +40,7 @@ extern PlayfieldPoint collmap_topleft; extern collmap_tile_amount_t collmap_stripe_tile_w; extern collmap_tile_amount_t collmap_tile_h; extern PlayfieldPoint collmap_bottomright; -extern unsigned char collmap_pid; +extern pid_t collmap_pid; // Stored as columns from left to right, not rows from top to bottom. extern uint8_t collmap[PLAYER_COUNT][COLLMAP_MEMORY_W][COLLMAP_H]; diff --git a/th03/main/player/combo.h b/th03/main/player/combo.h index 67db8026..d90d35ea 100644 --- a/th03/main/player/combo.h +++ b/th03/main/player/combo.h @@ -17,7 +17,7 @@ extern combo_t combos[PLAYER_COUNT]; // amount of [hits] is enough to continue the combo. Returns the new total // bonus value. unsigned int pascal combo_add( - unsigned char hits, unsigned char pid, unsigned int bonus + unsigned char hits, pid_t pid, unsigned int bonus ); void combo_update_and_render(void); @@ -39,6 +39,6 @@ extern unsigned char hitcombo_ring[PLAYER_COUNT][HITCOMBO_RING_SIZE]; // [slot], adding the given amount of bonus points. Returns the new total // bonus value. unsigned int pascal hitcombo_commit( - unsigned char pid, unsigned char slot, unsigned int bonus_to_add + pid_t pid, unsigned char slot, unsigned int bonus_to_add ); /// ---------------- diff --git a/th03/main/player/player.hpp b/th03/main/player/player.hpp index 6ff89ba9..5d4587f9 100644 --- a/th03/main/player/player.hpp +++ b/th03/main/player/player.hpp @@ -17,7 +17,7 @@ typedef uint16_t gauge_t; typedef uint8_t gauge_perbyte_t; -void pascal near gauge_avail_add(unsigned char pid, unsigned char charge); +void pascal near gauge_avail_add(pid_t pid, unsigned char charge); // ----- // Charge Shots @@ -92,8 +92,8 @@ typedef struct { uint8_t padding[6]; } player_t; -extern unsigned char pid_current; -extern unsigned char pid_other; +extern pid_t pid_current; +extern pid_t pid_other; // ZUN bloat: Doubly redundant: The player ID is already covered by // [pid_current], while [so_attack] can be easily calculated from that ID. diff --git a/th03/main/player/shot.hpp b/th03/main/player/shot.hpp index 6c19e367..43cbae7d 100644 --- a/th03/main/player/shot.hpp +++ b/th03/main/player/shot.hpp @@ -29,7 +29,7 @@ struct shotpair_t { sprite16_offset_t so_pid; unsigned char so_anim; char unused_2; // ZUN bloat - unsigned char pid; + pid_t pid; char unused_3; // ZUN bloat }; diff --git a/th03/main_011.cpp b/th03/main_011.cpp index 8f7ee30f..0c1cc0c6 100644 --- a/th03/main_011.cpp +++ b/th03/main_011.cpp @@ -6,6 +6,7 @@ extern "C" { #include "platform.h" #include "pc98.h" +#include "th03/common.h" #include "th03/sprite16.hpp" #include "th03/main/playfld.hpp" #include "th03/main/player/shot.hpp" diff --git a/th03/resident.hpp b/th03/resident.hpp index ca04b8b8..817ca10e 100644 --- a/th03/resident.hpp +++ b/th03/resident.hpp @@ -40,7 +40,7 @@ typedef struct { int8_t unused_1; unsigned char bgm_mode; unsigned char key_mode; - unsigned char pid_winner; + pid_t pid_winner; score_lebcd_t score_last[PLAYER_COUNT]; unsigned char game_mode; PlaycharPalettedOptional story_opponents[STAGE_COUNT];