Changeset 4f508e6 in buchla-68k for vlib/vwputs.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/vwputs.s
rf40a309 r4f508e6 1 *------------------------------------------------------------------------------2 *vwputs.s -- output a character string to a 2-bit per pixel graphics window3 *Version 9 -- 1987-07-28 -- D.N. Lynx Crowe4 *(c) Copyright 1987 -- D.N. Lynx Crowe5 *------------------------------------------------------------------------------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, and14 *'bg' as the background color. Uses cgtable[][256] as the15 *VSDD formatted character generator table.16 *No error checks are done.17 *------------------------------------------------------------------------------18 * 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 19 19 .text 20 20 .xdef _vwputs 21 * 21 22 22 .xref _cgtable 23 * 24 *Argument offsets from a6:25 * 26 OBASE .equ 8 *L: Output area base address27 NW .equ 12 *W: Character width of output area28 FG .equ 14 *W: Foreground color29 BG .equ 16 *W: Background color30 ROW .equ 18 *W: Row31 COL .equ 20 *W: Column32 STR .equ 22 *L: String base address33 * 34 *Miscellaneous constants:35 * 36 HPIX .equ 8 *Horizontal pixels in the character37 * 38 NVPIX .equ 12 *Vertical pixels in the character39 VPITCH .equ 12 *Vertical pitch between characters40 * 41 *Register usage:42 * 43 *d0 output word and scratch44 *d1 CG word and scratch45 *d2 pixel counter46 *d3 foreground color (in the 2 ms bits)47 *d4 background color (in the 2 ms bits)48 *d5 width of the area in bytes49 *d6 scan line counter50 * 51 *a0 CG table pointer52 *a1 output area scan line pointer53 *a2 input character pointer54 *a3 output area character pointer55 * 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 56 56 .page 57 * 58 _vwputs: link a6,#0 *Link stack frames59 movem.l d3-d6/a3,-(a7) *Save registers we use60 move.w #14,d1 *Set shift constant61 move.w FG(a6),d3 *Setup foreground color62 lsl.w d1,d3 *... in ms 2 bits of d363 move.w BG(a6),d4 *Setup background color64 lsl.w d1,d4 *... in ms 2 bits of d465 move.w NW(a6),d5 *Get width in characters in d566 lsl.w #1,d5 *... make it words67 move.w ROW(a6),d0 *Calculate output address68 move.w #VPITCH,d1 *...69 mulu d1,d0 * ... ROW *VPITCH70 add.w #NVPIX-1,d0 *... + NVPIX-171 mulu d5,d0 * ... *NW72 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 *... + OBASE77 movea.l d0,a3 *Leave output address in a378 movea.l STR(a6),a2 *Put string address in a279 * 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 80 80 .page 81 cgl0: clr.l d0 *Clear out upper bits of d082 move.b (a2)+,d0 *Get next character83 beq cgl5 *Done if character EQ 084 * 85 movea.l a3,a1 *Establish output pointer in a186 adda.l #2,a3 *Update output pointer for next char.87 lea _cgtable,a0 *Establish CG pointer in a088 lsl.w #1,d0 * ... 2 *character89 adda.w d0,a0 *... + _cgtable address90 move.w #NVPIX-1,d6 *Set scan line counter in d691 * 92 cgl1: move.w #HPIX-1,d2 *Set pixel counter in d293 move.w (a0),d1 *Get character generator word in d194 * 95 cgl2: lsr.w #2,d0 *Shift output word right 1 pixel96 btst.l #0,d1 *Check CG word ls bit97 beq cgl3 *Set background color if bit EQ 098 * 99 or.w d3,d0 *OR foreground color into output word100 bra cgl4 *Go update CG word101 * 102 cgl3: or.w d4,d0 *OR background color into output word103 * 104 cgl4: lsr.w #1,d1 *Shift CG word right 1 pixel105 dbf d2,cgl2 *Loop for all 8 pixels106 * 107 move.w d0,(a1) *Store output word in output bitmap108 suba.w d5,a1 *Update output pointer109 adda.l #512,a0 *Update CG pointer for next scan line110 dbf d6,cgl1 *Loop for all scan lines111 * 112 bra cgl0 *Loop for next character113 * 114 cgl5: movem.l (a7)+,d3-d6/a3 *Restore registers115 unlk a6 *Unlink stack frames116 rts *Return to caller117 * 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 118 118 .end
Note:
See TracChangeset
for help on using the changeset viewer.