Rename globalScores to netScores to work towards moving it to NetScoresGS

This commit is contained in:
Jeremy Rand 2023-06-08 20:04:22 -04:00
parent 1be8d217f1
commit 3660b47fd3
7 changed files with 53 additions and 53 deletions

View File

@ -23,7 +23,7 @@
9DE37B742694E0B0005FC562 /* level.s in Sources */ = {isa = PBXBuildFile; fileRef = 9DE37B332694E0B0005FC562 /* level.s */; };
9DE37B752694E0B0005FC562 /* tileConvert.s in Sources */ = {isa = PBXBuildFile; fileRef = 9DE37B342694E0B0005FC562 /* tileConvert.s */; };
9DE37B762694E0B0005FC562 /* gameSpider.s in Sources */ = {isa = PBXBuildFile; fileRef = 9DE37B362694E0B0005FC562 /* gameSpider.s */; };
9DE37B772694E0B0005FC562 /* globalScores.c in Sources */ = {isa = PBXBuildFile; fileRef = 9DE37B372694E0B0005FC562 /* globalScores.c */; };
9DE37B772694E0B0005FC562 /* netScores.c in Sources */ = {isa = PBXBuildFile; fileRef = 9DE37B372694E0B0005FC562 /* netScores.c */; };
9DE37B782694E0B0005FC562 /* game.s in Sources */ = {isa = PBXBuildFile; fileRef = 9DE37B382694E0B0005FC562 /* game.s */; };
9DE37B792694E0B0005FC562 /* gameShot.s in Sources */ = {isa = PBXBuildFile; fileRef = 9DE37B3A2694E0B0005FC562 /* gameShot.s */; };
9DE37B7A2694E0B0005FC562 /* loadSounds.c in Sources */ = {isa = PBXBuildFile; fileRef = 9DE37B3B2694E0B0005FC562 /* loadSounds.c */; };
@ -106,14 +106,14 @@
9DE37B342694E0B0005FC562 /* tileConvert.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = tileConvert.s; sourceTree = "<group>"; };
9DE37B352694E0B0005FC562 /* main.rez */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.rez; path = main.rez; sourceTree = "<group>"; };
9DE37B362694E0B0005FC562 /* gameSpider.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = gameSpider.s; sourceTree = "<group>"; };
9DE37B372694E0B0005FC562 /* globalScores.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = globalScores.c; sourceTree = "<group>"; };
9DE37B372694E0B0005FC562 /* netScores.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = netScores.c; sourceTree = "<group>"; };
9DE37B382694E0B0005FC562 /* game.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = "<group>"; };
9DE37B392694E0B0005FC562 /* main.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = main.h; sourceTree = "<group>"; };
9DE37B3A2694E0B0005FC562 /* gameShot.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = gameShot.s; sourceTree = "<group>"; };
9DE37B3B2694E0B0005FC562 /* loadSounds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = loadSounds.c; sourceTree = "<group>"; };
9DE37B3C2694E0B0005FC562 /* loadSounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = loadSounds.h; sourceTree = "<group>"; };
9DE37B3D2694E0B0005FC562 /* gameMushroom.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = gameMushroom.s; sourceTree = "<group>"; };
9DE37B3E2694E0B0005FC562 /* globalScores.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = globalScores.h; sourceTree = "<group>"; };
9DE37B3E2694E0B0005FC562 /* netScores.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = netScores.h; sourceTree = "<group>"; };
9DE37B3F2694E0B0005FC562 /* globals.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = globals.s; sourceTree = "<group>"; };
9DE37B402694E0B0005FC562 /* gameSegments.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = gameSegments.s; sourceTree = "<group>"; };
9DE37B412694E0B0005FC562 /* score.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = score.s; sourceTree = "<group>"; };
@ -221,8 +221,8 @@
9DE37B732694E0B0005FC562 /* genData.pl */,
9DE37B442694E0B0005FC562 /* global.macros */,
9DE37B3F2694E0B0005FC562 /* globals.s */,
9DE37B372694E0B0005FC562 /* globalScores.c */,
9DE37B3E2694E0B0005FC562 /* globalScores.h */,
9DE37B372694E0B0005FC562 /* netScores.c */,
9DE37B3E2694E0B0005FC562 /* netScores.h */,
9DE37B332694E0B0005FC562 /* level.s */,
9DE37B3B2694E0B0005FC562 /* loadSounds.c */,
9DE37B3C2694E0B0005FC562 /* loadSounds.h */,
@ -478,7 +478,7 @@
9DE37B852694E0B0005FC562 /* solid.s in Sources */,
9DE37B7C2694E0B0005FC562 /* globals.s in Sources */,
9DE37B872694E0B0005FC562 /* symbols.s in Sources */,
9DE37B772694E0B0005FC562 /* globalScores.c in Sources */,
9DE37B772694E0B0005FC562 /* netScores.c in Sources */,
9DE37B8B2694E0B0005FC562 /* scores.s in Sources */,
9DE37B932694E0B0005FC562 /* gameSound.s in Sources */,
9DE37B922694E0B0005FC562 /* gameScorpion.s in Sources */,

View File

@ -97,7 +97,7 @@ gameLoop_skipPreload anop
; The following is the network poll code which runs when not playing a game
lda gameState
bne gameLoop_skipNetwork
jsl pollNetwork
jsl NSGS_PollNetwork
lda hasGlobalHighScores
beq gameLoop_skipNetwork
lda highScoreCountdown
@ -247,7 +247,7 @@ startGame_singlePlayer anop
jsl spiderInitGame
jsl levelInit
jsl soundInit
jsl disconnectNetwork
jsl NSGS_DisconnectNetwork
; Fall through intentionally here...
startLevel entry
jsl segmentsInitLevel

View File

@ -19,7 +19,7 @@
#include "main.h"
#include "game.h"
#include "globalScores.h"
#include "netScores.h"
#include "settings.h"
#include "tileData.h"
@ -99,7 +99,7 @@ void showConnectionString(BOOLEAN display)
int main(void)
{
static tHighScoreInitParams highScoreInitParams;
static tNSGSHighScoreInitParams highScoreInitParams;
int event;
Ref toolStartupRef;
@ -138,14 +138,14 @@ int main(void)
highScoreInitParams.uploadSpin = uploadSpin;
highScoreInitParams.scorePosition = scorePosition;
initNetwork(&highScoreInitParams);
NSGS_InitNetwork(&highScoreInitParams);
if (!loadSettings())
saveSettings();
game();
shutdownNetwork();
NSGS_ShutdownNetwork();
ShutDownTools(refIsHandle, toolStartupRef);
TOOLFAIL("Unable to shutdown tools");

View File

@ -1,6 +1,6 @@
/*
* globalScores.c
* BuGS
* netScores.c
* NetScoresGS
*
* Created by Jeremy Rand on 2021-05-23.
* Copyright © 2021 Jeremy Rand. All rights reserved.
@ -17,7 +17,7 @@
#include <orca.h>
#include <tcpip.h>
#include "globalScores.h"
#include "netScores.h"
// Defines
@ -77,7 +77,7 @@ typedef struct tHelloResponse {
typedef struct tScoresResponse {
uint16_t responseType;
tHighScores highScores;
tNSGSHighScores highScores;
} tScoresResponse;
@ -144,7 +144,7 @@ typedef void (*tGameNetworkStateHandler)(void);
typedef struct tGameNetworkGlobals {
Boolean networkStartedConnected;
tHighScoreInitParams initParams;
tNSGSHighScoreInitParams initParams;
tGameNetworkState gameNetworkState;
dnrBuffer domainNameResolution;
srBuff tcpStatus;
@ -227,7 +227,7 @@ tSetHighScoreRequestWithHash setHighScoreRequest;
// Implementation
void initNetwork(tHighScoreInitParams * params)
void NSGS_InitNetwork(tNSGSHighScoreInitParams * params)
{
networkGlobals = NULL;
@ -289,7 +289,7 @@ void initNetwork(tHighScoreInitParams * params)
}
void shutdownNetwork(void)
void NSGS_ShutdownNetwork(void)
{
if ((!networkGlobals->networkStartedConnected) &&
(networkGlobals->gameNetworkState > GAME_NETWORK_UNCONNECTED)) {
@ -312,7 +312,7 @@ static void abortConnection(void)
}
void disconnectNetwork(void)
void NSGS_DisconnectNetwork(void)
{
if (networkGlobals == NULL)
return;
@ -326,7 +326,7 @@ void disconnectNetwork(void)
while (networkGlobals->gameNetworkState > GAME_NETWORK_TCP_UNCONNECTED) {
networkGlobals->initParams.waitForVbl();
pollNetwork();
NSGS_PollNetwork();
}
}
}
@ -717,7 +717,7 @@ static void handleClosingTcp(void)
networkGlobals->gameNetworkState = GAME_NETWORK_TCP_UNCONNECTED;
}
void pollNetwork(void)
void NSGS_PollNetwork(void)
{
if (networkGlobals == NULL)
return;
@ -728,7 +728,7 @@ void pollNetwork(void)
}
BOOLEAN canSendHighScore(void)
BOOLEAN NSGS_CanSendHighScore(void)
{
if (networkGlobals == NULL)
return FALSE;
@ -744,7 +744,7 @@ BOOLEAN canSendHighScore(void)
return TRUE;
}
BOOLEAN sendHighScore(void)
BOOLEAN NSGS_SendHighScore(void)
{
uint16_t cycleCount = 0;
@ -755,7 +755,7 @@ BOOLEAN sendHighScore(void)
do {
networkGlobals->initParams.waitForVbl();
pollNetwork();
NSGS_PollNetwork();
cycleCount++;
if ((cycleCount & 0x7) == 0) {

View File

@ -1,31 +1,31 @@
/*
* globalScores.h
* BuGS
* netScores.h
* NetScoresGS
*
* Created by Jeremy Rand on 2021-05-23.
* Copyright © 2021 Jeremy Rand. All rights reserved.
*/
#ifndef _GUARD_PROJECTBuGS_FILEglobalScores_
#define _GUARD_PROJECTBuGS_FILEglobalScores_
#ifndef _GUARD_PROJECTNetScoresGS_FILEnetScores_
#define _GUARD_PROJECTNetScoresGS_FILEnetScores_
#include <TYPES.h>
typedef struct tHighScore
typedef struct tNSGSHighScore
{
char scoreText[10];
char who[4];
unsigned long score;
} tHighScore;
} tNSGSHighScore;
typedef struct tHighScores
typedef struct tNSGSHighScores
{
tHighScore score[10];
} tHighScores;
tNSGSHighScore score[10];
} tNSGSHighScores;
typedef struct tHighScoreInitParams
typedef struct tNSGSHighScoreInitParams
{
/* This structure is initialized by the game and passed by pointer to the high score code. It consists of
a series of data members and a series of callbacks which are provided by the game.
@ -50,7 +50,7 @@ typedef struct tHighScoreInitParams
/* This function should display a message to the user that the network is being brought up and they should
be patient when the argument is TRUE and when the argument is FALSE, it should clear that message. This
function shouldn't block and just put something on the screen to say that the connection is being brought
up or clear that message. It is called sometimes (rarely) by pollNetwork(). It is called with argument
up or clear that message. It is called sometimes (rarely) by NSGS_PollNetwork(). It is called with argument
TRUE and will always be called with FALSE sometime after that.
*/
void (*displayConnectionString)(BOOLEAN display);
@ -63,7 +63,7 @@ typedef struct tHighScoreInitParams
/* This argument iterates over 0, 1, 2, 3 and then back to 0, 1, 2, etc and is intended to show some kind
of spinner to the user while uploading a high score to the server. This function shouldn't block for
any real amount of time and just cause something on the screen to change to make sure the player doesn't
think something has hung while the upload is in progress. It is called when sendHighScore() is called
think something has hung while the upload is in progress. It is called when NSGS_SendHighScore() is called
by the game.
*/
void (*uploadSpin)(int);
@ -72,52 +72,52 @@ typedef struct tHighScoreInitParams
of this player's score among the total number of scores recorded for this game. This information
should be displayed to the user. The function can block while this information is being displayed
and that message should be cleaned up before the function returns to the caller. This function is
called by sendHighScore().
called by NSGS_SendHighScore().
*/
void (*scorePosition)(unsigned int position, unsigned int numberOfScores);
} tHighScoreInitParams;
} tNSGSHighScoreInitParams;
/* Call this function once at launch. The pointer to the parameters is copied so the structure does not need
to remain valid after the call to this function.
*/
extern void initNetwork(tHighScoreInitParams * params);
extern void NSGS_InitNetwork(tNSGSHighScoreInitParams * params);
/* Call this when a game is about to start. It will interrupt any network operation in progress and get ready for
a quiet period where polling will stop until the game is over. That way, all CPU time can be focused on the game.
This function may call the waitForVbl() callback.
*/
extern void disconnectNetwork(void);
extern void NSGS_DisconnectNetwork(void);
/* Call this every frame refresh period when a game is _not_ in progress. This does any network operations required
to download high scores. During this function call, the displayConnectionString() callback may be called.
*/
extern void pollNetwork(void);
extern void NSGS_PollNetwork(void);
/* Call this function once when the game is quitting. */
extern void shutdownNetwork(void);
extern void NSGS_ShutdownNetwork(void);
/* Call this function when the player has a high score that should be recorded online. This function will return
TRUE if the network is up and a high score can be sent and if so, the game should call sendHighScore() to send
TRUE if the network is up and a high score can be sent and if so, the game should call NSGS_SendHighScore() to send
the high score. If FALSE is returned, then the user is playing while offline and no attempt should be made to
send the high score.
*/
extern BOOLEAN canSendHighScore(void);
extern BOOLEAN NSGS_CanSendHighScore(void);
/* Assuming canSendHighScore() returned TRUE, the game can call this function to actually try to send the high score
/* Assuming NSGS_CanSendHighScore() returned TRUE, the game can call this function to actually try to send the high score
to the server. If this function returns TRUE, then the score was successfully sent to the server. If FALSE
is returned, then an error has occurred. The game can offer the user the option to retry to the upload of the
score and if the user would like to retry, just call sendHighScore() again. During this function call, the
score and if the user would like to retry, just call NSGS_SendHighScore() again. During this function call, the
waitForVbl(), uploadSpin() and scorePosition() callbacks may be called.
TODO - Pass the score as an argument rather than through globals.
*/
extern BOOLEAN sendHighScore(void);
extern BOOLEAN NSGS_SendHighScore(void);
#endif /* define _GUARD_PROJECTBuGS_FILEglobalScores_ */
#endif /* define _GUARD_PROJECTNetScoresGS_FILEnetScores_ */

View File

@ -787,7 +787,7 @@ checkHighScore_doneInitials anop
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_WHO_OFFSET-1,y
sta setHighScoreRequest+4
jsl saveSettings
jsl canSendHighScore
jsl NSGS_CanSendHighScore
bne checkHighScore_retry
brl checkHighScore_doneNetwork
@ -814,7 +814,7 @@ checkHighScore_retry anop
_overwriteGameTile TILE_EMPTY
_overwriteGameTile TILE_EMPTY
_overwriteGameTile TILE_EMPTY
jsl sendHighScore
jsl NSGS_SendHighScore
beq checkHighScore_retryPrompt
brl checkHighScore_doneNetwork

View File

@ -13,7 +13,7 @@
#include <Memory.h>
#include "game.h"
#include "globalScores.h"
#include "netScores.h"
#include "settings.h"
#include "tileData.h"
@ -30,7 +30,7 @@ typedef struct tSettingsData
char magic[4];
int version;
Boolean stereoCorrect;
tHighScore highScores[NUM_HIGH_SCORES];
tNSGSHighScore highScores[NUM_HIGH_SCORES];
} tSettingsData;