Changeset 4f508e6 in buchla-68k for vlib/vwputp.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/vwputp.s
rf40a309 r4f508e6 1 *------------------------------------------------------------------------------2 *vwputp.s -- put a pixel into a 2-bit per pixel bitmap object3 *Version 2 -- 1987-04-14 -- D.N. Lynx Crowe4 *(c) Copyright 1987 -- D.N. Lynx Crowe5 *------------------------------------------------------------------------------6 *int7 *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 pixel12 *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 * 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 35 .text 36 * 36 37 37 .xdef _vputp 38 * 39 OCTAD .equ840 XLOC .equ1241 YLOC .equ1442 VAL .equ1643 * 44 YSIZE .equ045 XSIZE .equ246 OBJX .equ447 OBJY .equ648 OBASE .equ849 OPRI .equ1250 OFLAGS .equ1351 ODTW0 .equ1452 ODTW1 .equ1653 * 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 54 .page 55 * 56 _vwputp: link a6,#0 *Link stack frames57 movea.l OCTAD(a6),a1 *Get OCTAD base into a158 move.w XLOC(a6),d0 *Get XLOC into d059 cmp.w XSIZE(a1),d0 *Check XLOC range60 bge vputerr *ERROR if too large61 * 62 tst.w d0 *Check XLOC sign63 bmi vputerr *ERROR if negative64 * 65 move.w YLOC(a6),d1 *Get YLOC into d1 to test66 cmp.w YSIZE(a1),d1 *Check YLOC range67 bge vputerr *ERROR if too large68 * 69 tst.w d1 *Check YLOC sign70 bmi vputerr *ERROR if negative71 * 72 lsr.w #3,d0 *Divide XLOC by 873 move.w XSIZE(a1),d1 *Get width into d174 lsr.w #3,d1 *Divide width by 875 mulu YLOC(a6),d1 *Multiply width/8 by YLOC76 ext.l d0 *Extend XLOC/8 to a long77 add.l d0,d1 *... and add it to d178 add.l OBASE(a1),d1 *Add OBASE to d179 movea.l d1,a0 *Make a0 point at bitmap data80 move.w XLOC(a6),d0 *Get XLOC81 andi.l # $07,d0 *Mask to low 3 bits82 add.l d0,d0 *Multiply by 2 for word index83 move.l d0,d1 *Save index in d184 add.l #MTAB,d0 *Add mask table base85 movea.l d0,a2 *a2 points at mask86 add.l #STAB,d1 *Add shift table base to index87 move.l d1,a1 *a1 points at shift count88 move.w (a1),d0 *Get shift count in d089 move.w VAL(a6),d1 *Get new pixel in d190 andi.w # $03,d1 *Mask down to 2 bits91 lsl.w d0,d1 *Shift into position for OR92 move.w (a0),d0 *Get old bitmap word in d093 and.w (a2),d0 *Mask out old pixel94 or.w d1,d0 *OR in new pixel95 move.w d0,(a0) *Store updated word in bitmap96 clr.l d0 *Set return value = 0 = OK97 * 98 vputexit: unlk a6 *Unlink stack frame99 rts *Return to caller100 * 101 vputerr: moveq.l #-1,d0 *Set return value = -1 = ERROR102 bra vputexit *Go unlink stack and return103 * 104 MTAB: dc.w $FFFC,$FFF3,$FFCF,$FF3F *Mask table105 dc.w $FCFF,$F3FF,$CFFF,$3FFF106 STAB: dc.w 0,2,4,6,8,10,12,14 *Shift table107 * 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 108 .end
Note:
See TracChangeset
for help on using the changeset viewer.