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,8 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ogcsys.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <iostream>
#include <iomanip>
@ -15,64 +14,90 @@ static void *xfb = NULL;
u32 first_frame = 1;
GXRModeObj *rmode;
void Initialise();
int main()
{
VIDEO_Init();
rmode = VIDEO_GetPreferredMode(NULL);
PAD_Init();
Initialise();
xfb = 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);
time_t gc_time;
gc_time = time(NULL);
srand(gc_time);
while(1)
{
s32 Size;
s32 SSize;
u32 ID;
s32 error;
s32 getIDerr;
s32 CARDerr;
s32 EXIerr;
VIDEO_ClearFrameBuffer(rmode, xfb, 0);
EXI_GetID(0, 0, &ID);
error = CARD_ProbeEx(0, &Size, &SSize);
// Can't use printf since Dolphin overrides it
if(error >= 0) // All is good
std::cout << "Card A has a size of " << Size << " and a Sector Size of " << SSize;
else if( error == -2) // Device isn't Memory card
std::cout << "Device isn't Mem card in Slot A";
else
std::cout << "Got an error of " << error << " with slot A";
std::cout << " ID of 0x" << std::setbase(16) << ID << std::endl;
std::cout << std::setbase(10);
EXI_GetID(1, 0, &ID);
error = CARD_ProbeEx(1, &Size, &SSize);
if(error >= 0) // All is good
std::cout << "Card B has a size of " << Size << " and a Sector Size of " << SSize;
else if( error == -2) // Device isn't Memory card
std::cout << "Device isn't Mem card in Slot B";
else
std::cout << "Got an error of " << error << " with slot B";
std::cout << " ID of 0x" << std::setbase(16) << ID << std::endl;
std::cout<<"\x1b[0;0H"; // Position the cursor (at 0, 0)
for (int channel = 0; channel < EXI_CHANNEL_MAX; ++channel)
for (int device = 0; device < EXI_DEVICE_MAX; ++device)
{
if (getIDerr = EXI_GetID(channel, device, &ID) == 1)
{
std::cout<<"Channel "<<channel<<" Device "<<device<<"\tID = 0x"<<std::setbase(16)<<ID<<std::endl;
if ((channel == 0 && device == 0)||(channel == 1 && device == 0))
{
// It's a memcard slot
if (CARDerr = CARD_ProbeEx(channel, &Size, &SSize) >= 0)
{
std::cout<<"\tMemcard has a size of "<<std::setbase(10)<<Size<<" and a Sector Size of "<<std::setbase(10)<<SSize<<std::endl;
}
else if (CARDerr == -2)
std::cout<<"\tNot a Memcard!"<<std::endl;
else
std::cout<<"\tCARD Error "<<CARDerr<<std::endl;
}
else
{
// It's not a memcard, what to do? - Just probe for now
if (EXIerr = EXI_ProbeEx(channel)){}
else
std::cout<<"\tEXI Error "<<EXIerr<<std::endl;
}
}
else
std::cout<<"Channel "<<channel<<" Device "<<device<<std::endl<<"\tEXI_GetID Error "<<getIDerr<<std::endl;
}
VIDEO_WaitVSync();
}
return 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();
}