Skip to content

Instantly share code, notes, and snippets.

@Dragorn421
Last active August 21, 2021 07:39
Show Gist options
  • Save Dragorn421/934c49d39a5acee56be19d3a6f9dc967 to your computer and use it in GitHub Desktop.
Save Dragorn421/934c49d39a5acee56be19d3a6f9dc967 to your computer and use it in GitHub Desktop.

Very basic actor that just draws text on screen. For MQ debug (or change that in actor.h)

#include "actor.h"
void CustomActor_Init(CustomActor* this, GlobalContext* globalCtx);
void CustomActor_Destroy(CustomActor* this, GlobalContext* globalCtx);
void CustomActor_Update(CustomActor* this, GlobalContext* globalCtx);
void CustomActor_Draw(CustomActor* this, GlobalContext* globalCtx);
const ActorInit initvars = {
1,
ACTORCAT_MISC,
0x00000030,
OBJECT_GAMEPLAY_KEEP,
sizeof(CustomActor),
(ActorFunc)CustomActor_Init,
(ActorFunc)CustomActor_Destroy,
(ActorFunc)CustomActor_Update,
(ActorFunc)CustomActor_Draw,
};
void CustomActor_Init(CustomActor* this, GlobalContext* globalCtx) {
}
void CustomActor_Destroy(CustomActor* this, GlobalContext* globalCtx) {
}
void CustomActor_Update(CustomActor* this, GlobalContext* globalCtx) {
}
void CustomActor_Draw(CustomActor* this, GlobalContext* globalCtx) {
GfxPrint printer;
Gfx* gfx = globalCtx->state.gfxCtx->polyOpa.p + 1;
gSPDisplayList(globalCtx->state.gfxCtx->overlay.p++, gfx);
GfxPrint_Init(&printer);
GfxPrint_Open(&printer, gfx);
GfxPrint_SetColor(&printer, 255, 0, 0, 255);
GfxPrint_SetPos(&printer, 1, 1);
GfxPrint_Printf(&printer, "It works! I am loaded at 0x%X", this);
gfx = GfxPrint_Close(&printer);
GfxPrint_Destroy(&printer);
gSPEndDisplayList(gfx++);
gSPBranchList(globalCtx->state.gfxCtx->polyOpa.p, gfx);
globalCtx->state.gfxCtx->polyOpa.p = gfx;
}
#ifndef _Z_CUSTOMACTOR_H_
#define _Z_CUSTOMACTOR_H_
#include "oot_mq_debug/z64hdr.h"
typedef struct CustomActor {
Actor actor;
} CustomActor;
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment