6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 3:02 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Dec 06, 2020 11:10 am 
Offline

Joined: Mon Oct 17, 2011 7:50 am
Posts: 33
Back in 1984, the 12 year old Elon Musk wrote a rudimentary video game for his SpectraVideo SV-328 (a Z80 Microcomputer)

https://www.theverge.com/2015/6/9/8752333/elon-musk-blastar-pc-game

Then about 5 years ago someone turned it into an HTML-5 version of the game which you can play here:

http://blastar-1984.appspot.com

And someone else found the screenshots of the listing:

https://archive.org/details/blastar-elon-musk-spectravideo

Since it's quite instructive to see what 12 year old geniuses can achieve, I thought I'd recreate it for the ZX-Spectrum and then port that to the unexpanded VIC-20 as the first two steps towards building my first $billion company !

Here's it is! And in my 'umble opinion, it's better than the original, because a VIC-20 is better than the SV-328!

Image

Observations:


The SV-328 version uses Sprites and ON INTERVAL type commands to force periodic calls to the game code. In reality, that kind of functionality doesn't provide any advantages over the straightforward video game pattern: Render, Take Input, CalculateNextPositions and in fact probably made the game a bit more complex for Musk, because it means he could never be sure exactly which part of the program was running as one part could 'interrupt' another.

Secondly, the game really is super-simple. With a bit more programming experience, his version can be reduced to less than half the length (though some of this is because my UDGs were in decimal rather than binary). I fixed an issue in his code whereby the STATUS BEAM that will certainly kill your ship was, I think meant to track your ship as it fell, but in fact it didn't. In this Improved version, the status beam does track the ship!

The VIC-20 version is particularly challenging for several reasons. Firstly, it's possible, but really tricky, to set up a graphics mode so that you only allocate space for the graphics characters you need (in my case 5 characters) and are also able to access normal text characters.

The solution is to allocate one page of memory for the graphics chars starting at 7168 (28*256), and it turns out that inverse characters appear as normal upper case + some block graphic characters. Because I only wanted 5 graphical chars, I used video (not ASCII) characters 59 to 63. I then set the end of BASIC to point to the address 7640, which meant that BASIC in fact could encroach on the character set!

The second major problem for the VIC-20 version is that it's tricky to print at any location on the screen. I chose to poke the printing position to where I wanted it, which needed 3 pokes, but subsequent testing shows that using cursor controls is much neater and faster. This had the consequence that the VIC-20 version of the game is slower than the ZX Spectrum version, though ironically the sluggishness and keyboard buffering on the VICE emulator makes the game more fun and challenging to play.

And here's the listing if you want to type it in ;-) (tap file also attached)

Image

The ZX Spectrum version can also be found here:

https://sites.google.com/site/libby8dev/zxblastar


Attachments:
Blastar.tap.zip [15 KiB]
Downloaded 89 times
Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 08, 2020 3:57 am 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
Nice work! I'm sure you'll be a multi-billionaire any day now.

How did you generate the listing? Is it just a series of screen caps glued together?

(And kinda ow on readability; that 22-column screen is the one thing I dislike about the VIC-20. I suppose you could fix that by buying a dot-matrix printer, printing out the listing, and posting an image of the scanned printout. :-))

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 08, 2020 8:26 am 
Offline

Joined: Mon Oct 17, 2011 7:50 am
Posts: 33
cjs wrote:
Nice work! I'm sure you'll be a multi-billionaire any day now.


Thanks! Feel free to convert it to the microcomputer of your choice! Remember, Blastar, it's the secret of success!

cjs wrote:
How did you generate the listing? Is it just a series of screen caps glued together? (And kinda low on readability..


I'm afraid so! And the best way to grab them is to list the program backwards, because it's tricky to stop the listing at a given page. Instead I did LIST, captured the last screen (which started at 1065); then LIST -1064 whose screen started at 1025, then LIST -1024 etc until I got to LIST -99. 10 screenshots in total.

This was less effort than trying to figure out how to get macOS VICE to list to a file. I had started on a program to generate a plain text listing from a memory snapshot. Ideally though, listing to a .png file would be best (using a VIC-20 ROM file for the character bitmaps), because that way you'd be able to capture the graphics properly.

The awful screen width of the VIC-20 is amply demonstrated in the listing, which was a major handicap to actually porting it in the first place. A bit like typing programs on a Casio PB-110 pocket computer ;-)

Image


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 08, 2020 12:51 pm 
Offline
User avatar

Joined: Sat Dec 01, 2018 1:53 pm
Posts: 730
Location: Tokyo, Japan
Snial wrote:
And the best way to grab them is to list the program backwards....

Ah, that's clever!

Quote:
This was less effort than trying to figure out how to get macOS VICE to list to a file.

VICE seems the easy part of it; it supports sending (virtual) printer output to a file. But it had not occurred to me that the VIC-20 doesn't have an LLIST command, which means some trickery is necessary. This post suggests:

carlsson wrote:
You access the printer with OPEN 1,4 or 1,5 depending how it is set up. Then you either PRINT#1 individual lines or use CMD1 to redirect screen output to the printer, so LIST will send its content to the printer. Use a final PRINT#1 without content to end the CMD command, then CLOSE 1.

VICE also comes with a filter called petlp which I am guessing is what produced the following:

Attachment:
viceprnt-out01.png
viceprnt-out01.png [ 5.55 KiB | Viewed 1996 times ]


Quote:
The awful screen width of the VIC-20 is amply demonstrated in the listing, which was a major handicap to actually porting it in the first place.

Indeed! The nostalgia from seeing that screen cannot overcome the internal horror that arises when I think about using it for any serious amount of programming. (And I am even again well used to 40-column systems at this point.)

Snial wrote:
I had started on a program to generate a plain text listing from a memory snapshot. Ideally though, listing to a .png file would be best (using a VIC-20 ROM file for the character bitmaps), because that way you'd be able to capture the graphics properly.

Ah, yes, that inevitable "graphics char" issue. I actually wrote some software to help with that. bastok, written in Python, detokenizes Microsoft MSX-BASIC files and uses character substitution to replace screen/character codes embeded in string constants, DATA statements and comments with selected Unicode characters. (It also has incomplete code to go back the other way, but the BASIC parser still needs a few hours of work that I've not yet got around to doing because the project I was doing this for kind of died.)

It should be pretty easy to add Commodore BASIC support to it, especially since that's also an MS-BASIC, and I'd even be happy to do the coding for that if someone wants to deal with testing, debugging, and selection of Unicode chars to map to/from PETSCII chars. (If I finish the code to get it working in the other direction, it would also be a much nicer way to do program development for BASIC machines, especially those with small memory since I designed this to "unsquash" program text into a multiline-format with lots of spaces and the reverse.)

_________________
Curt J. Sampson - github.com/0cjs


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: