Looking for PRG-files from Compute's programming the VIC

History and Preservation Issues

Moderator: Moderators

User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Looking for PRG-files from Compute's programming the VIC

Post by Witzo »

I've typed in Program 12-39 on page 423 of Compute's programming the VIC. As in old times with type ins, it does not run as expected. Maybe I should have tried typing in the list of data-statements of the proofreader first.

Are the programs from this book available somewhere?
I vaguely remember someone building a collection of typed-in programs.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Looking for PRG-files from Compute's programming the VIC

Post by Mike »

Witzo wrote:I vaguely remember someone building a collection of typed-in programs.
tokra did a run for games from German computer magazines, orion70 and some other Denial fellows for Italian magazines. For the moment, I don't know about a specific collection for the book in charge here, 'Compute's Programming the VIC'. I'll have a go at the listing 12-39 in the next days.

You should be aware though, that all that program can do is equally well performed by MINIPAINT. :mrgreen:
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Re: Looking for PRG-files from Compute's programming the VIC

Post by Schlowski »

BasEdit has built-in proofreader functionality for old ('83) and new ('86) compute proofreader algorithms :-)
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Re: Looking for PRG-files from Compute's programming the VIC

Post by Witzo »

Mike wrote:
Witzo wrote:I vaguely remember someone building a collection of typed-in programs.
tokra did a run for games from German computer magazines, orion70 and some other Denial fellows for Italian magazines. For the moment, I don't know about a specific collection for the book in charge here, 'Compute's Programming the VIC'. I'll have a go at the listing 12-39 in the next days.

You should be aware though, that all that program can do is equally well performed by MINIPAINT. :mrgreen:
Thanks! The program showed me a dark rectangle at the top of the screen and background colour for the rest.
I went with the old type-from-book way in this case because I wanted to find out how the graphics screen is set up and pixels painted in the right places. Typing a program forces me to read each step and helps me find the relevant actions in context.
I am well aware of Minipaint, it can do much more and probably better than this type-in, and intend to use it once I go into actual drawing of graphics.
Schlowski wrote:BasEdit has built-in proofreader functionality for old ('83) and new ('86) compute proofreader algorithms :-)
Thanks, I'll look up that functionality.
By the way, it took me a while to figure out the the '=' symbol is mapped to shift-0, and there are some other keyboard peculiarities. Is this because I'm using Basedit in Wine on Ubuntu? Or because I have my Ubuntu keymap to US? Would a German keymap work better?
User avatar
vicist
Vic 20 Afficionado
Posts: 352
Joined: Tue Oct 09, 2012 5:26 am
Location: Sheffield, UK

Re: Looking for PRG-files from Compute's programming the VIC

Post by vicist »

Witzo wrote:
I vaguely remember someone building a collection of typed-in programs.
You may mean these listings.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Looking for PRG-files from Compute's programming the VIC

Post by Mike »

Witzo wrote:I went with the old type-from-book way in this case because I wanted to find out how the graphics screen is set up and pixels painted in the right places. Typing a program forces me to read each step and helps me find the relevant actions in context.
Still, that type-in only shows a particular and not especially efficient way to do bitmap graphics on the VIC-20.

For example, the program employs handbrakes by evaluating the bit-position value of the pixels with "2^". That method is *extremely* slow and one should use a table instead. Likewise, the address function of the bitmap is made overly complicated by arranging the characters row-wise instead of column-wise.

All the necessary optimizations and the still necessary calculations found their way into BASIC extensions like MINIGRAFIK already a long time ago, so you can do hires graphics on the VIC-20 without the necessity to wrap your head around the details. The whole program 12-39 collapses into less than 10 lines of BASIC and also will be noticably faster when I use MG to (re-)implement it.
I am well aware of Minipaint, it can do much more and probably better than this type-in, and intend to use it once I go into actual drawing of graphics.
In its heart, MP is probably "just" a super-beefed up cousin of that program - but MP includes a lot of functions you just couldn't leave out for a seriously meant bitmap editor, like the ability to save and reload the works. Also, MP allows access to all degrees of freedom the bitmap mode allows, like mixed hires/multi-colour and foreground colour per attribute cell. Of course, the three global colours (background, exterior border and auxiliary colour) needn't be fixed at the program start like with 12-39, but can be changed at any time within MP. etc. ... pp.

So you can surely leave out the word "probably" in your statement and couldn't be more right. :mrgreen:
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Re: Looking for PRG-files from Compute's programming the VIC

Post by Witzo »

You've convinced me; in stead of picking a part a small demo program from an old book I'll be better off using Minigrafik for editing and its associated tools for displaying. I'll look into how to use them in combination with my own coding experiments.
vicist wrote:
Witzo wrote:
I vaguely remember someone building a collection of typed-in programs.
You may mean these listings.
That looks like it, yes! But there's only two programs related to the book http://www.vic20listings.freeolamail.co ... tml#8503pv .
User avatar
Floopy
Vic 20 Devotee
Posts: 221
Joined: Mon Feb 27, 2017 7:38 pm
Location: US

Re: Looking for PRG-files from Compute's programming the VIC

Post by Floopy »

I typed in a short program once from a Compute! magazine..... It took FOREVER :shock:. Now if I want a program I usually find it on line.
-Floopy
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Re: Looking for PRG-files from Compute's programming the VIC

Post by Schlowski »

By the way, it took me a while to figure out the the '=' symbol is mapped to shift-0, and there are some other keyboard peculiarities. Is this because I'm using Basedit in Wine on Ubuntu? Or because I have my Ubuntu keymap to US? Would a German keymap work better?
The default keyboard mapping is german in BasEdit.ini:

Code: Select all

' Mapping file for keystrokes
' KeyMap=KeyMap_German.txt
you can change this to english keyboard mapping

Code: Select all

' Mapping file for keystrokes
' KeyMap=KeyMap_English_ccs64.txt
or edit the KeyMap-File yourself for other languages.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Looking for PRG-files from Compute's programming the VIC

Post by Mike »

Mike wrote:I'll have a go at the listing 12-39 in the next days.
For completeness, here we go (download):

Code: Select all

20 PRINT "BACKGROUND?";: GOSUB 50000: BA=G-1
22 PRINT "{4 SPACE}BORDER?";: GOSUB 50000: BO=G-1
24 PRINT " AUXILIARY?";: GOSUB 50000: AU=G-1
26 PRINT " CHARACTER?";: GOSUB 50000: CE=G-1
30 POKE 36879,8+BO+16*BA: REM SET BORDER, BACKGND
32 POKE 36878,16*AU: REM AUXILIARY COLOR
34 POKE 36869,204: POKE 648,16: REM SCREEN & CHARS AT $1000
36 POKE 36866,20: REM 20 COLUMNS
38 POKE 36867,25: REM 12 DOUBLE-SIZE ROWS
40 FOR J=320 TO 343: READ G:POKE J,G: NEXT:SYS 320
42 FOR J=0 TO 239:POKE 4096+J,J+16: REM SCREEN CHARS 16 & UP
44 POKE 37888+J,CE+8: REM DEFAULT CELL COLOR
46 NEXT
100 GET G$: G=ASC(G$+CHR$(0))
200 IF G>48 AND G<57 THEN G=G-49: GOSUB 40000: GOTO 500
210 IF G>32 AND G<41 THEN G=G-25: GOSUB 40000: GOTO 500
220 IF G$=" " THEN MOVE = 1-MOVE:REM SPACE TOGGLES PLOT ON/OFF
230 IF G$="{RIGHT}" THEN X=X+2: IF X>158 THEN X=158: REM RIGHT
240 IF G$="{LEFT}" THEN X=X-2: IF X<0 THEN X=0: REM LEFT
250 IF G$="{UP}" THEN Y=Y-1: IF Y<0 THEN Y=0: REM UP
260 IF G$="{DOWN}" THEN Y=Y+1: IF Y>191 THEN Y=191: REM DOWN
500 SCREENCHR = 20*INT(Y/16) + INT(X/8)
510 ROW = Y AND 15: BIT=6-(X AND 7)
520 CHAR=4352 + 16 * SCR + ROW: PE=PEEK(CH)
530 POKE CH,(PE AND (255-3*2^BIT)) AND NOT B*2^BIT: REM FLASH...
540 POKE CH,(PE AND (255-3*2^BIT)) OR B*2^BIT: REM AND PLOT
550 IF MOVE=1 THEN POKE CH,PE: REM REPLACE UNCHANGED
560 GOTO 100
1000 DATA 169,16,170,133,252,169,0,168,133: REM CLEAR CHAR DEFNS
1010 DATA 251,145,251,153,0,148,200,208
1020 DATA 248,230,252,202,208,243,96
40000 IF G=BACKGD THEN B=0: RETURN: REM SEARCH FOR COLOR
40010 IF G=BODER THEN B=1: RETURN
40020 IF G=CELL THEN B=2: RETURN
40030 IF G=AUX THEN B=3: RETURN
40040 CE=(G AND 7) + 8: B=2: REM NEW DEFAULT COLOR
40050 POKE 37888+20*INT(Y/16)+INT(X/8),CE: REM PUT INTO COLOR RAM
40060 RETURN
50000 GET G$:IF G$="" GOTO 50000: REM CONVERT COLOR KEY
50005 G=VAL(G$)
50010 IF G=0 THEN G=ASC(G$)-24
50015 PRINTG:RETURN
As given in the book, the original listing contains two errors and two misfeatures:

- In line 230, the range for X should be limited by 158, not 159 (has been corrected). Otherwise, as soon as the cursor is tried to move outside the right border, the bit patterns in line 510..530 are wrongly calculated. These formulae expect even X-coordinates.

- much more severe: the last number 33 in the DATA line 1000 should be 133 instead. This typo doesn't directly kill the machine code, as the ZP-address 251 contains a 0 after reset, but needn't so anymore after it has been used be another program. Also corrected.

- if the foreground colour is changed by selecting an "unknown" colour, only the current attribute cell is affected.

- using any other keys than given in the manual can make the program stop with an ?ILLEGAL QUANTITY error.

...

For use with a +3K RAM expansion, use "boot3k.prg"; with +8K or more, use "boot8k.prg".

The version with MINIGRAFIK will follow shortly.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Looking for PRG-files from Compute's programming the VIC

Post by Mike »

Mike wrote:The whole program 12-39 collapses into less than 10 lines of BASIC and also will be noticably faster when I use MG to (re-)implement it.
Here's the result (download):

Code: Select all

1 PRINT"GROUND,FORE,BORDER,AUX":INPUTG,F,B,A
2 POKE36878,16*A:POKE36879,16*G+8+B:POKE646,8+F:@ON:@CLR:S=1
3 GETA$:X=X+2*(A$="{LEFT}"ANDX>0)-2*(A$="{RIGHT}"ANDX<158)
4 Y=Y+(A$="{UP}"ANDY>0)-(A$="{DOWN}"ANDY<191):R=@(X,Y):@3-R,X,Y
5 IFA$>="1"ANDA$<="4"THENS=VAL(A$)-1
6 IFA$=" "THENP=NOTP
7 @R,X,Y:IFPTHEN:@S,X,Y
8 GOTO3
The controls are somewhat different from 12-39: instead of entering the colour key and the program calculating the colour source from that, the colour source is directly selected with 1..4; the change of the foreground colour from an "unknown" colour is not implemented. At program start, the palette is specified by a comma separated list of physical colours. *) Like in 12-39, SPACE acts as pen up/down. **)

I've put upaint into a *.d64 with a boot program, MINIGRAFIK and the main program itself. You'll need at least a +8K RAM expansion.

Cheers,

Michael


*) e.g. 1,6,3,0 for white background, blue foreground, cyan border and black auxiliary colour

**) For a comparison - in MINIPAINT, the drawing mode in charge here is selected by pressing M ("multi-colour") and f5 ("set, don't advance") beforehand, and then the left arrow key acts as pen up/down. The pixels are set with 1..4 as well, cursor movements with pen down draw a continuous line. The palette is changed with Ctrl-1..4 (and 2, the foreground colour, is local to each attribute cell).
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Re: Looking for PRG-files from Compute's programming the VIC

Post by Witzo »

Schlowski wrote:
By the way, it took me a while to figure out the the '=' symbol is mapped to shift-0, and there are some other keyboard peculiarities. Is this because I'm using Basedit in Wine on Ubuntu? Or because I have my Ubuntu keymap to US? Would a German keymap work better?
The default keyboard mapping is german in BasEdit.ini:

Code: Select all

' Mapping file for keystrokes
' KeyMap=KeyMap_German.txt
you can change this to english keyboard mapping

Code: Select all

' Mapping file for keystrokes
' KeyMap=KeyMap_English_ccs64.txt
or edit the KeyMap-File yourself for other languages.
I get no change in the behaviour, '=' is mapped to shift-0 in both settings in BasEdit.ini.

Looking at the keymap, it's remarkable that the default German puts = on shift-0, since it's defined as this:
48, 1= "="

While the English keymap has three entries for =, under ' second row characters, ' second row - characters and another ' second row - characters:
220, 0= "=" ' windows '\' maps to c64 '='

Where are the cursor keys mapped? Not on the cursor keys.
But maybe it's all my Ubuntu/Wine setup messing it up.
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Re: Looking for PRG-files from Compute's programming the VIC

Post by Witzo »

Mike wrote:
Mike wrote:I'll have a go at the listing 12-39 in the next days.
For completeness, here we go:
I'll study all this, thanks Mike!
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Re: Looking for PRG-files from Compute's programming the VIC

Post by Schlowski »

Mmh, really strange with the cursor keys. But I can confirm the "= is on shift-0" behaviour in both mappings.
The english key mapping is not from me, someone (sorry, can't remember who) made it and send it to me for inclusion in the final version. It seems as if there was some misunderstanding, the mapping is definately for a german keyboard (easily confirmed with Y and Z) but maps some keys differently from my german mapping to get closer to the ccs64 mapping.

To make a long story short: there is no english mapping :(

PS: The cursor keys (which are mapped 1:1) and all other keys I tested work in both mappings - so maybe it's really a matter of Wine/Ubuntu.
User avatar
mathom
Vic 20 Dabbler
Posts: 79
Joined: Wed Aug 07, 2019 11:37 am
Location: Centennial, Colorado
Occupation: Software Engineer

Programs from “Programming the VIC” Raeto Collin West

Post by mathom »

Does anyone know if there exists a collection of the programs/examples from “Programming the VIC” in electronic form? I don’t mind at all typing in programs where you are actually seeing the code that will be executed, but typing in ML loaders is no fun and not all that instructive.

...mathom...
...mathom...
Post Reply