100 lines
1.8 KiB
C
100 lines
1.8 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <malloc.h>
|
|
#include <ogcsys.h>
|
|
#include <gccore.h>
|
|
|
|
static void *xfb = NULL;
|
|
static GXRModeObj *rmode = NULL;
|
|
|
|
void* initialise();
|
|
int test_bba_get_id();
|
|
|
|
#define EXI_BBA_ID 0x04020200
|
|
|
|
#define OK 0
|
|
#define NOK -1
|
|
|
|
typedef int(*test_f)(void);
|
|
|
|
typedef enum {
|
|
Ok = OK,
|
|
ExiGetIdFailed,
|
|
Nok = NOK,
|
|
} error_code_t;
|
|
|
|
typedef struct {
|
|
test_f test;
|
|
char test_name[32];
|
|
} test_entry_t;
|
|
|
|
#define TEST_ENTRY(name) { (name), #name }
|
|
|
|
test_entry_t tests[1] = {
|
|
TEST_ENTRY(test_bba_get_id)
|
|
};
|
|
|
|
int main(int argc, char **argv) {
|
|
xfb = initialise();
|
|
|
|
printf("\nHello World!\n");
|
|
|
|
int current_test = 0;
|
|
int nr_tests = sizeof(tests) / sizeof(tests[0]);
|
|
|
|
while(1) {
|
|
|
|
VIDEO_WaitVSync();
|
|
PAD_ScanPads();
|
|
|
|
int buttonsDown = PAD_ButtonsDown(0);
|
|
|
|
if( buttonsDown & PAD_BUTTON_A ) {
|
|
printf("Button A pressed.\n");
|
|
}
|
|
|
|
if (buttonsDown & PAD_BUTTON_START) {
|
|
exit(0);
|
|
}
|
|
|
|
if(current_test < nr_tests) {
|
|
test_entry_t t = tests[current_test++];
|
|
int result = t.test();
|
|
printf("Test: %s Result %s", t.test_name, result == OK ? "OK" : "NOK");
|
|
current_test++;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void * initialise() {
|
|
void *framebuffer;
|
|
|
|
VIDEO_Init();
|
|
PAD_Init();
|
|
|
|
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);
|
|
|
|
VIDEO_Configure(rmode);
|
|
VIDEO_SetNextFramebuffer(framebuffer);
|
|
VIDEO_SetBlack(FALSE);
|
|
VIDEO_Flush();
|
|
VIDEO_WaitVSync();
|
|
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
|
|
|
|
return framebuffer;
|
|
}
|
|
|
|
error_code_t test_bba_get_id() {
|
|
|
|
u32 exi_id = 0;
|
|
EXI_GetID(EXI_CHANNEL_0, EXI_DEVICE_2, &exi_id);
|
|
return exi_id == EXI_BBA_ID ? Ok : ExiGetIdFailed;
|
|
}
|
|
|