diff --git a/Source/TestSuite/ARAM/source/dolphintest_aram.cpp b/Source/TestSuite/ARAM/source/dolphintest_aram.cpp index dd6622a7f6..d7b2a66532 100644 --- a/Source/TestSuite/ARAM/source/dolphintest_aram.cpp +++ b/Source/TestSuite/ARAM/source/dolphintest_aram.cpp @@ -11,20 +11,22 @@ static void *xfb = NULL; static GXRModeObj *rmode = NULL; -void *Initialise(); +void Initialise(); #define NUM_BLOCKS 10 u32 aram_blocks[NUM_BLOCKS]; u32 start_addr = -1; -int main(int argc, char **argv) { - - xfb = Initialise(); +int main(int argc, char **argv) +{ + Initialise(); start_addr = AR_Init(aram_blocks, NUM_BLOCKS); - while(1) { + while(1) + { PAD_ScanPads(); VIDEO_ClearFrameBuffer(rmode, xfb, 0); - + std::cout<<"\x1b[2;0H"; // Position the cursor (on 2nd row) + std::cout << "Aram is " << (AR_GetDMAStatus() ? "In Progress" : "Idle") << std::endl; std::cout << "Aram Start is 0x" << std::setbase(16) << start_addr << ", Allocated 0x" << AR_GetSize() << " Of memory" << std::setbase(10) << std::endl; std::cout << "Internal Size is 0x" << std::setbase(16) << AR_GetInternalSize() << std::setbase(10) << std::endl; @@ -34,25 +36,37 @@ int main(int argc, char **argv) { return 0; } -void * Initialise() { - - void *framebuffer; - +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); - framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); - console_init(framebuffer,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); - + // 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); - VIDEO_SetNextFramebuffer(framebuffer); + + // 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(); - - return framebuffer; - } diff --git a/Source/TestSuite/EXI/source/dolphintest_exi.cpp b/Source/TestSuite/EXI/source/dolphintest_exi.cpp index b93867f709..e559e86bbd 100644 --- a/Source/TestSuite/EXI/source/dolphintest_exi.cpp +++ b/Source/TestSuite/EXI/source/dolphintest_exi.cpp @@ -3,8 +3,7 @@ #include #include #include -#include -#include +#include #include #include @@ -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 "<= 0) + { + std::cout<<"\tMemcard has a size of "<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(); +} diff --git a/Source/TestSuite/PAD/source/dolphintest_pad.cpp b/Source/TestSuite/PAD/source/dolphintest_pad.cpp index adb5beae35..91e679c011 100644 --- a/Source/TestSuite/PAD/source/dolphintest_pad.cpp +++ b/Source/TestSuite/PAD/source/dolphintest_pad.cpp @@ -3,15 +3,13 @@ #include #include #include -#include -#include #include #include #include -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["<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(); +} diff --git a/Source/TestSuite/RTC/source/dolphintest_rtc.cpp b/Source/TestSuite/RTC/source/dolphintest_rtc.cpp index 03b0450036..036b19c2da 100644 --- a/Source/TestSuite/RTC/source/dolphintest_rtc.cpp +++ b/Source/TestSuite/RTC/source/dolphintest_rtc.cpp @@ -10,46 +10,63 @@ #include #include - static void *xfb = NULL; u32 first_frame = 1; GXRModeObj *rmode; +void Initialise(); -int main() { - - VIDEO_Init(); - - rmode = VIDEO_GetPreferredMode(NULL); - - - 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); +int main() +{ + Initialise(); time_t gc_time; gc_time = time(NULL); srand(gc_time); - while(1) { - + while(1) + { gc_time = time(NULL); - printf("\x1b[10;0HRTC time is %s ",ctime(&gc_time)); + std::cout<<"\x1b[10;0HRTC time is"<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(); +} diff --git a/Source/TestSuite/SI/source/dolphintest_si.cpp b/Source/TestSuite/SI/source/dolphintest_si.cpp index d7940990d4..5884b05f74 100644 --- a/Source/TestSuite/SI/source/dolphintest_si.cpp +++ b/Source/TestSuite/SI/source/dolphintest_si.cpp @@ -6,52 +6,65 @@ #include #include #include +#include -static void *xfb = NULL; -static GXRModeObj *rmode = NULL; +static void *xfb; +static GXRModeObj *rmode; -void *Initialise(); +void Initialise(); -int main(int argc, char **argv) { - - xfb = Initialise(); +int main(int argc, char **argv) +{ + Initialise(); while(1) { PAD_ScanPads(); VIDEO_ClearFrameBuffer(rmode, xfb, 0); + std::cout<<"\x1b[0;0H"; // Position the cursor (at 0, 0) for(int Chan = 0; Chan < 4; Chan++) { std::cout << "Chan " << Chan << std::endl; std::cout << "Status is " << SI_GetStatus(Chan) << std::endl; std::cout << "Type is 0x" << std::setbase(16) << SI_GetType(Chan) << std::setbase(10) << std::endl << std::endl; } - VIDEO_WaitVSync(); } return 0; } -void * Initialise() { - - void *framebuffer; - +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); - framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); - console_init(framebuffer,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); - + // 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); - VIDEO_SetNextFramebuffer(framebuffer); + + // 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(); - - return framebuffer; - } diff --git a/Source/TestSuite/WPAD/source/dolphintest_wpad.cpp b/Source/TestSuite/WPAD/source/dolphintest_wpad.cpp index 8c3ed4042d..8530023015 100644 --- a/Source/TestSuite/WPAD/source/dolphintest_wpad.cpp +++ b/Source/TestSuite/WPAD/source/dolphintest_wpad.cpp @@ -3,6 +3,7 @@ //code by WinterMute #include #include +#include #include #include #include @@ -76,48 +77,48 @@ void countevs(int chan, const WPADData *data) { void print_wiimote_connection_status(int wiimote_connection_status) { switch(wiimote_connection_status) { case WPAD_ERR_NO_CONTROLLER: - printf(" Wiimote not connected\n"); + std::cout<<" Wiimote not connected\n"; break; case WPAD_ERR_NOT_READY: - printf(" Wiimote not ready\n"); + std::cout<<" Wiimote not ready\n"; break; case WPAD_ERR_NONE: - printf(" Wiimote ready\n"); + std::cout<<" Wiimote ready\n"; break; default: - printf(" Unknown Wimote state %d\n",wiimote_connection_status); + std::cout<<" Unknown Wimote state "<btns_h & WPAD_BUTTON_A) printf("A "); - if(wd->btns_h & WPAD_BUTTON_B) printf("B "); - if(wd->btns_h & WPAD_BUTTON_1) printf("1 "); - if(wd->btns_h & WPAD_BUTTON_2) printf("2 "); - if(wd->btns_h & WPAD_BUTTON_MINUS) printf("MINUS "); - if(wd->btns_h & WPAD_BUTTON_HOME) printf("HOME "); - if(wd->btns_h & WPAD_BUTTON_PLUS) printf("PLUS "); - printf("\n "); - if(wd->btns_h & WPAD_BUTTON_LEFT) printf("LEFT "); - if(wd->btns_h & WPAD_BUTTON_RIGHT) printf("RIGHT "); - if(wd->btns_h & WPAD_BUTTON_UP) printf("UP "); - if(wd->btns_h & WPAD_BUTTON_DOWN) printf("DOWN "); - printf("\n"); + std::cout<<" Buttons down:\n "; + if(wd->btns_h & WPAD_BUTTON_A) std::cout<<"A "; + if(wd->btns_h & WPAD_BUTTON_B) std::cout<<"B "; + if(wd->btns_h & WPAD_BUTTON_1) std::cout<<"1 "; + if(wd->btns_h & WPAD_BUTTON_2) std::cout<<"2 "; + if(wd->btns_h & WPAD_BUTTON_MINUS) std::cout<<"MINUS "; + if(wd->btns_h & WPAD_BUTTON_HOME) std::cout<<"HOME "; + if(wd->btns_h & WPAD_BUTTON_PLUS) std::cout<<"PLUS "; + std::cout<<"\n "; + if(wd->btns_h & WPAD_BUTTON_LEFT) std::cout<<"LEFT "; + if(wd->btns_h & WPAD_BUTTON_RIGHT) std::cout<<"RIGHT "; + if(wd->btns_h & WPAD_BUTTON_UP) std::cout<<"UP "; + if(wd->btns_h & WPAD_BUTTON_DOWN) std::cout<<"DOWN "; + std::cout<<"\n"; } void print_and_draw_wiimote_data(void *screen_buffer) { //Makes the var wd point to the data on the wiimote WPADData *wd = WPAD_Data(0); - printf(" Data->Err: %d\n",wd->err); - printf(" IR Dots:\n"); + std::cout<<" Data->Err: "<err<<"\n"; + std::cout<<" IR Dots:\n"; int i; for(i=0; i<4; i++) { if(wd->ir.dot[i].visible) { - printf(" %4d, %3d\n", wd->ir.dot[i].rx, wd->ir.dot[i].ry); + std::cout<<" "<ir.dot[i].rx<<", "<ir.dot[i].ry<<"\n"; drawdot(screen_buffer, rmode, 1024, 768, wd->ir.dot[i].rx, wd->ir.dot[i].ry, COLOR_YELLOW); } else { - printf(" None\n"); + std::cout<<" None\n"; } } //ir.valid - TRUE is the wiimote is pointing at the screen, else it is false @@ -126,31 +127,31 @@ void print_and_draw_wiimote_data(void *screen_buffer) { //ir.x/ir.y - The x/y coordinates that the wiimote is pointing to, relative to the screen. //ir.angle - how far (in degrees) the wiimote is twisted (based on ir) - printf(" Cursor: %.02f,%.02f\n",wd->ir.x, wd->ir.y); - printf(" @ %.02f deg\n",wd->ir.angle); + std::cout<<" Cursor: "<ir.x<<","<ir.y<<"\n"; + std::cout<<" @ "<ir.angle<<" deg\n"; drawdot(screen_buffer, rmode, rmode->fbWidth, rmode->xfbHeight, wd->ir.x, wd->ir.y, COLOR_RED); drawdot(screen_buffer, rmode, rmode->fbWidth, rmode->xfbHeight, wd->ir.x + 10*sinf(theta), wd->ir.y - 10*cosf(theta), COLOR_BLUE); } else { - printf(" No Cursor\n\n"); + std::cout<<" No Cursor\n\n"; } if(wd->ir.raw_valid) { //ir.z - How far away the wiimote is from the screen in meters - printf(" Distance: %.02fm\n", wd->ir.z); + std::cout<<" Distance: "<ir.z<<"m\n"; //orient.yaw - The left/right angle of the wiimote to the screen - printf(" Yaw: %.02f deg\n", wd->orient.yaw); + std::cout<<" Yaw: "<orient.yaw<<" deg\n"; } else { - printf("\n\n"); + std::cout<<"\n\n"; } - printf(" Accel:\n"); + std::cout<<" Accel:\n"; //accel.x/accel.y/accel.z - analog values for the accelleration of the wiimote //(Note: Gravity pulls downwards, so even if the wiimote is not moving, //one(or more) axis will have a reading as if it is moving "upwards") - printf(" XYZ: %3d,%3d,%3d\n",wd->accel.x,wd->accel.y,wd->accel.z); + std::cout<<" XYZ: "<accel.x<<","<accel.y<<","<accel.z<<"\n"; //orient.pitch - how far the wiimote is "tilted" in degrees - printf(" Pitch: %.02f\n",wd->orient.pitch); + std::cout<<" Pitch: "<orient.pitch<<"\n"; //orient.roll - how far the wiimote is "twisted" in degrees (uses accelerometer) - printf(" Roll: %.02f\n",wd->orient.roll); + std::cout<<" Roll: "<orient.roll<<"\n"; print_wiimote_buttons(wd); @@ -194,12 +195,12 @@ int main(int argc, char **argv) { while(!doreload && !dooff) { CON_Init(xfb[fbi],0,0,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); //VIDEO_ClearFrameBuffer(rmode,xfb[fbi],COLOR_BLACK); - printf("\n\n\n"); + std::cout<<"\n\n\n"; WPAD_ReadPending(WPAD_CHAN_ALL, countevs); int wiimote_connection_status = WPAD_Probe(0, &type); print_wiimote_connection_status(wiimote_connection_status); - printf(" Event count: %d\n",evctr); + std::cout<<" Event count: "<