Add memory module.
This commit is contained in:
parent
02e2ef3caf
commit
16d303008c
16
src/memory.ml
Normal file
16
src/memory.ml
Normal 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;
|
||||
}
|
|
@ -15,6 +15,7 @@ let power_up cartridge =
|
|||
Cartridge.print_info cartridge;
|
||||
|
||||
let cpu = Cpu.init_cpu in
|
||||
let mem = Memory.init cartridge in
|
||||
run cpu cartridge
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue