1 | * ------------------------------------------------------------------------------
|
---|
2 | * vcputs.s -- output a character string to a 4-bit per pixel graphics window
|
---|
3 | * Version 3 -- 1987-07-31 -- D.N. Lynx Crowe
|
---|
4 | * (c) Copyright 1987 -- D.N. Lynx Crowe
|
---|
5 | * ------------------------------------------------------------------------------
|
---|
6 | *
|
---|
7 | * vcputs(obase, nw, fg, bg, row, col, str)
|
---|
8 | * int *obase, nw, fg, bg, row, col;
|
---|
9 | * char *str;
|
---|
10 | *
|
---|
11 | * Outputs characters from the string at 'str' to an 'nw'
|
---|
12 | * character wide 4-bit per pixel graphics window at 'obase'
|
---|
13 | * at ('row','col'), using 'fg' as the foreground color, and
|
---|
14 | * 'bg' as the background color. Uses cgtable[][256] as the
|
---|
15 | * VSDD formatted character generator table.
|
---|
16 | * No error checks are done.
|
---|
17 | *
|
---|
18 | * ------------------------------------------------------------------------------
|
---|
19 | .text
|
---|
20 | *
|
---|
21 | .xdef _vcputs
|
---|
22 | *
|
---|
23 | .xref _cgtable
|
---|
24 | *
|
---|
25 | * Argument offsets from a6:
|
---|
26 | *
|
---|
27 | OBASE .equ 8 * Output area base address
|
---|
28 | NW .equ 12 * Character width of output area
|
---|
29 | FG .equ 14 * Foreground color
|
---|
30 | BG .equ 16 * Background color
|
---|
31 | ROW .equ 18 * Row
|
---|
32 | COL .equ 20 * Column
|
---|
33 | STR .equ 22 * String base address
|
---|
34 | *
|
---|
35 | * Program constant definitions:
|
---|
36 | *
|
---|
37 | HPIX .equ 8 * Character width in pixels
|
---|
38 | VPIX .equ 12 * Character height in pixels
|
---|
39 | HCW .equ 4 * Horizontal character width (bytes)
|
---|
40 | PSHIFT .equ 12 * Pixel shift into MS bits
|
---|
41 | HSHIFT .equ 4 * Pixel right shift
|
---|
42 | *
|
---|
43 | .page
|
---|
44 | *
|
---|
45 | * Register usage:
|
---|
46 | *
|
---|
47 | * d0 output word and scratch
|
---|
48 | * d1 CG word and scratch
|
---|
49 | * d2 pixel counter
|
---|
50 | *
|
---|
51 | * d3 foreground color (in the 4 ms bits)
|
---|
52 | * d4 background color (in the 4 ms bits)
|
---|
53 | * d5 width of the area in bytes
|
---|
54 | * d6 scan line counter
|
---|
55 | *
|
---|
56 | * a0 CG table pointer
|
---|
57 | * a1 output area scan line pointer
|
---|
58 | * a2 input string character pointer
|
---|
59 | *
|
---|
60 | * a3 output area character base pointer
|
---|
61 | *
|
---|
62 | .page
|
---|
63 | *
|
---|
64 | _vcputs: link a6,#0 * Link stack frames
|
---|
65 | movem.l d3-d6/a3,-(a7) * Save registers we use
|
---|
66 | move.w #PSHIFT,d1 * Set shift constant
|
---|
67 | move.w FG(a6),d3 * Setup foreground color
|
---|
68 | lsl.w d1,d3 * ... in ms 4 bits of d3.W
|
---|
69 | move.w BG(a6),d4 * Setup background color
|
---|
70 | lsl.w d1,d4 * ... in ms 4 bits of d4.W
|
---|
71 | move.w NW(a6),d5 * Get line width in d5.W
|
---|
72 | lsl.w #2,d5 * Multiply width by 4 for offset
|
---|
73 | move.w ROW(a6),d0 * Calculate output address
|
---|
74 | move.w #VPIX,d1 * ... VPIX
|
---|
75 | mulu d1,d0 * ... * ROW
|
---|
76 | add.w #VPIX-1,d0 * ... + VPIX-1
|
---|
77 | mulu d5,d0 * ... * NW
|
---|
78 | clr.l d1 * ...
|
---|
79 | move.w COL(a6),d1 * ... +
|
---|
80 | lsl.w #2,d1 * ... COL * 4
|
---|
81 | add.l d1,d0 * ...
|
---|
82 | add.l OBASE(a6),d0 * ... + OBASE
|
---|
83 | movea.l d0,a3 * Leave output address in a3
|
---|
84 | movea.l STR(a6),a2 * Put string address in a2
|
---|
85 | *
|
---|
86 | cgl0: clr.l d0 * Clear out upper bits of d0
|
---|
87 | move.b (a2)+,d0 * Get next character
|
---|
88 | beq cgl5 * Done if character EQ 0
|
---|
89 | *
|
---|
90 | movea.l a3,a1 * Establish output pointer in a1
|
---|
91 | adda.l #HCW,a3 * Update output pointer for next char.
|
---|
92 | lea _cgtable,a0 * Establish CG pointer in a0
|
---|
93 | lsl.w #1,d0 * ... 2 * character
|
---|
94 | adda.w d0,a0 * ... + _cgtable address
|
---|
95 | move.w #VPIX-1,d6 * Set scan line counter in d6
|
---|
96 | *
|
---|
97 | .page
|
---|
98 | cgl1: move.w (a0),d1 * Get character generator word in d1
|
---|
99 | move.w #(HPIX/2)-1,d2 * Set pixel counter in d2
|
---|
100 | *
|
---|
101 | cgl2: lsr.w #HSHIFT,d0 * Shift output word right 1 pixel
|
---|
102 | btst.l #0,d1 * Check CG word ls bit
|
---|
103 | beq cgl3 * Set background color if bit EQ 0
|
---|
104 | *
|
---|
105 | or.w d3,d0 * OR foreground color into output word
|
---|
106 | bra cgl4 * Go update CG word
|
---|
107 | *
|
---|
108 | cgl3: or.w d4,d0 * OR background color into output word
|
---|
109 | *
|
---|
110 | cgl4: lsr.w #1,d1 * Shift CG word right 1 pixel
|
---|
111 | dbf d2,cgl2 * Loop for first 4 pixels
|
---|
112 | *
|
---|
113 | move.w d0,(a1)+ * Store first output word in scan line
|
---|
114 | move.w #(HPIX/2)-1,d2 * Set pixel counter in d2
|
---|
115 | *
|
---|
116 | cgl2a: lsr.w #HSHIFT,d0 * Shift output word right 1 pixel
|
---|
117 | btst.l #0,d1 * Check CG word ls bit
|
---|
118 | beq cgl3a * Set background color if bit EQ 0
|
---|
119 | *
|
---|
120 | or.w d3,d0 * OR foreground color into output word
|
---|
121 | bra cgl4a * Go update CG word
|
---|
122 | *
|
---|
123 | cgl3a: or.w d4,d0 * OR background color into output word
|
---|
124 | *
|
---|
125 | cgl4a: lsr.w #1,d1 * Shift CG word right 1 pixel
|
---|
126 | dbf d2,cgl2a * Loop for last 4 pixels
|
---|
127 | *
|
---|
128 | move.w d0,(a1) * Store second output word in scan line
|
---|
129 | suba.w d5,a1 * Update output pointer
|
---|
130 | suba.w #2,a1 * ...
|
---|
131 | adda.l #512,a0 * Update CG pointer for next scan line
|
---|
132 | dbf d6,cgl1 * Loop for all scan lines
|
---|
133 | *
|
---|
134 | bra cgl0 * Loop for next character
|
---|
135 | *
|
---|
136 | cgl5: movem.l (a7)+,d3-d6/a3 * Restore registers
|
---|
137 | unlk a6 * Unlink stack frames
|
---|
138 | rts * Return to caller
|
---|
139 | *
|
---|
140 | .end
|
---|