Page 1 of 1

[Emulator] OLD - command crashes (on start / reset with no 'old' code)

Posted: Mon Dec 11, 2023 3:56 am
by OldOzC64er
The OLD command is still crashing the emulator (R46, Windows 10), if you enter it when there is no past program history. On boot, type OLD (enter) and it will hang. If you were to boot up, move around screen, even type in 10 (enter) [with no program] and then try OLD it will still hang. If you enter some function/command it seems to break the spell - so, if you direct enter PRINT "HELLO" (enter) then it seems to be okay if type OLD.
* I don't have a x16 computer, so not sure if it's the same in hardware version.

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Posted: Mon Dec 11, 2023 6:16 pm
by mortarm
OldOzC64er wrote: Mon Dec 11, 2023 3:56 am ...if you direct enter PRINT "HELLO" (enter) then it seems to be okay if type OLD.
Mine hangs, also R46 w/Win10.

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Posted: Mon Dec 11, 2023 6:16 pm
by kelli217
I believe this is a known issue, and one that I don't think anyone is inclined to fix.

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Posted: Mon Dec 11, 2023 10:22 pm
by OldOzC64er
Mine hangs, also R46 w/Win10.
Hmm... I can't seem to replicate what I did when I noticed this? Mine too just hangs even after the print command.

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Posted: Mon Dec 11, 2023 11:58 pm
by DragWx
It's because the "OLD" command naively assumes there's a valid BASIC program in memory at $0801, and in your case, the emulator is likely initializing RAM to random values instead, so the routine is trying to scan through garbage data as though it were a BASIC program and it ends up choking. :P

More specifically, the issue is in x16rom/basic/code1.s, at lnkprg. This routine needs to read some zeroes at the correct times in order to terminate. With garbage data, it probably won't, so it gets stuck in a loop like you're seeing.

EDIT: I don't think the solution is necessarily to update lnkprg, but instead to update the OLD command itself to do some kind of contingency check to make sure something that "looks like" a BASIC program is indeed at $0801 before doing anything else.

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Posted: Tue Dec 12, 2023 1:34 am
by OldOzC64er
Thanks for explanation.

I noticed a previous post from Tomxp411 mentioning the CTRL + R key to reset, and it seems to work in this lock-up 👍.
It's fringe case situation that someone does enter OLD, but I was more wondering if it pointed to a bigger issue (originally).

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Posted: Tue Dec 12, 2023 3:43 am
by DragWx
It may be fringe, but I'm all for eliminating any kind of "lol here's how you can crash the X16 with one simple command lol" memes. :P

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Posted: Tue Dec 12, 2023 7:03 pm
by JimmyDansbo
kelli217 wrote: Mon Dec 11, 2023 6:16 pm I believe this is a known issue, and one that I don't think anyone is inclined to fix.
I have just created a pull request that will prevent OLD command from hanging.
https://github.com/X16Community/x16-rom/pull/237
Granted, it will restore a random BASIC line, but it does not hang.