Merge branch 'Rainchus:main' into main
This commit is contained in:
commit
1a3988db0a
11 changed files with 551 additions and 70 deletions
|
|
@ -14,7 +14,7 @@ s16 lbl_1_bss_E;
|
|||
s16 lbl_1_bss_C;
|
||||
void* lbl_1_bss_8;
|
||||
s32 lbl_1_bss_4_pad;
|
||||
BoardStateSubStruct* lbl_1_bss_0;
|
||||
W10State* lbl_1_bss_0;
|
||||
|
||||
//DATA
|
||||
unkw10Dll lbl_1_data_0[1] = {
|
||||
|
|
@ -62,7 +62,7 @@ s32 lbl_1_data_6C[2] = {
|
|||
|
||||
// function is probably global. only inlined in rels?
|
||||
inline s32 get_current_board(void) {
|
||||
return GWSystem.unk08 & 0x1F;
|
||||
return GWSystem.board;
|
||||
}
|
||||
|
||||
void fn_1_E0(void) {
|
||||
|
|
@ -76,7 +76,7 @@ void fn_1_E0(void) {
|
|||
s32 temp2;
|
||||
|
||||
temp2 = get_current_board();
|
||||
lbl_1_bss_0 = &GWSystem.unk10;
|
||||
lbl_1_bss_0 = (W10State *)&GWSystem.board_data;
|
||||
lbl_1_bss_0->unk0 = 0;
|
||||
lbl_1_bss_0->unk4 = 0;
|
||||
lbl_1_bss_0->unk6 = 0;
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ void fn_1_13A4(void) {
|
|||
|
||||
fn_1_BA0(0x2E0023);
|
||||
for (i = 0; i < 4; i++) {
|
||||
GWPlayer[i].flags.unk0 = 1;
|
||||
GWPlayer[i].color = 1;
|
||||
}
|
||||
fn_800A4C88();
|
||||
fn_800884F4(0);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "REL/w10Dll.h"
|
||||
#include "game/data.h"
|
||||
|
||||
s16 HuPadStatGet(s16 i); //TODO: Move to some other header file since gamework.c relies on an implicit declaration of it
|
||||
|
||||
char lbl_1_data_98[] = "@@@@@@@@@@@@@@ Tutorial Exit @@@@@@@@@@@@@@\n\000";
|
||||
|
||||
w10DllUnk03 lbl_1_data_C6[11] = {
|
||||
|
|
@ -85,21 +87,21 @@ void fn_1_176C(void) {
|
|||
|
||||
void fn_1_179C(void) {
|
||||
fn_1_BA0(0x2E0025);
|
||||
GWPlayer[1].flags.unk0 = 2;
|
||||
GWPlayer[3].flags.unk0 = 2;
|
||||
GWPlayer[1].color = 2;
|
||||
GWPlayer[3].color = 2;
|
||||
}
|
||||
|
||||
void fn_1_17F4(void) {
|
||||
fn_1_BA0(0x2E0026);
|
||||
GWPlayer[0].flags.unk0 = 2;
|
||||
GWPlayer[0].color = 2;
|
||||
}
|
||||
|
||||
void fn_1_1834(void) {
|
||||
fn_1_BA0(0x2E0027);
|
||||
GWPlayer[0].flags.unk0 = 1;
|
||||
GWPlayer[1].flags.unk0 = 1;
|
||||
GWPlayer[2].flags.unk0 = 1;
|
||||
GWPlayer[3].flags.unk0 = 2;
|
||||
GWPlayer[0].color = 1;
|
||||
GWPlayer[1].color = 1;
|
||||
GWPlayer[2].color = 1;
|
||||
GWPlayer[3].color = 2;
|
||||
}
|
||||
|
||||
void fn_1_18BC(void) {
|
||||
|
|
@ -139,7 +141,7 @@ void fn_1_1984(void) {
|
|||
return;
|
||||
}
|
||||
for (i = 0; i < ARRAY_COUNT(GWPlayer); i++) {
|
||||
contPortIndex = GWPlayer[i].controllerPort;
|
||||
contPortIndex = GWPlayer[i].port;
|
||||
if (contPortIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -168,7 +170,7 @@ int fn_1_1AAC(s16 arg0, s32 arg1) {
|
|||
if (fn_8005B6A8() == 0) {
|
||||
s32 contPortIndex;
|
||||
for (i = 0; i < ARRAY_COUNT(GWPlayer); i++) {
|
||||
contPortIndex = GWPlayer[i].controllerPort;
|
||||
contPortIndex = GWPlayer[i].port;
|
||||
if (contPortIndex == -1) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -190,8 +192,8 @@ int fn_1_1AAC(s16 arg0, s32 arg1) {
|
|||
}
|
||||
if (arg0 != 0x1D) {
|
||||
OSReport(lbl_1_data_258,
|
||||
(GWPlayer[0].characterID >> 5) & 1, (GWPlayer[1].characterID >> 5) & 1,
|
||||
(GWPlayer[2].characterID >> 5) & 1, (GWPlayer[3].characterID >> 5) & 1,
|
||||
GWPlayer[0].com, GWPlayer[1].com,
|
||||
GWPlayer[2].com, GWPlayer[3].com,
|
||||
lbl_1_bss_0->unk0, arg0, arg1, lbl_1_bss_0->unk4, lbl_1_bss_0->unk6);
|
||||
if (lbl_1_data_108[lbl_1_bss_0->unk0].unk0 != -1) {
|
||||
if (arg0 == 5) {
|
||||
|
|
|
|||
362
src/game/gamework.c
Normal file
362
src/game/gamework.c
Normal file
|
|
@ -0,0 +1,362 @@
|
|||
#include "common.h"
|
||||
#include "string.h"
|
||||
#include "game/gamework.h"
|
||||
|
||||
GameStat GWGameStatDefault;
|
||||
GameStat GWGameStat;
|
||||
SystemState GWSystem;
|
||||
PlayerState GWPlayer[4];
|
||||
PlayerConfig GWPlayerCfg[4];
|
||||
|
||||
static inline void GWErase(void)
|
||||
{
|
||||
memset(GWPlayerCfg, 0, sizeof(GWPlayerCfg));
|
||||
memset(GWPlayer, 0, sizeof(GWPlayer));
|
||||
memset(&GWSystem, 0, sizeof(GWSystem));
|
||||
}
|
||||
|
||||
static inline void InitPlayerConfig(void)
|
||||
{
|
||||
PlayerConfig *config;
|
||||
s32 i;
|
||||
for(i=0; i<4; i++) {
|
||||
config = &GWPlayerCfg[i];
|
||||
config->character = i;
|
||||
config->pad_idx = i;
|
||||
config->diff = 0;
|
||||
config->group = i;
|
||||
if(!HuPadStatGet(i)) {
|
||||
config->iscom = 0;
|
||||
} else {
|
||||
config->iscom = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void ResetBoardSettings(void)
|
||||
{
|
||||
GWGameStat.rumble = 1;
|
||||
GWSystem.explain_mg = 1;
|
||||
GWSystem.show_com_mg = 1;
|
||||
GWSystem.mess_speed = 1;
|
||||
GWSystem.mess_delay = 32;
|
||||
GWSystem.save_mode = 0;
|
||||
}
|
||||
|
||||
void GWInit(void)
|
||||
{
|
||||
GWResetGameStat();
|
||||
_InitFlag();
|
||||
GWErase();
|
||||
InitPlayerConfig();
|
||||
GWGameStat.language = 1;
|
||||
ResetBoardSettings();
|
||||
}
|
||||
|
||||
static inline void ResetMGRecord(GameStat *game_stat)
|
||||
{
|
||||
game_stat->mg_record[0] = 18000;
|
||||
game_stat->mg_record[1] = 80;
|
||||
game_stat->mg_record[2] = 3600;
|
||||
game_stat->mg_record[3] = 7200;
|
||||
game_stat->mg_record[4] = 0;
|
||||
game_stat->mg_record[5] = 3600;
|
||||
game_stat->mg_record[6] = 18000;
|
||||
game_stat->mg_record[7] = 18000;
|
||||
game_stat->mg_record[8] = 18000;
|
||||
game_stat->mg_record[9] = 0;
|
||||
game_stat->mg_record[10] = 300;
|
||||
game_stat->mg_record[11] = 0;
|
||||
game_stat->mg_record[12] = 0;
|
||||
game_stat->mg_record[13] = 0;
|
||||
game_stat->mg_record[14] = 0;
|
||||
}
|
||||
|
||||
static inline void ResetBoardRecord(GameStat *game_stat)
|
||||
{
|
||||
s32 i;
|
||||
s32 j;
|
||||
|
||||
for(i=0; i<9; i++) {
|
||||
for(j=0; j<8; j++) {
|
||||
game_stat->board_win_count[i][j] = 0;
|
||||
}
|
||||
game_stat->board_play_count[i] = 0;
|
||||
game_stat->board_max_stars[i] = 0;
|
||||
game_stat->board_max_coins[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void ResetPresent(GameStat *game_stat)
|
||||
{
|
||||
s32 i;
|
||||
for(i=0; i<60; i++) {
|
||||
game_stat->present[i] = 0;
|
||||
}
|
||||
(void)i; //HACK to match GWResetGameStat
|
||||
}
|
||||
|
||||
static inline void ResetFlag(GameStat *game_stat)
|
||||
{
|
||||
game_stat->story_continue = 0;
|
||||
game_stat->party_continue = 0;
|
||||
game_stat->open_w06 = 0;
|
||||
game_stat->field10E_bit4 = 0;
|
||||
game_stat->field10E_bit5 = 0;
|
||||
game_stat->field10E_bit6 = 0;
|
||||
game_stat->field10F_bit0 = game_stat->field110_bit0 = 1;
|
||||
game_stat->field10F_bit1 = game_stat->field110_bit1 = 1;
|
||||
game_stat->field10F_bit2 = game_stat->field110_bit2 = 0;
|
||||
game_stat->field10F_bit4 = game_stat->field110_bit4 = 1;
|
||||
game_stat->field10F_bit6 = game_stat->field110_bit6 = 0;
|
||||
}
|
||||
|
||||
void GWResetGameStat(void)
|
||||
{
|
||||
GameStat *game_stat = &GWGameStatDefault;
|
||||
memset(game_stat, 0, sizeof(GameStat));
|
||||
game_stat->unk_00 = 0;
|
||||
game_stat->language = 1;
|
||||
game_stat->sound_mode = 1;
|
||||
game_stat->rumble = 1;
|
||||
game_stat->total_stars = 0;
|
||||
game_stat->create_time = 0;
|
||||
game_stat->mg_custom[0] = 0;
|
||||
game_stat->mg_custom[1] = 0;
|
||||
game_stat->mg_avail[0] = 0;
|
||||
game_stat->mg_avail[1] = 0;
|
||||
ResetMGRecord(game_stat);
|
||||
ResetBoardRecord(game_stat);
|
||||
ResetPresent(game_stat);
|
||||
ResetFlag(game_stat);
|
||||
memcpy(&GWGameStat, &GWGameStatDefault, sizeof(GameStat));
|
||||
ResetBoardSettings();
|
||||
}
|
||||
|
||||
s16 GWGetMessSpeed(void)
|
||||
{
|
||||
if(GWSystem.mess_delay > 48) {
|
||||
GWSystem.mess_speed = 1;
|
||||
GWSystem.mess_delay = 32;
|
||||
}
|
||||
return GWSystem.mess_delay;
|
||||
}
|
||||
|
||||
void GWSetMGRecord(int index, s32 value)
|
||||
{
|
||||
if(!_CheckFlag(0x1000C)) {
|
||||
GWGameStat.mg_record[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
s32 GWGetMGRecord(int index)
|
||||
{
|
||||
return GWGameStat.mg_record[index];
|
||||
}
|
||||
|
||||
void GWGetCharColor(int character, GXColor *color)
|
||||
{
|
||||
GXColor char_color[] = {
|
||||
{ 227, 67, 67, 255 },
|
||||
{ 68, 67, 227, 255 },
|
||||
{ 241, 158, 220, 255 },
|
||||
{ 67, 228, 68, 255 },
|
||||
{ 138, 60, 180, 255 },
|
||||
{ 146, 85, 55, 255 },
|
||||
{ 227, 228, 68, 255 },
|
||||
{ 40, 40, 40, 255 }
|
||||
};
|
||||
*color = char_color[character];
|
||||
}
|
||||
|
||||
void GWSetBoardPlayCount(int board, u8 value)
|
||||
{
|
||||
if(value > 99) {
|
||||
value = 99;
|
||||
}
|
||||
GWGameStat.board_play_count[board] = value;
|
||||
}
|
||||
|
||||
void GWAddBoardPlayCount(int board, u8 value)
|
||||
{
|
||||
value += GWGameStat.board_play_count[board];
|
||||
if(value > 99) {
|
||||
value = 99;
|
||||
}
|
||||
GWGameStat.board_play_count[board] = value;
|
||||
}
|
||||
|
||||
|
||||
u8 GWGetBoardPlayCount(int board)
|
||||
{
|
||||
return GWGameStat.board_play_count[board];
|
||||
}
|
||||
|
||||
void GWSetBoardMaxStars(int board, int value)
|
||||
{
|
||||
GWGameStat.board_max_stars[board] = value;
|
||||
}
|
||||
|
||||
u16 GWGetBoardMaxStars(int board)
|
||||
{
|
||||
return GWGameStat.board_max_stars[board];
|
||||
}
|
||||
|
||||
void GWSetBoardMaxCoins(int board, int value)
|
||||
{
|
||||
GWGameStat.board_max_coins[board] = value;
|
||||
}
|
||||
|
||||
u16 GWGetBoardMaxCoins(int board)
|
||||
{
|
||||
return GWGameStat.board_max_coins[board];
|
||||
}
|
||||
|
||||
int GWIncBoardWinCount(int character, int board)
|
||||
{
|
||||
int win_count = GWGameStat.board_win_count[board][character]+1;
|
||||
if(win_count > 99) {
|
||||
win_count = 99;
|
||||
}
|
||||
GWGameStat.board_win_count[board][character] = win_count;
|
||||
return win_count;
|
||||
}
|
||||
|
||||
int GWGetBoardWinCount(int character, int board)
|
||||
{
|
||||
return GWGameStat.board_win_count[board][character];
|
||||
}
|
||||
|
||||
void GWSetBoardWinCount(int character, int board, int value)
|
||||
{
|
||||
GWGameStat.board_win_count[board][character] = value;
|
||||
}
|
||||
|
||||
int GWGetMGAvail(int id)
|
||||
{
|
||||
int word;
|
||||
int bit;
|
||||
id -= 401;
|
||||
word = id >> 5;
|
||||
bit = id % 32;
|
||||
if(GWGameStat.mg_avail[word] & (1 << bit)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int GWSetMGAvail(int id)
|
||||
{
|
||||
int word;
|
||||
int bit;
|
||||
id -= 401;
|
||||
word = id >> 5;
|
||||
bit = id % 32;
|
||||
GWGameStat.mg_avail[word] |= (1 << bit);
|
||||
}
|
||||
|
||||
int GWGetMGCustom(int id)
|
||||
{
|
||||
int word;
|
||||
int bit;
|
||||
id -= 401;
|
||||
word = id >> 5;
|
||||
bit = id % 32;
|
||||
if(GWGameStat.mg_custom[word] & (1 << bit)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int GWSetMGCustom(int id)
|
||||
{
|
||||
int word;
|
||||
int bit;
|
||||
id -= 401;
|
||||
word = id >> 5;
|
||||
bit = id % 32;
|
||||
GWGameStat.mg_custom[word] |= (1 << bit);
|
||||
}
|
||||
|
||||
int GWResetMGCustom(int id)
|
||||
{
|
||||
int word;
|
||||
int bit;
|
||||
id -= 401;
|
||||
word = id >> 5;
|
||||
bit = id % 32;
|
||||
GWGameStat.mg_custom[word] &= ~(1 << bit);
|
||||
}
|
||||
|
||||
s16 GWGetCoins(int player)
|
||||
{
|
||||
return GWPlayer[player].coins;
|
||||
}
|
||||
|
||||
void GWSetCoins(int player, s16 value)
|
||||
{
|
||||
if(!_CheckFlag(0x1000C)) {
|
||||
if(value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
if(value > 999) {
|
||||
value = 999;
|
||||
}
|
||||
if(value > GWPlayer[player].coins_max) {
|
||||
GWPlayer[player].coins_max = value;
|
||||
}
|
||||
GWPlayer[player].coins = value;
|
||||
}
|
||||
}
|
||||
|
||||
void GWAddCoins(int player, s16 amount)
|
||||
{
|
||||
GWSetCoins(player, GWPlayer[player].coins+amount);
|
||||
}
|
||||
|
||||
void GWSetStars(int player, s16 value)
|
||||
{
|
||||
if(value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
if(value > 999) {
|
||||
value = 999;
|
||||
}
|
||||
if(value > GWPlayer[player].stars_max) {
|
||||
GWPlayer[player].stars_max = value;
|
||||
}
|
||||
GWPlayer[player].stars = value;
|
||||
}
|
||||
|
||||
void GWAddStars(int player, s16 amount)
|
||||
{
|
||||
GWSetStars(player, GWPlayer[player].stars+amount);
|
||||
}
|
||||
|
||||
s16 GWGetStars(int player)
|
||||
{
|
||||
return GWPlayer[player].stars;
|
||||
}
|
||||
|
||||
void GWSetTotalStars(s16 value)
|
||||
{
|
||||
if(value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
if(value > 10000) {
|
||||
value = 10000;
|
||||
}
|
||||
GWGameStat.total_stars = value;
|
||||
}
|
||||
|
||||
void GWAddTotalStars(s16 amount)
|
||||
{
|
||||
GWSetTotalStars(GWGameStat.total_stars+amount);
|
||||
}
|
||||
|
||||
u16 GWGetTotalStars(void)
|
||||
{
|
||||
return GWGameStat.total_stars;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue