Skip to content

Instantly share code, notes, and snippets.

@bricklife
Created January 8, 2025 05:11
Show Gist options
  • Save bricklife/0e9bfd957bce41d3fc07c1b60497c55e to your computer and use it in GitHub Desktop.
Save bricklife/0e9bfd957bce41d3fc07c1b60497c55e to your computer and use it in GitHub Desktop.
GBA div test
int main() {
*(unsigned long*) 0x4000000 = 0x403;
unsigned short* vram = (unsigned short*) 0x6000000;
for(int x = 0; x < 240; x++) {
for(int y = 0; y < 160; y++) {
vram[x + y * 240] = (x * 100) / (y + 1);
}
}
while(1) {};
return 1;
}
@main
struct GameMain {
static func main() {
let REG_DISPCNT = UnsafeMutablePointer<UInt16>(bitPattern: 0x04000000)!
REG_DISPCNT.pointee = 0x403
let vram = UnsafeMutablePointer<UInt16>(bitPattern: 0x06000000)!
for x in 0..<240 {
for y in 0..<160 {
vram[x + y * 240] = UInt16((x * 100) / (y + 1))
}
}
while true {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment