home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / QuakeC / qtools0.2-src.lha / src / libqdisplay / drawSpans24-m68k2.S < prev    next >
Encoding:
Text File  |  1998-08-11  |  5.7 KB  |  327 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. void draw_spans24(register int y __asm__("a4"), register int ey __asm__("d5"))
  7.  
  8.     __asm ("
  9.  
  10.     .equ    len,a6
  11.     .equ    dest,a5
  12.     .equ    y,a4
  13.     .equ    storev,a3
  14.     .equ    storeu,a2
  15.     .equ    buf,a0        | parameter ...
  16.     
  17.     .equ    prew,fp7
  18.     .equ    prev,fp6
  19.     .equ    preu,fp5
  20.     .equ    w0,fp4
  21.     .equ    v0,fp3
  22.     .equ    u0,fp2
  23.     
  24.     .equ    slen,d7
  25.     .equ    sx,d6
  26.     .equ    ey,d5
  27.  
  28.     .equ    count,d4    | parameter ...
  29.     .equ    dv,d3        |
  30.     .equ    du,d2        |
  31.     .equ    v,d1        |
  32.     .equ    u,d0        |
  33.  
  34. .text
  35.     .globl    _draw_spans24
  36. | void draw_spans24(register int y __asm__ (a4), register int ey __asm__ (d5))
  37. _draw_spans24:
  38.     moveml    d2-d4/d6-d7/a2-a3/a5-a6,sp@-
  39.     fmovem    fp2-fp7,sp@-
  40.  
  41.     movel    _localDim+26,dest    | localDim.frameBuffer
  42.  
  43.     movel    y,d0
  44.     fmovel    d0,preu
  45.  
  46.     fmoves    _tmap+32,prew        | tmap[8]
  47.     fsglmulx preu,prew        | y * tmap[8]
  48.     fadds    _tmap+24,prew        | tmap[6] + y * tmap[8]
  49.  
  50.     fmoves    _tmap+20,prev
  51.     fsglmulx preu,prev
  52.     fadds    _tmap+12,prev
  53.  
  54.     fsglmuls _tmap+8,preu
  55.     fadds    _tmap+0,preu
  56.     
  57.     subl    y,ey            | y < ey
  58.     subql    #1,ey            | (y - 1) <= ey
  59.     blt    .bigEnd24
  60. .bigLoop24:
  61.     lea    @(_scan, y:l:8), a0    | scan[y][]
  62.     movel    a0@+,sx            | FIX_INT(scan[y][0])
  63.     |addl    #65535,sx
  64.     |swap    sx
  65.     movel    a0@,d0            | FIX_INT(scan[y][1])
  66.     |addl    #65535,d0
  67.     |swap    d0
  68.     subw    sx,d0            | scan[y][1] - sx
  69.     ble    .noSpan24        | len > 0
  70.     movew    d0,len
  71.     
  72.     movel    _multRows,buf
  73.     movel    buf@(y:l:4),buf        | multRows[y]
  74.     addl    dest,buf        | localDim.frameBuffer + multRows[y]
  75.     addw    sx,buf            | localDim.frameBuffer + multRows[y] + sx
  76.     addw    sx,buf            | localDim.frameBuffer + multRows[y] + sx
  77.     addw    sx,buf            | localDim.frameBuffer + multRows[y] + sx
  78.     
  79.     fmovew    sx,u0
  80.     fmoves    #0r65536.0,w0        | 1.0
  81.     fmoves    _tmap+28,fp0        | tmap[7]
  82.     fsglmulx u0,fp0            | sx * tmap[7]
  83.     faddx    prew,fp0        | prew + sx * tmap[7]
  84.     fsgldivx fp0,w0            | 1 / (prew + sx * tmap[7])
  85.  
  86.     fmoves    _tmap+16,v0        | tmap[4]
  87.     fsglmulx u0,v0            | sx * tmap[4]
  88.  
  89.     fsglmuls _tmap+4,u0
  90.  
  91.     faddx    prev,v0            | prev + sx * tmap[4]
  92.     faddx    preu,u0
  93.  
  94.     fsglmulx w0,v0            | (prev + sx * tmap[4]) * w0
  95.     fsglmulx w0,u0
  96.     
  97.     fmovel    v0,v
  98.     fmovel    u0,u
  99.     
  100.     movew    len,slen
  101.     lsrw    #4,slen
  102.     subqw    #1,slen            | dbge if not blts ???
  103.     blt    .noSub24
  104. .sub24:    addw    #16,sx
  105.  
  106.     fmovew    sx,u0
  107.     fmoves    #0r65536.0,w0
  108.     fmoves    _tmap+28,fp0
  109.     fsglmulx u0,fp0
  110.     faddx    prew,fp0
  111.     fsgldivx fp0,w0
  112.  
  113.     fmoves    _tmap+16,v0
  114.     fsglmulx u0,v0
  115.  
  116.     fsglmuls _tmap+4,u0
  117.  
  118.     faddx    prev,v0
  119.     faddx    preu,u0
  120.  
  121.     fsglmulx w0,v0
  122.     fsglmulx w0,u0
  123.     
  124.     fmovel    v0,dv
  125.     fmovel    u0,du
  126.  
  127.     movel    dv,storev
  128.     movel    du,storeu
  129.  
  130.     subl    v,dv
  131.     asrl    #4,dv
  132.     subl    u,du
  133.     asrl    #4,du
  134.     
  135.     |moveq    #16,count
  136.     moveq    #15,count
  137.     bsr    _draw_affine24
  138.  
  139.     movel    storev,v
  140.     movel    storeu,u
  141.     
  142.     dbra    slen,.sub24
  143. .noSub24:
  144.     |moveq    #0,count    | sometimes something in upper word
  145.     movew    len,count
  146.     andw    #0x000F,count
  147.     subqw    #1,count
  148.     blts    .noSpan24    | nothing to do
  149.     beqs    .noRest24    | avoid division by 0
  150.     addw    count,sx    | count is near 15 and sx smaller than 32767
  151.  
  152.     fmovew    sx,fp1
  153.     fmoves    #0r65536.0,w0    | v0 and u0 are scaled by 65536.0 on entry
  154.     fmoves    _tmap+28,fp0
  155.     fsglmulx fp1,fp0
  156.     faddx    prew,fp0
  157.     fsgldivx fp0,w0
  158.  
  159.     fmoves    _tmap+16,fp0    | tmap[4]
  160.     fsglmulx fp1,fp0    | sx * tmap[4]
  161.  
  162.     fsglmuls _tmap+4,fp1
  163.  
  164.     faddx    prev,fp0    | prev + sx * tmap[4]
  165.     faddx    preu,fp1
  166.  
  167.     fsglmulx w0,fp0        | (prev + sx * tmap[4]) * w1
  168.     fsglmulx w0,fp1
  169.  
  170.     fsubx    v0,fp0        | v1 - v0
  171.     fsubx    u0,fp1
  172.  
  173.     fsgldivw count,fp0
  174.     fsgldivw count,fp1
  175.  
  176.     fmovel    fp0,dv
  177.     fmovel    fp1,du
  178.     
  179. .noRest24:
  180.     |addqw    #1,count
  181.     bsrs    _draw_affine24
  182. .noSpan24:
  183.     fadds    _tmap+32,prew
  184.     fadds    _tmap+20,prev
  185.     fadds    _tmap+8,preu
  186.     addql    #1,y        | y++
  187.     dbra    ey,.bigLoop24
  188. .bigEnd24:
  189.     fmovem    sp@+,fp2-fp7
  190.     moveml    sp@+,d2-d4/d6-d7/a2-a3/a5-a6
  191.     rts
  192.     .even
  193.  
  194. _draw_affine24:
  195.     movew    _textureType,a1
  196.     cmpw    #1,a1
  197.     bnes    .noWall24
  198.     moveml    d5-d7,sp@-
  199.     movel    _texture,a1
  200.     movel    #0x0000FF00,d7            | from tables.h        ,MAX_MASKX
  201.     asrl    #8,v                | inaccurate but fast    ,16-MAX_LOGX
  202.     asrl    #8,dv                | inaccurate but fast    ,16-MAX_LOGX
  203. .wall24:
  204.     movel    u,d6
  205.     movel    v,d5
  206.     clrw    d6
  207.     swap    d6
  208.     andl    d7,d5                | nessecary? -> yep
  209.     moveb    _textureRow+3,d5
  210.     addl    @(_multTMap, d5:l:4),d6
  211.     mulsw    #3,d6
  212.     movew    a1@(d6:l:1),buf@+
  213.     moveb    a1@(2,d6:l:1),buf@+
  214.     addl    du,u
  215.     addl    dv,v    
  216.     dbra    count,.wall24
  217.     moveml    sp@+,d5-d7
  218.     rts
  219. .noWall24:
  220.     cmpw    #5,a1
  221.     bnes    .noSky24
  222.     moveml    d5-d7,sp@-
  223.     movel    _texture,a1
  224.     movew    #0x7F7F,d7
  225.     asrl    #8,u                | inaccurate but fast
  226.     asrl    #8,du                | inaccurate but fast
  227. .sky24:
  228.     movel    u,d6
  229.     movel    v,d5
  230.     swap    d5
  231.     moveb    d5,d6
  232.     movew    d6,d5
  233.     addw    _skyMovementX1+2,d6
  234.     addw    _skyMovementX2+2,d5
  235.     addb    _skyMovementY1+3,d6
  236.     addb    _skyMovementY2+3,d5
  237.     andw    d7,d6
  238.     andw    d7,d5
  239.     mulsw    #3,d6
  240.     mulsw    #3,d5
  241.     movel    a1@(0x180,d6:w:1),d6
  242.     movel    a1@(d5:w:1),d5
  243.     clrb    d5
  244.     tstl    d5
  245.     beqs    .skipSky24
  246.     movel    d5,d6
  247. .skipSky24:
  248.     swap    d6
  249.     movew    d6,buf@+
  250.     roll    #8,d6
  251.     moveb    d6,buf@+
  252.     addl    du,u
  253.     addl    dv,v    
  254.     dbra    count,.sky24
  255.     moveml    sp@+,d5-d7
  256.     rts
  257.  
  258. .noSky24:
  259.     moveml    a2/d5-d7,sp@-
  260.     | fast configureable transparency for 24bit needed!!
  261.     subql    #2,a1            | textureType - WATER_TYPE + 1
  262.     movel    _texture,a2
  263.     moveq    #0,d7            | nessecary ? (asr is faster then)
  264. .liquid24:
  265.     movew    _textureShift2,d7
  266.     movel    u,d6            | bfextu    u{d7:8},d6
  267.     movel    v,d5            | bfextu    v{d7:8},d5
  268.     asrl    d7,d6            | ...
  269.     asrl    d7,d5            | ...
  270.     andw    #0x00FF,d6        | ...
  271.     andw    #0x00FF,d5        | ...
  272.     movel    @(_swim_v, d6:w:4),d6
  273.     movel    @(_swim_u, d5:w:4),d5
  274.     movew    _textureMip,d7
  275.     asrl    d7,d6
  276.     asrl    d7,d5
  277.     addl    v,d6
  278.     addl    u,d5
  279.     movew    _textureShift1,d7
  280.     swap    d6
  281.     asrl    d7,d5
  282.     andl    _textureMask2,d6
  283.     andl    _textureMask1,d5
  284.     orl    d6,d5
  285.     |moveq    #0,d6            | d6 is not greater than 64*64, so the upper bits are 0
  286.     mulsw    #3,d5
  287.     movel    buf@,d6
  288.     movel    a2@(d5:w:1),d5
  289.  
  290.     | fast configureable transparency for 24bit needed!!
  291.     movel    a1,d7
  292.     
  293.     roll    #8,d5
  294.     roll    #8,d6
  295.     andw    0x00FF,d5
  296.     andw    0x00FF,d6
  297.     subw    d5,d6
  298.     asrw    d7,d6
  299.     addw    d6,d5
  300.     moveb    d5,buf@+
  301.     
  302.     roll    #8,d5
  303.     roll    #8,d6
  304.     andw    0x00FF,d5
  305.     andw    0x00FF,d6
  306.     subw    d5,d6
  307.     asrw    d7,d6
  308.     addw    d6,d5
  309.     moveb    d5,buf@+
  310.     
  311.     roll    #8,d5
  312.     roll    #8,d6
  313.     andw    0x00FF,d5
  314.     andw    0x00FF,d6
  315.     subw    d5,d6
  316.     asrw    d7,d6
  317.     addw    d6,d5
  318.     moveb    d5,buf@+
  319.     |
  320.     
  321.     addl    du,u
  322.     addl    dv,v    
  323.     dbra    count,.liquid24
  324.     moveml    sp@+,a2/d5-d7
  325.     rts
  326.     ");
  327.