From b81e3c9da73ef158339e73e14795935243558b96 Mon Sep 17 00:00:00 2001 From: Frank Buss Date: Sat, 19 Jun 2021 08:26:49 +0200 Subject: [PATCH] fixed some warnings and compiling errors, when compiling with G++ instead of GCC --- 6502-emu.c | 8 ++++---- 6502.c | 6 +++--- 6502.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/6502-emu.c b/6502-emu.c index 1d1c5ed..764d770 100644 --- a/6502-emu.c +++ b/6502-emu.c @@ -19,10 +19,10 @@ void step_delay() nanosleep(&req, &rem); } -void run_cpu(long cycle_stop, int verbose, int mem_dump, int break_pc, int fast) +void run_cpu(uint64_t cycle_stop, int verbose, int mem_dump, int break_pc, int fast) { - long cycles = 0; - int cycles_per_step = (CPU_FREQ / (ONE_SECOND / STEP_DURATION)); + uint64_t cycles = 0; + uint64_t cycles_per_step = (CPU_FREQ / (ONE_SECOND / STEP_DURATION)); for (;;) { for (cycles %= cycles_per_step; cycles < cycles_per_step;) { @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) { int a, x, y, sp, sr, pc, load_addr; int verbose, interactive, mem_dump, break_pc, fast; - long cycles; + uint64_t cycles; int opt; verbose = 0; diff --git a/6502.c b/6502.c index 15f2ddd..379d4af 100644 --- a/6502.c +++ b/6502.c @@ -416,12 +416,12 @@ static inline uint8_t stack_pull() static inline uint8_t *read_ptr() { - return read_addr = get_ptr[inst.mode](); + return (uint8_t*) (read_addr = get_ptr[inst.mode]()); } static inline uint8_t *write_ptr() { - return write_addr = get_ptr[inst.mode](); + return (uint8_t*) (write_addr = get_ptr[inst.mode]()); } /* Branch logic common to all branch instructions */ @@ -1068,7 +1068,7 @@ int step_cpu(int verbose) // returns cycle count return inst.cycles + extra_cycles; } -void save_memory(char *filename) { // dump memory for analysis (slows down emulation significantly) +void save_memory(const char *filename) { // dump memory for analysis (slows down emulation significantly) if (filename == NULL) filename = "memdump"; FILE *fp = fopen(filename, "w"); fwrite(&memory, sizeof(memory), 1, fp); diff --git a/6502.h b/6502.h index edec193..9add854 100644 --- a/6502.h +++ b/6502.h @@ -58,7 +58,7 @@ typedef enum { } Mode; typedef struct { - char *mnemonic; + const char *mnemonic; void (*function)(); Mode mode; uint8_t cycles; @@ -74,4 +74,4 @@ int load_rom(char *filename, int load_addr); int step_cpu(int verbose); -void save_memory(char *filename); +void save_memory(const char *filename);