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

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: 472
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: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Can you be more precise? :)
User avatar
darkatx
Vic 20 Afficionado
Posts: 472
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Post by darkatx »

Welp, in short - its a line drawing routine for my 3D program that I'm working on. I did one a few years ago on the C-64 based on a C routine from a 3D game programming book...coupled with Mr. Butterfield's pixel plotter routine found in a Compute's Gazette mag.
The one I'm working on now - should be much faster using tables and the line drawing routine is already worked out in ML - just have to type it all in and get the bugs out... :D
Learning all the time... :)
lordbubsy
Vic 20 Amateur
Posts: 45
Joined: Fri Nov 18, 2011 12:31 pm

Post by lordbubsy »

Hi Mike,
first of all my deep respect for your programs and BASIC scripts! :)
I’ve read this thread and I’d love to have commented sources of MINIGRAFIK! Especially the @CLR, @RETURN, @LOAD and @SAVE parts (@ON was described in this thread earlier).
I’m asking for learning purposes and eventually using that graphic mode and knowledge in a game.
8-bit assimilation
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Hi, lordbubsy,

it's rather strange to see this thread revived after nearly 4 years. :)
lordbubsy wrote:I’ve read this thread and I’d love to have commented sources of MINIGRAFIK! Especially the @CLR, @RETURN, @LOAD and @SAVE parts ([...])
@RETURN is rather easy, it just calls $E518 to reset the VIC registers and initialise the screen editor.

@CLR is also quite simple, the bitmap is cleared with a loop and the colour RAM is initialised with the value in $0286:

Code: Select all

.Clr
 LDA #$11     ; put start of bitmap ($1100) into pointer in ZP
 STA $FC
 LDA #$00
 STA $FB
 TAY
 LDX #$0F     ; clear 15 pages
.Clr_00
 STA ($FB),Y
 INY
 BNE Clr_00
 INC $FC
 DEX
 BNE Clr_00
 LDA $0286    ; load foreground colour
.Clr_01
 STA $9400,Y  ; init the first page of colour RAM
 INY          ; (actually, clearing just 240 bytes would be
 BNE Clr_01   ;  enough, but no harm doing 256.)
 RTS
The subroutines of @LOAD and @SAVE call a routine in the BASIC interpreter to fetch the filename and device number from the running BASIC program, which makes it difficult to use them unaltered in the context of another ML program. I can provide stand-alone versions of these two, but even MINIPAINT takes a simpler route: the editor code just drops to BASIC and then executes @LOAD and @SAVE from there. ;)

Greetings,

Michael
lordbubsy
Vic 20 Amateur
Posts: 45
Joined: Fri Nov 18, 2011 12:31 pm

Post by lordbubsy »

Mike wrote:it's rather strange to see this thread revived after nearly 4 years. :)
Well I read a lot of the old threads using the forum search. Let me know if it’s better for the forum to make new threads.

I’m interested in BASIC extensions and one of my ongoing projects for the C64 and now also for the VIC-20, is to collect (and try to understand) sources of BASIC commands like DEL, AUTO, FIND, RENUM, LIN, MERGE, OLD, HELP, MEM, KILL, CLS, CURSOR, BSAVE, BLOAD, DUMP, PAUSE etc.
I use them as little utilities, for instance at $33C or in a custom BASIC extension.
@RETURN is rather easy, it just calls $E518 to reset the VIC registers and initialise the screen editor.
So essentially

Code: Select all

JSR $E518
JMP $C474	;restart basic, print ready, set direct mode
@CLR is also quite simple, the bitmap is cleared with a loop and the colour RAM is initialised with the value in $0286:
OK, that’s 100% clear.
@LOAD and @SAVE use a lot of calls into the BASIC interpreter and in their current form it would be difficult to incorporate them into another program
I guess because of setting up the complete file structure.
If you're interested I can provide stand-alone versions of these two, so they can be called from other ML code
Well, actually I am.:)
I didn’t find any good sources for them. At least for the VIC.
So that would be great!
8-bit assimilation
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

PM sent.
lordbubsy
Vic 20 Amateur
Posts: 45
Joined: Fri Nov 18, 2011 12:31 pm

Post by lordbubsy »

Thank you for the source and help!
It resulted in a stand-alone display routine for own purposes. (like a game etc.)
The source can be assembled with ACME
http://www.esw-heim.tu-clausthal.de/~ma ... brod/acme/
http://codebase64.org/doku.php?id=base:crossdev

Picture and loader has to be in the same directory.
The program has to be loaded with ,8,1 and started with “SYS8888
8-bit assimilation
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Just a small remark about this section:
lordbubsy wrote:

Code: Select all

[...]
lda $10fe
sta $900e
[...]
The original code in MINIGRAFIK and in its executable pictures does a slightly more elaborate:

Code: Select all

LDA $900E
AND #$0F
ORA $10FE
STA $900E
MINIGRAFIK saves the contents of VIC register $900E (auxiliary colour and volume) with the bottom nibble zeroed out. When a picture is loaded again, these four instructions then serve to keep the current volume setting.
Post Reply