Changeset 4f508e6 in buchla-68k for vlib/vcputsv.s
- Timestamp:
- 07/01/2017 02:34:46 PM (7 years ago)
- Branches:
- master
- Children:
- 08e1da1
- Parents:
- f40a309
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vlib/vcputsv.s
rf40a309 r4f508e6 1 *------------------------------------------------------------------------------2 *vcputsv.s -- output characters to a 4-bit / pixel graphics window3 *with variable vertical pitch4 *Version 2 -- 1987-08-03 -- D.N. Lynx Crowe5 *(c) Copyright 1987 -- D.N. Lynx Crowe6 *------------------------------------------------------------------------------7 * 8 *vcputsv(obase, nw, fg, bg, row, col, str. pitch)9 * int *obase, nw, fg, bg, 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, and15 *'bg' as the background color. Uses cgtable[][256] as the16 *VSDD formatted character generator table. Assumes 12 bit17 *high characters in the cgtable. Uses 'pitch' as the vertical18 *spacing between character rows. No error checks are done.19 *The string must fit the output area (no overlaps, single line).20 * 21 *------------------------------------------------------------------------------1 | ------------------------------------------------------------------------------ 2 | vcputsv.s -- output characters to a 4-bit / pixel graphics window 3 | with variable vertical pitch 4 | Version 2 -- 1987-08-03 -- D.N. Lynx Crowe 5 | (c) Copyright 1987 -- D.N. Lynx Crowe 6 | ------------------------------------------------------------------------------ 7 8 | vcputsv(obase, nw, fg, bg, row, col, str. pitch) 9 | int |obase, nw, fg, bg, 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, and 15 | 'bg' as the background color. Uses cgtable[][256] as the 16 | VSDD formatted character generator table. Assumes 12 bit 17 | high characters in the cgtable. Uses 'pitch' as the vertical 18 | spacing between character rows. No error checks are done. 19 | The string must fit the output area (no overlaps, single line). 20 21 | ------------------------------------------------------------------------------ 22 22 .text 23 * 23 24 24 .xdef _vcputsv 25 * 25 26 26 .xref _cgtable 27 * 28 *Argument offsets from a6:29 * 30 OBASE .equ 8 *LONG - Output area base address31 NW .equ 12 *WORD - Character width of output area32 FG .equ 14 *WORD - Foreground color33 BG .equ 16 *WORD - Background color34 ROW .equ 18 *WORD - Row35 COL .equ 20 *WORD - Column36 STR .equ 22 *LONG - String base address37 PITCH .equ 26 *WORD - Vertical spacing between rows38 * 39 *Program constant definitions:40 * 41 HPIX .equ 8 *Character width in pixels42 VPIX .equ 12 *Character height in pixels43 HCW .equ 4 *Horizontal character width (bytes)44 PSHIFT .equ 12 *Pixel shift into MS bits45 HSHIFT .equ 4 *Pixel right shift46 * 27 28 | Argument offsets from a6: 29 30 OBASE = 8 | LONG - Output area base address 31 NW = 12 | WORD - Character width of output area 32 FG = 14 | WORD - Foreground color 33 BG = 16 | WORD - Background color 34 ROW = 18 | WORD - Row 35 COL = 20 | WORD - Column 36 STR = 22 | LONG - String base address 37 PITCH = 26 | WORD - Vertical spacing between rows 38 39 | Program constant definitions: 40 41 HPIX = 8 | Character width in pixels 42 VPIX = 12 | Character height in pixels 43 HCW = 4 | Horizontal character width (bytes) 44 PSHIFT = 12 | Pixel shift into MS bits 45 HSHIFT = 4 | Pixel right shift 46 47 47 .page 48 * 49 *Register usage:50 * 51 *d0 output word and scratch52 *d1 CG word and scratch53 *d2 pixel counter54 * 55 *d3 foreground color (in the 4 ms bits)56 *d4 background color (in the 4 ms bits)57 *d5 width of the area in bytes58 *d6 scan line counter59 * 60 *a0 CG table pointer61 *a1 output area scan line pointer62 *a2 input string character pointer63 * 64 *a3 output area character base pointer65 * 66 *a6 frame pointer67 *a7 stack pointer68 * 48 49 | Register usage: 50 51 | d0 output word and scratch 52 | d1 CG word and scratch 53 | d2 pixel counter 54 55 | d3 foreground color (in the 4 ms bits) 56 | d4 background color (in the 4 ms bits) 57 | d5 width of the area in bytes 58 | d6 scan line counter 59 60 | a0 CG table pointer 61 | a1 output area scan line pointer 62 | a2 input string character pointer 63 64 | a3 output area character base pointer 65 66 | a6 frame pointer 67 | a7 stack pointer 68 69 69 .page 70 * 71 _vcputsv: link a6,#0 *Link stack frames72 movem.l d3-d6/a3,-(a7) *Save registers we use73 move.w #PSHIFT,d1 *Set shift constant74 move.w FG(a6),d3 *Setup foreground color75 lsl.w d1,d3 *... in ms 4 bits of d3.W76 move.w BG(a6),d4 *Setup background color77 lsl.w d1,d4 *... in ms 4 bits of d4.W78 move.w NW(a6),d5 *Get line width in d5.W79 lsl.w #2,d5 *Multiply width by 4 for offset80 move.w ROW(a6),d0 *Calculate output address81 move.w PITCH(a6),d1 *... PITCH82 mulu d1,d0 * ... *ROW83 add.w #VPIX-1,d0 *... + VPIX-184 mulu d5,d0 * ... *NW85 clr.l d1 *...86 move.w COL(a6),d1 * ... +87 lsl.w #2,d1 * ... COL *488 add.l d1,d0 *...89 add.l OBASE(a6),d0 *... + OBASE90 movea.l d0,a3 *Leave output address in a391 movea.l STR(a6),a2 *Put string address in a292 * 93 cgl0: clr.l d0 *Clear out upper bits of d094 move.b (a2)+,d0 *Get next character95 beq cgl5 *Done if character EQ 096 * 97 movea.l a3,a1 *Establish output pointer in a198 adda.l #HCW,a3 *Update output pointer for next char.99 lea _cgtable,a0 *Establish CG pointer in a0100 lsl.w #1,d0 * ... 2 *character101 adda.w d0,a0 *... + _cgtable address102 move.w #VPIX-1,d6 *Set scan line counter in d6103 * 70 71 _vcputsv: link a6,#0 | Link stack frames 72 movem.l d3-d6/a3,-(a7) | Save registers we use 73 move.w #PSHIFT,d1 | Set shift constant 74 move.w FG(a6),d3 | Setup foreground color 75 lsl.w d1,d3 | ... in ms 4 bits of d3.W 76 move.w BG(a6),d4 | Setup background color 77 lsl.w d1,d4 | ... in ms 4 bits of d4.W 78 move.w NW(a6),d5 | Get line width in d5.W 79 lsl.w #2,d5 | Multiply width by 4 for offset 80 move.w ROW(a6),d0 | Calculate output address 81 move.w PITCH(a6),d1 | ... PITCH 82 mulu d1,d0 | ... | ROW 83 add.w #VPIX-1,d0 | ... + VPIX-1 84 mulu d5,d0 | ... | NW 85 clr.l d1 | ... 86 move.w COL(a6),d1 | ... + 87 lsl.w #2,d1 | ... COL | 4 88 add.l d1,d0 | ... 89 add.l OBASE(a6),d0 | ... + OBASE 90 movea.l d0,a3 | Leave output address in a3 91 movea.l STR(a6),a2 | Put string address in a2 92 93 cgl0: clr.l d0 | Clear out upper bits of d0 94 move.b (a2)+,d0 | Get next character 95 beq cgl5 | Done if character EQ 0 96 97 movea.l a3,a1 | Establish output pointer in a1 98 adda.l #HCW,a3 | Update output pointer for next char. 99 lea _cgtable,a0 | Establish CG pointer in a0 100 lsl.w #1,d0 | ... 2 | character 101 adda.w d0,a0 | ... + _cgtable address 102 move.w #VPIX-1,d6 | Set scan line counter in d6 103 104 104 .page 105 cgl1: move.w (a0),d1 *Get character generator word in d1106 move.w #(HPIX/2)-1,d2 *Set pixel counter in d2107 * 108 cgl2: lsr.w #HSHIFT,d0 *Shift output word right 1 pixel109 btst.l #0,d1 *Check CG word ls bit110 beq cgl3 *Set background color if bit EQ 0111 * 112 or.w d3,d0 *OR foreground color into output word113 bra cgl4 *Go update CG word114 * 115 cgl3: or.w d4,d0 *OR background color into output word116 * 117 cgl4: lsr.w #1,d1 *Shift CG word right 1 pixel118 dbf d2,cgl2 *Loop for first 4 pixels119 * 120 move.w d0,(a1)+ *Store first output word in scan line121 move.w #(HPIX/2)-1,d2 *Set pixel counter in d2122 * 123 cgl2a: lsr.w #HSHIFT,d0 *Shift output word right 1 pixel124 btst.l #0,d1 *Check CG word ls bit125 beq cgl3a *Set background color if bit EQ 0126 * 127 or.w d3,d0 *OR foreground color into output word128 bra cgl4a *Go update CG word129 * 130 cgl3a: or.w d4,d0 *OR background color into output word131 * 132 cgl4a: lsr.w #1,d1 *Shift CG word right 1 pixel133 dbf d2,cgl2a *Loop for last 4 pixels134 * 135 move.w d0,(a1) *Store second output word in scan line136 suba.w d5,a1 *Update output pointer137 suba.w #2,a1 *...138 adda.l #512,a0 *Update CG pointer for next scan line139 dbf d6,cgl1 *Loop for all scan lines140 * 141 bra cgl0 *Loop for next character142 * 143 cgl5: movem.l (a7)+,d3-d6/a3 *Restore registers144 unlk a6 *Unlink stack frames145 rts *Return to caller146 * 105 cgl1: move.w (a0),d1 | Get character generator word in d1 106 move.w #(HPIX/2)-1,d2 | Set pixel counter in d2 107 108 cgl2: lsr.w #HSHIFT,d0 | Shift output word right 1 pixel 109 btst.l #0,d1 | Check CG word ls bit 110 beq cgl3 | Set background color if bit EQ 0 111 112 or.w d3,d0 | OR foreground color into output word 113 bra cgl4 | Go update CG word 114 115 cgl3: or.w d4,d0 | OR background color into output word 116 117 cgl4: lsr.w #1,d1 | Shift CG word right 1 pixel 118 dbf d2,cgl2 | Loop for first 4 pixels 119 120 move.w d0,(a1)+ | Store first output word in scan line 121 move.w #(HPIX/2)-1,d2 | Set pixel counter in d2 122 123 cgl2a: lsr.w #HSHIFT,d0 | Shift output word right 1 pixel 124 btst.l #0,d1 | Check CG word ls bit 125 beq cgl3a | Set background color if bit EQ 0 126 127 or.w d3,d0 | OR foreground color into output word 128 bra cgl4a | Go update CG word 129 130 cgl3a: or.w d4,d0 | OR background color into output word 131 132 cgl4a: lsr.w #1,d1 | Shift CG word right 1 pixel 133 dbf d2,cgl2a | Loop for last 4 pixels 134 135 move.w d0,(a1) | Store second output word in scan line 136 suba.w d5,a1 | Update output pointer 137 suba.w #2,a1 | ... 138 adda.l #512,a0 | Update CG pointer for next scan line 139 dbf d6,cgl1 | Loop for all scan lines 140 141 bra cgl0 | Loop for next character 142 143 cgl5: movem.l (a7)+,d3-d6/a3 | Restore registers 144 unlk a6 | Unlink stack frames 145 rts | Return to caller 146 147 147 .end
Note:
See TracChangeset
for help on using the changeset viewer.