Skip to content

Commit

Permalink
With this commit, processing of the result of a score set request is …
Browse files Browse the repository at this point in the history
…working. The connection seems to drop during the game and I don't want to poll the network during the game so the next steps will be to close and re-open the connection between games.
  • Loading branch information
jeremysrand committed Jun 3, 2021
1 parent 9a77919 commit fb36a28
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
21 changes: 17 additions & 4 deletions BuGS/game.s
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ gameLoop_skipScoreAgeDec anop

jsl checkKeyboard

jsl waitForVbl
jsl waitForBeam

lda shouldQuit
beq gameDone
Expand Down Expand Up @@ -1182,15 +1182,28 @@ waitForKey_loop anop
rtl


waitForVbl entry
vblLoop anop
waitForBeam entry
beamLoop anop
lda >VERTICAL_COUNTER ; load the counter value
and #$80ff ; mask out the VBL bits
asl a ; shift the word around
adc #0 ; move MSB -> LSB
cmp #$1c8
bge vblLoop
bge beamLoop
rtl


waitForVbl entry
vblLoop1 anop
short m
lda #$fe
cmp >READ_VBL
bpl vblLoop1
vblLoop2 anop
cmp >READ_VBL
bmi vblLoop2
long m
rtl


shouldQuit dc i2'1'
Expand Down
16 changes: 9 additions & 7 deletions BuGS/globalScores.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ void shutdownNetwork(void)

void pollNetwork(void)
{
Word errorCode;

if (!networkToolsStarted)
return;

Expand Down Expand Up @@ -414,13 +412,17 @@ void pollNetwork(void)
gameNetworkState = GAME_NETWORK_PROTOCOL_FAILED;
}

if ((setHighScoreResponse.responseType != RESPONSE_TYPE_STATUS) ||
(!setHighScoreResponse.success)) {
if (setHighScoreResponse.responseType != RESPONSE_TYPE_STATUS) {
TCPIPAbortTCP(ipid);
TCPIPLogout(ipid);
gameNetworkState = GAME_NETWORK_PROTOCOL_FAILED;
}

if (!setHighScoreResponse.success) {
TCPIPAbortTCP(ipid);
TCPIPLogout(ipid);
gameNetworkState = GAME_NETWORK_PROTOCOL_FAILED;
}
// TODO - I don't think we are getting out of this state successfully...

globalScoreAge = 0;
gameNetworkState = GAME_NETWORK_REQUEST_SCORES;
Expand Down Expand Up @@ -452,7 +454,6 @@ void sendHighScore(void)
return;
}


setHighScoreRequest.setHighScoreRequest.requestType = REQUEST_TYPE_SET_SCORE;
setHighScoreRequest.setHighScoreRequest.who[3] = '\0';

Expand All @@ -465,13 +466,14 @@ void sendHighScore(void)
TCPIPAbortTCP(ipid);
TCPIPLogout(ipid);
gameNetworkState = GAME_NETWORK_SOCKET_ERROR;
return;
}

gameNetworkState = GAME_NETWORK_WAITING_FOR_SCORE_ACK;
bytesRead = 0;

timeout = 10*60;
while (gameNetworkState != GAME_NETWORK_SCORES_RETRIEVED) {
while (gameNetworkState != GAME_NETWORK_REQUEST_SCORES) {
waitForVbl();
pollNetwork();
timeout--;
Expand Down

0 comments on commit fb36a28

Please sign in to comment.