Hires Graphics

Basic and Machine Language

Moderator: Moderators

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

Post by Mike »

nippur72 wrote:And, yes, I am interested in the source, I need only the screen and pointers setup part.
This is the code executed by the @ON command:

Code: Select all

.On
 CLC            ; set up char map
 LDA #$10       ; first char is 'P', accessing $1100
 TAY
.On_00
 STA $0FF0,Y
 ADC #$0C
 BCC On_01
 SBC #$EF
.On_01
 INY
 BNE On_00
 LDY #$05       ; program VIC registers
.On_02
 CLC
 LDA $EDE4,Y
 ADC Offset,Y
 STA $9000,Y
 DEY
 BPL On_02
 RTS

.Offset
 EQUB $02
 EQUB $FE
 EQUB $FE
 EQUB $EB
 EQUB $00
 EQUB $0C
The bitmap starts at $1100, the address of a pixel is calculated thus (done with a table lookup):

Code: Select all

AD=4352+192*INT(X/8)+Y
The definitions of {SHIFT-M} and reverse {SHIFT-M} at $8268 and $8668 provide convenient bitmasks for setting or clearing single points.
Last edited by Mike on Wed Aug 26, 2009 10:05 am, edited 1 time in total.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Today a guy mailed me asking how to draw bitmapped graphics on an unexpanded VIC-20 without using Super Expander. I posted a link to MINIGRAFIK, converted Mike's docs to MS Word and added a few examples.

The other guy now wrote me that he's not interested in this extention, but rather would like to draw his own hires graphics from Basic. *sigh*
Anders Carlsson

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

Post by Mike »

I had dug out the original MINIGRAFIK extension (download) some time ago. It runs on an unexpanded VIC, or with +3K, but only provides 128x128 pixels. And, of course, my later extensions, like line drawing, (easy) multi-colour support, and load/save aren't there at all.
carlsson wrote:[...]and added a few examples.
If these are your own, would you like to post them here?

Greetings,

Michael

Edit: Listing of BASIC DATA loader replaced by d/l link, courtesy tokra.
Last edited by Mike on Tue Aug 02, 2016 9:30 am, edited 2 times in total.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

No, I copy and pasted yours + one from NBLA000.

In the end I wrote a Basic program that defines a 128x96 bitmap with space for regular text below, but pointed out how slow it was.
Anders Carlsson

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

Post by Mike »

carlsson wrote:Today a guy mailed me asking how to draw bitmapped graphics on an unexpanded VIC-20 without using Super Expander. [...] The other guy now wrote me that he's not interested in [MINIGRAFIK], but rather would like to draw his own hires graphics from Basic. *sigh* [...] In the end I wrote a Basic program that defines a 128x96 bitmap with space for regular text below, but pointed out how slow it was.
Well there are sometimes strange people around. What did that guy expect, anyway? With only unexpanded memory, and BASIC only you can't jump very far. Really, pearls thrown before the swine.

Michael
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

He's actually working with up to 8-16K expansion memory, which means a bit of moving start of Basic to have room for any custom graphics at all.

Anyway, this was the program I wrote for an unexpanded VIC:

Code: Select all

10 POKE56,22:POKE52,22:POKE648,22:CLR
20 V=36864:POKEV+5,208:POKEV+15,10:PRINT"{CLR}{13 DOWN}{YEL}A SINE CURVE"
30 FORY=0TO11:FORX=0TO15:POKE5632+Y*22+X,64+X*12+Y:NEXTX,Y
40 POKEV+5,222:FORI=0TO511:POKE6144+I,PEEK(32768+I):NEXT
50 FORI=0TO1535:POKE6656+I,0:NEXT
60 FORX=0TO127:Y=INT(48+SIN(X/64*pi)*44)
70 A=6656+INT(X/8)*96+Y:POKEA,PEEK(A)OR2^(7-XAND7)
80 NEXT
:roll:
Anders Carlsson

Image Image Image Image Image
6502dude
megacart
Posts: 1581
Joined: Wed Dec 01, 2004 9:53 am

Post by 6502dude »

carlsson wrote:Anyway, this was the program I wrote for an unexpanded VIC:
Cool!
Image Mega-Cart: the ultimate cartridge for your Commodore Vic-20
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

carlsson wrote:[...] working with up to 8-16K expansion memory [...] means a bit of moving start of Basic to have room for any custom graphics at all.
...which, of course, is automatically done by MINIGRAFIK.

Except the PRINT statement - which isn't supported by MINIGRAFIK at the moment -, your program is reduced to this:

Code: Select all

20 POKE36879,10:POKE646,1
30 @ON
50 @CLR
60 FORX=0TO127:Y=INT(48+SIN(X/64*{PI})*44)
70 @1,X,Y
80 NEXT
:wink:

I kept the line numbers for equivalent statements.

My program runs 5,3 sec, yours 32,8 sec - most of which is spent for setting up the hires screen, clearing it, and copying the charset. As you said.
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Earth globe

Post by Mike »

Hi,

This program displays an Earth globe. You specify the longitude, and latitude, that is centered. The north pole is always facing up.

In line 11, R1 can be adapted for different aspect ratios: R1=57 is correct for PAL; NTSC, and VICE should use R1=71, and R1=47, respectively. Line 11 also contains a {PI} symbol. That noted, any tokenizer should work.

Cheers,

Michael

Edit: type-in listing removed. It is contained in the MG batch suite.
Last edited by Mike on Sat Jul 28, 2012 10:22 am, 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 wonder to show to my C64 friends :D .
Here's a screenshot of the new desktop, after a bit of GIMPing on the image:
Image
I'm working on the animated gif of the revolving globe now - it will take a while, but the result will be the first 3D animation made with a Commodore VIC-20 (well, with a little help from other tools, but... :P ).
User avatar
ral-clan
plays wooden flutes
Posts: 3702
Joined: Thu Jan 26, 2006 2:01 pm
Location: Canada

Post by ral-clan »

Wow, that's impressive. Especially considering the small size of the code.
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Post by orion70 »

Last edited by orion70 on Wed Dec 03, 2008 2:50 am, edited 1 time in total.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

:shock:
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Jeff-20 wrote::shock:
A perfect candidate to include in the Denial home page images. :D

Alessandro, you've had a great idea. Could you make a GIF animation with 24 phases (one for each hour)?

Michael
Last edited by Mike on Thu Dec 04, 2008 1:58 am, 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 »

OK 15 degrees instead of 20. And invert the sense of rotation, of course. :oops:

Tomorrow :wink:
Post Reply