gfxdrawbmp4.pas

来自「一个不出名的GBA模拟器」· PAS 代码 · 共 81 行

PAS
81
字号
//////////////////////////////////////////////////////////////////////
//                                                                  //
// gfxDrawBMP4.pas: Render metacode for the mode 4 framebuffer      //
//                                                                  //
// 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: integer;
  pix: uint16;
  a, c, cx, cy: uint32;
  dx, dy, base: 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;

  // Choose the appropriate framebuffer
  if registers[DISPLAY_CR] and DISPLAY_CR_FB <> 0 then base := DISP_FB1_START else base := DISP_FB0_START;

  // Render the screen
  x := 0;
  if wrap then begin
    while x < 240 do begin
      // Wrap the position around
      // eew: mod's in an innerloop, I must be crazy
      if dx >= 240 shl 8 then dx := dx mod (240 shl 8);
      if dy >= 160 shl 8 then dy := dy mod (160 shl 8);

      pix := VRAM[base + dx shr 8 + (dy shr 8)*240];
      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 < 240 do begin
      // Deadspace
      if (dx >= 240 shl 8) or (dy >= 160 shl 8) then pix := 0 else pix := VRAM[base + dx shr 8 + (dy shr 8)*240];

      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 + =
减小字号Ctrl + -
显示快捷键?