From 54fffb7fff09bc5daca6f995b041b185f0cf2524 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 17 Apr 2013 00:45:23 -0700 Subject: [PATCH] Add HLE BIOS from GBA.js --- src/gba/gba-memory.c | 5 +++-- src/gba/hle-bios.c | 23 +++++++++++++++++++++++ src/gba/hle-bios.h | 7 +++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/gba/hle-bios.c create mode 100644 src/gba/hle-bios.h diff --git a/src/gba/gba-memory.c b/src/gba/gba-memory.c index eaaa4a1ad..1174927f5 100644 --- a/src/gba/gba-memory.c +++ b/src/gba/gba-memory.c @@ -1,6 +1,7 @@ #include "gba-memory.h" #include "gba-io.h" +#include "hle-bios.h" #include #include @@ -26,7 +27,7 @@ void GBAMemoryInit(struct GBAMemory* memory) { memory->d.store16 = GBAStore16; memory->d.store8 = GBAStore8; - memory->bios = 0; + memory->bios = hleBios; memory->wram = mmap(0, SIZE_WORKING_RAM, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); memory->iwram = mmap(0, SIZE_WORKING_IRAM, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); memory->rom = 0; @@ -75,7 +76,7 @@ static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t address) { switch (address & ~OFFSET_MASK) { case BASE_BIOS: memory->activeRegion = gbaMemory->bios; - memory->activeMask = 0; + memory->activeMask = SIZE_BIOS - 1; break; case BASE_WORKING_RAM: memory->activeRegion = gbaMemory->wram; diff --git a/src/gba/hle-bios.c b/src/gba/hle-bios.c new file mode 100644 index 000000000..81661e62b --- /dev/null +++ b/src/gba/hle-bios.c @@ -0,0 +1,23 @@ +#include "hle-bios.h" + +const unsigned int hleBiosLength = 216; +const unsigned char hleBios[] = { + 0x06, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x05, 0x00, 0x00, 0xea, + 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff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00, 0xc1, 0xe1, + 0xe8, 0xff, 0xff, 0x0a, 0x04, 0xd0, 0x8d, 0xe2, 0x04, 0x80, 0xbd, 0xe8 +}; diff --git a/src/gba/hle-bios.h b/src/gba/hle-bios.h new file mode 100644 index 000000000..28ed40e66 --- /dev/null +++ b/src/gba/hle-bios.h @@ -0,0 +1,7 @@ +#ifndef HLE_BIOS_H +#define HLE_BIOS_H + +const unsigned int hleBiosLength; +const unsigned char hleBios[]; + +#endif