TI-NESulator SVN reimport

This commit is contained in:
godzil
2008-02-20 15:40:31 +00:00
commit 3f4b4990ea
67 changed files with 19026 additions and 0 deletions

1038
src/include/MIDIFreq.h Normal file

File diff suppressed because it is too large Load Diff

39
src/include/NESCarts.h Executable file
View File

@@ -0,0 +1,39 @@
/*
* Cart manager - The TI-NESulator Project
* NESCart.h
*
* Created by Manoel TRAPIER.
* Copyright (c) 2003-2007 986Corp. All rights reserved.
*
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
* $Author: godzil $
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/NESCarts.h $
* $Revision: 39 $
*/
#ifndef NESCARTS_H
#define NESCARTS_H
#include "types.h"
#define iNES_MIRROR 0x01
#define iNES_BATTERY 0x02
#define iNES_TRAINER 0x04
#define iNES_4SCREEN 0x08
typedef struct NesCart_
{
unsigned long PROMSize, /* Size of PROM */
VROMSize; /* Size of VROM */
char MapperID; /* Mapper Type */
byte Flags;
char *FileName;
byte *File; /* Pointer on the file in memory */
byte *PROMBanks; /* Pointer on the first PROM */
byte *VROMBanks; /* Pointer on the first VROM */
} NesCart;
void DumpCartProperties();
int LoadCart(const char *filename, NesCart * cart);
#endif

232
src/include/Sound.h Normal file
View File

@@ -0,0 +1,232 @@
/** EMULib Emulation Library *********************************/
/** **/
/** Sound.h **/
/** **/
/** This file defines standard sound generation API and **/
/** functions needed to log soundtrack into a MIDI file. **/
/** See Sound.c and the sound drivers for the code. **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-2007 **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/*************************************************************/
#ifndef SOUND_H
#define SOUND_H
#ifdef __cplusplus
extern "C" {
#endif
/* SetSound() arguments: */
#define SND_MELODIC 0 /* Melodic sound (default) */
#define SND_RECTANGLE 0 /* Rectangular wave */
#define SND_QS_DU0 5
#define SND_QS_DU1 6
#define SND_QS_DU2 7
#define SND_QS_DU3 8
#define SND_TRIANGLE 1 /* Triangular wave (1/2 rect.)*/
#define SND_NOISE 2 /* White noise */
#define SND_PERIODIC 3 /* Periodic noise (not im-ed) */
#define SND_WAVE 4 /* Wave sound set by SetWave()*/
#define SND_MIDI 0x100 /* MIDI instrument (ORable) */
/* Drum() arguments: */
#define DRM_CLICK 0 /* Click (default) */
#define DRM_MIDI 0x100 /* MIDI drum (ORable) */
/* MIDI characteristics: */
#define MIDI_CHANNELS 16 /* Number of MIDI channels */
#define MIDI_MINFREQ 9 /* Min MIDI frequency (Hz) */
#define MIDI_MAXFREQ 12285 /* Max MIDI frequency (Hz) */
#define MIDI_DIVISIONS 1000 /* Number of ticks per second */
/* MIDILogging() arguments: */
#define MIDI_OFF 0 /* Turn MIDI logging off */
#define MIDI_ON 1 /* Turn MIDI logging on */
#define MIDI_TOGGLE 2 /* Toggle MIDI logging */
#define MIDI_QUERY 3 /* Query MIDI logging status */
/** TrashSound() *********************************************/
/** Shut down sound driver. Each driver implements its own **/
/** TrashSound() function. **/
/*************************************************************/
void TrashSound(void);
/** Sound() **************************************************/
/** Generate sound of given frequency (Hz) and volume **/
/** (0..255) via given channel. Setting Freq=0 or Volume=0 **/
/** turns sound off. **/
/*************************************************************/
void Sound(int Channel,int Freq,int Volume);
/** Drum() ***************************************************/
/** Hit a drum of given type with given force (0..255). **/
/** MIDI drums can be used by ORing their numbers with **/
/** SND_MIDI. **/
/*************************************************************/
void Drum(int Type,int Force);
/** SetSound() ***********************************************/
/** Set sound type at a given channel. MIDI instruments can **/
/** be set directly by ORing their numbers with SND_MIDI. **/
/*************************************************************/
void SetSound(int Channel,int NewType);
/** SetChannels() ********************************************/
/** Set master volume (0..255) and switch channels on/off. **/
/** Each channel N has corresponding bit 2^N in Switch. Set **/
/** or reset this bit to turn the channel on or off. **/
/*************************************************************/
void SetChannels(int Volume,int Switch);
/** SetWave() ************************************************/
/** Set waveform for a given channel. The channel will be **/
/** marked with sound type SND_WAVE. Set Rate=0 if you want **/
/** waveform to be an instrument or set it to the waveform **/
/** own playback rate. **/
/*************************************************************/
void SetWave(int Channel,const signed char *Data,int Length,int Rate);
/** GetWave() ************************************************/
/** Get current read position for the buffer set with the **/
/** SetWave() call. Returns 0 if no buffer has been set, or **/
/** if there is no playrate set (i.e. wave is instrument). **/
/*************************************************************/
const signed char *GetWave(int Channel);
/** InitMIDI() ***********************************************/
/** Initialize soundtrack logging into MIDI file FileName. **/
/** Repeated calls to InitMIDI() will close current MIDI **/
/** file and continue logging into a new one. **/
/*************************************************************/
void InitMIDI(const char *FileName);
/** TrashMIDI() **********************************************/
/** Finish logging soundtrack and close the MIDI file. **/
/*************************************************************/
void TrashMIDI(void);
/** MIDILogging() ********************************************/
/** Turn soundtrack logging on/off and return its current **/
/** status. Possible values of Switch are MIDI_OFF (turn **/
/** logging off), MIDI_ON (turn logging on), MIDI_TOGGLE **/
/** (toggle logging), and MIDI_QUERY (just return current **/
/** state of logging). **/
/*************************************************************/
int MIDILogging(int Switch);
/** MIDITicks() **********************************************/
/** Log N 1ms MIDI ticks. **/
/*************************************************************/
void MIDITicks(int N);
//#ifdef UNIX
#define SND_CHANNELS 16 /* 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 */
#define SND_BUFFERS 64 /* Number of fragments, >= 2 */
/* Bigger value results in better behaviour on loaded */
/* but output gets more delayed. */
/** InitSound() **********************************************/
/** Initialize Unix sound driver with given synthesis rate. **/
/** Returns Rate on success, 0 otherwise. Pass Rate=0 to **/
/** skip initialization and be silent. Pass Verbose!=0 to **/
/** see initialization messages. **/
/*************************************************************/
#warning You Suck !
int InitSound(int Rate,int Verbose);
/** StopSound() **********************************************/
/** Temporarily suspend sound. **/
/*************************************************************/
void StopSound(void);
/** ResumeSound() ********************************************/
/** Resume sound after StopSound(). **/
/*************************************************************/
void ResumeSound(void);
//#endif /* UNIX */
#ifdef MSDOS
#define SND_CHANNELS 16 /* Number of sound channels */
#define OPL_CHANNELS 7 /* Number of Adlib channels */
#define SND_SAMPLESIZE 256 /* Max. SetWave() sample size */
#define SND_BUFSIZE 512 /* Buffer size for DMA */
#define SND_MAXDELAY 10 /* Maximal sound delay 1/n s */
/** InitSound() **********************************************/
/** Initialize sound. Returns Rate on success, 0 otherwise. **/
/** Rate=0 to skip initialization (will be silent). **/
/*************************************************************/
int InitSound(unsigned int Rate,unsigned int Latency);
#endif /* MSDOS */
#ifdef WINDOWS
#define SND_CHANNELS 16 /* Number of channels */
#define SND_SAMPLESIZE 256 /* Max. SetWave() sample size */
#define SND_BUFSIZE 512 /* Size of a wave buffer */
#define SND_BUFFERS 32 /* Number of wave buffers */
#include <Windows.h>
/** InitSound() **********************************************/
/** Initialize Windows sound driver with given synthesis **/
/** rate. Returns Rate on success, 0 otherwise. Pass Rate=0 **/
/** to skip initialization and be silent. Pass Rate=1 to **/
/** use MIDI (midiOut). Pass Rate=8192..44100 to use wave **/
/** synthesis (waveOut). Number of wave synthesis buffers **/
/** must be in 2..SND_BUFFERS range. **/
/*************************************************************/
unsigned int InitSound(unsigned int Rate,unsigned int Delay);
#endif /* WINDOWS */
#if 0
#ifndef MSDOS
#ifndef WINDOWS
#ifndef UNIX
#define SND_CHANNELS MIDI_CHANNELS /* Default number */
#endif
#endif
#endif
/** InitSound() **********************************************/
/** Initialize Series60 sound driver with given synthesis **/
/** rate. Returns Rate on success, 0 otherwise. Pass Rate=0 **/
/** to skip initialization and be silent. **/
/*************************************************************/
unsigned int InitSound(unsigned int Rate,unsigned int Delay);
#endif
/** RenderAudio() ********************************************/
/** Render given number of melodic sound samples. Returns **/
/** number of samples actually rendered. **/
/*************************************************************/
unsigned int RenderAudio(unsigned int Samples);
/** SndDriver ************************************************/
/** Each sound driver should fill this structure with **/
/** pointers to hardware-dependent handlers. This has to be **/
/** done inside the InitSound() function. **/
/*************************************************************/
struct SndDriverStruct
{
void (*SetSound)(int Channel,int NewType);
void (*Drum)(int Type,int Force);
void (*SetChannels)(int Volume,int Switch);
void (*Sound)(int Channel,int NewFreq,int NewVolume);
void (*SetWave)(int Channel,const signed char *Data,int Length,int Freq);
const signed char *(*GetWave)(int Channel);
};
extern struct SndDriverStruct SndDriver;
#ifdef __cplusplus
}
#endif
#endif /* SOUND_H */

60
src/include/mappers/manager.h Executable file
View File

@@ -0,0 +1,60 @@
/*
* Mappers manager & facilities - The TI-NESulator Project
* mappers.h
*
* Created by Manoel TRAPIER.
* Copyright (c) 2003-2007 986Corp. All rights reserved.
*
* $LastChangedDate$
* $Author$
* $HeadURL$
* $Revision$
*
*/
#ifndef MAPPERS_H
#define MAPPERS_H
#include <types.h>
#include <stdio.h>
#include <NESCarts.h>
typedef int (*MapperInit) (NesCart * cart);
typedef int (*MapperWriteHook) (register unsigned short Addr,
register unsigned char Value);
typedef int (*MapperIRQ) (int cycledone);
typedef void (*MapperDump) ();
#ifdef __TINES_MAPPERS__
extern NesCart *Cart;
/* Available functions for mappers */
#define GETLAST08KBANK(c) ((c->PROMSize>>13)-1)
#define GETLAST16KBANK(c) ((c->PROMSize>>14)-1)
#define GETLAST32KBANK(c) ((c->PROMSize>>15)-1)
void map_sram(); /* Map SRAM */
void unmap_sram(); /* Unmap SRAM */
void set_vrom_bank_1k(unsigned short addr,int slot);
void set_vrom_bank_2k(unsigned short addr,int slot);
void set_vrom_bank_4k(unsigned short addr,int slot);
void set_vrom_bank_8k(unsigned short addr, int slot);
void set_prom_bank_8k(unsigned short addr,int slot);
void set_prom_bank_16k(unsigned short addr,int slot);
void set_prom_bank_32k(unsigned short addr,int slot);
#else /* __TINES_MAPPERS__ */
/* Available functions outside of mappers */
void mapper_list ();
int mapper_init (NesCart *cart);
extern int (*mapper_irqloop) (int cyclodone);
extern void (*mapper_dump) (FILE *fp);
#endif /* __TINES_MAPPERS__ */
#endif

68
src/include/memory/manager.h Executable file
View File

@@ -0,0 +1,68 @@
/*
* 6502 Memory manager - The TI-NESulator Project
* memory.h - Taken from the Quick6502 project
*
* Created by Manoël Trapier on 18/09/06.
* Copyright 2003-2007 986 Corp. All rights reserved.
*
* $LastChangedDate: 2007-04-05 16:30:20 +0200 (jeu, 05 avr 2007) $
* $Author: mtrapier $
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/memory.h $
* $Revision: 31 $
*
*/
#ifndef MEMORY_H
#define MEMORY_H
#include "types.h"
#define ATTR_PAGE_HAVE_RDHOOK 0x20
#define ATTR_PAGE_HAVE_WRHOOK 0x10
#define ATTR_PAGE_WRITEABLE 0x08
#define ATTR_PAGE_READABLE 0x04
#define ATTR_PAGE_GHOST 0x02
#define ATTR_PAGE_MAPPED 0x01
typedef byte (*func_rdhook)(byte /* addr */);
typedef void (*func_wrhook)(byte addr, byte data);
/* Functions to manage pages data */
void set_page_ptr(byte page, byte *ptr);
void set_page_ptr_1k(byte page, byte *ptr);
void set_page_ptr_2k(byte page, byte *ptr);
void set_page_ptr_4k(byte page, byte *ptr);
void set_page_ptr_8k(byte page, byte *ptr);
void set_page_ptr_16k(byte page, byte *ptr);
void set_page_ptr_32k(byte page, byte *ptr);
byte *get_page_ptr(byte page);
/* Functions to set pages attributes */
void set_page_rd_hook(byte page, func_rdhook func);
void set_page_wr_hook(byte page, func_wrhook func);
void set_page_readable(byte page, bool value);
void set_page_writeable(byte page, bool value);
void set_page_ghost(byte page, bool value, byte ghost);
byte get_page_attributes(byte page);
func_rdhook get_page_rdhook(byte page);
func_wrhook get_page_wrhook(byte page);
/* Generalist functions */
void InitMemory();
byte ReadMemory(byte page, byte addr);
void WriteMemory(byte page, byte addr, byte value);
void DumpMemoryState();
#endif

36
src/include/paddle.h Executable file
View File

@@ -0,0 +1,36 @@
/*
* Paddle manager - The TI-NESulator Project
* paddle.h
*
* Created by Manoel TRAPIER.
* Copyright (c) 2003-2007 986Corp. All rights reserved.
*
* $LastChangedDate: 2007-04-16 01:55:35 +0200 (lun, 16 avr 2007) $
* $Author: godzil $
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/paddle.h $
* $Revision: 39 $
*
*/
#ifndef PADDLE_H
#define PADDLE_H
typedef struct Paddle_
{
unsigned char Bit;
unsigned char LastWrite;
} Paddle;
unsigned char ReadPaddle(Paddle * pdl);
void InitPaddle(Paddle * pdl);
void WritePaddle(Paddle * pdl, unsigned char val);
#endif

261
src/include/palette.h Normal file
View File

@@ -0,0 +1,261 @@
/* Generated data file from file 'stdin' */
PALETTE basicPalette = {
{ 0x1E, 0x1E, 0x1E, 0x07 },
{ 0x03, 0x09, 0x28, 0xB7 },
{ 0x0A, 0x04, 0x2B, 0x0D },
{ 0x17, 0x02, 0x28, 0x00 },
{ 0x22, 0x00, 0x1D, 0xB7 },
{ 0x24, 0x01, 0x0A, 0xB7 },
{ 0x24, 0x04, 0x02, 0xB7 },
{ 0x1B, 0x09, 0x01, 0xB7 },
{ 0x11, 0x10, 0x01, 0x00 },
{ 0x05, 0x15, 0x01, 0x00 },
{ 0x01, 0x17, 0x02, 0xB7 },
{ 0x00, 0x14, 0x0B, 0xBF },
{ 0x01, 0x11, 0x1B, 0xBF },
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0xB7 },
{ 0x2F, 0x30, 0x2F, 0xB7 },
{ 0x05, 0x1A, 0x37, 0xBF },
{ 0x12, 0x10, 0x3B, 0xBF },
{ 0x23, 0x09, 0x38, 0xB7 },
{ 0x31, 0x06, 0x2E, 0xBF },
{ 0x35, 0x08, 0x18, 0xB7 },
{ 0x35, 0x0D, 0x08, 0x00 },
{ 0x2D, 0x16, 0x03, 0xB7 },
{ 0x22, 0x1E, 0x01, 0x00 },
{ 0x0E, 0x24, 0x01, 0x00 },
{ 0x05, 0x26, 0x06, 0x00 },
{ 0x02, 0x26, 0x16, 0xB7 },
{ 0x02, 0x22, 0x2A, 0xBF },
{ 0x0B, 0x0B, 0x0B, 0xBF },
{ 0x00, 0x00, 0x00, 0x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, 0x00 },
{ 0x1B, 0x09, 0x01, 0x00 },
{ 0x11, 0x10, 0x01, 0x00 },
{ 0x05, 0x15, 0x01, 0xB7 },
{ 0x01, 0x17, 0x02, 0x00 },
{ 0x00, 0x14, 0x0B, 0xB7 },
{ 0x01, 0x11, 0x1B, 0x50 },
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0xB7 },
{ 0x2F, 0x30, 0x2F, 0xBF },
{ 0x05, 0x1A, 0x37, 0xB7 },
{ 0x12, 0x10, 0x3B, 0xB7 },
{ 0x23, 0x09, 0x38, 0x20 },
{ 0x31, 0x06, 0x2E, 0xBF },
{ 0x35, 0x08, 0x18, 0xB7 },
{ 0x35, 0x0D, 0x08, 0xBF },
{ 0x2D, 0x16, 0x03, 0xBF },
{ 0x22, 0x1E, 0x01, 0xB7 },
{ 0x0E, 0x24, 0x01, 0xBF },
{ 0x05, 0x26, 0x06, 0xB7 },
{ 0x02, 0x26, 0x16, 0xBF },
{ 0x02, 0x22, 0x2A, 0xBF },
{ 0x0B, 0x0B, 0x0B, 0x00 },
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0xB7 },
{ 0x3D, 0x3D, 0x3E, 0xBF },
{ 0x12, 0x2C, 0x3E, 0x53 },
{ 0x22, 0x25, 0x3F, 0x54 },
{ 0x30, 0x1E, 0x3E, 0x46 },
{ 0x3A, 0x1B, 0x3B, 0x31 },
{ 0x3D, 0x1D, 0x2E, 0x3A },
{ 0x3D, 0x20, 0x1B, 0x32 },
{ 0x3B, 0x28, 0x11, 0x54 },
{ 0x35, 0x30, 0x08, 0x30 },
{ 0x26, 0x35, 0x08, 0x00 },
{ 0x14, 0x37, 0x11, 0x00 },
{ 0x0F, 0x37, 0x25, 0x00 },
{ 0x0A, 0x36, 0x37, 0x00 },
{ 0x18, 0x19, 0x19, 0x00 },
{ 0x01, 0x01, 0x01, 0x00 },
{ 0x01, 0x01,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x11, 0xB7 },
{ 0x35, 0x30, 0x08, 0x00 },
{ 0x26, 0x35, 0x08, 0x00 },
{ 0x14, 0x37, 0x11, 0x00 },
{ 0x0F, 0x37, 0x25, 0xB7 },
{ 0x0A, 0x36, 0x37, 0xB7 },
{ 0x18, 0x19, 0x19, 0x00 },
{ 0x01, 0x01, 0x01, 0x00 },
{ 0x01, 0x01, 0x01, 0x00 },
{ 0x3E, 0x3E, 0x3E, 0x00 },
{ 0x2D, 0x37, 0x3E, 0xB7 },
{ 0x33, 0x34, 0x3F, 0x00 },
{ 0x37, 0x31, 0x3E, 0xB7 },
{ 0x3C, 0x30, 0x3D, 0xBF },
{ 0x3D, 0x30, 0x38, 0xB7 },
{ 0x3D, 0x33, 0x30, 0x08 },
{ 0x3D, 0x36, 0x2B, 0x01 },
{ 0x3B, 0x39, 0x26, 0x01 },
{ 0x34, 0x3B, 0x27, 0x00 },
{ 0x2E, 0x3C, 0x2D, 0xB7 },
{ 0x2C, 0x3C, 0x36, 0xB7 },
{ 0x29, 0x3C, 0x3C, 0x08 },
{ 0x32, 0x31, 0x32, 0xB7 },
{ 0x01, 0x01, 0x01, 0x08 },
{ 0x01, 0x01, 0x01, 0xBF }
};

View File

@@ -0,0 +1,46 @@
/*
* Plugins manager - The TI-NESulator Project
* plugins.h
*
* Created by Manoel TRAPIER on 02/04/07.
* Copyright (c) 2003-2007 986Corp. All rights reserved.
*
* $LastChangedDate$
* $Author$
* $HeadURL$
* $Revision$
*
*/
#ifndef PLUGINS_H
#define PLUGINS_H
#include <types.h>
/* Function pointer for prototyping function that plugins may export */
typedef int (*PluginInit) (void);
typedef int (*PluginDeinit) (void);
typedef void (*PluginKeypress) (void);
#ifdef __TINES_PLUGINS__
/* Available functions for plugins */
int plugin_install_keypressHandler(byte key, PluginKeypress);
int plugin_remove_keypressHandler(byte key, PluginKeypress);
#else /* __TINES_PLUGINS__ */
/* Available functions outside of plugins */
int plugin_keypress(byte key);
/* Real Prototype: TBD */
void plugin_list();
int plugin_load(int id);
int plugin_unload(int id);
#endif /* __TINES_PLUGINS__ */
#endif /* PLUGINS_H */

View File

@@ -0,0 +1,24 @@
/*
* PPU debug utilities - The TI-NESulator Project
* ppu.debug.h
*
* Created by Manoël Trapier on 12/04/07.
* Copyright 2003-2007 986 Corp. All rights reserved.
*
* $LastChangedDate: 2007-05-24 15:11:55 +0200 (jeu, 24 mai 2007) $
* $Author: mtrapier $
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/ppu/ppu.debug.h $
* $Revision: 53 $
*
*/
#ifdef __TINES_PPU_INTERNAL__
void ppu_dumpPalette(int x, int y);
void ppu_dumpPattern(int xd, int yd);
void ppu_dumpNameTable(int xd, int yd);
void ppu_dumpAttributeTable(int xd, int yd);
#else
#error Must only be included inside the PPU code
#endif

68
src/include/ppu/ppu.h Executable file
View File

@@ -0,0 +1,68 @@
/*
* PPU emulation - The TI-NESulator Project
* ppu.h
*
* Define and emulate the PPU (Picture Processing Unit) of the real NES
*
* Created by Manoel TRAPIER.
* Copyright (c) 2003-2007 986Corp. All rights reserved.
*
* $LastChangedDate: 2007-04-26 18:47:34 +0200 (jeu, 26 avr 2007) $
* $Author: mtrapier $
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/ppu.h $
* $Revision: 46 $
*
*/
#ifndef PPU_H
#define PPU_H
#include <types.h>
typedef struct PPU_Sprite_
{
byte y;
byte tileid;
byte flags;
byte x;
} PPU_Sprite;
/*
PPU must be initialized after memory initialisation..
*/
int ppu_init();
int ppu_hblank(int scanline);
byte ppu_readReg(byte id);
void ppu_writeReg(byte id, byte val);
void ppu_fillSprRamDMA(byte value);
#define PPU_MIRROR_HORIZTAL 0
#define PPU_MIRROR_VERTICAL 1
#define PPU_SCREEN_000 0
#define PPU_SCREEN_400 1
#define PPU_SCREEN_800 2
#define PPU_SCREEN_C00 3
#define PPU_SCMODE_SINGLE 0
#define PPU_SCMODE_NORMAL 1
#define PPU_SCMODE_FOURSC 2
void ppu_setMirroring(byte direction);
void ppu_setSingleScreen(byte screen);
void ppu_setScreenMode(byte mode);
PPU_Sprite ppu_getSprite(unsigned short i);
unsigned char ppu_memoryRead(byte page, byte addr);
void ppu_memoryWrite(byte page, byte addr, byte value);
void ppu_debugSprites();
void ppu_debugColor();
#endif

View File

@@ -0,0 +1,32 @@
/*
* PPU Memory manager - The TI-NESulator Project
* ppu.memory.h - Inspired from the memory manager of the Quick6502 Project.
*
* Created by Manoël Trapier on 12/04/07.
* Copyright 2003-2007 986 Corp. All rights reserved.
*
* $LastChangedDate: 2007-05-24 15:11:55 +0200 (jeu, 24 mai 2007) $
* $Author: mtrapier $
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/ppu/ppu.memory.h $
* $Revision: 53 $
*
*/
#ifdef __TINES_PPU_INTERNAL__
int ppu_initMemory();
void ppu_setPagePtr (byte page, byte *ptr);
void ppu_setPagePtr1k(byte page, byte *ptr);
void ppu_setPagePtr2k(byte page, byte *ptr);
void ppu_setPagePtr4k(byte page, byte *ptr);
void ppu_setPagePtr8k(byte page, byte *ptr);
void ppu_memoryDumpState(FILE *fp);
byte ppu_readMemory(byte page, byte addr);
void ppu_writeMemory(byte page, byte addr, byte value);
#else
#error Must only be included inside the PPU code
#endif

28
src/include/types.h Executable file
View File

@@ -0,0 +1,28 @@
/*
* Base type definitions - The TI-NESulator Project
* types.h - Taken from the Quick6502 project
*
* Created by Manoël Trapier on 18/09/06.
* Copyright 2003-2007 986 Corp. All rights reserved.
*
* $LastChangedDate: 2007-03-28 15:50:50 +0200 (mer, 28 mar 2007) $
* $Author: mtrapier $
* $HeadURL: file:///media/HD6G/SVNROOT/trunk/TI-NESulator/src/types.h $
* $Revision: 25 $
*
*/
#ifndef TYPES_H
#define TYPES_H
#ifndef BYTE_TYPE_DEFINED
#define BYTE_TYPE_DEFINED
typedef unsigned char byte;
#endif
typedef unsigned char bool;
#define true (0)
#define false (!true)
#endif