source: buchla-68k/orig/IOLIB/VPUTP.S@ 06ccda2

Last change on this file since 06ccda2 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 2.8 KB
Line 
1* ------------------------------------------------------------------------------
2* vputp.s -- put a pixel into a 4-bit per pixel bitmap object
3* Version 4 -- 1987-08-04 -- D.N. Lynx Crowe
4* (c) Copyright 1987 -- D.N. Lynx Crowe
5* ------------------------------------------------------------------------------
6* int
7* vputp(octad, xloc, yloc, val)
8* struct octent *octad;
9* int xloc, yloc;
10*
11* Puts the pixel value 'val' at ('xloc','yloc') in the
12* 4-bit per pixel bitmap object described by 'octad'.
13*
14* -----
15* struct octent {
16*
17* uint ysize,
18* xsize;
19*
20* int objx,
21* objy;
22*
23* uint *obase;
24*
25* char opri,
26* obank;
27*
28* uint odtw0,
29* odtw1;
30* };
31*
32 .text
33*
34 .xdef _vputp
35*
36OCTAD .equ 8
37XLOC .equ 12
38YLOC .equ 14
39VAL .equ 16
40*
41YSIZE .equ 0
42XSIZE .equ 2
43OBJX .equ 4
44OBJY .equ 6
45OBASE .equ 8
46OPRI .equ 12
47OBANK .equ 13
48ODTW0 .equ 14
49ODTW1 .equ 16
50*
51 .page
52*
53_vputp: link a6,#0 * Link stack frames
54 movea.l OCTAD(a6),a1 * Get OCTAD base into a1
55 move.w XLOC(a6),d0 * Get XLOC into d0
56 cmp.w XSIZE(a1),d0 * Check XLOC range
57 bge vputerr * ERROR if too large
58*
59 tst.w d0 * Check XLOC sign
60 bmi vputerr * ERROR if negative
61*
62 move.w YLOC(a6),d1 * Get YLOC into d1 to test
63 cmp.w YSIZE(a1),d1 * Check YLOC range
64 bge vputerr * ERROR if too large
65*
66 tst.w d1 * Check YLOC sign
67 bmi vputerr * ERROR if negative
68*
69 lsr.w #2,d0 * Divide XLOC by 4
70 move.w XSIZE(a1),d1 * Get width into d1
71 lsr.w #2,d1 * Divide width by 4
72 mulu YLOC(a6),d1 * Multiply width/4 by YLOC
73 ext.l d0 * Extend XLOC/4 to a long
74 add.l d0,d1 * ... and add it to d1
75 lsl.l #1,d1 * Make d1 a word offset
76 add.l OBASE(a1),d1 * Add OBASE to d1
77 movea.l d1,a0 * Make a0 point at bitmap data
78 move.w XLOC(a6),d0 * Get XLOC
79 andi.l #$03,d0 * Mask to low 2 bits
80 add.l d0,d0 * Multiply by 2 for word index
81 move.l d0,d1 * Save index in d1
82 add.l #MTAB,d0 * Add mask table base
83 movea.l d0,a2 * a2 points at mask
84 add.l #STAB,d1 * Add shift table base to index
85 move.l d1,a1 * a1 points at shift count
86 move.w (a1),d0 * Get shift count in d0
87 move.w VAL(a6),d1 * Get new pixel in d1
88 andi.w #$0F,d1 * Mask down to 4 bits
89 lsl.w d0,d1 * Shift into position for OR
90 move.w (a0),d0 * Get old bitmap word in d0
91 and.w (a2),d0 * Mask out old pixel
92 or.w d1,d0 * OR in new pixel
93 move.w d0,(a0) * Store updated word in bitmap
94 clr.l d0 * Set return value = 0 = OK
95*
96vputexit: unlk a6 * Unlink stack frame
97 rts * Return to caller
98*
99vputerr: moveq.l #-1,d0 * Set return value = -1 = ERROR
100 bra vputexit * Go unlink stack and return
101*
102 .page
103*
104 .data
105*
106MTAB: dc.w $FFF0,$FF0F,$F0FF,$0FFF * Mask table
107STAB: dc.w 0,4,8,12 * Shift table
108*
109 .end
Note: See TracBrowser for help on using the repository browser.