17

After loading a file list from a floppy disk it is hard to program in BASIC because the file list is interpreted as BASIC lines.
For example there can be 20 lines with the number 1, because 20 files have a file size of one, so to delete them, you have to type 1+RETURN 20 times.

Is there a way to use BASIC in this case without having to Soft Reset or Hard Reset the C64?

4 Answers 4

29

Try using the "new" command. This clears BASIC's memory, so that you can write a new program.

8

A workaround is to load the DOS WEDGE from the 1541 Demo Disk. Once installed, it enables several disk commands without interfering with the BASIC memory. For example @$ will list the directory without overwriting BASIC memory.

Another one is to load the directory into the screen buffer, by using kernal calls:

SYS57812"$",8:POKE147,0:POKE780,0:POKE781,0,POKE782,16:SYS65493

Caveats:

  • The directory listing will be difficult to read
  • If the directory exceeds 2KB, it will corrupt BASIC RAM.
2
  • 7
    "Sell you a disk drive that could independently run your computer code? Sure. Sell you a disk drive to which you can save your code without having first memorised your disk's contents? You'll need a software extension for that."
    – Tommy
    Sep 6, 2017 at 20:21
  • 1
    @Tommy It looks to me that someone wanted to do it initially correctly, but meanwhile some constraint (boss, timing) has partially destroyed the nice goals. After that, the "don't change a working system" rule of the management blocked all the improvements.
    – peterh
    Dec 4, 2019 at 10:59
5

You might also try to start the BASIC program on a different location.

It is determined by the values of the bytes 43, 44. By default the BASIC starts at 2048, thus the values are 1 in 43 and 8 in 44. (The 1 might be some rounding reason ;-) ). But you can change it.

More exactly:

POKE 43, 1: POKE 44, 192

will move the start of the BASIC program to 49152, where you have free 4kB to load the directory. After you got your list, you can move the BASIC area back to 2048.

1
  • I recall something about the location that 43/44 points to or the location before needing to be an 0, but I think that might only affect lines entered through keyboard. That may be why it's offset by 1.
    – LawrenceC
    Dec 6, 2019 at 18:41
3

The best way is to have some sort of accessory program installed. There are a few options:

  • on the Commodore 1541 test/demo disk there is a program called "DOS WEDGE". You can load and run this, and it will take a little memory (I think at $C000, 49152, but it might be in the cassette buffer instead) with a little machine language program that will let you do a directory. I believe you type >$ (it might just be $). > by itself will also let you read the disk drive error channel. This test/demo disk came for free with the 1541 drive, and you should be able to find disk images of it online; all the contents are public domain and are freely redistributable.
  • some fast load cartridges like Epyx Fast Load have a wedge-like capability too which will let you pull a directory.
  • the Commodore 128, 16 and Plus/4 (plus PETs/CBMs that had BASIC 4.0) have a DIRECTORY command (you can also use CATALOG, which I tended to use instead because c-shift-A was the abbreviation instead of d-i-shift-R). This lets you pull a directory without erasing an existing program in BASIC memory.

You can clear existing BASIC programs (and directories loaded via LOAD"$",x) with the NEW command, and you can also reset the C64 entirely via the command SYS64738, which is the equivalent of a soft reset of the entire system and will reset things to the initial power-up screen.

You must log in to answer this question.