testsuite: convert printf to std::cout(now all output should appear in dolphin) and add more checks to exi

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2073 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman
2009-02-02 22:11:49 +00:00
parent 4f44afcb04
commit 82d510e252
6 changed files with 279 additions and 194 deletions

View File

@ -3,15 +3,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <ogcsys.h>
#include <time.h>
#include <sys/time.h>
#include <iostream>
#include <debug.h>
#include <math.h>
static u32* xfb = NULL;
static void* xfb = NULL;
u32 first_frame = 1;
GXRModeObj *rmode;
@ -21,63 +19,80 @@ vu16 keydown;
vu16 keyup;
PADStatus pad[4];
int main() {
VIDEO_Init();
rmode = VIDEO_GetPreferredMode(NULL);
PAD_Init();
xfb = (u32*)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE)
VIDEO_WaitVSync();
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*2);
void Initialise();
time_t gc_time;
gc_time = time(NULL);
int main()
{
Initialise();
srand(gc_time);
while(1) {
gc_time = time(NULL);
while(1)
{
VIDEO_ClearFrameBuffer(rmode, xfb, 0);
std::cout<<"\x1b[0;0H"; // Position the cursor (at 0, 0)
PAD_Read(pad);
for(int a = 0; a < 4;a ++)
{
if(pad[a].err & PAD_ERR_NO_CONTROLLER)
continue; // Controller not connected
printf("pad[%d] Sticks, Main[ %d, %d ] Sub[ %d, %d ]\n", a, pad[a].stickX, pad[a].stickY, pad[a].substickX, pad[a].substickY);
printf("pad[%d] LTrigger is %s, LTrigger Analog %d\n", a, pad[a].button & PAD_TRIGGER_L ? "pressed" : "not pressed", pad[a].triggerL);
printf("pad[%d] RTrigger is %s, RTrigger Analog %d\n", a, pad[a].button & PAD_TRIGGER_R ? "pressed" : "not pressed", pad[a].triggerR);
printf("pad[%d] Trigger Z is %s\n", a, pad[a].button & PAD_TRIGGER_Z ? "pressed" : "not pressed");
printf("pad[%d] Button A %s, Analog A %d\n", a, pad[a].button & PAD_BUTTON_A ? "pressed" : "not pressed", pad[a].analogA);
printf("pad[%d] Button B %s, Analog B %d\n", a, pad[a].button & PAD_BUTTON_B ? "pressed" : "not pressed", pad[a].analogB);
printf("pad[%d] Button X is %s\n", a, pad[a].button & PAD_BUTTON_X ? "pressed" : "not pressed");
printf("pad[%d] Button Y is %s\n", a, pad[a].button & PAD_BUTTON_Y ? "pressed" : "not pressed");
printf("pad[%d] Button Start is %s\n", a, pad[a].button & PAD_BUTTON_START ? "pressed" : "not pressed");
printf("pad[%d] DPad is [up, down, left, right](%d, %d, %d, %d)\n", a, pad[a].button & PAD_BUTTON_UP ? 1 : 0, pad[a].button & PAD_BUTTON_DOWN ? 1 : 0, pad[a].button & PAD_BUTTON_LEFT ? 1 : 0, pad[a].button & PAD_BUTTON_RIGHT ? 1 : 0);
}
{
std::cout<<"pad["<<a<<"] Not Connected\n";
continue;
}
std::cout<<"pad["<<a<<"] Sticks: Main[ "<<(int)pad[a].stickX<<", "<<(int)pad[a].stickY<<" ] Sub[ "<<(int)pad[a].substickX<<", "<<(int)pad[a].substickX<<" ]\n";
std::cout<<"pad["<<a<<"] Analog Triggers: Left "<<(int)pad[a].triggerL<<" Right "<<(int)pad[a].triggerL<<"\n";
std::cout<<"pad["<<a<<"] Buttons: "<<
(pad[a].button & PAD_BUTTON_START? "Start " : "")<<
(pad[a].button & PAD_BUTTON_A ? "A " : "")<<
(pad[a].button & PAD_BUTTON_B ? "B " : "")<<
(pad[a].button & PAD_BUTTON_X ? "X " : "")<<
(pad[a].button & PAD_BUTTON_Y ? "Y " : "")<<
(pad[a].button & PAD_TRIGGER_Z? "Z " : "")<<
(pad[a].button & PAD_TRIGGER_L? "L " : "")<<
(pad[a].button & PAD_TRIGGER_R? "R " : "")<<std::endl;
std::cout<<"pad["<<a<<"] DPad: "<<
(pad[a].button & PAD_BUTTON_UP ? "Up " : "")<<
(pad[a].button & PAD_BUTTON_DOWN ? "Down " : "")<<
(pad[a].button & PAD_BUTTON_LEFT ? "Left " : "")<<
(pad[a].button & PAD_BUTTON_RIGHT ? "Right " : "")<<std::endl;
}
VIDEO_WaitVSync();
int buttonsDown = PAD_ButtonsDown(0);
if (buttonsDown & PAD_BUTTON_START) {
exit(0);
}
}
}
void Initialise()
{
// Initialise the video system
VIDEO_Init();
// This function initialises the attached controllers
PAD_Init();
// Obtain the preferred video mode from the system
// This will correspond to the settings in the Wii menu
rmode = VIDEO_GetPreferredMode(NULL);
// Allocate memory for the display in the uncached region
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
// Initialise the console, required for printf
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
// Set up the video registers with the chosen mode
VIDEO_Configure(rmode);
// Tell the video hardware where our display memory is
VIDEO_SetNextFramebuffer(xfb);
// Make the display visible
VIDEO_SetBlack(FALSE);
// Flush the video register changes to the hardware
VIDEO_Flush();
// Wait for Video setup to complete
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
}