home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quake_src / r_surf68k.s < prev    next >
Encoding:
Text File  |  2000-06-17  |  8.0 KB  |  392 lines

  1. * Copyright (C) 1996-1997 Id Software, Inc. 
  2. * This program is free software; you can redistribute it and/or 
  3. * modify it under the terms of the GNU General Public License 
  4. * as published by the Free Software Foundation; either version 2 
  5. * of the License, or (at your option) any later version. 
  6. * This program is distributed in the hope that it will be useful, 
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of 
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   
  9. * See the GNU General Public License for more details. 
  10. * You should have received a copy of the GNU General Public License 
  11. * along with this program; if not, write to the Free Software 
  12. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
  13.  
  14. **
  15. ** Quake for AMIGA
  16. ** r_surf.c assembler implementations by Frank Wille <frank@phoenix.owl.de>
  17. **
  18.  
  19. ; viddef_t
  20.         rsreset
  21. buffer        rs.l    1
  22. colormap    rs.l    1
  23. ; etc...
  24.  
  25.  
  26.     code
  27.  
  28.     xref    _pbasesource
  29.     xref    _prowdestbase
  30.     xref    _r_numvblocks
  31.     xref    _r_lightptr
  32.     xref    _r_lightwidth
  33.     xref    _sourcetstep
  34.     xref    _surfrowbytes
  35.     xref    _r_sourcemax
  36.     xref    _r_stepback
  37.     xref    _vid
  38.  
  39.  
  40.     xdef    _R_DrawSurfaceBlock8_mip0
  41.     cnop    0,4
  42. _R_DrawSurfaceBlock8_mip0:
  43.     movem.l    d1-d7/a2-a6,-(sp)
  44.     setso    0
  45. .v    so.l    1            ; saved d1-field is used as .v
  46.  
  47.     move.l    _vid+colormap,a4
  48.     move.l    _sourcetstep,a5
  49.     move.l    _surfrowbytes,a6
  50.  
  51. ; psource = pbasesource;
  52. ; prowdest = prowdestbase;
  53.     move.l    _pbasesource,a2        ; a2 psource
  54.     move.l    _prowdestbase,a3    ; a3 prowdest
  55.  
  56. ; for (v=0 ; v<r_numvblocks ; v++) {
  57.     move.l    _r_numvblocks,(sp)    ; .v
  58.     beq    .quit
  59.  
  60. .vloop:
  61. ; lightleft = r_lightptr[0];
  62. ; lightright = r_lightptr[1];
  63.     move.l    _r_lightptr,a0
  64.     move.l    (a0)+,d6        ; d6 lightleft
  65.     move.l    (a0),d7            ; d7 lightright
  66.  
  67. ; r_lightptr += r_lightwidth;
  68. ; lightleftstep = (r_lightptr[0] - lightleft) >> 4;
  69. ; lightrightstep = (r_lightptr[1] - lightright) >> 4;
  70.     move.l    _r_lightwidth,d0
  71.     lea    -4(a0,d0.l*4),a0
  72.     move.l    a0,_r_lightptr
  73.     move.l    (a0)+,d1
  74.     sub.l    d6,d1
  75.     lsr.l    #4,d1            ; d1 lightleftstep
  76.     move.l    (a0),d2
  77.     sub.l    d7,d2
  78.     lsr.l    #4,d2            ; d2 lightrightstep
  79.  
  80. ; for (i=0 ; i<16 ; i++) {
  81.     moveq    #15,d5
  82.  
  83. ; lighttemp = lightleft - lightright;
  84. ; lightstep = lighttemp >> 4;
  85. ; light = lightright;
  86. .1:    move.l    d6,d4
  87.     sub.l    d7,d4
  88.     lsr.l    #4,d4            ; d4 lightstep
  89.     move.l    d7,d3            ; d3 light
  90.  
  91. ; for (b=15; b>=0; b--) {
  92.     moveq    #16,d0
  93.     add.w    d0,a2
  94.     add.w    d0,a3
  95.  
  96. ; pix = psource[b];
  97. ; prowdest[b] = ((unsigned char *)vid.colormap)[(light & 0xFF00) + pix];
  98. ; light += lightstep;
  99.     REPT    16
  100.     move.w    d3,d0
  101.     move.b    -(a2),d0
  102.     move.b    (a4,d0.l),-(a3)
  103.     add.l    d4,d3
  104.     ENDR
  105.  
  106. ; psource += sourcetstep;
  107. ; lightright += lightrightstep;
  108. ; lightleft += lightleftstep;
  109. ; prowdest += surfrowbytes;
  110.     add.l    a5,a2
  111.     add.l    a6,a3
  112.     add.l    d1,d6
  113.     add.l    d2,d7
  114.     dbf    d5,.1
  115.  
  116. ; if (psource >= r_sourcemax) psource -= r_stepback;
  117.     cmp.l    _r_sourcemax,a2
  118.     blo.b    .2
  119.     sub.l    _r_stepback,a2
  120.  
  121. .2:    subq.l    #1,(sp)            ; .v
  122.     bne    .vloop
  123. .quit:    movem.l    (sp)+,d1-d7/a2-a6
  124.     rts
  125.  
  126.  
  127.     xdef    _R_DrawSurfaceBlock8_mip1
  128.     cnop    0,4
  129. _R_DrawSurfaceBlock8_mip1:
  130.     movem.l    d1-d7/a2-a6,-(sp)
  131.     setso    0
  132. .v    so.l    1            ; saved d1-field is used as .v
  133.  
  134.     move.l    _vid+colormap,a4
  135.     move.l    _sourcetstep,a5
  136.     move.l    _surfrowbytes,a6
  137.  
  138. ; psource = pbasesource;
  139. ; prowdest = prowdestbase;
  140.     move.l    _pbasesource,a2        ; a2 psource
  141.     move.l    _prowdestbase,a3    ; a3 prowdest
  142.  
  143. ; for (v=0 ; v<r_numvblocks ; v++) {
  144.     move.l    _r_numvblocks,(sp)    ; .v
  145.     beq    .quit
  146.  
  147. .vloop:
  148. ; lightleft = r_lightptr[0];
  149. ; lightright = r_lightptr[1];
  150.     move.l    _r_lightptr,a0
  151.     move.l    (a0)+,d6        ; d6 lightleft
  152.     move.l    (a0),d7            ; d7 lightright
  153.  
  154. ; r_lightptr += r_lightwidth;
  155. ; lightleftstep = (r_lightptr[0] - lightleft) >> 3;
  156. ; lightrightstep = (r_lightptr[1] - lightright) >> 3;
  157.     move.l    _r_lightwidth,d0
  158.     lea    -4(a0,d0.l*4),a0
  159.     move.l    a0,_r_lightptr
  160.     move.l    (a0)+,d1
  161.     sub.l    d6,d1
  162.     lsr.l    #3,d1            ; d1 lightleftstep
  163.     move.l    (a0),d2
  164.     sub.l    d7,d2
  165.     lsr.l    #3,d2            ; d2 lightrightstep
  166.  
  167. ; for (i=0 ; i<8 ; i++) {
  168.     moveq    #7,d5
  169.  
  170. ; lighttemp = lightleft - lightright;
  171. ; lightstep = lighttemp >> 3;
  172. ; light = lightright;
  173. .1:    move.l    d6,d4
  174.     sub.l    d7,d4
  175.     lsr.l    #3,d4            ; d4 lightstep
  176.     move.l    d7,d3            ; d3 light
  177.  
  178. ; for (b=7; b>=0; b--) {
  179.     moveq    #8,d0
  180.     add.w    d0,a2
  181.     add.w    d0,a3
  182.  
  183. ; pix = psource[b];
  184. ; prowdest[b] = ((unsigned char *)vid.colormap)[(light & 0xFF00) + pix];
  185. ; light += lightstep;
  186.     REPT    8
  187.     move.w    d3,d0
  188.     move.b    -(a2),d0
  189.     move.b    (a4,d0.l),-(a3)
  190.     add.l    d4,d3
  191.     ENDR
  192.  
  193. ; psource += sourcetstep;
  194. ; lightright += lightrightstep;
  195. ; lightleft += lightleftstep;
  196. ; prowdest += surfrowbytes;
  197.     add.l    a5,a2
  198.     add.l    a6,a3
  199.     add.l    d1,d6
  200.     add.l    d2,d7
  201.     dbf    d5,.1
  202.  
  203. ; if (psource >= r_sourcemax) psource -= r_stepback;
  204.     cmp.l    _r_sourcemax,a2
  205.     blo.b    .2
  206.     sub.l    _r_stepback,a2
  207.  
  208. .2:    subq.l    #1,(sp)            ; .v
  209.     bne    .vloop
  210. .quit:    movem.l    (sp)+,d1-d7/a2-a6
  211.     rts
  212.  
  213.  
  214.     xdef    _R_DrawSurfaceBlock8_mip2
  215.     cnop    0,4
  216. _R_DrawSurfaceBlock8_mip2:
  217.     movem.l    d1-d7/a2-a6,-(sp)
  218.     setso    0
  219. .v    so.l    1            ; saved d1-field is used as .v
  220.  
  221.     move.l    _vid+colormap,a4
  222.     move.l    _sourcetstep,a5
  223.     move.l    _surfrowbytes,a6
  224.  
  225. ; psource = pbasesource;
  226. ; prowdest = prowdestbase;
  227.     move.l    _pbasesource,a2        ; a2 psource
  228.     move.l    _prowdestbase,a3    ; a3 prowdest
  229.  
  230. ; for (v=0 ; v<r_numvblocks ; v++) {
  231.     move.l    _r_numvblocks,(sp)    ; .v
  232.     beq    .quit
  233.  
  234. .vloop:
  235. ; lightleft = r_lightptr[0];
  236. ; lightright = r_lightptr[1];
  237.     move.l    _r_lightptr,a0
  238.     move.l    (a0)+,d6        ; d6 lightleft
  239.     move.l    (a0),d7            ; d7 lightright
  240.  
  241. ; r_lightptr += r_lightwidth;
  242. ; lightleftstep = (r_lightptr[0] - lightleft) >> 2;
  243. ; lightrightstep = (r_lightptr[1] - lightright) >> 2;
  244.     move.l    _r_lightwidth,d0
  245.     lea    -4(a0,d0.l*4),a0
  246.     move.l    a0,_r_lightptr
  247.     move.l    (a0)+,d1
  248.     sub.l    d6,d1
  249.     lsr.l    #2,d1            ; d1 lightleftstep
  250.     move.l    (a0),d2
  251.     sub.l    d7,d2
  252.     lsr.l    #2,d2            ; d2 lightrightstep
  253.  
  254. ; for (i=0 ; i<4 ; i++) {
  255.     moveq    #3,d5
  256.  
  257. ; lighttemp = lightleft - lightright;
  258. ; lightstep = lighttemp >> 3;
  259. ; light = lightright;
  260. .1:    move.l    d6,d4
  261.     sub.l    d7,d4
  262.     lsr.l    #2,d4            ; d4 lightstep
  263.     move.l    d7,d3            ; d3 light
  264.  
  265. ; for (b=3; b>=0; b--) {
  266.     moveq    #4,d0
  267.     add.w    d0,a2
  268.     add.w    d0,a3
  269.  
  270. ; pix = psource[b];
  271. ; prowdest[b] = ((unsigned char *)vid.colormap)[(light & 0xFF00) + pix];
  272. ; light += lightstep;
  273.     REPT    4
  274.     move.w    d3,d0
  275.     move.b    -(a2),d0
  276.     move.b    (a4,d0.l),-(a3)
  277.     add.l    d4,d3
  278.     ENDR
  279.  
  280. ; psource += sourcetstep;
  281. ; lightright += lightrightstep;
  282. ; lightleft += lightleftstep;
  283. ; prowdest += surfrowbytes;
  284.     add.l    a5,a2
  285.     add.l    a6,a3
  286.     add.l    d1,d6
  287.     add.l    d2,d7
  288.     dbf    d5,.1
  289.  
  290. ; if (psource >= r_sourcemax) psource -= r_stepback;
  291.     cmp.l    _r_sourcemax,a2
  292.     blo.b    .2
  293.     sub.l    _r_stepback,a2
  294.  
  295. .2:    subq.l    #1,(sp)            ; .v
  296.     bne    .vloop
  297. .quit:    movem.l    (sp)+,d1-d7/a2-a6
  298.     rts
  299.  
  300.  
  301.     xdef    _R_DrawSurfaceBlock8_mip3
  302.     cnop    0,4
  303. _R_DrawSurfaceBlock8_mip3:
  304.     movem.l    d1-d7/a2-a6,-(sp)
  305.     setso    0
  306. .v    so.l    1            ; saved d1-field is used as .v
  307.  
  308.     move.l    _vid+colormap,a4
  309.     move.l    _sourcetstep,a5
  310.     move.l    _surfrowbytes,a6
  311.  
  312. ; psource = pbasesource;
  313. ; prowdest = prowdestbase;
  314.     move.l    _pbasesource,a2        ; a2 psource
  315.     move.l    _prowdestbase,a3    ; a3 prowdest
  316.  
  317. ; for (v=0 ; v<r_numvblocks ; v++) {
  318.     move.l    _r_numvblocks,(sp)    ; .v
  319.     beq    .quit
  320.  
  321. .vloop:
  322. ; lightleft = r_lightptr[0];
  323. ; lightright = r_lightptr[1];
  324.     move.l    _r_lightptr,a0
  325.     move.l    (a0)+,d6        ; d6 lightleft
  326.     move.l    (a0),d7            ; d7 lightright
  327.  
  328. ; r_lightptr += r_lightwidth;
  329. ; lightleftstep = (r_lightptr[0] - lightleft) >> 1;
  330. ; lightrightstep = (r_lightptr[1] - lightright) >> 1;
  331.     move.l    _r_lightwidth,d0
  332.     lea    -4(a0,d0.l*4),a0
  333.     move.l    a0,_r_lightptr
  334.     move.l    (a0)+,d1
  335.     sub.l    d6,d1
  336.     lsr.l    #1,d1            ; d1 lightleftstep
  337.     move.l    (a0),d2
  338.     sub.l    d7,d2
  339.     lsr.l    #1,d2            ; d2 lightrightstep
  340.  
  341. ; for (i=0 ; i<2 ; i++) {
  342.     moveq    #1,d5
  343.  
  344. ; lighttemp = lightleft - lightright;
  345. ; lightstep = lighttemp >> 1;
  346. ; light = lightright;
  347. .1:    move.l    d6,d4
  348.     sub.l    d7,d4
  349.     lsr.l    #1,d4            ; d4 lightstep
  350.     move.l    d7,d3            ; d3 light
  351.  
  352. ; for (b=1; b>=0; b--) {
  353.     moveq    #2,d0
  354.     add.w    d0,a2
  355.     add.w    d0,a3
  356.  
  357. ; pix = psource[b];
  358. ; prowdest[b] = ((unsigned char *)vid.colormap)[(light & 0xFF00) + pix];
  359. ; light += lightstep;
  360.     REPT    2
  361.     move.w    d3,d0
  362.     move.b    -(a2),d0
  363.     move.b    (a4,d0.l),-(a3)
  364.     add.l    d4,d3
  365.     ENDR
  366.  
  367. ; psource += sourcetstep;
  368. ; lightright += lightrightstep;
  369. ; lightleft += lightleftstep;
  370. ; prowdest += surfrowbytes;
  371.     add.l    a5,a2
  372.     add.l    a6,a3
  373.     add.l    d1,d6
  374.     add.l    d2,d7
  375.     dbf    d5,.1
  376.  
  377. ; if (psource >= r_sourcemax) psource -= r_stepback;
  378.     cmp.l    _r_sourcemax,a2
  379.     blo.b    .2
  380.     sub.l    _r_stepback,a2
  381.  
  382. .2:    subq.l    #1,(sp)            ; .v
  383.     bne    .vloop
  384. .quit:    movem.l    (sp)+,d1-d7/a2-a6
  385.     rts
  386.