LaunchAPPLServer: optional embedded debug console

This commit is contained in:
Wolfgang Thaller 2019-01-09 00:31:32 +01:00
parent 71660defd6
commit 360c364bf9
5 changed files with 74 additions and 5 deletions

View File

@ -25,10 +25,17 @@ else()
)
endif()
option(LAUNCHAPPLSERVER_DEBUG_CONSOLE "Add a debug console to LaunchAPPLServer" FALSE)
set(MAYBE_CONSOLE)
if(LAUNCHAPPLSERVER_DEBUG_CONSOLE)
set(MAYBE_CONSOLE "CONSOLE")
endif()
add_application(LaunchAPPLServer
TYPE "APPL"
CREATOR "R68L"
${MAYBE_CONSOLE}
LaunchAPPLServer.r
LauncherIcon.r
@ -46,6 +53,9 @@ add_application(LaunchAPPLServer
${CONNECTION_SOURCES}
)
if(LAUNCHAPPLSERVER_DEBUG_CONSOLE)
target_compile_definitions(LaunchAPPLServer PRIVATE DEBUG_CONSOLE)
endif()
target_link_libraries(LaunchAPPLServer LaunchAPPLCommon)
set_target_properties(LaunchAPPLServer PROPERTIES

View File

@ -300,6 +300,9 @@ public:
size_t onReceive(const uint8_t* p, size_t n)
{
#ifdef DEBUG_CONSOLE
printf("Received %d bytes in state %d.\n", (int)n, (int)state);
#endif
switch(state)
{
case State::command:
@ -309,6 +312,7 @@ public:
command = (RemoteCommand)p[0];
if(command == RemoteCommand::launchApp || command == RemoteCommand::upgradeLauncher)
state = State::header;
return 1;
}
@ -333,8 +337,8 @@ public:
if(dataSize)
{
state = State::data;
remainingSize = dataSize;
state = State::data;
remainingSize = dataSize;
}
else if(rsrcSize)
{
@ -365,8 +369,8 @@ public:
OpenRF("\pRetro68App", 0, &refNum);
if(rsrcSize)
{
state = State::rsrc;
remainingSize = rsrcSize;
state = State::rsrc;
remainingSize = rsrcSize;
}
else
state = State::launch;
@ -458,6 +462,9 @@ public:
}
else
{
#ifdef DEBUG_CONSOLE
printf("Failed to Launch.\n");
#endif
connection->resume();
onReset();
}

View File

@ -103,7 +103,7 @@ resource 'WIND' (128, "About") {
resource 'WIND' (129, "Main") {
{50, 10, 200, 400}, noGrowDocProc;
visible;
invisible;
noGoAway;
0, "Retro68 Application Launching Server";
centerMainScreen;

View File

@ -72,6 +72,22 @@ StatusDisplay::StatusDisplay()
tableTop + (i/2+1) * tableLineHeight);
}
#ifdef DEBUG_CONSOLE
short consoleTop = tableTop + (nValues+1)/2 * tableLineHeight + 10;
SetRect(&consoleRect, 10, consoleTop,
bounds.right - 10, consoleTop + 150);
#if TARGET_API_MAC_CARBON
console = retro::Console(GetWindowPort(statusWindow), consoleRect);
#else
console = retro::Console(statusWindow, consoleRect);
#endif
retro::Console::currentInstance = &console;
bounds.bottom = consoleRect.bottom + 10;
#else
bounds.bottom = tableTop + (nValues+1)/2 * tableLineHeight + 10;
#endif
RgnHandle tmp = NewRgn();
background = NewRgn();
RectRgn(background, &bounds);
@ -82,6 +98,11 @@ StatusDisplay::StatusDisplay()
RectRgn(tmp, &valueRects[i]);
DiffRgn(background, tmp, background);
}
#ifdef DEBUG_CONSOLE
RectRgn(tmp, &consoleRect);
DiffRgn(background, tmp, background);
#endif
DisposeRgn(tmp);
if(hasColorQD)
@ -89,6 +110,9 @@ StatusDisplay::StatusDisplay()
progressBg = GetPixPat(128);
progressFg = GetPixPat(129);
}
SizeWindow(statusWindow, bounds.right, bounds.bottom, false);
ShowWindow(statusWindow);
}
StatusDisplay::~StatusDisplay()
@ -199,6 +223,21 @@ void StatusDisplay::Update()
DrawValue(Stat::timeRemaining, timeRemaining);
DrawValue(Stat::transmissionErrors, errorCount);
#ifdef DEBUG_CONSOLE
Rect updateRect;
#if TARGET_API_MAC_CARBON
RgnHandle rgn = NewRgn();
GetPortVisibleRegion(GetWindowPort(statusWindow), rgn);
GetRegionBounds(rgn, &updateRect);
DisposeRgn(rgn);
#else
updateRect = (*qd.thePort->visRgn)->rgnBBox; // Life was simple back then.
#endif
console.Draw(updateRect);
FrameRect(&consoleRect);
#endif
EndUpdate(statusWindow);
}
@ -244,6 +283,11 @@ void StatusDisplay::SetStatus(AppStatus stat)
startTime = TickCount();
GetIndString(statusString,128,(short)stat);
Inval(statusRect);
#ifdef DEBUG_CONSOLE
statusString[statusString[0]+1] = 0;
printf("%s\n", (const char*)statusString+1);
#endif
}
}

View File

@ -3,6 +3,9 @@
#include <TextUtils.h>
#include "Window.h"
#ifdef DEBUG_CONSOLE
#include <retro/Console.h>
#endif
enum class AppStatus
{
@ -39,6 +42,11 @@ class StatusDisplay : public Window
PixPatHandle progressBg, progressFg;
#ifdef DEBUG_CONSOLE
Rect consoleRect;
retro::Console console;
#endif
enum class Stat : short;
void DrawValue(Stat stat, ConstStr255Param str);