Skip to content

Commit

Permalink
mapper: improve empty bank check
Browse files Browse the repository at this point in the history
  • Loading branch information
cornelk committed Dec 25, 2024
1 parent 3e5da5d commit b8d79d0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions internal/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ type Mapper struct {
addressShifts int
bankWindowSize int

emptyMappedBank mappedBank
banksMapped []mappedBank
mapped []mappedBank
banksMapped []mappedBank
mapped []mappedBank
}

const bankWindowSize = 0x2000 // TODO use as parameter
Expand All @@ -33,9 +32,8 @@ func New(dis arch.Disasm, prg []byte) (*Mapper, error) {
addressShifts: 16 - log2(mappedWindows),
bankWindowSize: bankWindowSize,

emptyMappedBank: mappedBank{},
banksMapped: make([]mappedBank, mappedBanks),
mapped: make([]mappedBank, mappedWindows),
banksMapped: make([]mappedBank, mappedBanks),
mapped: make([]mappedBank, mappedWindows),
}

m.initializeBanks(dis, prg)
Expand Down Expand Up @@ -98,7 +96,7 @@ func (m *Mapper) ReadMemory(address uint16) byte {
func (m *Mapper) OffsetInfo(address uint16) *arch.Offset {
bankWindow := address >> m.addressShifts
bnk := m.mapped[bankWindow]
if bnk == m.emptyMappedBank {
if bnk.bank == nil {
return nil
}

Expand Down

0 comments on commit b8d79d0

Please sign in to comment.