-
Notifications
You must be signed in to change notification settings - Fork 0
/
mmu.go
59 lines (51 loc) · 1.45 KB
/
mmu.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package mmu
import (
"github.com/jmontupet/gbcore/internal/pkg/hram"
"github.com/jmontupet/gbcore/internal/pkg/unusableaddr"
"github.com/jmontupet/gbcore/internal/pkg/gpu"
"github.com/jmontupet/gbcore/internal/pkg/joypad"
"github.com/jmontupet/gbcore/internal/pkg/wram"
"github.com/jmontupet/gbcore/internal/pkg/interrupt"
"github.com/jmontupet/gbcore/internal/pkg/ioports"
"github.com/jmontupet/gbcore/internal/pkg/memory"
)
type MMU struct {
cartridge memory.Memory
gpu *gpu.GPU
io *ioports.IOPorts
hram *hram.HRAM
wram *wram.WRam
mirrorWram *wram.TranslatedWram
interrupt *interrupt.Manager
joypad *joypad.Joypad
unusableAddr *unusableaddr.UnusableAddr
oamDMA *OamDmaManager
vramDMA *VramDmaManager
}
func (mmu *MMU) GetOamDMA() *OamDmaManager { return mmu.oamDMA }
func (mmu *MMU) GetVramDMA() *VramDmaManager { return mmu.vramDMA }
func NewMMU(
cart memory.Memory,
gpu *gpu.GPU,
io *ioports.IOPorts,
hram *hram.HRAM,
ram *wram.WRam,
interrupt *interrupt.Manager,
joypad *joypad.Joypad,
unusableAddr *unusableaddr.UnusableAddr,
) *MMU {
mmu := &MMU{
cartridge: cart,
gpu: gpu,
io: io,
hram: hram,
wram: ram,
mirrorWram: wram.NewTranlatedWram(ram),
interrupt: interrupt,
joypad: joypad,
unusableAddr: unusableAddr,
}
mmu.oamDMA = &OamDmaManager{mmu: mmu}
mmu.vramDMA = &VramDmaManager{mmu: mmu}
return mmu
}