Created
March 30, 2019 18:55
-
-
Save bendmorris/e351166df12458abbcbb819510d162d0 to your computer and use it in GitHub Desktop.
Kit GameCube example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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