1 /***************************************************************************
5 Created by Gil Pedersen on Sun April 18 2004.
6 Copyright (c) 2004 Gil Pedersen.
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. See also the license.txt file for *
15 * additional informations. *
17 ***************************************************************************/
19 #import "PluginWindowController.h"
20 #import "PluginGLView.h"
21 #include "ExtendedKeys.h"
22 #include "externals.h"
27 ////////////////////////////////////////////////////////////////////////////////////
29 ////////////////////////////////////////////////////////////////////////////////////
34 BOOL bIsFirstFrame = TRUE;
35 BOOL bCheckMask=FALSE;
36 unsigned short sSetMask=0;
37 unsigned long lSetMask=0;
42 int iUseNoStretchBlt=0;
46 PSXPoint_t ptCursorPoint[8];
47 unsigned short usCursorActive=0;
51 //static PluginWindowController *windowController;
52 static PluginGLView *glView;
54 ////////////////////////////////////////////////////////////////////////
56 void DoBufferSwap(void) // SWAP BUFFERS
61 static long long lastTickCount = -1;
62 static int skipCount = 0;
63 long long microTickCount;
66 Microseconds((struct UnsignedWide *)µTickCount);
67 deltaTime = (long)(microTickCount - lastTickCount);
68 if (deltaTime <= (PSXDisplay.PAL ? 1000000/50 : 100000000 / 5994) ||
75 NSLog(@"count: %i", deltaTime);
76 lastTickCount = microTickCount;
81 ////////////////////////////////////////////////////////////////////////
83 void DoClearScreenBuffer(void) // CLEAR DX BUFFER
85 // clear the screen, and DON'T flush it
86 [glView clearBuffer:NO];
90 ////////////////////////////////////////////////////////////////////////
92 void DoClearFrontBuffer(void) // CLEAR DX BUFFER
94 // clear the screen, and flush it
95 [glView clearBuffer:YES];
98 ////////////////////////////////////////////////////////////////////////
100 unsigned long ulInitDisplay(void) // OPEN GAME WINDOW
106 bIsFirstFrame = FALSE;
111 ulKeybits|=KEY_SHOWFPS;
116 PluginWindowController *windowController = [PluginWindowController openGameView];
117 glView = [windowController getOpenGLView];
119 [[windowController window] setTitle:[NSString stringWithCString:pCaptionText]];
121 return (unsigned long)[windowController window];
125 ////////////////////////////////////////////////////////////////////////
127 void CloseDisplay(void)
129 if (gameController) {
130 [gameController close];
131 [gameController release];
132 gameController = nil;
138 ////////////////////////////////////////////////////////////////////////
140 void CreatePic(unsigned char * pMem)
145 ///////////////////////////////////////////////////////////////////////////////////////
147 void DestroyPic(void)
152 ///////////////////////////////////////////////////////////////////////////////////////
154 void DisplayPic(void)
159 ///////////////////////////////////////////////////////////////////////////////////////
161 void ShowGpuPic(void)
163 // this is the default implementation...
166 ///////////////////////////////////////////////////////////////////////////////////////
168 void ShowTextGpuPic(void)
170 // this is the default implementation...
174 void HandleKey(int keycode)
177 case GPU_FULLSCREEN_KEY:
178 [gameController setFullscreen:![gameController fullscreen]];