Add memory module.

This commit is contained in:
Fabien Freling 2015-03-22 13:56:32 +01:00
parent 02e2ef3caf
commit 16d303008c
2 changed files with 17 additions and 0 deletions

16
src/memory.ml Normal file
View file

@ -0,0 +1,16 @@
(** http://bgb.bircd.org/pandocs.htm#memorymap
http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-Memory *)
type map = {
rom_bank_00 : bytes; (* cartridge, 16KB *)
rom_bank_01 : bytes; (* additional bank, 16KB *)
vram : bytes; (* Video RAM, 8KB *)
}
let init (cartridge: Cartridge.t) =
let open Bytes in
{
rom_bank_00 = sub cartridge.full_rom 0 0x4000;
rom_bank_01 = create 0x4000;
vram = create 0x2000;
}

View file

@ -15,6 +15,7 @@ let power_up cartridge =
Cartridge.print_info cartridge; Cartridge.print_info cartridge;
let cpu = Cpu.init_cpu in let cpu = Cpu.init_cpu in
let mem = Memory.init cartridge in
run cpu cartridge run cpu cartridge