1 /*
2 Copyright (C) 2002 Rice1964
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 
18 */
19 
20 #ifndef _DLLINTERFACE_H_
21 #define _DLLINTERFACE_H_
22 
23 #define M64P_PLUGIN_PROTOTYPES 1
24 #include "typedefs.h"
25 #include "m64p_config.h"
26 #include "m64p_plugin.h"
27 #include "m64p_vidext.h"
28 
29 typedef struct {
30     float   fViWidth, fViHeight;
31     unsigned short        uViWidth, uViHeight;
32     unsigned short        uDisplayWidth, uDisplayHeight;
33 
34     bool    bVerticalSync;
35 
36     float   fMultX, fMultY;
37     int     vpLeftW, vpTopW, vpRightW, vpBottomW, vpWidthW, vpHeightW;
38 
39     struct {
40         uint32_t      left;
41         uint32_t      top;
42         uint32_t      right;
43         uint32_t      bottom;
44         uint32_t      width;
45         uint32_t      height;
46         bool        needToClip;
47     } clipping;
48 
49     int     timer;
50     float   fps;    // frame per second
51     float   dps;    // dlist per second
52     uint32_t  lastSecFrameCount;
53     uint32_t  lastSecDlistCount;
54 }WindowSettingStruct;
55 
56 typedef enum
57 {
58     PRIM_TRI1,
59     PRIM_TRI2,
60     PRIM_TRI3,
61     PRIM_DMA_TRI,
62     PRIM_LINE3D,
63     PRIM_TEXTRECT,
64     PRIM_TEXTRECTFLIP,
65     PRIM_FILLRECT,
66 } PrimitiveType;
67 
68 typedef enum
69 {
70     RSP_SCISSOR,
71     RDP_SCISSOR,
72     UNKNOWN_SCISSOR,
73 } CurScissorType;
74 
75 typedef struct {
76     bool    bGameIsRunning;
77     uint32_t  dwTvSystem;
78     float   fRatio;
79 
80     bool    frameReadByCPU;
81     bool    frameWriteByCPU;
82 
83     uint32_t  SPCycleCount;       // Count how many CPU cycles SP used in this DLIST
84     uint32_t  DPCycleCount;       // Count how many CPU cycles DP used in this DLIST
85 
86     uint32_t  dwNumTrisRendered;
87     uint32_t  dwNumDListsCulled;
88     uint32_t  dwNumTrisClipped;
89     uint32_t  dwNumVertices;
90     uint32_t  dwBiggestVertexIndex;
91 
92     uint32_t  gDlistCount;
93     uint32_t  gFrameCount;
94     uint32_t  gUcodeCount;
95     uint32_t  gRDPTime;
96     bool    ToResize;
97     uint32_t  gNewResizeWidth, gNewResizeHeight;
98     bool    bDisableFPS;
99 
100     bool    bUseModifiedUcodeMap;
101     bool    ucodeHasBeenSet;
102     bool    bUcodeIsKnown;
103 
104     uint32_t  curRenderBuffer;
105     uint32_t  curDisplayBuffer;
106     uint32_t  curVIOriginReg;
107     CurScissorType  curScissor;
108 
109     PrimitiveType primitiveType;
110 
111     uint32_t  lastPurgeTimeTime;      // Time textures were last purged
112 
113     bool    UseLargerTile[2];       // This is a speed up for large tile loading,
114     uint32_t  LargerTileRealLeft[2];  // works only for TexRect, LoadTile, large width, large pitch
115 
116     bool    bVIOriginIsUpdated;
117     bool    bCIBufferIsRendered;
118     int     leftRendered,topRendered,rightRendered,bottomRendered;
119 
120     bool    isMMXSupported;
121 
122     bool    isMMXEnabled;
123 
124     bool    toShowCFB;
125 
126     bool    bAllowLoadFromTMEM;
127 
128     // Frame buffer simulation related status variables
129     bool    bN64FrameBufferIsUsed;      // Frame buffer is used in the frame
130     bool    bN64IsDrawingTextureBuffer; // The current N64 game is rendering into render_texture, to create self-rendering texture
131     bool    bHandleN64RenderTexture;    // Do we need to handle of the N64 render_texture stuff?
132     bool    bDirectWriteIntoRDRAM;      // When drawing into render_texture, this value =
133                                         // = true   don't render, but write real N64 graphic value into RDRAM
134                                         // = false  rendering into render_texture of DX or OGL, the render_texture
135                                         //          will be copied into RDRAM at the end
136     bool    bFrameBufferIsDrawn;        // flag to mark if the frame buffer is ever drawn
137     bool    bFrameBufferDrawnByTriangles;   // flag to tell if the buffer is even drawn by Triangle cmds
138 
139     bool    bScreenIsDrawn;
140 
141 } PluginStatus;
142 
143 #define MI_INTR_DP          0x00000020
144 #define MI_INTR_SP          0x00000001
145 
146 extern PluginStatus status;
147 
148 #ifdef __cplusplus
149 extern "C" {
150 #endif
151 
152 extern GFX_INFO gfx_info;
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 extern WindowSettingStruct windowSetting;
159 
160 extern uint32_t   g_dwRamSize;
161 
162 #define renderCallback ricerenderCallback
163 
164 /* global functions provided by Video.cpp */
165 extern char generalText[];
166 extern void (*renderCallback)(int);
167 void DebugMessage(int level, const char *message, ...);
168 
169 void SetVIScales();
170 extern void _VIDEO_DisplayTemporaryMessage2(const char *msg, ...);
171 extern void _VIDEO_DisplayTemporaryMessage(const char *msg);
172 extern void XBOX_Debugger_Log(const char *Message, ...);
173 
174 #endif
175 
176