[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.
This commit is contained in:
nmlgc 2023-10-27 23:28:28 +02:00
parent cf78098a79
commit 7e89d76751
7 changed files with 13 additions and 9 deletions

View File

@ -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

View File

@ -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];

View File

@ -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
);
/// ----------------

View File

@ -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.

View File

@ -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
};

View File

@ -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"

View File

@ -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];