From 362341eac334ada91de79360d98924c48061a657 Mon Sep 17 00:00:00 2001 From: vin Date: Sun, 21 Jul 2024 14:48:29 -0400 Subject: [PATCH] rename struct Rom to struct rom --- cpu.c | 3 ++- ppu.h | 5 +---- rom.c | 4 ++-- rom.h | 6 +++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cpu.c b/cpu.c index 621fe5b..509f7a8 100644 --- a/cpu.c +++ b/cpu.c @@ -36,7 +36,7 @@ #define PULL() \ (peek(0x0100 + ++regs.sp)) -struct Rom rom = {0}; +struct rom rom = {0}; uint32_t cycles = 0; bool page_crossed = false; @@ -1020,6 +1020,7 @@ main(int argc, char *argv[]) parse_rom(buf, buflen, &rom); free(buf); + ppu.rom = &rom; cpu_init(); diff --git a/ppu.h b/ppu.h index 1527b93..6bc8b5a 100644 --- a/ppu.h +++ b/ppu.h @@ -11,10 +11,7 @@ struct ppu { uint8_t vram[2048]; uint8_t palette[16*2]; uint16_t cycles, scanlines; - /* copied from rom */ - uint8_t *chr_rom; - size_t chr_rom_size; - enum screen_mirroring mirror; + struct rom *rom; }; extern struct ppu ppu; diff --git a/rom.c b/rom.c index d432cc2..8360833 100644 --- a/rom.c +++ b/rom.c @@ -6,7 +6,7 @@ #include "rom.h" void -parse_rom(const uint8_t *data, size_t data_len, struct Rom *rom) +parse_rom(const uint8_t *data, size_t data_len, struct rom *rom) { size_t prg_rom_offset = 16; size_t chr_rom_offset = 0; @@ -48,7 +48,7 @@ parse_rom(const uint8_t *data, size_t data_len, struct Rom *rom) } void -free_rom(struct Rom *rom) +free_rom(struct rom *rom) { free(rom->prg_rom); if (rom->chr_rom_size > 0) diff --git a/rom.h b/rom.h index 703fabd..d27afdf 100644 --- a/rom.h +++ b/rom.h @@ -7,7 +7,7 @@ enum screen_mirroring { M_FOUR, }; -struct Rom { +struct rom { char *prg_rom; char *chr_rom; size_t prg_rom_size; @@ -16,7 +16,7 @@ struct Rom { enum screen_mirroring mirror; }; -void parse_rom(const uint8_t *data, size_t data_len, struct Rom *rom); -void free_rom(struct Rom *rom); +void parse_rom(const uint8_t *data, size_t data_len, struct rom *rom); +void free_rom(struct rom *rom); #endif /* ROM_H */