13
#include <wiiuse/wpad.h>
14
#include <sdcard/wiisd_io.h>
18
static GXRModeObj *rmode;
21
void (*reboot)() = (void(*)())0x80001800;
22
static u32* const SI_REG = (u32*)0xCD006400;
23
static bool haveInit = false;
24
static int counter = 0;
25
static bool logWritten = false;
30
FILE *f = fopen("sd:/si_log.txt", "a");
33
fprintf(f, "\n-------------------------------------\n");
34
for (int i = 0; i < 4; i++)
35
fprintf(f, "%i\tstatus: %x\t type:%x\n", i, SI_GetStatus(i), SI_GetType(i));
37
fprintf(f, "-------------------------------------\n");
38
fprintf(f, "SI_CHANNEL_0_OUT\t%08x\n", SI_REG[x++]);
39
fprintf(f, "SI_CHANNEL_0_IN_HI\t%08x\n", SI_REG[x++]);
40
fprintf(f, "SI_CHANNEL_0_IN_LO\t%08x\n", SI_REG[x++]);
41
fprintf(f, "SI_CHANNEL_1_OUT\t%08x\n", SI_REG[x++]);
42
fprintf(f, "SI_CHANNEL_1_IN_HI\t%08x\n", SI_REG[x++]);
43
fprintf(f, "SI_CHANNEL_1_IN_LO\t%08x\n", SI_REG[x++]);
44
fprintf(f, "SI_CHANNEL_2_OUT\t%08x\n", SI_REG[x++]);
45
fprintf(f, "SI_CHANNEL_2_IN_HI\t%08x\n", SI_REG[x++]);
46
fprintf(f, "SI_CHANNEL_2_IN_LO\t%08x\n", SI_REG[x++]);
47
fprintf(f, "SI_CHANNEL_3_OUT\t%08x\n", SI_REG[x++]);
48
fprintf(f, "SI_CHANNEL_3_IN_HI\t%08x\n", SI_REG[x++]);
49
fprintf(f, "SI_CHANNEL_3_IN_LO\t%08x\n", SI_REG[x++]);
50
fprintf(f, "SI_POLL\t\t\t%08x\n", SI_REG[x++]);
51
fprintf(f, "SI_COM_CSR\t\t\t%08x\n", SI_REG[x++]);
52
fprintf(f, "SI_STATUS_REG\t\t%08x\n", SI_REG[x++]);
53
fprintf(f, "SI_EXI_CLOCK_COUNT\t%08x\n", SI_REG[x++]);
54
fprintf(f, "-------------------------------------\n");
60
int main(int argc, char **argv)
65
if (haveInit) PAD_ScanPads();
67
VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);
71
for(int Chan = 0; Chan < 4; Chan++)
72
printf("%i\tstatus: %x\t type:%x\n", Chan, SI_GetStatus(Chan), SI_GetType(Chan));
74
printf("SI Regs: (cc006000)\n");
75
for (u32 i = 0; i < 16/*num SI regs*/; ++i)
77
printf("%08x ", SI_REG[i]);
78
if ((i+1)%8==0) printf("\n");
82
printf("\nPAD_Init\n");
88
if (PAD_ButtonsDown(0) & PAD_BUTTON_START)
93
__io_wiisd.shutdown();
101
if (counter > 5 && !haveInit)
106
else if (haveInit && !logWritten)
117
// Initialise the video system
120
// Obtain the preferred video mode from the system
121
// This will correspond to the settings in the Wii menu
122
rmode = VIDEO_GetPreferredMode(NULL);
124
// Allocate memory for the display in the uncached region
125
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
127
// Initialise the console, required for printf
128
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
130
// Set up the video registers with the chosen mode
131
VIDEO_Configure(rmode);
133
// Tell the video hardware where our display memory is
134
VIDEO_SetNextFramebuffer(xfb);
136
// Make the display visible
137
VIDEO_SetBlack(FALSE);
139
// Flush the video register changes to the hardware
142
// Wait for Video setup to complete
144
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
147
// Initialize FAT so we can write to SD.
148
__io_wiisd.startup();
149
fatMountSimple("sd", &__io_wiisd);