How to load a game?

Tutorials and help articles.

(Posts require approval. See pinned post.)
Forum rules
Post guides, tutorials, and other instructional content here.

This topic area requires approval, so please be patient while we review content to make sure it fits the expectations for this topic area.

Tech support questions should be asked in Hardware or Software support.
Post Reply
Bighead
Posts: 1
Joined: Wed Oct 12, 2022 6:07 am

How to load a game?

Post by Bighead »


I downloaded the X16 emulation and I would like to try out some of the games. I have never used any of these old computers before that run BASIC, so I have no idea where to begin. I tried reading some literature on the subject but everything I find seems way above my head. Can anyone explain a step by step process of the commands needed to navigate to a directory within the emulator and load a game from that directory?

User avatar
AndyMt
Posts: 326
Joined: Sun Jun 21, 2020 3:02 pm
Location: Switzerland

How to load a game?

Post by AndyMt »


The easiest way is to use the "Try Now" button in the web emulator.

Otherwise if that's too slow or you really want to use the emulator separately do the following to keep it simple:


  • install the emulator on your desktop machine


  • copy the game files into the same directory


  • start emulator


type


  • LOAD"game.prg",8,1


  • RUN


game.prg needs to be whatever prg file you copied.

minirop
Posts: 2
Joined: Sat Jul 03, 2021 6:26 pm

How to load a game?

Post by minirop »


and if you are not afraid of the command line, you can do: x16emu -prg game.prg -run

nulcow
Posts: 7
Joined: Mon Oct 23, 2023 11:48 pm

Re: How to load a game?

Post by nulcow »

AndyMt wrote: Wed Oct 12, 2022 8:30 am type


LOAD"game.prg",8,1


RUN
What is the '1' at the end of LOAD"game.prg",8,1?
nulcow, software developer and computer artist.
kelli217
Posts: 531
Joined: Sun Jul 05, 2020 11:27 pm

Re: How to load a game?

Post by kelli217 »

nulcow wrote: Tue Oct 24, 2023 2:41 pm What is the '1' at the end of LOAD"game.prg",8,1?
It indicates that the system should load the file at the location specified by the first two bytes. It's good for loading self-starting programs, or for resident programs. And if you accidentally use it for an ordinary BASIC program, it's fine; BASIC programs are automatically saved with the first two bytes placing it in memory location $0801, which is where BASIC programs go anyway.
Ser Olmy
Posts: 39
Joined: Thu Aug 18, 2022 8:20 pm

Re: How to load a game?

Post by Ser Olmy »

nulcow wrote: Tue Oct 24, 2023 2:41 pmWhat is the '1' at the end of LOAD"game.prg",8,1?
It's an instruction to the loader routine to load the file into whatever memory address specified by the two-byte header at the start of the file. Without the ",1" at the end, the header will be ignored and the file will be loaded at start of BASIC memory, which on the X16 is address 2049 ($0801).

Using ",8,1" to load a game instead of just ",8" probably isn't necessary, especially since you're told to start the program with RUN afterwards. Because if the load address is $0801 anyway, using ",8,1" won't make any difference, and if it's not, there won't be any program at $0801 to RUN afterwards.

The only instances where it makes sense to use the extra ",1" are:
  • when you're loading a binary file from inside a BASIC program
  • if you're loading a binary file that is to be started with a SYS command afterwards
  • if someone has created a custom loader that autoruns by overwriting vectors in low memory
voidstar
Posts: 494
Joined: Thu Apr 15, 2021 8:05 am

Re: How to load a game?

Post by voidstar »

By default, the emulator will use the directory it is being launched from as the "current SD" content. There are ways to override that (using command line), but we'll suppose most people are just going to click the x16emu.exe and go from there.

To list possible files that can be loaded, just press F7. Or type the DOS"$ command

If you have a lot of files in that folder, you can hold CTRL to slow down the listing. Otherwise, it is a bit of a pain to only do a partial listing (you can use the STOP key) - the KERNAL is compact and doesn't have provision for nice features like sorting or filtering your directory listing for you. In general that wasn't an issue in the past, we just never really had that many files on a 160KB disk to begin with (and were limited to 25 row systems then; the X16 gives you 60 rows, such luxury! but if it's hard to read you can use the SCREEN 1 command and see how 30 rows works for you).


There is no formal operating system and so extensions don't really mean anything. At the end of the listing on the right, it will say PRG or DIR. DIR are directories you can go into (and there is the implied . and .. for current and previous directory, like in modern systems).
HISTORY NOTE: Some of the first versions of PC-DOS and some late 1970s operating systems, they didn't even have sub-directories yet and the number files were altogether limited to sometimes only 32 (or some multiple of 2) even on very early mainframes! So, having sub-directories at all is a luxury!!

Besides "DIR", X16 CMDR-DOS is going to basically list all non-DIR files as PRG's - which is confusing, but that's just the convention Commodore started. The file MIGHT actually be a PRG, or it might just be a data file. As a convention, most people will mark data files as .DAT or .BIN, but it's not a guarantee. And sometimes there is "no extension" - like modern day Linux style, you must just see "SOMEPROGRAM" or "SOMEPROGRAM.PRG" and either can be loaded and executed.

There are no "file" or "directory" permissions - the only security back then was a punch in the face if you messed with other peoples files, or of course take your disks of files with you.

Executable programs don't even have a header, like modern day MS-DOS EXE files (start with "MZ"). So the system can't even probe the file to try to figure it out for you. This is all pre-protected mode era, the line between Code and Data is very blurred.

The only multi-tasking is that blinking cursor - which is actually doing more than just blinking. It's also monitoring your keystrokes to. If you press RETURN, a slew of activity happens - as the KERNAL ROM starts to parse the current line as a command. Someday when really bored, look up the history of who invented the idea of the blinking cursor :)



This question of how to run things: a useful program might be something that opens every file, looks at the first two bytes, and tries to determine if it is a "valid address." Now nearly anything from $0000 to $FFFF is a valid address - but no program is going to start at $FFFF, nor start in the ZeroPage region - since that'd just be rude. As mentioned, all BASIC programs will start $0801. And for practical reasons, there are only a few regions that "normal programs" would generally started at. Taking it one step further, it could look at the third byte into the file and determine if it is a valid 6502 opcode (it would have to probe a little further to examine operands) - making an even better guess on if it's an executable file versus a data file. Then do a little summary of "Probably a BASIC program" "Probably executable Code" etc. Food for thought....
PolygonSlayer
Posts: 1
Joined: Tue Jan 09, 2024 8:58 pm

Re: How to load a game?

Post by PolygonSlayer »

Hi all, I am able to load a game fine via command line as long as I have it in the same directory as the emulator, but so far I've not had any luck trying to load files outside of that folder.
I tried using both the -startin and -fsroot commands and the emulator boots up, but does not run the game.
Does anyone have any idea what I'm doing wrong?


Cheers :)
Post Reply