Beginner Questions about the X16-Demo stuff.

Chat about anything CX16 related that doesn't fit elsewhere
Post Reply
VanguardHydra
Posts: 3
Joined: Sun Dec 03, 2023 7:59 pm

Beginner Questions about the X16-Demo stuff.

Post by VanguardHydra »

Hello,

I have been playing with the X16 Emulator on the Mac.
I have downloaded the X16-Demo files from GitHub.
How do I use the .BAS files in the basic folder?

I can open them in the editor to see the basic program complete with line numbers.

I just down know how to load the basic file contained in the text file.

Thanks.

Colin
User avatar
ahenry3068
Posts: 1139
Joined: Tue Apr 04, 2023 9:57 pm

Re: Beginner Questions about the X16-Demo stuff.

Post by ahenry3068 »

There is a way to do it. Read to the end.

Commodore BASIC isn't designed to open ASCII BASIC files. When you type BASIC commands it converts them to single byte Tokens internally and when you SAVE "MYFILE.PRG" it saves those tokens.

With the Emulator you can fool it into thinking you just type really fast. Open the .BAS file in a text editor, copy all of it to the clipboard.
Then Paste it to the emulator window, (In Windows or Linux Ctrl/V, I'm sure there's an equivalent on Mac).

Once the scrolling is done. Type RUN and ENTER to see what you've got.

Occasionally on Windows when I do this a line or two might get corrupted. If it doesn't work the first time try at least twice before you think the program your loading has any bugs.
Johan Kårlin
Posts: 292
Joined: Wed Jun 03, 2020 11:33 am
Location: Kalmar, Sweden

Re: Beginner Questions about the X16-Demo stuff.

Post by Johan Kårlin »

There is actually a simpler way to do it, but basically it works in the same way as already described. You can load a BASIC text file directly into the emulator by using the option -bas. For example x16emu -bas file.bas -run will load the file and run it immediately.
kelli217
Posts: 532
Joined: Sun Jul 05, 2020 11:27 pm

Re: Beginner Questions about the X16-Demo stuff.

Post by kelli217 »

There's a third way to do it, and this will work even from an actual machine: The EXEC command.

You have to load the text of the program into memory (usually high memory is a good choice for this, pick any bank other than 0. Generally bank 1 and address $A000 is a good place to start.)

Use BLOAD to do it. The first line here is what you type in (adjusted, of course to change "WHATEVER.BAS" to the actual name of the file you're trying to load. The lines after that are what the computer will say back to you, as it's loading the file. The hexadecimal numbers following the 'TO' in the output will vary according to the length of the file you're loading.
BLOAD"WHATEVER.BAS",8,1,$A000

SEARCHING FOR WHATEVER.BAS
LOADING FROM $01:A000 TO $01:A123
READY.
Then you type:
EXEC $A000,1
to load from address $A000 in bank 1.

It will literally type it out on the screen for you just the same as if you'd pasted it as ahenry3068 describes.

Yes, this is BY FAR the most complicated way to go about it so far mentioned; it's also the only way to do it on the actual hardware, short of loading the program into the editor and, after carefully changing all the GOTO and GOSUB targets to labels and placing the labels in the right places in the code, deleting the line numbers, and then running BASLOAD. That's even more complicated, I think.
User avatar
ahenry3068
Posts: 1139
Joined: Tue Apr 04, 2023 9:57 pm

Re: Beginner Questions about the X16-Demo stuff.

Post by ahenry3068 »

I will add this note. In most cases the .BAS files are included for reference if you want to study and/or change the code.
There should almost always be a corresponding .PRG for the .BAS file that can just be loaded with LOAD.
Post Reply