diff --git a/.idea/FunComputerScienceProjectsInPython.iml b/.idea/FunComputerScienceProjectsInPython.iml
index 909438d..74d515a 100644
--- a/.idea/FunComputerScienceProjectsInPython.iml
+++ b/.idea/FunComputerScienceProjectsInPython.iml
@@ -1,8 +1,10 @@
-
-
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3ea7c1c..05ad949 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,9 @@
-
+
+
+
+
diff --git a/NESEmulator/cpu.py b/NESEmulator/cpu.py
index fcde755..1ce4150 100644
--- a/NESEmulator/cpu.py
+++ b/NESEmulator/cpu.py
@@ -777,7 +777,7 @@ def read_memory(self, location: int, mode: MemMode) -> int:
# Memory map at http://wiki.nesdev.com/w/index.php/CPU_memory_map
if address < 0x2000: # main ram 2 KB goes up to 0x800
return self.ram[address % 0x800] # mirrors for next 6 KB
- elif address < 0x3FFF: # 2000-2007 is PPU, up to 3FFF mirrors it every 8 bytes
+ elif address < 0x4000: # 2000-2007 is PPU, up to 3FFF mirrors it every 8 bytes
temp = ((address % 8) | 0x2000) # get data from ppu register
return self.ppu.read_register(temp)
elif address == 0x4016: # Joypad 1 status
diff --git a/NESEmulator/ppu.py b/NESEmulator/ppu.py
index 43f902c..aded774 100644
--- a/NESEmulator/ppu.py
+++ b/NESEmulator/ppu.py
@@ -83,7 +83,7 @@ def step(self):
def draw_background(self):
attribute_table_address = self.nametable_address + 0x3C0
- # 30 tiles in width and 32 tiles in height
+ # 32 tiles in width and 30 tiles in height
for y in range(30):
for x in range(32):
tile_address = self.nametable_address + y * 0x20 + x
@@ -116,17 +116,13 @@ def draw_background(self):
transparent_background = ((pixel & 3) == 0)
# if the background is transparent, we use the first color in the palette
color = self.palette[0] if transparent_background else self.palette[pixel]
- # self.display_buffer[x_screen_loc, y_screen_loc] = NES_PALETTE[color]
self.display_buffer[x_screen_loc, y_screen_loc] = NES_PALETTE[color]
- # plot pixel here draw_pixel(x_screen_loc, y_screen_loc,
- # transparent_background ? palette[0] : palette[pixel]);
def draw_sprites(self, background_transparent: bool):
for i in range(SPR_RAM_SIZE - 4, -4, -4):
y_position = self.spr[i]
if y_position == 0xFF: # 0xFF is a marker for no sprite data
continue
- # we actually draw sprites shifted one pixel down
background_sprite = bool((self.spr[i + 2] >> 5) & 1)
x_position = self.spr[i + 3]
@@ -140,15 +136,15 @@ def draw_sprites(self, background_transparent: bool):
sprite_line = y - y_position
if flip_y:
sprite_line = 7 - sprite_line
+
index = self.spr[i + 1]
bit0s_address = self.spr_pattern_table_address + (index * 16) + sprite_line
bit1s_address = self.spr_pattern_table_address + (index * 16) + sprite_line + 8
bit0s = self.read_memory(bit0s_address)
bit1s = self.read_memory(bit1s_address)
bit3and2 = ((self.spr[i + 2]) & 3) << 2
- # draw the 8 pixels on this scanline
- flip_x = bool((self.spr[i + 2] >> 6) & 1)
+ flip_x = bool((self.spr[i + 2] >> 6) & 1)
x_loc = x - x_position # position within sprite
if not flip_x:
x_loc = 7 - x_loc
@@ -166,12 +162,11 @@ def draw_sprites(self, background_transparent: bool):
# need to do this after sprite zero checking so we still count background
# sprites for sprite zero checks
if background_sprite and not background_transparent:
- continue # don't draw over opaque background pixels if this is backround sprite
+ continue # don't draw over opaque background pixels if this is background sprite
color = bit3and2 | bit1and0
color = self.read_memory(0x3F10 + color) # pull from palette
self.display_buffer[x, y] = NES_PALETTE[color]
- # draw_pixel(x, y, color)
def read_register(self, address: int) -> int:
if address == 0x2002:
diff --git a/NESEmulator/rom.py b/NESEmulator/rom.py
index 6d59fda..ddd728e 100644
--- a/NESEmulator/rom.py
+++ b/NESEmulator/rom.py
@@ -51,7 +51,7 @@ def __init__(self, filename: str):
# Read PRG_ROM and CHR_ROM, these are in multiples of 16K and 8K respectively
self.prg_rom = file.read(PRG_ROM_BASE_UNIT_SIZE * self.header.prg_rom_size)
self.chr_rom = file.read(CHR_ROM_BASE_UNIT_SIZE * self.header.chr_rom_size)
- self.prg_ram = array('B', [0] * PRG_RAM_SIZE) # sprite ram
+ self.prg_ram = array('B', [0] * PRG_RAM_SIZE) # ram
def read_mapper0(self, address: int) -> int:
if address < 0x2000:
diff --git a/requirements.txt b/requirements.txt
index ca356ff..9ba55e7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
setuptools~=68.2.2
-Pillow~=10.1.0
+Pillow~=10.3.0
pygame~=2.5.2
-numpy~=1.26.1
+numpy~=1.26.4