loss of program lines

Modding and Technical Issues

Moderator: Moderators

Post Reply
User avatar
merser
Vic 20 Drifter
Posts: 20
Joined: Sat Sep 30, 2017 4:50 pm
Location: brisbane

loss of program lines

Post by merser »

I was trying a small program on my vic and saved it to disk. Then I altered it but when I added a line it wiped out the end of the program past where I added it. I could remove lines but if I attempted to add or edit a line it just wiped lines.
I thought maybe a memory problem but print fre(0) was giving correct number. After reloading and trying again it kept doing it. Until I turned the vic off and on again and it behaved normal.
Anyone else encountered this or has an idea what may have been happening?

Michael
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: loss of program lines

Post by Mike »

That's more likely a stray POKE into zeropage, or into the address range occupied by the BASIC program, which corrupts the data structures.

When the internal RAM is defective, the VIC-20 doesn't start up at all (you only get the white background with cyan border without the start-up prompt), if an external RAM expansion doesn't work correctly, the start-up prompt shows a number other than 6655 (+3K), 6519 (Super Expander), 11775 (+8K), 19967 (+16K) or 28159 (+24K) bytes free (extra RAM in BLK5 is not counted, also the +3K RAM is not usable for BASIC when a bigger RAM expansion is present).

So, for more informed help, you should tell what RAM expansion you use; and if you don't mind, put the suspect *.prg file into a *.zip and attach it here.
User avatar
merser
Vic 20 Drifter
Posts: 20
Joined: Sat Sep 30, 2017 4:50 pm
Location: brisbane

Re: loss of program lines

Post by merser »

Hi Mike,

I think you could be right maybe it was a stray poke. It hasn't occurred again. The file is attached. Maybe it loaded incorrectly from disk. The disk I used is quite old. I have to admit I didn't check the memory locations poked in the code were correct after it loaded.
Attachments
line draw.zip
(437 Bytes) Downloaded 42 times
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: loss of program lines

Post by Mike »

O.K. - I had a quick peek. The program as is looks unsuspecting for sure.

However, you should be wary if you go to extend it: of the long variable names, BASIC V2 only uses the first two characters to differentiate them (COLUMN and COST, for example, are the same). Any assignment to one of these aliased identifiers also changes what is read/written by the other one. If that other identifier then is used as POKE address you have that stray write, where you didn't suspect it.

The program could also be shortened quite a bit. The only subroutine that is actually called more than once is the colour picker in lines 110..115. All other subroutines could be folded back into the main program.
User avatar
merser
Vic 20 Drifter
Posts: 20
Joined: Sat Sep 30, 2017 4:50 pm
Location: brisbane

Re: loss of program lines

Post by merser »

Hi Mike,

Yeah I realized the two character limitation for variable names, hence why I changed the color subroutine to hue as I already was using Column as a variable name. Will make those changes you suggested.

thanks
Post Reply