Port gamework.c to PAL (#467)

This commit is contained in:
dbalatoni13 2024-11-17 00:08:24 +01:00 committed by GitHub
parent 03e0dedb8e
commit be79577202
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 85 additions and 60 deletions

View file

@ -1,7 +1,12 @@
#include "string.h"
#include "game/gamework.h"
#include "game/gamework_data.h"
#include "game/flag.h"
#include "game/gamework_data.h"
#include "string.h"
#include "version.h"
s16 GwLanguage = 1;
s16 GwLanguageSave = -1;
GameStat GWGameStatDefault;
GameStat GWGameStat;
@ -20,15 +25,16 @@ static inline void InitPlayerConfig(void)
{
PlayerConfig *config;
s32 i;
for(i=0; i<4; 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)) {
if (!HuPadStatGet(i)) {
config->iscom = 0;
} else {
}
else {
config->iscom = 1;
}
}
@ -36,11 +42,11 @@ static inline void InitPlayerConfig(void)
static inline void ResetBoardSettings(void)
{
GWRumbleSet(1);
GWMGExplainSet(1);
GWMGShowComSet(1);
GWMessSpeedSet(1);
GWSaveModeSet(0);
GWRumbleSet(1);
GWMGExplainSet(1);
GWMGShowComSet(1);
GWMessSpeedSet(1);
GWSaveModeSet(0);
}
void GWInit(void)
@ -49,23 +55,29 @@ void GWInit(void)
_InitFlag();
GWErase();
InitPlayerConfig();
#if VERSION_JAP
GWGameStat.language = 0;
#elif VERSION_NTSC
GWGameStat.language = 1;
#else
GWLanguageSet(GwLanguage);
#endif
ResetBoardSettings();
}
static inline void ResetMGRecord(GameStat *game_stat)
{
game_stat->mg_record[0] = 18000;
game_stat->mg_record[0] = 300 * REFRESH_RATE;
game_stat->mg_record[1] = 80;
game_stat->mg_record[2] = 3600;
game_stat->mg_record[3] = 7200;
game_stat->mg_record[2] = 60 * REFRESH_RATE;
game_stat->mg_record[3] = 120 * REFRESH_RATE;
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[5] = 60 * REFRESH_RATE;
game_stat->mg_record[6] = 300 * REFRESH_RATE;
game_stat->mg_record[7] = 300 * REFRESH_RATE;
game_stat->mg_record[8] = 300 * REFRESH_RATE;
game_stat->mg_record[9] = 0;
game_stat->mg_record[10] = 300;
game_stat->mg_record[10] = 5 * REFRESH_RATE;
game_stat->mg_record[11] = 0;
game_stat->mg_record[12] = 0;
game_stat->mg_record[13] = 0;
@ -76,9 +88,9 @@ static inline void ResetBoardRecord(GameStat *game_stat)
{
s32 i;
s32 j;
for(i=0; i<9; i++) {
for(j=0; j<8; 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;
@ -90,10 +102,10 @@ static inline void ResetBoardRecord(GameStat *game_stat)
static inline void ResetPresent(GameStat *game_stat)
{
s32 i;
for(i=0; i<60; i++) {
for (i = 0; i < 60; i++) {
game_stat->present[i] = 0;
}
(void)i; //HACK to match GWResetGameStat
(void)i; // HACK to match GWResetGameStat
}
static inline void ResetFlag(GameStat *game_stat)
@ -120,7 +132,13 @@ void GWGameStatReset(void)
GameStat *game_stat = &GWGameStatDefault;
memset(game_stat, 0, sizeof(GameStat));
game_stat->unk_00 = 0;
#if VERSION_JAP
game_stat->language = 0;
#elif VERSION_NTSC
game_stat->language = 1;
#else
game_stat->language = GwLanguage;
#endif
game_stat->sound_mode = 1;
game_stat->rumble = 1;
game_stat->total_stars = 0;
@ -133,23 +151,30 @@ void GWGameStatReset(void)
ResetBoardRecord(game_stat);
ResetPresent(game_stat);
ResetFlag(game_stat);
ResetPauseConfig(game_stat);
ResetPauseConfig(game_stat);
memcpy(&GWGameStat, &GWGameStatDefault, sizeof(GameStat));
ResetBoardSettings();
}
s32 GWMessDelayGet(void)
{
if(GWSystem.mess_delay > 48) {
#if VERSION_NTSC
if (GWSystem.mess_delay > 48) {
GWSystem.mess_speed = 1;
GWSystem.mess_delay = 32;
}
#else
if (GWSystem.mess_delay > 64) {
GWSystem.mess_speed = 1;
GWSystem.mess_delay = 48;
}
#endif
return GWSystem.mess_delay;
}
void GWMGRecordSet(s32 index, u32 value)
{
if(!_CheckFlag(FLAG_ID_MAKE(1, 12))) {
if (!_CheckFlag(FLAG_ID_MAKE(1, 12))) {
GWGameStat.mg_record[index] = value;
}
}
@ -161,22 +186,14 @@ u32 GWMGRecordGet(s32 index)
void GWCharColorGet(s32 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 }
};
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 GWBoardPlayCountSet(s32 board, u8 value)
{
if(value > 99) {
if (value > 99) {
value = 99;
}
GWGameStat.board_play_count[board] = value;
@ -185,13 +202,12 @@ void GWBoardPlayCountSet(s32 board, u8 value)
void GWBoardPlayCountAdd(s32 board, u8 value)
{
value += GWGameStat.board_play_count[board];
if(value > 99) {
if (value > 99) {
value = 99;
}
GWGameStat.board_play_count[board] = value;
}
u8 GWBoardPlayCountGet(s32 board)
{
return GWGameStat.board_play_count[board];
@ -219,8 +235,8 @@ u16 GWBoardMaxCoinsGet(s32 board)
s32 GWBoardWinCountInc(s32 character, s32 board)
{
s32 win_count = GWGameStat.board_win_count[board][character]+1;
if(win_count > 99) {
s32 win_count = GWGameStat.board_win_count[board][character] + 1;
if (win_count > 99) {
win_count = 99;
}
GWGameStat.board_win_count[board][character] = win_count;
@ -244,9 +260,10 @@ s32 GWMGAvailGet(s32 id)
id -= 401;
word = id >> 5;
bit = id % 32;
if(GWGameStat.mg_avail[word] & (1 << bit)) {
if (GWGameStat.mg_avail[word] & (1 << bit)) {
return 1;
} else {
}
else {
return 0;
}
}
@ -268,9 +285,10 @@ s32 GWMGCustomGet(s32 id)
id -= 401;
word = id >> 5;
bit = id % 32;
if(GWGameStat.mg_custom[word] & (1 << bit)) {
if (GWGameStat.mg_custom[word] & (1 << bit)) {
return 1;
} else {
}
else {
return 0;
}
}
@ -302,14 +320,14 @@ s16 GWCoinsGet(s32 player)
void GWCoinsSet(s32 player, s16 value)
{
if(!_CheckFlag(FLAG_ID_MAKE(1, 12))) {
if(value < 0) {
if (!_CheckFlag(FLAG_ID_MAKE(1, 12))) {
if (value < 0) {
value = 0;
}
if(value > 999) {
if (value > 999) {
value = 999;
}
if(value > GWPlayer[player].coins_max) {
if (value > GWPlayer[player].coins_max) {
GWPlayer[player].coins_max = value;
}
GWPlayer[player].coins = value;
@ -318,18 +336,18 @@ void GWCoinsSet(s32 player, s16 value)
void GWCoinsAdd(s32 player, s16 amount)
{
GWCoinsSet(player, GWPlayer[player].coins+amount);
GWCoinsSet(player, GWPlayer[player].coins + amount);
}
void GWStarsSet(s32 player, s16 value)
{
if(value < 0) {
if (value < 0) {
value = 0;
}
if(value > 999) {
if (value > 999) {
value = 999;
}
if(value > GWPlayer[player].stars_max) {
if (value > GWPlayer[player].stars_max) {
GWPlayer[player].stars_max = value;
}
GWPlayer[player].stars = value;
@ -337,7 +355,7 @@ void GWStarsSet(s32 player, s16 value)
void GWStarsAdd(s32 player, s16 amount)
{
GWStarsSet(player, GWPlayer[player].stars+amount);
GWStarsSet(player, GWPlayer[player].stars + amount);
}
s32 GWStarsGet(s32 player)
@ -347,10 +365,10 @@ s32 GWStarsGet(s32 player)
void GWTotalStarsSet(s16 value)
{
if(value < 0) {
if (value < 0) {
value = 0;
}
if(value > 10000) {
if (value > 10000) {
value = 10000;
}
GWGameStat.total_stars = value;
@ -358,7 +376,7 @@ void GWTotalStarsSet(s16 value)
void GWTotalStarsAdd(s16 amount)
{
GWTotalStarsSet(GWGameStat.total_stars+amount);
GWTotalStarsSet(GWGameStat.total_stars + amount);
}
u16 GWTotalStarsGet(void)