Page 7 of 7

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 1:42 pm
by Daedalus
That's not actually using an SDcard as far as the emulator is concerned, it's using the SDcard as a hostfs with the root set to the card. It's still just "Files on the host system."

Using the -sdcard switch says "Use this mounted file as a literal fat32 SDcard" and that lets the emulator uses the actual fat32 code in the kernal. It uses the code in the kernal ROM at that point, instead of being emulated by the ... emulator.

I know, right? WUT?

Long story short, the system behaves differently when on -sdcard and when on hostfs.

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 2:35 pm
by Daedalus
Milk my duds! (From the movie "Wreck it Ralph.")

I'm going through the keyboard scan code, and I see there is a "I2C" WRITE that sets the Caplock led.

Have we always been able to write through "I2C" as well as read? Does this mean we can set the mouse mode so the scroll wheel works?

There doesn't appear to be anything in the mouse driver that supports changing the mode, but that doesn't mean it can't be added.

... The mouse we ship with the keyboard DOES have a scroll wheel, right?

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 3:11 pm
by DragWx
The ROM contains a full implementation of a FAT32 driver (i.e., taking a plain seekable bitstream and making "FAT32" happen on it). Using the SD card image directly is such a seekable bitstream, so the CPU/ROM can operate on it as intended.

The host's hard drive cannot be used like this, so for hostfs, the best we can do is detect when the 6502 is about to run a disk access i/o routine, break out, have the emulator itself fulfill it natively with standard file access functions, skip the 6502 ahead and resume as though it completed the operation itself.

The trade-off is, the emulator needs to simulate those Kernal functions itself, outside of the ROM. While the goal is to match the ROM's behavior as closely as possible, there will be times when it doesn't (and sometimes can't). Hostfs would be fine for the most common operations a game would need like loading and saving, and the SD card image is when you need true 1:1 emulation of the SD card, like using an OS.

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 3:16 pm
by DragWx
Daedalus wrote: Wed Jul 26, 2023 2:35 pm Have we always been able to write through "I2C" as well as read? Does this mean we can set the mouse mode so the scroll wheel works?
Yes, the i2c interface had always been both read and write, and I imagine scroll wheel support could be added as long as the smc isn't filtering the messages out or something.

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 4:09 pm
by ahenry3068
I guess I haven't done anything advanced enough to break it yet. Using -fsroot with the sdcard
has so far worked ok for me.

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 8:54 pm
by Ed Minchau
Can I just use the actual SD card plugged into my laptop rather than an image?

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 9:26 pm
by ahenry3068
I use it that way on Linux. I'm sure it can work under windows too. According to other
people here on some functions it won't work correctly. But if your just using Load and Save it should work fine.

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 9:33 pm
by Daedalus
Ed, if you want it to be an actual fat32 image usable with -sdcard, then no. But if all you want is to connect to the SDcard instead of a subdirectory on your hard drive, then sure: Just use -fsroot your_sdcard just as you would any sub directory in your computer.

Long answer, the "secret sauce" is in what DragWx said:
"(i.e., taking a plain seekable bitstream and making "FAT32" happen on it). Using the SD card image directly is such a seekable bitstream, so the CPU/ROM can operate on it as intended."

So what you need to do to make an sdcard.img work like that is to mount it using your computer's mount system, then pass the mounted file itself (NOT the mount point..) to the emulator in the -sdcard param

The mount point, which is also sees the contents of the file, is just part of your host filesystem, and can only be used as a root for the -fsroot param.

Look at the link posted by DragWx a few posts ago. That explains how to set up the sdcard image to work that way.

Re: Switching to R43 frustration

Posted: Wed Jul 26, 2023 9:42 pm
by Daedalus
Easy way to tell the difference:

In the BASIC screen on startup, type:
DOS"$

In an emulated environment (not using the -sdcard switch.) the first line will show the root directory, or "/" HOST

In an sdcard environment (and assumedly, real hardware.) it will show the volume label, or "X16 DISK" FAT32

This doesn't affect much in the way of normal operation, but some commands like copy (DOS"C:dest_file=source_file) won't work on the host fs.