Skip to content

Commit

Permalink
make a rombank view specifically for 0
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 authored and Baekalfen committed Dec 8, 2023
1 parent c14c383 commit a69e2e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyboy/core/cartridge/base_mbc.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cdef class BaseMBC:
cdef bint rambank_initialized
cdef uint16_t rambank_selected
cdef uint16_t rombank_selected
cdef uint8_t[:] rombank_0
cdef uint8_t[:] rombank_view
cdef uint8_t[:] rambank_view
cdef bint cgb
Expand Down
3 changes: 2 additions & 1 deletion pyboy/core/cartridge/base_mbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, filename, rombanks, external_ram_count, carttype, sram, batte
self.rambank_view = self.rambanks[self.rambank_selected]
self.rombank_selected = 1
self.rombank_view = self.rombanks[self.rombank_selected]
self.rombank_0 = self.rombanks[0]

self.cgb = bool(self.getitem(0x0143) >> 7)

Expand Down Expand Up @@ -121,7 +122,7 @@ def overrideitem(self, rom_bank, address, value):

def getitem(self, address):
if 0x0000 <= address < 0x4000:
return self.rombanks[0, address]
return self.rombank_0[address]
elif 0x4000 <= address < 0x8000:
# return self.rombanks[self.rombank_selected, address - 0x4000]
return self.rombank_view[address - 0x4000]
Expand Down

0 comments on commit a69e2e2

Please sign in to comment.