From fb36a28e98e5bd0bdc37948ef4d1a30b32999553 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Thu, 3 Jun 2021 00:32:56 -0400 Subject: [PATCH] With this commit, processing of the result of a score set request is 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. --- BuGS/game.s | 21 +++++++++++++++++---- BuGS/globalScores.c | 16 +++++++++------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/BuGS/game.s b/BuGS/game.s index 9a19216..fb5bd3e 100644 --- a/BuGS/game.s +++ b/BuGS/game.s @@ -121,7 +121,7 @@ gameLoop_skipScoreAgeDec anop jsl checkKeyboard - jsl waitForVbl + jsl waitForBeam lda shouldQuit beq gameDone @@ -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' diff --git a/BuGS/globalScores.c b/BuGS/globalScores.c index ead42db..e6df33c 100644 --- a/BuGS/globalScores.c +++ b/BuGS/globalScores.c @@ -248,8 +248,6 @@ void shutdownNetwork(void) void pollNetwork(void) { - Word errorCode; - if (!networkToolsStarted) return; @@ -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; @@ -452,7 +454,6 @@ void sendHighScore(void) return; } - setHighScoreRequest.setHighScoreRequest.requestType = REQUEST_TYPE_SET_SCORE; setHighScoreRequest.setHighScoreRequest.who[3] = '\0'; @@ -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--;