Jump to content


Recommended Posts

Instead of working on the dozen or so projects that I have started, I decided the other day to delve into SecondBASIC programming for the Genesis. For those that don't know SecondBASIC http://www.sbasic.net/ is a BASIC language developed by Second Dimension. It is in active development and appears to be fairly robust. My biggest gripe is that there are virtually no programming examples for it. Commands are documented and a few code snippets come with the development environment but that's about it. I decided to help rectify this situation by writing a simple Snake game and commenting the hell out of it. The game uses the text functions only (i.e. no shape tiles) and has two very simple sounds. I've tested it with the Fusion 3.64 emulator and everything appears to work as intended. I can't seem to find my flash cart so if someone could test it on real hardware that would be much appreciated.


While coding the game I did run into a couple of things. First, I did not see any mention of multi-dimensional arrays on the SecondBASIC site although they are supported. I did only test with 2 dimensional arrays, however. Second, I had to use another program to fix the checksum on the binary. Otherwise, fusion would throw up a checksum error whenever I tested the binary. I ended up using Fix Checksum https://www.romhacking.net/utilities/342/ to correct it. Third, at one point during coding I tried to do an animated spinner using the string: "\|/-" to no avail. Older guys will recognize this as a cursor used by many on the Apple II and C64. Not that big of a deal that it didn't work but I did find it a little odd. I believe the "\" is used by SecondBASIC to denote something, possibly "\n" for newline, etc. Even when I tried to build the string using chr$, it failed to work. Fourth, the ASCII codes don't quite lineup with the text screen that I'm using. I tried using codes: 016,017,030,031 (4 arrows) to do the spinner and one of them kept displaying as a heart. At that point I decided the hell with it and didn't look any further into it. Lastly, the binary generated by SecondBASIC is always named sbasic.bin no matter what your project file is named. You have to manually go to the work folder and rename it if you want to keep a copy. Otherwise, it will be overwritten at the next compile.


Attached is the rom file and the basic listing. I'm sure there are things that can be improved along with using actual shape tiles for the visuals. This is just a simple example to hopefully encourage others to take a look at this programming option for the Sega Genesis. Feel free to tinker around with it and see what you can do. 


Controls are simple (up, down, left, right). Skill level can be chosen at the title screen by pressing left or right. It's a basic Snake game, eat the dot and avoid hitting the walls or yourself. Once you reach 100 points, obstacles will appear in the playfield to make things tougher. Have fun.



Snake.bas snake.bin

  • Like 2
Link to comment
Share on other sites

Much of the code from BasiEgaXorz projects is compatible with SecondBASIC so one can scavenge the BEX forum for examples.



Second Dimension also has a section on RVG UKs forum.  Might be a way to ask questions.


  • Like 1
Link to comment
Share on other sites

Since I mentioned having problems with a text character spinner animation, I figured I'd share the solution I found. Using strings in this regard appears to be out of the question with SecondBASIC Studio v3.9.58. The way around it is to create an array which holds the ASCII codes for the characters you want to use and then print chr$ of each element of the array. The attached .bas file has a few lines that can be uncommented to see the strange behavior in action, the .bin simply shows the two different spinners doing their thing. This will only be interesting to those experiencing similar strange behavior with strings or if you happen to want to use one of these spinners.

SpinnerAnimation.bas SpinnerAnimation.bin

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...