320x200 - a CGA emulator for VIC-20! (+35K RAM req'd)

Basic and Machine Language

Moderator: Moderators

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

320x200 - a CGA emulator for VIC-20! (+35K RAM req'd)

Postby Mike » Sat Apr 01, 2017 1:03 am

Hi, y'all!

Here's a program to display a bitmap of 320x200 pixels in 4 colours on the VIC-20: :mrgreen:

320x200.zip
(10.93 KiB) Downloaded 48 times

Code: Select all

10 AD=PEEK(55)+256*PEEK(56):IFAD<>12376THENPOKE55,88:POKE56,48:CLR
11 IFAD=0THENFORT=12376TO12700:READA:POKET,A:NEXT:SYS12376:AD=12376
12 DN=PEEK(186):INPUT"FILE";N$:OPEN2,DN,2,N$+",S,R":GET#2,A$,B$:CLOSE2
13 A=ASC(A$+CHR$(.)):SYS57809N$+",S",DN,0:POKE780,0:POKE781,88:POKE782,48:SYS65493
14 POKE646,AAND15:POKE36878,AAND240:POKE36879,ASC(B$+CHR$(.)):@ON:@CLR:X=0:Y=0:P=-1
15 IFPTHENP=0:POKE251,ADAND255:POKE252,AD/256:SYS1024
16 GETA$:IFA$=""THEN16
17 IFA$="{LEFT}"ANDX>0THENX=X-1:AD=AD-200:P=-1
18 IFA$="{RIGHT}"ANDX<60THENX=X+1:AD=AD+200:P=-1
19 IFA$="{UP}"ANDY>0THENY=Y-1:AD=AD-4:P=-1
20 IFA$="{DOWN}"ANDY<34THENY=Y+1:AD=AD+4:P=-1
21 IFA$="S"THENOPEN15,DN,15,"S0:SCRAPFILE":CLOSE15:@SAVE"SCRAPFILE",DN
22 IFA$=" "THEN:@RETURN:END
23 GOTO15
24 :
25 DATA 169,0,141,146,49,133,251,169,64,141,147,49,169,17,133,252,162,20,169,160,32,145
26 DATA 49,169,0,32,145,49,160,64,169,177,32,145,49,169,251,32,145,49,169,200,32,145,49
27 DATA 169,141,32,145,49,165,251,32,145,49,165,252,32,145,49,32,138,49,169,141,32,145
28 DATA 49,165,251,32,145,49,165,252,32,145,49,32,138,49,169,141,32,145,49,165,251,32
29 DATA 145,49,165,252,32,145,49,32,138,49,136,208,184,169,24,32,145,49,169,165,32,145
30 DATA 49,169,251,32,145,49,169,105,32,145,49,169,200,32,145,49,169,133,32,145,49,169
31 DATA 251,32,145,49,169,165,32,145,49,169,252,32,145,49,169,105,32,145,49,169,0,32
32 DATA 145,49,169,133,32,145,49,169,252,32,145,49,202,240,3,76,106,48,169,0,133,251
33 DATA 169,64,133,252,169,0,133,253,169,4,133,254,162,252,160,15,32,110,49,169,76,141
34 DATA 252,15,169,216,141,253,15,169,110,141,254,15,169,33,133,251,169,93,133,252,169
35 DATA 0,133,253,169,160,133,254,162,254,160,191,32,110,49,169,96,141,254,191,169,252
36 DATA 133,251,169,75,133,252,169,216,133,253,169,110,133,254,162,253,160,127,32,110
37 DATA 49,169,76,141,253,127,169,0,141,254,127,169,160,141,255,127,96,152,72,160,0,177
38 DATA 251,32,138,49,145,253,230,253,208,2,230,254,104,168,228,253,208,233,196,254,208
39 DATA 229,96,230,251,208,2,230,252,96,141,255,255,238,146,49,208,3,238,147,49,96
40 :
41 REM ** CGA PAN VIEWER WRITTEN 2016-11-16 BY MICHAEL KIRCHER

The program was inspired by a posting of mine in the "MINIPAINT 1.2" thread. I pondered for myself for some days how much it would take to get that picture there on display on the VIC-20.

+35K RAM are required: yes, that means +24K in BLK1..3, +8K in BLK5 *and* +3K in RAM1..3! Decompress the *.zip archive and run the file "BOOT". The program lets you pan a view into the whole picture with the cursor keys. The display is zoomed, so the pixels do have a square aspect ratio (about perfect for NTSC, only slightly elongated for PAL). With "S", the current view is saved as MINIGRAFIK/MINIPAINT picture file. SPACE returns you to BASIC.

I have included two example pictures, PCPAINT1 and CECILE. Just enter their name in the "FILE?" prompt. These files are 16002 bytes in size, the first 2 bytes hold palette information, the following 16000 bytes contain the bitmap in column-major order. The payload then is loaded to address $3058 in RAM.

This is still a work in progress, and a converter from 4 colour *.ppm files is in the works.

Enjoy!

Michael

User avatar
GreyGhost
Vic 20 Nerd
Posts: 515
Joined: Wed Oct 05, 2005 11:10 pm

Re: 320x200 - a CGA emulator for VIC-20! (+35K RAM req'd)

Postby GreyGhost » Sun Apr 02, 2017 4:35 pm

This is pretty neat. I was expecting the usual April Fools gag. lol. The scrolling is very fast. I look forward to seeing what becomes of this.
Rob

Bobbi
Vic 20 Afficionado
Posts: 347
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: 320x200 - a CGA emulator for VIC-20! (+35K RAM req'd)

Postby Bobbi » Sun Apr 02, 2017 6:50 pm

I am 3096 bytes short!! Damn!

User avatar
orion70
Meteo VIC
Posts: 3288
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: 320x200 - a CGA emulator for VIC-20! (+35K RAM req'd)

Postby orion70 » Mon Apr 03, 2017 3:14 am

Wow! I just ignored your post in the first place, given the peculiar date of publication :).
Thanks for that. Can't wait for the ppm converter, so that I can play with some "classic" CGA screenshots.

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

Re: 320x200 - a CGA emulator for VIC-20! (+35K RAM req'd)

Postby Mike » Fri Aug 25, 2017 2:02 pm

Mike wrote:This is still a work in progress, and a converter from 4 colour *.ppm files is in the works.

Found time this evening to give it a try. Here's a new example picture:

splatoon.zip
(10.03 KiB) Downloaded 15 times

:mrgreen:

The converter takes a full-colour 320x200 *.ppm file and does a full optimization for the best 4 colour palette out of the 16 available colours. That's a search space of 'just' 2548 combinations.

Cheers,

Michael

User avatar
tokra
Vic 20 Nerd
Posts: 814
Joined: Tue Apr 27, 2010 5:32 pm
Location: Germany

Re: 320x200 - a CGA emulator for VIC-20! (+35K RAM req'd)

Postby tokra » Fri Aug 25, 2017 2:28 pm

Neat! This would have been a good starting point for my "VIC Hunt"-picture which uses exactly the same "pixel"-size (2 wide, 3 high) :D

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

Re: 320x200 - a CGA emulator for VIC-20! (+35K RAM req'd)

Postby Mike » Sat Aug 26, 2017 2:51 am

tokra wrote:This would have been a good starting point for my "VIC Hunt"-picture [...]

Though it becomes quite cumbersome and confusing to edit the picture in the zoomed view of both fcbpaint and MINIPAINT. Starting from this converted picture ...

01_splatoon.png
01_splatoon.png (22.23 KiB) Viewed 318 times

... you'll only ever get to see (and save as scrapfile) a view like this ...

02_inkling.png
02_inkling.png (57.29 KiB) Viewed 318 times

... which will look like this when edited in MINIPAINT (it's the right eye of the inkling girl), ...

03_minipaint.png
03_minipaint.png (14.54 KiB) Viewed 318 times

... or like this in fcbpaint (just the eye's pupil). :shock:

04_fcbpaint.png
04_fcbpaint.png (12.64 KiB) Viewed 318 times

I've put "inkling.fcb" (for fcbpaint) and "inkling.prg" (for MINIPAINT) into the attachment below. "inkling.prg" was saved straight as scrapfile from the CGA panning viewer, and in turn converted to "inkling.fcb" with MG2FCB.
Attachments
inkling.zip
(4.16 KiB) Downloaded 11 times


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest