Skip to content

Commit

Permalink
v0.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SweMonkey committed Jun 8, 2024
1 parent fff31b0 commit ed1eedf
Show file tree
Hide file tree
Showing 43 changed files with 1,238 additions and 480 deletions.
16 changes: 16 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
v0.30.0:
Terminal: Added bold variant of the 8x8 font.
Terminal: More colours in text output.
Terminal: Added "savecfg" command for saving config to sram.
Terminal: Added "reboot" command to reboot the system, with optional -soft parameter for soft reset instead of the default hard reset.
Terminal: Now wraps at screen edge instead of at column 80.
Terminal: Removed unused leftover variables.
Terminal: Fixed command parser reading some extra garbage if the inputted string was too long for the internal buffer.
Terminal: More stdout work. Automatic "less/more" when more than a full screen worth of text tries to print to the screen in one go.
Telnet/IRC/Terminal now has their own font selection setting, no more keeping track of state should use what font.
IRC: Fixed a leftover inverted check that caused the irc client to quit prematurely when initializing.
Net: More network callbacks.
XPN: More work done to support b1tsh1ft3r's controller port network adapter. Ping/Get IP/Transmit data/Receive data works good enough.
RLN: More work done to support b1tsh1ft3r's cartridge network adapter. Ping/Get IP/Transmit data works good enough, Receive data does not work correctly (lots of dropped/unprinted bytes?).
Hex viewer can now show the rx buffer, tx buffer and stdout buffer.

v0.29:
IRC: Cursor fix.
Added initial support for xPico module connected to an MD UART port.
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# SMD Terminal emulator, Telnet and IRC client v0.29+
# SMD Terminal emulator, Telnet and IRC client v0.30+
A terminal emulator, telnet and IRC client for the Sega Mega Drive/Genesis with support for PS/2 keyboards and RS-232 communication.<br>
![Screenshot of the telnet client](https://deceptsoft.com/smdtc_extra_git/telnet_small.png)
![Screenshot of the IRC client](https://deceptsoft.com/smdtc_extra_git/irc_small.png)
Expand Down
Binary file added res/ascii_b_i.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion res/system.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 8x8 Font glyps
TILESET GFX_ASCII_TERM "ascii_n_i.png" NONE NONE
TILESET GFX_ASCII_TERM_NORMAL "ascii_n_i.png" NONE NONE
TILESET GFX_ASCII_TERM_BOLD "ascii_b_i.png" NONE NONE

# 4x8 Font glyps with antialiasing, using colour indices 15/16
TILESET GFX_ASCII_TERM_SMALL_AA "4x8_by_RKT_v2_AA.png" NONE NONE
Expand Down
4 changes: 3 additions & 1 deletion smdt.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
"cstddef": "c",
"cursor.h": "c",
"irc.h": "c",
"atomic": "c"
"atomic": "c",
"sram.h": "c",
"kdebug.h": "c"
}
}
}
10 changes: 10 additions & 0 deletions src/Buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ void Buffer_Flush(Buffer *b)
b->tail = 0;
}

/// @brief Clear the buffer and fill the first 32 entries with 0
/// @param b Pointer to buffer
void Buffer_Flush0(Buffer *b)
{
b->head = 0;
b->tail = 0;

for (u8 i = 0; i < 32; i++) b->data[i] = 0;
}

/// @brief Get the last <num> of bytes up to head
/// @param b Pointer to buffer
/// @param num Number of bytes to return
Expand Down
1 change: 1 addition & 0 deletions src/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ u8 Buffer_Pop(Buffer *b, u8 *data);
u8 Buffer_ReversePop(Buffer *b);

void Buffer_Flush(Buffer *b);
void Buffer_Flush0(Buffer *b);
void Buffer_PeekLast(Buffer *b, u16 num, u8 r[]);

#endif // BUFFER_H_INCLUDED
50 changes: 22 additions & 28 deletions src/DevMgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,24 +199,8 @@ void DetectDevices()
vu8 *SCtrl;
SCtrl = (vu8 *)DEV_UART.SCtrl;
*SCtrl = 0x38;

// Check if xPico device is present
u8 xpn_r = XPN_Initialize();
switch (xpn_r)
{
/*case 0:
TRM_DrawText("XPN: Device not found", 1, BootNextLine++, PAL1);
break;*/
case 1:
TRM_DrawText("XPN: xPico module OK", 1, BootNextLine++, PAL1);
break;
case 2:
TRM_DrawText("XPN: Error", 1, BootNextLine++, PAL1);
break;

default:
break;
}
u8 xpn_r = 0;

if (RLN_Initialize()) // Check if RetroLink network adapter is present
{
Expand All @@ -225,13 +209,13 @@ void DetectDevices()
VDP_setReg(0xB, 0); // Disable VDP ext interrupt (Enable: 8 - Disable: 0)

NET_SetConnectFunc(RLN_Connect);

TRM_DrawText("RetroLink IP: ", 1, BootNextLine++, PAL1);
RLN_PrintIP(1, BootNextLine++);
TRM_DrawText("RetroLink MAC: ", 1, BootNextLine++, PAL1);
RLN_PrintMAC(1, BootNextLine++);
NET_SetDisconnectFunc(RLN_BlockConnections);
NET_SetGetIPFunc(RLN_GetIP);
NET_SetPingFunc(RLN_PingIP);

TRM_DrawText("RLN: RetroLink found", 1, BootNextLine++, PAL1);
}
else if (xpn_r) // Was something resembling an xPico module found earlier?
else if ((xpn_r = XPN_Initialize())) // Check if xPico device is present
{
DEV_UART.Id.sName = "XPICO UART";

Expand All @@ -241,18 +225,28 @@ void DetectDevices()
bXPNetwork = TRUE;

NET_SetConnectFunc(XPN_Connect);
NET_SetDisconnectFunc(XPN_Disconnect);
NET_SetGetIPFunc(XPN_GetIP);
NET_SetPingFunc(XPN_PingIP);

//TRM_DrawText("xPico IP: <not implemented>", 1, BootNextLine++, PAL1);
//XPN_PrintIP(1, BootNextLine++);
//TRM_DrawText("xPico MAC: <not implemented>", 1, BootNextLine++, PAL1);
//XPN_PrintMAC(1, BootNextLine++);
switch (xpn_r)
{
case 1:
TRM_DrawText("XPN: xPico module OK", 1, BootNextLine++, PAL1);
break;
case 2:
TRM_DrawText("XPN: Error", 1, BootNextLine++, PAL1);
break;

default:
break;
}
}
else // No external network adapters found
{
bRLNetwork = FALSE;
bXPNetwork = FALSE;

//TRM_DrawText("RetroLink Network Adapter not found", 1, BootNextLine++, PAL1);
TRM_DrawText("No network adapters found", 1, BootNextLine++, PAL1);
TRM_DrawText("Listening on built in UART", 1, BootNextLine++, PAL1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DevMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct s_deviceid
char *sName; // Device name
u8 Bitmask; // Used bits (Example; Used bits = b00000011)
u8 Bitshift; // Used bits shift (Example; If Shift=2 then Used bits = b00001100)
u8 Mode; // 0=Parallel / 1=Serial
u8 Mode; // 1=Parallel / 2=Serial / 3=Both
} SM_DeviceId;

typedef struct s_device
Expand Down
62 changes: 42 additions & 20 deletions src/HexView.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,40 @@
#include "UI.h"
#include "Network.h"
#include "Utils.h"
#include "misc/Stdout.h"

static u32 FileOffset = 0;
static s16 ScrollY = 0;
bool bShowHexView = FALSE;
static SM_Window HexWindow;
static Buffer *bufptr = NULL;
static char WinTitle[16];
bool bShowHexView = FALSE;


void DrawDataLine(u8 Line)
{
char buf[41];
sprintf(buf, "%04lX %02X %02X %02X %02X %02X %02X %02X %02X %c%c%c%c%c%c%c%c",
FileOffset, RxBuffer.data[FileOffset+0], RxBuffer.data[FileOffset+1], RxBuffer.data[FileOffset+2], RxBuffer.data[FileOffset+3], RxBuffer.data[FileOffset+4], RxBuffer.data[FileOffset+5], RxBuffer.data[FileOffset+6], RxBuffer.data[FileOffset+7],
(char)((RxBuffer.data[FileOffset+0] >= 0x20) && (RxBuffer.data[FileOffset+0] <= 0x7E) ? RxBuffer.data[FileOffset+0] : '.'),
(char)((RxBuffer.data[FileOffset+1] >= 0x20) && (RxBuffer.data[FileOffset+1] <= 0x7E) ? RxBuffer.data[FileOffset+1] : '.'),
(char)((RxBuffer.data[FileOffset+2] >= 0x20) && (RxBuffer.data[FileOffset+2] <= 0x7E) ? RxBuffer.data[FileOffset+2] : '.'),
(char)((RxBuffer.data[FileOffset+3] >= 0x20) && (RxBuffer.data[FileOffset+3] <= 0x7E) ? RxBuffer.data[FileOffset+3] : '.'),
(char)((RxBuffer.data[FileOffset+4] >= 0x20) && (RxBuffer.data[FileOffset+4] <= 0x7E) ? RxBuffer.data[FileOffset+4] : '.'),
(char)((RxBuffer.data[FileOffset+5] >= 0x20) && (RxBuffer.data[FileOffset+5] <= 0x7E) ? RxBuffer.data[FileOffset+5] : '.'),
(char)((RxBuffer.data[FileOffset+6] >= 0x20) && (RxBuffer.data[FileOffset+6] <= 0x7E) ? RxBuffer.data[FileOffset+6] : '.'),
(char)((RxBuffer.data[FileOffset+7] >= 0x20) && (RxBuffer.data[FileOffset+7] <= 0x7E) ? RxBuffer.data[FileOffset+7] : '.'));

UI_DrawText(0, Line, buf);
FileOffset, bufptr->data[FileOffset+0], bufptr->data[FileOffset+1], bufptr->data[FileOffset+2], bufptr->data[FileOffset+3], bufptr->data[FileOffset+4], bufptr->data[FileOffset+5], bufptr->data[FileOffset+6], bufptr->data[FileOffset+7],
(char)((bufptr->data[FileOffset+0] >= 0x20) && (bufptr->data[FileOffset+0] <= 0x7E) ? bufptr->data[FileOffset+0] : '.'),
(char)((bufptr->data[FileOffset+1] >= 0x20) && (bufptr->data[FileOffset+1] <= 0x7E) ? bufptr->data[FileOffset+1] : '.'),
(char)((bufptr->data[FileOffset+2] >= 0x20) && (bufptr->data[FileOffset+2] <= 0x7E) ? bufptr->data[FileOffset+2] : '.'),
(char)((bufptr->data[FileOffset+3] >= 0x20) && (bufptr->data[FileOffset+3] <= 0x7E) ? bufptr->data[FileOffset+3] : '.'),
(char)((bufptr->data[FileOffset+4] >= 0x20) && (bufptr->data[FileOffset+4] <= 0x7E) ? bufptr->data[FileOffset+4] : '.'),
(char)((bufptr->data[FileOffset+5] >= 0x20) && (bufptr->data[FileOffset+5] <= 0x7E) ? bufptr->data[FileOffset+5] : '.'),
(char)((bufptr->data[FileOffset+6] >= 0x20) && (bufptr->data[FileOffset+6] <= 0x7E) ? bufptr->data[FileOffset+6] : '.'),
(char)((bufptr->data[FileOffset+7] >= 0x20) && (bufptr->data[FileOffset+7] <= 0x7E) ? bufptr->data[FileOffset+7] : '.'));

UI_DrawText(0, Line, PAL1, buf);
}

void UpdateView()
{
u16 p = ScrollY << 3;
UI_Begin(&HexWindow);

FileOffset = p;

UI_Begin(&HexWindow);

for (u8 l = 0; l < 24; l++)
{
DrawDataLine(l);
Expand All @@ -42,7 +45,7 @@ void UpdateView()

UI_DrawVLine(4, 0, 24, UC_VLINE_SINGLE);
UI_DrawVLine(28, 0, 24, UC_VLINE_SINGLE);
UI_DrawVScrollbar(37, 0, 24, 0, (BUFFER_LEN-1)-0xC0+2, p); // 0xFFF = RxBuf size - 0xC0 = amount of data on a single screen + 2 to make sure slider doesn't go over down arrow
UI_DrawVScrollbar(37, 0, 24, 0, (BUFFER_LEN-1)-0xC0+2, p); // 0xFFF = Buffer size - 0xC0 = amount of data on a single screen + 2 to make sure slider doesn't go over down arrow

UI_End();
}
Expand All @@ -62,7 +65,7 @@ void HexView_Input()

if (is_KeyDown(KEY_DOWN))
{
if (ScrollY < ((BUFFER_LEN/8)-24))//296)
if (ScrollY < ((BUFFER_LEN/8)-24))
{
ScrollY++;
UpdateView();
Expand All @@ -85,7 +88,7 @@ void HexView_Input()

if (is_KeyDown(KEY_RIGHT))
{
if (ScrollY < ((BUFFER_LEN/8)-31))//289)
if (ScrollY < ((BUFFER_LEN/8)-31))
{
ScrollY += 8;
UpdateView();
Expand All @@ -99,7 +102,7 @@ void HexView_Input()

if (is_KeyDown(KEY_ESCAPE))
{
HexView_Toggle();
HexView_Toggle(0);
}

return;
Expand All @@ -111,15 +114,15 @@ void DrawHexView()
TRM_ClearTextArea(0, 0, 35, 1);
TRM_ClearTextArea(0, 1, 40, 29);

UI_CreateWindow(&HexWindow, "HexView - Rx Buffer", UC_NONE);
UI_CreateWindow(&HexWindow, WinTitle, UC_NONE);

FileOffset = 0;
ScrollY = 0;

UpdateView();
}

void HexView_Toggle()
void HexView_Toggle(u8 bufnum)
{
if (bShowHexView)
{
Expand All @@ -129,6 +132,25 @@ void HexView_Toggle()
}
else
{
switch (bufnum)
{
case 0:
strcpy(WinTitle, "HexView - Rx Buffer");
bufptr = &RxBuffer;
break;
case 1:
strcpy(WinTitle, "HexView - Tx Buffer");
bufptr = &TxBuffer;
break;
case 2:
strcpy(WinTitle, "HexView - Stdout");
bufptr = &stdout;
break;

default:
break;
}

DrawHexView();
}

Expand Down
2 changes: 1 addition & 1 deletion src/HexView.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
extern bool bShowHexView;

void HexView_Input();
void HexView_Toggle();
void HexView_Toggle(u8 bufnum);

#endif // HEXVIEW_H_INCLUDED
41 changes: 28 additions & 13 deletions src/IRC.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Cursor.h"
#include "StateCtrl.h"
#include "../res/system.h"
#include "misc/Stdout.h"

/*
USERLIST WARNING:
Expand Down Expand Up @@ -67,9 +68,6 @@ char **PG_UserList = {NULL};
u16 PG_UserNum = 0;
u16 UserIterator = 0;

// Terminal print function used to return error messages
extern void PrintOutput(const char *str);


void IRC_Init()
{
Expand All @@ -95,6 +93,8 @@ void IRC_Reset()
NickReRegisterCount = 0;
sv_CursorCL = 0x0E0;
LastCursor = 0x12;

Stdout_Flush();

// Allocate and setup channel slots
for (u8 ch = 0; ch < IRC_MAX_CHANNELS; ch++)
Expand All @@ -105,8 +105,9 @@ void IRC_Reset()
#ifdef IRC_LOGGING
kprintf("Failed to allocate memory for PG_Buffer[%u]", ch);
#endif
ChangeState(PS_Terminal, 0, NULL);
PrintOutput("Failed to allocate memory for PG_Buf!");
Stdout_Push("IRC Client: Failed to allocate memory\n for PG_Buf!\n");
RevertState();
return;
}
memset(PG_Buffer[ch], 0, sizeof(TMBuffer));
strcpy(PG_Buffer[ch]->Title, PG_EMPTYNAME);
Expand All @@ -123,8 +124,9 @@ void IRC_Reset()
#ifdef IRC_LOGGING
kprintf("Failed to allocate memory for LineBuf");
#endif
ChangeState(PS_Terminal, 0, NULL);
PrintOutput("Failed to allocate memory for LineBuf!");
Stdout_Push("IRC Client: Failed to allocate memory\n for LineBuf!\n");
RevertState();
return;
}
memset(LineBuf, 0, sizeof(struct s_linebuf));

Expand All @@ -135,8 +137,9 @@ void IRC_Reset()
#ifdef IRC_LOGGING
kprintf("Failed to allocate memory for RXString");
#endif
ChangeState(PS_Terminal, 0, NULL);
PrintOutput("Failed to allocate memory for RXString!");
Stdout_Push("IRC Client: Failed to allocate memory\n for RXString!\n");
RevertState();
return;
}
memset(RXString, 0, B_RXSTRING_LEN);

Expand All @@ -153,8 +156,19 @@ void IRC_Reset()
#ifdef IRC_LOGGING
kprintf("Failed to allocate memory for PG_UserList[%u]", i);
#endif
ChangeState(PS_Terminal, 0, NULL);
PrintOutput("Failed to allocate memory for PG_UserList[x]!");
//Stdout_Push("IRC Client: Failed to allocate memory\n for PG_UserList[x]!\n\n");
char tmp[80];

sprintf(tmp, "IRC Client: Failed to allocate memory\n for PG_UserList[%u]!\n", i);
Stdout_Push(tmp);

sprintf(tmp, "Free: %u - Needed: %u", MEM_getLargestFreeBlock(), IRC_MAX_USERNAME_LEN*IRC_MAX_USERLIST);
Stdout_Push(tmp);

Stdout_Push("\n");

RevertState();
return;
}
memset(PG_UserList[i], 0, IRC_MAX_USERNAME_LEN);
}
Expand All @@ -164,8 +178,9 @@ void IRC_Reset()
#ifdef IRC_LOGGING
kprintf("Failed to allocate memory for PG_UserList");
#endif
ChangeState(PS_Terminal, 0, NULL);
PrintOutput("Failed to allocate memory for PG_UserList!");
Stdout_Push("Failed to allocate memory for PG_UserList!\n");
RevertState();
return;
}

// Set defaults
Expand Down
Loading

0 comments on commit ed1eedf

Please sign in to comment.