PDA

View Full Version : DOOM running on the Teensy 4.1 with VGA output



Jean-Marc
10-10-2020, 03:16 PM
Happy to share this little video with you...

https://www.youtube.com/watch?v=adYwnctiKsg

and the code of course:

https://github.com/Jean-MarcHarvengt/MCUME
(Doom is part of the tree next to other emulator ports)

Not all keys are mapped on the USB keyboard but it is easy to add them... ;-)

Jean-Marc
10-10-2020, 03:31 PM
I forgot to mention, please compile with the option "faster code" else the PSRAM seems to "hang up" the CPU at short intervals

MarkT
10-12-2020, 02:06 AM
Nice! Is the audio handled?

Jean-Marc
10-12-2020, 06:59 AM
Not yet but I am working on it. It is a general issue with my VGA driver, that audio DMA transfer is interfering with the VGA ones. I am experimenting with interrupt based transfer. I hope some light for next w-e

darthvader
10-13-2020, 01:30 PM
Hi Jean Marc,
Is it possible for you to made a real schematic ?
From the PCB it's not really easy to know the connection if we do it on a test board ;)

Thanks.

tschrama
10-13-2020, 03:19 PM
Very cool��

Jean-Marc
10-14-2020, 06:47 AM
I will for sure add the schematic this w-e, I am now busy to add a dedicated audio driver to the VGA library to avoid DMA disturbance. I saw some light at the end of the tunnel yesterday!

darthvader
10-14-2020, 11:57 AM
Are you going to use the PCM5102 for audio ?
If yes , let me know , so i will look to add it on the new test board i have to do later this week :)

Jean-Marc
10-14-2020, 02:42 PM
PCM5102 Indeed. Not sure they are all the same modules I only use 3 lines+ power. No master clock needed. I also use the default volume level so no real need for i2c else there is a default control module in the audio lib for it if you need.

Jean-Marc
10-17-2020, 09:11 PM
A "kind of" schematic has been added in the project. Emulators as the Colecovision and the ZX Spectrum ones now supports sound with VGA. Others also but still few bugs to fix ;-(

darthvader
10-18-2020, 10:05 AM
Hi ;)
With the schematic it's allot easier to see how everything is connected together :)
But i see that you are using the pins D34 to D37 for the external joystick , this pins are connected to the PSRAM and because of this , i will not use them for something else if the extra PSRAM chip is soldered on the board.

defragster
10-18-2020, 10:59 AM
Hi ;)
With the schematic it's allot easier to see how everything is connected together :)
But i see that you are using the pins D34 to D37 for the external joystick , this pins are connected to the PSRAM and because of this , i will not use them for something else if the extra PSRAM chip is soldered on the board.

T_4.1 with PSRAM soldered to underside does not use any 'edge' pins like D34-37 or other? Those pins for bottom chip pads are unique, shown here on this PDF by KurtE :github.com/KurtE/TeensyDocuments/blob/master/Teensy4.1%20Pins.pdf (https://github.com/KurtE/TeensyDocuments/blob/master/Teensy4.1%20Pins.pdf)

Jean-Marc
10-18-2020, 11:08 AM
Hi Defragster,

Thanks confirming. It was indeed a problem with T4.0 but not with T4.1!

Jaapio
10-21-2020, 11:33 PM
Well done Jean-Marc!

I tried it on my Teensy 4.1 with an SPI ILI9341 Display and 16 MB of psram but after the menu all I got was a white screen. Since I don't have a keyboard connected I rigged the handleMenu function so that if you'd send the character a it sets bClick to MASK_JOY1_BTN. The serial monitor just shows:

DOOM.WAD
DOOM2.WAD
DOOM1.WAD
SD initialized, files found: 3

Current callibration params:
34
60
285
222
pre callibrateTouch
post callibrateTouch

Got a serial char: a
/data/DOOM.WAD
fopen
/data/DOOM.WAD
0
12408292
fsize
12408292
could allocate dynamic
64000
could allocate dynamic
1284
could allocate dynamic
16384
init end

Jean-Marc
10-22-2020, 06:20 AM
Il did not try the latest code with the ili display but I think it is because you have a non official wad file' it only works with official version. You should take it from doom95, it must be around 4mb. Also compile for faster code. I will try when back from work.

Jaapio
10-22-2020, 09:35 AM
Il did not try the latest code with the ili display but I think it is because you have a non official wad file' it only works with official version. You should take it from doom95, it must be around 4mb. Also compile for faster code. I will try when back from work.

Yes, I compiled for faster code and 600Mhz. I read something about a USE_VIDEO_PLL but I am not sure where or how to set that.

Not sure what you mean with 4mb, the wads I got from gog are way bigger:

DOOM.WAD - 12.408.292 bytes, the version from gog
DOOM2.WAD - 14.604.584 bytes, the version from gog
DOOM1.WAD - 4.196.020 bytes, the 1.9 shareware version (I tried another version but then I got an error message about the version)

Jean-Marc
10-22-2020, 05:04 PM
I did not reconnect the ILI display but at least on the VGA:
- when I compile the sketch I have: 508596 octets of RAM (97%)
- my DOOM1.wad file seems to be same (see below)

if I run it (latest repo)
frequency
604200
div
24.00
DOOM1.WAD
DOOM2.WAD
PLUTONIA.WAD
TNT.WAD
SD initialized, files found: 4
Current callibration params:
34
60
285
222
/data/DOOM1.WAD
fopen
/data/DOOM1.WAD
0
4196020
fsize
4196020
could allocate dynamic
64000
could allocate dynamic
1284
could allocate dynamic
16384
init end

Did you try another emulator from the MCUME (something simple as the atari2600 or Coleco? Do you have the same?
I hope it is not the DMA copy which is too fast (menu does not use DMA but the emu/doom does)

Normally in the platform_config.h
you just comment out HAS_T4_VGA
and define the ILI934.

if I disable HAS_USBKEY I get a sketch of 467636 octets for the VGA version but it still works.

pinout is also different if you don't use HAS_T4_VGA. That is just because of the difference in my 2 PCBs in history...

#define PIN_JOY2_A1X A1
#define PIN_JOY2_A2Y A2
#define PIN_JOY2_BTN 17
#define PIN_KEY_USER1 3 //34
#define PIN_KEY_USER2 4 //35

I need to delicately move the teensy from one prototype board to the other to test, first a jogging ;-)
Keep you informed.

Jaapio
10-22-2020, 06:36 PM
I just tried the vcs emulator, I didn't have any roms so I downloaded a demo from https://files.scene.org/view/parties/2004/buenzli04/alternative_demo/vtg_2600.zip when I select that rom from the menu the screen goes to white. This is what the serial monitor contains:
2600.BIN

SD initialized, files found: 1
Current callibration params:
34
60
285
222
bClick = MASK_JOY2_BTN
2600/2600.BIN
could allocate dynamic
16384
could allocate dynamic
4096
could allocate dynamic
1024
could allocate dynamic
224
could allocate dynamic
30728
LoadFile...
2600/2600.BIN
4096


The same result for the gameboy emulator. How ever, I did notice that when the doom1 wad is loaded the screen sometimes flickers in brightness and one time it logged a message about a texture (I forgot to copy the message). I will try running some ILI dma examples...

Jean-Marc
10-22-2020, 07:47 PM
I just tried and the latest code published is working with the ILI for me.
You can try reducing the SPI clock in tft_t_dma.cpp
#define SPICLOCK 60000000
you can try 40000000?
May be some displays are more tolerant.
I used below config.
The DMA starts in the ino file at tft.startDMA();
You can try to put a delay for debugging?


#ifndef _PLATFORM_CONFIG_H_
#define _PLATFORM_CONFIG_H_

//#define OLD_LAYOUT 1
//#define HAS_T4_VGA 1

//#define INVX 1
#define INVY 1
//#define HAS_SND 1
//#define HAS_USBKEY 1
//#define HAS_I2CKBD 1

#define ILI9341 1
//#define ST7789 1
//#define SWAP_JOYSTICK 1
//#define LOHRES 1
//#define ROTATE_SCREEN 1
//#define EXTERNAL_SD 1

//#define USE_SDFAT 1
//#define SD_FAT_TYPE 1
//#define USE_SDFS 1
//#define SDFSDEV "1:"

#endif

Jean-Marc
10-22-2020, 07:53 PM
here is a picture
22168

Jaapio
10-22-2020, 07:57 PM
I just tried and the latest code published is working with the ILI for me.
You can try reducing the SPI clock in tft_t_dma.cpp
#define SPICLOCK 60000000
you can try 40000000?
May be some displays are more tolerant.
I used below config.
The DMA starts in the ino file at tft.startDMA();
You can try to put a delay for debugging?


#ifndef _PLATFORM_CONFIG_H_
#define _PLATFORM_CONFIG_H_

//#define OLD_LAYOUT 1
//#define HAS_T4_VGA 1

//#define INVX 1
#define INVY 1
//#define HAS_SND 1
//#define HAS_USBKEY 1
//#define HAS_I2CKBD 1

#define ILI9341 1
//#define ST7789 1
//#define SWAP_JOYSTICK 1
//#define LOHRES 1
//#define ROTATE_SCREEN 1
//#define EXTERNAL_SD 1

//#define USE_SDFAT 1
//#define SD_FAT_TYPE 1
//#define USE_SDFS 1
//#define SDFSDEV "1:"

#endif

That's it! I've set it to 55000000 and now it works... ... well at least the demo played for 10-20 seconds and then everything turned to black. Could it be that the screen is not getting enough power causing clock issues?

Edit:

Now it seems to keep on running:
https://www.youtube.com/watch?v=9W24pFAv8CY

Thanks for the help. It is really cool to see Doom run on a Teensy :-D

Jaapio
10-22-2020, 11:07 PM
The demo for the full version of doom now loads too! I did have to set the clock to 50000000.

Frank B
10-26-2020, 10:04 AM
Happy to share this little video with you...

https://www.youtube.com/watch?v=adYwnctiKsg

and the code of course:

https://github.com/Jean-MarcHarvengt/MCUME
(Doom is part of the tree next to other emulator ports)


Wooow this is great.

As far as I can tell from the video, it runs faster than on the PC i owned..

Jean-Marc
11-06-2020, 03:41 PM
Hi Frank,

Sure, the Teensy 4.1 is such a beast ;-)

Please also have look at the latest version of the VGA driver with "non DMA" I2S sound (to reduce video interference) and improved image stability at higher resolution.

Enjoy Amiga and Atari ST emulation at VGA resolution up to 640x480 with sound!!!

https://www.youtube.com/watch?v=vex335vHc68
https://www.youtube.com/watch?v=LKdcduVwwGQ

Latest code is on the GIT.
https://github.com/Jean-MarcHarvengt/MCUME

You C64 emulator was such a great source of inspiration for this project!

pmprog
11-08-2020, 05:54 PM
Great project. Well done.
Wish I'd seen this when posting my question about using the Teensy as a TV out, seems if I use my 4.0 should be fine, though I have since broken the left trigger button on my OGA, so my agency has somewhat lessened.
Still, great to see what this is capable of