mirror of
https://github.com/autc04/Retro68.git
synced 2025-01-10 10:31:09 +00:00
LaunchAPPLServer: Carbon version (no backend yet)
This commit is contained in:
parent
dbfa7e8645
commit
bf9cba16b8
@ -1,10 +1,7 @@
|
||||
add_subdirectory(Common)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Retro.*)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
||||
else()
|
||||
add_subdirectory(Server)
|
||||
endif()
|
||||
add_subdirectory(Server)
|
||||
else()
|
||||
add_subdirectory(Client)
|
||||
endif()
|
||||
|
@ -1,33 +1,44 @@
|
||||
set(CONNECTION_SOURCES)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
|
||||
else()
|
||||
list(APPEND CONNECTION_SOURCES
|
||||
SerialConnectionProvider.h
|
||||
SerialConnectionProvider.cc
|
||||
MacSerialStream.h
|
||||
MacSerialStream.cc
|
||||
|
||||
MacTCPStream.h
|
||||
MacTCPStream.cc
|
||||
TCPConnectionProvider.h
|
||||
TCPConnectionProvider.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
add_application(LaunchAPPLServer
|
||||
TYPE "APPL"
|
||||
CREATOR "R68L"
|
||||
|
||||
|
||||
LaunchAPPLServer.r
|
||||
LauncherIcon.r
|
||||
LaunchAPPLServer.cc
|
||||
MacSerialStream.h
|
||||
MacSerialStream.cc
|
||||
AppLauncher.h
|
||||
AppLauncher.cc
|
||||
ToolLauncher.cc
|
||||
StatusDisplay.h
|
||||
StatusDisplay.cc
|
||||
ConnectionProvider.h
|
||||
SerialConnectionProvider.h
|
||||
SerialConnectionProvider.cc
|
||||
CarbonFileCompat.h
|
||||
|
||||
MacTCPStream.h
|
||||
MacTCPStream.cc
|
||||
TCPConnectionProvider.h
|
||||
TCPConnectionProvider.cc
|
||||
${CONNECTION_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(LaunchAPPLServer LaunchAPPLCommon)
|
||||
set_target_properties(LaunchAPPLServer PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
)
|
||||
target_compile_options(LaunchAPPLServer PRIVATE -ffunction-sections -fno-exceptions -Os)
|
||||
target_compile_options(LaunchAPPLServer PRIVATE -ffunction-sections -Os) # -fno-exceptions
|
||||
if(CMAKE_SYSTEM_NAME MATCHES Retro68)
|
||||
set_target_properties(LaunchAPPLServer PROPERTIES
|
||||
LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/LaunchAPPLServer.segmap"
|
||||
|
30
LaunchAPPL/Server/CarbonFileCompat.h
Normal file
30
LaunchAPPL/Server/CarbonFileCompat.h
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <Files.h>
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
inline OSErr Create(ConstStr255Param fileName, short vRefNum, OSType creator, OSType fileType)
|
||||
{
|
||||
return HCreate(vRefNum, 0, fileName, creator, fileType);
|
||||
}
|
||||
|
||||
inline OSErr OpenDF(ConstStr255Param fileName, short vRefNum, short *refNum)
|
||||
{
|
||||
return HOpenDF(vRefNum, 0, fileName, fsCurPerm, refNum);
|
||||
}
|
||||
|
||||
inline OSErr OpenRF(ConstStr255Param fileName, short vRefNum, short *refNum)
|
||||
{
|
||||
return HOpenRF(vRefNum, 0, fileName, fsCurPerm, refNum);
|
||||
}
|
||||
|
||||
inline OSErr FSDelete(ConstStr255Param fileName, short vRefNum)
|
||||
{
|
||||
return HDelete(vRefNum, 0, fileName);
|
||||
}
|
||||
|
||||
inline OSErr Rename(ConstStr255Param oldName, short vRefNum, ConstStr255Param newName)
|
||||
{
|
||||
return HRename(vRefNum, 0, oldName, newName);
|
||||
}
|
||||
#endif
|
@ -40,8 +40,13 @@
|
||||
#include <memory>
|
||||
|
||||
#include "ConnectionProvider.h"
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
#include "SerialConnectionProvider.h"
|
||||
#include "TCPConnectionProvider.h"
|
||||
#endif
|
||||
|
||||
#include "CarbonFileCompat.h"
|
||||
|
||||
#include <Stream.h>
|
||||
|
||||
enum
|
||||
@ -65,7 +70,12 @@ enum class Port : int
|
||||
printerPort,
|
||||
macTCP
|
||||
};
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
bool portsAvailable[] = { false, false, false };
|
||||
#else
|
||||
bool portsAvailable[] = { true, true, false };
|
||||
#endif
|
||||
|
||||
struct Prefs
|
||||
{
|
||||
@ -111,12 +121,19 @@ void ConnectionChanged();
|
||||
void ShowAboutBox()
|
||||
{
|
||||
WindowRef w = GetNewWindow(128, NULL, (WindowPtr) -1);
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
MacMoveWindow(w,
|
||||
qd.screenBits.bounds.right/2 - w->portRect.right/2,
|
||||
qd.screenBits.bounds.bottom/2 - w->portRect.bottom/2,
|
||||
false);
|
||||
#if TARGET_API_MAC_CARBON
|
||||
Rect screenBounds = (*GetMainDevice())->gdRect;
|
||||
Rect portBounds;
|
||||
GetWindowPortBounds(w,&portBounds);
|
||||
#else
|
||||
const Rect& screenBounds = qd.screenBits.bounds;
|
||||
const Rect& portBounds = w->portRect;
|
||||
#endif
|
||||
MacMoveWindow(w,
|
||||
screenBounds.right/2 - portBounds.right/2,
|
||||
screenBounds.bottom/2 - portBounds.bottom/2,
|
||||
false);
|
||||
|
||||
ShowWindow(w);
|
||||
#if TARGET_API_MAC_CARBON
|
||||
SetPortWindowPort(w);
|
||||
@ -126,12 +143,8 @@ void ShowAboutBox()
|
||||
|
||||
Handle h = GetResource('TEXT', 128);
|
||||
HLock(h);
|
||||
#if TARGET_API_MAC_CARBON
|
||||
Rect r;
|
||||
GetWindowPortBounds(w,&r);
|
||||
#else
|
||||
Rect r = w->portRect;
|
||||
#endif
|
||||
Rect r = portBounds;
|
||||
|
||||
InsetRect(&r, 10,10);
|
||||
TETextBox(*h, GetHandleSize(h), &r, teJustLeft);
|
||||
|
||||
@ -161,7 +174,7 @@ void SetItemEnabled(MenuHandle m, short item, bool enabled)
|
||||
|
||||
void UpdateMenus()
|
||||
{
|
||||
MenuRef m = GetMenu(kMenuFile);
|
||||
MenuRef m = GetMenuHandle(kMenuFile);
|
||||
WindowRef w = FrontWindow();
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
@ -169,7 +182,7 @@ void UpdateMenus()
|
||||
#define DisableItem DisableMenuItem
|
||||
#endif
|
||||
|
||||
m = GetMenu(kMenuEdit);
|
||||
m = GetMenuHandle(kMenuEdit);
|
||||
|
||||
bool enableEditMenu = (w && GetWindowKind(w) < 0);
|
||||
// Desk accessory in front: Enable edit menu items
|
||||
@ -178,7 +191,7 @@ void UpdateMenus()
|
||||
for(short i : {1,3,4,5,6})
|
||||
SetItemEnabled(m,i,enableEditMenu);
|
||||
|
||||
m = GetMenu(kMenuConnection);
|
||||
m = GetMenuHandle(kMenuConnection);
|
||||
SetItemEnabled(m, 1, portsAvailable[(int)Port::macTCP]);
|
||||
CheckMenuItem(m, 1, gPrefs.port == Port::macTCP);
|
||||
SetItemEnabled(m, 2, portsAvailable[(int)Port::modemPort]);
|
||||
@ -245,7 +258,7 @@ void DoMenuCommand(long menuCommand)
|
||||
gPrefs.port = Port::printerPort;
|
||||
break;
|
||||
default:
|
||||
GetMenuItemText(GetMenu(menuID), menuItem, str);
|
||||
GetMenuItemText(GetMenuHandle(menuID), menuItem, str);
|
||||
StringToNum(str, &gPrefs.baud);
|
||||
}
|
||||
ConnectionChanged();
|
||||
@ -374,7 +387,8 @@ public:
|
||||
void idle()
|
||||
{
|
||||
++nullEventCounter;
|
||||
connection->idle();
|
||||
if(connection)
|
||||
connection->idle();
|
||||
|
||||
if(state == State::launch)
|
||||
{
|
||||
@ -486,6 +500,7 @@ void ConnectionChanged()
|
||||
{
|
||||
switch(gPrefs.port)
|
||||
{
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
case Port::macTCP:
|
||||
connection = std::make_unique<TCPConnectionProvider>(statusDisplay.get());;
|
||||
break;
|
||||
@ -495,10 +510,14 @@ void ConnectionChanged()
|
||||
case Port::printerPort:
|
||||
connection = std::make_unique<SerialConnectionProvider>(0, gPrefs.baud, statusDisplay.get());
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
connection->setListener(&server);
|
||||
server.onReset();
|
||||
if(connection)
|
||||
{
|
||||
connection->setListener(&server);
|
||||
server.onReset();
|
||||
}
|
||||
}
|
||||
|
||||
pascal OSErr aeRun (const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefcon)
|
||||
@ -521,12 +540,13 @@ pascal OSErr aeQuit (const AppleEvent *theAppleEvent, AppleEvent *reply, long ha
|
||||
|
||||
int main()
|
||||
{
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
// default stack size is 8KB on B&W macs
|
||||
// and 24 KB on Color macs.
|
||||
// 8KB is too little as soon as we allocate a buffer on the stack.
|
||||
// To allow that, increae stack size: SetApplLimit(GetApplLimit() - 8192);
|
||||
MaxApplZone();
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
||||
InitGraf(&qd.thePort);
|
||||
InitFonts();
|
||||
InitWindows();
|
||||
@ -566,6 +586,8 @@ int main()
|
||||
const Boolean hasGestalt = true;
|
||||
const Boolean hasAppleEvents = true;
|
||||
#endif
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
if(hasGestalt)
|
||||
{
|
||||
long resp;
|
||||
@ -579,7 +601,7 @@ int main()
|
||||
(resp & ((1 << gestaltHidePortB) | (1<< gestaltPortBDisabled))) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SetMenuBar(GetNewMBar(128));
|
||||
AppendResMenu(GetMenu(128), 'DRVR');
|
||||
@ -643,7 +665,11 @@ int main()
|
||||
DisposeWindow(win);
|
||||
break;
|
||||
case inDrag:
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
DragWindow(win, e.where, &qd.screenBits.bounds);
|
||||
#else
|
||||
DragWindow(win, e.where, nullptr);
|
||||
#endif
|
||||
break;
|
||||
case inMenuBar:
|
||||
UpdateMenus();
|
||||
|
@ -140,7 +140,7 @@ resource 'SIZE' (-1) {
|
||||
notDisplayManagerAware,
|
||||
reserved,
|
||||
reserved,
|
||||
150 * 1024,
|
||||
350 * 1024,
|
||||
136 * 1024
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,12 @@ StatusDisplay::StatusDisplay()
|
||||
{
|
||||
statusWindow = GetNewWindow(129, NULL, (WindowPtr) -1);
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
Rect bounds;
|
||||
GetWindowPortBounds(statusWindow, &bounds);
|
||||
#else
|
||||
Rect bounds = statusWindow->portRect;
|
||||
#endif
|
||||
|
||||
SetRect(&statusRect, 10, 0, bounds.right-10, 30);
|
||||
SetRect(&progressRect, 10, 30, bounds.right-10, 46);
|
||||
@ -30,7 +35,11 @@ StatusDisplay::StatusDisplay()
|
||||
memset(columnWidths, 0, sizeof(columnWidths));
|
||||
columnWidths[1] = columnWidths[4] = 50;
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
SetPortWindowPort(statusWindow);
|
||||
#else
|
||||
SetPort(statusWindow);
|
||||
#endif
|
||||
TextSize(9);
|
||||
TextFace(bold);
|
||||
for(int i = 0; i < 2 * nValues; i++)
|
||||
@ -77,6 +86,16 @@ StatusDisplay::~StatusDisplay()
|
||||
DisposeRgn(background);
|
||||
}
|
||||
|
||||
void StatusDisplay::Inval(const Rect& r)
|
||||
{
|
||||
#if TARGET_API_MAC_CARBON
|
||||
InvalWindowRect(statusWindow, &r);
|
||||
#else
|
||||
SetPort(statusWindow);
|
||||
InvalRect(&r);
|
||||
#endif
|
||||
}
|
||||
|
||||
void StatusDisplay::DrawValue(Stat stat, ConstStr255Param str)
|
||||
{
|
||||
Rect& r = valueRects[(short)stat];
|
||||
@ -120,10 +139,20 @@ void StatusDisplay::Update()
|
||||
SetRect(&r, progressRect.left+1, progressRect.top+1,
|
||||
progressRect.left+1 + (progressRect.right-progressRect.left-2) * progressDone / progressTotal,
|
||||
progressRect.bottom-1);
|
||||
FillRect(&r, &qd.dkGray);
|
||||
|
||||
#if TARGET_API_MAC_CARBON
|
||||
Pattern fg, bg;
|
||||
GetQDGlobalsDarkGray(&fg);
|
||||
GetQDGlobalsLightGray(&bg);
|
||||
#else
|
||||
const Pattern& fg = qd.dkGray;
|
||||
const Pattern& bg = qd.ltGray;
|
||||
#endif
|
||||
|
||||
FillRect(&r, &fg);
|
||||
r.left = r.right;
|
||||
r.right = progressRect.right - 1;
|
||||
FillRect(&r, &qd.ltGray);
|
||||
FillRect(&r, &bg);
|
||||
}
|
||||
else
|
||||
EraseRect(&progressRect);
|
||||
@ -144,7 +173,9 @@ void StatusDisplay::Update()
|
||||
}
|
||||
|
||||
TextFace(normal);
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
DrawValue(Stat::heapSize, (ApplicationZone()->bkLim - (Ptr)ApplicationZone()) / 1024);
|
||||
#endif
|
||||
DrawValue(Stat::freeMem, freeMem);
|
||||
if(progressTotal)
|
||||
{
|
||||
@ -169,8 +200,7 @@ void StatusDisplay::Idle()
|
||||
if(newFreeMem != freeMem)
|
||||
{
|
||||
freeMem = newFreeMem;
|
||||
SetPort(statusWindow);
|
||||
InvalRect(&valueRects[(short)Stat::freeMem]);
|
||||
Inval(valueRects[(short)Stat::freeMem]);
|
||||
}
|
||||
|
||||
long newTimeRemaining = -1;
|
||||
@ -185,8 +215,7 @@ void StatusDisplay::Idle()
|
||||
if(newSpeed != speed)
|
||||
{
|
||||
speed = newSpeed;
|
||||
SetPort(statusWindow);
|
||||
InvalRect(&valueRects[(short)Stat::speed]);
|
||||
Inval(valueRects[(short)Stat::speed]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,8 +223,7 @@ void StatusDisplay::Idle()
|
||||
if(newTimeRemaining != timeRemaining)
|
||||
{
|
||||
timeRemaining = newTimeRemaining;
|
||||
SetPort(statusWindow);
|
||||
InvalRect(&valueRects[(short)Stat::timeRemaining]);
|
||||
Inval(valueRects[(short)Stat::timeRemaining]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,8 +235,7 @@ void StatusDisplay::SetStatus(AppStatus stat)
|
||||
if(status == AppStatus::downloading || status == AppStatus::upgrading)
|
||||
startTime = TickCount();
|
||||
GetIndString(statusString,128,(short)stat);
|
||||
SetPort(statusWindow);
|
||||
InvalRect(&statusRect);
|
||||
Inval(statusRect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,11 +243,10 @@ void StatusDisplay::SetProgress(int done, int total)
|
||||
{
|
||||
if(done != progressDone || total != progressTotal)
|
||||
{
|
||||
SetPort(statusWindow);
|
||||
InvalRect(&progressRect);
|
||||
Inval(progressRect);
|
||||
if(total != progressTotal)
|
||||
InvalRect(&valueRects[(short)Stat::fileSize]);
|
||||
InvalRect(&valueRects[(short)Stat::transferred]);
|
||||
Inval(valueRects[(short)Stat::fileSize]);
|
||||
Inval(valueRects[(short)Stat::transferred]);
|
||||
progressTotal = total;
|
||||
progressDone = done;
|
||||
}
|
||||
@ -237,7 +263,6 @@ void StatusDisplay::SetErrorCount(int newErrorCount)
|
||||
if(newErrorCount != errorCount)
|
||||
{
|
||||
errorCount = newErrorCount;
|
||||
SetPort(statusWindow);
|
||||
InvalRect(&valueRects[(short)Stat::transmissionErrors]);
|
||||
Inval(valueRects[(short)Stat::transmissionErrors]);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class StatusDisplay
|
||||
|
||||
void DrawValue(Stat stat, ConstStr255Param str);
|
||||
void DrawValue(Stat stat, long val);
|
||||
void Inval(const Rect& r);
|
||||
|
||||
public:
|
||||
StatusDisplay();
|
||||
|
Loading…
x
Reference in New Issue
Block a user