9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Basic and Machine Language

Moderator: Moderators

Post Reply
aeb
Vic 20 Amateur
Posts: 68
Joined: Sat Jun 19, 2004 2:06 pm

9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by aeb »

When I got my first computer, a VIC 20, in December 1984, one of the first
BASIC commands I tried was PLOT. And was I a little disappointed when my
little friendly computer didn't recognize this command at all.

37 years later I got the idea to write a BASIC extension with block graphics
and a PLOT command and make it fit in the tape buffer area of an unexpanded
VIC 20. I had never written a BASIC extension before, so it was a fun thing
to try out. Excellent one-nighter for when I was supposed to be doing something
else :)

Yes, it did fit in the tape buffer and there's even 10 bytes free.

As a little bonus, you get an extra color too! Or two extra colors, if you also
count the light cyan background in the basic loader.

plot1.png
plot1.png (1.71 KiB) Viewed 962 times
plot2.png
plot2.png (2.21 KiB) Viewed 962 times

Usage: PLOT X,Y,C (X = 0-43, Y = 0-45, C = 0-9)

Use color 0 to unplot

Colors 1-8 are black, white, red, cyan, purple, green, blue and yellow

POKE36878,V+16*N to set color 9 (N = color 0-15, V = audio volume 0-15)

SYS832 to restart


Download:
plot.zip
(3.65 KiB) Downloaded 71 times

Code: Select all

0 fora=832to1013:readb:pokea,b:c=c+b:next:ifc<>22354thenprint"error":end
1 poke36879,187:poke36878,16*9:sys832
2 print"{clr}{blk}9-color block graphicsbasic extension"
3 print"{down}sys832 to restart"
4 print"{down}{down}{wht}usage: plot x,y,c"
5 print"{down}{blk}x=0-43, y=0-45, c=0-9"
6 print"{down}use color 0 to unplot"
7 print"{down}colors 1-8 are normal"
8 print"{down}{wht}poke36878,16*n to set color 9 (n=0-15){blk}"
100 data169,88,141,8,3,169,3,141,9,3,96,162,14,76,55,196
110 data32,253,206,32,158,215,138,96,160,4,177,122,217,241,3,240
120 data3,76,228,199,136,208,243,162,5,32,115,0,202,208,250,32
130 data117,3,76,174,199,32,83,3,201,44,176,207,162,1,74,133
140 data251,144,2,162,4,134,1,32,80,3,201,46,176,189,74,133
150 data252,144,2,6,1,10,10,10,101,252,101,252,101,252,162,30
160 data10,133,253,144,1,232,134,254,32,80,3,201,10,176,156,202
170 data134,2,164,251,162,16,189,226,3,209,253,240,3,202,208,246
180 data165,2,48,22,138,5,1,170,189,226,3,145,253,165,254,73
190 data136,133,254,165,2,48,2,145,253,96,134,252,69,1,37,252
200 data16,229,32,126,123,97,124,226,255,236,108,127,98,252,225,251
210 data254,160,80,76,79,84
User avatar
tokra
Vic 20 Scientist
Posts: 1123
Joined: Tue Apr 27, 2010 5:32 pm
Location: Scheessel, Germany

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by tokra »

Hey, that's a neat trick using multicolor-mode for the 9th color and exploiting the fact that the block-pixels are using the right bits to use this color!

I was using a similar trick in my ColorRun to have both orange and brown on the screen at the same time.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by chysn »

This is pretty cool!
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
crusti
Vic 20 Drifter
Posts: 27
Joined: Sat Nov 28, 2020 5:22 am
Location: Southampton UK

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by crusti »

Oh, this is very likeable.
I imagine this could produce some wonderful and fast low res games.

Thanks again chysn, often your programs take me down worm holes.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by chysn »

crusti wrote: Fri Jan 14, 2022 1:59 pm Thanks again chysn, often your programs take me down worm holes.
This one's aeb's wormhole :)
crusti
Vic 20 Drifter
Posts: 27
Joined: Sat Nov 28, 2020 5:22 am
Location: Southampton UK

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by crusti »

oh lol, i should learn to read rather than skim.
great little proggy AEB
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by Mike »

This is not the first implementation of chunky pixels that found its way to Denial, see here: viewtopic.php?t=5505.

The presentation of the "9-color feature" in the second screenshot (by means of a colourful sine-curve) is somewhat misleading: the pixels are necessarily colourized with the colour RAM, which means every 2 by 2 block of those pixels will share one colour - and the example just places them enough apart so the colour clash does not become visible for the most part. ;)

There's also prior art for the use of the auxiliary colour in block graphics. Jeff does this with flag colours in "FIFA World Cup 2014". He 'presets' address 646 with 8 which switches on multi-colour mode and a 'neutral' control code (IIRC, he uses {F1} for this) then selects orange for an inverted space, otherwise he uses a standard colour code.

What remains is the feat of a first self-written BASIC extension, which is fair enough. There's still room for improvement though: the PLOT keyword is not tokenized and will take up 4 bytes in the program text.
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by AndyH »

This is really cool and I also like that trick to get a ninth colour :)

I've done something similar with these blocks and I don't think I've ever mentioned it here.

When I got my PET Mini from TFW8B last year I started playing with graphics on that using the PETSCII characterset. In particular I figured you could do something with those 2x2 block patterns. My tool of choice is Turbo Rascal which I had added a commandset for a bitmap mode on the Vic 20 using the well known double height character mode and I wondered if I could do the same but with these blocks. On a 40 column PET that would give a resolution of 80 x 50 block pixels.

So I created a PETSCII block bitmap and some simple commands to draw to it, including sprites. I also created an exporter to extract bitmap graphic data from the TRSE character editor to a number of prepared binary formats suitable for my library (uncompressed and byte compressed). Here's the result on the PET:

Image

I set it up to work with the Vic 20 and C64 with minor changes. For the Vic I added a virtual screen with some horizontal scrolling to allow the same blockmap of 80 to be displayed part at a time. It is able to draw at a pretty fast framerate and there are some simple tricks for drawing a sprite flipped to face the other direction with only a small speed penalty.

Image

The C64 version was simpler to get going as it shared the same character resolution. Both the Vic and C64 can have colour, although as Mike points out this is restricted to the standard colour memory and colours each character cell affecting all four blocks (2x2) at a particular position.

Image

I'd given myself too much to do last year, and with real life, I didn't get around to annoucing it. The code and an example is availble in the Turbo Rascal nightly build version. I'll be adding more examples, including how to do a tileset and map as can be seen in the above GIFs.
--
AndyH
HEWCO | Vic 20 blog
User avatar
mathom
Vic 20 Dabbler
Posts: 80
Joined: Wed Aug 07, 2019 11:37 am
Location: Centennial, Colorado
Occupation: Software Engineer

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by mathom »

This is some really neat stuff. I think I will make a late New Years resolution to finally wrap my head around TRSE.
...mathom...
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: 9-color Block Graphics BASIC Extension for Unexpanded VIC 20

Post by wimoos »

WimBasic is still at your disposal. Next to SET, RESET and POINT it already supported, I have also added TOGGLE.

For the use of the '9-th color' there is the command AUXCOL to set this color in 36878. The CURSOR command sets the color in 646.

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Post Reply