PDA

View Full Version : GB/GBC Emulator on Teensy4.1



Ryzee119
10-17-2020, 08:31 AM
Another Teensy emulator :)

Ported from the highly accurate/compatible emulator SameBoy.

It supports:

USB Host Stack with input from Xbox360 Wired/Wireless Controllers
ILI93412 TFT LCD Library by KurtE (Awesome library!)
Audio ouput via MQS subsystem. GB Stereo audio is mixed into one channel.
SD Card with FATFS
Requires external PSRAM (8MB)

Admittedly, due to the highly accurate emulation, performance is not quite perfect, but pretty good in some less demanding games!

https://github.com/Ryzee119/SameBoyT4

22108

22109

Loving this teensy!

defragster
10-17-2020, 08:48 AM
Nice, Is the PSRAM access speed setup changed from 88 MHz to 132MHz? If that is a bottleneck it might be some easy help to performance.

link here : Teensy-4-1-PSRAM-Random-Access-Latency (https://forum.pjrc.com/threads/62456-Teensy-4-1-PSRAM-Random-Access-Latency?p=249444&viewfull=1#post249444)

Ryzee119
10-17-2020, 08:52 AM
Thanks for the tip. I'll certainly have a look at that!

Ryzee119
10-19-2020, 10:00 AM
Nice, Is the PSRAM access speed setup changed from 88 MHz to 132MHz? If that is a bottleneck it might be some easy help to performance.

link here : Teensy-4-1-PSRAM-Random-Access-Latency (https://forum.pjrc.com/threads/62456-Teensy-4-1-PSRAM-Random-Access-Latency?p=249444&viewfull=1#post249444)

Thanks for that! I didn't notice a huge speed improvement by changing the psram clock.
However it got me thinking about my other memory.
The emulator core malloc'd ram and vram on the heap which I remembered is in the slower RAM region. I replaced these to use DTCM memory and got a small but notible improvement 😊

defragster
10-19-2020, 11:23 AM
Thanks for that! I didn't notice a huge speed improvement by changing the psram clock.
However it got me thinking about my other memory.
The emulator core malloc'd ram and vram on the heap which I remembered is in the slower RAM region. I replaced these to use DTCM memory and got a small but notible improvement ��

Faster QSPI speed can't hurt when used (if chips likes it) ... indeed lower DTCM RAM runs at CPU speed, upper malloc/DMAMEM runs at CPU/4 so that can make a big difference when it doesn't run through the full speed 32KB cache.

How much code is in ITCM? KurtE has a current Win imxrt-size.exe that shows in build - and there is a MEM func in the FrankB powerButton lib on github. Minding that 32KB block usage and moving code to FLASH resident could free up another 32KB of DTCM for use. Also the first 32KB of FLASH code should run from code cache at full speed.

Ryzee119
10-20-2020, 03:11 AM
Faster QSPI speed can't hurt when used (if chips likes it) ... indeed lower DTCM RAM runs at CPU speed, upper malloc/DMAMEM runs at CPU/4 so that can make a big difference when it doesn't run through the full speed 32KB cache.

How much code is in ITCM? KurtE has a current Win imxrt-size.exe that shows in build - and there is a MEM func in the FrankB powerButton lib on github. Minding that 32KB block usage and moving code to FLASH resident could free up another 32KB of DTCM for use. Also the first 32KB of FLASH code should run from code cache at full speed.

This is how it's currently sitting. Wasnt aware of this neat program:

FlexRAM section ITCM+DTCM = 512 KB
Config : aaaaabff (DDDDDDDDDDDIIIII)
ITCM : 143432 B (87.54% of 160 KB)
DTCM : 279232 B (77.47% of 352 KB)
Available for Stack: 81216
OCRAM: 512KB
DMAMEM: 170656 B (32.55% of 512 KB)
Available for Heap: 353632 B (67.45% of 512 KB)
Flash: 352280 B ( 4.33% of 7936 KB)