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

/media/uploads/beaglescout007/nucleo_ex06_emu.png

TFT J2Nucleo
VCC3V3
GNDGND
CSPB_5(D4)
ResetPA_10(D2) Pull Up(100k)
D/CPA_8(D7)
MOSIPA_7(D11)
SCKPA_5(D13)
LEDLED-100ohm-3V3
MISOPA_6(D12)
TFT J4Nucleo
SD_CSPA_9
SD_MOSIPB_15
SD_MISOPB_14
SD_SCKPB_13
AudioNucleo
TIPPA_4(A2)
USB con.Nucleo
GNDGND
+PA_12
-PA_11
5V5V

https://youtu.be/jL24IjT6LnI

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

Committer:
beaglescout007
Date:
Sun Apr 03 07:45:29 2016 +0000
Revision:
0:3dac1f1bc9e0
Release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beaglescout007 0:3dac1f1bc9e0 1 /*===================================================================*/
beaglescout007 0:3dac1f1bc9e0 2 /* */
beaglescout007 0:3dac1f1bc9e0 3 /* K6502.h : Header file for K6502 */
beaglescout007 0:3dac1f1bc9e0 4 /* */
beaglescout007 0:3dac1f1bc9e0 5 /* 1999/10/19 Racoon New preparation */
beaglescout007 0:3dac1f1bc9e0 6 /* */
beaglescout007 0:3dac1f1bc9e0 7 /*===================================================================*/
beaglescout007 0:3dac1f1bc9e0 8
beaglescout007 0:3dac1f1bc9e0 9 #ifndef K6502_H_INCLUDED
beaglescout007 0:3dac1f1bc9e0 10 #define K6502_H_INCLUDED
beaglescout007 0:3dac1f1bc9e0 11
beaglescout007 0:3dac1f1bc9e0 12 // Type definition
beaglescout007 0:3dac1f1bc9e0 13 #ifndef DWORD
beaglescout007 0:3dac1f1bc9e0 14 typedef unsigned long DWORD;
beaglescout007 0:3dac1f1bc9e0 15 //typedef unsigned int DWORD;
beaglescout007 0:3dac1f1bc9e0 16 #endif
beaglescout007 0:3dac1f1bc9e0 17
beaglescout007 0:3dac1f1bc9e0 18 #ifndef WORD
beaglescout007 0:3dac1f1bc9e0 19 typedef unsigned short WORD;
beaglescout007 0:3dac1f1bc9e0 20 //typedef unsigned short WORD;
beaglescout007 0:3dac1f1bc9e0 21 #endif
beaglescout007 0:3dac1f1bc9e0 22
beaglescout007 0:3dac1f1bc9e0 23 #ifndef BYTE
beaglescout007 0:3dac1f1bc9e0 24 typedef unsigned char BYTE;
beaglescout007 0:3dac1f1bc9e0 25 //typedef char BYTE;
beaglescout007 0:3dac1f1bc9e0 26 #endif
beaglescout007 0:3dac1f1bc9e0 27
beaglescout007 0:3dac1f1bc9e0 28 #ifndef NULL
beaglescout007 0:3dac1f1bc9e0 29 #define NULL 0
beaglescout007 0:3dac1f1bc9e0 30 #endif
beaglescout007 0:3dac1f1bc9e0 31
beaglescout007 0:3dac1f1bc9e0 32 /* 6502 Flags */
beaglescout007 0:3dac1f1bc9e0 33 #define FLAG_C 0x01
beaglescout007 0:3dac1f1bc9e0 34 #define FLAG_Z 0x02
beaglescout007 0:3dac1f1bc9e0 35 #define FLAG_I 0x04
beaglescout007 0:3dac1f1bc9e0 36 #define FLAG_D 0x08
beaglescout007 0:3dac1f1bc9e0 37 #define FLAG_B 0x10
beaglescout007 0:3dac1f1bc9e0 38 #define FLAG_R 0x20
beaglescout007 0:3dac1f1bc9e0 39 #define FLAG_V 0x40
beaglescout007 0:3dac1f1bc9e0 40 #define FLAG_N 0x80
beaglescout007 0:3dac1f1bc9e0 41
beaglescout007 0:3dac1f1bc9e0 42 /* Stack Address */
beaglescout007 0:3dac1f1bc9e0 43 #define BASE_STACK 0x100
beaglescout007 0:3dac1f1bc9e0 44
beaglescout007 0:3dac1f1bc9e0 45 /* Interrupt Vectors */
beaglescout007 0:3dac1f1bc9e0 46 #define VECTOR_NMI 0xfffa
beaglescout007 0:3dac1f1bc9e0 47 #define VECTOR_RESET 0xfffc
beaglescout007 0:3dac1f1bc9e0 48 #define VECTOR_IRQ 0xfffe
beaglescout007 0:3dac1f1bc9e0 49
beaglescout007 0:3dac1f1bc9e0 50 // NMI Request
beaglescout007 0:3dac1f1bc9e0 51 #define NMI_REQ NMI_State = 0;
beaglescout007 0:3dac1f1bc9e0 52
beaglescout007 0:3dac1f1bc9e0 53 // IRQ Request
beaglescout007 0:3dac1f1bc9e0 54 #define IRQ_REQ IRQ_State = 0;
beaglescout007 0:3dac1f1bc9e0 55
beaglescout007 0:3dac1f1bc9e0 56 // Emulator Operation
beaglescout007 0:3dac1f1bc9e0 57 void K6502_Init();
beaglescout007 0:3dac1f1bc9e0 58 void K6502_Reset();
beaglescout007 0:3dac1f1bc9e0 59 void K6502_Set_Int_Wiring( BYTE byNMI_Wiring, BYTE byIRQ_Wiring );
beaglescout007 0:3dac1f1bc9e0 60 void K6502_Step( register WORD wClocks );
beaglescout007 0:3dac1f1bc9e0 61
beaglescout007 0:3dac1f1bc9e0 62 // I/O Operation (User definition)
beaglescout007 0:3dac1f1bc9e0 63 static inline BYTE K6502_Read( WORD wAddr);
beaglescout007 0:3dac1f1bc9e0 64 static inline WORD K6502_ReadW( WORD wAddr );
beaglescout007 0:3dac1f1bc9e0 65 static inline BYTE K6502_ReadZp( BYTE byAddr );
beaglescout007 0:3dac1f1bc9e0 66 static inline WORD K6502_ReadZpW( BYTE byAddr );
beaglescout007 0:3dac1f1bc9e0 67 static inline BYTE K6502_ReadAbsX();
beaglescout007 0:3dac1f1bc9e0 68 static inline BYTE K6502_ReadAbsY();
beaglescout007 0:3dac1f1bc9e0 69 static inline BYTE K6502_ReadIY();
beaglescout007 0:3dac1f1bc9e0 70
beaglescout007 0:3dac1f1bc9e0 71 static inline void K6502_Write( WORD wAddr, BYTE byData );
beaglescout007 0:3dac1f1bc9e0 72 static inline void K6502_WriteW( WORD wAddr, WORD wData );
beaglescout007 0:3dac1f1bc9e0 73
beaglescout007 0:3dac1f1bc9e0 74 // The state of the IRQ pin
beaglescout007 0:3dac1f1bc9e0 75 extern BYTE IRQ_State;
beaglescout007 0:3dac1f1bc9e0 76
beaglescout007 0:3dac1f1bc9e0 77 // The state of the NMI pin
beaglescout007 0:3dac1f1bc9e0 78 extern BYTE NMI_State;
beaglescout007 0:3dac1f1bc9e0 79
beaglescout007 0:3dac1f1bc9e0 80 #endif /* !K6502_H_INCLUDED */
beaglescout007 0:3dac1f1bc9e0 81
beaglescout007 0:3dac1f1bc9e0 82