Hires Graphics
Moderator: Moderators
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
- Mike
- Herr VC
- Posts: 4853
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
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:
The POKEs to addresses 646, 36878, and 36879 can easily be replaced by macros.
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);
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
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
- Mike
- Herr VC
- Posts: 4853
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
To refer to my post in the other thread:
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:
Finally, you load, and start MINIGRAFIK thus:
Then you can try the examples in this thread, using the *.d64 file to store them.
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
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.
No, it isn't. MINIGRAFIK needs at least an 8K RAM expansion. In VICE, look under Settings > VIC Settings ...Legacy wrote:1) is that for unexpanded VICE ?
*.d64 image files contain the data of a whole 5 1/4" disc (one sided).2) i dont know how to save as .d64 image on VICE
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:
Now there are two files stored in the disk image file. You can check this 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.
Code: Select all
LOAD"$",8 + Return
and
LIST + Return
Code: Select all
LOAD"MINIGRAFIK",8 + Return
RUN + Return
Some thoughts:Legacy wrote:Well this thread started as me learning what a vic is and now im into assembly language basics
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
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!
Ok so looks like i got it right, it just wasnt pasting right, that was fun!
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.
Last edited by Legacy on Fri Jan 30, 2009 2:03 am, edited 1 time in total.
- Mike
- Herr VC
- Posts: 4853
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
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
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
- Mike
- Herr VC
- Posts: 4853
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
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.
When you have attached the disk image file, start MINIGRAFIK the way I've already described earlier. Then the two examples are run with:
P.S.: In another thread you wrote:
Mind you, it is you who has problems transfering the program to the emulator. The given data loader is in perfect working order.Legacy wrote:maybe a working version will popup soon?
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
This is surely not helping to make us friends. I might quite as well decide to ignore your posts in future.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...
Last edited by Mike on Sun Aug 31, 2014 1:12 pm, edited 7 times in total.
- Mike
- Herr VC
- Posts: 4853
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
MG text print
This might be a workable solution:Mike wrote:Except the PRINT statement - which isn't supported by MINIGRAFIK at the moment -, [...]
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$+" !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THENRETURN
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.