Some questions about TheVIC20

You need an actual VIC.

Moderator: Moderators

Post Reply
The Geek on Skates
Vic 20 Drifter
Posts: 33
Joined: Fri Jul 12, 2019 6:11 am
Website: http://www.geekonskates.com
Occupation: Code Monkey

Some questions about TheVIC20

Post by The Geek on Skates »

Happy Friday! :)

I recently got a new "TheVIC20" (and absolutely loving it!), and lately I've been messing around with BASIC. I learned (from the manual and a few videos) to use the LOAD, SAVE and VERIFY commands, and understand how they work. But I was wondering, how do you edit an existing program, or remove a program from the disk file? Calling SAVE "NAME", 8, 1 doesn't seem to work after a program named NAME is already on disk. I know I could just delete the entire .d64 file from my USB drive, but is that the only way to make changes? That seems a bit odd, like throwing away the disk after saving a program or two. But I didn't have a VIC-20 growing up, so for all I know that was an actual limitation of the hardware. Anyway I couldn't find anything in the manual about editing/deleting programs, so I figured this was the best place to ask. :)

Oh, and I just remembered (and sorry if this is in the manual somewhere) but while I'm here, is there a way to set the amount of RAM available in Classic Mode? Totally not a big deal if not - 3.5k is a lot for the kinds of fun tinkering I'm doing. If I want to build a real game, I'll stick to cc65. But I'm asking because I've been reading "Compute's Programming the VIC" and saw a few things that change in memory depending on your RAM setup (like where the screen and color RAM are). I would kind of like to mess around with those in BASIC, so that way next time I'm writing a game I can have a better understanding of how all that works.

Thanks and have an awesome weekend!
The Geek on Skates
Vic 20 Drifter
Posts: 33
Joined: Fri Jul 12, 2019 6:11 am
Website: http://www.geekonskates.com
Occupation: Code Monkey

Best place to talk coding in

Post by The Geek on Skates »

I have one and it's the coolest thing I've ever seen! :)

As a newcomer to the Commodore community, this is the closest I've ever come to the real thing. We had an NES growing up, and I had never heard of Commodore until a few years ago, so granted I have nothing to compare it to apart from pics and videos. But it looks very similar to the 8-Bit Guy's (except for the ports and branding, of course). Here's a screenshot (sorry for the bad quality -
1AFDB5A6-F8CC-47D5-834F-293972D1E1A5.jpeg
might have to get one with the screen off lol). It's not yellow or even beige, but that nice off-white color. The joystick is the best I've ever played with, and I've been totally hooked on Matrix, Mega-Vault and Choplifter. Some games don't seem to work on there (Omega Race, Ms. Pac-Man, Donkey Kong, etc.), and I'm guessing it has something to do with the ".a0" extension on the ROMs (I've read it's an older format or something, but not sure what to do about it). But at least it'll run the games I'm building (a text adventure and a hockey game), and it's been fun messing with C64 games too. And Classic Mode is the bomb.com! I've learned my way around the PETSCII keyboard, and I'm going through some old books on the VIC and typing in programs like kids did back in the 80s. It's been a ton of fun and if you can get one in your country, I totally recommend it!
User avatar
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: Some questions about TheVIC20

Post by Noizer »

Hi Geek on Skates, welcome on Denial.
First thing I did some time ago as I got The64 was to check the manuals on the site: https://retrogames.biz/thec64/support/manuals-thec64
Here you should find some hints.
Apart from that, using the search function on the Denial site will certainly show you some information of earlier topics to this and all you other questions you may have. ✍️👍
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Some questions about TheVIC20

Post by Mike »

The Geek on Skates wrote:[...] I learned (from the manual and a few videos) to use the LOAD, SAVE and VERIFY commands, and understand how they work. But I was wondering, how do you edit an existing program, or remove a program from the disk file? Calling SAVE "NAME", 8, 1 doesn't seem to work after a program named NAME is already on disk. [...]
CBM DOS at first does not allow two files with the same name on a storage medium, that is why your attempt to save a new file under the same name is faulted. You need to delete the old file first - in CBM DOS parlance, "scratch" it - with a command sent over the CBM DOS command channel:

OPEN15,8,15,"S0:name":CLOSE15

Replace "name" within the quotes with the appropriate file name. Then, a save command with that name will succeed.

I should note that this is not specific to TheVIC20, but you will encounter the same issue also on original hardware. Also, with disk there is no significance to using ",8,1" with SAVE instead of just ",8".

...

You might find the so-called "save-and-replace" variant of the SAVE command being mentioned elsewhere here on Denial. Don't use it! Its implementation is faulted on many original 1541 disk drives and can lead to data loss.
Vic20-Ian
Vic 20 Scientist
Posts: 1214
Joined: Sun Aug 24, 2008 1:58 pm

Re: Some questions about TheVIC20

Post by Vic20-Ian »

The Geek on Skates wrote: Fri Jan 08, 2021 9:53 pm
Oh, and I just remembered (and sorry if this is in the manual somewhere) but while I'm here, is there a way to set the amount of RAM available in Classic Mode? Totally not a big deal if not - 3.5k is a lot for the kinds of fun tinkering I'm doing. If I want to build a real game, I'll stick to cc65. But I'm asking because I've been reading "Compute's Programming the VIC" and saw a few things that change in memory depending on your RAM setup (like where the screen and color RAM are). I would kind of like to mess around with those in BASIC, so that way next time I'm writing a game I can have a better understanding of how all that works.

Thanks and have an awesome weekend!
Here you go

Watch this from Robin on TheC64 Vic20 memory

https://youtu.be/88cJVoESSps?t=1250

Link to config files for classic mode

https://www.youtube.com/redirect?q=http ... U4dw%3D%3D
Vic20-Ian

The best things in life are Vic-20

Upgrade all new gadgets and mobiles to 3583 Bytes Free today! Ready
Vic20-Ian
Vic 20 Scientist
Posts: 1214
Joined: Sun Aug 24, 2008 1:58 pm

Re: Best place to talk coding in

Post by Vic20-Ian »

Have a look in the programming section of the board.

Glad you like your TheVIc20.

PM Sent.
Vic20-Ian

The best things in life are Vic-20

Upgrade all new gadgets and mobiles to 3583 Bytes Free today! Ready
The Geek on Skates
Vic 20 Drifter
Posts: 33
Joined: Fri Jul 12, 2019 6:11 am
Website: http://www.geekonskates.com
Occupation: Code Monkey

Whoops! My mistake

Post by The Geek on Skates »

lol wow this is embarrassing... I had way, way too many tabs open! :D

The title of this was going to be "best place to learn about coding in C using cc65" or something like that; then I found there is a section specifically about cross-compiling and asked it there. When I wrote the message above, I thought I was replying to the post on TheVIC20! :D

Sorry about the confusion lol
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Whoops! My mistake

Post by Mike »

The Geek on Skates wrote:When I wrote the message above, I thought I was replying to the post on TheVIC20! :D
No worries. I've merged the two threads. :)
The Geek on Skates
Vic 20 Drifter
Posts: 33
Joined: Fri Jul 12, 2019 6:11 am
Website: http://www.geekonskates.com
Occupation: Code Monkey

Re: Some questions about TheVIC20

Post by The Geek on Skates »

Mike wrote: Sat Jan 09, 2021 4:01 am CBM DOS at first does not allow two files with the same name on a storage medium, that is why your attempt to save a new file under the same name is faulted. You need to delete the old file first - in CBM DOS parlance, "scratch" it - with a command sent over the CBM DOS command channel:

OPEN15,8,15,"S0:name":CLOSE15

Replace "name" within the quotes with the appropriate file name. Then, a save command with that name will succeed.

I should note that this is not specific to TheVIC20, but you will encounter the same issue also on original hardware. Also, with disk there is no significance to using ",8,1" with SAVE instead of just ",8".

...

You might find the so-called "save-and-replace" variant of the SAVE command being mentioned elsewhere here on Denial. Don't use it! Its implementation is faulted on many original 1541 disk drives and can lead to data loss.
Wow, okay, thanks! I've never heard of CBM DOS before (I read "DOS", I think DOSBox lol) but that would explain why I've never found any info on this subject; gotta have the right search keywords lol. Seriously tho, I will definitely have to memorize this code - it doesn't make a whole lot of sense, but if it works, it works. I especially appreciate that bit about the other way being faulted; if I ever get to use a real VIC, I don't want to do anything that would break stuff.

PS: Thanks also to Vic20-Ian for the video and links! In addition to answering my question, you also gave me another fun YouTube channel to check out :)
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Some questions about TheVIC20

Post by Mike »

The Geek on Skates wrote:[...] I've never heard of CBM DOS before (I read "DOS", I think DOSBox lol) but that would explain why I've never found any info on this subject; gotta have the right search keywords [...]
If you enter this small program and RUN it with a freshly powered on 1541 ...

Code: Select all

1 OPEN15,8,15
2 GET#15,A$:PRINTA$;:IFST=0THEN2
3 CLOSE15
... you'll get the start-up message of the drive: 73,CBM DOS V2.6 1541,00,00 ;)

The OPEN15,8,15,"...":CLOSE15 incantation is just boilerplate. What matters is, the 1541 is an own computer and you can send commands to its 'command line' this way and read responses (success reports or error messages) with a program like the one you see above.

For an easier access to the command line, you can use the DOS Wedge. With this tool, you can instead simply send the commands by prefacing them with "@". "@" on its own returns the responses and "@$" shows you the disk directory without erasing the current program in memory.

There are quite some commands available (you should see the 1541 drive manual for more info), here are some of the more often used ones:
  • S0:name - delete file "name",
  • R0:new=old - rename file "old" to file "new"
  • I0 - Initialise disk. If you want to be 100% sure that a disk change is correctly handled, use this (normally, giving disks differents IDs on format ensures the drive handles a disk change correctly, but people are lazy and tend to use the same ID all day long ... ;) )
  • V0 - Validate disk. Roughly equivalent to chkdsk in the Windows/DOS command line.
  • N0:name,id - Format disk. Shouldn't be necessary in emulation but you'll need this on real hardware. Always use 2 characters for the ID, and give different IDs to different disks (see the I0 command above why).
The "0" or "0:" behind the command is the drive number. For single drive units, this is always 0 and can be omitted, but it makes the syntax clearer especially with the S and R commands. There exist dual drives, and these allow for 0 or 1 as drive number.

Other commands allow for direct sector access or writing/reading the drive's memory and even executing programs in the drive, but that's somewhat advanced stuff.

Greetings,

Michael
The Geek on Skates
Vic 20 Drifter
Posts: 33
Joined: Fri Jul 12, 2019 6:11 am
Website: http://www.geekonskates.com
Occupation: Code Monkey

Re: Some questions about TheVIC20

Post by The Geek on Skates »

Last night I fired up my TheVIC20 and put those CBM DOS commands to the test. Sure enough, they worked like a charm. In case anyone's interested, here's how to edit:

1. Load your program the usual way (i.e. LOAD "my-code",8)
2. Edit your code how you want (in memory).
3. Scratch (delete) the old version (i.e. "OPEN 15,8,15,"SO:my-code":CLOSE 15)
4. Save the revised program - you can use the same name (SAVE "my-code",8)

I probably have a syntax error in there somewhere (lol) but the bottom line is I was able to edit and delete my files just fine. This is a HUGE help for my experiments in BASIC, especially now that I can even play with the different RAM options (and I know I can do it in VICE, but IMO there's no beating a real PETSCII keyboard for PETSCII art, and it's also nice to see what the finished graphics look like and all that). Also, for those interested, if you search Wikipedia for "CBM DOS" they have a command for renaming files on there too (and also some other things).

Thanks guys! :)
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: Some questions about TheVIC20

Post by orion70 »

The Geek on Skates wrote: Thu Jan 14, 2021 6:32 pm[...]
3. Scratch (delete) the old version (i.e. "OPEN 15,8,15,"SO:my-code":CLOSE 15)
[...]
...where "SO" should be "S0" (S-ZERO) :wink:
The Geek on Skates
Vic 20 Drifter
Posts: 33
Joined: Fri Jul 12, 2019 6:11 am
Website: http://www.geekonskates.com
Occupation: Code Monkey

Re: Some questions about TheVIC20

Post by The Geek on Skates »

wait, really? SO (with an 0 instead of a zero) seemed to work for me that night. I figured "SO" must be "scratch out" or something. But still, thanks for letting me know. :)
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Some questions about TheVIC20

Post by srowe »

The Geek on Skates wrote: Fri Jan 15, 2021 9:00 pm wait, really? SO (with an 0 instead of a zero) seemed to work for me that night. I figured "SO" must be "scratch out" or something. But still, thanks for letting me know. :)
DOS commands are only significant in their first character. So the following are all the same
  • S
  • SCRATCH
  • SAUSAGES
The (optional) number that follows is the drive number. For single drive devices it isn't necessary but has been recommended to avoid the "save with replace" bug on the 1541.
Post Reply