x16emu locks up when loading Basic demo programs

MarioG

New Member
Feb 10, 2020
2
0
1
I don't seem to be able to get the Basic demo programs from the GitHub repository to load in the emulator.
I am loading programs from within the emulator using the following syntax:

LOAD"DEMOS/BASIC/BALLS.BAS"

The emulator finds the file okay, loads it and responds with a "Ready" prompt but the keyboard locks up
preventing me from listing or running the program. Am I doing something wrong?
 
May 22, 2019
662
313
63
I'm also having some really bad luck with the current version of the emulator. I think the changes to the disk I/O subsystem have some bugs.
 

MarioG

New Member
Feb 10, 2020
2
0
1
I think I have discovered why the B.A.S.I.C demo programs will not execute in the emulator. The emulator expects a PRG file, not a
plain ASCII file.

PRG files are binary files that begin with a two byte sequence indicating the start address in memory that the program should be loaded into. The
address should appear in low byte/high byte order. For example, to load an assembly language program into memory
at address $0801 the assembled instruction file should contain the two byte header: $01,$08 as the first two bytes of the file.
The remainder of the file contains your assembled byte codes.

After loading, to execute the program you can type: sys $0801 into the emulator.

Presumably, you can load B.A.S.I.C files using the same PRG file format, although I have not tried this it seems that the Kernal saves
the B.A.S.I.C programs that you type in into tokenized form when you issue a
save command. The first two bytes of a
saved X16 B.A.S.I.C file appear to contain the two byte sequence
$01,$08 which looks like the start address in memory for X16 B.A.S.I.C
programs. After this two byte sequence the remainder of the file contains the B.A.S.I.C program in tokenized form.


I think that solves the mystery. :)
 

BruceMcF

Active Member
May 19, 2019
208
63
28
Yes, Microsoft V2 Basic tokenizes lines as they are entered into a program, and so when it saves a program it saves the tokenized program. "PRG" format is from the Kernel function that Basic calls, which prefixes the original starting address (in 6502 low byte first order) when it saves a file. So, yes, the LOAD keyword is designed to load files saved by SAVE, not to load text files.

If the Basic file is generic V2 Basic, then the Windows 64List program should be able to tokenize it. Or you can start the VICE C64 emulator, copy the program into your clipboard, then with the emulator in focus a right click should "type it in" to the emulated C64, and it can be saved in the emulator.