Skip to content

Commit

Permalink
Readd inlined getcolor instead of palette access
Browse files Browse the repository at this point in the history
  • Loading branch information
Baekalfen committed Jul 13, 2024
1 parent 813ce2d commit 4b1aeb7
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions pyboy/core/lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ def scanline_window(self, y, _x, wx, wy, cols, lcd):
wt, yy, _ = self._get_tile(self.ly_window, x - wx, lcd._LCDC.windowmap_offset, lcd)
self.update_tilecache0(lcd, wt, 0)

# TODO: Dynamic direct mapping?
pixel = lcd.BGP.lookup[self._tilecache0[yy, xx]]
pixel = lcd.BGP.getcolor(self._tilecache0[yy, xx])
self._pixel(self._tilecache0, pixel, x, y, xx, yy, 0)
return cols

Expand All @@ -564,7 +563,7 @@ def scanline_window_cgb(self, y, _x, wx, wy, cols, lcd):
if w_horiflip:
xx = 7 - xx

pixel = lcd.bcpd.palette_mem_rgb[w_palette*4 + tilecache[yy, xx]]
pixel = lcd.bcpd.getcolor(w_palette, tilecache[yy, xx])
self._pixel(tilecache, pixel, x, y, xx, yy, bg_priority_apply)
return cols

Expand All @@ -579,8 +578,7 @@ def scanline_background(self, y, _x, bx, by, cols, lcd):
xx = b_xx
yy = b_yy

# TODO: Dynamic direct mapping?
pixel = lcd.BGP.lookup[self._tilecache0[yy, xx]]
pixel = lcd.BGP.getcolor(self._tilecache0[yy, xx])
self._pixel(self._tilecache0, pixel, x, y, xx, yy, 0)
return cols

Expand All @@ -603,7 +601,7 @@ def scanline_background_cgb(self, y, _x, bx, by, cols, lcd):
if b_horiflip:
xx = 7 - xx

pixel = lcd.bcpd.palette_mem_rgb[b_palette*4 + tilecache[yy, xx]]
pixel = lcd.bcpd.getcolor(b_palette, tilecache[yy, xx])
self._pixel(tilecache, pixel, x, y, xx, yy, bg_priority_apply)
return cols

Expand Down Expand Up @@ -1077,9 +1075,6 @@ def get(self):

def getcolor(self, paletteindex, colorindex):
# Each palette = 8 bytes or 4 colors of 2 bytes
# if not (paletteindex <= 7 and colorindex <= 3):
# logger.error("Palette Mem Index Error, tried: Palette %d color %d", paletteindex, colorindex)

return self.palette_mem_rgb[paletteindex*4 + colorindex]

def save_state(self, f):
Expand Down

0 comments on commit 4b1aeb7

Please sign in to comment.