NES.hpp
#ifndef _WXWIDGETS_NES_
#define _WXWIDGETS_NES_
#include <wx\file.h>
#include "MyMarco.h"
#include "mapper.hpp"
#define PRG_BLOCK_SIZE 0x4000
#define PAT_BLOCK_SIZE 0x2000
#define FETCH_CYCLES 0x8
typedef struct tagNESCONFIG
{
float BaseClock; // NTSC:21477270.0 PAL:21281364.0
float CpuClock; // NTSC: 1789772.5 PAL: 1773447.0
int TotalScanlines; // NTSC: 262 PAL: 312
int ScanlineCycles; // NTSC:1364 PAL:1362
int HDrawCycles; // NTSC:1024 PAL:1024
int HBlankCycles; // NTSC: 340 PAL: 338
int ScanlineEndCycles; // NTSC: 4 PAL: 2
int FrameCycles; // NTSC:29829.52 PAL:35468.94
int FrameIrqCycles; // NTSC:29829.52 PAL:35468.94
int FrameRate; // NTSC:60(59.94) PAL:50
float FramePeriod; // NTSC:16.683 PAL:20.0
} NESCONFIG,*LPNESCONFIG;
NESCONFIG NESCONFIG_NTSC =
{
21477270.0f, // Base clock
1789772.5f, // Cpu clock
262, // Total scanlines
1364, // Scanline total cycles(15.75KHz)
1024, // H-Draw cycles
340, // H-Blank cycles
4, // End cycles
1364 * 262, // Frame cycles
29830, // FrameIRQ cycles
60, // Frame rate(Be originally 59.94Hz)
1000.0f / 60.0f // Frame period(ms)
};
NESCONFIG NESCONFIG_PAL =
{
21281364.0f, // Base clock
1773447.0f, // Cpu clock
312, // Total scanlines
1362, // Scanline total cycles(15.625KHz)
1024, // H-Draw cycles
338, // H-Blank cycles
2, // End cycles
1362 * 312, // Frame cycles
35469, // FrameIRQ cycles
50, // Frame rate(Hz)
1000.0f / 50.0f // Frame period(ms)
};
RGBQUAD rgbQuard[64] =
{
{0x7F, 0x7F, 0x7F, 0}, {0xB0, 0x00, 0x20, 0}, {0xB8, 0x00, 0x28, 0}, {0xA0, 0x10, 0x60, 0},
{0x78, 0x20, 0x98, 0}, {0x30, 0x10, 0xB0, 0}, {0x00, 0x30, 0xA0, 0}, {0x00, 0x40, 0x78, 0},
{0x00, 0x58, 0x48, 0}, {0x00, 0x68, 0x38, 0}, {0x00, 0x6C, 0x38, 0}, {0x40, 0x60, 0x30, 0},
{0x80, 0x50, 0x30, 0}, {0x00, 0x00, 0x00, 0}, {0x00, 0x00, 0x00, 0}, {0x00, 0x00, 0x00, 0},
{0xBC, 0xBC, 0xBC, 0}, {0xF8, 0x60, 0x40, 0}, {0xFF, 0x40, 0x40, 0}, {0xF0, 0x40, 0x90, 0},
{0xC0, 0x40, 0xD8, 0}, {0x60, 0x40, 0xD8, 0}, {0x00, 0x50, 0xE0, 0}, {0x00, 0x70, 0xC0, 0},
{0x00, 0x88, 0x88, 0}, {0x00, 0xA0, 0x50, 0}, {0x10, 0xA8, 0x48, 0}, {0x68, 0xA0, 0x48, 0},
{0xC0, 0x90, 0x40, 0}, {0x00, 0x00, 0x00, 0}, {0x00, 0x00, 0x00, 0}, {0x00, 0x00, 0x00, 0},
{0xFF, 0xFF, 0xFF, 0}, {0xFF, 0xA0, 0x60, 0}, {0xFF, 0x80, 0x50, 0}, {0xFF, 0x70, 0xA0, 0},
{0xFF, 0x60, 0xF0, 0}, {0xB0, 0x60, 0xFF, 0}, {0x30, 0x78, 0xFF, 0}, {0x00, 0xA0, 0xFF, 0},
{0x20, 0