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

Thread: Teensy 4.1 Atari ST emulation with MIDI & VGA

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

    Teensy 4.1 Atari ST emulation with MIDI & VGA

    The Teensy is now able to emulate an Atari ST computer with VGA output and MIDI control via its USB host interface.

    https://www.youtube.com/watch?v=H-TlCDBwdak
    https://www.youtube.com/watch?v=fzoTYUpEOKs

    https://github.com/Jean-MarcHarvengt...ster/README.md

  2. #2
    Junior Member
    Join Date
    Dec 2020
    Posts
    5
    Great work!! Earlier this year I was attempting to use my Macbook to emulate Atari ST MIDI Librarians/Editors for my Ensoniq ESQ-1, but I wasn't able to get MIDI to work... might have to try this out.

  3. #3
    Junior Member
    Join Date
    Dec 2020
    Posts
    5
    Hi Jean-Marc,

    Wanting to try the Atari emulator on my recently-acquired Teensy 4.1, I downloaded the repository (2b18321) today, and noted the instructions:

    # Compilation/flashing (Teensy)
    - open the respective ino file with Arduino SDK
    - select DISPLAY MODULE in platform_config.h (ST7789 or ILI9341)!!!!
    - select VGA or not in platform_config.h (T4.1 using vgat4 lib, T3.6 using uvga lib)
    - double check iopins.h for pins configuration!!!!
    - compile and install from there.
    Just to clarify, in platform_config.h, do I select ST7789/ILI9341/VGA by setting only one of the following?
    Code:
    #define ST7789         1
    #define ILI9341        1
    #define HAS_T4_VGA     1
    Finally, though I did eventually figure this out after searching these forums for "vga_t4", maybe mention in the Readme that we need to install the VGA_t4 library. Without it, I wasn't able to compile, even if setting #define HAS_T4_VGA 0. For example,

    Code:
    Arduino: 1.8.13 (Mac OS X), TD: 1.53, Board: "Teensy 4.1, Serial, 600 MHz, Faster, US English"
    
    In file included from /Teensy/Teensy MCUME/MCUME-2b18321/MCUME_teensy41/teensycastaway41/teensycastaway41.ino:38:0:
    /var/folders/xk/0yb20rbd6pv_0y6jp6vcbr1w0000gn/T/arduino_build_990766/sketch/vga_t_dma.h:9:20: fatal error: VGA_t4.h: No such file or directory
    compilation terminated.
    Error compiling for board Teensy 4.1.
    At any rate, after installing the library I was able to compile fine! But I'll have to wait until I can connect a VGA port, resistors, USB port, etc. to my new T4.1. Can't wait.

  4. #4
    Senior Member
    Join Date
    May 2018
    Posts
    211
    Dont forget you need the PSRAM chip soldered under the Teensy4.1 board, else it will not work!

    Best is indeed to use the VGA output.
    You should only select one of the supported display (comment out the others, e.g.):
    //#define ST7789 1
    //#define ILI9341 1
    #define HAS_T4_VGA 1

    It used to work with ILI9341 but then you only have 320X200 resolution.
    I did not try with latest code to be honest but it used to work.

    Also joystick + 3 buttons have to be connected else it might read out floating input.
    It is a bit of wiring but ok...
    Once you did it you can try all emulators including the amiga one too ... ;-)

  5. #5
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    83
    Hello Jean Marc

    I just have a question about pin-out when i want to use a SPI TFT LCD.
    As i see , the 2 user keys are in conflict with TFT_RST and TFT_CD , the I2S audio data pin is in conflict with TFT_DC.
    Some NES console use up to 4 buttons , can you tell me what pin was planned for this ?

    Cheers.

  6. #6
    Senior Member
    Join Date
    May 2018
    Posts
    211
    Hi,

    I have not used I2S with the TFT display.
    TFT_RST is not mandatory AFAIK. I used ILI and ST display. As I recall at least for the ST display it is not. I think same for ILI.

    TFT_CD/ you mean DC. As I said I was not using I2S at same time.
    I used MSQL audio only with the TFT display. MISO is not used for the TFT (only MOSI). I had a trick to avoid that the SPI library initializing the PIN configuration modifying the code.

    NES 4 buttons was never really supported. With the I2C keyboard I mapped most keys. There is a BUT key USER1,2,3.
    USER3 is supported in the code but you can map it to a pin in IOPINS.h. It was there on the T3.6 support. if you define it should be added.

    Just try and tell me

  7. #7
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    83
    Hi , thanks for all this information's
    I use the ILI9341 , so i will then not connect the MISO , TFT_RST will then be connected to VCC.
    For the user button that is conflicting with TFT_CS i will chose another pin , and will do same for other user pins in iopins.h

    Cheers

  8. #8
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    83
    Hi ,
    i have do like you said and everything is working up to the joybut and the 3 user keys.(they work on a test sketch i have do just for testing the analog joy and the buttons).
    The Emulators don't react to the joybut and the user keys , i don't have made the i2c kb because i have made a minimalistic box (like a handled console) so it stay very compact
    I tested with teensy5200 , teensygen , teensygnuboy , teensyvectrex .
    All emulators start and i can select a game (rom) , and that's it ... the game start and i can't do anything because the non reaction to the switch.
    Was those emulators only working with your i2c KB ??
    The case i printed is like that.
    Click image for larger version. 

Name:	teesy console A.jpg 
Views:	29 
Size:	182.0 KB 
ID:	23501
    Click image for larger version. 

Name:	teesy console B.jpg 
Views:	29 
Size:	147.4 KB 
ID:	23502

    Schematic:
    https://drive.google.com/file/d/1XbB...ew?usp=sharing

  9. #9
    Senior Member
    Join Date
    May 2018
    Posts
    211
    This problem is familiar to me. I will try again this w.e on my handled version.
    Normally no need for the I2C keyboard.
    You edited the option file and selected the proper options there I guess.

    The menu does not use the DMA mode for the display.
    As soon you start the emulator by launching the game, it switches to DMA. You see the game graphical updates but no control correct?

    You did not selected external SD, you use the SD card of the teensy 4.1, not of the display.

  10. #10
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    83
    I found why it was not working correctly
    It was here ...

    Code:
    #ifdef HAS_T4_VGA
    #define PIN_JOY2_A1X    A3
    #define PIN_JOY2_A2Y    A2
    #define PIN_JOY2_BTN    14
    #define PIN_KEY_USER1   22
    #define PIN_KEY_USER2   23
    #define PIN_KEY_USER3   35
    
    // Second joystick
    #define PIN_JOY1_BTN     34
    #define PIN_JOY1_1       35 // UP
    #define PIN_JOY1_2       36 // DOWN
    #define PIN_JOY1_3       38 // RIGHT
    #define PIN_JOY1_4       37 // LEFT
    
    #else
    #define PIN_JOY2_A1X    A3               <-----
    #define PIN_JOY2_A2Y    A2               <-----
    #define PIN_JOY2_BTN    14               <-----
    #define PIN_KEY_USER1   22 //34          <-----
    #define PIN_KEY_USER2   23 //35          <-----
    #define PIN_KEY_USER3   35               <-----
    Its just because i just have this define : #define HAS_T41 1
    So after the #else i don't have set the correct pins
    For answer your questions , i don't use external SD , just the one present on the t41 board , and here everything is perfect.

    The next i have to do is add audio , have you a schematic for this if you don't use pcm5102 ?
    Last edited by darthvader; 01-29-2021 at 10:37 PM.

  11. #11
    Senior Member
    Join Date
    May 2018
    Posts
    211
    the new pinout was introduced for T4.1 VGA because I needed more pins and because of the flexio usage.

    With my original ILI PCB, in lopins.h, it should end up in the else and I use those pins.

    Because the code was working with a T4.0, HAS_T41 don't need to be defined. If I recall well, HAS_T41 was defined if PSRAM is defined or needed by the emulator. With T4.0 I used my own PSRAM driver and for T4.1 it is just supported by the library.

    Happy it is working for you now (I hope at least)

    I will solder header pins on a new T4. and try again, to avoid swapping it from one board to the other and destroy it.

    If you want to use the I2S together with the ILI, you better use the other SPI bus for the T4.1 (pin 26 and 27)

    #ifdef HAS_T4_VGA
    #define PIN_JOY2_A1X A3
    #define PIN_JOY2_A2Y A2
    #define PIN_JOY2_BTN 14
    #define PIN_KEY_USER1 22
    #define PIN_KEY_USER2 23

    // Second joystick
    #define PIN_JOY1_BTN 34
    #define PIN_JOY1_1 35 // UP
    #define PIN_JOY1_2 36 // DOWN
    #define PIN_JOY1_3 38 // RIGHT
    #define PIN_JOY1_4 37 // LEFT

    #else
    #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

    // Second joystick
    #define PIN_JOY1_BTN 2
    #define PIN_JOY1_1 14 // UP
    #define PIN_JOY1_2 7 // DOWN
    #define PIN_JOY1_3 6 // RIGHT
    #define PIN_JOY1_4 5 // LEFT
    #endif

  12. #12
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    83
    Hi ,
    i tested some of the emulators , they are working up to one (.... problem.....) ,
    It seems that all emulators are slower than normal , can it be that the T41 is not set at 600Mhz ?
    In the Arduino IDE it's check for 600Mhz but i don't know if you change something in the emulators
    I tried to compile from Fastest to Smallest code but the speed stay the same ...
    Click image for larger version. 

Name:	teensy tetris.jpg 
Views:	28 
Size:	93.8 KB 
ID:	23529

  13. #13
    Senior Member
    Join Date
    May 2018
    Posts
    211
    few possibilities,
    - screen refresh too slow because of the SPI display (you can try go above the clock, normally it uses 60000000MHz in the DMA driver)
    - it does sync on timer interrupt (myTimer.begin(vblCount, 20000); in the sketch, you can lower the value)
    - for some there is a fixed delay sometimes in the sketch
    - play with frame skip in emuapi.h VID_FRAME_SKIP 0x0

    The teensy is fast enough for those emulator.
    Try for e.g. colecovision. It is a simple one and you should be able to make it running 5 times faster.

  14. #14
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    83
    That's it
    on gameboy emulator :
    myTimer.begin(vblCount, 40000); <--- i set it to 20000 and it's more like the expected speed
    VID_FRAME_SKIP 0x1 give a little boost too ....
    To test the result speed i have test with Sonic game on the sms emulator , it have a second counter in-game , was easy to compare the video i have do with a real clock

  15. #15
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    83
    I forget to ask you about audio
    On github i read that you use MSQ for audio.
    Do you use MSQR , MSQL or both ?
    If i understand correctly , all i have to do is to connect a little audio amplifier on this pins (10 & 12) to get sound .... correct me if i'm wrong

  16. #16
    Member
    Join Date
    Aug 2020
    Location
    France
    Posts
    83
    Hi Jean Marc ,
    I just fond out for audio , i activated the commented MQS in your code.
    But it was allot of noise , so i made a filter and now everything goes well

Tags for this Thread

Posting Permissions

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