[4f508e6] | 1 | | ------------------------------------------------------------------------------
|
---|
| 2 | | vwputs.s -- output a character string to a 2-bit per pixel graphics window
|
---|
| 3 | | Version 9 -- 1987-07-28 -- D.N. Lynx Crowe
|
---|
| 4 | | (c) Copyright 1987 -- D.N. Lynx Crowe
|
---|
| 5 | | ------------------------------------------------------------------------------
|
---|
| 6 |
|
---|
| 7 | | vwputs(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 2-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 |
|
---|
[f40a309] | 19 | .text
|
---|
| 20 | .xdef _vwputs
|
---|
[4f508e6] | 21 |
|
---|
[f40a309] | 22 | .xref _cgtable
|
---|
[4f508e6] | 23 |
|
---|
| 24 | | Argument offsets from a6:
|
---|
| 25 |
|
---|
| 26 | OBASE = 8 | L: Output area base address
|
---|
| 27 | NW = 12 | W: Character width of output area
|
---|
| 28 | FG = 14 | W: Foreground color
|
---|
| 29 | BG = 16 | W: Background color
|
---|
| 30 | ROW = 18 | W: Row
|
---|
| 31 | COL = 20 | W: Column
|
---|
| 32 | STR = 22 | L: String base address
|
---|
| 33 |
|
---|
| 34 | | Miscellaneous constants:
|
---|
| 35 |
|
---|
| 36 | HPIX = 8 | Horizontal pixels in the character
|
---|
| 37 |
|
---|
| 38 | NVPIX = 12 | Vertical pixels in the character
|
---|
| 39 | VPITCH = 12 | Vertical pitch between characters
|
---|
| 40 |
|
---|
| 41 | | Register usage:
|
---|
| 42 |
|
---|
| 43 | | d0 output word and scratch
|
---|
| 44 | | d1 CG word and scratch
|
---|
| 45 | | d2 pixel counter
|
---|
| 46 | | d3 foreground color (in the 2 ms bits)
|
---|
| 47 | | d4 background color (in the 2 ms bits)
|
---|
| 48 | | d5 width of the area in bytes
|
---|
| 49 | | d6 scan line counter
|
---|
| 50 |
|
---|
| 51 | | a0 CG table pointer
|
---|
| 52 | | a1 output area scan line pointer
|
---|
| 53 | | a2 input character pointer
|
---|
| 54 | | a3 output area character pointer
|
---|
| 55 |
|
---|
[f40a309] | 56 | .page
|
---|
[4f508e6] | 57 |
|
---|
| 58 | _vwputs: link a6,#0 | Link stack frames
|
---|
| 59 | movem.l d3-d6/a3,-(a7) | Save registers we use
|
---|
| 60 | move.w #14,d1 | Set shift constant
|
---|
| 61 | move.w FG(a6),d3 | Setup foreground color
|
---|
| 62 | lsl.w d1,d3 | ... in ms 2 bits of d3
|
---|
| 63 | move.w BG(a6),d4 | Setup background color
|
---|
| 64 | lsl.w d1,d4 | ... in ms 2 bits of d4
|
---|
| 65 | move.w NW(a6),d5 | Get width in characters in d5
|
---|
| 66 | lsl.w #1,d5 | ... make it words
|
---|
| 67 | move.w ROW(a6),d0 | Calculate output address
|
---|
| 68 | move.w #VPITCH,d1 | ...
|
---|
| 69 | mulu d1,d0 | ... ROW | VPITCH
|
---|
| 70 | add.w #NVPIX-1,d0 | ... + NVPIX-1
|
---|
| 71 | mulu d5,d0 | ... | NW
|
---|
| 72 | clr.l d1 | ...
|
---|
| 73 | move.w COL(a6),d1 | ... + (COL | 2)
|
---|
| 74 | lsl.l #1,d1 | ...
|
---|
| 75 | add.l d1,d0 | ...
|
---|
| 76 | add.l OBASE(a6),d0 | ... + OBASE
|
---|
| 77 | movea.l d0,a3 | Leave output address in a3
|
---|
| 78 | movea.l STR(a6),a2 | Put string address in a2
|
---|
| 79 |
|
---|
[f40a309] | 80 | .page
|
---|
[4f508e6] | 81 | cgl0: clr.l d0 | Clear out upper bits of d0
|
---|
| 82 | move.b (a2)+,d0 | Get next character
|
---|
| 83 | beq cgl5 | Done if character EQ 0
|
---|
| 84 |
|
---|
| 85 | movea.l a3,a1 | Establish output pointer in a1
|
---|
| 86 | adda.l #2,a3 | Update output pointer for next char.
|
---|
| 87 | lea _cgtable,a0 | Establish CG pointer in a0
|
---|
| 88 | lsl.w #1,d0 | ... 2 | character
|
---|
| 89 | adda.w d0,a0 | ... + _cgtable address
|
---|
| 90 | move.w #NVPIX-1,d6 | Set scan line counter in d6
|
---|
| 91 |
|
---|
| 92 | cgl1: move.w #HPIX-1,d2 | Set pixel counter in d2
|
---|
| 93 | move.w (a0),d1 | Get character generator word in d1
|
---|
| 94 |
|
---|
| 95 | cgl2: lsr.w #2,d0 | Shift output word right 1 pixel
|
---|
| 96 | btst.l #0,d1 | Check CG word ls bit
|
---|
| 97 | beq cgl3 | Set background color if bit EQ 0
|
---|
| 98 |
|
---|
| 99 | or.w d3,d0 | OR foreground color into output word
|
---|
| 100 | bra cgl4 | Go update CG word
|
---|
| 101 |
|
---|
| 102 | cgl3: or.w d4,d0 | OR background color into output word
|
---|
| 103 |
|
---|
| 104 | cgl4: lsr.w #1,d1 | Shift CG word right 1 pixel
|
---|
| 105 | dbf d2,cgl2 | Loop for all 8 pixels
|
---|
| 106 |
|
---|
| 107 | move.w d0,(a1) | Store output word in output bitmap
|
---|
| 108 | suba.w d5,a1 | Update output pointer
|
---|
| 109 | adda.l #512,a0 | Update CG pointer for next scan line
|
---|
| 110 | dbf d6,cgl1 | Loop for all scan lines
|
---|
| 111 |
|
---|
| 112 | bra cgl0 | Loop for next character
|
---|
| 113 |
|
---|
| 114 | cgl5: movem.l (a7)+,d3-d6/a3 | Restore registers
|
---|
| 115 | unlk a6 | Unlink stack frames
|
---|
| 116 | rts | Return to caller
|
---|
| 117 |
|
---|
[f40a309] | 118 | .end
|
---|