diff --git a/src/NESCarts.c b/src/NESCarts.c index c8fa240..9da49bb 100755 --- a/src/NESCarts.c +++ b/src/NESCarts.c @@ -44,9 +44,9 @@ void DumpCartProperties(FILE *out, NesCart * cart) cart->PROMSize, cart->VROMSize, cart->MapperID, - cart->Flags & iNES_MIRROR? "Horizontal" : "Vertical", - cart->Flags & iNES_BATTERY? "Yes": "No ", - cart->Flags & iNES_4SCREEN? "Yes": "No ", + (cart->Flags & iNES_MIRROR) ? "Horizontal" : "Vertical", + (cart->Flags & iNES_BATTERY)? "Yes": "No ", + (cart->Flags & iNES_4SCREEN)? "Yes": "No ", cart->PROMBanks, cart->VROMBanks); } diff --git a/src/corecpu/corecpu.c b/src/corecpu/corecpu.c index c39a1f5..48ef26b 100644 --- a/src/corecpu/corecpu.c +++ b/src/corecpu/corecpu.c @@ -152,7 +152,7 @@ cpu->reg_P = (cpu->reg_P & ~(Q6502_C_FLAG | Q6502_N_FLAG | Q6502_Z_FLAG | Q6502_V_FLAG)) | \ (tmp & 0x80) | ((tmp&0xFF)?0:Q6502_Z_FLAG) | \ ((tmp & 0xFF00)?Q6502_C_FLAG:0) | \ - ( ( ~(cpu->reg_A^v)&(cpu->reg_A^tmp) )&0x80?Q6502_V_FLAG:0 ); \ + ( (( ~(cpu->reg_A^v)&(cpu->reg_A^tmp) ))&0x80?Q6502_V_FLAG:0 ); \ cpu->reg_A = tmp & 0xFF; \ } while(0) @@ -162,7 +162,7 @@ cpu->reg_P = (cpu->reg_P & ~(Q6502_C_FLAG | Q6502_N_FLAG | Q6502_Z_FLAG | Q6502_V_FLAG)) | \ (tmp & Q6502_N_FLAG) | ((tmp&0xFF)?0:Q6502_Z_FLAG) | \ ((tmp & 0xFF00)?0:Q6502_C_FLAG) | \ - ( ( (cpu->reg_A^v)&(cpu->reg_A^tmp) )&0x80?Q6502_V_FLAG:0 ); \ + ( (( (cpu->reg_A^v)&(cpu->reg_A^tmp) )&0x80)?Q6502_V_FLAG:0 ); \ cpu->reg_A = tmp & 0xFF; \ } while(0) @@ -340,7 +340,7 @@ void quick6502_reset(quick6502_cpu *cpu) */ int quick6502_run(quick6502_cpu *cpu, int cycles) { - cpu->running = !0; + cpu->running = true; while(cpu->cycle_done < cycles) { @@ -348,7 +348,7 @@ int quick6502_run(quick6502_cpu *cpu, int cycles) } cpu->cycle_done -= cycles; - cpu->running = 0; + cpu->running = false; return cycles + cpu->cycle_done; } @@ -356,20 +356,20 @@ int quick6502_run(quick6502_cpu *cpu, int cycles) /** Loop CPU until explicit quit */ void quick6502_loop(quick6502_cpu *cpu) { - cpu->running = !0; + cpu->running = true; while(cpu->exit_loop) { quick6502_exec_one(cpu); } - cpu->running = 0; + cpu->running = false; } /** Run CPU for one instruction */ void quick6502_exec(quick6502_cpu *cpu) { - cpu->running = !0; + cpu->running = true; quick6502_exec_one(cpu); - cpu->running = 0; + cpu->running = false; } /** Send IRQ/NMI/EXITLOOP signal to CPU */ @@ -425,14 +425,14 @@ void quick6502_dump(quick6502_cpu *cpu, FILE * fp) fprintf(fp, "## Quick6502: PC:$%04X A:$%02X X:$%02X Y:$%02X S:$%02X P:$%02X [%c%c%c%c%c%c%c%c]\n", cpu->reg_PC, cpu->reg_A, cpu->reg_X, cpu->reg_Y, cpu->reg_S, cpu->reg_P, - cpu->reg_P&Q6502_N_FLAG ? 'N':'.', - cpu->reg_P&Q6502_V_FLAG ? 'V':'.', - '.', /* No real flag here */ - cpu->reg_P&Q6502_B_FLAG ? 'B':'.', - cpu->reg_P&Q6502_D_FLAG ? 'D':'.', - cpu->reg_P&Q6502_I_FLAG ? 'I':'.', - cpu->reg_P&Q6502_Z_FLAG ? 'Z':'.', - cpu->reg_P&Q6502_C_FLAG ? 'C':'.' + (cpu->reg_P&Q6502_N_FLAG) ? 'N':'.', + (cpu->reg_P&Q6502_V_FLAG) ? 'V':'.', + '.', /* No real flag here */ + (cpu->reg_P&Q6502_B_FLAG) ? 'B':'.', + (cpu->reg_P&Q6502_D_FLAG) ? 'D':'.', + (cpu->reg_P&Q6502_I_FLAG) ? 'I':'.', + (cpu->reg_P&Q6502_Z_FLAG) ? 'Z':'.', + (cpu->reg_P&Q6502_C_FLAG) ? 'C':'.' ); /* Display stack */ @@ -450,7 +450,7 @@ void quick6502_dump(quick6502_cpu *cpu, FILE * fp) } fprintf(fp, "]\n"); - quick6502_getinstruction(cpu, (1==1), cpu->reg_PC, instr, NULL); + quick6502_getinstruction(cpu, true, cpu->reg_PC, instr, NULL); fprintf(fp, "## $%04X: %s\n", cpu->reg_PC, instr); } @@ -1923,7 +1923,7 @@ INSTRUCTION(INCzX) /* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */ }; -#ifdef MINE +#if 1 typedef enum InstructionType { @@ -2215,7 +2215,7 @@ int quick6502_getinstruction(quick6502_cpu *cpu, char interpret, case IP_aBc: buffer += strlen(sprintf(buffer, IPf_aB, cpu->memory_opcode_read(cpu->reg_PC + 2), cpu->memory_opcode_read(cpu->reg_PC + 1))); break; case IP_aXc: buffer += strlen(sprintf(buffer, IPf_aX, cpu->memory_opcode_read(cpu->reg_PC + 2), cpu->memory_opcode_read(cpu->reg_PC + 1))); break; case IP_aYc: buffer += strlen(sprintf(buffer, IPf_aY, cpu->memory_opcode_read(cpu->reg_PC + 2), cpu->memory_opcode_read(cpu->reg_PC + 1))); break; - case IP_rEc: buffer += strlen(sprintf(buffer, IPf_rE, cpu->reg_PC + (signed char) cpu->memory_opcode_read(cpu->reg_PC) + 1)); break; + case IP_rEc: buffer += strlen(sprintf(buffer, IPf_rE, 0, cpu->reg_PC + (signed char) cpu->memory_opcode_read(cpu->reg_PC) + 1)); break; } *buffer = 0; diff --git a/src/os/macos/io.c b/src/os/macos/io.c index 1d3cc69..98fc4be 100644 --- a/src/os/macos/io.c +++ b/src/os/macos/io.c @@ -40,7 +40,6 @@ int console_vprintf(const ConsoleLevel level, const char *format, va_list ap) int console_printf(const ConsoleLevel level, const char *format, ...) { - int ret = 0; va_list ap; va_start(ap, format); @@ -56,6 +55,8 @@ int console_printf_d(const char *format, ...) va_start(ap, format); console_vprintf (Console_Debug, format, ap); - + + va_end(ap); + return 0; } diff --git a/src/os/macos/loadfile.c b/src/os/macos/loadfile.c index 0c41d76..760d38b 100644 --- a/src/os/macos/loadfile.c +++ b/src/os/macos/loadfile.c @@ -30,7 +30,7 @@ void *LoadFilePtr(char * filename) { int fd; - void *RetPtr = NULL; + void *RetPtr; struct stat FileStat; fd = open(filename, O_RDONLY); diff --git a/src/os/unix/graphics_dummy.c b/src/os/unix/graphics_dummy.c index b9c572c..669b61c 100644 --- a/src/os/unix/graphics_dummy.c +++ b/src/os/unix/graphics_dummy.c @@ -30,7 +30,6 @@ struct KeyArray unsigned char lastState; unsigned char curState; unsigned char debounced; - GLFWwindow* window; }; struct GLWindow_t diff --git a/src/os/unix/io.c b/src/os/unix/io.c index 7eda058..c5b8af6 100644 --- a/src/os/unix/io.c +++ b/src/os/unix/io.c @@ -55,6 +55,8 @@ int console_printf_d(const char *format, ...) va_start(ap, format); console_vprintf (Console_Debug, format, ap); - + + va_end(ap); + return 0; } diff --git a/src/os/unix/loadfile.c b/src/os/unix/loadfile.c index f68839c..908946e 100644 --- a/src/os/unix/loadfile.c +++ b/src/os/unix/loadfile.c @@ -19,7 +19,7 @@ void *LoadFilePtr(char * filename) { int fd; - void *RetPtr = NULL; + void *RetPtr; struct stat FileStat; fd = open(filename, O_RDONLY); diff --git a/src/os/win32/io.c b/src/os/win32/io.c index cfb3426..c43774d 100644 --- a/src/os/win32/io.c +++ b/src/os/win32/io.c @@ -40,7 +40,6 @@ int console_vprintf(const ConsoleLevel level, const char *format, va_list ap) int console_printf(const ConsoleLevel level, const char *format, ...) { - int ret = 0; va_list ap; va_start(ap, format); @@ -56,6 +55,8 @@ int console_printf_d(const char *format, ...) va_start(ap, format); console_vprintf (Console_Debug, format, ap); - + + va_end(ap); + return 0; } \ No newline at end of file diff --git a/src/os/win32/loadfile.c b/src/os/win32/loadfile.c index 692124b..9b06d8e 100644 --- a/src/os/win32/loadfile.c +++ b/src/os/win32/loadfile.c @@ -19,7 +19,7 @@ void *LoadFilePtr(char * filename) { int fd; - void *RetPtr = NULL; + void *RetPtr; struct stat FileStat; fd = open(filename, O_RDONLY); diff --git a/src/utils/bin2h/bin2h.c b/src/utils/bin2h/bin2h.c index 5a433d5..229e938 100755 --- a/src/utils/bin2h/bin2h.c +++ b/src/utils/bin2h/bin2h.c @@ -85,5 +85,14 @@ int main(int argc, char *argv[]) } fprintf(fpout, "\n\t\t};\n"); + if (fpin != stdin) + { + fclose(fpin); + } + if (fpout != stdout) + { + fclose(fpout); + } + return 0; }