Created
August 9, 2016 23:01
-
-
Save ashquarky/9d366e610f7ecbf692f77089e9b37812 to your computer and use it in GitHub Desktop.
Quick reverse-engineering of OSScreenSetBufferEx. 5.5.1.
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
int globalVar; //This could be anything, likely a struct? | |
//Feels like a stack pointer. | |
//unk_10098EB4 | |
void OSScreenSetBufferEx(int bufferNum, void* address) { | |
int r0 = bufferNum << 6; //32-Bit left shift | |
int* r11 = globalVar + r0; | |
int r12 = *(r11 + 0x2C); | |
*(r11 + 0x38) = address; | |
r0 = address + r12; | |
*(r11 + 0x3C) = r0; | |
*(r11 + 0x34) = address; | |
*(r11 + 0x30) = r0; | |
} | |
//This is my refactoring, rewritten to make a bit more sense. | |
void* globalMemoryLocation; //preset | |
struct OSScreenBuffer { | |
char unk[0x2B]; | |
int offset; //0x2C, preset | |
int virtAddr; //0x30 | |
int realAddr; //0x34 | |
int realAddr2; //0x38 | |
int virtAddr2; //0x3C | |
} | |
void OSScreenSetBufferEx_refactored(int bufferNum, void* address) { | |
OSScreenBuffer* buffer = globalMemoryLocation + (bufferNum << 6); | |
buffer->virtAddr = address + buffer->offset; | |
buffer->realAddr = address; | |
buffer->realAddr2 = address; | |
buffer->virtAddr2 = address + buffer->offset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment