Changeset 4f508e6 in buchla-68k for vlib/vputp.s


Ignore:
Timestamp:
07/01/2017 02:34:46 PM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
08e1da1
Parents:
f40a309
Message:

Converted assembly language files.

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 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 *
     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
    3232                .text
    33 *
     33
    3434                .xdef   _vputp
    35 *
    36 OCTAD           .equ    8
    37 XLOC            .equ    12
    38 YLOC            .equ    14
    39 VAL             .equ    16
    40 *
    41 YSIZE           .equ    0
    42 XSIZE           .equ    2
    43 OBJX            .equ    4
    44 OBJY            .equ    6
    45 OBASE           .equ    8
    46 OPRI            .equ    12
    47 OBANK           .equ    13
    48 ODTW0           .equ    14
    49 ODTW1           .equ    16
    50 *
     35
     36OCTAD           =       8
     37XLOC            =       12
     38YLOC            =       14
     39VAL             =       16
     40
     41YSIZE           =       0
     42XSIZE           =       2
     43OBJX            =       4
     44OBJY            =       6
     45OBASE           =       8
     46OPRI            =       12
     47OBANK           =       13
     48ODTW0           =       14
     49ODTW1           =       16
     50
    5151                .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 *
    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 *
     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
     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
    102102                .page
    103 *
     103
    104104                .data
    105 *
    106 MTAB:           dc.w    $FFF0,$FF0F,$F0FF,$0FFF * Mask table
    107 STAB:           dc.w    0,4,8,12                * Shift table
    108 *
     105
     106MTAB:           dc.w    0xFFF0,0xFF0F,0xF0FF,0x0FFF     | Mask table
     107STAB:           dc.w    0,4,8,12                | Shift table
     108
    109109                .end
Note: See TracChangeset for help on using the changeset viewer.