Page 1 of 1

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

Posted: Sat Apr 01, 2017 1:03 am
by Mike
Hi, y'all!

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

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

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

Posted: Sun Apr 02, 2017 4:35 pm
by GreyGhost
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.

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

Posted: Sun Apr 02, 2017 6:50 pm
by Bobbi
I am 3096 bytes short!! Damn!

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

Posted: Mon Apr 03, 2017 3:14 am
by orion70
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.

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

Posted: Fri Aug 25, 2017 2:02 pm
by Mike
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 (download) ... :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' 1302 combinations.

Cheers,

Michael

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

Posted: Fri Aug 25, 2017 2:28 pm
by tokra
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

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

Posted: Sat Aug 26, 2017 2:51 am
by Mike
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 ...

Image

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

Image

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

Image

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

Image

I've put "inkling.fcb" (for fcbpaint) and "inkling.prg" (for MINIPAINT) here for download. "inkling.prg" was saved straight as scrapfile from the CGA panning viewer, and in turn converted to "inkling.fcb" with MG2FCB.

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

Posted: Sat Nov 25, 2017 6:13 am
by Mike
Mike wrote:[...] a converter from 4 colour *.ppm files is in the works.
Here we go (download):

When you double-click 'ppm2cga.cmd', the *.exe will quantize the file 'input.ppm' (strictly 320x200 pixels and a 24 bpp *.ppm file) and write the files 'result.ppm' (preview on PC) and 'result.seq' (for use by the panning viewer in the OP). If you change the filenames in the command line, neither the input file nor the preview file (1st and 2nd parameters) include the *.ppm extension - this is added internally!

The bundled executable requires a 64 bit Windows. Source is included for those who want to have some insight and/or want to compile the *.exe for themselves. The converter should compile on pretty much everything that has a C compiler. :)

Cheers,

Michael

P.S. if you want to use another permutation of the physical to logical colour mapping for SCRAPFILE pictures saved from the CGA panning viewer, take a look at the REMAP tool set in the MG batch suite.

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

Posted: Tue Feb 26, 2019 6:17 am
by mamejay
Hi Mike,
I have built Ruud's 35k RAM expansion and have been doing some testing.
I can't seem to get the 320x200 to work. I have run your memory test program and the initial tests with all banks on is showing ram in all locations.

Should your program work with Ruud's memory expansion? http://www.baltissen.org/newhtm/memv20.htm

I am loading it from a SD2IEC

(mod: link fixed)

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

Posted: Tue Feb 26, 2019 2:15 pm
by Mike
A more detailed problem description would be helpful.
mamejay wrote:Should your program work with Ruud's memory expansion?
Yes. *Any* RAM expansion that provides +35K as per the description in the OP will work.
I am loading it from a SD2IEC
So do I, but the exact type of drive really doesn't matter. The program will also work, if you transfer the *.zip file's content onto a real disk and run it from a disk drive (in that case, be sure the picture files are saved with a SEQ file type).
I can't seem to get the 320x200 to work.
If you proceed like given in the OP, at which point does the output of the program differ from expected behaviour?

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

Posted: Tue Feb 26, 2019 4:24 pm
by mamejay
Hi Mike,

Basically I run your program and select the image file. After sometime I am throw back out to basic with a flashing cursor.
At the moment I have all dip switches enabled except for the write-protect switch.
I tested your program in VICE and all is working as expected.
I will give it another go tonight after work. I will also run your memory test program completely and see if any errors occur.

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

Posted: Wed Feb 27, 2019 12:42 am
by mamejay
Hi Mike,
OK did more tests. Thanks for the heads up about naming the files correctly. I created a D64 image that did not have SEQ extension.
I just moved the files to a folder and not in a D64 image and it loaded perfectly VIA the SD2IEC.

Excellent my ram expansion is working.
Thanks for the great test.