From 44c8e0178db1edf52faac2b6053d438be3bd7010 Mon Sep 17 00:00:00 2001 From: Mads Ynddal <5528170+Baekalfen@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:55:24 +0100 Subject: [PATCH] Fix clear cache --- pyboy/core/lcd.pxd | 4 ---- pyboy/core/lcd.py | 36 ++++++++++++++---------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/pyboy/core/lcd.pxd b/pyboy/core/lcd.pxd index 3c4a5f971..3c2e07a9c 100644 --- a/pyboy/core/lcd.pxd +++ b/pyboy/core/lcd.pxd @@ -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, diff --git a/pyboy/core/lcd.py b/pyboy/core/lcd.py index 421ead4b8..dd8f04159 100644 --- a/pyboy/core/lcd.py +++ b/pyboy/core/lcd.py @@ -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: @@ -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 @@ -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]: