⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gfxdrawrotscale.pas

📁 一个不出名的GBA模拟器
💻 PAS
字号:
//////////////////////////////////////////////////////////////////////
//                                                                  //
// gfxDrawRotScale.pas: Render metacode for rot/scale backgrounds   //
//                                                                  //
// The contents of this file are subject to the Bottled Light       //
// Public License Version 1.0 (the "License"); you may not use this //
// file except in compliance with the License. You may obtain a     //
// copy of the License at http://www.bottledlight.com/BLPL/         //
//                                                                  //
// Software distributed under the License is distributed on an      //
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or   //
// implied. See the License for the specific language governing     //
// rights and limitations under the License.                        //
//                                                                  //
// The Original Code is the Mappy VM Core, released April 1st, 2003 //
// The Initial Developer of the Original Code is Bottled Light,     //
// Inc. Portions created by Bottled Light, Inc. are Copyright       //
// (C) 2001 - 2003 Bottled Light, Inc. All Rights Reserved.         //
//                                                                  //
// Author(s):                                                       //
//   Michael Noland (joat), michael@bottledlight.com                //
//                                                                  //
// Changelog:                                                       //
//   1.0: First public release (April 1st, 2003)                    //
//                                                                  //
//////////////////////////////////////////////////////////////////////

var
  temp: uint32;
  x, pix: uint16;
  w, haww: integer;
  dx, dy: integer;
  base, charbase: integer;
  a, c, cx, cy: uint32;
  wrap: boolean;
{$INCLUDE gfxDrawPixelInc.pas}

  wrap := CR and RS_BG_WRAP <> 0;

  // Read the coords
  a := params.a;
  c := params.c;
  dx := params.cx;
  dy := params.cy;

  // Calculate the size of the screen
  w := 16 shl (CR shr 14);
  haww := 4 + CR shr 14;

  // Calculate the map and data addresses in VRAM
  base := ((CR shr 8) and $1F) * $800;
  charbase := ((CR shr 2) and $3) * $4000;

  // Render
  x := 0;
  w := (w shl 3) shl 8 - 1;
  if wrap then begin
    while x < gfxScreenWidth do begin
      // Wrap the position around
      dx := dx and w;
      dy := dy and w;

      // Look up the appropiate tile and then pixel
      pix := VRAM[base + ((dy shr 8) shr 3) shl haww + (dx shr 8) shr 3];
      pix := VRAM[charbase + ((dy shr 8) and 7) shl 3 + (dx shr 8) and 7 + pix shl 6];

      if (pix <> 0) and (wins^ and mask <> 0) or ((pix = 0) and (not latchXparent) and (mclock > 0)) then begin
        pix := Puint16(@(palette[pix shl 1]))^;
      {$INCLUDE gfxDrawPixel.pas}

      Inc(dx, a);
      Inc(dy, c);
      Inc(x);
    end;
  end else begin
    while x < gfxScreenWidth do begin
      // Deadspace
      if (dx > w) or (dy > w) or (dx < 0) or (dy < 0) then
        pix := 0
      else begin
        // Look up the appropiate tile and then pixel
        pix := VRAM[base + ((dy shr 8) shr 3) shl haww + (dx shr 8) shr 3];
        pix := VRAM[charbase + ((dy shr 8) and 7) shl 3 + (dx shr 8) and 7 + pix shl 6];
      end;

      if (pix <> 0) and (wins^ and mask <> 0) or ((pix = 0) and (not latchXparent) and (mclock > 0)) then begin
        pix := Puint16(@(palette[pix shl 1]))^;
      {$INCLUDE gfxDrawPixel.pas}

      Inc(dx, a);
      Inc(dy, c);
      Inc(x);
    end;
  end;
end; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -