ProDOS STARTUP menu - trying to work out how this code works

7 posts / 0 new
Last post
gmc
Offline
Last seen: 4 days 16 hours ago
Joined: Sep 29 2021 - 08:41
Posts: 36
ProDOS STARTUP menu - trying to work out how this code works

I'm busy teaching myself all about the Apple II and starting off with  a ProDOS ROM image written by Terence Boldt

 

Looking at the STARTUP code in CiderPress, it uses Applesoft to print a menu and then loads a game depending on which key you press.  

I've worked out most of the simple basic commands but what is stumping me is how is the game actually loaded. 

I would think there should be something like LOAD game? 

 

The code reads the key pressed and sets a variable GAME = 0 to 26 (Depending on which key is pressed) Then the below routing is run. 

 

 400  DIM PREFIX$(26)

 420  FOR X = 0 TO 25

 430  READ PREFIX$(X)

 440  NEXT X

 500  DIM EXEC$(26)

 510  FOR X = 0 TO 25

 520  READ EXEC$(X)

 530  NEXT X

 

What exaclty does this do? Looking at the applesoft commands  it allocates an array of size 26 and then reads the array.  What happens when it's read. Where is it read to?

After that it prints executing game to the screen, and then 

 

 1000  DATA "BC.QUEST" 

 1001  DATA "BOLO"

 1002  DATA "BRUCE.LEE" 

and continues listing each game.

 

How exactly does that load/run the game you have selected? 

 

If it helps, here is a link to the .po file:

https://github.com/tjboldt/ProDOS-ROM-Drive/blob/main/Firmware/GamesWithFirmware.po

 

 

 

 

 

Offline
Last seen: 3 hours 44 min ago
Joined: Jun 29 2018 - 16:55
Posts: 572
Great project to start with.

Great project to start with. Quite fond of it myself.

 

Off the top of my head it uses the variable and runs BRUN on the DATA path specified, but I haven't really torn into the code of his menu itself.

 

I have been working on a separate ROM image for II+ which is a whole topic in and of itself; I hope someone here is more familiar with how Terrence's menu is coded and can more specifically answer your question. 

gmc
Offline
Last seen: 4 days 16 hours ago
Joined: Sep 29 2021 - 08:41
Posts: 36
Looks like I missed this

Looks like I missed this important bit out (On second thoughts this is just printing to the screen?) 

 

 590  PRINT "Setting prefix to "PREFIX$(GAME)

 600  PRINT  CHR$ (4)"PREFIX GAMES/"PREFIX$(GAME)

 605  PRINT "Executing "EXEC$(GAME)

 610  PRINT  CHR$ (4)"-"EXEC$(GAME)

 

I don't see any BRUN commands in the code. 

 

 

Online
Last seen: 1 hour 57 min ago
Joined: Jun 18 2010 - 13:54
Posts: 733
The first part of the program

The first part of the program populates two string arrays with the DATA statements below it. One array holds the prefix or directory to each game  and the second holds an EXEC command that is used to execute the corresponding program from the "disk." Line 610 is where this command is executed causing the appropriate program to launch. You'll find the BRUN (or possibly the ProDOS "-") command in many of those EXEC strings. The EXEC command basically just emulates typing commands from the keyboard.

gmc
Offline
Last seen: 4 days 16 hours ago
Joined: Sep 29 2021 - 08:41
Posts: 36
Thanks. the bit I was missing

Thanks. the bit I was missing is the CHR(4) which is DOS command escape prefix.  I thought it was just printing to the screen.

 

I think I"m following now:

READ PREFIX$(0)  - reads the DATA from 1000

READ PREFIX$(1)  - would then read the next data statement at 1001

 

 Wow, very different to modern programming :)

It's not helping that I"m trying to compare it to Visual Basic!

Offline
Last seen: 7 hours 15 min ago
Joined: Apr 26 2016 - 08:36
Posts: 666
gmc wrote: Wow, very
gmc wrote:

 Wow, very different to modern programming :)

It's not helping that I"m trying to compare it to Visual Basic!

 

Yeah, you need to get your head out of "C" and even VB.

Microsoft derived BASIC is a different animal altogether, but it did put programming power into the hands of the common person.

Even mere mortals could learn to write meaninful computer programs (we didn't call it "code" in the 80s) thanks to computers like the Apple II, the Commodore PET, C64 and of course, BASIC.

 

I'm not a professional coder, programmer or even a highly trained amateur.  But when I spend days working out some vintage computer programming and then try to switch my mindset to something modern like Arduino "C" it sometimes seems like the most @#$%-ed up programming langugage ever devised (C, that is).  Whoever thought camel-case was a neat idea should be drawn, quartered and fed to the pigs.

 

 

 

CVT
CVT's picture
Offline
Last seen: 13 min 49 sec ago
Joined: Aug 9 2022 - 00:48
Posts: 981
jeffmazur wrote:...You'll
jeffmazur wrote:

...

You'll find the BRUN (or possibly the ProDOS "-") command in many of those EXEC strings.

...

Yep, the dash is my favorite ProDOS command. If you have a program called foo then -foo just executes it. You don't have to care if it's written in Basic or it's binary, like you do when using RUN and BRUN.

 

Otherwise for anyone who is a modern programmer I would recommend going through this tutorial (takes about an hour or two to go thorugh and understand it):

http://www.hoist-point.com/applesoft_basic_tutorial.htm

 

Also you can copy any of the example programs and <Shift><Insert> them directly into AppleWin.

 

Log in or register to post comments