// MEMVIEW v1.1 // // James Shaughnessy james@manc.u-net.com // http://www.netyaroze-europe.com/~shaughnj #include #include "pad.h" #define SCR_ADDR (0x80090000) #define MIN_ADDR (0x80000000) #define MAX_ADDR (0x801fffff) #define OT_LENGTH (1) #define NUM_SPRITES (1+1) // Two Ordering Tables, one for each buffer GsOT WorldOT[2]; // Two Ordering Table Tags, one for each buffer GsOT_TAG OTTag[2][1< 640) scrW = 640; } else memAddr += 1 * (4 + (padStatus & PAD1R1)); // Limit address to avoid DMA crash if (memAddr < MIN_ADDR) memAddr = MIN_ADDR; else if (memAddr > MAX_ADDR-(scrW*scrH*bitDepth/8)) memAddr = MAX_ADDR-(scrW*scrH*bitDepth/8); UpdateScreen(); // Display H-Sync counter FntPrint("HSyncs: %d\n", hsyncs); FntPrint("Memory Address = %x\n", memAddr); FntPrint("Screen width = %d\n", scrW); FntPrint("Screen height = %d\n", scrH); FntPrint("Bit depth = %d\n", bitDepth); FntFlush(-1); // Wait for end of drawing, a vertical blank then swap buffers DrawSync(0); hsyncs = VSync(0); GsSwapDispBuff(); // Register Clear in OT GsSortClear(0, 0, 0, &WorldOT[activeBuff]); // Draw the Ordering Table GsDrawOt(&WorldOT[activeBuff]); } ResetGraph(0); return 0; } void UpdateScreen() { RECT rect; u_long *ptrAddr = (u_long *)memAddr; if (scrW < 320) rect.x = (320-scrW)>>1; else rect.x = 0; rect.y = activeBuff<<8; rect.w = scrW; rect.h = scrH; LoadImage(&rect, ptrAddr); DrawSync(0); } // Initialises Video, 3D Graphics and the Frame Buffer void InitGraphics() { int i; // Setup graphics PAL 320x256 SetVideoMode(MODE_PAL); GsInitGraph(320, 256, 4, 0, 0); GsDISPENV.screen.y = 20; GsDISPENV.screen.h = 256; GsDefDispBuff(0, 0, 0, 256); // Init Ordering Tables for (i = 0; i < 2; i++) { WorldOT[i].length = OT_LENGTH; WorldOT[i].org = OTTag[i]; GsClearOt(0, 0, &WorldOT[i]); } // Loads the debug font into Frame Buffer FntLoad(960, 256); // Font printing location FntOpen(16, 200, 256, 192, 0, 512); } // ****** PAD routines ****** // call once only in program initialisation void PadInit (void) { GetPadBuf(&bb0, &bb1); } // call once per VSync(0) // puts controller pad status into unsigned long integer // please refer to the manuals if you want explanation // of the internals of this function u_long PadRead(void) { return(~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24)); }