MINIGRAFIK batch processing suite

Basic and Machine Language

Moderator: Moderators

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

Post by Mike »

Here we have a viewer for MG pictures, that runs on an unexpanded VIC-20! (download)

Code: Select all

10 FORT=320TO450:READA:POKET,A:NEXT:SYS320
11 :
12 DATA 169,1,166,186,160,0,32,186,255,162,6,189,188,1,32,210,255,202,208,247,134,88,32
13 DATA 207,255,157,0,2,232,201,13,208,245,202,138,162,0,160,2,32,189,255,169,0,162,1
14 DATA 160,16,32,213,255,162,16,134,90,142,174,31,142,180,31,162,31,134,89,142,160,31
15 DATA 142,224,31,202,134,91,162,96,142,184,31,142,242,31,32,152,31,32,218,31,162,15
16 DATA 160,255,32,232,195,24,169,16,168,153,240,15,105,12,144,2,233,239,200,208,244,32
17 DATA 228,255,240,251,169,0,141,0,16,32,68,198,0,32,63,69,76,73,70
18 :
19 REM ** VIEW3K WRITTEN 2013-04-28 BY MICHAEL KIRCHER
The *.d64 image in the archive contains some sample images, just enter their name at the 'FILE?' prompt. Here's one of them:

Image

The display routine of the viewer resides in the stack area. Once the viewer has been exited by pressing a key, it can be restarted with SYS320 to load another picture.

Of course, all the example pictures also still load fine into MINIGRAFIK and MINIPAINT. :)

Cheers,

Michael
Last edited by Mike on Thu Feb 20, 2014 4:31 pm, edited 1 time in total.
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Post by orion70 »

Another hit Mike--- you should build a time machine and go back to 1981, showing all your applications... (then, the C64 never appeared, and new VICs with more RAM and improved video chips lasted well into the Nineties... )
Last edited by orion70 on Mon Apr 29, 2013 6:40 am, edited 1 time in total.
User avatar
Mike
Herr VC
Posts: 4840
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

C64? What C64?

;)
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

I wonder if given an unlimited size drive of some sort what sort of video you could get out of the vic20. Obviously it would be RAW, but what is the best resolution you could come up with? Or even with 24k of ram, maybe a looping animation.
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Post by orion70 »

Didn't write anything about a thing called "the C64", whatever you mean with this term.. Sorry, now I must go working on my VIC2013 :)
User avatar
darkatx
Vic 20 Afficionado
Posts: 471
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Post by darkatx »

Just awesome! :)
Learning all the time... :)
User avatar
Mike
Herr VC
Posts: 4840
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

matsondawson wrote:I wonder if given an unlimited size drive of some sort what sort of video you could get out of the vic20. Obviously it would be RAW, but what is the best resolution you could come up with? Or even with 24k of ram, maybe a looping animation.
Feel free to try it out. I don't own a monopoly on graphics oriented programs for the VIC-20.
User avatar
Mike
Herr VC
Posts: 4840
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Today I ported a display hack over to the VIC-20, which I had originally programmed on the C128 some 25 years ago. Its name, 'Munching Squares', is an hommage to a similar program which saw the light of day on the PDP-10 as early as 1962!

Here's the BASIC source. The *.d64 file (download) features a boot loader and a copy of MINIGRAFIK, so it easily autostarts in VICE:

Code: Select all

1 POKE55,43:POKE56,60:CLR:FORT=0TO17:READA:POKE16366+T,A:NEXT:POKE15403,169:POKE15404,0
2 POKE15405,170:AD=15406:FORX=0TO19:FORY=0TO7:P=4352+192*X+Y:H=INT(P/256):L=P-256*H
3 POKEAD,93:POKEAD+1,L:POKEAD+2,H:POKEAD+3,157:POKEAD+4,L:POKEAD+5,H:AD=AD+6:NEXT:NEXT
4 POKE36879,8:POKE646,1:@ON:@CLR:@1,0,0TO159,159:@1,159,0TO0,159:SYS15403:DATA 232,232
5 DATA 232,232,232,232,232,232,224,192,240,3,76,46,60,76,43,60
When the program is started, it first writes a ML program to memory. That takes a few seconds. It then draws a simple geometric figure on screen, which then is animated with the ML code.

The screenshot below really doesn't do the effect justice. The animation runs at ~30 frames/sec.!

Image

Cheers,

Michael
Last edited by Mike on Thu Feb 20, 2014 4:31 pm, edited 1 time in total.
User avatar
Mike
Herr VC
Posts: 4840
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Another one for a rainy Sunday - the rendition of a broken Penrose tribar with MINIGRAFIK: (download)

Image

Here's the listing. The assignment 'A=5/3' in line 11 refers to PAL, NTSC users should replace it with 'A=3/2' to compensate for the different pixel aspect ratio:

Code: Select all

10 DIMX(11),Y(11),L(12,1)
11 A=5/3:INPUT"ANGLE";P0:P0={PI}*P0/180
12 FORT=0TO11:READX(T),Y:Y(T)=SQR(3)*Y:NEXT
13 FORT=0TO12:READL(T,0),L(T,1):NEXT
14 POKE36879,110:POKE646,1:@ON:@CLR
15 P=P0:GOSUB18:P=P0+2*{PI}/3:GOSUB18:P=P0-2*{PI}/3:GOSUB18
16 FORQ=-1TO0:GETA$:Q=A$="":NEXT:@RETURN:END
17 :
18 C=COS(P):S=SIN(P):FORT=0TO12
19 L=L(T,0):GOSUB23:X1=X2:Y1=Y2
20 L=L(T,1):GOSUB23:@1,X1,Y1TOX2,Y2
21 NEXT:RETURN
22 :
23 X2=6*(C*X(L)-S*Y(L))/A+80.5:Y2=96.5-6*(S*X(L)+C*Y(L)):RETURN
24 :
25 DATA 1,-1,3,-3,13,-3,8,2,4,2,7,-1,1,-5,11,-5,2,0,3,-1,0,-2,0,-4
26 DATA 0,1,1,2,2,3,3,4,4,5,5,0,1,6,6,7,7,2,4,8,8,9,0,10,6,11
27 :
28 REM ** TRIBAR WRITTEN 2013-05-12 BY MICHAEL KIRCHER
User avatar
Mike
Herr VC
Posts: 4840
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: MINIGRAFIK batch processing suite

Post by Mike »

Another one after quite a long time! :)

Sometimes it is necessary to use non-uniform distributed random numbers. One particular case are Gauss-distributed random numbers, i.e. when 'collected', they form the well-known bell curve.

A fairly known trick to produce these is to add up 12 random numbers with uniform distribution between 0 and 1, and subtract 6. This gives random numbers with a mean of 0 and a standard deviation of 1, and whose distribution for all practical purposes is indistinguishable from Gaussian randoms.

Well, let's see how this works out in MINIGRAFIK. ;)

The formula to stretch the range of z = -6 .. +6 to the x-coordinates 0.5 .. 159.5 (+.5 to account for the rounding into 160 'classes') would be X=159*(Z+6)/12+.5, the program below (download) omits the subtraction of 6 in the RNG-formula just to add it again for the scaling:

Code: Select all

1 Q=RND(-TI):CLR:DIMY(159):FORX=0TO159:Y(X)=192:NEXT:@ON:@CLR
2 Z=RND(1)+RND(1)+RND(1)+RND(1)+RND(1)+RND(1)+RND(1)+RND(1)+RND(1)+RND(1)+RND(1)+RND(1)
3 X=159*Z/12+.5:IFY(X)>0THENY(X)=Y(X)-1:@1,X,Y(X):GOTO2
4 GETA$:IFA$=""THEN4
5 @RETURN
As the program runs, one can see how the bell curve builds up. The 'noisy' shape is quite expected, as it takes much more drawn Gaussians to even it out.

Image
Last edited by Mike on Sat Jul 25, 2015 1:26 am, edited 8 times in total.
User avatar
darkatx
Vic 20 Afficionado
Posts: 471
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Re: MINIGRAFIK batch processing suite

Post by darkatx »

That was fascinating and pretty quick too! Amazing seeing the Bell curve emerge out of twelve random numbers on such a tiny screen resolution!
Learning all the time... :)
User avatar
Mike
Herr VC
Posts: 4840
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: MINIGRAFIK batch processing suite

Post by Mike »

These days I had some fun porting a nice demonstration graphic from a C16/C116/+4 BASIC tutorial over to MINIGRAFIK (download). :mrgreen:

Code: Select all

10 GOTO28
11 :
12 X=0:Y=B:S=B*B:T=A*A*(2*Y-1):U=2*B*B:V=2*A*A:E=0
13 X1=MX+X:Y1=MY+Y:P1=X1>=0ANDX1<80:P2=Y1>=0ANDY1<192
14 X2=MX-X:Y2=MY-Y:P3=X2>=0ANDX2<80:P4=Y2>=0ANDY2<192
15 IFP1ANDP2THEN:@C,X1+X1,Y1
16 IFP1ANDP4THEN:@C,X1+X1,Y2
17 IFP3ANDP4THEN:@C,X2+X2,Y2
18 IFP3ANDP2THEN:@C,X2+X2,Y1
19 IFX=AANDY=0THENRETURN
20 F=E+S:D=0
21 G=F-T:IFABS(F)>ABS(G)THENF=G:D=1
22 G=E-T:IFABS(F)>ABS(G)THENF=G:D=2
23 E=F
24 IFD<2THENX=X+1:S=S+U
25 IFD>0THENY=Y-1:T=T-V
26 GOTO13
27 :
28 POKE646,13:@ON:@CLR:FORX=0TO159STEP2:@2,X,0TOX,191:NEXT:POKE36878,64:POKE36879,104
29 MX=40:MY=96
30 B=80:C=1:FORA=2TO22STEP4:GOSUB12:NEXT
31 A=24:C=0:FORB=0TO80STEP10:GOSUB12:NEXT
32 FORT=39TO0STEP-1:Y=2*SQR(6241-4*T*T)/3
33 IFT>27THENX=80+2*T:@3,X,96.5-YTOX,96.5+Y:X=80-2*T:@3,X,96.5-YTOX,96.5+Y:GOTO37
34 Z=2*SQR(3025-4*T*T)/3:X=80+2*T:@3,X,96.5+ZTOX,96.5+Y:X=80-2*T:@3,X,96.5+ZTOX,96.5+Y
35 IFT<25THENR=5*SQR(2401-4*T*T)/3:IFZ<RTHENZ=R:IFZ>YTHEN37
36 X=80+2*T:@3,X,96.5-ZTOX,96.5-Y:X=80-2*T:@3,X,96.5-ZTOX,96.5-Y
37 NEXT:FORP=-1TO0:GETA$:P=A$="":NEXT
38 RESTORE:FORT=1TO12:READC:POKE36878,16*C:FORS=1TO30:NEXT:NEXT:GOTO38
39 :
40 DATA 0,6,14,3,11,1,15,7,9,10,8,2
41 :
42 REM ** SATURN WRITTEN 2017-10-31 BY MICHAEL KIRCHER
The program draws Saturn with its rings:

Image

I (re-)used the ellipse drawing routines of the MG batch suite with a few alterations to make them work in multi-colour mode. They take their time though, but at least the ellipses themselves are mathematically correct (and are not faked by polygons as with the BASIC V3.5/V7 CIRCLE command!). The rings are drawn in the lines 32 to 37, and actually are quite fast at that. In BASIC, it's faster to draw filled circles/ellipses than just their outlines. :shock:

When the drawing has finished, press any key for an amazing neon effect!

Cheers,

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

Re: MINIGRAFIK batch processing suite

Post by Mike »

This (slightly longer) post covers a MG tool package (download), which does huge global changes to a picture. To be more specific, the programs of this package facilitate to remap the colour sources. This comes in quite handy, if a draft done in MINIPAINT suggests it might be better to have another exterior border colour. It is also useful for outputs of PGM IMPORT and the ppm2cga converter (via the 'scrapfile' function of the CGA panning viewer), which by themselves only realise one possible mapping of the 4 displayed physical colours to the colour sources.

The package is only intended for use with strictly multi-coloured pictures. If you process pictures which contain hires foreground attributes, you'll get unexpected results.

Biggest, and most important tool here is REMAP itself. It takes source and target file names and remaps the colour sources. The assignments M(...)=... in the lines 11 to 14 determine, which colour source is mapped to what other colour source. By default, nothing happens (an example, which exchanges exterior border and background, is given below). REMAP checks for all foreground attributes to be the same colour and in multi-colour. It refuses to work, if the mapping cannot be done - for example, if the auxiliary colour happens to be orange, and this is supposed to be mapped to foreground, the video chip couldn't do this - REMAP then stops with an error message to tell you what went wrong. In general, it's always possible to exchange background with auxiliary colour, and foreground with border colour, respectively.

Multicolour pictures with differing foreground colours cannot be processed directly with REMAP. First, the foreground data is saved away and replaced by a single foreground colour. This is done with SPLIT. REMAP can then proceed with its task, provided the mapping of the foreground attributes remains unchanged (i.e. line 12: 12 M(1)=1 must remain so!). Finally JOIN rejoins (duh!) the processed 4-colour bitmap with the original foreground attributes.


Now for an example: the splash screen of "Spider vs. Doc Ock" as drawn by darkatx:

Image

Unfortunately, the picture features a black border, where a white border possibly might fit better to the scene. So let's go - at first, a glance of the colour sources in MINIPAINT:

Image

The colour numbers in MINIPAINT are offset by one (by a feature request to keep the colour keys grouped). For MINIGRAFIK, the background colour is #0, and white; the border colour is #2, and black, and the auxiliary colour is #3 and light blue. It is intended to keep the foreground attributes as they differ along the picture (red, yellow, green and even white are used) - i.e. we'll go and exchange background and border colour source. But first we need to separate the attribute data. Cyan (physical colour code 3) serves as replacement colour:

Code: Select all

LOAD"SPLIT",8

SEARCHING FOR SPLIT
LOADING
READY.
RUN
SOURCE? SPLASH.1
BITMAP? BITMAP
COLOUR? COLOUR
REPL. (0..7)? 3
We get this result:

Image

Now, REMAP can work upon the file "BITMAP" as this now only contains 4 colours. Lines 11 and 13 are prepared to exchange background and border colour:

Code: Select all

LOAD"REMAP",8

SEARCHING FOR REMAP
LOADING
READY.
11 M(0)=2
13 M(2)=0
RUN
SRC? BITMAP
DST? BITMAP2
When REMAP has finished (after one minute or so), the colour sources have been remapped. The picture still looks the same, just the video chip generates the physical colours inside the display frame from other bit patterns. But most important, the exterior border colour now is white, as was intended!

Image

Finally, we recombine the result in "BITMAP2" with the original foreground data:

Code: Select all

LOAD"JOIN",8

SEARCHING FOR JOIN
LOADING
READY.
RUN
BITMAP? BITMAP2
COLOUR? COLOUR
TARGET? SPLASH.2
... and here's the result:

Image

... :mrgreen:

Cheers,

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

Re: MINIGRAFIK batch processing suite

Post by Mike »

I was not alone in having the need to solve the aforementioned issue... ;)

Lemon 64: Tool To Recolour Characters
mrr19121970 wrote:I was hoping that CHARpad would do this, but it doesn't. Anyone know of a tool to recolour multicolor CHARSETS ?

ie

Transparent
Char Colour
MC 1
MC 2

I want to change one of these attributes to another (say swap MC1 and Char Colour)
dyme wrote:charpad 2.0 has edit->multi-colour pixel swap
in the menu
mrr19121970 wrote:Fantastic! This is exactly what I needed. I didn't find it myself
User avatar
Mike
Herr VC
Posts: 4840
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: MINIGRAFIK batch processing suite

Post by Mike »

A tool to import save files from Commodore Artist has been released over there in the "Collecting and History" section, in the thread "Commodore Artist Save Files".
Post Reply