/***********************************************************************************1Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.23(c) Copyright 1996 - 2002 Gary Henderson ([email protected]),4Jerremy Koot ([email protected])56(c) Copyright 2002 - 2004 Matthew Kendora78(c) Copyright 2002 - 2005 Peter Bortas ([email protected])910(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)1112(c) Copyright 2001 - 2006 John Weidman ([email protected])1314(c) Copyright 2002 - 2006 funkyass ([email protected]),15Kris Bleakley ([email protected])1617(c) Copyright 2002 - 2010 Brad Jorsch ([email protected]),18Nach ([email protected]),1920(c) Copyright 2002 - 2011 zones ([email protected])2122(c) Copyright 2006 - 2007 nitsuja2324(c) Copyright 2009 - 2011 BearOso,25OV2262728BS-X C emulator code29(c) Copyright 2005 - 2006 Dreamer Nom,30zones3132C4 x86 assembler and some C emulation code33(c) Copyright 2000 - 2003 _Demo_ ([email protected]),34Nach,35zsKnight ([email protected])3637C4 C++ code38(c) Copyright 2003 - 2006 Brad Jorsch,39Nach4041DSP-1 emulator code42(c) Copyright 1998 - 2006 _Demo_,43Andreas Naive ([email protected]),44Gary Henderson,45Ivar ([email protected]),46John Weidman,47Kris Bleakley,48Matthew Kendora,49Nach,50neviksti ([email protected])5152DSP-2 emulator code53(c) Copyright 2003 John Weidman,54Kris Bleakley,55Lord Nightmare ([email protected]),56Matthew Kendora,57neviksti5859DSP-3 emulator code60(c) Copyright 2003 - 2006 John Weidman,61Kris Bleakley,62Lancer,63z80 gaiden6465DSP-4 emulator code66(c) Copyright 2004 - 2006 Dreamer Nom,67John Weidman,68Kris Bleakley,69Nach,70z80 gaiden7172OBC1 emulator code73(c) Copyright 2001 - 2004 zsKnight,74pagefault ([email protected]),75Kris Bleakley76Ported from x86 assembler to C by sanmaiwashi7778SPC7110 and RTC C++ emulator code used in 1.39-1.5179(c) Copyright 2002 Matthew Kendora with research by80zsKnight,81John Weidman,82Dark Force8384SPC7110 and RTC C++ emulator code used in 1.52+85(c) Copyright 2009 byuu,86neviksti8788S-DD1 C emulator code89(c) Copyright 2003 Brad Jorsch with research by90Andreas Naive,91John Weidman9293S-RTC C emulator code94(c) Copyright 2001 - 2006 byuu,95John Weidman9697ST010 C++ emulator code98(c) Copyright 2003 Feather,99John Weidman,100Kris Bleakley,101Matthew Kendora102103Super FX x86 assembler emulator code104(c) Copyright 1998 - 2003 _Demo_,105pagefault,106zsKnight107108Super FX C emulator code109(c) Copyright 1997 - 1999 Ivar,110Gary Henderson,111John Weidman112113Sound emulator code used in 1.5-1.51114(c) Copyright 1998 - 2003 Brad Martin115(c) Copyright 1998 - 2006 Charles Bilyue'116117Sound emulator code used in 1.52+118(c) Copyright 2004 - 2007 Shay Green ([email protected])119120SH assembler code partly based on x86 assembler code121(c) Copyright 2002 - 2004 Marcus Comstedt ([email protected])1221232xSaI filter124(c) Copyright 1999 - 2001 Derek Liauw Kie Fa125126HQ2x, HQ3x, HQ4x filters127(c) Copyright 2003 Maxim Stepin ([email protected])128129NTSC filter130(c) Copyright 2006 - 2007 Shay Green131132GTK+ GUI code133(c) Copyright 2004 - 2011 BearOso134135Win32 GUI code136(c) Copyright 2003 - 2006 blip,137funkyass,138Matthew Kendora,139Nach,140nitsuja141(c) Copyright 2009 - 2011 OV2142143Mac OS GUI code144(c) Copyright 1998 - 2001 John Stiles145(c) Copyright 2001 - 2011 zones146147148Specific ports contains the works of other authors. See headers in149individual files.150151152Snes9x homepage: http://www.snes9x.com/153154Permission to use, copy, modify and/or distribute Snes9x in both binary155and source form, for non-commercial purposes, is hereby granted without156fee, providing that this license information and copyright notice appear157with all copies and any derived work.158159This software is provided 'as-is', without any express or implied160warranty. In no event shall the authors be held liable for any damages161arising from the use of this software or it's derivatives.162163Snes9x is freeware for PERSONAL USE only. Commercial users should164seek permission of the copyright holders first. Commercial use includes,165but is not limited to, charging money for Snes9x or software derived from166Snes9x, including Snes9x or derivatives in commercial game bundles, and/or167using Snes9x as a promotion for your commercial product.168169The copyright holders request that bug fixes and improvements to the code170should be forwarded to them so everyone can benefit from the modifications171in future versions.172173Super NES and Super Nintendo Entertainment System are trademarks of174Nintendo Co., Limited and its subsidiary companies.175***********************************************************************************/176177178#ifndef _GFX_H_179#define _GFX_H_180181struct SGFX182{183uint16 *Screen;184uint16 *SubScreen;185uint8 *ZBuffer;186uint8 *SubZBuffer;187uint32 Pitch;188uint32 ScreenSize;189uint16 *S;190uint8 *DB;191uint16 *X2;192uint16 *ZERO;193uint32 RealPPL; // true PPL of Screen buffer194uint32 PPL; // number of pixels on each of Screen buffer195uint32 LinesPerTile; // number of lines in 1 tile (4 or 8 due to interlace)196uint16 *ScreenColors; // screen colors for rendering main197uint16 *RealScreenColors; // screen colors, ignoring color window clipping198uint8 Z1; // depth for comparison199uint8 Z2; // depth to save200uint32 FixedColour;201uint8 DoInterlace;202uint8 InterlaceFrame;203uint32 StartY;204uint32 EndY;205bool8 ClipColors;206uint8 OBJWidths[128];207uint8 OBJVisibleTiles[128];208209struct ClipData *Clip;210211struct212{213uint8 RTOFlags;214int16 Tiles;215216struct217{218int8 Sprite;219uint8 Line;220} OBJ[32];221} OBJLines[SNES_HEIGHT_EXTENDED];222223#ifdef GFX_MULTI_FORMAT224uint32 PixelFormat;225uint32 (*BuildPixel) (uint32, uint32, uint32);226uint32 (*BuildPixel2) (uint32, uint32, uint32);227void (*DecomposePixel) (uint32, uint32 &, uint32 &, uint32 &);228#endif229230void (*DrawBackdropMath) (uint32, uint32, uint32);231void (*DrawBackdropNomath) (uint32, uint32, uint32);232void (*DrawTileMath) (uint32, uint32, uint32, uint32);233void (*DrawTileNomath) (uint32, uint32, uint32, uint32);234void (*DrawClippedTileMath) (uint32, uint32, uint32, uint32, uint32, uint32);235void (*DrawClippedTileNomath) (uint32, uint32, uint32, uint32, uint32, uint32);236void (*DrawMosaicPixelMath) (uint32, uint32, uint32, uint32, uint32, uint32);237void (*DrawMosaicPixelNomath) (uint32, uint32, uint32, uint32, uint32, uint32);238void (*DrawMode7BG1Math) (uint32, uint32, int);239void (*DrawMode7BG1Nomath) (uint32, uint32, int);240void (*DrawMode7BG2Math) (uint32, uint32, int);241void (*DrawMode7BG2Nomath) (uint32, uint32, int);242243const char *InfoString;244uint32 InfoStringTimeout;245char FrameDisplayString[256];246};247248struct SBG249{250uint8 (*ConvertTile) (uint8 *, uint32, uint32);251uint8 (*ConvertTileFlip) (uint8 *, uint32, uint32);252253uint32 TileSizeH;254uint32 TileSizeV;255uint32 OffsetSizeH;256uint32 OffsetSizeV;257uint32 TileShift;258uint32 TileAddress;259uint32 NameSelect;260uint32 SCBase;261262uint32 StartPalette;263uint32 PaletteShift;264uint32 PaletteMask;265uint8 EnableMath;266uint8 InterlaceLine;267268uint8 *Buffer;269uint8 *BufferFlip;270uint8 *Buffered;271uint8 *BufferedFlip;272bool8 DirectColourMode;273};274275struct SLineData276{277struct278{279uint16 VOffset;280uint16 HOffset;281} BG[4];282};283284struct SLineMatrixData285{286short MatrixA;287short MatrixB;288short MatrixC;289short MatrixD;290short CentreX;291short CentreY;292short M7HOFS;293short M7VOFS;294};295296extern uint16 BlackColourMap[256];297extern uint16 DirectColourMaps[8][256];298extern uint8 mul_brightness[16][32];299extern struct SBG BG;300extern struct SGFX GFX;301302#define H_FLIP 0x4000303#define V_FLIP 0x8000304#define BLANK_TILE 2305306#define COLOR_ADD1_2(C1, C2) \307((((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \308((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \309((C1) & (C2) & RGB_LOW_BITS_MASK)) | ALPHA_BITS_MASK)310311#define COLOR_ADD(C1, C2) \312(GFX.X2[((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \313((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \314((C1) & (C2) & RGB_LOW_BITS_MASK)] | \315(((C1) ^ (C2)) & RGB_LOW_BITS_MASK))316317#define COLOR_SUB1_2(C1, C2) \318GFX.ZERO[(((C1) | RGB_HI_BITS_MASKx2) - \319((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]320321inline uint16 COLOR_SUB (uint16 C1, uint16 C2)322{323uint16 mC1, mC2, v = ALPHA_BITS_MASK;324325mC1 = C1 & FIRST_COLOR_MASK;326mC2 = C2 & FIRST_COLOR_MASK;327if (mC1 > mC2) v += (mC1 - mC2);328329mC1 = C1 & SECOND_COLOR_MASK;330mC2 = C2 & SECOND_COLOR_MASK;331if (mC1 > mC2) v += (mC1 - mC2);332333mC1 = C1 & THIRD_COLOR_MASK;334mC2 = C2 & THIRD_COLOR_MASK;335if (mC1 > mC2) v += (mC1 - mC2);336337return (v);338}339340void S9xStartScreenRefresh (void);341void S9xEndScreenRefresh (void);342void S9xUpdateScreen (void);343void S9xBuildDirectColourMaps (void);344void RenderLine (uint8);345void S9xComputeClipWindows (void);346void S9xDisplayChar (uint16 *, uint8);347// called automatically unless Settings.AutoDisplayMessages is false348void S9xDisplayMessages (uint16 *, int, int, int, int);349#ifdef GFX_MULTI_FORMAT350bool8 S9xSetRenderPixelFormat (int);351#endif352353// external port interface which must be implemented or initialised for each port354bool8 S9xGraphicsInit (void);355void S9xGraphicsDeinit (void);356bool8 S9xInitUpdate (void);357bool8 S9xDeinitUpdate (int, int);358bool8 S9xContinueUpdate (int, int);359void S9xReRefresh (void);360void S9xSetPalette (void);361void S9xSyncSpeed (void);362363// called instead of S9xDisplayString if set to non-NULL364extern void (*S9xCustomDisplayString) (const char *, int, int, bool);365366#endif367368369