Skip to content
/ smdt Public

Sega Megadrive/Genesis terminal emulator, telnet and IRC client

License

Notifications You must be signed in to change notification settings

SweMonkey/smdt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMD Terminal emulator, Telnet and IRC client v0.31+

A terminal emulator, telnet and IRC client for the Sega Mega Drive/Genesis with support for keyboards and RS-232 communication.
Screenshot of the telnet client in 80 column + 16 colour mode Screenshot of the IRC client Screenshot of the terminal emulator showing nano Screenshot of a debugging utility to inspect streams Screenshot of the telnet client in 80 column + 8 colour mode Screenshot of the terminal emulator

Table of Contents

Disclaimer

Warning

Do note that the MD is a 5 volt system! That means you should take care to not connect any random serial device directly to the MD (Such as a PC).
Use a "voltage translator" such as the max3232 between your MD and remote device to translate the voltage levels.
Make sure you understand my ramble down under the "Device" section to hook up external devices correctly!
I (smds) will not take any responsibilities for any failure to read and understand the above warning.


Thanks to

b1tsh1ft3r - Testing, improvement ideas and RetroLink/xPort support
RKT - For creating a 4x8 extended ASCII font tileset
Stef - For creating SGDK
Sik - For creating the website Plutiedev with valuable information regarding the MD
littlefs - For an awesome little filesystem

Building SMDTC from source

This part needs to be expanded, for now it assumes you are familiar with SGDK and how to use it.

To build SMDTC from source you will need SGDK version 1.80 (newer versions untested but will probably work as SMDTC mostly only uses macros and basic functions from SGDK)
The SGDK library must be rebuilt with the flags HALT_Z80_ON_IO and HALT_Z80_ON_DMA set to 0 in config.h to make sure the z80 CPU is never getting its bus back.

Running SMDTC

SMDTC is made to run on the original Mega Drive / Genesis hardware;
Easiest way to run SMDTC on your system is by transferring the binary file smdt_vX.YY.Z.bin to a flashcart.

You can also run SMDTC in a Mega Drive / Genesis emulator and easily check it out; Do mind that most emulators do not provide any way to actually connect any external serial devices or keyboards.

I highly recommend the emulator BlastEm 0.6.3+ since it supports the Sega Saturn keyboard as well as providing the functionality to connect the serial port to a UNIX socket, allowing SMDTC to connect to remote servers.

Running SMDTC in blastEm

To run SMDTC on blastEm you need setup IO devices in blastEm, this is partially done by going into the system settings in blastEm (Settings -> System)

For IO Port 1 Device, select "Saturn keyboard"

To setup IO Port 2 Device you need to navigate to your blastem.cfg file, on linux this file is by default located in ~/.config/blastem/
Open blastem.cfg and scroll down to the io section.
In the device block change 2 <some device> to 2 serial
After the device block, add this line: socket smdtsock.sock

Your io section should now look something like this:

io {
	devices {
		1 saturn keyboard
		2 serial
		ext none
	}
	socket smdtsock.sock
	ea_multitap {
		1 gamepad6.1
		2 gamepad6.2
		3 gamepad6.3
		4 gamepad6.4
	}
	sega_multitap.1 {
		1 gamepad6.2
		2 gamepad6.3
		3 gamepad6.4
		4 gamepad6.5
	}
}

If the serial port is setup correctly in blastEm, then you can now connect to the above socket by using the tool SMDT-PC like this:

  1. Open smdt_vX.YY.Z.bin in blastEm.
  2. Launch SMDT-PC with this command in a terminal: ./smdtpc -xportsock /path/to/blastEm/smdtsock.sock.

In step 1, blastEm and SMDT will initially halt and wait for a connection being made (step 2)
If all is well SMDT should print out "XPN: xPort module OK" to the boot messages and you're good to go.

Note

  1. Requires a very recent nightly build of blastEm as blastEm's serial mode was bugged in versions prior to revision 25e40370e0e4 (2024-10-27).
  2. SMDT-PC (xPort emulator) is in early stages, it may lack certain features or contain bugs.
  3. It is not strictly required to use Port 1 and Port 2;
    SMDT will autodetect which port the keyboard is plugged into.
    If you want to have the serial port on a different controller port then you will need to change where SMDT looks for it using the Quick Menu (F8): Mega Drive Settings -> Select serial port.

Required hardware

  1. A PS/2 keyboard or a Sega Saturn keyboard (not strictly required but preferred).
  2. A 5 volt RS-232 serial connection or an xPort module.
  3. A Mega Drive or Genesis and a way to run roms on it.

RetroLink network cartridge as an alternative network adapter is being worked on.

Devices

SMDTC has a device manager which can autodetect if a device is present and where it is plugged in.
Device detection is only done on bootup, no plug & play support (yet).

A total of 2 PS/2 devices and 1 UART device can potentially be connected to a single MD controller port. However, beware the power draw may exceed what the MD can supply!

When a keyboard is connected and detected a 'K' icon will be visible in the status bar.
A fallback joypad device will be activated if SMDTC fails to find a keyboard or when a keyboard is plugged into PORT 2, allowing the use of a regular joypad.

All detected devices can be viewed in the "Connected devices" list (Quick menu -> Mega Drive settings -> Connected devices)

Note

SMDTC is limited when it comes to detecting the presence of a serial connection on the built in UART.
By default SMDTC will listen for incoming connections and attempt to find serial devices on PORT 2 UART.
This setting can be changed in the "Select serial port" menu (Quick menu -> Mega Drive settings -> Select serial port)
Do not forget to save your changes! (Quick menu -> System -> Save config)


List of autodetected devices

PS/2 Keyboard.
Sega Saturn keyboard.
Sega 3/6 button joypad.
xPort module connected to built in UART (May require you to set the correct serial port as described above)
RetroLink network adapter cartridge (Currently being worked on, support may be iffy)

How to wire up a PS/2 keyboard

For PS/2 devices (a keyboard or mouse) SMDTC has two ways to connect one:

Example keyboard wiring (1):
MD port pin 1 = PS/2 clock pin 5
MD port pin 2 = PS/2 data pin 1
MD port pin 5 = PS/2 VCC pin 4
MD port pin 8 = PS/2 GND pin 3

Example keyboard wiring (2):
MD port pin 3 = PS/2 clock pin 5
MD port pin 4 = PS/2 data pin 1
MD port pin 5 = PS/2 VCC pin 4
MD port pin 8 = PS/2 GND pin 3

See the pin configuration lists below for pinouts of the MD controller ports and PS/2 keyboard.

Pin configuration of the MD controller ports

MD port pin 1 = PS/2 device 1 clock (CLK1)
MD port pin 2 = PS/2 device 1 data (DATA1)
MD port pin 3 = PS/2 device 2 clock (CLK2)
MD port pin 4 = PS/2 device 2 data (DATA2)
MD port pin 5 = VCC (+5V)
MD port pin 6 = Serial TX
MD port pin 7 = Reserved (CP3)
MD port pin 8 = GND
MD port pin 9 = Serial RX

PS/2 pin reference

PS/2 pin 1 = Data
PS/2 pin 3 = GND
PS/2 pin 4 = VCC
PS/2 pin 5 = Clock

MD UART pin reference

MD port pin 5 = VCC
MD port pin 6 = TX
MD port pin 8 = GND
MD port pin 9 = RX

Connected device list

P1:0 = Port 1 @ pin 1+2
P1:1 = Port 1 @ pin 3+4
P1:S = Port 1 UART
P1:D = Port 1 Parallel+UART Mode
P2:0 = Port 2 @ pin 1+2
P2:1 = Port 2 @ pin 3+4
P2:S = Port 2 UART
P2:D = Port 2 Parallel+UART Mode
P3:0 = Port 3 @ pin 1+2
P3:1 = Port 3 @ pin 3+4
P3:S = Port 3 UART
P3:D = Port 3 Parallel+UART Mode

Filesystem

SMDT features a littlefs formatted filesystem that lives in SRAM.
It is currently hardcoded to a 32KB partition and SRAM is configured as BYTE/ODD. Maybe I'll add support for flashcart SD cards in the future?
SMDT will still work without SRAM but with no possibility to save settings due to obvious reasons.
The filesystem can be navigated and manipulated in the terminal using basic UNIX commands such as: ls, mv, cp, cat, touch, mkdir, rm, lsblk etc etc.

This is still very much WIP, beware data loss and bugs!

The little filesystem
Copyright (c) 2022, The littlefs authors.
Copyright (c) 2017, Arm Limited. All rights reserved.
See littlefs on github

Shortcuts

Quick menu

Right windows key OR F8 = Open the Quick menu
Enter = Enter submenu and activate a choice
Escape = Back out of current menu
Up cursor = Move selector up
Down cursor = Move selector down

IRC client

F1 = Channel 1 tab
F2 = Channel 2 tab
F3 = Channel 3 tab
F4 = Channel 4 tab
F5 = Channel 5 tab
Left arrow key = Switch to previous channel
Right arrow key = Switch to next channel
Tab = Toggle channel user list
Numpad 4 = Scroll left
Numpad 6 = Scroll right

Telnet client

None

Gopher client

Very WIP gopher client, use at your own risk!
Cursor keys = Move the cursor on screen
Enter = Go to link highlighted by the cursor

Terminal emulator

Type help for a list of all available built in commands.

History queue:
Up arrow = Go back in history of entered command strings.
Down arrow = Go forward in history or clear command string if at the last entered command string.

FAQ

Q: How do I change the terminal or IRC font?
A: Open the Quick Menu (F8) and go to "Settings -> Default fonts -> Terminal/IRC font" and select prefered font by using the cursor keys and finally confirming your choice by pressing Enter.

Q: Changing IRC font does not change anything?
A: Due to current design limitations of the IRC client the changes made won't take effect until next time the IRC client is started.

Q: My settings got reset after rebooting!
A: Make sure to save your settings by either using the Quick menu (System -> Save config) or by typing savecfg and pressing Enter in the terminal. If settings still fail to save it may be due to your system or emulator lacking SRAM, thus being unable to access the filesystem in SMDT.

Q: How do I change my IRC nick?
A: In the terminal, run the command setvar username yournick OR in the IRC client, type /nick yournick and press Enter.

Q: How do I join a channel?
A: Type /join #channel in the text input box at the bottom and press Enter.

Q: I get double characters typed when I type on certain telnet servers?
A: Either the server or SMDT failed to setup local echo. You can change this manually in the Quick meu (Settings -> Client settings -> Terminal -> Variables -> Local echo -> On).