From d28ad56810b43cb3ea5d11e5e32042f69ee04562 Mon Sep 17 00:00:00 2001 From: alekseiplusplus Date: Fri, 8 Dec 2023 06:52:14 +1100 Subject: major refactor of cpu code --- src/cpu/6502.h | 53 ++++++++++++----------------------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) (limited to 'src/cpu/6502.h') diff --git a/src/cpu/6502.h b/src/cpu/6502.h index bad36fb..41ecb7a 100644 --- a/src/cpu/6502.h +++ b/src/cpu/6502.h @@ -6,7 +6,7 @@ #include"stdio.h" #include"core.h" -// FLAGS +// CPU Flags #define flag_N 0x80 // Negative #define flag_V 0x40 // Overflow #define flag_B 0x10 // BRK command @@ -15,50 +15,21 @@ #define flag_Z 0x02 // Zero #define flag_C 0x01 // Carry -byte getFlag(byte flag); -// Get the value of a flag. +// Return a truth value of 1 or 0. +byte GetFlag(byte flag); +// x can be a conditional, and any non-zero value will set the flag. void SetFlag(byte flag, int x); -// Set a flag with some value. -void flagSet(byte flag); -// Sets some flag. +// Reusable routines for setting specific flags +void SetFlag_N(byte x); +void SetFlag_V(byte x, byte y); +void SetFlag_Z(int x); -void flagClear(byte flag); -// Clears some flag. - -// Functions which perform reusable routines for finding if a specific flag should be set. - -void SetFlagN(byte x); - -//Perform prior to any changes -void SetFlagV(byte x, byte y); - -//void SetFlagB(); -//May not need since its dependent on the BRK insturction - -//void SetFlagD(); -//Might not be necessary. - -//void SetFlagI(); -//Need to work on. - -void SetFlagZ(int x); - -//void SetFlagC(); -//Only 6 instructions, 2 not including stack instructions, use the carry flag. - -// The following two may be better defined within apple.c - -//byte GetMemory(address x); -// Retrieve value from the computers address space. -// It is important not to directly access the memory array because some value hold special meaning. - -//void SetMemory(address x, byte y); -// Set a piece of memory to some value. +// Memory access declarations; to be defined somewhere computer-specific, not CPU-specific +byte GetMemory(address x); +void SetMemory(address x, byte y); +// Stack access and manipulation byte GetStack(); -// Get top value of the stack. - void SetStack(byte z); -// Set top value of the stack. \ No newline at end of file -- cgit v1.2.3