From 75f8cbf953093bc539af67c77d18263767bb3474 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 31 Mar 2019 21:15:45 +0200 Subject: [PATCH] draft API for OpenGL shito in libui --- src/ARM.cpp | 14 +++++++++++++- src/GPU.cpp | 4 ++-- src/NDS.cpp | 2 +- src/libui_sdl/libui/ui.h | 11 +++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/ARM.cpp b/src/ARM.cpp index f1bed5f8..69755ffb 100644 --- a/src/ARM.cpp +++ b/src/ARM.cpp @@ -159,7 +159,7 @@ void ARM::SetupCodeMem(u32 addr) //NDS::ARM7GetMemRegion(addr, false, &CodeMem); } } - +extern u64 vbltime; void ARMv5::JumpTo(u32 addr, bool restorecpsr) { if (restorecpsr) @@ -180,6 +180,16 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr) if (R[15]==0x0204BE5E) printf("recvfrom() ret:%d errno:%d %08X\n", R[0], NDS::ARM9Read32(0x217F398), addr); if (R[15]==0x0205038A) printf("sgrecvfrom() ret:%d errno:%d %08X\n", R[0], NDS::ARM9Read32(0x217F398), addr); if (addr==0x02050379 || addr==0x0205036D) printf("morp %08X->%08X, %d\n", R[15], addr, R[7]);*/ + /*if (addr==0x020B5F14) printf("VRAM UNMAP %02X %08X\n", R[0], R[15]); + if (addr==0x020B5FAC) printf("VRAM MAP %2X %08X\n", R[0], R[15]); + if (addr==0x0209F860) printf("VRAM BLORP %02X %08X\n", R[0], R[15]); + if (addr==0x02005A34) printf("VAZAVAZORP %08X. VCOUNT=%d\n", R[15], NDS::ARM9Read16(0x04000006)); + if (addr==0x0209FBEC) printf("COUILLON. %08X %08X\n", R[0], R[1]); + if (addr==0x02004AA8) printf("ANEBATE 1 %d\n", NDS::ARM9Read16(0x04000006)); + if (addr==0x020058C8) printf("ANEBATE 2 %d\n", NDS::ARM9Read16(0x04000006)); + if (addr==0x02005398) printf("ANEBATE 3 %d %d\n", NDS::ARM9Read16(0x04000006), (u32)(NDS::ARM9Timestamp-vbltime)); + if (addr==0x02005A5C) printf("PLAFORP %d\n", NDS::ARM9Read16(0x04000006)); + if (addr==0x209FBDC) printf("ROLOLORP\n");*/ u32 oldregion = R[15] >> 24; u32 newregion = addr >> 24; @@ -508,6 +518,8 @@ void ARMv5::Execute() } else AddCycles_C(); + + //if (R[15]>=0x02005A5C && R[15]<=0x02005A84) printf("NORP %08X %d\n", R[15]-8, NDS::ARM9Read16(0x04000006)); } // TODO optimize this shit!!! diff --git a/src/GPU.cpp b/src/GPU.cpp index 14e562e8..ad390073 100644 --- a/src/GPU.cpp +++ b/src/GPU.cpp @@ -20,7 +20,7 @@ #include #include "NDS.h" #include "GPU.h" - +u64 vbltime; namespace GPU { @@ -811,7 +811,7 @@ void StartScanline(u32 line) else { if (VCount == 192) - { + {//printf("- VBLANK -\n");vbltime=NDS::ARM9Timestamp; // VBlank DispStat[0] |= (1<<0); DispStat[1] |= (1<<0); diff --git a/src/NDS.cpp b/src/NDS.cpp index ae71ad65..a814dfd0 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -1532,7 +1532,7 @@ void debug(u32 param) // printf("VRAM %c: %02X\n", 'A'+i, GPU::VRAMCNT[i]); FILE* - shit = fopen("debug/lmnts.bin", "wb"); + shit = fopen("debug/card.bin", "wb"); for (u32 i = 0x02000000; i < 0x02400000; i+=4) { u32 val = ARM7Read32(i); diff --git a/src/libui_sdl/libui/ui.h b/src/libui_sdl/libui/ui.h index b100c084..a81aa705 100644 --- a/src/libui_sdl/libui/ui.h +++ b/src/libui_sdl/libui/ui.h @@ -599,6 +599,17 @@ _UI_EXTERN void uiDrawTextLayoutSetColor(uiDrawTextLayout *layout, int startChar _UI_EXTERN void uiDrawText(uiDrawContext *c, double x, double y, uiDrawTextLayout *layout); + +// OpenGL support +// TODO for later: allow using OpenGL inside a uiWindow or uiArea + +typedef struct uiGLContext uiGLContext; + +_UI_EXTERN uiGLContext *uiGLNewContext(uiControl* c); +_UI_EXTERN void uiGLMakeContextCurrent(uiGLContext* ctx); +_UI_EXTERN void *uiGLGetProcAddress(const char* proc); + + _UI_ENUM(uiModifiers) { uiModifierCtrl = 1 << 0, uiModifierAlt = 1 << 1,