vic 20 listing help needed

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
TheVic20User
Vic 20 Drifter
Posts: 30
Joined: Mon Jan 13, 2025 2:22 pm
Location: Germany

vic 20 listing help needed

Post by TheVic20User »

Hello!

I want to enter the Desert Race listing on my original VC20 PAL. Even though I typed line 1 correctly, I get a syntax error when I hit return. I've unlisted the original program, and line 1 is exactly as I entered it. At first, I thought there was a defect on my VC20, but I get the same error on the second device. What am I doing wrong? The game is for unexpanded VC. Thank you very much!

The Listing are:

1 print"{clear}{black}wait...":cs=6144:fori=csto7678step2:z=peek(32768+(i-cs)/2):pokei,z:pokei+1,z:next
2 poke36879,255:poke36867,(peek(36867))or23:poke36869,254:poke36881,24:fori=0to47step2:reada
3 poke6144+i,a:poke6144+i+1,a:next:data16,186,254,186,56,170,254,186,0,216,219,219,123,30,24,24
4 data42,0,160,5,0,144,1,36:print"{clear}":f=30720:c=7702:au=7954:sp=0:sc=0:poke36878,15
5 pokeau+f,6:pokeau,0:poke36874,128+int(sp/10):sp=sp+.3:ifsp=>100thensp=100
6 a=int(rnd(1)*22):pokec+f+a,5:pokec+a,1:fort=0to100-sp:next:pokeau,32:print"{home}{down}{left}"chr$(148)
7 poke218,peek(218)or128:ifpeek(197)=17thenau=au-1:ifau<7944thenau=7944
8 ifpeek(197)=18thenau=au+1:ifau>7965thenau=7965
9 ifpeek(au)<>32thenpokeau+f,2:pokeau,2:fort=15to0step-.1:poke36878,t:next:poke198,0:wait198,1:goto4
10 print"{home}{black}score"sc:sc=sc+1:goto5:rem desert race (c) 2023 by rainer kappler
PRESS PLAY ON TAPE
User avatar
srowe
Vic 20 Scientist
Posts: 1471
Joined: Mon Jun 16, 2014 3:19 pm

Re: vic 20 listing help needed

Post by srowe »

The listing works for me if I adjust the control sequences slightly and process it with cbm-shell

Code: Select all

(cbm) cat desert-race.txt
1 print"{clr}{blk}wait...":cs=6144:fori=csto7678step2:z=peek(32768+(i-cs)/2):pokei,z:pokei+1,z:next
2 poke36879,255:poke36867,(peek(36867))or23:poke36869,254:poke36881,24:fori=0to47step2:reada
3 poke6144+i,a:poke6144+i+1,a:next:data16,186,254,186,56,170,254,186,0,216,219,219,123,30,24,24
4 data42,0,160,5,0,144,1,36:print"{clr}":f=30720:c=7702:au=7954:sp=0:sc=0:poke36878,15
5 pokeau+f,6:pokeau,0:poke36874,128+int(sp/10):sp=sp+.3:ifsp=>100thensp=100
6 a=int(rnd(1)*22):pokec+f+a,5:pokec+a,1:fort=0to100-sp:next:pokeau,32:print"{home}{down}{left}"chr$(148)
7 poke218,peek(218)or128:ifpeek(197)=17thenau=au-1:ifau<7944thenau=7944
8 ifpeek(197)=18thenau=au+1:ifau>7965thenau=7965
9 ifpeek(au)<>32thenpokeau+f,2:pokeau,2:fort=15to0step-.1:poke36878,t:next:poke198,0:wait198,1:goto4
10 print"{home}{blk}score"sc:sc=sc+1:goto5:rem desert race (c) 2023 by rainer kappler
(cbm) unlist desert-race.txt desert-race.prg
Writing desert-race.txt to desert-race.prg
(cbm) !xvic -mem none -autoload desert-race.prg
Try entering lines one at a time and splitting any that fail with ?SYNTAX ERROR until you find the problem. Alternatively, if you zip up a failing program and attach it here I'll try and diagnose what the problem is.
User avatar
TheVic20User
Vic 20 Drifter
Posts: 30
Joined: Mon Jan 13, 2025 2:22 pm
Location: Germany

Re: vic 20 listing help needed

Post by TheVic20User »

Thank you! I got a syntax error on line 1, even though I entered everything very precisely.

So I couldn't get any further.

1 print"{clear}{black}wait...":cs=6144:fori=csto7678step2:z=peek(32768+(i-cs)/2):pokei,z:pokei+1,z:next

but what will not work on the original vic i cannot find the problem :roll:
PRESS PLAY ON TAPE
User avatar
AndyH
Vic 20 Afficionado
Posts: 442
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: vic 20 listing help needed

Post by AndyH »

Edit -
1 print"{clear}{black}wait...":cs=6144:fori=csto7678step2:z=peek(32768+(i-cs)/2):pokei,z:pokei+1,z:next
The line is too long to fit in the editor if typed out in full, you'll need to abbreviate some commands to fit them in to a maximum of 4 lines.
vicline.png
vicline.png (3.34 KiB) Viewed 255 times
You can use the shortcut ? for print and there are other shortcuts for most of the commands. In this case using ? instead of PRINT will suffice:
Screenshot 2025-04-27 184556.png
Screenshot 2025-04-27 184556.png (7.38 KiB) Viewed 255 times
Notice when listed out it goes over to a 5th line, should you want to edit line 1 you will need to do some careful editing, abbreviating again and completing the characters that overflowed onto line 5.
--
AndyH
HEWCO | Vic 20 blog
User avatar
TheVic20User
Vic 20 Drifter
Posts: 30
Joined: Mon Jan 13, 2025 2:22 pm
Location: Germany

Re: vic 20 listing help needed

Post by TheVic20User »

That its. The line was too long. Thank you very much! :) I'm always learning something new. I'll study and apply shortcuts.
PRESS PLAY ON TAPE
User avatar
Mike
Herr VC
Posts: 5134
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: vic 20 listing help needed

Post by Mike »

In addition to what AndyH wrote in the preceding post:
TheVic20User wrote:I got a syntax error on line 1, even though I entered everything very precisely. [...]
You cannot get ?SYNTAX errors from entered program lines with line numbers, as that error is only generated during execution.

When entering program lines in the screen editor of the VIC-20, at most 88 characters in 4 physical text lines are combined into one logical line. Upon entry (without abbreviations) or when listed, this line overflows the limit, and "EXT" stands by itself on a new logical line. Entering that is what gives you the ?SYNTAX error - there is no line number prefaced to "EXT", so the VIC-20 tries to execute it, however "EXT" is no recognized command. Furthermore, as the cursor was not within any of the 4 physical lines that constitute the logical line of the typed-in program line 1, that line is not actually entered!

Those are quite some intricacies when you work with the screen editor of the VIC-20. I would recommend you work through chapters 1 and 2 of the VIC-20 user's manual, where most of these quirks are explained (if you do not have a physical copy, here is the German version on archive.org, check out the big box "VC-20-TIP: Korrektur von Fehlern innerhalb eines Programmes" on page 8).

...

On another note, while this program looks rather simple, it has some rough edges you probably should not replicate in own code.

For example, this very line 1 uses a rather awkward method to make a double sized copy of the character set. The addressing can be made much more simpler by replacing line 1 as is:

Code: Select all

1 print"{clear}{black}wait...":cs=6144:fori=csto7678step2:z=peek(32768+(i-cs)/2):pokei,z:pokei+1,z:next
with:

Code: Select all

1 print"{clear}{black}wait...":cs=6144:fori=0to767:z=peek(32768+i):pokecs+i+i,z:pokecs+i+i+1,z:next
omitting a costly division by 2 in the address calculation. Incidentally, this also makes the line fit within the 88 character limit without abbreviations.

Furthermore, in line 2, "poke36881,24" addresses a mirror of VIC register 36865, which however has the side effect of also writing to another register in one of the VIA chips. That POKE should be "poke36865,24" instead.
User avatar
TheVic20User
Vic 20 Drifter
Posts: 30
Joined: Mon Jan 13, 2025 2:22 pm
Location: Germany

Re: vic 20 listing help needed

Post by TheVic20User »

Thank you very much. Now I understand more about what went wrong. I have the original book handy. I'll look it up again.
PRESS PLAY ON TAPE
Post Reply