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