Skip to content

Commit

Permalink
Remove PPU bus method for getting raw pointer for given address
Browse files Browse the repository at this point in the history
  • Loading branch information
SirBob01 committed Oct 15, 2023
1 parent d751ff6 commit 8984a05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
11 changes: 4 additions & 7 deletions src/ppu_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,19 @@ address_t mirror_address_ppu_bus(address_t address, rom_mirroring_t mirroring) {
return address;
}

unsigned char *get_memory_ppu_bus(ppu_bus_t *bus, address_t address) {
rom_mirroring_t mirroring = bus->rom->header.mirroring;
return bus->memory + mirror_address_ppu_bus(address, mirroring);
}

unsigned char read_ppu_bus(ppu_bus_t *bus, address_t address) {
if (address >= PPU_MAP_NAMETABLE_0) {
return *get_memory_ppu_bus(bus, address);
address = mirror_address_ppu_bus(address, bus->rom->header.mirroring);
return bus->memory[address];
} else {
return read_ppu_mapper(bus->mapper, address);
}
}

void write_ppu_bus(ppu_bus_t *bus, address_t address, unsigned char value) {
if (address >= PPU_MAP_NAMETABLE_0) {
*get_memory_ppu_bus(bus, address) = value;
address = mirror_address_ppu_bus(address, bus->rom->header.mirroring);
bus->memory[address] = value;
} else {
write_ppu_mapper(bus->mapper, address, value);
}
Expand Down
9 changes: 0 additions & 9 deletions src/ppu_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ void create_ppu_bus(ppu_bus_t *bus, rom_t *rom, mapper_t *mapper);
*/
address_t mirror_address_ppu_bus(address_t address, rom_mirroring_t mirroring);

/**
* @brief Get the physical pointer to memory for a given address.
*
* @param bus
* @param address
* @return unsigned char*
*/
unsigned char *get_memory_ppu_bus(ppu_bus_t *bus, address_t address);

/**
* @brief Read a byte from the PPU address bus.
*
Expand Down

0 comments on commit 8984a05

Please sign in to comment.