Hires Graphics

Basic and Machine Language

Moderator: Moderators

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

Post by Mike »

Schlowski wrote:Hope this is ok, Mike?
No problem, of course not. :)

I also checked the files on your account, and found that BasEdit seems to strip the spaces in the resulting PRG file.

For instruction lines, this is o.k., but REM's might become difficult to read. It would be good, if you made this stripping of spaces an optional setting.
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Fine :-)

For the spaces, you're right, that results in some ugly comments...
Ok, just another little correction I have to make, think I won't make it an optional setting but simply keep the spaces in the REM lines. All in all, if I want to save space I would eliminate REMs totally...

Björg
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

Ok, changed. And while changing the behaviour with spaces within REM's, I changed BasEdit so that in REM's the tokenizer will be switched off ...

I think some more samples from Mike and my BasEdit will become a reliable tool :roll:

Btw, I read in the mgrafdemo3 and MinigrafikV3 sources in BasEdit again and saved, now with spaces so that the next downloader will be able to read your comments :-)

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

Post by Mike »

Another test for BasEdit. ;)

This program wouldn't have been possible without the addition of the line-routine to MINIGRAFIK. It displays a wall clock, with hands for seconds, minutes, and hours. TI$ is set in the first line, so set time can be easily synchronised with RUN+{RETURN}. As the clock face is drawn, some arrays are too being initialised. The main loop insists on making redraw fast.

There is still enough time left at line 26 to add some effects. Maybe an alarm function, or a Westminster Gong? :)

Greetings,

Michael

Code: Select all

10 REM ** WALL CLOCK
11 TI$="123456":DIMSX(59),SY(59),BX(59),BY(59):MX=80:MY=96:@ON:@CLR
12 FORT=0TO59:S=SIN({PI}*T/30):C=COS({PI}*T/30)
13 SX(T)=MX+INT(33*S+.5):SY(T)=MY-INT(55*C+.5)
14 BX(T)=MX+INT(48*S+.5):BY(T)=MY-INT(80*C+.5)
15 RX=54:RY=90:IFT=5*INT(T/5)THENRX=51:RY=85
16 @1,MX+INT(RX*S+.5),MY-INT(RY*C+.5)TOMX+INT(57*S+.5),MY-INT(95*C+.5)
17 NEXT:H=0:M=0:S=0:A$=TI$
18 :
19 B$=TI$:IFB$=A$THEN19
20 S=VAL(MID$(B$,5,2)):M=VAL(MID$(B$,3,2))
21 H=VAL(MID$(B$,1,2)):H=INT(0.5+5*H+M/12):H=H-60*INT(H/60)
22 IFG<>HTHEN:@0,MX,MYTOSX(G),SY(G)
23 IFL<>MTHEN:@0,MX,MYTOBX(L),BY(L)
24 @0,MX,MYTOBX(R),BY(R):@1,MX,MYTOBX(S),BY(S)
25 @1,MX,MYTOBX(M),BY(M):@1,MX,MYTOSX(H),SY(H)
26 G=H:L=M:R=S:A$=B$:GOTO19
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Did you check the demo programs in the graphic extention I posted? One of the original ones was a wall clock.
Anders Carlsson

Image Image Image Image Image
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

You got me again, Mike :oops:
After replacing {PI} with the PI-sign in BasEdit and saving it, it didn't work - I obviously forgot to tokenize PI ... I just hit enter in VICE on that line and saved again, now it works, but I have to fix this in BasEdit soon...

Nevertheless your wall clock is downloadable as
http://www.stojalowski.de/files/mgrafdemo4

Björg

Edit: New version of BasEdit uploadet, now with {PI} :-)
Last edited by Schlowski on Thu Apr 06, 2006 1:40 am, edited 1 time in total.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Indeed I took this program as inspiration to improve upon:

The example in the hires toolkit you posted shows only a dot for the seconds... therefore it needs to redraw the hands for minutes and hours only every minute. Mine does this (and needs to, since the hands are possibly overlapping) every second.

Otherwise the inner workings are very similar. With a program that short and of identical task one couldn't expect otherwise.

And my example is shorter. ;)

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

Version 3.2 of MINIGRAFIK

Post by Mike »

New version 3.2:

* line-drawing is faster by 50% (I replaced the slow address-calculation by a table-lookup)
* rationalised handling of errors: when an error occurs while hires graphics are being displayed, the system reverts to text mode before outputting the error message.

Code: Select all

[BASIC DATA loader deleted]
Greetings,

Michael

Edit: MINIGRAFIK V3.2 is obsolete. Please use V4.02 instead.
Last edited by Mike on Thu Mar 15, 2012 10:12 am, edited 1 time in total.
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

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

3D Bar Chart

Post by Mike »

Here's another application for MINIGRAFIK. A 3D Bar Chart. No more need to use E**el for this. ;)

I was lucky to see the design allows for 12 bars over the screen width. So the program can accommodate the display of the fuel consumption of your car over the year, or similar things.

Greetings,

Michael

Code: Select all

1 REM ** 3D BAR CHART
2 @ON:@CLR
3 Y=191:Z=175:S=25:GOSUB10
4 Y=188:FORX=6TO138STEP12:READZ:GOSUB20:NEXT
5 GETA$:IFA$=""THEN5
6 @RETURN:END
7 :
10 @1,0,YTO147,Y:@1,147,YTO159,Y-12
11 FORT=0TOZSTEPS
12 @1,0,Y-TTO12,Y-T-12:@1,12,Y-T-12TO159,Y-T-12
13 NEXT
14 @1,0,YTO0,Y-Z:@1,12,Y-12TO12,Y-Z-12:@1,159,Y-12TO159,Y-Z-12
15 RETURN
16 :
20 IFZ<2THEN23
21 FORT=1TO8:@0,X+T,Y-1TOX+T,Y-Z+1:NEXT
22 FORT=1TO5:@0,X+T+9,Y-T-1TOX+T+9,Y-T-Z+1:NEXT
23 FORT=1TO5:@0,X+T+1,Y-T-ZTOX+T+8,Y-T-Z:NEXT
24 @1,X,YTOX+9,Y:@1,X+9,YTOX+15,Y-6
25 @1,X,YTOX,Y-Z:@1,X+9,YTOX+9,Y-Z:@1,X+15,Y-6TOX+15,Y-Z-6
26 @1,X,Y-ZTOX+9,Y-Z:@1,X+9,Y-ZTOX+15,Y-Z-6
27 @1,X,Y-ZTOX+6,Y-Z-6:@1,X+6,Y-Z-6TOX+15,Y-Z-6
28 RETURN
29 :
30 DATA 0,1,2,3,10,20,55,175,111,33,81,47
Thomas Hechelhammer
Vic 20 Dabbler
Posts: 79
Joined: Thu Jun 09, 2005 11:51 pm
Location: Germany

Post by Thomas Hechelhammer »

Thanks for the examples.

I was wondering how the bitmap is arranged so I looked here and there:

Bitmap and chars start both at 1000.

Chars are arranged in a 20x12 char map as follows:

Code: Select all

10 1c 28 34 40 4c 58 64 70 7c 88 94 a0 ac b8 c4 d0 dc e8 f4
11 1d 29 35 41 4d 59 65 71 7d 89 95 a1 ad b9 c5 d1 dd e9 f5
.. ..	     					              				.. ..
1a 26 32 3e 4a 56 62 6e 7a 86 92 9e aa b6 c2 ce da e6 f2 fe
1b 27 33 3f 4b 57 63 6f 7b 87 93 9f ab b7 c3 cf db e7 f3 ff
This area is between 1000 and 10ef (240 characters). Bit 1 in $9003 is set, so we have double-chars which give us direct access to 240 x 2 x 8 x 8 = 30720 pixel (which is 160 (X-Axis) x192 (Y-Axis)).

The very first double-character $10 in the upper left corner (8x16 pixel) uses the bitmap from chars $20 and $21, which are memory-locations 1000 + $20 x 8 = 1100 to 110f (16 bytes).

For saving pictures simply store the memory from 1000 to 1fff, and write the following bytes to 9000 – 900f : 0e 24 14 19 00 cc 57 ea 00 00 00 00 00 00 00 1b

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

Post by Mike »

Thomas Hechelhammer wrote:I was wondering how the bitmap is arranged so I looked here and there:

Bitmap and chars start both at 1000.
Yep. With double-height characters, one needs 17 Bytes (1 text byte, 16 bitmap bytes) to display an 8x16 pixel cell. I didn't want to use the bottom 1K, so the calculation was:

4096/17 ~= 240.94

Of course we cannot use fractions of a cell. But 240 chars can be neatly arranged in a 20x12 map. :) So we have optimal use of the upper 4K built-in RAM.
Thomas Hechelhammer wrote:For saving pictures simply store the memory from 1000 to 1fff, and write the following bytes to 9000 – 900f : 0e 24 14 19 00 cc 57 ea 00 00 00 00 00 00 00 1b
Since the text map is always the same, you can restore it from MINIGRAFIK, and you don't need to save the text map:

Save picture from program:

Code: Select all

SYS57809(N$),8,1:POKE193,0:POKE194,17 
POKE780,193:POKE781,0:POKE782,32:SYS65496
Load picture:

Code: Select all

@CLR:SYS57809(N$),8,1:POKE780,0:SYS65493:@ON
@CLR clears the screen bitmap - which isn't needed here -, but also initialises the colour RAM. @ON then writes the text map, and sets the needed values in the VIC registers, which are correct for both PAL and NTSC.

Greetings,

Michael

Edit: MINIGRAFIK 4.02 features @SAVE and @LOAD commands to save and load images.
Last edited by Mike on Thu Oct 30, 2008 2:54 am, edited 1 time in total.
User avatar
GreyGhost
Vic 20 Nerd
Posts: 525
Joined: Wed Oct 05, 2005 11:10 pm

Post by GreyGhost »

Just playing around with this program. Here is a graphical picture of just how finite the RND(1) function really is. Some number combos never even come up. I ran this in VICE so I hope that's what's doing it. You'll have to use warp mode to see what I mean.

10 @ON:@CLR
20 @1,INT(RND(1)*160,INT(RND(1)*192)
30 GOTO 20


If you replace the 1 with a 0 it really gets crappy.

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

Post by GreyGhost »

Can any one come up with a way to fill the screen randomly like this? :?
Rob
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

GreyGhost wrote:I ran this in VICE so I hope that's what's doing it.
Hi, Rob!

This is not VICE's fault. The RND() function is broken. I wrote a posting about that some months ago.

The replacement, that I posted, indeed manages to fill the entire screen. However, its BASIC implementation is rather slow. Furthermore, your fill routine as such slows down exponentially (like a radio-active decay of the white pixels).

Better is an algorithm, that produces pixel-addresses exactly once - but still semi-random. You might try this:

Code: Select all

1 @ON:@CLR
2 X=0:Y=0
3 FORT=1TO30880
4 X=X+39:IFX>159THENX=X-160
5 Y=Y+74:IFY>192THENY=Y-193
6 IFY<192THEN:@1,X,Y
7 NEXT
8 GETA$:IFA$=""THEN8
9 @RETURN
Greetings,

Michael

Edit: Corrected error in line 5
Last edited by Mike on Thu Jan 11, 2007 1:47 am, edited 1 time in total.
Post Reply