Merge pull request #3 from robmcmullen/extern_h

Changed header to define external vars to prevent multiple symbol def…
This commit is contained in:
David Buchanan 2018-05-17 20:33:30 +01:00 committed by GitHub
commit 5790cbaf03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 10 deletions

10
6502.c
View File

@ -4,6 +4,16 @@
#include "6502.h" #include "6502.h"
uint8_t memory[1<<16];
uint8_t A;
uint8_t X;
uint8_t Y;
uint16_t PC;
uint8_t SP;
uint8_t extra_cycles;
uint64_t total_cycles;
union StatusReg SR;
int lengths[NUM_MODES]; // instruction length table, indexed by addressing mode int lengths[NUM_MODES]; // instruction length table, indexed by addressing mode
uint8_t * (*get_ptr[NUM_MODES])(); // addressing mode decoder table uint8_t * (*get_ptr[NUM_MODES])(); // addressing mode decoder table
Instruction instructions[0x100]; // instruction data table Instruction instructions[0x100]; // instruction data table

20
6502.h
View File

@ -10,14 +10,14 @@
#define RST_VEC 0xFFFC #define RST_VEC 0xFFFC
#define IRQ_VEC 0xFFFE #define IRQ_VEC 0xFFFE
uint8_t memory[1<<16]; extern uint8_t memory[1<<16];
uint8_t A; extern uint8_t A;
uint8_t X; extern uint8_t X;
uint8_t Y; extern uint8_t Y;
uint16_t PC; extern uint16_t PC;
uint8_t SP; // points to first empty stack location extern uint8_t SP; // points to first empty stack location
uint8_t extra_cycles; extern uint8_t extra_cycles;
uint64_t total_cycles; extern uint64_t total_cycles;
void * read_addr; void * read_addr;
void * write_addr; void * write_addr;
@ -38,7 +38,7 @@ union StatusReg { // this means we can access the status register as a byte, or
uint8_t byte; uint8_t byte;
}; };
union StatusReg SR; extern union StatusReg SR;
typedef enum { typedef enum {
ACC, ACC,
@ -64,7 +64,7 @@ typedef struct {
uint8_t cycles; uint8_t cycles;
} Instruction; } Instruction;
Instruction instructions[0x100]; extern Instruction instructions[0x100];
void init_tables(); void init_tables();