I have ported my old project “pNesX” game console emulator to the nucleo.
Dependencies: SDFileSystem mbed
Intro
I have ported my old project “pNesX” to the STM32 Nucleo. The pNesX is a NES emulator for the PlayStation that I have created 16 years ago!
Emulation part was almost without change, the sound part was newly added.
Parts
STM32 Nucleo F446RE |
QVGA 2.2 TFT SPI (with the SD card slot) |
Audio jack(TS or TRS) |
USB Connector |
Register 100k, 10k, 4.7k, 100 |
Capacitor 0.01uF, 2.2uF |
Breadboard |
Wires |
Computer Speakers |
USB GamePad |
Wiring diagram
TFT J2 | Nucleo |
---|---|
VCC | 3V3 |
GND | GND |
CS | PB_5(D4) |
Reset | PA_10(D2) Pull Up(100k) |
D/C | PA_8(D7) |
MOSI | PA_7(D11) |
SCK | PA_5(D13) |
LED | LED-100ohm-3V3 |
MISO | PA_6(D12) |
TFT J4 | Nucleo |
---|---|
SD_CS | PA_9 |
SD_MOSI | PB_15 |
SD_MISO | PB_14 |
SD_SCK | PB_13 |
Audio | Nucleo |
---|---|
TIP | PA_4(A2) |
USB con. | Nucleo |
---|---|
GND | GND |
+ | PA_12 |
- | PA_11 |
5V | 5V |
Limitations
- Since the rest of the RAM is about 50kbyte, maximum capacity of the game ROM is about 50kbyte.
- The length of the file name up to 32 characters.
- The number of files in the folder is up to 100.
Used Library
- SDFileSystem by Neil Thiessen
- F401RE-USBHost by Norimasa Okamoto
- USBHostGamepad by Yuuichi Akagawa
pNesX.h@0:3dac1f1bc9e0, 2016-04-03 (annotated)
- Committer:
- beaglescout007
- Date:
- Sun Apr 03 07:45:29 2016 +0000
- Revision:
- 0:3dac1f1bc9e0
Release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
beaglescout007 | 0:3dac1f1bc9e0 | 1 | /*===================================================================*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 2 | /* */ |
beaglescout007 | 0:3dac1f1bc9e0 | 3 | /* pNesX.h : NES Emulator for PSX */ |
beaglescout007 | 0:3dac1f1bc9e0 | 4 | /* */ |
beaglescout007 | 0:3dac1f1bc9e0 | 5 | /* 1999/11/03 Racoon New preparation */ |
beaglescout007 | 0:3dac1f1bc9e0 | 6 | /* */ |
beaglescout007 | 0:3dac1f1bc9e0 | 7 | /*===================================================================*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 8 | |
beaglescout007 | 0:3dac1f1bc9e0 | 9 | #ifndef PNESX_H_INCLUDED |
beaglescout007 | 0:3dac1f1bc9e0 | 10 | #define PNESX_H_INCLUDED |
beaglescout007 | 0:3dac1f1bc9e0 | 11 | |
beaglescout007 | 0:3dac1f1bc9e0 | 12 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 13 | /* Include files */ |
beaglescout007 | 0:3dac1f1bc9e0 | 14 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 15 | |
beaglescout007 | 0:3dac1f1bc9e0 | 16 | #include "pNesX_Types.h" |
beaglescout007 | 0:3dac1f1bc9e0 | 17 | |
beaglescout007 | 0:3dac1f1bc9e0 | 18 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 19 | /* NES resources */ |
beaglescout007 | 0:3dac1f1bc9e0 | 20 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 21 | |
beaglescout007 | 0:3dac1f1bc9e0 | 22 | #define RAM_SIZE 0x2000 |
beaglescout007 | 0:3dac1f1bc9e0 | 23 | #define SRAM_SIZE 0x2000 |
beaglescout007 | 0:3dac1f1bc9e0 | 24 | #define PPURAM_SIZE 0x4000 |
beaglescout007 | 0:3dac1f1bc9e0 | 25 | #define SPRRAM_SIZE 256 |
beaglescout007 | 0:3dac1f1bc9e0 | 26 | |
beaglescout007 | 0:3dac1f1bc9e0 | 27 | /* RAM */ |
beaglescout007 | 0:3dac1f1bc9e0 | 28 | extern BYTE RAM[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 29 | |
beaglescout007 | 0:3dac1f1bc9e0 | 30 | /* SRAM */ |
beaglescout007 | 0:3dac1f1bc9e0 | 31 | extern BYTE SRAM[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 32 | |
beaglescout007 | 0:3dac1f1bc9e0 | 33 | /* ROM */ |
beaglescout007 | 0:3dac1f1bc9e0 | 34 | extern BYTE *ROM; |
beaglescout007 | 0:3dac1f1bc9e0 | 35 | |
beaglescout007 | 0:3dac1f1bc9e0 | 36 | /* ROM BANK ( 8Kb * 4 ) */ |
beaglescout007 | 0:3dac1f1bc9e0 | 37 | extern BYTE *ROMBANK0; |
beaglescout007 | 0:3dac1f1bc9e0 | 38 | extern BYTE *ROMBANK1; |
beaglescout007 | 0:3dac1f1bc9e0 | 39 | extern BYTE *ROMBANK2; |
beaglescout007 | 0:3dac1f1bc9e0 | 40 | extern BYTE *ROMBANK3; |
beaglescout007 | 0:3dac1f1bc9e0 | 41 | |
beaglescout007 | 0:3dac1f1bc9e0 | 42 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 43 | /* PPU resources */ |
beaglescout007 | 0:3dac1f1bc9e0 | 44 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 45 | |
beaglescout007 | 0:3dac1f1bc9e0 | 46 | /* PPU RAM */ |
beaglescout007 | 0:3dac1f1bc9e0 | 47 | extern BYTE PPURAM[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 48 | |
beaglescout007 | 0:3dac1f1bc9e0 | 49 | /* VROM */ |
beaglescout007 | 0:3dac1f1bc9e0 | 50 | extern BYTE *VROM; |
beaglescout007 | 0:3dac1f1bc9e0 | 51 | |
beaglescout007 | 0:3dac1f1bc9e0 | 52 | /* PPU BANK ( 1Kb * 16 ) */ |
beaglescout007 | 0:3dac1f1bc9e0 | 53 | extern BYTE *PPUBANK[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 54 | |
beaglescout007 | 0:3dac1f1bc9e0 | 55 | #define NAME_TABLE0 8 |
beaglescout007 | 0:3dac1f1bc9e0 | 56 | #define NAME_TABLE1 9 |
beaglescout007 | 0:3dac1f1bc9e0 | 57 | #define NAME_TABLE2 10 |
beaglescout007 | 0:3dac1f1bc9e0 | 58 | #define NAME_TABLE3 11 |
beaglescout007 | 0:3dac1f1bc9e0 | 59 | |
beaglescout007 | 0:3dac1f1bc9e0 | 60 | #define NAME_TABLE_V_MASK 2 |
beaglescout007 | 0:3dac1f1bc9e0 | 61 | #define NAME_TABLE_H_MASK 1 |
beaglescout007 | 0:3dac1f1bc9e0 | 62 | |
beaglescout007 | 0:3dac1f1bc9e0 | 63 | /* Sprite RAM */ |
beaglescout007 | 0:3dac1f1bc9e0 | 64 | extern BYTE SPRRAM[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 65 | |
beaglescout007 | 0:3dac1f1bc9e0 | 66 | #define SPR_Y 0 |
beaglescout007 | 0:3dac1f1bc9e0 | 67 | #define SPR_CHR 1 |
beaglescout007 | 0:3dac1f1bc9e0 | 68 | #define SPR_ATTR 2 |
beaglescout007 | 0:3dac1f1bc9e0 | 69 | #define SPR_X 3 |
beaglescout007 | 0:3dac1f1bc9e0 | 70 | #define SPR_ATTR_COLOR 0x3 |
beaglescout007 | 0:3dac1f1bc9e0 | 71 | #define SPR_ATTR_V_FLIP 0x80 |
beaglescout007 | 0:3dac1f1bc9e0 | 72 | #define SPR_ATTR_H_FLIP 0x40 |
beaglescout007 | 0:3dac1f1bc9e0 | 73 | #define SPR_ATTR_PRI 0x20 |
beaglescout007 | 0:3dac1f1bc9e0 | 74 | |
beaglescout007 | 0:3dac1f1bc9e0 | 75 | /* PPU Register */ |
beaglescout007 | 0:3dac1f1bc9e0 | 76 | extern BYTE PPU_R0; |
beaglescout007 | 0:3dac1f1bc9e0 | 77 | extern BYTE PPU_R1; |
beaglescout007 | 0:3dac1f1bc9e0 | 78 | extern BYTE PPU_R2; |
beaglescout007 | 0:3dac1f1bc9e0 | 79 | extern BYTE PPU_R3; |
beaglescout007 | 0:3dac1f1bc9e0 | 80 | extern BYTE PPU_R7; |
beaglescout007 | 0:3dac1f1bc9e0 | 81 | |
beaglescout007 | 0:3dac1f1bc9e0 | 82 | extern BYTE PPU_Scr_V; |
beaglescout007 | 0:3dac1f1bc9e0 | 83 | extern BYTE PPU_Scr_V_Next; |
beaglescout007 | 0:3dac1f1bc9e0 | 84 | extern BYTE PPU_Scr_V_Byte; |
beaglescout007 | 0:3dac1f1bc9e0 | 85 | extern BYTE PPU_Scr_V_Byte_Next; |
beaglescout007 | 0:3dac1f1bc9e0 | 86 | extern BYTE PPU_Scr_V_Bit; |
beaglescout007 | 0:3dac1f1bc9e0 | 87 | extern BYTE PPU_Scr_V_Bit_Next; |
beaglescout007 | 0:3dac1f1bc9e0 | 88 | |
beaglescout007 | 0:3dac1f1bc9e0 | 89 | extern BYTE PPU_Scr_H; |
beaglescout007 | 0:3dac1f1bc9e0 | 90 | extern BYTE PPU_Scr_H_Next; |
beaglescout007 | 0:3dac1f1bc9e0 | 91 | extern BYTE PPU_Scr_H_Byte; |
beaglescout007 | 0:3dac1f1bc9e0 | 92 | extern BYTE PPU_Scr_H_Byte_Next; |
beaglescout007 | 0:3dac1f1bc9e0 | 93 | extern BYTE PPU_Scr_H_Bit; |
beaglescout007 | 0:3dac1f1bc9e0 | 94 | extern BYTE PPU_Scr_H_Bit_Next; |
beaglescout007 | 0:3dac1f1bc9e0 | 95 | |
beaglescout007 | 0:3dac1f1bc9e0 | 96 | extern BYTE PPU_Latch_Flag; |
beaglescout007 | 0:3dac1f1bc9e0 | 97 | extern WORD PPU_Addr; |
beaglescout007 | 0:3dac1f1bc9e0 | 98 | extern WORD PPU_Increment; |
beaglescout007 | 0:3dac1f1bc9e0 | 99 | |
beaglescout007 | 0:3dac1f1bc9e0 | 100 | #define R0_NMI_VB 0x80 |
beaglescout007 | 0:3dac1f1bc9e0 | 101 | #define R0_NMI_SP 0x40 |
beaglescout007 | 0:3dac1f1bc9e0 | 102 | #define R0_SP_SIZE 0x20 |
beaglescout007 | 0:3dac1f1bc9e0 | 103 | #define R0_BG_ADDR 0x10 |
beaglescout007 | 0:3dac1f1bc9e0 | 104 | #define R0_SP_ADDR 0x08 |
beaglescout007 | 0:3dac1f1bc9e0 | 105 | #define R0_INC_ADDR 0x04 |
beaglescout007 | 0:3dac1f1bc9e0 | 106 | #define R0_NAME_ADDR 0x03 |
beaglescout007 | 0:3dac1f1bc9e0 | 107 | |
beaglescout007 | 0:3dac1f1bc9e0 | 108 | #define R1_BACKCOLOR 0xe0 |
beaglescout007 | 0:3dac1f1bc9e0 | 109 | #define R1_SHOW_SP 0x10 |
beaglescout007 | 0:3dac1f1bc9e0 | 110 | #define R1_SHOW_SCR 0x08 |
beaglescout007 | 0:3dac1f1bc9e0 | 111 | #define R1_CLIP_SP 0x04 |
beaglescout007 | 0:3dac1f1bc9e0 | 112 | #define R1_CLIP_BG 0x02 |
beaglescout007 | 0:3dac1f1bc9e0 | 113 | #define R1_MONOCHROME 0x01 |
beaglescout007 | 0:3dac1f1bc9e0 | 114 | |
beaglescout007 | 0:3dac1f1bc9e0 | 115 | #define R2_IN_VBLANK 0x80 |
beaglescout007 | 0:3dac1f1bc9e0 | 116 | #define R2_HIT_SP 0x40 |
beaglescout007 | 0:3dac1f1bc9e0 | 117 | #define R2_MAX_SP 0x20 |
beaglescout007 | 0:3dac1f1bc9e0 | 118 | #define R2_WRITE_FLAG 0x10 |
beaglescout007 | 0:3dac1f1bc9e0 | 119 | |
beaglescout007 | 0:3dac1f1bc9e0 | 120 | #define SCAN_TOP_OFF_SCREEN_START 0 |
beaglescout007 | 0:3dac1f1bc9e0 | 121 | #define SCAN_ON_SCREEN_START 8 |
beaglescout007 | 0:3dac1f1bc9e0 | 122 | #define SCAN_BOTTOM_OFF_SCREEN_START 232 |
beaglescout007 | 0:3dac1f1bc9e0 | 123 | #define SCAN_POSTRENDER_START 240 |
beaglescout007 | 0:3dac1f1bc9e0 | 124 | #define SCAN_VBLANK_START 245 |
beaglescout007 | 0:3dac1f1bc9e0 | 125 | #define SCAN_VBLANK_END 261 |
beaglescout007 | 0:3dac1f1bc9e0 | 126 | |
beaglescout007 | 0:3dac1f1bc9e0 | 127 | #define SCAN_APU_CLK1 45 // 240Hz |
beaglescout007 | 0:3dac1f1bc9e0 | 128 | #define SCAN_APU_CLK2 110 // 240Hz 120Hz |
beaglescout007 | 0:3dac1f1bc9e0 | 129 | #define SCAN_APU_CLK3 176 // 240Hz |
beaglescout007 | 0:3dac1f1bc9e0 | 130 | #define SCAN_APU_CLK4 241 // 240Hz 120Hz 60Hz |
beaglescout007 | 0:3dac1f1bc9e0 | 131 | |
beaglescout007 | 0:3dac1f1bc9e0 | 132 | /* Current Scanline */ |
beaglescout007 | 0:3dac1f1bc9e0 | 133 | extern WORD PPU_Scanline; |
beaglescout007 | 0:3dac1f1bc9e0 | 134 | |
beaglescout007 | 0:3dac1f1bc9e0 | 135 | /* Scanline Table */ |
beaglescout007 | 0:3dac1f1bc9e0 | 136 | extern BYTE PPU_ScanTable[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 137 | |
beaglescout007 | 0:3dac1f1bc9e0 | 138 | /* Name Table Bank */ |
beaglescout007 | 0:3dac1f1bc9e0 | 139 | extern BYTE PPU_NameTableBank; |
beaglescout007 | 0:3dac1f1bc9e0 | 140 | |
beaglescout007 | 0:3dac1f1bc9e0 | 141 | /* BG Base Address */ |
beaglescout007 | 0:3dac1f1bc9e0 | 142 | extern BYTE *PPU_BG_Base; |
beaglescout007 | 0:3dac1f1bc9e0 | 143 | |
beaglescout007 | 0:3dac1f1bc9e0 | 144 | /* Sprite Base Address */ |
beaglescout007 | 0:3dac1f1bc9e0 | 145 | extern BYTE *PPU_SP_Base; |
beaglescout007 | 0:3dac1f1bc9e0 | 146 | |
beaglescout007 | 0:3dac1f1bc9e0 | 147 | /* Sprite Height */ |
beaglescout007 | 0:3dac1f1bc9e0 | 148 | extern WORD PPU_SP_Height; |
beaglescout007 | 0:3dac1f1bc9e0 | 149 | |
beaglescout007 | 0:3dac1f1bc9e0 | 150 | /* NES display size */ |
beaglescout007 | 0:3dac1f1bc9e0 | 151 | #define NES_DISP_WIDTH 256 |
beaglescout007 | 0:3dac1f1bc9e0 | 152 | #define NES_DISP_HEIGHT 224 |
beaglescout007 | 0:3dac1f1bc9e0 | 153 | |
beaglescout007 | 0:3dac1f1bc9e0 | 154 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 155 | /* Display and Others resouces */ |
beaglescout007 | 0:3dac1f1bc9e0 | 156 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 157 | |
beaglescout007 | 0:3dac1f1bc9e0 | 158 | /* Frame Skip */ |
beaglescout007 | 0:3dac1f1bc9e0 | 159 | extern WORD FrameSkip; |
beaglescout007 | 0:3dac1f1bc9e0 | 160 | extern WORD FrameCnt; |
beaglescout007 | 0:3dac1f1bc9e0 | 161 | |
beaglescout007 | 0:3dac1f1bc9e0 | 162 | //extern WORD DoubleFrame[ 2 ][ NES_DISP_WIDTH * NES_DISP_HEIGHT ]; |
beaglescout007 | 0:3dac1f1bc9e0 | 163 | //extern WORD DoubleFrame[ 2 ][ NES_DISP_WIDTH ]; |
beaglescout007 | 0:3dac1f1bc9e0 | 164 | extern WORD *WorkFrame; |
beaglescout007 | 0:3dac1f1bc9e0 | 165 | extern WORD WorkFrameIdx; |
beaglescout007 | 0:3dac1f1bc9e0 | 166 | |
beaglescout007 | 0:3dac1f1bc9e0 | 167 | extern BYTE ChrBuf[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 168 | |
beaglescout007 | 0:3dac1f1bc9e0 | 169 | extern BYTE ChrBufUpdate; |
beaglescout007 | 0:3dac1f1bc9e0 | 170 | |
beaglescout007 | 0:3dac1f1bc9e0 | 171 | extern WORD PalTable[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 172 | |
beaglescout007 | 0:3dac1f1bc9e0 | 173 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 174 | /* APU and Pad resources */ |
beaglescout007 | 0:3dac1f1bc9e0 | 175 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 176 | |
beaglescout007 | 0:3dac1f1bc9e0 | 177 | extern BYTE APU_Reg[]; |
beaglescout007 | 0:3dac1f1bc9e0 | 178 | |
beaglescout007 | 0:3dac1f1bc9e0 | 179 | extern DWORD PAD1_Latch; |
beaglescout007 | 0:3dac1f1bc9e0 | 180 | extern DWORD PAD2_Latch; |
beaglescout007 | 0:3dac1f1bc9e0 | 181 | extern DWORD PAD_System; |
beaglescout007 | 0:3dac1f1bc9e0 | 182 | extern DWORD PAD1_Bit; |
beaglescout007 | 0:3dac1f1bc9e0 | 183 | extern DWORD PAD2_Bit; |
beaglescout007 | 0:3dac1f1bc9e0 | 184 | |
beaglescout007 | 0:3dac1f1bc9e0 | 185 | #define PAD_SYS_QUIT 1 |
beaglescout007 | 0:3dac1f1bc9e0 | 186 | #define PAD_SYS_OK 2 |
beaglescout007 | 0:3dac1f1bc9e0 | 187 | #define PAD_SYS_CANCEL 4 |
beaglescout007 | 0:3dac1f1bc9e0 | 188 | #define PAD_SYS_UP 8 |
beaglescout007 | 0:3dac1f1bc9e0 | 189 | #define PAD_SYS_DOWN 0x10 |
beaglescout007 | 0:3dac1f1bc9e0 | 190 | #define PAD_SYS_LEFT 0x20 |
beaglescout007 | 0:3dac1f1bc9e0 | 191 | #define PAD_SYS_RIGHT 0x40 |
beaglescout007 | 0:3dac1f1bc9e0 | 192 | |
beaglescout007 | 0:3dac1f1bc9e0 | 193 | #define PAD_PUSH(a,b) ( ( (a) & (b) ) != 0 ) |
beaglescout007 | 0:3dac1f1bc9e0 | 194 | |
beaglescout007 | 0:3dac1f1bc9e0 | 195 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 196 | /* Mapper Function */ |
beaglescout007 | 0:3dac1f1bc9e0 | 197 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 198 | |
beaglescout007 | 0:3dac1f1bc9e0 | 199 | /* Initialize Mapper */ |
beaglescout007 | 0:3dac1f1bc9e0 | 200 | extern void (*MapperInit)(); |
beaglescout007 | 0:3dac1f1bc9e0 | 201 | /* Write to Mapper */ |
beaglescout007 | 0:3dac1f1bc9e0 | 202 | extern void (*MapperWrite)( WORD wAddr, BYTE byData ); |
beaglescout007 | 0:3dac1f1bc9e0 | 203 | /* Callback at VSync */ |
beaglescout007 | 0:3dac1f1bc9e0 | 204 | extern void (*MapperVSync)(); |
beaglescout007 | 0:3dac1f1bc9e0 | 205 | /* Callback at HSync */ |
beaglescout007 | 0:3dac1f1bc9e0 | 206 | extern void (*MapperHSync)(); |
beaglescout007 | 0:3dac1f1bc9e0 | 207 | |
beaglescout007 | 0:3dac1f1bc9e0 | 208 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 209 | /* ROM information */ |
beaglescout007 | 0:3dac1f1bc9e0 | 210 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 211 | |
beaglescout007 | 0:3dac1f1bc9e0 | 212 | /* .nes File Header */ |
beaglescout007 | 0:3dac1f1bc9e0 | 213 | struct NesHeader_tag |
beaglescout007 | 0:3dac1f1bc9e0 | 214 | { |
beaglescout007 | 0:3dac1f1bc9e0 | 215 | BYTE byID[ 4 ]; |
beaglescout007 | 0:3dac1f1bc9e0 | 216 | BYTE byRomSize; |
beaglescout007 | 0:3dac1f1bc9e0 | 217 | BYTE byVRomSize; |
beaglescout007 | 0:3dac1f1bc9e0 | 218 | BYTE byInfo1; |
beaglescout007 | 0:3dac1f1bc9e0 | 219 | BYTE byInfo2; |
beaglescout007 | 0:3dac1f1bc9e0 | 220 | BYTE byReserve[ 8 ]; |
beaglescout007 | 0:3dac1f1bc9e0 | 221 | }; |
beaglescout007 | 0:3dac1f1bc9e0 | 222 | |
beaglescout007 | 0:3dac1f1bc9e0 | 223 | /* .nes File Header */ |
beaglescout007 | 0:3dac1f1bc9e0 | 224 | extern struct NesHeader_tag NesHeader; |
beaglescout007 | 0:3dac1f1bc9e0 | 225 | |
beaglescout007 | 0:3dac1f1bc9e0 | 226 | /* Mapper No. */ |
beaglescout007 | 0:3dac1f1bc9e0 | 227 | extern BYTE MapperNo; |
beaglescout007 | 0:3dac1f1bc9e0 | 228 | |
beaglescout007 | 0:3dac1f1bc9e0 | 229 | /* Other */ |
beaglescout007 | 0:3dac1f1bc9e0 | 230 | extern BYTE ROM_Mirroring; |
beaglescout007 | 0:3dac1f1bc9e0 | 231 | extern BYTE ROM_SRAM; |
beaglescout007 | 0:3dac1f1bc9e0 | 232 | extern BYTE ROM_Trainer; |
beaglescout007 | 0:3dac1f1bc9e0 | 233 | extern BYTE ROM_FourScr; |
beaglescout007 | 0:3dac1f1bc9e0 | 234 | |
beaglescout007 | 0:3dac1f1bc9e0 | 235 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 236 | /* Function prototypes */ |
beaglescout007 | 0:3dac1f1bc9e0 | 237 | /*-------------------------------------------------------------------*/ |
beaglescout007 | 0:3dac1f1bc9e0 | 238 | |
beaglescout007 | 0:3dac1f1bc9e0 | 239 | /* Initialize pNesX */ |
beaglescout007 | 0:3dac1f1bc9e0 | 240 | void pNesX_Init(); |
beaglescout007 | 0:3dac1f1bc9e0 | 241 | |
beaglescout007 | 0:3dac1f1bc9e0 | 242 | /* Completion treatment */ |
beaglescout007 | 0:3dac1f1bc9e0 | 243 | void pNesX_Fin(); |
beaglescout007 | 0:3dac1f1bc9e0 | 244 | |
beaglescout007 | 0:3dac1f1bc9e0 | 245 | /* Load a cassette */ |
beaglescout007 | 0:3dac1f1bc9e0 | 246 | int pNesX_Load( const char *pszFileName ); |
beaglescout007 | 0:3dac1f1bc9e0 | 247 | |
beaglescout007 | 0:3dac1f1bc9e0 | 248 | /* Reset pNesX */ |
beaglescout007 | 0:3dac1f1bc9e0 | 249 | int pNesX_Reset(); |
beaglescout007 | 0:3dac1f1bc9e0 | 250 | |
beaglescout007 | 0:3dac1f1bc9e0 | 251 | /* Initialize PPU */ |
beaglescout007 | 0:3dac1f1bc9e0 | 252 | void pNesX_SetupPPU(); |
beaglescout007 | 0:3dac1f1bc9e0 | 253 | |
beaglescout007 | 0:3dac1f1bc9e0 | 254 | /* Set up a Mirroring of Name Table */ |
beaglescout007 | 0:3dac1f1bc9e0 | 255 | void pNesX_Mirroring( int nType ); |
beaglescout007 | 0:3dac1f1bc9e0 | 256 | |
beaglescout007 | 0:3dac1f1bc9e0 | 257 | /* The main loop of pNesX */ |
beaglescout007 | 0:3dac1f1bc9e0 | 258 | void pNesX_Main(); |
beaglescout007 | 0:3dac1f1bc9e0 | 259 | |
beaglescout007 | 0:3dac1f1bc9e0 | 260 | /* The loop of emulation */ |
beaglescout007 | 0:3dac1f1bc9e0 | 261 | void pNesX_Cycle(); |
beaglescout007 | 0:3dac1f1bc9e0 | 262 | |
beaglescout007 | 0:3dac1f1bc9e0 | 263 | /* A function in H-Sync */ |
beaglescout007 | 0:3dac1f1bc9e0 | 264 | int pNesX_HSync(); |
beaglescout007 | 0:3dac1f1bc9e0 | 265 | |
beaglescout007 | 0:3dac1f1bc9e0 | 266 | /* Render a scanline */ |
beaglescout007 | 0:3dac1f1bc9e0 | 267 | void pNesX_DrawLine(); |
beaglescout007 | 0:3dac1f1bc9e0 | 268 | |
beaglescout007 | 0:3dac1f1bc9e0 | 269 | /* Get a position of scanline hits sprite #0 */ |
beaglescout007 | 0:3dac1f1bc9e0 | 270 | void pNesX_GetSprHitY(); |
beaglescout007 | 0:3dac1f1bc9e0 | 271 | |
beaglescout007 | 0:3dac1f1bc9e0 | 272 | /* Develop character data */ |
beaglescout007 | 0:3dac1f1bc9e0 | 273 | void pNesX_SetupChr(); |
beaglescout007 | 0:3dac1f1bc9e0 | 274 | |
beaglescout007 | 0:3dac1f1bc9e0 | 275 | /* Apu */ |
beaglescout007 | 0:3dac1f1bc9e0 | 276 | void ApuInit(); |
beaglescout007 | 0:3dac1f1bc9e0 | 277 | void ApuWrite(WORD wAddr, BYTE byData); |
beaglescout007 | 0:3dac1f1bc9e0 | 278 | BYTE ApuRead(WORD wAddr); |
beaglescout007 | 0:3dac1f1bc9e0 | 279 | void pNesX_ApuClk_240Hz(); |
beaglescout007 | 0:3dac1f1bc9e0 | 280 | void pNesX_ApuClk_120Hz(); |
beaglescout007 | 0:3dac1f1bc9e0 | 281 | void pNesX_ApuClk_60Hz(); |
beaglescout007 | 0:3dac1f1bc9e0 | 282 | |
beaglescout007 | 0:3dac1f1bc9e0 | 283 | #endif /* !PNESX_H_INCLUDED */ |
beaglescout007 | 0:3dac1f1bc9e0 | 284 | |
beaglescout007 | 0:3dac1f1bc9e0 | 285 |