mirror of
https://github.com/autc04/Retro68.git
synced 2024-06-15 22:29:38 +00:00
LaunchAPPLServer: support printer port
This commit is contained in:
parent
d47958bcb9
commit
5e1e67de2c
|
@ -48,7 +48,7 @@ enum
|
|||
kMenuApple = 128,
|
||||
kMenuFile,
|
||||
kMenuEdit,
|
||||
kMenuSpeed
|
||||
kMenuConnection
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -60,6 +60,9 @@ enum
|
|||
|
||||
struct Prefs
|
||||
{
|
||||
const static int currentVersion = 1;
|
||||
int version = currentVersion;
|
||||
int port = 0;
|
||||
long baud = 19200;
|
||||
bool inSubLaunch = false;
|
||||
};
|
||||
|
@ -135,8 +138,10 @@ void UpdateMenus()
|
|||
DisableItem(m,6);
|
||||
}
|
||||
|
||||
m = GetMenu(kMenuSpeed);
|
||||
for(int i = 1; i <= CountMenuItems(m); i++)
|
||||
m = GetMenu(kMenuConnection);
|
||||
CheckMenuItem(m, 1, gPrefs.port == 0);
|
||||
CheckMenuItem(m, 2, gPrefs.port == 1);
|
||||
for(int i = 3; i <= CountMenuItems(m); i++)
|
||||
{
|
||||
Str255 str;
|
||||
long baud;
|
||||
|
@ -182,11 +187,18 @@ void DoMenuCommand(long menuCommand)
|
|||
// edit command not handled by desk accessory
|
||||
}
|
||||
}
|
||||
else if(menuID == kMenuSpeed)
|
||||
else if(menuID == kMenuConnection)
|
||||
{
|
||||
GetMenuItemText(GetMenu(menuID), menuItem, str);
|
||||
StringToNum(str, &gPrefs.baud);
|
||||
SetBaud(gPrefs.baud);
|
||||
if(menuItem <= 2)
|
||||
{
|
||||
gPrefs.port = menuItem - 1;
|
||||
}
|
||||
if(menuItem >= 3)
|
||||
{
|
||||
GetMenuItemText(GetMenu(menuID), menuItem, str);
|
||||
StringToNum(str, &gPrefs.baud);
|
||||
SetBaud(gPrefs.baud);
|
||||
}
|
||||
}
|
||||
HiliteMenu(0);
|
||||
}
|
||||
|
@ -433,12 +445,15 @@ int main()
|
|||
if(OpenDF("\pLaunchAPPLServer Preferences", 0, &refNum) == noErr)
|
||||
{
|
||||
long count = sizeof(gPrefs);
|
||||
gPrefs.version = -1;
|
||||
FSRead(refNum, &count, &gPrefs);
|
||||
if(gPrefs.version != Prefs::currentVersion)
|
||||
gPrefs = Prefs();
|
||||
FSClose(refNum);
|
||||
}
|
||||
}
|
||||
|
||||
MacSerialStream stream(gPrefs.baud);
|
||||
MacSerialStream stream(gPrefs.port, gPrefs.baud);
|
||||
gSerialStream = &stream;
|
||||
|
||||
//#define SIMULATE_ERRORS
|
||||
|
@ -474,7 +489,7 @@ int main()
|
|||
else
|
||||
#endif
|
||||
{
|
||||
hadEvent = WaitNextEvent(everyEvent, &e, 10, NULL);
|
||||
hadEvent = WaitNextEvent(everyEvent, &e, 1, NULL);
|
||||
}
|
||||
|
||||
if(hadEvent)
|
||||
|
|
|
@ -59,8 +59,11 @@ resource 'MENU' (130) {
|
|||
resource 'MENU' (131) {
|
||||
131, textMenuProc;
|
||||
allEnabled, enabled;
|
||||
"Speed";
|
||||
"Connection";
|
||||
{
|
||||
"Modem Port", noIcon, noKey, noMark, plain;
|
||||
"Printer Port", noIcon, noKey, noMark, plain;
|
||||
"-", noIcon, noKey, noMark, plain;
|
||||
"9600", noIcon, noKey, noMark, plain;
|
||||
"19200", noIcon, noKey, check, plain;
|
||||
"38400", noIcon, noKey, noMark, plain;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
MacSerialStream::MacSerialStream(int baud)
|
||||
: curBaud(baud)
|
||||
MacSerialStream::MacSerialStream(int port, int baud)
|
||||
: port(port), curBaud(baud)
|
||||
{
|
||||
open();
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ void MacSerialStream::close()
|
|||
void MacSerialStream::open()
|
||||
{
|
||||
OSErr err;
|
||||
err = OpenDriver("\p.AOut", &outRefNum);
|
||||
err = OpenDriver("\p.AIn", &inRefNum);
|
||||
err = OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum);
|
||||
err = OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum);
|
||||
SerSetBuf(inRefNum, inputBuffer, kInputBufferSize);
|
||||
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ class MacSerialStream : public Stream
|
|||
char readBuffer[kReadBufferSize];
|
||||
|
||||
short outRefNum, inRefNum;
|
||||
int curBaud;
|
||||
int port, curBaud;
|
||||
public:
|
||||
virtual void write(const void* p, size_t n) override;
|
||||
|
||||
void idle();
|
||||
|
||||
MacSerialStream(int baud = 19200);
|
||||
MacSerialStream(int port = 0, int baud = 19200);
|
||||
~MacSerialStream();
|
||||
|
||||
void close();
|
||||
|
|
Loading…
Reference in New Issue
Block a user