mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-24 23:32:06 +00:00
LaunchAPPLServer: optional embedded debug console
This commit is contained in:
parent
71660defd6
commit
360c364bf9
@ -25,10 +25,17 @@ else()
|
|||||||
)
|
)
|
||||||
endif()
|
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
|
add_application(LaunchAPPLServer
|
||||||
TYPE "APPL"
|
TYPE "APPL"
|
||||||
CREATOR "R68L"
|
CREATOR "R68L"
|
||||||
|
${MAYBE_CONSOLE}
|
||||||
|
|
||||||
LaunchAPPLServer.r
|
LaunchAPPLServer.r
|
||||||
LauncherIcon.r
|
LauncherIcon.r
|
||||||
@ -46,6 +53,9 @@ add_application(LaunchAPPLServer
|
|||||||
|
|
||||||
${CONNECTION_SOURCES}
|
${CONNECTION_SOURCES}
|
||||||
)
|
)
|
||||||
|
if(LAUNCHAPPLSERVER_DEBUG_CONSOLE)
|
||||||
|
target_compile_definitions(LaunchAPPLServer PRIVATE DEBUG_CONSOLE)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(LaunchAPPLServer LaunchAPPLCommon)
|
target_link_libraries(LaunchAPPLServer LaunchAPPLCommon)
|
||||||
set_target_properties(LaunchAPPLServer PROPERTIES
|
set_target_properties(LaunchAPPLServer PROPERTIES
|
||||||
|
@ -300,6 +300,9 @@ public:
|
|||||||
|
|
||||||
size_t onReceive(const uint8_t* p, size_t n)
|
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)
|
switch(state)
|
||||||
{
|
{
|
||||||
case State::command:
|
case State::command:
|
||||||
@ -309,6 +312,7 @@ public:
|
|||||||
command = (RemoteCommand)p[0];
|
command = (RemoteCommand)p[0];
|
||||||
if(command == RemoteCommand::launchApp || command == RemoteCommand::upgradeLauncher)
|
if(command == RemoteCommand::launchApp || command == RemoteCommand::upgradeLauncher)
|
||||||
state = State::header;
|
state = State::header;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,8 +337,8 @@ public:
|
|||||||
|
|
||||||
if(dataSize)
|
if(dataSize)
|
||||||
{
|
{
|
||||||
state = State::data;
|
state = State::data;
|
||||||
remainingSize = dataSize;
|
remainingSize = dataSize;
|
||||||
}
|
}
|
||||||
else if(rsrcSize)
|
else if(rsrcSize)
|
||||||
{
|
{
|
||||||
@ -365,8 +369,8 @@ public:
|
|||||||
OpenRF("\pRetro68App", 0, &refNum);
|
OpenRF("\pRetro68App", 0, &refNum);
|
||||||
if(rsrcSize)
|
if(rsrcSize)
|
||||||
{
|
{
|
||||||
state = State::rsrc;
|
state = State::rsrc;
|
||||||
remainingSize = rsrcSize;
|
remainingSize = rsrcSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
state = State::launch;
|
state = State::launch;
|
||||||
@ -458,6 +462,9 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_CONSOLE
|
||||||
|
printf("Failed to Launch.\n");
|
||||||
|
#endif
|
||||||
connection->resume();
|
connection->resume();
|
||||||
onReset();
|
onReset();
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ resource 'WIND' (128, "About") {
|
|||||||
|
|
||||||
resource 'WIND' (129, "Main") {
|
resource 'WIND' (129, "Main") {
|
||||||
{50, 10, 200, 400}, noGrowDocProc;
|
{50, 10, 200, 400}, noGrowDocProc;
|
||||||
visible;
|
invisible;
|
||||||
noGoAway;
|
noGoAway;
|
||||||
0, "Retro68 Application Launching Server";
|
0, "Retro68 Application Launching Server";
|
||||||
centerMainScreen;
|
centerMainScreen;
|
||||||
|
@ -72,6 +72,22 @@ StatusDisplay::StatusDisplay()
|
|||||||
tableTop + (i/2+1) * tableLineHeight);
|
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();
|
RgnHandle tmp = NewRgn();
|
||||||
background = NewRgn();
|
background = NewRgn();
|
||||||
RectRgn(background, &bounds);
|
RectRgn(background, &bounds);
|
||||||
@ -82,6 +98,11 @@ StatusDisplay::StatusDisplay()
|
|||||||
RectRgn(tmp, &valueRects[i]);
|
RectRgn(tmp, &valueRects[i]);
|
||||||
DiffRgn(background, tmp, background);
|
DiffRgn(background, tmp, background);
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_CONSOLE
|
||||||
|
RectRgn(tmp, &consoleRect);
|
||||||
|
DiffRgn(background, tmp, background);
|
||||||
|
#endif
|
||||||
|
|
||||||
DisposeRgn(tmp);
|
DisposeRgn(tmp);
|
||||||
|
|
||||||
if(hasColorQD)
|
if(hasColorQD)
|
||||||
@ -89,6 +110,9 @@ StatusDisplay::StatusDisplay()
|
|||||||
progressBg = GetPixPat(128);
|
progressBg = GetPixPat(128);
|
||||||
progressFg = GetPixPat(129);
|
progressFg = GetPixPat(129);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SizeWindow(statusWindow, bounds.right, bounds.bottom, false);
|
||||||
|
ShowWindow(statusWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusDisplay::~StatusDisplay()
|
StatusDisplay::~StatusDisplay()
|
||||||
@ -199,6 +223,21 @@ void StatusDisplay::Update()
|
|||||||
DrawValue(Stat::timeRemaining, timeRemaining);
|
DrawValue(Stat::timeRemaining, timeRemaining);
|
||||||
DrawValue(Stat::transmissionErrors, errorCount);
|
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);
|
EndUpdate(statusWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,6 +283,11 @@ void StatusDisplay::SetStatus(AppStatus stat)
|
|||||||
startTime = TickCount();
|
startTime = TickCount();
|
||||||
GetIndString(statusString,128,(short)stat);
|
GetIndString(statusString,128,(short)stat);
|
||||||
Inval(statusRect);
|
Inval(statusRect);
|
||||||
|
|
||||||
|
#ifdef DEBUG_CONSOLE
|
||||||
|
statusString[statusString[0]+1] = 0;
|
||||||
|
printf("%s\n", (const char*)statusString+1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
#include <TextUtils.h>
|
#include <TextUtils.h>
|
||||||
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
#ifdef DEBUG_CONSOLE
|
||||||
|
#include <retro/Console.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum class AppStatus
|
enum class AppStatus
|
||||||
{
|
{
|
||||||
@ -39,6 +42,11 @@ class StatusDisplay : public Window
|
|||||||
|
|
||||||
PixPatHandle progressBg, progressFg;
|
PixPatHandle progressBg, progressFg;
|
||||||
|
|
||||||
|
#ifdef DEBUG_CONSOLE
|
||||||
|
Rect consoleRect;
|
||||||
|
retro::Console console;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum class Stat : short;
|
enum class Stat : short;
|
||||||
|
|
||||||
void DrawValue(Stat stat, ConstStr255Param str);
|
void DrawValue(Stat stat, ConstStr255Param str);
|
||||||
|
Loading…
Reference in New Issue
Block a user