Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 25 of 25

Thread: DOOM running on the Teensy 4.1 with VGA output

  1. #1
    Senior Member
    Join Date
    May 2018
    Posts
    195

    DOOM running on the Teensy 4.1 with VGA output

    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... ;-)

  2. #2
    Senior Member
    Join Date
    May 2018
    Posts
    195
    I forgot to mention, please compile with the option "faster code" else the PSRAM seems to "hang up" the CPU at short intervals

  3. #3
    Senior Member
    Join Date
    Jul 2020
    Posts
    477
    Nice! Is the audio handled?

  4. #4
    Senior Member
    Join Date
    May 2018
    Posts
    195
    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

  5. #5
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    70
    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.

  6. #6
    Very cool��

  7. #7
    Senior Member
    Join Date
    May 2018
    Posts
    195
    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!

  8. #8
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    70
    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

  9. #9
    Senior Member
    Join Date
    May 2018
    Posts
    195
    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.

  10. #10
    Senior Member
    Join Date
    May 2018
    Posts
    195
    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 ;-(

  11. #11
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    70
    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.

  12. #12
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,735
    Quote Originally Posted by darthvader View Post
    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

  13. #13
    Senior Member
    Join Date
    May 2018
    Posts
    195
    Hi Defragster,

    Thanks confirming. It was indeed a problem with T4.0 but not with T4.1!
    Last edited by defragster; 10-19-2020 at 12:08 PM. Reason: opps

  14. #14
    Junior Member
    Join Date
    Sep 2017
    Posts
    5
    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

  15. #15
    Senior Member
    Join Date
    May 2018
    Posts
    195
    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.

  16. #16
    Junior Member
    Join Date
    Sep 2017
    Posts
    5
    Quote Originally Posted by Jean-Marc View Post
    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)
    Last edited by Jaapio; 10-22-2020 at 10:01 AM.

  17. #17
    Senior Member
    Join Date
    May 2018
    Posts
    195
    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.

  18. #18
    Junior Member
    Join Date
    Sep 2017
    Posts
    5
    I just tried the vcs emulator, I didn't have any roms so I downloaded a demo from https://files.scene.org/view/parties...o/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...

  19. #19
    Senior Member
    Join Date
    May 2018
    Posts
    195
    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

  20. #20
    Senior Member
    Join Date
    May 2018
    Posts
    195
    here is a picture
    Click image for larger version. 

Name:	doom.jpg 
Views:	28 
Size:	60.1 KB 
ID:	22168

  21. #21
    Junior Member
    Join Date
    Sep 2017
    Posts
    5
    Quote Originally Posted by Jean-Marc View Post
    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
    Last edited by Jaapio; 10-22-2020 at 08:15 PM.

  22. #22
    Junior Member
    Join Date
    Sep 2017
    Posts
    5
    The demo for the full version of doom now loads too! I did have to set the clock to 50000000.

  23. #23
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    7,096
    Quote Originally Posted by Jean-Marc View Post
    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..

  24. #24
    Senior Member
    Join Date
    May 2018
    Posts
    195
    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!

  25. #25
    Junior Member
    Join Date
    Apr 2016
    Posts
    4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •