home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quake_src / r_sky68k.s < prev    next >
Text File  |  2000-06-17  |  4KB  |  130 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_sky.c assembler implementations by Frank Wille <frank@phoenix.owl.de>
  17. **
  18.  
  19.         XREF    _r_skymade
  20.         XREF    _bottommask
  21.         XREF    _bottomsky
  22.         XREF    _newsky
  23.         XREF    _skytime
  24.         XREF    _skyspeed
  25.  
  26.  
  27.         XDEF    _R_MakeSky
  28.  
  29. SKYSHIFT                =       7
  30. SKYSIZE                 =       (1 << SKYSHIFT)
  31. SKYMASK                 =       (SKYSIZE - 1)
  32.  
  33.  
  34. ******************************************************************************
  35. *
  36. *       void R_MakeSky (void)
  37. *
  38. *       This function contains unaligned accesses to longwords (supported
  39. *       by 68K)
  40. *
  41. ******************************************************************************
  42.  
  43.         cnop    0,4
  44. _R_MakeSky
  45.  
  46. *        xshift = skytime*skyspeed;
  47. *        yshift = skytime*skyspeed;
  48. *
  49. *        if ((xshift == xlast) && (yshift == ylast))
  50. *                return;
  51. *
  52. *        xlast = xshift;
  53. *        ylast = yshift;
  54. *
  55. *        pnewsky = (unsigned *)&newsky[0];
  56.  
  57.         movem.l d2-d5/a2,-(sp)
  58.         lea     _bottommask,a1
  59.         lea     _bottomsky,a2
  60.         fmove.s _skytime,fp0            ;xshift = skytime*skyspeed
  61.         fmul.s  _skyspeed,fp0
  62.         fmove.l fp0,d0
  63.         cmp.l   _xlast,d0               ;if (xshift==xlast)&&(yshift==ylast)
  64.         bne.b   .cont
  65.         cmp.l   _ylast,d0
  66.         beq.b   .exit                   ;return
  67. .cont
  68.         move.l  d0,_xlast               ;_xlast = xshift
  69.         move.l  d0,_ylast               ;_ylast = yshift
  70.         lea     _newsky,a0              ;pnewsky = (unsigned *)&newsky[0]
  71.  
  72. *        for (y=0 ; y<SKYSIZE ; y++)
  73. *        {
  74. *                baseofs = ((y+yshift) & SKYMASK) * 131;
  75. *
  76. *                for (x=0 ; x<SKYSIZE ; x += 4)
  77. *                {
  78. *                        ofs = baseofs + ((x+xshift) & SKYMASK);
  79. *
  80. *                // PORT: unaligned dword access to bottommask and bottomsky
  81. *
  82. *                        *pnewsky = (*(pnewsky + (128 / sizeof (unsigned))) &
  83. *                                                *(unsigned *)&bottommask[ofs]) |
  84. *                                                *(unsigned *)&bottomsky[ofs];
  85. *                        pnewsky++;
  86. *                }
  87. *
  88. *                pnewsky += 128 / sizeof (unsigned);
  89. *        }
  90. *
  91. *        r_skymade = 1;
  92.  
  93.  
  94.         moveq   #0,d1
  95. .loop
  96.         move.l  d1,d2
  97.         add.l   d0,d2                   ;d2 = y+yshift
  98.         and.l   #SKYMASK,d2             ;d2 = (y+yshift)&SKYMASK
  99.         muls    #131,d2                 ;baseofs = d2 * 131
  100.         moveq   #0,d3
  101. .loop2
  102.         move.l  d3,d4
  103.         add.l   d0,d4                   ;d3 = x+xshift
  104.         and.l   #SKYMASK,d4             ;d3 = (x+xshift)&SKYMASK
  105.         add.l   d2,d4                   ;ofs = baseofs + d3
  106.         move.l  0(a1,d4.l),d5           ;*(unsigned *)&bottommask[ofs]
  107.         and.l   128(a0),d5              ;& (*(pnewsky + (128/sizeof(unsigned)))
  108.         or.l    0(a2,d4.l),d5           ;| *(unsigned *)&bottomsky[ofs]
  109.         move.l  d5,(a0)+                ;*pnewsky = d5; pnewsky++
  110.         addq.l  #4,d3                   ;x += 4
  111.         cmp.l   #SKYSIZE,d3
  112.         blt.b   .loop2
  113.         lea     128(a0),a0              ;pnewsky += 128/sizeof(unsigned)
  114.         addq.l  #1,d1                   ;y++
  115.         cmp.l   #SKYSIZE,d1
  116.         blt.b   .loop
  117.         move.b  #1,_r_skymade           ;r_skymade = 1
  118. .exit
  119.         movem.l (sp)+,d2-d5/a2
  120.         rts
  121.  
  122. _xlast          dc.l    -1
  123. _ylast          dc.l    -1
  124.