Beginner Question about the Emulator

Chat about anything CX16 related that doesn't fit elsewhere
Post Reply
Pop
Posts: 5
Joined: Thu Mar 30, 2023 9:46 am

Beginner Question about the Emulator

Post by Pop »

I'm just getting started using the emulator and was wondering what it means when I do this:

Code: Select all

LOAD"$",8
It says: "LOADING FROM $0801 TO $0B06"
Then when I do a list the listing that is returned is a whole lot of petscii characters instead of filenames?
User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Re: Beginner Question about the Emulator

Post by JimmyDansbo »

The problem is most likely that your files are in all lowercase.
Try creating or renaming a file to all upper cases and see if it does not show up correctly in the listing.

You can also press F7 to get a listing, it will automaticly execute DOS"$" for you.
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Pop
Posts: 5
Joined: Thu Mar 30, 2023 9:46 am

Re: Beginner Question about the Emulator

Post by Pop »

I feel like I'm not doing anything wrong therefore its a bug.

Image
User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Re: Beginner Question about the Emulator

Post by JimmyDansbo »

There is just a difference i how the code does things.

DOS commands try to make things as easy for you as possible that is why you see the correct names when you use DOS.

LOAD, OPEN, CLOSE and the other C64 native commands has not (yet?) been given the same treatment and therefor still only work correctly with names with capital letters.
One of the problems is that your PC uses ASCII/Unicode while the X16 emulator uses PETSCII. The characters are not mapped to the same IDs.
dosvsload.jpg
dosvsload.jpg (126.4 KiB) Viewed 58434 times
The files on the host filesystem are named as follows:
RAMTEST.PRG
ramtest.asm
README.md

From my LOAD"$",8 listing you can even see that the README.md file is displayed almost correctly. It is just the md part that is converted to "wrong" petscii codes.
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Xiphod
Posts: 568
Joined: Thu Apr 15, 2021 8:05 am

Re: Beginner Question about the Emulator

Post by Xiphod »

Within the emulator, press SHIFT+ALT to swap between the two PETSCII character sets. The default set is upper case only. Swapping once over to the upper/lower PETSCII set will show the filenames better (but will be swapped-case). This is not just for the emulator, it is how the actual hardware works as well.

That's just how mixed-case host filenames are presented within the X16 system. For actually deployed X16 software, those should be upper case filenames. Generally I don't run the emulator from within its own folder. "start fresh" from an empty sub-folder, something like

Code: Select all

md WORKING
cd WORKING
..\x16emu.exe 
TomXP411
Posts: 1803
Joined: Tue May 19, 2020 8:49 pm

Re: Beginner Question about the Emulator

Post by TomXP411 »

Pop wrote: Fri Jan 12, 2024 8:40 am I feel like I'm not doing anything wrong therefore its a bug.
It's not a bug. It's expected behavior. Commodore and Commander computers use the PETSCII character set, not ASCII. So some things are a little different. Load "$" is not the best way to get a directory on the Commander, anyway.

Filenames for Commander X16 files should be "UPPER CASE" when viewed on an ASCII/Unicode system (Windows, MacOS, Linux.)

When viewing text in upper case/graphics mode on the Commander, letters that show up as lower case on ASCII systems will show up as graphic symbols on the Commander. For example, the letter "a" is ASCII value 193. If you PRINT CHR$(193) on the Commander, you'll see the ♠ spade symbol.

Also, when you go to LOAD a file, note that CMDR-DOS expects unshifted letters, whether the letters on the screen are upper or lower case. So do NOT type letters with the shift key, even in the load command. Just type the lower case letters, and let LOAD work out whether it sHoulD bE sHiFtED.

Finally... LOAD"$" works, but it's not the preferred way of getting a directory listing. Instead, use the DOS"$" command, or its shortcut, F7.

The system also now integrates the DOS wedge, so you can use @$ to get a directory, @command to send disk commands, and /filename to quickly load files.
Pop
Posts: 5
Joined: Thu Mar 30, 2023 9:46 am

Re: Beginner Question about the Emulator

Post by Pop »

Thanks, I don't really understand but maybe that's because I don't know enough about Commodore systems.
TomXP411
Posts: 1803
Joined: Tue May 19, 2020 8:49 pm

Re: Beginner Question about the Emulator

Post by TomXP411 »

Pop wrote: Fri Jan 12, 2024 11:33 pm Thanks, I don't really understand but maybe that's because I don't know enough about Commodore systems.
That's totally understandable.

The quick answer is that Commodore, unlike virtually every other computer maker, uses a different order of letters in its character set.

On all computers, letters, numbers, symbols, and control codes ("Move that cursor left, please") are stored as numbers. Most computers use the ASCII standard for this, and basically every computer built since the 70s has used the same standard. Here's a handy chart: https://web.alfredstate.edu/faculty/wei ... index.html

In ASCII, the letter "A" is stored as the number 65, "B" is 66, and so on. The lower case letters, "abc..." start at 97 and also go sequentially in ASCII.

But the good folks at Commodore did something a little different. The 1977 Commodore PET did not have lower case letters. Instead, the engineers used that space for graphic symbols, which could be used for drawing boxes and charts. "A" is still 65, but there was no "a". Instead, pressing Shift+A prints the ♠ character, which actually lives at 193 in the PETSCII table. (65 + 128. Turns out the SHIFT key is basically the "add 128" key.)

This is called PETSCII. You can find a handy PETSCII chart here: https://www.c64-wiki.com/wiki/PETSCII

Well, as you might expect, users were all "HEY, IT MIGHT BE NICE IF WE COULD TYPE LOWER CASE LETTERS INSTEAD OF SHOUTING ALL THE TIME!"

And Commodore said, "SURE, THAT SOUNDS LIKE A GOOD IDEA!" And a second version of the PET came out with a "Typewriter" keyboard. One of the new PET's features was lower case text.

Except... they made the lower case mode optional. And instead of flipping how the shift key works, they just changed the way the text looked, without changing anything about how it worked. So Upper-Case "A" became lower-case "a", and pressing

And we've been stuck with that nonsense ever since.

Anyway, this leads us to the obvious question of translating between ASCII and PETSCII. And the process is, surprisingly, super annoying.

In upper-case/graphic mode (the default mode when a Commodore boots up):
A-Z on PC and Commodore are the same.
a-z on PC become graphic symbols on Commodore. So don't use them.

In upper/lower case mode:
A-Z on PC should be mapped to 193-218. (Remember, "SHIFT" adds 128)
a-z on the PC get mapped to 65-90.

And then the are "screen codes"... which are in yet another order, because Commodore's engineers don't want us to sleep at night.
Pop
Posts: 5
Joined: Thu Mar 30, 2023 9:46 am

Re: Beginner Question about the Emulator

Post by Pop »

Ok thanks for the info it makes sense. And I reread what JimmyDansbo said and would I be correct in saying the LOAD commands are C64 commands and only operate at a C64 level so that's why I'm getting garbage. When I first started with the emulator I googled how to read the files and I thought I was doing the accepted Commander X16 way but it appears not. I always find the starting off with something new is an extremely slow process but once I learn enough then the learning process speeds up a lot.
TomXP411
Posts: 1803
Joined: Tue May 19, 2020 8:49 pm

Re: Beginner Question about the Emulator

Post by TomXP411 »

Pop wrote: Sat Jan 13, 2024 3:03 am Ok thanks for the info it makes sense. And I reread what JimmyDansbo said and would I be correct in saying the LOAD commands are C64 commands and only operate at a C64 level so that's why I'm getting garbage. When I first started with the emulator I googled how to read the files and I thought I was doing the accepted Commander X16 way but it appears not. I always find the starting off with something new is an extremely slow process but once I learn enough then the learning process speeds up a lot.
Basically, yes. The LOAD "$" method gives you the real directory data, complete with the case-mismatched filenames.

When you type DOS"$" or @$, the DOS command translates case so that all the letters are unshifted and readable.
Post Reply