diff --git a/SerialHelper.c b/SerialHelper.c index 5bf61b3..1505492 100644 --- a/SerialHelper.c +++ b/SerialHelper.c @@ -22,14 +22,14 @@ OSErr writeSerialPortDebug(short refNum, const char* str) // OSErr err; // return err; - const char* nameStr = ""; + const unsigned char* nameStr = "\p"; switch (refNum) { case aoutRefNum: - nameStr = MODEM_PORT_OUT; + nameStr = (const unsigned char*)MODEM_PORT_OUT; break; case boutRefNum: - nameStr = PRINTER_PORT_OUT; + nameStr = (const unsigned char*)PRINTER_PORT_OUT; break; default: diff --git a/coprocessorjs.c b/coprocessorjs.c index f3c4593..4ea6eed 100644 --- a/coprocessorjs.c +++ b/coprocessorjs.c @@ -98,17 +98,17 @@ void setupSerialPort(const char *name) { #define PRINTER_PORT_OUT "\p.BOut" #define PRINTER_PORT_IN "\p.BIn" - const char* serialPortOutputName = ""; - const char* serialPortInputName = ""; + const unsigned char* serialPortOutputName = "\p"; + const unsigned char* serialPortInputName = "\p"; if (strcmp (name, "modem") == 0) { - serialPortOutputName = MODEM_PORT_OUT; - serialPortInputName = MODEM_PORT_IN; + serialPortOutputName = (const unsigned char *)MODEM_PORT_OUT; + serialPortInputName = (const unsigned char *)MODEM_PORT_IN; } else if (strcmp (name, "printer") == 0) { - serialPortOutputName = PRINTER_PORT_OUT; - serialPortInputName = MODEM_PORT_IN; + serialPortOutputName = (const unsigned char *)PRINTER_PORT_OUT; + serialPortInputName = (const unsigned char *)MODEM_PORT_IN; } else { return; @@ -220,7 +220,7 @@ void readSerialPort(char* output) { char *errorMessage = "TIMEOUT_ERROR"; - strncat(output, errorMessage, strlen(errorMessage)); + strncat(output, errorMessage, strlen(output) - 1); // once we are done reading the buffer entirely, we need to clear it. i'm not sure if this is the best way or not but seems to work memset(&GlobalSerialInputBuffer[0], 0, MAX_RECEIVE_SIZE); @@ -241,7 +241,7 @@ void readSerialPort(char* output) { if (DEBUGGING) { char debugMessage[100]; - sprintf(debugMessage, "receive loop: byteCount: %d, lastByteCount: %d\n", byteCount, lastByteCount); + sprintf(debugMessage, "receive loop: byteCount: %ld, lastByteCount: %ld\n", byteCount, lastByteCount); printf(debugMessage); } @@ -264,7 +264,7 @@ void readSerialPort(char* output) { if (DEBUGGING) { char debugMessage[100]; - sprintf(debugMessage, "receive loop setting last doByteCountsMatch to true: byteCount: %d, lastByteCount: %d\n", byteCount, lastByteCount); + sprintf(debugMessage, "receive loop setting last doByteCountsMatch to true: byteCount: %ld, lastByteCount: %ld\n", byteCount, lastByteCount); printf(debugMessage); } @@ -275,7 +275,7 @@ void readSerialPort(char* output) { if (DEBUGGING) { char debugMessage[100]; - sprintf(debugMessage, "receive loop complete: byteCount: %d, lastByteCount: %d\n", byteCount, lastByteCount); + sprintf(debugMessage, "receive loop complete: byteCount: %ld, lastByteCount: %ld\n", byteCount, lastByteCount); printf(debugMessage); } @@ -304,7 +304,7 @@ void readSerialPort(char* output) { char *debugOutput; char tempString[MAX_RECEIVE_SIZE]; strncat(tempString, tempOutput, totalByteCount); - sprintf(debugOutput, "\n'%d'\n", strlen(tempString)); + sprintf(debugOutput, "\n'%ld'\n", strlen(tempString)); printf(debugOutput); printf("\ndone with output\n"); printf("\n"); @@ -453,12 +453,19 @@ char* _getReturnValueFromResponse(char* response, char* application_id, char* ca printf("setting output to token:\n"); printf(token); char *debugOutput; - sprintf(debugOutput, "\n'%d'\n", strlen(token)); + sprintf(debugOutput, "\n'%ld'\n", strlen(token)); printf(debugOutput); printf("\ndone with output\n"); } - strncat(output, token, strlen(token) - 6); // the -6 here is to drop the ;;@@&& off the end of the response + int lengthWithoutControlChars = strlen(token) - 6; + + if (strlen(output) - 1 < lengthWithoutControlChars) { + + lengthWithoutControlChars = strlen(output) - 1; + } + + strncat(output, token, lengthWithoutControlChars); // drop the ;;@@&& off the end of the response return NULL; @@ -508,7 +515,7 @@ void writeToCoprocessor(char* operation, char* operand) { // must be called after writeToCoprocessor and before other writeToCoprocessor // operations because we depend on the location of call_counter -char* getReturnValueFromResponse(char *response, char *operation, char *output) { +void getReturnValueFromResponse(char *response, char *operation, char *output) { if (DEBUGGING) { diff --git a/dist/MessagesForMacintosh.dsk b/dist/MessagesForMacintosh.dsk index 4650436..c7f6f82 100644 Binary files a/dist/MessagesForMacintosh.dsk and b/dist/MessagesForMacintosh.dsk differ diff --git a/dist/MessagesForMacintosh.zip b/dist/MessagesForMacintosh.zip index 22975d5..59e7111 100644 Binary files a/dist/MessagesForMacintosh.zip and b/dist/MessagesForMacintosh.zip differ diff --git a/mac_main.c b/mac_main.c index d52880f..f6437f7 100644 --- a/mac_main.c +++ b/mac_main.c @@ -181,6 +181,7 @@ void EventLoop(struct nk_context *ctx) int lastMouseVPos = 0; int lastUpdatedTickCountMessagesInChat = 0; int lastUpdatedTickCountChatCounts = 0; + Boolean gotNewMessages = false; do { @@ -196,11 +197,15 @@ void EventLoop(struct nk_context *ctx) ShowCursor(); } + gotNewMessages = false; + // check for new stuff every 10 sec? // note! this is used by some of the functionality in our nuklear_app to trigger // new chat lookups if (TickCount() - lastUpdatedTickCountMessagesInChat > 600) { + gotNewMessages = true; + // writeSerialPortDebug(boutRefNum, "update by tick count"); lastUpdatedTickCountMessagesInChat = TickCount(); @@ -213,7 +218,7 @@ void EventLoop(struct nk_context *ctx) // this should be out of sync with the counter above it so that we dont end up making // two coprocessor calls on one event loop iteration - if (TickCount() - lastUpdatedTickCountChatCounts > 300) { + if (!gotNewMessages && TickCount() - lastUpdatedTickCountChatCounts > 300) { // writeSerialPortDebug(boutRefNum, "update by tick count"); lastUpdatedTickCountChatCounts = TickCount(); @@ -632,7 +637,7 @@ void DoMenuCommand(menuResult) { short menuID; /* the resource ID of the selected menu */ short menuItem; /* the item number of the selected menu */ - short itemHit; + // short itemHit; // Str255 daName; // short daRefNum; // Boolean handledByDA; @@ -644,7 +649,7 @@ void DoMenuCommand(menuResult) switch ( menuItem ) { // case iAbout: /* bring up alert for About */ default: - itemHit = Alert(rAboutAlert, nil); + // itemHit = Alert(rAboutAlert, nil); break; /* @@ -689,7 +694,7 @@ void DoMenuCommand(menuResult) case mHelp: switch ( menuItem ) { case iQuickHelp: - itemHit = Alert(rAboutAlert, nil); + // itemHit = Alert(rAboutAlert, nil); break; case iUserGuide: { @@ -875,9 +880,9 @@ Boolean TrapAvailable(tNumber,tType) } /*TrapAvailable*/ void AlertUser() { - short itemHit; + // short itemHit; SetCursor(&qd.arrow); - itemHit = Alert(rUserAlert, nil); + // itemHit = Alert(rUserAlert, nil); ExitToShell(); } /* AlertUser */ \ No newline at end of file diff --git a/nuklear_quickdraw.h b/nuklear_quickdraw.h index 3fe6cd7..0ed88b7 100644 --- a/nuklear_quickdraw.h +++ b/nuklear_quickdraw.h @@ -402,7 +402,7 @@ static short nk_quickdraw_font_get_text_width(nk_handle handle, short height, co for (short i = 0; i < len; i++) { - width += widthFor12ptFont[text[i]]; + width += widthFor12ptFont[(int)text[i]]; } return width;