Jump to content

Photo

Gate Racer with High Score saving on Atarivox/SaveKey


33 replies to this topic

#1 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Tue Mar 12, 2013 12:31 PM

EDIT: This is an expansion of the original 2K Gate Racer, that thread can be found here: http://www.atariage....ent-gate-racer/

After a bit of help from RevEng and reading his post about it here, I was able to add High Score saving to Gate Racer using the AtariVox or SaveKey. Your high score will automatically save and be displayed on the titlescreen. It saves only one high score. I decided to create a new post about it since it's no longer a part of my "2k game experiment". :) The game needed to be expanded to 4k to fit the extra save game code in. I made a few other minor changes, but the game is pretty much the same as the 2k version right now. Changes were very minor and I'll probably make some more changes in the future. You can now press F2/Reset during the game to go back to the title screen and see your high score.

The save feature works in Stella too but you need to activate the SaveKey on controller port 2. This can be done by launching Stella from the command line with stella -rc savekey game.bin or in the GUI by highlighting the game, clicking on Options | Game Properties | Controller Tab | P1 Controller | SaveKey. If the titlescreen score remains a blank white strip on the bottom of the screen after more than one play, you probably haven't properly activated the SaveKey in Stella. I have not yet tested this on real hardware but it appears stable in Stella. I'll test on real hardware after work this evening.

Note that Richard Hutchinson maintains the memory allocation list for the AtariVox and SaveKey here. The current version of this game will write to the "Scratchpad" area of memory. If you use it on real hardware, it's possible another game that uses the SaveKey could overwrite the data. I need approval from Richard to be permanently assigned an area and I haven't requested that at this point.

You'll still need all of the modified include files (in the attached zip) from the original 2k Gate Racer if you're going to compile it yourself, along with the Avox include files from RevEng's post here.

EDIT: Revision 'i' should be the final version barring any bugs found. Here are the changes:

:arrow: Fixed savekey initialization issue (thanks again to RevEng)
:arrow: Added permanent savekey location for real hardware at my assigned location (I used $0640, $0650 and $0660)
:arrow: Holding the joystick up and pressing the game select switch on the title screen will clear out the current high score
:arrow: Hitting oil slick now has the same behavior with velocity controls turned on or off
:arrow: The oil slick now resets to top after a crash
:arrow: Hitting the oil slick now produces a skidding sound
:arrow: One other important note about saving: The high score does not save until you press the fire button after a crash.

3/24/13: I noticed a bug in the final version of Gate Racer II, if you hit the side of the road you may get stuck in a loop where the game won't reset because the car sprite's location isn't reset properly. The updated version (b) is attached, it was a simple one line fix.

Attached Thumbnails

  • grii-titlescreen.jpg

Attached Files



#2 stephena OFFLINE  

stephena

    River Patroller

  • 2,764 posts
  • Stella maintainer
  • Location:Newfoundland, Canada

Posted Tue Mar 12, 2013 1:02 PM

Technically, you only need to use 'Savekey" for the controller, and you don't need to specify the avoxport at all. You only need to specifically use AtariVox (and avoxport) when you have a real AVox attached to your computer, so that the emulator can use the speech functionality of the hardware. For actually saving scores, both the SaveKey and AtariVox use a file on your computer and don't touch the real device at all, even if one is plugged in.

#3 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Tue Mar 12, 2013 1:05 PM

Technically, you only need to use 'Savekey" for the controller, and you don't need to specify the avoxport at all. You only need to specifically use AtariVox (and avoxport) when you have a real AVox attached to your computer, so that the emulator can use the speech functionality of the hardware. For actually saving scores, both the SaveKey and AtariVox use a file on your computer and don't touch the real device at all, even if one is plugged in.

Thanks for the clarification, Stephen. I'll update the first post.

#4 stephena OFFLINE  

stephena

    River Patroller

  • 2,764 posts
  • Stella maintainer
  • Location:Newfoundland, Canada

Posted Tue Mar 12, 2013 1:25 PM

Thanks for the clarification, Stephen. I'll update the first post.


Almost right, but the commandline would be: stella -rc savekey game.bin :)

#5 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Tue Mar 12, 2013 1:28 PM

Almost right, but the commandline would be: stella -rc savekey game.bin :)

Thanks again. I fixed it. :)

#6 Cybearg OFFLINE  

Cybearg

    Dragonstomper

  • 950 posts

Posted Tue Mar 12, 2013 2:25 PM

That's pretty awesome! Is there some downside to doing EEPROM game saving that would make most people not want to attempt it? Does it significantly increase the price of developing cartridges or have some other big drawback?

#7 Gemintronic OFFLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 8,806 posts

Posted Tue Mar 12, 2013 2:46 PM

That's pretty awesome! Is there some downside to doing EEPROM game saving that would make most people not want to attempt it? Does it significantly increase the price of developing cartridges or have some other big drawback?


* SLOW
* Not many peeps have savekeys/AtariVox

The last problem can be solved over time.

#8 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Tue Mar 12, 2013 2:46 PM

There's no downside that I'm aware of other than using extra ROM space. It doesn't increase the price of a cart either, if you don't have an avox or save key the high score function simply won't work.

#9 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Tue Mar 12, 2013 2:49 PM

Avox's aren't currently available, savekeys might be. I bought my savekey from CPUWIZ for $15, but I'm not sure if he's actively making them now. It's still a cool feature to use in Stella.

#10 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Tue Mar 12, 2013 2:53 PM

Yes, they are slow. You need to call a drawscreen after every call to the EEPROM, so you do need to place the code outside of your game loop. I call it after you crash and blank the screen during the process, then restart the game.

#11 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Tue Mar 12, 2013 5:20 PM

Hey Stephen, I think there may be a Stella issue here, but I'm not positive. I've been using Stella 3.7.2 on my work laptop all day and it worked fine in my testing. I was using the command line option to launch in a batch file all day: using stella -rc atarivox game.bin still works perfectly for me on 3.7.2, my saved high score is loaded and saved as I would expect. If I use stella -rc savekey game.bin using Stella 3.7.2 on my work laptop, it does not load my high score correctly, only sc1 (the first two digits) are displayed.

I updated my home laptop to Stella 3.8.1, and it won't load my high score at all using stella -rc savekey game.bin or stella -rc atarivox game.bin. Both of those commands result in a blank high score, nothing loads.

I have no idea if this is a Stella issue or an issue with my code, but I wanted to let you know.

Steve

#12 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Wed Mar 13, 2013 7:29 AM

RevEng discovered that I wasn't properly initializing the eeprom in my code. That's what was causing the issue I just described to stephena above. The attached version (GRIIb) fixes the issue, it should work fine on all versions of Stella and on real hardware now. Now I'll probably start looking at ways to use up the additional 1300 bytes. I'm thinking of adding a menu screen with some customization options.

Attached Files



#13 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Wed Mar 13, 2013 1:51 PM

I created a new version that includes an "options" screen which appears immediately after you press fire on the title screen. You can select Velocity controls to on or off, the oil slick to on or off, the size of your car to large or normal, and powerups to on or off. Push left and right to select the option you want to change, up or down to change it, then fire to start the game. The default options match the original game and are how it's intended to be played, but it's also fun to be able to change things up a bit. It's untested on real hardware but looks good on Stella. There's only 3 bytes left in this 4k build, although I'm sure there's plenty of optimization that could be done. Don't forget to launch it with "stella -rc savekey GRIIe.bin". :)

EDIT: I updated and reposted the 'e' version as there was a mistake on the "oil slick" playfield screen.

Steve

Attached Files



#14 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Wed Mar 13, 2013 4:52 PM

Horeus and ACrystal2011 posted in my duplicate thread in the homebrew forum about their high scores. Incredibly, both of them got the exact same high score of 3:14.8. :) It'll have to be based on the honor system based on my recent changes with the options screen, high score posts are going to have to be based on the default options. My best is 2:24.4, nowhere near either of them yet but I'm working on it. :)

#15 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Wed Mar 13, 2013 10:32 PM

Horeus and ACrystal2011 posted in my duplicate thread in the homebrew forum about their high scores. Incredibly, both of them got the exact same high score of 3:14.8. :) It'll have to be based on the honor system based on my recent changes with the options screen, but high score posts are going to have to be based on the default options. My best is 2:24.4, nowhere near either of them yet but I'm working on it. :)

I played for about 30 minutes tonight and didn't even get close to 3:00 with the default options. I bow to your gaming skills, ACrystal2011 and Horeus.

#16 toymailman OFFLINE  

toymailman

    River Patroller

  • 2,172 posts

Posted Wed Mar 13, 2013 11:32 PM

Note that Richard Hutchinson maintains the memory allocation list for the AtariVox and SaveKey here. The current version of this game will write to the "Scratchpad" area of memory. If you use it on real hardware, it's possible another game that uses the SaveKey could overwrite the data. I need approval from Richard to be permanently assigned an area and I haven't requested that at this point.

This seems like something to be worried about as more games are made that take advantage of the AtariVox/SaveKey. I would hate to write over my scores/settings as the a major point of these devices is to save the scores and/or settings. It seems like it would defeat the purpose.

Is there a way (prior to writing to the scratchpad) to check if data (from another game) is already written? Something to think about.

#17 Cybearg OFFLINE  

Cybearg

    Dragonstomper

  • 950 posts

Posted Thu Mar 14, 2013 1:58 AM

Is there a way (prior to writing to the scratchpad) to check if data (from another game) is already written? Something to think about.

If the memory can be read, it can be compared to check for a null value, though that may be very, very slow.

Also, if you dynamically place your high score value at the next available location, you wouldn't know which position it is in to retrieve it.

#18 RevEng OFFLINE  

RevEng

    River Patroller

  • 4,449 posts
  • Bitnik
  • Location:Canada

Posted Sat Mar 16, 2013 1:21 PM

I wouldn't worry about it. There aren't any completed games that write to the scratchpad - development is what the scratchpad is for.

If you really want dynamic locations, that's what the filesystem area is for.

#19 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Sat Mar 16, 2013 2:27 PM

I wouldn't worry about it. There aren't any completed games that write to the scratchpad - development is what the scratchpad is for.

If you really want dynamic locations, that's what the filesystem area is for.

Good point. I sent an email to Richard about 24 hours ago asking for a permanent location and haven't heard back yet. The only thing I've noticed in my recent 4k build that I don't like is when you choose the non-velocity controls and hit the oil slick - it propels you quickly to one side and pretty much results in instant death if you hit it. Fixing that issue and getting a permanent slot on the SaveKey are the last two things to do, the game is complete otherwise. I'm looking forward to my next project (yet undetermined) and implementing voice. Once I start that I'm probably going to be filling up your inbox with questions, Mike. :)

EDIT: I actually did try to use the file area first (and I saw batari's preference for utilizing that area in your original post) however I initially couldn't get my game to compile when using that include file. Based on all the advice you've given me thus far to get it to work I'm sure it was an error on my part. I should probably revisit that option.

#20 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Sat Mar 16, 2013 3:21 PM

Good News. :)

I've allocated you page 19 ($0640 - $067F)
Thanks
Richard H.

Thanks Richard! Time to update the code with my reserved space.

#21 Horeus OFFLINE  

Horeus

    Space Invader

  • 16 posts
  • Location:France

Posted Sat Mar 16, 2013 4:31 PM

Horeus and ACrystal2011 posted in my duplicate thread in the homebrew forum about their high scores. Incredibly, both of them got the exact same high score of 3:14.8. :)

The same score and the same crash on same spot. Knowing that the gates are random, it is a funny coincidence.

I played for about 30 minutes tonight and didn't even get close to 3:00 with the default options. I bow to your gaming skills, ACrystal2011 and Horeus.

With practice, you can easily do better. I'm sure ^^

Edit :

New (world ?) record : 5:43:2 with the defaults options.
^^;
I actived the SaveKey on controller port 2 but Stella has not kept my score...Fortunately, I thought to make a screenshot.

Attached Thumbnails

  • gate-racer-2-challenge-1.jpg

Edited by Horeus, Sat Mar 16, 2013 5:16 PM.


#22 stephena OFFLINE  

stephena

    River Patroller

  • 2,764 posts
  • Stella maintainer
  • Location:Newfoundland, Canada

Posted Sat Mar 16, 2013 5:49 PM

I actived the SaveKey on controller port 2 but Stella has not kept my score...Fortunately, I thought to make a screenshot.


Confirmed. Manually deleting the savekey EEPROM file and restarting the ROM fixes the issue. Perhaps previous builds corrupted the data in some way, and you're only testing with a fresh file. Maybe an erase is needed before saving??

#23 Horeus OFFLINE  

Horeus

    Space Invader

  • 16 posts
  • Location:France

Posted Sun Mar 17, 2013 4:02 AM

Thanks Stephena but it does not always work. This is not serious, I make sreenshot ^^

#24 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,798 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Sun Mar 17, 2013 10:06 AM

Great job Horeus! I played for a long time last night to try and beat your score and got a 7:03.7. :) After a lot more practice the game is starting to feel a bit easy to me again, however I don't plan on making any more changes to the gameplay. I think the default difficulty options are just right for someone picking it up for the first time. Actually you can make it much harder if you like as you can double the size of the car and turn off the powerup in the options screen on the 4K build. Unfortunately there is no way to know if the score has rolled over, so if you happen to do better than 10 minutes on the road you'll have to keep track of that yourself (or take a video :) ). Based on all of the posted scores so far (counting those after I posted the release candidate of Gate Racer 2k), here are the top scores:

1. Steve 7:03.7
2. Horeus 5:43.2
3. (Tied) Horeus & ACrystal2011 3:14.8
4. Steve 2:28.0
5. Steve 2:26.6
6. Steve 2:14.8
7. Impaler_26 2:03.1
8. Brian O 1:01.6

These scores are based on Gate Racer 2k or using the default options on Gate Racer II (4k). I haven't updated the game to use the permanent savekey memory location yet, I hope to get that (and a few other minor tweaks) completed by early in the week. Here's a few bits of strategy I'm using that might help:

1. On wide turns, start turning the other direction before you've completely traveled through the gate.
2. Try and center yourself after every gate pass right away to make it easier to get to the next.
3. For me, at least so far, trying to grab a powerup that looks hard to reach is extremely risky and I avoid them. I usually only grab the ones that are very close to the gate opening.
4. If it looks like you're going to have to drive right through an oil slick at the same time as passing through the gate, try to enter it dead-center. It won't swing you wide enough to hit the side of the gate.

Steve

Attached Thumbnails

  • GRII-7.03.7.JPG


#25 stephena OFFLINE  

stephena

    River Patroller

  • 2,764 posts
  • Stella maintainer
  • Location:Newfoundland, Canada

Posted Sun Mar 17, 2013 10:12 AM

Confirmed. Manually deleting the savekey EEPROM file and restarting the ROM fixes the issue. Perhaps previous builds corrupted the data in some way, and you're only testing with a fresh file. Maybe an erase is needed before saving??


Sorry, my response was more directed to Atarius Maximus, in that there might be something wrong in how the Savekey data is being initialized/saved. Manually deleting the savekey file shouldn't be necessary, and indeed on the real thing is impossible.




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users