More changes
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#ifndef NESCARTS_H
|
||||
#define NESCARTS_H
|
||||
|
||||
#include "types.h"
|
||||
#include <types.h>
|
||||
|
||||
#define iNES_MIRROR 0x01
|
||||
#define iNES_BATTERY 0x02
|
||||
|
||||
@@ -129,7 +129,7 @@ int MIDILogging(int Switch);
|
||||
void MIDITicks(int N);
|
||||
|
||||
//#ifdef UNIX
|
||||
#define SND_CHANNELS 16 /* Number of channels */
|
||||
#define SND_CHANNELS 4 /* Number of channels */
|
||||
#define SND_SAMPLESIZE 256 /* Max. SetWave() sample size */
|
||||
#define SND_BUFSIZE 256 /* Buffer size, <= 2^SND_BITS */
|
||||
#define SND_BITS 8 /* Number of bits in a fragment */
|
||||
|
||||
164
src/include/corecpu.h
Normal file
164
src/include/corecpu.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* CoreCPU - The Quick6502 Project
|
||||
* corecpu.h
|
||||
*
|
||||
* Created by Manoel Trapier on 24/02/08
|
||||
* Copyright 2008 986 Corp. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate$
|
||||
* $Author$
|
||||
* $HeadURL$
|
||||
* $Revision$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _QUICK6502_CORECPU_H_
|
||||
#define _QUICK6502_CORECPU_H_
|
||||
|
||||
/* M6502 configuration
|
||||
*
|
||||
* Supported DEFINEs :
|
||||
* NO_DECIMAL Quick6502 will not support BDC arithemtic (used for NES)
|
||||
* CMOS_6502 Quick6502 will act as a CMOS 6502 (Not actually used)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef CMOS_6502
|
||||
//#warning Quick6502 CMOS support is actually desactivated, desactivate it
|
||||
#undef CMOS_6502
|
||||
#endif
|
||||
|
||||
#ifndef NO_DECIMAL
|
||||
//#warning Quick6502 have actually no BCD support, fallback to no NO_DECIMAL
|
||||
#define NO_DECIMAL
|
||||
#endif
|
||||
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef byte (*quick6502_MemoryReadFunction)(unsigned short addr);
|
||||
typedef void (*quick6502_MemoryWriteFunction)(unsigned short addr, byte value);
|
||||
|
||||
typedef struct quick6502_cpu_
|
||||
{
|
||||
/* 6502 registers */
|
||||
byte reg_A, reg_X, reg_Y;
|
||||
byte reg_P, reg_S;
|
||||
unsigned short reg_PC;
|
||||
|
||||
/* Read/Write memory functions */
|
||||
quick6502_MemoryReadFunction memory_read;
|
||||
quick6502_MemoryWriteFunction memory_write;
|
||||
quick6502_MemoryReadFunction memory_page0_read;
|
||||
quick6502_MemoryWriteFunction memory_page0_write;
|
||||
quick6502_MemoryReadFunction memory_stack_read;
|
||||
quick6502_MemoryWriteFunction memory_stack_write;
|
||||
quick6502_MemoryReadFunction memory_opcode_read;
|
||||
|
||||
/* Timing related */
|
||||
long cycle_done;
|
||||
byte exit_loop;
|
||||
byte int_pending;
|
||||
|
||||
/* Other config options */
|
||||
byte running; /* This field is used to prevent cpu free if this cpu is running */
|
||||
byte page_crossed;
|
||||
} quick6502_cpu;
|
||||
|
||||
typedef struct quick6502_cpuconfig_
|
||||
{
|
||||
/* Read/Write memory functions */
|
||||
quick6502_MemoryReadFunction memory_read;
|
||||
quick6502_MemoryWriteFunction memory_write;
|
||||
quick6502_MemoryReadFunction memory_page0_read;
|
||||
quick6502_MemoryWriteFunction memory_page0_write;
|
||||
quick6502_MemoryReadFunction memory_stack_read;
|
||||
quick6502_MemoryWriteFunction memory_stack_write;
|
||||
quick6502_MemoryReadFunction memory_opcode_read;
|
||||
} quick6502_cpuconfig;
|
||||
|
||||
/*** Signal that we can send to the CPU ***/
|
||||
typedef enum
|
||||
{
|
||||
Q6502_NO_SIGNAL = 0,
|
||||
Q6502_IRQ_SIGNAL,
|
||||
Q6502_NMI_SIGNAL,
|
||||
Q6502_STOPLOOP_SIGNAL
|
||||
} quick6502_signal;
|
||||
|
||||
/*** Some 6502 related definitions ***/
|
||||
|
||||
/*** P register flags ***/
|
||||
#define Q6502_N_FLAG 0x80 /* Negavite flag */
|
||||
#define Q6502_V_FLAG 0x40 /* oVerflow flag */
|
||||
#define Q6502_R_FLAG 0x20 /* Not a real flag, but need to be to 1 on PHP */
|
||||
#define Q6502_B_FLAG 0x10 /* Break flag */
|
||||
#define Q6502_D_FLAG 0x08 /* BCD flag */
|
||||
#define Q6502_I_FLAG 0x04 /* IRQ/BRK flag */
|
||||
#define Q6502_Z_FLAG 0x02 /* Zero flag */
|
||||
#define Q6502_C_FLAG 0x01 /* Carry flag */
|
||||
|
||||
/*** Interuption Vectors ***/
|
||||
#define Q6502_NMI_LOW 0xFFFA
|
||||
#define Q6502_NMI_HIGH 0xFFFB
|
||||
#define Q6502_RESET_LOW 0xFFFC
|
||||
#define Q6502_RESET_HIGH 0xFFFD
|
||||
#define Q6502_IRQ_LOW 0xFFFE
|
||||
#define Q6502_IRQ_HIGH 0xFFFF
|
||||
|
||||
/**
|
||||
* Initialise the CPU
|
||||
*
|
||||
* Inputs:
|
||||
*
|
||||
* - CPU Init structure:
|
||||
* +- Memory Read function pointer
|
||||
* +- Memory Write function pointer
|
||||
* +- Fast memory read function pointer (for opcodes read)
|
||||
* +- Fast page 0 function / Read/Write
|
||||
* +- Fast page 1 function / Read/Write
|
||||
*
|
||||
* Output:
|
||||
*
|
||||
* (void *): An opaque pointer to the internal structure of the CPU
|
||||
*
|
||||
*/
|
||||
quick6502_cpu *quick6502_init(quick6502_cpuconfig *config);
|
||||
|
||||
/* Reset the CPU (must be done after init) */
|
||||
void quick6502_reset(quick6502_cpu *cpu);
|
||||
|
||||
/**
|
||||
* Run cpu for at least X cycles
|
||||
*
|
||||
* Output:
|
||||
*
|
||||
* int: (Number of cycle really done) - (Number of cycle asked)
|
||||
*/
|
||||
int quick6502_run(quick6502_cpu *cpu, int cycles);
|
||||
|
||||
/** Loop CPU until explicit quit */
|
||||
void quick6502_loop(quick6502_cpu *cpu);
|
||||
|
||||
/** Run CPU for one instruction */
|
||||
void quick6502_exec(quick6502_cpu *cpu);
|
||||
|
||||
/** Send IRQ/NMI/EXITLOOP signal to CPU */
|
||||
void quick6502_int(quick6502_cpu *cpu, quick6502_signal signal);
|
||||
|
||||
/** Dump CPU State to the given file */
|
||||
void quick6502_dump(quick6502_cpu *cpu, FILE * fp);
|
||||
|
||||
/** Get current instruction name at specified address and put it into buffer */
|
||||
void quick6502_getinstruction(quick6502_cpu *cpu, unsigned short addr, char *buffer);
|
||||
|
||||
/**
|
||||
* Free the CPU
|
||||
*
|
||||
* This function will free the CPU only if it's not currently used, it will
|
||||
* return !0 if everything goes well and 0 if the free is impossible
|
||||
*/
|
||||
int quick6502_free(quick6502_cpu *cpu);
|
||||
|
||||
#endif /* _QUICK6502_CORECPU_H_ */
|
||||
|
||||
@@ -29,6 +29,7 @@ typedef void (*MapperDump) ();
|
||||
|
||||
#include <ppu/ppu.h>
|
||||
#include <memory/manager.h>
|
||||
#include <os_dependent.h>
|
||||
|
||||
extern NesCart *Cart;
|
||||
|
||||
|
||||
45
src/include/os_dependent.h
Normal file
45
src/include/os_dependent.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* OS Dependent functions - The TI-NESulator Project
|
||||
* os_dependent.h
|
||||
*
|
||||
* Created by Manoel TRAPIER on 08/05/08.
|
||||
* Copyright (c) 2003-2008 986Corp. All rights reserved.
|
||||
*
|
||||
* $LastChangedDate$
|
||||
* $Author$
|
||||
* $HeadURL$
|
||||
* $Revision$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef OS_DEPENDENT_H
|
||||
#define OS_DEPENDENT_H
|
||||
|
||||
/* File related functions */
|
||||
/* Graphics related functions */
|
||||
int graphics_init();
|
||||
int graphics_drawpixel(long x, long y, long color);
|
||||
int graphics_blit(long x, long y, long w, long h);
|
||||
|
||||
/* Sound related functions */
|
||||
|
||||
/* IO functions */
|
||||
void *LoadFilePtr(char * filename);
|
||||
|
||||
/* Console functions */
|
||||
typedef enum ConsoleLevel_t
|
||||
{
|
||||
Console_Error = 0,
|
||||
Console_Warning,
|
||||
Console_Alert,
|
||||
Console_Default,
|
||||
Console_Verbose,
|
||||
Console_Debug,
|
||||
} ConsoleLevel;
|
||||
|
||||
|
||||
int console_init(ConsoleLevel DefaultLevel);
|
||||
int console_printf(const ConsoleLevel level, const char *format, ...);
|
||||
int console_printf_d(const char *format, ...);
|
||||
|
||||
#endif /* OS_DEPENDENT_H */
|
||||
@@ -262,5 +262,5 @@ PALETTE basicPalette = {
|
||||
{ 0x29, 0x3C, 0x3C, 0x08 },
|
||||
{ 0x32, 0x31, 0x32, 0xB7 },
|
||||
{ 0x01, 0x01, 0x01, 0x08 },
|
||||
{ 0x01, 0x01, 0x01, 0xBF }
|
||||
{ 0x01, 0x01, 0x01, 0xBF },
|
||||
};
|
||||
|
||||
@@ -27,6 +27,8 @@ void ppu_memoryDumpState(FILE *fp);
|
||||
byte ppu_readMemory(byte page, byte addr);
|
||||
void ppu_writeMemory(byte page, byte addr, byte value);
|
||||
|
||||
void ppu_setPageGhost(byte page, bool value, byte ghost);
|
||||
|
||||
#else
|
||||
#error Must only be included inside the PPU code
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user