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

  1.  
  2.  
  3.  
  4.  
  5.  
  6. void draw_spans8(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_spans8
  36. | void draw_spans8(register int y __asm__ (a4), register int ey __asm__ (d5))
  37. _draw_spans8:
  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    .bigEnd8
  60. .bigLoop8:
  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    .noSpan8        | 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.     
  77.     fmovew    sx,u0
  78.     fmoves    #0r65536.0,w0        | 1.0
  79.     fmoves    _tmap+28,fp0        | tmap[7]
  80.     fsglmulx u0,fp0            | sx * tmap[7]
  81.     faddx    prew,fp0        | prew + sx * tmap[7]
  82.     fsgldivx fp0,w0            | 1 / (prew + sx * tmap[7])
  83.  
  84.     fmoves    _tmap+16,v0        | tmap[4]
  85.     fsglmulx u0,v0            | sx * tmap[4]
  86.  
  87.     fsglmuls _tmap+4,u0
  88.  
  89.     faddx    prev,v0            | prev + sx * tmap[4]
  90.     faddx    preu,u0
  91.  
  92.     fsglmulx w0,v0            | (prev + sx * tmap[4]) * w0
  93.     fsglmulx w0,u0
  94.     
  95.     fmovel    v0,v
  96.     fmovel    u0,u
  97.     
  98.     movew    len,slen
  99.     lsrw    #4,slen
  100.     subqw    #1,slen            | dbge if not blts ???
  101.     blt    .noSub8
  102. .sub8:    addw    #16,sx
  103.  
  104.     fmovew    sx,u0
  105.     fmoves    #0r65536.0,w0
  106.     fmoves    _tmap+28,fp0
  107.     fsglmulx u0,fp0
  108.     faddx    prew,fp0
  109.     fsgldivx fp0,w0
  110.  
  111.     fmoves    _tmap+16,v0
  112.     fsglmulx u0,v0
  113.  
  114.     fsglmuls _tmap+4,u0
  115.  
  116.     faddx    prev,v0
  117.     faddx    preu,u0
  118.  
  119.     fsglmulx w0,v0
  120.     fsglmulx w0,u0
  121.     
  122.     fmovel    v0,dv
  123.     fmovel    u0,du
  124.  
  125.     movel    dv,storev
  126.     movel    du,storeu
  127.  
  128.     subl    v,dv
  129.     asrl    #4,dv
  130.     subl    u,du
  131.     asrl    #4,du
  132.     
  133.     |moveq    #16,count
  134.     moveq    #15,count
  135.     bsr    _draw_affine8
  136.  
  137.     movel    storev,v
  138.     movel    storeu,u
  139.     
  140.     dbra    slen,.sub8
  141. .noSub8:
  142.     |moveq    #0,count    | sometimes something in upper word
  143.     movew    len,count
  144.     andw    #0x000F,count
  145.     subqw    #1,count
  146.     blts    .noSpan8    | nothing to do
  147.     beqs    .noRest8    | avoid division by 0
  148.     addw    count,sx    | count is near 15 and sx smaller than 32767
  149.  
  150.     fmovew    sx,fp1
  151.     fmoves    #0r65536.0,w0    | v0 and u0 are scaled by 65536.0 on entry
  152.     fmoves    _tmap+28,fp0
  153.     fsglmulx fp1,fp0
  154.     faddx    prew,fp0
  155.     fsgldivx fp0,w0
  156.  
  157.     fmoves    _tmap+16,fp0    | tmap[4]
  158.     fsglmulx fp1,fp0    | sx * tmap[4]
  159.  
  160.     fsglmuls _tmap+4,fp1
  161.  
  162.     faddx    prev,fp0    | prev + sx * tmap[4]
  163.     faddx    preu,fp1
  164.  
  165.     fsglmulx w0,fp0        | (prev + sx * tmap[4]) * w1
  166.     fsglmulx w0,fp1
  167.  
  168.     fsubx    v0,fp0        | v1 - v0
  169.     fsubx    u0,fp1
  170.  
  171.     fsgldivw count,fp0
  172.     fsgldivw count,fp1
  173.  
  174.     fmovel    fp0,dv
  175.     fmovel    fp1,du
  176.     
  177. .noRest8:
  178.     |addqw    #1,count
  179.     bsrs    _draw_affine8
  180. .noSpan8:
  181.     fadds    _tmap+32,prew
  182.     fadds    _tmap+20,prev
  183.     fadds    _tmap+8,preu
  184.     addql    #1,y        | y++
  185.     dbra    ey,.bigLoop8
  186. .bigEnd8:
  187.     fmovem    sp@+,fp2-fp7
  188.     moveml    sp@+,d2-d4/d6-d7/a2-a3/a5-a6
  189.     rts
  190.     .even
  191.  
  192. _draw_affine8:
  193.     movew    _textureType,a1
  194.     cmpw    #1,a1
  195.     bnes    .noWall8
  196.     moveml    d5-d7,sp@-
  197.     movel    _texture,a1
  198.     movel    #0x0000FF00,d7            | from tables.h        ,MAX_MASKX
  199.     asrl    #8,v                | inaccurate but fast    ,16-MAX_LOGX
  200.     asrl    #8,dv                | inaccurate but fast    ,16-MAX_LOGX
  201. .wall8:
  202.     movel    u,d6
  203.     movel    v,d5
  204.     clrw    d6
  205.     swap    d6
  206.     andl    d7,d5                | nessecary? -> yep
  207.     moveb    _textureRow+3,d5
  208.     addl    @(_multTMap, d5:l:4),d6
  209.     moveb    a1@(d6:l:1),buf@+
  210.     addl    du,u
  211.     addl    dv,v    
  212.     dbra    count,.wall8
  213.     moveml    sp@+,d5-d7
  214.     rts
  215. .noWall8:
  216.     cmpw    #5,a1
  217.     bnes    .noSky8
  218.     moveml    d5-d7,sp@-
  219.     movel    _texture,a1
  220.     movew    #0x7F7F,d7
  221.     asrl    #8,u                | inaccurate but fast
  222.     asrl    #8,du                | inaccurate but fast
  223. .sky8:
  224.     movel    u,d6
  225.     movel    v,d5
  226.     swap    d5
  227.     moveb    d5,d6
  228.     movew    d6,d5
  229.     addw    _skyMovementX1+2,d6
  230.     addw    _skyMovementX2+2,d5
  231.     addb    _skyMovementY1+3,d6
  232.     addb    _skyMovementY2+3,d5
  233.     andw    d7,d6
  234.     andw    d7,d5
  235.     moveb    a1@(0x80, d6:w:1),d6
  236.     moveb    a1@(d5:w:1),d5
  237.     beqs    .skipSky8
  238.     moveb    d5,d6
  239. .skipSky8:
  240.     moveb    d6,buf@+
  241.     addl    du,u
  242.     addl    dv,v    
  243.     dbra    count,.sky8
  244.     moveml    sp@+,d5-d7
  245.     rts
  246. .noSky8:
  247.     moveml    a2/d5-d7,sp@-
  248.     movel    _texture,a1
  249.     movel    _preTransparency,a2
  250.     moveq    #0,d7            | nessecary ? (asr is faster then)
  251. .liquid8:
  252.     movew    _textureShift2,d7
  253.     movel    u,d6            | bfextu    u{d7:8},d6
  254.     movel    v,d5            | bfextu    v{d7:8},d5
  255.     asrl    d7,d6            | ...
  256.     asrl    d7,d5            | ...
  257.     andw    #0x00FF,d6        | ...
  258.     andw    #0x00FF,d5        | ...
  259.     movel    @(_swim_v, d6:w:4),d6
  260.     movel    @(_swim_u, d5:w:4),d5
  261.     movew    _textureMip,d7
  262.     asrl    d7,d6
  263.     asrl    d7,d5
  264.     addl    v,d6
  265.     addl    u,d5
  266.     movew    _textureShift1,d7
  267.     swap    d6
  268.     asrl    d7,d5
  269.     andl    _textureMask2,d6
  270.     andl    _textureMask1,d5
  271.     orl    d6,d5
  272.     |moveq    #0,d6            | d6 is not greater than 64*64, so the upper bits are 0
  273.     movew    buf@,d6
  274.     moveb    a1@(d5:w:1),d6
  275.     moveb    a2@(d6:l:1),buf@+
  276.     addl    du,u
  277.     addl    dv,v    
  278.     dbra    count,.liquid8
  279.     moveml    sp@+,a2/d5-d7
  280.     rts
  281.     ");
  282.