source: buchla-68k/vlib/tsplot4.s@ f7c91fc

Last change on this file since f7c91fc was 4f508e6, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Converted assembly language files.

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