Captain Spazer Posted September 18, 2016 Share Posted September 18, 2016 (edited) I have an issue with getting my project to save highscores, I'm using RandomTerrain's "Save Highscore" example and it's self explanatory yet I can't get it to work, hm. It goes into bank3 which I set aside for when the game is over, but it won't cycle through any scores, it just shows the resent score the player got, what did I do wrong? bank 2 temp1=temp1 __Bank_2 ;*************************************************************** ;*************************************************************** ; ; Program Start/Restart ; __Start_Restart ;*************************************************************** ; ; Displays the screen to avoid going over 262 when reset. ; drawscreen ;*************************************************************** ; ; Clears the playfield. ; pfclear ;*************************************************************** ; ; Mutes volume of both sound channels. ; AUDV0 = 0 : AUDV1 = 0 ;*************************************************************** ; ; Clears all normal variables and the extra 9 (fastest way). ; a = 0 : b = 0 : c = 0 : d = 0 : e = 0 : f = 0 : g = 0 : h = 0 : i = 0 j = 0 : k = 0 : l = 0 : m = 0 : n = 0 : o = 0 : p = 0 : q = 0 : r = 0 s = 0 : t = 0 : u = 0 : v = 0 : w = 0 : x = 0 : y = 0 : z = 0 var0 = 0 : var1 = 0 : var2 = 0 : var3 = 0 : var4 = 0 var5 = 0 : var6 = 0 : var7 = 0 : var8 = 0 rem **************************************************************** rem * rem * Create aliases for variables. rem * rem * You can have more than one alias for each variable. rem * If you use different aliases for bit operations, it is rem * easier to understand and remember what they do. rem * dim Master_Counter = j dim Swap_Scores = k dim Debounce_Reset = k dim Debounce_Fire = k dim High_Score01 = l dim High_Score02 = m dim High_Score03 = n dim Store_Temp_Score01 = o dim Store_Temp_Score02 = p dim Store_Temp_Score03 = q rem **************************************************************** rem * Makes better random numbers. rem * dim rand16 = z rem **************************************************************** rem * Converts 6 digit score to 3 sets of two digits. rem * dim sc1 = score dim sc2 = score+1 dim sc3 = score+2 Master_Counter = 0 : score = 0 : Swap_Scores{2}=0 bank 3 Game_Over_Setup rem **************************************************************** rem **************************************************************** rem **************************************************************** rem **************************************************************** rem * rem * Game Over rem * rem **************************************************************** rem **************************************************************** rem **************************************************************** rem **************************************************************** rem **************************************************************** rem * Checks for a new high score. rem * if sc1 > High_Score01 then New_High_Score if sc1 < High_Score01 then Skip_High_Score rem * First byte equal. Do the next test. if sc2 > High_Score02 then New_High_Score if sc2 < High_Score02 then Skip_High_Score rem * Second byte equal. Do the next test. if sc3 > High_Score03 then New_High_Score if sc3 < High_Score03 then Skip_High_Score rem * All bytes equal. goto Skip_High_Score New_High_Score High_Score01 = sc1 : High_Score02 = sc2 : High_Score03 = sc3 Skip_High_Score rem **************************************************************** rem * Setup for the restart loop. rem * Master_Counter=0 : Debounce_Reset{1}=1 : COLUBK=$62 Store_Temp_Score01 = sc1 : Store_Temp_Score02 = sc2 : Store_Temp_Score03 = sc3 Loop_Ready_to_Restart rem **************************************************************** rem * The score will flip between the current score and rem * the high score every 2 seconds. rem * Master_Counter=Master_Counter+1 if Master_Counter < 120 then Skip_Flip Master_Counter = 0 : Swap_Scores{2} = !Swap_Scores{2} if Swap_Scores{2} then scorecolor = $AE : sc1=High_Score01 : sc2=High_Score02 : sc3=High_Score03 : goto Skip_Flip scorecolor = $1C : sc1=Store_Temp_Score01 : sc2=Store_Temp_Score02 : sc3=Store_Temp_Score03 Skip_Flip rem **************************************************************** rem * The screen would be blank without drawscreen. rem * drawscreen rem **************************************************************** rem * rem * Restart the game if reset switch or fire button is pressed. rem * rem **************************************************************** rem * rem * If the fire button and reset are not pressed, skip this section. rem * if !switchreset && !joy0fire then Debounce_Reset{1} = 0 : goto Skip_Game_Over_Restart rem **************************************************************** rem * If the fire button and reset switch haven't been released rem * since starting, skip this section. rem * if Debounce_Reset{1} then Skip_Game_Over_Restart goto __Start_Restart Skip_Game_Over_Restart goto Loop_Ready_to_Restart Entire code: ;**************************************************************** ; ; This program uses the DPC+ kernel. ; set kernel DPC+ ;**************************************************************** ; ; Standard used in North America and most of South America. ; set tv ntsc set smartbranching on ;**************************************************************** ; ; Helps player1 sprites register a collision with the playfield. ; set kernel_options collision(player1,playfield) ;*************************************************************** ; ; Variable aliases go here (DIMs). ; ;*************************************************************** ; ; (You can have more than one alias for each variable.) ; ;``````````````````````````````````````````````````````````````` ; Scroll counter. ; dim _Scroll_Counter = a ;``````````````````````````````````````````````````````````````` ; Bits for various jobs. ; dim _Bit0_Reset_Restrainer = y dim _Bit7_Flip_Scroll = y goto __Bank_2 bank2 bank 2 temp1=temp1 __Bank_2 ;*************************************************************** ;*************************************************************** ; ; Program Start/Restart ; __Start_Restart ;*************************************************************** ; ; Displays the screen to avoid going over 262 when reset. ; drawscreen ;*************************************************************** ; ; Clears the playfield. ; pfclear ;*************************************************************** ; ; Mutes volume of both sound channels. ; AUDV0 = 0 : AUDV1 = 0 ;*************************************************************** ; ; Clears all normal variables and the extra 9 (fastest way). ; a = 0 : b = 0 : c = 0 : d = 0 : e = 0 : f = 0 : g = 0 : h = 0 : i = 0 j = 0 : k = 0 : l = 0 : m = 0 : n = 0 : o = 0 : p = 0 : q = 0 : r = 0 s = 0 : t = 0 : u = 0 : v = 0 : w = 0 : x = 0 : y = 0 : z = 0 var0 = 0 : var1 = 0 : var2 = 0 : var3 = 0 : var4 = 0 var5 = 0 : var6 = 0 : var7 = 0 : var8 = 0 rem **************************************************************** rem * rem * Create aliases for variables. rem * rem * You can have more than one alias for each variable. rem * If you use different aliases for bit operations, it is rem * easier to understand and remember what they do. rem * dim Master_Counter = j dim Swap_Scores = k dim Debounce_Reset = k dim Debounce_Fire = k dim High_Score01 = l dim High_Score02 = m dim High_Score03 = n dim Store_Temp_Score01 = o dim Store_Temp_Score02 = p dim Store_Temp_Score03 = q rem **************************************************************** rem * Makes better random numbers. rem * dim rand16 = z rem **************************************************************** rem * Converts 6 digit score to 3 sets of two digits. rem * dim sc1 = score dim sc2 = score+1 dim sc3 = score+2 Master_Counter = 0 : score = 0 : Swap_Scores{2}=0 ;*************************************************************** ; ; Playfield data. ; playfield: X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X end ;*************************************************************** ; ; Playfield colors. ; pfcolors: $0E $0C $0A $08 $06 $1E $1C $1A $18 $16 $2E $2C $2A $28 $26 $3E $3C $3A $38 $36 $4E $4C $4A $48 $46 $5E $5C $5A $58 $56 $6E $6C $6A $68 $66 $7E $7C $7A $78 $76 $9E $9C $9A $98 $96 $AE $AC $AA $A8 $A6 $BE $BC $BA $B8 $B6 $CE $CC $CA $C8 $C6 $DE $DC $DA $D8 $D6 $EE $EC $EA $E8 $E6 $3E $3C $3A $38 $36 $4E $4C $4A $48 $46 $5E $5C $5A $58 $56 $6E $6C $6A $68 $66 $7E $7C $7A $78 $76 $8E $8C $8A $88 $86 $9E $9C $9A $98 $96 $BE $BC $BA $B8 $B6 $CE $CC $CA $C8 $C6 $FE $FC $FA $F8 $F6 end ;*************************************************************** ; ; Score colors. ; scorecolors: $1E $1C $1A $1A $18 $18 $16 $16 end ;*************************************************************** ; ; Restrains the reset switch for the main loop. ; ; This bit fixes it so the reset switch becomes inactive if ; it hasn't been released after being pressed once. ; _Bit0_Reset_Restrainer{0} = 1 player0x=75 : player0y=150 player1x=40 : player1y=0 player2x=40 : player2y=20 player3x=40 : player3y=40 player4x=40 : player4y=60 player5x=40 : player5y=80 player6x=40 : player6y=100 ;*************************************************************** ;*************************************************************** ; ; Main Loop ; __Main_Loop player0: %00111000 %00111000 %11111110 %11111110 %00101000 %00101000 %00111000 %11111110 %11111110 %00111000 %01000100 %11111110 end player0color: $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E end player1-6: %00111000 %00111000 %11111110 %11111110 %00101000 %00101000 %00111000 %11111110 %11111110 %00111000 %01000100 %11111110 end player1color: $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E end player2color: $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E end player3color: $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E end player4color: $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E end player5color: $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E end player6color: $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E $1E end ;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;``````````````````````````````````````````````````````````````` ; ; Gameplay logic goes here. ; ;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;``````````````````````````````````````````````````````````````` if joy0left then player0x=player0x-1 if joy0right then player0x=player0x+1 if i<10 && b=0 then player1y=player1y+1 if i<10 && c=0 then player2y=player2y+1 if i<10 && d=0 then player3y=player3y+1 if i<10 && f=0 then player4y=player4y+1 if i<10 && g=0 then player5y=player5y+1 if i<10 && h=0 then player6y=player6y+1 if i>=10 && i<20 && b=0 then player1y=player1y+2 if i>=10 && i<20 && c=0 then player2y=player2y+2 if i>=10 && i<20 && d=0 then player3y=player3y+2 if i>=10 && i<20 && f=0 then player4y=player4y+2 if i>=10 && i<20 && g=0 then player5y=player5y+2 if i>=10 && i<20 && h=0 then player6y=player6y+2 if i>=20 && i<40 && b=0 then player1y=player1y+3 if i>=20 && i<40 && c=0 then player2y=player2y+3 if i>=20 && i<40 && d=0 then player3y=player3y+3 if i>=20 && i<40 && f=0 then player4y=player4y+3 if i>=20 && i<40 && g=0 then player5y=player5y+3 if i>=20 && i<40 && h=0 then player6y=player6y+3 if i>=40 && i<60 && b=0 then player1y=player1y+4 if i>=40 && i<60 && c=0 then player2y=player2y+4 if i>=40 && i<60 && d=0 then player3y=player3y+4 if i>=40 && i<60 && f=0 then player4y=player4y+4 if i>=40 && i<60 && g=0 then player5y=player5y+4 if i>=40 && i<60 && h=0 then player6y=player6y+4 if i>=60 && i<80 && b=0 then player1y=player1y+5 if i>=60 && i<80 && c=0 then player2y=player2y+5 if i>=60 && i<80 && d=0 then player3y=player3y+5 if i>=60 && i<80 && f=0 then player4y=player4y+5 if i>=60 && i<80 && g=0 then player5y=player5y+5 if i>=60 && i<80 && h=0 then player6y=player6y+5 if player1y>160 then b=1 if b=1 then player1x=255 : player1y=255 : b=2 if b=2 then player1x=rand : player1y=0 : b=0 if player2y>160 then c=1 if c=1 then player2x=255 : player2y=255 : c=2 if c=2 then player2x=rand : player2y=0 : c=0 if player3y>160 then d=1 if d=1 then player3x=255 : player3y=255 : d=2 if d=2 then player3x=rand : player3y=0 : d=0 if player4y>160 then f=1 if f=1 then player4x=255 : player4y=255 : f=2 if f=2 then player4x=rand : player4y=0 : f=0 if player5y>160 then g=1 if g=1 then player5x=255 : player5y=255 : g=2 if g=2 then player5x=rand : player5y=0 : g=0 if player6y>160 then h=1 if h=1 then player6x=255 : player6y=255 : h=2 if h=2 then player6x=rand : player6y=0 : h=0 if player1x<30 then b=1 if player1x>135 then b=1 if player2x<30 then c=1 if player2x>135 then c=1 if player3x<30 then d=1 if player3x>135 then d=1 if player4x<30 then f=1 if player4x>135 then f=1 if player5x<30 then g=1 if player5x>135 then g=1 if player6x<30 then h=1 if player6x>135 then h=1 e=e+1 if e=60 then score=score+1 : i=i+1 : e=0 if collision(player0,player1) then goto Game_Over_Setup bank3 ;*************************************************************** ; ; Scrolls the foreground color up and down. ; _Scroll_Counter = _Scroll_Counter + 1 if _Bit7_Flip_Scroll{7} then pfscroll 255 4 4 if !_Bit7_Flip_Scroll{7} then pfscroll 1 4 4 if _Scroll_Counter < 32 then goto __Skip_Scroll _Scroll_Counter = 0 _Bit7_Flip_Scroll{7} = !_Bit7_Flip_Scroll{7} __Skip_Scroll ;*************************************************************** ; ; 88 rows that are 2 scanlines high. ; DF6FRACINC = 255 ; Background colors. DF4FRACINC = 255 ; Playfield colors. DF0FRACINC = 128 ; Column 0. DF1FRACINC = 128 ; Column 1. DF2FRACINC = 128 ; Column 2. DF3FRACINC = 128 ; Column 3. ;*************************************************************** ; ; Displays the screen. ; drawscreen ;*************************************************************** ; ; Reset switch check and end of main loop. ; ; Any Atari 2600 program should restart when the reset ; switch is pressed. It is part of the usual standards ; and procedures. ; ;``````````````````````````````````````````````````````````````` ; Turns off reset restrainer bit and jumps to beginning of ; main loop if the reset switch is not pressed. ; if !switchreset then _Bit0_Reset_Restrainer{0} = 0 : goto __Main_Loop ;``````````````````````````````````````````````````````````````` ; Jumps to beginning of main loop if the reset switch hasn't ; been released after being pressed. ; if _Bit0_Reset_Restrainer{0} then goto __Main_Loop ;``````````````````````````````````````````````````````````````` ; Restarts the program. ; goto __Start_Restart bank 3 Game_Over_Setup rem **************************************************************** rem **************************************************************** rem **************************************************************** rem **************************************************************** rem * rem * Game Over rem * rem **************************************************************** rem **************************************************************** rem **************************************************************** rem **************************************************************** rem **************************************************************** rem * Checks for a new high score. rem * if sc1 > High_Score01 then New_High_Score if sc1 < High_Score01 then Skip_High_Score rem * First byte equal. Do the next test. if sc2 > High_Score02 then New_High_Score if sc2 < High_Score02 then Skip_High_Score rem * Second byte equal. Do the next test. if sc3 > High_Score03 then New_High_Score if sc3 < High_Score03 then Skip_High_Score rem * All bytes equal. goto Skip_High_Score New_High_Score High_Score01 = sc1 : High_Score02 = sc2 : High_Score03 = sc3 Skip_High_Score rem **************************************************************** rem * Setup for the restart loop. rem * Master_Counter=0 : Debounce_Reset{1}=1 : COLUBK=$62 Store_Temp_Score01 = sc1 : Store_Temp_Score02 = sc2 : Store_Temp_Score03 = sc3 Loop_Ready_to_Restart rem **************************************************************** rem * The score will flip between the current score and rem * the high score every 2 seconds. rem * Master_Counter=Master_Counter+1 if Master_Counter < 120 then Skip_Flip Master_Counter = 0 : Swap_Scores{2} = !Swap_Scores{2} if Swap_Scores{2} then scorecolor = $AE : sc1=High_Score01 : sc2=High_Score02 : sc3=High_Score03 : goto Skip_Flip scorecolor = $1C : sc1=Store_Temp_Score01 : sc2=Store_Temp_Score02 : sc3=Store_Temp_Score03 Skip_Flip rem **************************************************************** rem * The screen would be blank without drawscreen. rem * drawscreen rem **************************************************************** rem * rem * Restart the game if reset switch or fire button is pressed. rem * rem **************************************************************** rem * rem * If the fire button and reset are not pressed, skip this section. rem * if !switchreset && !joy0fire then Debounce_Reset{1} = 0 : goto Skip_Game_Over_Restart rem **************************************************************** rem * If the fire button and reset switch haven't been released rem * since starting, skip this section. rem * if Debounce_Reset{1} then Skip_Game_Over_Restart goto __Start_Restart Skip_Game_Over_Restart goto Loop_Ready_to_Restart bank 4 temp1=temp1 bank 5 temp1=temp1 bank 6 temp1=temp1 Edited September 18, 2016 by Captain Spazer Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted September 18, 2016 Share Posted September 18, 2016 How about attaching the .bas file so we won't have to make a new file, copy your code, then paste the code into it? It saves us a few unnecessary steps. Before looking at the code, are you erasing the variables that remember the high score from game to game? For example, if you are using l, m, and n to remember the high score, you can't clear those variables. Quote Link to comment Share on other sites More sharing options...
Captain Spazer Posted September 18, 2016 Author Share Posted September 18, 2016 Ah, sorry. Here's the .bas: Racertech.basI double checked my variables and did some adjustments but it didn't help, seems variables being erased wasn't the issue. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted September 18, 2016 Share Posted September 18, 2016 I've been outside most of the day cleaning weird musty/moldy spots off the stupid patio chairs and other fun stuff like that. Now I can finally sit down and look at your program. I'll see if I can find what is wrong before I have to go to bed. You don't need to use "dim rand16 = z" with the DPC+ kernel. Explanation here. Some of the stuff you are using seems to be old code. I've updated it since then: Saving a High Score I'm seeing old code mixed with new code. Take a look at these programs on the bB page since they have all been updated: Bankswitching Example Tinkernut World Deluxe You might also want to look at these: Repetition Restrainer for the Fire Button Reset Switch Restrainer Quote Link to comment Share on other sites More sharing options...
Captain Spazer Posted September 19, 2016 Author Share Posted September 19, 2016 Thank you so much, mate. Yeah, I've mixed alot of old and new code, I haven't fully made the transition over to the new stuff, old habits die hard I guess =)I'll look at your recommendations tomorrow. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.