Add flag register.

This commit is contained in:
Fabien Freling 2015-03-23 12:50:02 +01:00
parent e5bc9bc4db
commit f3916dfd64
2 changed files with 46 additions and 15 deletions

View file

@ -8,6 +8,8 @@ type map = {
rom_bank_01 : bytes; (* additional bank, 16KB *)
vram : bytes; (* Video RAM, 8KB *)
io : bytes; (* I/O ports *)
hram : bytes; (* High RAM, 8KB *)
interrupt : bytes; (* Interrupt Enable Register *)
}
let init (cartridge: Cartridge.t) =
@ -16,6 +18,8 @@ let init (cartridge: Cartridge.t) =
rom_bank_01 = create 0x4000;
vram = create 0x2000;
io = create 0x0080;
hram = create 0x2000;
interrupt = create 1
}
let get_mem_bank mem addr =
@ -25,6 +29,8 @@ let get_mem_bank mem addr =
| x when x < 0xA000 -> mem.vram, (x - 0x8000)
| x when x < 0xFF00 -> failwith "Unimplemented memory range."
| x when x < 0xFF80 -> mem.io, x - 0xFF00
| x when x < 0xFFFF -> mem.hram, x - 0xFF80
| 0xFFFF -> mem.interrupt, 0
| _ -> failwith "Invalid memory range."