Add work RAM.
This commit is contained in:
		
							parent
							
								
									214590e2db
								
							
						
					
					
						commit
						7805e50062
					
				
					 1 changed files with 7 additions and 0 deletions
				
			
		|  | @ -8,6 +8,8 @@ type map = { | ||||||
|   rom_bank_00 : bytes; (* cartridge, 16KB *) |   rom_bank_00 : bytes; (* cartridge, 16KB *) | ||||||
|   rom_bank_01 : bytes; (* additional bank, 16KB *) |   rom_bank_01 : bytes; (* additional bank, 16KB *) | ||||||
|   vram : bytes; (* Video RAM, 8KB *) |   vram : bytes; (* Video RAM, 8KB *) | ||||||
|  |   wram_bank_0 : bytes; (* work RAM, 4KB *) | ||||||
|  |   wram_bank_1 : bytes; (* work RAM, 4KB *) | ||||||
|   io : bytes; (* I/O ports *) |   io : bytes; (* I/O ports *) | ||||||
|   hram : bytes; (* High RAM, 8KB *) |   hram : bytes; (* High RAM, 8KB *) | ||||||
|   interrupt : bytes; (* Interrupt Enable Register *) |   interrupt : bytes; (* Interrupt Enable Register *) | ||||||
|  | @ -18,6 +20,8 @@ let init (cartridge: Cartridge.t) = | ||||||
|     rom_bank_00 = sub cartridge.full_rom 0 0x4000; |     rom_bank_00 = sub cartridge.full_rom 0 0x4000; | ||||||
|     rom_bank_01 = create 0x4000; |     rom_bank_01 = create 0x4000; | ||||||
|     vram = create 0x2000; |     vram = create 0x2000; | ||||||
|  |     wram_bank_0 = create 0x1000; | ||||||
|  |     wram_bank_1 = create 0x1000; | ||||||
|     io = create 0x0080; |     io = create 0x0080; | ||||||
|     hram = create 0x2000; |     hram = create 0x2000; | ||||||
|     interrupt = create 1 |     interrupt = create 1 | ||||||
|  | @ -28,6 +32,9 @@ let get_mem_bank mem addr = | ||||||
|   | x when x < 0x4000 -> mem.rom_bank_00, x |   | x when x < 0x4000 -> mem.rom_bank_00, x | ||||||
|   | x when x < 0x8000 -> mem.rom_bank_01, (x - 0x4000) |   | x when x < 0x8000 -> mem.rom_bank_01, (x - 0x4000) | ||||||
|   | x when x < 0xA000 -> mem.vram,  (x - 0x8000) |   | x when x < 0xA000 -> mem.vram,  (x - 0x8000) | ||||||
|  |   | x when x < 0xC000 -> failwith "Unimplemented memory range." | ||||||
|  |   | x when x < 0xD000 -> mem.wram_bank_0,  (x - 0xC000) | ||||||
|  |   | x when x < 0xE000 -> mem.wram_bank_1,  (x - 0xD000) | ||||||
|   | x when x < 0xFF00 -> failwith "Unimplemented memory range." |   | x when x < 0xFF00 -> failwith "Unimplemented memory range." | ||||||
|   | x when x < 0xFF80 -> mem.io, x - 0xFF00 |   | x when x < 0xFF80 -> mem.io, x - 0xFF00 | ||||||
|   | x when x < 0xFFFF -> mem.hram, x - 0xFF80 |   | x when x < 0xFFFF -> mem.hram, x - 0xFF80 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue