source: buchla-68k/orig/IOLIB/VWPUTP.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* 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*
39OCTAD .equ 8
40XLOC .equ 12
41YLOC .equ 14
42VAL .equ 16
43*
44YSIZE .equ 0
45XSIZE .equ 2
46OBJX .equ 4
47OBJY .equ 6
48OBASE .equ 8
49OPRI .equ 12
50OFLAGS .equ 13
51ODTW0 .equ 14
52ODTW1 .equ 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 #$07,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 #$03,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*
98vputexit: unlk a6 * Unlink stack frame
99 rts * Return to caller
100*
101vputerr: moveq.l #-1,d0 * Set return value = -1 = ERROR
102 bra vputexit * Go unlink stack and return
103*
104MTAB: dc.w $FFFC,$FFF3,$FFCF,$FF3F * Mask table
105 dc.w $FCFF,$F3FF,$CFFF,$3FFF
106STAB: dc.w 0,2,4,6,8,10,12,14 * Shift table
107*
108 .end
Note: See TracBrowser for help on using the repository browser.