The MEGA65 Community Survey 2023
The MEGA65 Community Survey 2023. Dan’s MEGA65 Digest for August 2023.
Hey all! I’m keeping this issue short, because there’s something more important for you to do instead of reading.
The MEGA65 Community Survey 2023
The MEGA65 Community Survey 2023 is now open. This survey is for anyone even a little bit interested in the MEGA65, whether you own one, have preordered, are still considering it, or don’t intend to order but still enjoy seeing what’s going on. This includes anyone not subscribed to this Digest, so please share this link.
Responses are anonymous. We will share aggregate anonymized results in a future Digest. Full-text replies will be kept confidential to the MEGA65 Steering Committee.
We’re targeting 400 responses for this year’s survey. If everyone subscribed to the Digest responds, we’ll hit that easily. (Please only take the survey once, so we get accurate counts.)
Here’s that link again: please take the survey. Your response will go a long way to guiding the future of the MEGA65 project. Thank you!
New Galaga core!
After you have completed the survey, it’s time to hit the arcade! Run don’t walk to the Galaga core for the MEGA65 by muse. This isn’t just a version of Galaga for the MEGA65, this is Galaga, a port of the original arcade hardware architecture running directly on the MEGA65 FPGA. The core even supports connecting a vintage VGA monitor turned on its side to fully replicate the arcade experience.
Installation requires a few steps, including fetching the original Midway Galaga ROM from the Internet (using the link provided) and running a Python script. See muse’s installation instructions.
When starting the core, give it a minute to go through the arcade hardware test routine. The core displays its keyboard controls briefly; press the spacebar to dismiss. Press 5 to insert a quarter, then press 1 to start a one-player game. You can control the game via a joystick in port 1, or use the keyboard: A and Z move left and right, and the Cursor Up key fires. The P key pauses. As with the C64 core, press the Help key to open a settings menu.
Huge thanks to muse for this effort, and to all of the original implementors of the core. (And to Midway too, but they already have all of my lunch money.)
R4 is now R5
Last month I mentioned that there will be a new revision of the main board that will start shipping with the next delivery batch, known as R4. Due to restricted availability of a component, the board needs one more revision. This gives us an opportunity to further refine the cartridge interface before the revised board goes into production, so we’re taking that opportunity. The core needs a corresponding adjustment, so the board is now known as “R5” to distinguish between the core builds. R4 boards will not be manufactured. The next delivery batch will receive R5 boards.
The cartridge interface enhancements will make it possible to support fancier utility cartridges. As with the other revisions, only time will tell what differences will actually be notable in practice. The most important reason to know which main board revision you have is to download the correct versions of core files.
Pudding Mountain Miner 65
I said I’d keep this short, but I can’t resist including a bit of BASIC fun.
Of all the Commodore 64 games that could have been a staple of my childhood, an unlikely contender was “Pudding Mountain Miner” by Charles Brannon. Brannon was an editor for Compute!’s Gazette magazine, and originally wrote “Pudding Mountain Miner” as a short type-in to appear in newspapers promoting the magazine when it was getting started. He wrote up an explainer in the April 1985 issue of Gazette, in the “Horizons” column.
The game is a one-button shooter where you’re a fighter pilot dropping bombs on Pudding Mountain, digging for buried treasure. If you hit the dollar sign, you win the big bucks. If you hit the mantle underneath the pudding, it’s game over.
I liked Miner because it was fun and cute, and also because it was only 17 lines of BASIC code. I don’t think I ever bothered to save it to disk. I would just type it in any time I wanted to play it.
Here’s the program listing converted to a form where you can use it with petcat to generate a PRG in case you don’t want to type it in (but what’s the fun in that?). This version runs just fine with the MEGA65’s GO64
mode.
100 v=(peek(0)=76):w=40+18*v:t=1024-6656*v:c=55296+16896*v:s=53281+16402*v
110 c$=chr$(147):printc$:pokes,1-26*v:for i=0tow-1:q=22*w+i
115 poket+q,160:pokec+q,7:next
120 s$=chr$(32)+chr$(158)+chr$(18)+chr$(188)+chr$(146)+chr$(156)+chr$(185)
130 s$=s$+chr$(31)+chr$(175):q=rnd(1)*(w-7)+3+22*w:poket+q,164:pokec+q,5
140 fori=0tow-1:forj=0to7*rnd(1)+3:q=(21-j)*w+i:poket+q,160:pokec+q,2:next:next
150 printchr$(142);chr$(19);:y%=4*rnd(1)+1:fori=1toy%:print:next:x=0
160 l$=chr$(157):prints$;l$;l$;l$;:x=x+1:geta$:ifa$=""andx<w-4then160
170 ifx=w-4thenprinttab(x);chr$(32);chr$(32);chr$(32);:goto150
180 fori=y%+2to22:q=i*w+x+1:p=peek(t+q)
190 poket+q-w,32:poket+q,90:pokec+q,8*rnd(1):ifp=32thennext
200 b=b+1:poket+q,32:ifi<22goto160
210 ifp<>164thenfori=0to255:pokec+q,i:poket+q,i:next:printc$;"you lost":goto230
220 fori=1to50:poket+q,32+132*f:f=1-f:next:printc$;"you won! ";b;"bombs"
230 print:print"press "chr$(18);"return";chr$(146);" to play again"
240 geta$:ifa$<>chr$(13)then240
250 run
Brannon’s article gives a line-by-line description of how the program works. I’ll try not to repeat the whole analysis, but I do want to notice a few things.
For starters, it’s difficult to read. Brannon wrote this to appear in a newspaper ad, so he used Commodore BASIC’s abilities to combine multiple statements on a single line and omit spaces to cram all of the code into a dense rectangle. C64 programmers are accustomed to omitting spaces because it speeds up the program slightly when running at 1 MHz, and it uses slightly less BASIC memory. At the MEGA65’s 40 MHz, omitting spaces makes no measurable difference and isn’t worth doing.
Early Commodore BASICs lack built-in commands for graphics and sound, so programs like games tend to contain many POKE
statements. As a result, very few lines of code say what they mean, at least to a reader that didn’t write the program. To work backwards from an obscure statement like POKET+Q,160
, you have to recognize that this actually says POKE T + Q, 160
, that the variables T
and Q
are forming an address, that T
is assigned the number 1024 under some circumstances, and that this is the start of C64 screen memory. Then you know to look up a screen code table to determine that the value 160 represents a blank space. This statement is probably writing a blank space somewhere on the screen determined by the Q
variable.
I’m not criticizing the way the program is written. If anything, I’m criticizing the way programs had to be written for the Commodore 64, at least under some circumstances. Of course, Brannon intentionally wrote this program to take up as little printed space as possible, so it is designed, crunched, and organized in an atypical way.
One of the most interesting parts of the program is this bit in the very first line: V=(PEEK(0)=76)
When this runs on a Commodore 64, the V
variable is set to 0. Some simple arithmetic determines how the other variables on this line are set: W
is set to 40, T
is set to 1024, C
is 55296, S
is 53281. 40 is the number of characters that fit on a single line of a C64’s screen, so W
probably stands for “width,” and sure enough that’s what it appears to mean elsewhere in the code.
But what’s up with the PEEK(0)
? It turns out that this program also works on the VIC-20! When this runs on VIC-20 hardware, PEEK(0)
evaluates to 76, so the comparison PEEK(0)=76
evaluates to true, so the V
variable is set to -1, which is how “true” is represented in Commodore BASIC. This affects the settings for the other variables: W=40+18*V
becomes 22, which is the screen width for the VIC-20.
This game takes advantage of the similarities between the C64 and VIC-20, along with some intentional design choices, to scale its display to fit the computer it’s running on. This poses a question: what’s the smallest change we can make to this program so that it runs on the MEGA65 in 80-column mode?
On the MEGA65, the BASIC syntax is the same, the PETSCII character and screen codes are the same, and the VIC-II registers are present at the same addresses by default. Screen memory is relocatable and not at the same location by default, so we’ll have to do something about that. Color memory (whose location is stored in the C
variable) needs to be accessed at a different memory location if we want to access the full 80 column’s worth.
Let’s just try this and see what happens:
100 w=80:t=$0800:c=$1f800:s=$d021
(I’m using hexadecimal values here because I’m used to thinking of these addresses in hex, and BASIC 65 supports hexadecimal value literals.)
I had read through the whole program to make sure this would work and was still surprised that it did. There’s only one issue: it’s way too fast! We need to slow down the MEGA65 processor to make it playable. Thankfully, this is possible with a BASIC 65 command.
105 speed 1
It’s the nature of this game that the denser character width makes it more difficult to hit the target, but it works! No other changes are necessary.
Consolidating this into a single BASIC listing that works on all three machines would be straightforward—or not so straightforward if you want to preserve the compactness of the original. I’ll leave that as an exercise.
That’s it! Next month should be action-packed: we’re about to open public beta testing of the next major platform release. I’m trying to do my part and fix as many bugs as I can before the deadline. Of course, this is an open project, so you can get involved with testing right away if you like. Inquire in the Discord.
Go take the survey, and tell your friends. See you next month!
— Dan