Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kit GameCube example
// adapted from the original acube demo by tkcne.
// enjoy
include "stdlib.h";
include "string.h";
include "malloc.h";
include "math.h";
include "gccore.h";
include "stdio.h";
include "ogcsys.h";
include "debug.h";
var screenMode: Ptr[GXRModeObj];
var frameBuffer: Ptr[Void];
var readyForCopy: vu8;
function main() {
VIDEO_Init();
screenMode = VIDEO_GetPreferredMode(null);
PAD_Init();
frameBuffer = ${MEM_K0_TO_K1: function (Ptr[Void]) -> Ptr[Void]}(SYS_AllocateFramebuffer(screenMode));
CON_Init(frameBuffer,20,20,screenMode.fbWidth,screenMode.xfbHeight,screenMode.fbWidth*VI_DISPLAY_PIX_SZ);
puts("Hello from Kit!");
VIDEO_Configure(screenMode);
VIDEO_SetNextFramebuffer(frameBuffer);
VIDEO_SetPostRetraceCallback(copy_buffers);
VIDEO_SetBlack(false);
VIDEO_Flush();
while true {}
return 0;
}
function copy_buffers(count: Uint32) {
if readyForCopy == GX_TRUE {
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(frameBuffer, GX_TRUE);
GX_Flush();
readyForCopy = GX_FALSE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment