Changeset 4f508e6 in buchla-68k for vlib/vputp.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/vputp.s
rf40a309 r4f508e6 1 *------------------------------------------------------------------------------2 *vputp.s -- put a pixel into a 4-bit per pixel bitmap object3 *Version 4 -- 1987-08-04 -- D.N. Lynx Crowe4 *(c) Copyright 1987 -- D.N. Lynx Crowe5 *------------------------------------------------------------------------------6 *int7 *vputp(octad, xloc, yloc, val)8 * struct octent *octad;9 *int xloc, yloc;10 * 11 *Puts the pixel value 'val' at ('xloc','yloc') in the12 *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 * 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 32 .text 33 * 33 34 34 .xdef _vputp 35 * 36 OCTAD .equ837 XLOC .equ1238 YLOC .equ1439 VAL .equ1640 * 41 YSIZE .equ042 XSIZE .equ243 OBJX .equ444 OBJY .equ645 OBASE .equ846 OPRI .equ1247 OBANK .equ1348 ODTW0 .equ1449 ODTW1 .equ1650 * 35 36 OCTAD = 8 37 XLOC = 12 38 YLOC = 14 39 VAL = 16 40 41 YSIZE = 0 42 XSIZE = 2 43 OBJX = 4 44 OBJY = 6 45 OBASE = 8 46 OPRI = 12 47 OBANK = 13 48 ODTW0 = 14 49 ODTW1 = 16 50 51 51 .page 52 * 53 _vputp: link a6,#0 *Link stack frames54 movea.l OCTAD(a6),a1 *Get OCTAD base into a155 move.w XLOC(a6),d0 *Get XLOC into d056 cmp.w XSIZE(a1),d0 *Check XLOC range57 bge vputerr *ERROR if too large58 * 59 tst.w d0 *Check XLOC sign60 bmi vputerr *ERROR if negative61 * 62 move.w YLOC(a6),d1 *Get YLOC into d1 to test63 cmp.w YSIZE(a1),d1 *Check YLOC range64 bge vputerr *ERROR if too large65 * 66 tst.w d1 *Check YLOC sign67 bmi vputerr *ERROR if negative68 * 69 lsr.w #2,d0 *Divide XLOC by 470 move.w XSIZE(a1),d1 *Get width into d171 lsr.w #2,d1 *Divide width by 472 mulu YLOC(a6),d1 *Multiply width/4 by YLOC73 ext.l d0 *Extend XLOC/4 to a long74 add.l d0,d1 *... and add it to d175 lsl.l #1,d1 *Make d1 a word offset76 add.l OBASE(a1),d1 *Add OBASE to d177 movea.l d1,a0 *Make a0 point at bitmap data78 move.w XLOC(a6),d0 *Get XLOC79 andi.l # $03,d0 *Mask to low 2 bits80 add.l d0,d0 *Multiply by 2 for word index81 move.l d0,d1 *Save index in d182 add.l #MTAB,d0 *Add mask table base83 movea.l d0,a2 *a2 points at mask84 add.l #STAB,d1 *Add shift table base to index85 move.l d1,a1 *a1 points at shift count86 move.w (a1),d0 *Get shift count in d087 move.w VAL(a6),d1 *Get new pixel in d188 andi.w # $0F,d1 *Mask down to 4 bits89 lsl.w d0,d1 *Shift into position for OR90 move.w (a0),d0 *Get old bitmap word in d091 and.w (a2),d0 *Mask out old pixel92 or.w d1,d0 *OR in new pixel93 move.w d0,(a0) *Store updated word in bitmap94 clr.l d0 *Set return value = 0 = OK95 * 96 vputexit: unlk a6 *Unlink stack frame97 rts *Return to caller98 * 99 vputerr: moveq.l #-1,d0 *Set return value = -1 = ERROR100 bra vputexit *Go unlink stack and return101 * 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 #0x03,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 #0x0F,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 96 vputexit: unlk a6 | Unlink stack frame 97 rts | Return to caller 98 99 vputerr: moveq.l #-1,d0 | Set return value = -1 = ERROR 100 bra vputexit | Go unlink stack and return 101 102 102 .page 103 * 103 104 104 .data 105 * 106 MTAB: dc.w $FFF0,$FF0F,$F0FF,$0FFF *Mask table107 STAB: dc.w 0,4,8,12 *Shift table108 * 105 106 MTAB: dc.w 0xFFF0,0xFF0F,0xF0FF,0x0FFF | Mask table 107 STAB: dc.w 0,4,8,12 | Shift table 108 109 109 .end
Note:
See TracChangeset
for help on using the changeset viewer.