From 6947d8762cbf71446bb3ee84e04acb013d23ea81 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Wed, 30 Dec 2020 02:31:18 -0500 Subject: [PATCH] Add a way to swap left and right stereo channels and save the value in the settings. --- BuGS/game.s | 31 ++++++++++++++++++ BuGS/gameSound.s | 13 ++++++++ BuGS/main.c | 81 +++++++++++++++++++++++++----------------------- TODO.md | 1 - 4 files changed, 87 insertions(+), 39 deletions(-) diff --git a/BuGS/game.s b/BuGS/game.s index ad7a439..2c9ff72 100644 --- a/BuGS/game.s +++ b/BuGS/game.s @@ -754,6 +754,29 @@ gameOver entry _setGameTile TILE_EMPTY _setGameTile TILE_EMPTY _setGameTile TILE_EMPTY + _setGameTile TILE_LETTER_S + _setGameTile TILE_EMPTY + _setGameTile TILE_LETTER_T + _setGameTile TILE_LETTER_O + _setGameTile TILE_EMPTY + _setGameTile TILE_LETTER_S + _setGameTile TILE_LETTER_W + _setGameTile TILE_LETTER_A + _setGameTile TILE_LETTER_P + _setGameTile TILE_EMPTY + _setGameTile TILE_LETTER_S + _setGameTile TILE_LETTER_T + _setGameTile TILE_LETTER_E + _setGameTile TILE_LETTER_R + _setGameTile TILE_LETTER_E + _setGameTile TILE_LETTER_O + _setGameTile TILE_EMPTY + _setGameTile TILE_EMPTY + + ldx #GAME_NUM_TILES_WIDE*40+2 + _setGameTile TILE_EMPTY + _setGameTile TILE_EMPTY + _setGameTile TILE_EMPTY _setGameTile TILE_LETTER_Q _setGameTile TILE_EMPTY _setGameTile TILE_LETTER_T @@ -798,6 +821,11 @@ checkKey_loop2 anop cmp #'2' beq checkKey_game + + cmp #'s' + beq checkKey_swapStereo + cmp #'S' + beq checkKey_swapStereo checkKey_done anop long i,m @@ -814,6 +842,9 @@ checkKey_game anop sec sbc #'1' jmp startGame + +checkKey_swapStereo anop + jmp swapStereoSettings waitForKey entry diff --git a/BuGS/gameSound.s b/BuGS/gameSound.s index fbdb081..a6d1b83 100644 --- a/BuGS/gameSound.s +++ b/BuGS/gameSound.s @@ -1293,6 +1293,19 @@ unpauseSound_skipSegment anop unpauseSound_skipFlea anop rtl + +swapStereoChannels entry + ldx #SIZEOF_TILE_INFO*NUM_GAME_TILES-SIZEOF_TILE_INFO +swapStereoChannels_loop anop + lda tileRightVolume,x + eor #$ff + sta tileRightVolume,x + dex + dex + bpl swapStereoChannels_loop + + rtl + bonusSoundOscReg dc i2'SOUND_REG_CONTROL+BONUS_OSC_NUM' fleaSoundIsPlaying dc i2'1' diff --git a/BuGS/main.c b/BuGS/main.c index c7d25d0..a093aa1 100644 --- a/BuGS/main.c +++ b/BuGS/main.c @@ -52,13 +52,38 @@ typedef struct tSettingsData unsigned int userid; unsigned int randomSeed; -tSettingsData settings; +tSettingsData settings = { + { 'B', 'u', 'G', 'S' }, + 0, + FALSE, + { + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}}, + { 0, { ' ', ' ', ' '}} + } +}; +RefNumRecGS closeRec; +OpenRecGS openRec; +IORecGS readRec; +CreateRecGS createRec; +IORecGS writeRec; +NameRecGS destroyRec; Handle filenameHandle = NULL; /* Implementation */ +extern void swapStereoChannels(void); + + word randomMushroomOffset(void) { /* We do not put mushrooms in the bottom tile so we subtract the width here to find @@ -164,37 +189,8 @@ void allocateFilenameHandle(void) } -void initSettings(void) -{ - int i; - tHighScore *scorePtr; - - settings.magic[0] = 'B'; - settings.magic[1] = 'u'; - settings.magic[2] = 'G'; - settings.magic[3] = 'S'; - - settings.version = 0; - - settings.swapStereo = FALSE; - - scorePtr = &(settings.highScores[0]); - for (i = 0; i < NUM_HIGH_SCORES; i++); - { - scorePtr->score = 0; - scorePtr->who[0] = ' '; - scorePtr->who[1] = ' '; - scorePtr->who[2] = ' '; - - scorePtr++; - } -} - - void deleteSettings(void) { - NameRecGS destroyRec; - allocateFilenameHandle(); HLock(filenameHandle); @@ -208,10 +204,6 @@ void deleteSettings(void) void saveSettings(void) { - RefNumRecGS closeRec; - CreateRecGS createRec; - OpenRecGS openRec; - IORecGS writeRec; BOOLEAN success = false; deleteSettings(); @@ -259,9 +251,6 @@ void saveSettings(void) BOOLEAN loadSettings(void) { - RefNumRecGS closeRec; - OpenRecGS openRec; - IORecGS readRec; BOOLEAN success = FALSE; allocateFilenameHandle(); @@ -280,6 +269,7 @@ BOOLEAN loadSettings(void) readRec.refNum = openRec.refNum; readRec.dataBuffer = (Pointer)&settings; readRec.requestCount = sizeof(tSettingsData); + ReadGS(&readRec); success = (toolerror() == 0); } @@ -299,10 +289,26 @@ BOOLEAN loadSettings(void) success = FALSE; } + if (success) + { + if (settings.swapStereo) + { + swapStereoChannels(); + } + } + return success; } +void swapStereoSettings(void) +{ + swapStereoChannels(); + settings.swapStereo = !settings.swapStereo; + saveSettings(); +} + + int main(void) { int event; @@ -332,7 +338,6 @@ int main(void) InitMouse(0); SetMouse(transparent); - initSettings(); if (!loadSettings()) saveSettings(); diff --git a/TODO.md b/TODO.md index b3d9b93..3f893e0 100644 --- a/TODO.md +++ b/TODO.md @@ -4,6 +4,5 @@ TODO * Implement a high score list and save the high scores across restarts * Look at supporting a global high score list for systems with an Internet connection * Implement the code for supporting a two player game -* Provide a way to swap left and right stereo channels * Look at supporting Versions in order to support automatic SW upgrades * So much more.