PS2: Fix three compiler warnings and minor code formatting fixes.

This commit is contained in:
D G Turner 2012-11-27 03:55:06 +00:00
parent cf87fcba85
commit 6d4b0a2c9f
3 changed files with 40 additions and 41 deletions

View file

@ -102,8 +102,7 @@ int vblankEndHandler(int cause) {
void createAnimThread(Gs2dScreen *screen); void createAnimThread(Gs2dScreen *screen);
Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) { Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode mode) {
_systemQuit = false; _systemQuit = false;
ee_sema_t newSema; ee_sema_t newSema;
newSema.init_count = 1; newSema.init_count = 1;
@ -118,7 +117,7 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {
_vblankStartId = AddIntcHandler(INT_VBLANK_START, vblankStartHandler, 0); _vblankStartId = AddIntcHandler(INT_VBLANK_START, vblankStartHandler, 0);
_vblankEndId = AddIntcHandler(INT_VBLANK_END, vblankEndHandler, 0); _vblankEndId = AddIntcHandler(INT_VBLANK_END, vblankEndHandler, 0);
_dmacId = AddDmacHandler(2, dmacHandler, 0); _dmacId = AddDmacHandler(2, dmacHandler, 0);
_dmaPipe = new DmaPipe(0x2000); _dmaPipe = new DmaPipe(0x2000);
@ -139,7 +138,7 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {
_clut[1] = GS_RGBA(0xC0, 0xC0, 0xC0, 0); _clut[1] = GS_RGBA(0xC0, 0xC0, 0xC0, 0);
clearOverlay(); clearOverlay();
if (tvMode == TV_DONT_CARE) { if (mode == TV_DONT_CARE) {
#if 1 #if 1
char romver[8]; char romver[8];
int fd = fioOpen("rom0:ROMVER", O_RDONLY); int fd = fioOpen("rom0:ROMVER", O_RDONLY);
@ -157,12 +156,12 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {
_tvMode = TV_NTSC; _tvMode = TV_NTSC;
#endif #endif
} else } else
_tvMode = tvMode; _tvMode = mode;
// _tvMode = TV_NTSC; // _tvMode = TV_NTSC;
printf("Setting up %s mode\n", (_tvMode == TV_PAL) ? "PAL" : "NTSC"); printf("Setting up %s mode\n", (_tvMode == TV_PAL) ? "PAL" : "NTSC");
// set screen size, 640x512 for pal, 640x448 for ntsc // set screen size, 640x512 for pal, 640x448 for ntsc
_tvWidth = 640; _tvWidth = 640;
_tvHeight = ((_tvMode == TV_PAL) ? 512 /*544*/ : 448); _tvHeight = ((_tvMode == TV_PAL) ? 512 /*544*/ : 448);
kFullScreen[0].z = kFullScreen[1].z = 0; kFullScreen[0].z = kFullScreen[1].z = 0;
@ -186,8 +185,8 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {
_clutPtrs[MOUSE] = _clutPtrs[SCREEN] + 0x1000; // the cluts in PSMCT32 take up half a memory page each _clutPtrs[MOUSE] = _clutPtrs[SCREEN] + 0x1000; // the cluts in PSMCT32 take up half a memory page each
_clutPtrs[TEXT] = _clutPtrs[SCREEN] + 0x2000; _clutPtrs[TEXT] = _clutPtrs[SCREEN] + 0x2000;
_texPtrs[SCREEN] = _clutPtrs[SCREEN] + 0x3000; _texPtrs[SCREEN] = _clutPtrs[SCREEN] + 0x3000;
_texPtrs[TEXT] = 0; // these buffers are stored in the alpha gaps of the frame buffers _texPtrs[TEXT] = 0; // these buffers are stored in the alpha gaps of the frame buffers
_texPtrs[MOUSE] = 128 * 256 * 4; _texPtrs[MOUSE] = 128 * 256 * 4;
_texPtrs[PRINTF] = _texPtrs[MOUSE] + M_SIZE * M_SIZE * 4; _texPtrs[PRINTF] = _texPtrs[MOUSE] + M_SIZE * M_SIZE * 4;
_showOverlay = false; _showOverlay = false;
@ -201,14 +200,14 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {
_overlayFormat.bytesPerPixel = 2; _overlayFormat.bytesPerPixel = 2;
_overlayFormat.rLoss = 3; _overlayFormat.rLoss = 3;
_overlayFormat.gLoss = 3; _overlayFormat.gLoss = 3;
_overlayFormat.bLoss = 3; _overlayFormat.bLoss = 3;
_overlayFormat.aLoss = 7; _overlayFormat.aLoss = 7;
_overlayFormat.rShift = 0; _overlayFormat.rShift = 0;
_overlayFormat.gShift = 5; _overlayFormat.gShift = 5;
_overlayFormat.bShift = 10; _overlayFormat.bShift = 10;
_overlayFormat.aShift = 15; _overlayFormat.aShift = 15;
// setup hardware now. // setup hardware now.
GS_CSR = CSR_RESET; // Reset GS GS_CSR = CSR_RESET; // Reset GS
@ -249,18 +248,18 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {
createAnimTextures(); createAnimTextures();
// create anim thread // create animation thread
ee_thread_t animThread, thisThread; ee_thread_t animationThread, thisThread;
ReferThreadStatus(GetThreadId(), &thisThread); ReferThreadStatus(GetThreadId(), &thisThread);
_animStack = malloc(ANIM_STACK_SIZE); _animStack = malloc(ANIM_STACK_SIZE);
animThread.initial_priority = thisThread.current_priority - 3; animationThread.initial_priority = thisThread.current_priority - 3;
animThread.stack = _animStack; animationThread.stack = _animStack;
animThread.stack_size = ANIM_STACK_SIZE; animationThread.stack_size = ANIM_STACK_SIZE;
animThread.func = (void *)runAnimThread; animationThread.func = (void *)runAnimThread;
animThread.gp_reg = &_gp; animationThread.gp_reg = &_gp;
_animTid = CreateThread(&animThread); _animTid = CreateThread(&animationThread);
assert(_animTid >= 0); assert(_animTid >= 0);
StartThread(_animTid, this); StartThread(_animTid, this);
} }
@ -268,13 +267,13 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) {
void Gs2dScreen::quit(void) { void Gs2dScreen::quit(void) {
_systemQuit = true; _systemQuit = true;
ee_thread_t statAnim; ee_thread_t statAnim;
do { // wait until thread called ExitThread() do { // wait until thread called ExitThread()
SignalSema(g_AnimSema); SignalSema(g_AnimSema);
ReferThreadStatus(_animTid, &statAnim); ReferThreadStatus(_animTid, &statAnim);
} while (statAnim.status != 0x10); } while (statAnim.status != 0x10);
DeleteThread(_animTid); DeleteThread(_animTid);
free(_animStack); free(_animStack);
_dmaPipe->waitForDma(); // wait for dmac and vblank for the last time _dmaPipe->waitForDma(); // wait for dmac and vblank for the last time
while (g_DmacCmd || g_VblankCmd); while (g_DmacCmd || g_VblankCmd);
sioprintf("kill handlers\n"); sioprintf("kill handlers\n");
@ -606,7 +605,7 @@ void Gs2dScreen::grabOverlay(byte *buf, uint16 pitch) {
for (uint32 cnt = 0; cnt < _height; cnt++) { for (uint32 cnt = 0; cnt < _height; cnt++) {
memcpy(buf, src, _width * 2); memcpy(buf, src, _width * 2);
buf += pitch; buf += pitch;
src += _width; src += _width;
} }
} }

View file

@ -29,7 +29,6 @@
#include "backends/platform/ps2/DmaPipe.h" #include "backends/platform/ps2/DmaPipe.h"
#include "graphics/surface.h" #include "graphics/surface.h"
enum TVMode { enum TVMode {
TV_DONT_CARE = 0, TV_DONT_CARE = 0,
TV_PAL, TV_PAL,
@ -41,10 +40,9 @@ enum GsInterlace {
GS_INTERLACED GS_INTERLACED
}; };
class Gs2dScreen { class Gs2dScreen {
public: public:
Gs2dScreen(uint16 width, uint16 height, TVMode tvMode); Gs2dScreen(uint16 width, uint16 height, TVMode mode);
~Gs2dScreen(void); ~Gs2dScreen(void);
void newScreenSize(uint16 width, uint16 height); void newScreenSize(uint16 width, uint16 height);
uint8 tvMode(void); uint8 tvMode(void);
@ -94,27 +92,26 @@ private:
uint8 _curDrawBuf; uint8 _curDrawBuf;
uint32 _frameBufPtr[2]; // uint32 _frameBufPtr[2]; //
uint32 _clutPtrs[3]; // vram pointers uint32 _clutPtrs[3]; // vram pointers
uint32 _texPtrs[4]; // uint32 _texPtrs[4]; //
Graphics::Surface _framebuffer; Graphics::Surface _framebuffer;
/* TODO : check if we do need this */ // TODO : check if we do need this
struct VideoState { struct VideoState {
bool setup; bool setup;
bool fullscreen; bool fullscreen;
bool aspectRatio; bool aspectRatio;
int mode; int mode;
int scaleFactor; int scaleFactor;
int screenWidth, screenHeight; int screenWidth, screenHeight;
int overlayWidth, overlayHeight; int overlayWidth, overlayHeight;
}; };
VideoState _videoMode; VideoState _videoMode;
/* */
uint16 _width, _height, _pitch; uint16 _width, _height, _pitch;
int16 _mouseX, _mouseY, _hotSpotX, _hotSpotY; int16 _mouseX, _mouseY, _hotSpotX, _hotSpotY;

View file

@ -51,6 +51,9 @@ void Ps2Pad::initPad(void) {
} else { } else {
if (checkPadReady(_port, _slot)) { if (checkPadReady(_port, _slot)) {
switch (_padStatus) { switch (_padStatus) {
case STAT_NONE:
printf("Pad Status is None. Shouldn't happen\n");
break;
case STAT_OPEN: case STAT_OPEN:
_padStatus = STAT_DETECT; _padStatus = STAT_DETECT;
break; break;