Hires Graphics

Basic and Machine Language

Moderator: Moderators

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

Post by carlsson »

Finally a good use of the Warp mode in VICE. :-D

Jeff: unless it hasn't already been clear to you, almost all the Basic programs shown in this thread are based on that you already have Mike's MINI-GRAFIK extention loaded.
Anders Carlsson

Image Image Image Image Image
User avatar
Jeff-20
Denial Founder
Posts: 5761
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

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

Post by Mike »

Hi, Jeff,

the examples in the thread should give a good idea, what is possible with MINIGRAFIK, and how to use it. The graphics in "VICtoria Deluxe", and "VICtoria Gold Ed.", from orion70, and me were also done with this extension.

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

Post by carlsson »

How about making a C interface to MINIGRAFIK so it can be included and called from e.g. cc65? So far I haven't written any VIC programs in C except for "porting" Contiki, but the other day I considered to give it a try. It should speed up development somewhat, while still giving a machine code program in the end. I don't know if hires graphics is the first I'd try out in C though, but ... it is an option.
Anders Carlsson

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

Post by Mike »

The first pre-requisite is, that C source can be compiled to an executable with a BASIC start at $246B. Second, there must be no harmful clashes in zeropage usage.

With the exception of the @() function, all relevant routines in MINIGRAFIK are callable with JSR. Only parameter passing, and validation need be done in the C function wrappers.

The @() function itself must be re-implemented, although it can use internal routines for address calculation.

This would be the proposed API:

Code: Select all

typedef unsigned char byte;

void at_on(void);
void at_clr(void);
void at_return(void);
void at_plot(byte colour, byte x, byte y);
void at_line(byte colour, byte x1, byte y1, byte x2, byte y2);
byte at(byte x, byte y);
void at_save(const char *name, byte device);
void at_load(count char *name, byte device);
The POKEs to addresses 646, 36878, and 36879 can easily be replaced by macros.
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

MIKE - in response to continuing the thread in here now, hope you know what im referring to, i would have rather just kept it in that thread, but....

1) is that for unexpanded VICE ?
2) i dont know how to save as .d64 image on VICE
3) then what...
4) Well this thread started as me learning what a vic is and now im into assembly language basics, but I do want to know how to run this minigraphics program simply to learn the basic routines demonstrated and how i can implement them into assembly.
I dont know what a loader is i just know there is basic programs, machine language programs executed with a SYStem command, and self executing machine language programs .prg .bas .vsf are ones ive created and saved as a state in the emulator...

when i copy and paste that loader and type run , i run out of memory in line 12, im guessing i have to have it loaded as a prerequisite upon running minigraphiks, still dont know how to mike! Razz
User avatar
Mike
Herr VC
Posts: 4853
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

To refer to my post in the other thread:
Mike wrote:- First copy+paste the DATA loader of MINIGRAFIK 4.02 into VICE. This is the most recent version to date.
- SAVE this program as "LOADER" onto a *.d64 image.
- RUN the program. The file "MINIGRAFIK" is written on disk. This is the actual BASIC extension. Up to here, these steps need only be done once.

- LOAD the file "MINIGRAFIK", and RUN it. The VIC shows the start screen again, with slightly less memory available than before. MINIGRAFIK is now active.

There is no need to memorize a certain SYS address to start the extension, as it is already contained in the program. The correct SYS shows up, when you LIST it before starting. This SYS is executed for you, when you type RUN+Return.
Legacy wrote:1) is that for unexpanded VICE ?
No, it isn't. MINIGRAFIK needs at least an 8K RAM expansion. In VICE, look under Settings > VIC Settings ...
2) i dont know how to save as .d64 image on VICE
*.d64 image files contain the data of a whole 5 1/4" disc (one sided).

To create a *.d64 file in VICE:

- File > Attach disk image > Drive 8, you'll be presented with a file selection box.
- In the field 'New Image', enter a name, for example 'MINIGRAFIK', an ID, for example 'MG', select d64, but do not click yet 'create image'.
- Fill in the field 'File name', for example 'minigrafik.d64'.
- Click 'create image'.
- Click 'attach'.

The file 'minigrafik.d64' is now mounted as *.d64 disc image. You can now store files inside this disc image, as if it were a real floppy disc.

Now you can proceed as I said, with:
First copy+paste the DATA loader of MINIGRAFIK 4.02 into VICE. This is the most recent version to date. SAVE this program as "LOADER" onto a *.d64 image. RUN the program.
Now there are two files stored in the disk image file. You can check this with:

Code: Select all

LOAD"$",8 + Return

and

LIST + Return
Finally, you load, and start MINIGRAFIK thus:

Code: Select all

LOAD"MINIGRAFIK",8 + Return
RUN + Return
Then you can try the examples in this thread, using the *.d64 file to store them.
Legacy wrote:Well this thread started as me learning what a vic is and now im into assembly language basics
Some thoughts:

First. While those image files are not something innate related to the VIC, the handling of them needs be well understood if you want to use the VICE emulator efficiently.

Second. It is still not quite clear to me how proficient you are with programming at all. You are touching quite basic questions. Programming in assembly language nearly is 100% implementation oriented. If you don't have an exact idea how to implement a program, or algorithm, you're lost. While CBM BASIC still is not exactly problem oriented, you can easily test your ideas, and see if these produce a working program. It shields you in a positive way from the bare metal, as long as there are no POKE's, PEEK's, and SYS's involved.

Third. If you've gained some experience, and see that BASIC is too slow for your needs, you might consider to advance to assembly language. Take your own written BASIC programs. Think about how single BASIC commands could be rewritten in machine code (Hint: you might well need dozens, or more instructions for even a single BASIC command). Sometimes you'll have to re-formulate your program, especially when floating point arithmetic is involved.

...

Finally: I mostly wrote MINIGRAFIK to make hires graphics on the VIC-20 easily be accessible from BASIC, at usable speeds, so it isn't necessary to resort to machine language except in rare cases.

Michael
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

I still can't figure it out Mike, but thanks anyways, maybe I can just wait another couple hours for a reply in something that could be explained by a chat program in 2 minutes... anyways it was the thought that counts :)

Ive made a new image called minigrafik.d64 , paste the Loader program 4.02 onto vice 8k and run and still have runtime error!

Code: Select all

ok this is what I do:

	VICE > Settings > Vic Settings > 8K Block > Ctrl+ Alt + R

	**** CBM BASIC V2 ****
	11775 BYTES FREE
	READY.
	*
--------------------------------------------------------------------------------------------
	File > Attach Disk Image > Drive 8

	New Image

	Name: 	Minigrafik
	ID:	MG
	ext:	.d64
	
	Click > Create Image
--------------------------------------------------------------------------------------------
	File Name: minigrafik.d64	Click > Attach Image
--------------------------------------------------------------------------------------------

	VICE > Attached minigrafik.d64 to device #8

--------------------------------------------------------------------------------------------

	Edit > Paste : loader program


--------------------------------------------------------------------------------------------
	
	File > Attach Disk Image > Drive 8	

	File Name: loader.d64	Click > Attach Image	

--------------------------------------------------------------------------------------------
	
	VICE> attached loader.d64 to device #8

--------------------------------------------------------------------------------------------
	
	RUN

	?OUT OF DATA	
	ERROR IN 12
	READY.
Ok so looks like i got it right, it just wasnt pasting right, that was fun!
Last edited by Legacy on Fri Jan 30, 2009 2:03 am, edited 1 time in total.
User avatar
Mike
Herr VC
Posts: 4853
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Legacy,

please remove the log from your previous post. It isn't necessary to quote the complete program, which already has been posted before in this thread.

Most probably the copy+paste function of VICE doesn't work properly. As I already wrote, it has only recently been added to VICE.

I'll prepare a working *.d64 image file containing MINIGRAFIK, and a few examples, and post the link.

Michael
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Post by orion70 »

Mike wrote:Most probably the copy+paste function of VICE doesn't work properly.
It often happens with DATA statements. Try listing them in VICE, and confirm each one with RETURN.
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

yea i found at least 6 lines ommitted from the DATA statements, so i went through and copied and pasted every 5 lines and that still didnt fix it, dont feel like retyping the whole thing, maybe a working version will popup soon?
User avatar
Mike
Herr VC
Posts: 4853
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Here's a disk image containing MINIGRAFIK, and lots of examples. The data loader is not included as it is only run once to write the MINIGRAFIK executable on disk.
Legacy wrote:maybe a working version will popup soon?
Mind you, it is you who has problems transfering the program to the emulator. The given data loader is in perfect working order.

When you have attached the disk image file, start MINIGRAFIK the way I've already described earlier. Then the two examples are run with:

Code: Select all

LOAD"HAT",8 + Return, or
LOAD"3D BAR CHART",8 + Return,
followed by RUN + Return
P.S.: In another thread you wrote:
Legacy wrote:Be carefull these are long data strings and PASTE wont work and it'll be your own fault cause you messed it up big time! This is complicated copy/paste routines not for amateurs , you need at least 20 years on the Vic to learn how to copy and paste a data array.

*make sure to calibrate the transducer as well...
This is surely not helping to make us friends. I might quite as well decide to ignore your posts in future.
Last edited by Mike on Sun Aug 31, 2014 1:12 pm, edited 7 times in total.
User avatar
Mike
Herr VC
Posts: 4853
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

MG text print

Post by Mike »

Mike wrote:Except the PRINT statement - which isn't supported by MINIGRAFIK at the moment -, [...]
This might be a workable solution:

The program sets up an array B%(), which translates from PETSCII to 8*screen_code, i.e. offsets into the character ROM. This only takes a few seconds. The sub-routine at line 70 then reads out the ROM charwise, and copies it into the screen bitmap. Control chars are printed as SPACEs.

In line 34 the variable AD can be set to 32768, 33792, 34816, and 35840 to print upper case, inverted upper case, lower case, and inverted lower case, respectively.

Greetings,

Michael

Code: Select all

10 DIMB%(255)
11 FORT=0TO255:B%(T)=256:NEXT
12 Z$="@ABCDEFG"
13 Z$=Z$+"HIJKLMNO"
14 Z$=Z$+"PQRSTUVW"
15 Z$=Z$+"XYZ[£]^{<-}"
16 Z$=Z$+" !"+CHR$(34)+"#$%&'"
17 Z$=Z$+"()*+,-./"
18 Z$=Z$+"01234567"
19 Z$=Z$+"89:;<=>?"
20 Z$=Z$+"{SHIFT-*,SHIFT-A,SHIFT-B,SHIFT-C,SHIFT-D,SHIFT-E,SHIFT-F,SHIFT-G}"
21 Z$=Z$+"{SHIFT-H,SHIFT-I,SHIFT-J,SHIFT-K,SHIFT-L,SHIFT-M,SHIFT-N,SHIFT-O}"
22 Z$=Z$+"{SHIFT-P,SHIFT-Q,SHIFT-R,SHIFT-S,SHIFT-T,SHIFT-U,SHIFT-V,SHIFT-W}"
23 Z$=Z$+"{SHIFT-X,SHIFT-Y,SHIFT-Z,SHIFT-+,C=--,SHIFT--,PI,C=-*}"
24 Z$=Z$+"{SHIFT-SPACE,C=-K,C=-I,C=-T,C=-@,C=-G,C=-+,C=-M}"
25 Z$=Z$+"{C=-£,SHIFT-£,C=-N,C=-Q,C=-D,C=-Z,C=-S,C=-P}"
26 Z$=Z$+"{C=-A,C=-E,C=-R,C=-W,C=-H,C=-J,C=-L,C=-Y}"
27 Z$=Z$+"{C=-U,C=-O,SHIFT-@,C=-F,C=-C,C=-X,C=-V,C=-B}"
28 FORT=0TO127:B%(ASC(MID$(Z$,T+1,1)))=8*T:NEXT:Z$=""
29 :
30 @ON:@CLR
31 X1=10:Y1=10:X2=149:Y2=181:GOSUB60
32 X1=20:Y1=20:X2=139:Y2=171:GOSUB60
33 :
34 AD=32768
35 T$="TEXT PRINTED":X=4:Y=8:GOSUB70
36 T$="WITHIN":X=7:Y=11:GOSUB70
37 T$="MINIGRAFIK":X=5:Y=14:GOSUB70
38 :
39 GETA$:IFA$=""THEN39
40 @RETURN
41 END
42 :
60 @1,X1,Y1TOX2,Y1
61 @1,X2,Y1TOX2,Y2
62 @1,X2,Y2TOX1,Y2
63 @1,X1,Y2TOX1,Y1
64 RETURN
65 :
70 IFT$=""THENRETURN
71 IFX<0ORY<0THENRETURN
72 IFX>19THENX=0:Y=Y+1
73 IFY>23THENRETURN
74 A1=4352+X*192+Y*8
75 A2=AD+B%(ASC(T$))
76 FORT=0TO7:POKEA1+T,PEEK(A2+T):NEXT
77 T$=MID$(T$,2):X=X+1:GOTO70
89 :
90 REM ** MG TEXT PRINT WRITTEN 2009-03-05 BY MICHAEL KIRCHER
Last edited by Mike on Fri Nov 30, 2012 6:59 pm, edited 3 times in total.
User avatar
darkatx
Vic 20 Afficionado
Posts: 473
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Post by darkatx »

This is so interesting man...I have something similar cooking here - if I get it sorted then I'll post the code of it for use along with a possible editor to go along with it. ;)
Learning all the time... :)
User avatar
Mike
Herr VC
Posts: 4853
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Can you be more precise? :)
Post Reply