Skip to content

Commit

Permalink
Fix clear cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Baekalfen committed Nov 2, 2023
1 parent c0b275c commit 44c8e01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
4 changes: 0 additions & 4 deletions pyboy/core/lcd.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ cdef class Renderer:
cdef void sort_sprites(self, int) noexcept nogil

cdef void clear_cache(self) noexcept nogil
cdef void clear_tilecache0(self) noexcept nogil
cdef void clear_tilecache1(self) noexcept nogil # CGB Only
cdef void clear_spritecache0(self) noexcept nogil
cdef void clear_spritecache1(self) noexcept nogil
@cython.locals(
x=int,
t=int,
Expand Down
36 changes: 14 additions & 22 deletions pyboy/core/lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,12 @@ def scanline_sprites(self, lcd, ly, buffer, ignore_priority):
x -= 8

def clear_cache(self):
self.clear_tilecache0()
self.clear_spritecache0()
self.clear_spritecache1()
for i in range(TILES):
self._tilecache0_state[i] = 0
for i in range(TILES):
self._spritecache0_state[i] = 0
for i in range(TILES):
self._spritecache1_state[i] = 0

def invalidate_tile(self, tile, vbank):
if vbank and self.cgb:
Expand All @@ -679,18 +682,6 @@ def invalidate_tile(self, tile, vbank):
self._spritecache0_state[tile] = 0
self._spritecache1_state[tile] = 0

def clear_tilecache0(self):
self._tilecache0_state[:] = 0

def clear_tilecache1(self):
pass

def clear_spritecache0(self):
self._spritecache0_state[:] = 0

def clear_spritecache1(self):
self._spritecache1_state[:] = 0

def update_tilecache0(self, lcd, t, bank):
if self._tilecache0_state[t]:
return
Expand Down Expand Up @@ -816,13 +807,14 @@ def __init__(self):
self.clear_cache()

def clear_cache(self):
self.clear_tilecache0()
self.clear_tilecache1()
self.clear_spritecache0()
self.clear_spritecache1()

def clear_tilecache1(self):
self._tilecache1_state[:] = 0
for i in range(TILES):
self._tilecache0_state[i] = 0
for i in range(TILES):
self._tilecache1_state[i] = 0 # CGB Only
for i in range(TILES):
self._spritecache0_state[i] = 0
for i in range(TILES):
self._spritecache1_state[i] = 0

def update_tilecache0(self, lcd, t, bank):
if self._tilecache0_state[t]:
Expand Down

0 comments on commit 44c8e01

Please sign in to comment.