mirror of
https://github.com/jeremysrand/BuGS.git
synced 2025-04-29 12:37:36 +00:00
Well, it launches, clears the screen, waits for a key and then quits. But it is a start.
This commit is contained in:
parent
dbe7e7ad3f
commit
a9810ecb75
@ -63,6 +63,8 @@
|
||||
9D1716A42491C49300C83148 /* system601.2mg */ = {isa = PBXFileReference; lastKnownFileType = file; path = system601.2mg; sourceTree = "<group>"; };
|
||||
9D1716A62491C49300C83148 /* tail.mk */ = {isa = PBXFileReference; lastKnownFileType = text; path = tail.mk; sourceTree = "<group>"; };
|
||||
9D1716A92491C49300C83148 /* BuGS.xcscheme */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = BuGS.xcscheme; path = ../../BuGS.xcodeproj/xcshareddata/xcschemes/BuGS.xcscheme; sourceTree = "<group>"; };
|
||||
9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = "<group>"; };
|
||||
9D8FFC612491CAF0005C9327 /* game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = game.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -99,6 +101,8 @@
|
||||
children = (
|
||||
9D17168E2491C49300C83148 /* main.c */,
|
||||
9D1716902491C49300C83148 /* main.h */,
|
||||
9D8FFC602491CA28005C9327 /* game.s */,
|
||||
9D8FFC612491CAF0005C9327 /* game.h */,
|
||||
9D1716912491C49300C83148 /* main.rez */,
|
||||
9D1716932491C49300C83148 /* Makefile */,
|
||||
9D1716952491C49300C83148 /* make */,
|
||||
|
16
BuGS/game.h
Normal file
16
BuGS/game.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* game.h
|
||||
* BuGS
|
||||
*
|
||||
* Created by Jeremy Rand on 2020-06-10.
|
||||
* Copyright © 2020 Jeremy Rand. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _GUARD_PROJECTBuGS_FILEgame_
|
||||
#define _GUARD_PROJECTBuGS_FILEgame_
|
||||
|
||||
|
||||
extern void game(void);
|
||||
|
||||
|
||||
#endif /* define _GUARD_PROJECTBuGS_FILEgame_ */
|
68
BuGS/game.s
Normal file
68
BuGS/game.s
Normal file
@ -0,0 +1,68 @@
|
||||
;
|
||||
; game.s
|
||||
; BuGS
|
||||
;
|
||||
; Created by Jeremy Rand on 2020-06-10.
|
||||
;Copyright © 2020 Jeremy Rand. All rights reserved.
|
||||
;
|
||||
|
||||
case on
|
||||
mcopy game.macros
|
||||
keep game
|
||||
|
||||
game start
|
||||
jsl clearScreen
|
||||
jsl waitForKey
|
||||
rtl
|
||||
|
||||
|
||||
clearScreen entry
|
||||
short i,m
|
||||
lda $e0c035 ; Enable shadowing of SHR
|
||||
and #$f7
|
||||
sta $e0c035
|
||||
|
||||
lda #$a1
|
||||
sta $e0c029 ; Enable SHR mode
|
||||
long i,m
|
||||
|
||||
sei
|
||||
phd
|
||||
tsc
|
||||
sta backupStack
|
||||
lda $e1c068 ; Direct Page and Stack in Bank 01/
|
||||
ora #$0030
|
||||
sta $e1c068
|
||||
ldx #$0000
|
||||
|
||||
lda #$9cfe
|
||||
tcs
|
||||
ldy #$7d00
|
||||
nextWord anop
|
||||
phx
|
||||
dey
|
||||
dey
|
||||
bpl nextWord
|
||||
|
||||
lda $e1c068
|
||||
and #$ffcf
|
||||
sta $e1c068
|
||||
lda backupStack
|
||||
tcs
|
||||
pld
|
||||
cli
|
||||
rtl
|
||||
|
||||
|
||||
waitForKey entry
|
||||
short i,m
|
||||
loop anop
|
||||
lda $e0c000
|
||||
bpl loop
|
||||
sta $e0c010
|
||||
long i,m
|
||||
rtl
|
||||
|
||||
backupStack dc i2'0'
|
||||
|
||||
end
|
899
BuGS/main.c
899
BuGS/main.c
@ -11,24 +11,10 @@
|
||||
|
||||
#include <Memory.h>
|
||||
#include <Locator.h>
|
||||
#include <Event.h>
|
||||
#include <Menu.h>
|
||||
#include <QuickDraw.h>
|
||||
#include <Window.h>
|
||||
#include <Control.h>
|
||||
#include <TextEdit.h>
|
||||
#include <Desk.h>
|
||||
#include <Resources.h>
|
||||
#include <MiscTool.h>
|
||||
#include <STDFile.h>
|
||||
#include <GSOS.h>
|
||||
#include <Print.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "game.h"s
|
||||
|
||||
|
||||
/* Defines and macros */
|
||||
@ -36,880 +22,22 @@
|
||||
#define TOOLFAIL(string) \
|
||||
if (toolerror()) SysFailMgr(toolerror(), "\p" string "\n\r Error Code -> $");
|
||||
|
||||
#define MAX_DOCUMENT_NAME 80
|
||||
|
||||
#define PRINT_RECORD_SIZE 140
|
||||
|
||||
|
||||
/* Types */
|
||||
|
||||
typedef struct tDocument
|
||||
{
|
||||
struct tDocument * nextDocument;
|
||||
struct tDocument * prevDocument;
|
||||
GrafPortPtr wPtr;
|
||||
char documentName[MAX_DOCUMENT_NAME + 1];
|
||||
BOOLEAN isOnDisk;
|
||||
ResultBuf255Hndl pathName;
|
||||
PrRecHndl printRecordHandle;
|
||||
} tDocument;
|
||||
|
||||
|
||||
/* Globals */
|
||||
|
||||
BOOLEAN shouldQuit;
|
||||
EventRecord myEvent;
|
||||
unsigned int userid;
|
||||
tDocument * documentList;
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
void doFileSave(void);
|
||||
|
||||
|
||||
/* Implementation */
|
||||
|
||||
const char * resourceString(int resourceId, const char * defaultValue)
|
||||
{
|
||||
Handle handle;
|
||||
const char *result = defaultValue;
|
||||
|
||||
handle = LoadResource(rCString, resourceId);
|
||||
if (toolerror() == 0) {
|
||||
HLock(handle);
|
||||
result = (const char *) (*handle);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void freeResourceString(int resourceId)
|
||||
{
|
||||
ReleaseResource(-3, rCString, resourceId);
|
||||
}
|
||||
|
||||
|
||||
void showErrorAlert(int resourceId, int toolErrorCode)
|
||||
{
|
||||
char buffer[40] = "";
|
||||
const char *substArray[2];
|
||||
const char *toolErrorFormat;
|
||||
|
||||
if (toolErrorCode != 0) {
|
||||
toolErrorFormat = resourceString(TOOL_ERROR_STRING, "\n\nTool error code = $%04x");
|
||||
sprintf(buffer, toolErrorFormat, toolErrorCode);
|
||||
freeResourceString(TOOL_ERROR_STRING);
|
||||
}
|
||||
|
||||
substArray[0] = resourceString(resourceId, "Unknown error has occurred");
|
||||
substArray[1] = buffer;
|
||||
|
||||
AlertWindow(awCString + awResource, (Pointer) substArray, ERROR_ALERT_STRING);
|
||||
freeResourceString(resourceId);
|
||||
}
|
||||
|
||||
|
||||
tDocument * findDocumentFromWindow(GrafPortPtr wPtr)
|
||||
{
|
||||
tDocument * result = documentList;
|
||||
|
||||
while (result != NULL) {
|
||||
if (result->wPtr == wPtr)
|
||||
break;
|
||||
|
||||
result = result->nextDocument;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#pragma databank 1
|
||||
void drawContents(void)
|
||||
{
|
||||
DrawControls(GetPort());
|
||||
}
|
||||
#pragma databank 0
|
||||
|
||||
|
||||
const char * getUntitledName(void)
|
||||
{
|
||||
static int untitledNum = 1;
|
||||
static char buffer[MAX_DOCUMENT_NAME + 1];
|
||||
const char *untitledFormat = resourceString(UNTITLED_STRING, " Untitled %d ");
|
||||
|
||||
sprintf(buffer + 1, untitledFormat, untitledNum);
|
||||
buffer[0] = strlen(buffer + 1);
|
||||
|
||||
freeResourceString(UNTITLED_STRING);
|
||||
untitledNum++;
|
||||
|
||||
// Returns a Pascal string with a length byte prefix
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
const char * documentNameFromGSOSString(ResultBuf255Ptr gsosString)
|
||||
{
|
||||
static char buffer[MAX_DOCUMENT_NAME + 1];
|
||||
int nameLen = gsosString->bufString.length;
|
||||
|
||||
strcpy(buffer + 1, " ");
|
||||
nameLen = gsosString->bufString.length;
|
||||
if (nameLen > MAX_DOCUMENT_NAME - 5)
|
||||
nameLen = MAX_DOCUMENT_NAME - 5;
|
||||
strncat(buffer + 1, gsosString->bufString.text, nameLen);
|
||||
strcat(buffer + 1, " ");
|
||||
buffer[0] = strlen(buffer + 1);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
const char * documentNameFromPath(wStringPtr pathString)
|
||||
{
|
||||
static char buffer[MAX_DOCUMENT_NAME + 1];
|
||||
int nameLen = pathString->length;
|
||||
char * path = pathString->text;
|
||||
int lastSeparator = 0;
|
||||
int offset;
|
||||
|
||||
for (offset = 0; offset < nameLen; offset++) {
|
||||
if ((path[offset] == ':') ||
|
||||
(path[offset] == '/'))
|
||||
lastSeparator = offset + 1;
|
||||
}
|
||||
|
||||
path = &(path[lastSeparator]);
|
||||
nameLen -= lastSeparator;
|
||||
|
||||
strcpy(buffer + 1, " ");
|
||||
if (nameLen > MAX_DOCUMENT_NAME - 5)
|
||||
nameLen = MAX_DOCUMENT_NAME - 5;
|
||||
strncat(buffer + 1, path, nameLen);
|
||||
strcat(buffer + 1, " ");
|
||||
buffer[0] = strlen(buffer + 1);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
tDocument * newDocument(const char * windowName)
|
||||
{
|
||||
// windowName is a Pascal string with a length byte prefix
|
||||
tDocument * documentPtr;
|
||||
|
||||
documentPtr = malloc(sizeof(tDocument));
|
||||
if (documentPtr == NULL) {
|
||||
showErrorAlert(MALLOC_ERROR_STRING, 0);
|
||||
return(NULL);
|
||||
}
|
||||
documentPtr->printRecordHandle = (PrRecHndl) NewHandle(PRINT_RECORD_SIZE, userid, 0, NULL);
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(MALLOC_ERROR_STRING, toolerror());
|
||||
free(documentPtr);
|
||||
return NULL;
|
||||
}
|
||||
PrDefault(documentPtr->printRecordHandle);
|
||||
|
||||
documentPtr->isOnDisk = FALSE;
|
||||
documentPtr->pathName = NULL;
|
||||
|
||||
documentPtr->documentName[0] = windowName[0];
|
||||
strncpy(documentPtr->documentName + 1, windowName + 1, windowName[0]);
|
||||
|
||||
documentPtr->wPtr = NewWindow2(documentPtr->documentName, 0, drawContents, NULL, refIsResource,
|
||||
WINDOW_RESID, rWindParam1);
|
||||
if (documentPtr->wPtr == NULL) {
|
||||
showErrorAlert(NEW_WINDOW_ERROR_STRING, toolerror());
|
||||
DisposeHandle((Handle)documentPtr->printRecordHandle);
|
||||
free(documentPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
documentPtr->nextDocument = documentList;
|
||||
documentPtr->prevDocument = NULL;
|
||||
if (documentList != NULL)
|
||||
documentList->prevDocument = documentPtr;
|
||||
|
||||
documentList = documentPtr;
|
||||
|
||||
return documentPtr;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN isDocumentDirty(tDocument * documentPtr)
|
||||
{
|
||||
BOOLEAN isDirty = FALSE;
|
||||
CtlRecHndl controlHdl;
|
||||
CtlRec * controlPtr;
|
||||
|
||||
controlHdl = GetCtlHandleFromID(documentPtr->wPtr, CONTROL_TEXT_EDIT);
|
||||
if (toolerror() == 0) {
|
||||
HLock((Handle) controlHdl);
|
||||
controlPtr = *controlHdl;
|
||||
isDirty = ((controlPtr->ctlFlag & fRecordDirty) != 0);
|
||||
HUnlock((Handle) controlHdl);
|
||||
}
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
|
||||
void clearDocumentDirty(tDocument * documentPtr)
|
||||
{
|
||||
CtlRecHndl controlHdl;
|
||||
CtlRec * controlPtr;
|
||||
|
||||
controlHdl = GetCtlHandleFromID(documentPtr->wPtr, CONTROL_TEXT_EDIT);
|
||||
if (toolerror() == 0) {
|
||||
HLock((Handle) controlHdl);
|
||||
controlPtr = *controlHdl;
|
||||
controlPtr->ctlFlag &= (~fRecordDirty);
|
||||
HUnlock((Handle) controlHdl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void saveDocument(tDocument * documentPtr)
|
||||
{
|
||||
RefNumRecGS closeRecord;
|
||||
CreateRecGS createRecord;
|
||||
NameRecGS destroyRecord;
|
||||
OpenRecGS openRecord;
|
||||
IORecGS writeRecord;
|
||||
|
||||
GrafPortPtr tmpPort;
|
||||
LongWord dataLength;
|
||||
Handle dataHandle;
|
||||
|
||||
tmpPort = GetPort();
|
||||
SetPort(documentPtr->wPtr);
|
||||
dataLength = TEGetText(teTextIsNewHandle | teDataIsCString, (Ref) &dataHandle, 0,
|
||||
0, (Ref) NULL, NULL);
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(SAVE_FILE_ERROR_STRING, toolerror());
|
||||
SetPort(tmpPort);
|
||||
return;
|
||||
}
|
||||
|
||||
HLock((Handle) documentPtr->pathName);
|
||||
|
||||
destroyRecord.pCount = 1;
|
||||
destroyRecord.pathname = &((*(documentPtr->pathName))->bufString);
|
||||
DestroyGS(&destroyRecord);
|
||||
|
||||
createRecord.pCount = 5;
|
||||
createRecord.pathname = &((*(documentPtr->pathName))->bufString);
|
||||
createRecord.access = destroyEnable | renameEnable | readWriteEnable;
|
||||
createRecord.fileType = 0x04;
|
||||
createRecord.auxType = 0x0000;
|
||||
createRecord.storageType = 1;
|
||||
CreateGS(&createRecord);
|
||||
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(SAVE_FILE_ERROR_STRING, toolerror());
|
||||
} else {
|
||||
openRecord.pCount = 3;
|
||||
openRecord.pathname = &((*(documentPtr->pathName))->bufString);
|
||||
openRecord.requestAccess = writeEnable;
|
||||
OpenGS(&openRecord);
|
||||
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(SAVE_FILE_ERROR_STRING, toolerror());
|
||||
} else {
|
||||
HLock(dataHandle);
|
||||
|
||||
writeRecord.pCount = 4;
|
||||
writeRecord.refNum = openRecord.refNum;
|
||||
writeRecord.dataBuffer = *dataHandle;
|
||||
writeRecord.requestCount = dataLength;
|
||||
WriteGS(&writeRecord);
|
||||
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(SAVE_FILE_ERROR_STRING, toolerror());
|
||||
} else {
|
||||
documentPtr->isOnDisk = TRUE;
|
||||
clearDocumentDirty(documentPtr);
|
||||
}
|
||||
|
||||
HUnlock(dataHandle);
|
||||
|
||||
closeRecord.pCount = 1; /* close the file */
|
||||
closeRecord.refNum = openRecord.refNum;
|
||||
CloseGS(&closeRecord);
|
||||
}
|
||||
}
|
||||
|
||||
DisposeHandle(dataHandle);
|
||||
HUnlock((Handle) documentPtr->pathName);
|
||||
SetPort(tmpPort);
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN loadDocument(tDocument * documentPtr)
|
||||
{
|
||||
BOOLEAN result = TRUE;
|
||||
|
||||
RefNumRecGS closeRecord;
|
||||
OpenRecGS openRecord;
|
||||
IORecGS readRecord;
|
||||
GrafPortPtr tmpPort;
|
||||
Handle dataHandle;
|
||||
|
||||
openRecord.pCount = 12;
|
||||
HLock((Handle) documentPtr->pathName);
|
||||
openRecord.pathname = &((*(documentPtr->pathName))->bufString);
|
||||
openRecord.requestAccess = readEnable;
|
||||
openRecord.resourceNumber = 0;
|
||||
openRecord.optionList = NULL;
|
||||
OpenGS(&openRecord);
|
||||
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(OPEN_FILE_ERROR_STRING, toolerror());
|
||||
result = FALSE;
|
||||
} else {
|
||||
dataHandle = NewHandle(openRecord.eof, userid, attrLocked, NULL);
|
||||
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(MALLOC_ERROR_STRING, toolerror());
|
||||
result = FALSE;
|
||||
} else {
|
||||
readRecord.pCount = 4;
|
||||
readRecord.refNum = openRecord.refNum;
|
||||
readRecord.dataBuffer = *dataHandle;
|
||||
readRecord.requestCount = openRecord.eof;
|
||||
ReadGS(&readRecord);
|
||||
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(OPEN_FILE_ERROR_STRING, toolerror());
|
||||
result = FALSE;
|
||||
} else {
|
||||
tmpPort = GetPort();
|
||||
SetPort(documentPtr->wPtr);
|
||||
TESetText(teTextIsPtr | teDataIsTextBlock, (Ref)*dataHandle, openRecord.eof,
|
||||
teCtlStyleIsPtr, NULL, NULL);
|
||||
SetPort(tmpPort);
|
||||
}
|
||||
DisposeHandle(dataHandle);
|
||||
}
|
||||
|
||||
closeRecord.pCount = 1;
|
||||
closeRecord.refNum = openRecord.refNum;
|
||||
CloseGS(&closeRecord);
|
||||
}
|
||||
|
||||
HUnlock((Handle) documentPtr->pathName);
|
||||
clearDocumentDirty(documentPtr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void closeDocument(GrafPortPtr wPtr)
|
||||
{
|
||||
tDocument * documentPtr;
|
||||
char documentName[MAX_DOCUMENT_NAME];
|
||||
char * alertStrings[] = { documentName };
|
||||
int documentNameLen;
|
||||
char * tmpPtr;
|
||||
int buttonClicked;
|
||||
|
||||
if (wPtr == NULL)
|
||||
return;
|
||||
|
||||
documentPtr = findDocumentFromWindow(wPtr);
|
||||
if (documentPtr != NULL) {
|
||||
while (isDocumentDirty(documentPtr)) {
|
||||
/* The documentName in the documentPtr is actually a PString so the
|
||||
first byte is the length of the string. */
|
||||
tmpPtr = documentPtr->documentName;
|
||||
documentNameLen = *tmpPtr;
|
||||
tmpPtr++;
|
||||
|
||||
/* The documentName has spaces before and after the real name to format
|
||||
the string for the window title bar. Strip those spaces out and store
|
||||
the name into the documentName local array. */
|
||||
while ((documentNameLen > 0) &&
|
||||
(tmpPtr[documentNameLen - 1] == ' ')) {
|
||||
documentNameLen--;
|
||||
}
|
||||
while (*tmpPtr == ' ') {
|
||||
tmpPtr++;
|
||||
documentNameLen--;
|
||||
}
|
||||
strncpy(documentName, tmpPtr, documentNameLen);
|
||||
documentName[documentNameLen] = '\0';
|
||||
|
||||
buttonClicked = AlertWindow(awCString+awResource, (Pointer) alertStrings, SAVE_BEFORE_CLOSING);
|
||||
switch (buttonClicked) {
|
||||
case 0:
|
||||
doFileSave();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
clearDocumentDirty(documentPtr);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseWindow(wPtr);
|
||||
|
||||
if (documentPtr == NULL)
|
||||
return;
|
||||
|
||||
if (documentPtr->pathName != NULL) {
|
||||
DisposeHandle((Handle) documentPtr->pathName);
|
||||
documentPtr->pathName = NULL;
|
||||
}
|
||||
if (documentPtr->printRecordHandle != NULL) {
|
||||
DisposeHandle((Handle)documentPtr->printRecordHandle);
|
||||
documentPtr->printRecordHandle = NULL;
|
||||
}
|
||||
if (documentList == documentPtr) {
|
||||
documentList = documentPtr->nextDocument;
|
||||
} else if (documentPtr->prevDocument != NULL) {
|
||||
documentPtr->prevDocument->nextDocument = documentPtr->nextDocument;
|
||||
}
|
||||
|
||||
if (documentPtr->nextDocument != NULL)
|
||||
documentPtr->nextDocument->prevDocument = documentPtr->prevDocument;
|
||||
|
||||
free(documentPtr);
|
||||
}
|
||||
|
||||
|
||||
void printDocument(tDocument * documentPtr)
|
||||
{
|
||||
GrafPortPtr printerPort;
|
||||
LongWord lineNumber;
|
||||
PrStatusRec printerStatus;
|
||||
Rect pageRect;
|
||||
|
||||
printerPort = PrOpenDoc(documentPtr->printRecordHandle, NULL);
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(PRINT_ERROR_STRING, toolerror());
|
||||
return;
|
||||
}
|
||||
|
||||
HLock((Handle) documentPtr->printRecordHandle);
|
||||
pageRect = (*(documentPtr->printRecordHandle))->prInfo.rPage;
|
||||
HUnlock((Handle) documentPtr->printRecordHandle);
|
||||
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(PRINT_ERROR_STRING, toolerror());
|
||||
} else {
|
||||
lineNumber = 0;
|
||||
while (lineNumber != -1) {
|
||||
PrOpenPage(printerPort, NULL);
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(PRINT_ERROR_STRING, toolerror());
|
||||
break;
|
||||
}
|
||||
else {
|
||||
lineNumber = TEPaintText(printerPort, lineNumber, &pageRect, 0,
|
||||
(Handle) GetCtlHandleFromID(documentPtr->wPtr, CONTROL_TEXT_EDIT));
|
||||
PrClosePage(printerPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
PrCloseDoc(printerPort);
|
||||
|
||||
if (PrError() == 0)
|
||||
PrPicFile(documentPtr->printRecordHandle, NULL, &printerStatus);
|
||||
}
|
||||
|
||||
|
||||
void doAppleAbout(void)
|
||||
{
|
||||
AlertWindow(awCString + awResource, NULL, ABOUT_ALERT_STRING);
|
||||
}
|
||||
|
||||
|
||||
void doFileNew(void)
|
||||
{
|
||||
newDocument(getUntitledName());
|
||||
}
|
||||
|
||||
|
||||
void doFileOpen(void)
|
||||
{
|
||||
tDocument * documentPtr;
|
||||
SFTypeList2 fileTypes;
|
||||
SFReplyRec2 reply;
|
||||
ResultBuf255Hndl nameHandle;
|
||||
|
||||
/* By default, we want to open text files only which is what
|
||||
the following fileTypes request. Customize as necessary. */
|
||||
fileTypes.numEntries = 1;
|
||||
fileTypes.fileTypeEntries[0].flags = 0x0000;
|
||||
fileTypes.fileTypeEntries[0].fileType = 0x04;
|
||||
fileTypes.fileTypeEntries[0].auxType = 0x0000;
|
||||
|
||||
reply.nameRefDesc = refIsNewHandle;
|
||||
reply.pathRefDesc = refIsNewHandle;
|
||||
SFGetFile2(30, 30, refIsResource, OPEN_FILE_STRING, NULL, &fileTypes, &reply);
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(OPEN_FILE_ERROR_STRING, toolerror());
|
||||
return;
|
||||
}
|
||||
|
||||
if (reply.good) {
|
||||
nameHandle = (ResultBuf255Hndl) reply.nameRef;
|
||||
HLock((Handle) nameHandle);
|
||||
documentPtr = newDocument(documentNameFromGSOSString(*nameHandle));
|
||||
DisposeHandle((Handle) nameHandle);
|
||||
|
||||
if (documentPtr == NULL) {
|
||||
DisposeHandle((Handle) reply.pathRef);
|
||||
} else {
|
||||
documentPtr->pathName = (ResultBuf255Hndl) reply.pathRef;
|
||||
documentPtr->isOnDisk = loadDocument(documentPtr);
|
||||
|
||||
if (!documentPtr->isOnDisk)
|
||||
closeDocument(documentPtr->wPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void doFileSaveAs(void)
|
||||
{
|
||||
ResultBuf255Hndl nameHandle;
|
||||
SFReplyRec2 reply;
|
||||
const char * documentName;
|
||||
tDocument * documentPtr = findDocumentFromWindow(FrontWindow());
|
||||
|
||||
if (documentPtr == NULL)
|
||||
return;
|
||||
|
||||
reply.nameRefDesc = refIsNewHandle;
|
||||
reply.pathRefDesc = refIsNewHandle;
|
||||
|
||||
if (documentPtr->pathName == NULL)
|
||||
SFPutFile2(30, 30, refIsResource, SAVE_FILE_STRING, refIsPointer,
|
||||
(Ref) &(documentPtr->pathName), &reply);
|
||||
else
|
||||
SFPutFile2(30, 30, refIsResource, SAVE_FILE_STRING, refIsPointer,
|
||||
(Ref) &((*(documentPtr->pathName))->bufString), &reply);
|
||||
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(SAVE_FILE_ERROR_STRING, toolerror());
|
||||
return;
|
||||
}
|
||||
|
||||
if (reply.good) {
|
||||
nameHandle = (ResultBuf255Hndl) reply.nameRef;
|
||||
HLock((Handle) nameHandle);
|
||||
documentName = documentNameFromGSOSString(*nameHandle);
|
||||
documentPtr->documentName[0] = documentName[0];
|
||||
strncpy(documentPtr->documentName + 1, documentName + 1, documentName[0]);
|
||||
DisposeHandle((Handle) nameHandle);
|
||||
|
||||
SetWTitle(documentPtr->documentName, documentPtr->wPtr);
|
||||
|
||||
documentPtr->pathName = (ResultBuf255Hndl) reply.pathRef;
|
||||
documentPtr->isOnDisk = TRUE;
|
||||
saveDocument(documentPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void doFileSave(void)
|
||||
{
|
||||
tDocument * documentPtr = findDocumentFromWindow(FrontWindow());
|
||||
|
||||
if (documentPtr == NULL)
|
||||
return;
|
||||
|
||||
if (documentPtr->isOnDisk)
|
||||
saveDocument(documentPtr);
|
||||
else
|
||||
doFileSaveAs();
|
||||
}
|
||||
|
||||
|
||||
void doFileClose(void)
|
||||
{
|
||||
closeDocument(FrontWindow());
|
||||
}
|
||||
|
||||
|
||||
void doFilePageSetup(void)
|
||||
{
|
||||
tDocument * documentPtr = findDocumentFromWindow(FrontWindow());
|
||||
|
||||
if (documentPtr == NULL)
|
||||
return;
|
||||
|
||||
PrStlDialog(documentPtr->printRecordHandle);
|
||||
}
|
||||
|
||||
|
||||
void doFilePrint(void)
|
||||
{
|
||||
tDocument * documentPtr = findDocumentFromWindow(FrontWindow());
|
||||
|
||||
if (documentPtr == NULL)
|
||||
return;
|
||||
|
||||
if (PrJobDialog(documentPtr->printRecordHandle))
|
||||
printDocument(documentPtr);
|
||||
}
|
||||
|
||||
|
||||
void doFileQuit(void)
|
||||
{
|
||||
shouldQuit = TRUE;
|
||||
}
|
||||
|
||||
|
||||
void doEditUndo(void)
|
||||
{
|
||||
/* Nothing extra to do here. The text edit control handles this for us. */
|
||||
}
|
||||
|
||||
|
||||
void doEditCut(void)
|
||||
{
|
||||
/* Nothing extra to do here. The text edit control handles this for us. */
|
||||
}
|
||||
|
||||
|
||||
void doEditCopy(void)
|
||||
{
|
||||
/* Nothing extra to do here. The text edit control handles this for us. */
|
||||
}
|
||||
|
||||
|
||||
void doEditPaste(void)
|
||||
{
|
||||
/* Nothing extra to do here. The text edit control handles this for us. */
|
||||
}
|
||||
|
||||
|
||||
void doEditClear(void)
|
||||
{
|
||||
/* Nothing extra to do here. The text edit control handles this for us. */
|
||||
}
|
||||
|
||||
|
||||
void handleMenu(void)
|
||||
{
|
||||
int menuNum;
|
||||
int menuItemNum;
|
||||
|
||||
menuNum = myEvent.wmTaskData >> 16;
|
||||
menuItemNum = myEvent.wmTaskData;
|
||||
|
||||
switch (menuItemNum) {
|
||||
case APPLE_ABOUT:
|
||||
doAppleAbout();
|
||||
break;
|
||||
|
||||
case FILE_NEW:
|
||||
doFileNew();
|
||||
break;
|
||||
|
||||
case FILE_OPEN:
|
||||
doFileOpen();
|
||||
break;
|
||||
|
||||
case FILE_SAVE:
|
||||
doFileSave();
|
||||
break;
|
||||
|
||||
case FILE_SAVE_AS:
|
||||
doFileSaveAs();
|
||||
break;
|
||||
|
||||
case FILE_CLOSE:
|
||||
doFileClose();
|
||||
break;
|
||||
|
||||
case FILE_PAGE_SETUP:
|
||||
doFilePageSetup();
|
||||
break;
|
||||
|
||||
case FILE_PRINT:
|
||||
doFilePrint();
|
||||
break;
|
||||
|
||||
case FILE_QUIT:
|
||||
doFileQuit();
|
||||
break;
|
||||
|
||||
case EDIT_UNDO:
|
||||
doEditUndo();
|
||||
break;
|
||||
|
||||
case EDIT_CUT:
|
||||
doEditCut();
|
||||
break;
|
||||
|
||||
case EDIT_COPY:
|
||||
doEditCopy();
|
||||
break;
|
||||
|
||||
case EDIT_PASTE:
|
||||
doEditPaste();
|
||||
break;
|
||||
|
||||
case EDIT_CLEAR:
|
||||
doEditClear();
|
||||
break;
|
||||
}
|
||||
HiliteMenu(FALSE, menuNum);
|
||||
}
|
||||
|
||||
|
||||
void dimMenus(void)
|
||||
{
|
||||
static BOOLEAN windowWasOpen = TRUE;
|
||||
static BOOLEAN applicationWindowWasInFront = TRUE;
|
||||
BOOLEAN windowIsOpen;
|
||||
BOOLEAN applicationWindowIsInFront;
|
||||
|
||||
GrafPortPtr wPtr = FrontWindow();
|
||||
windowIsOpen = (wPtr != NULL);
|
||||
applicationWindowIsInFront = (findDocumentFromWindow(wPtr) != NULL);
|
||||
|
||||
if ((windowIsOpen == windowWasOpen) &&
|
||||
(applicationWindowIsInFront == applicationWindowWasInFront)) {
|
||||
return;
|
||||
}
|
||||
|
||||
windowWasOpen = windowIsOpen;
|
||||
applicationWindowWasInFront = applicationWindowIsInFront;
|
||||
|
||||
if (windowIsOpen) {
|
||||
EnableMItem(FILE_CLOSE);
|
||||
SetMenuFlag(enableMenu, EDIT_MENU);
|
||||
} else {
|
||||
DisableMItem(FILE_CLOSE);
|
||||
SetMenuFlag(disableMenu, EDIT_MENU);
|
||||
}
|
||||
|
||||
if (applicationWindowIsInFront) {
|
||||
EnableMItem(FILE_SAVE);
|
||||
EnableMItem(FILE_SAVE_AS);
|
||||
EnableMItem(FILE_PAGE_SETUP);
|
||||
EnableMItem(FILE_PRINT);
|
||||
} else {
|
||||
DisableMItem(FILE_SAVE);
|
||||
DisableMItem(FILE_SAVE_AS);
|
||||
DisableMItem(FILE_PAGE_SETUP);
|
||||
DisableMItem(FILE_PRINT);
|
||||
}
|
||||
|
||||
DrawMenuBar();
|
||||
}
|
||||
|
||||
|
||||
void handleMessages(void)
|
||||
{
|
||||
#if MESSAGE_CENTER == 1
|
||||
Handle msgHandle;
|
||||
MessageRecGSPtr msgPtr;
|
||||
wStringPtr pathPtr;
|
||||
tDocument * documentPtr;
|
||||
ResultBuf255Ptr resultBufPtr;
|
||||
|
||||
msgHandle = NewHandle(1, userid, 0, NULL);
|
||||
if (toolerror() != 0) {
|
||||
showErrorAlert(MALLOC_ERROR_STRING, toolerror());
|
||||
return;
|
||||
}
|
||||
|
||||
MessageCenter(getMessage, fileInfoTypeGS, msgHandle);
|
||||
if (toolerror() != 0) {
|
||||
DisposeHandle(msgHandle);
|
||||
return;
|
||||
}
|
||||
|
||||
MessageCenter(deleteMessage, fileInfoTypeGS, msgHandle);
|
||||
HLock(msgHandle);
|
||||
msgPtr = (MessageRecGSPtr)(*msgHandle);
|
||||
|
||||
for (pathPtr = msgPtr->fileNames;
|
||||
pathPtr->length != 0;
|
||||
pathPtr = (wStringPtr)(pathPtr->text + pathPtr->length))
|
||||
{
|
||||
documentPtr = newDocument(documentNameFromPath(pathPtr));
|
||||
if (documentPtr == NULL)
|
||||
continue;
|
||||
|
||||
documentPtr->pathName = (ResultBuf255Hndl)NewHandle(pathPtr->length + 4, userid, 0, NULL);
|
||||
if (toolerror() != 0)
|
||||
{
|
||||
showErrorAlert(MALLOC_ERROR_STRING, toolerror());
|
||||
closeDocument(documentPtr->wPtr);
|
||||
continue;
|
||||
}
|
||||
HLock((Handle) documentPtr->pathName);
|
||||
resultBufPtr = *(documentPtr->pathName);
|
||||
resultBufPtr->bufSize = pathPtr->length + 4;
|
||||
resultBufPtr->bufString.length = pathPtr->length;
|
||||
memcpy(resultBufPtr->bufString.text, pathPtr->text, pathPtr->length);
|
||||
HUnlock((Handle) documentPtr->pathName);
|
||||
|
||||
documentPtr->isOnDisk = loadDocument(documentPtr);
|
||||
|
||||
if (!documentPtr->isOnDisk)
|
||||
{
|
||||
closeDocument(documentPtr->wPtr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msgPtr->printFlag)
|
||||
{
|
||||
doFilePrint();
|
||||
closeDocument(documentPtr->wPtr);
|
||||
}
|
||||
}
|
||||
|
||||
if (msgPtr->printFlag)
|
||||
doFileQuit();
|
||||
|
||||
DisposeHandle(msgHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void initMenus(void)
|
||||
{
|
||||
int height;
|
||||
MenuBarRecHndl menuBarHand;
|
||||
|
||||
menuBarHand = NewMenuBar2(refIsResource, MENU_BAR, NULL);
|
||||
TOOLFAIL("Unable to create menu bar");
|
||||
|
||||
SetSysBar(menuBarHand);
|
||||
TOOLFAIL("Unable to set system menu bar");
|
||||
|
||||
SetMenuBar(NULL);
|
||||
TOOLFAIL("Unable to set menu bar");
|
||||
|
||||
FixAppleMenu(APPLE_MENU);
|
||||
TOOLFAIL("Unable to fix Apple menu");
|
||||
|
||||
height = FixMenuBar();
|
||||
TOOLFAIL("Unable to fix menu bar");
|
||||
|
||||
DrawMenuBar();
|
||||
TOOLFAIL("Unable to draw menu bar");
|
||||
}
|
||||
|
||||
|
||||
void initGlobals(void)
|
||||
{
|
||||
documentList = NULL;
|
||||
shouldQuit = FALSE;
|
||||
myEvent.wmTaskMask = 0x001F7FFF;
|
||||
}
|
||||
|
||||
|
||||
@ -927,28 +55,11 @@ int main(void)
|
||||
toolStartupRef = StartUpTools(userid, refIsResource, TOOL_STARTUP);
|
||||
TOOLFAIL("Unable to start tools");
|
||||
|
||||
initGlobals();
|
||||
initMenus();
|
||||
InitCursor();
|
||||
CompactMem();
|
||||
NewHandle(0x8000, userid, attrLocked | attrFixed | attrAddr | attrBank, (Pointer)0x012000);
|
||||
TOOLFAIL("Unable to allocate SHR screen");
|
||||
|
||||
handleMessages();
|
||||
|
||||
while (!shouldQuit) {
|
||||
HandleDiskInsert(hdiScan | hdiHandle, 0);
|
||||
dimMenus();
|
||||
event = TaskMaster(everyEvent, &myEvent);
|
||||
TOOLFAIL("Unable to handle next event");
|
||||
|
||||
switch (event) {
|
||||
case wInSpecial:
|
||||
case wInMenuBar:
|
||||
handleMenu();
|
||||
break;
|
||||
case wInGoAway:
|
||||
closeDocument((GrafPortPtr)myEvent.wmTaskData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
game();
|
||||
|
||||
ShutDownTools(refIsHandle, toolStartupRef);
|
||||
TOOLFAIL("Unable to shutdown tools");
|
||||
|
59
BuGS/main.h
59
BuGS/main.h
@ -11,65 +11,6 @@
|
||||
#define _GUARD_PROJECTBuGS_FILEmain_
|
||||
|
||||
|
||||
/* Menu bars */
|
||||
#define MENU_BAR 1
|
||||
|
||||
|
||||
/* Menus */
|
||||
#define APPLE_MENU 3
|
||||
#define FILE_MENU 4
|
||||
#define EDIT_MENU 5
|
||||
|
||||
|
||||
/* Menu items */
|
||||
#define EDIT_UNDO 250
|
||||
#define EDIT_CUT 251
|
||||
#define EDIT_COPY 252
|
||||
#define EDIT_PASTE 253
|
||||
#define EDIT_CLEAR 254
|
||||
|
||||
#define FILE_NEW 401
|
||||
#define FILE_OPEN 402
|
||||
#define FILE_SAVE 403
|
||||
#define FILE_SAVE_AS 404
|
||||
#define FILE_CLOSE 255
|
||||
#define FILE_PAGE_SETUP 405
|
||||
#define FILE_PRINT 406
|
||||
#define FILE_QUIT 256
|
||||
|
||||
#define APPLE_ABOUT 301
|
||||
|
||||
|
||||
/* Alert strings */
|
||||
#define ABOUT_ALERT_STRING 1
|
||||
#define ERROR_ALERT_STRING 2
|
||||
#define SAVE_BEFORE_CLOSING 3
|
||||
|
||||
|
||||
/* Error strings */
|
||||
#define TOOL_ERROR_STRING 2001
|
||||
#define NEW_WINDOW_ERROR_STRING 2002
|
||||
#define MALLOC_ERROR_STRING 2003
|
||||
#define OPEN_FILE_ERROR_STRING 2004
|
||||
#define SAVE_FILE_ERROR_STRING 2005
|
||||
#define PRINT_ERROR_STRING 2006
|
||||
|
||||
|
||||
/* Other strings */
|
||||
#define UNTITLED_STRING 3001
|
||||
#define OPEN_FILE_STRING 3002
|
||||
#define SAVE_FILE_STRING 3003
|
||||
#define HELLO_WORLD_STRING 3004
|
||||
|
||||
|
||||
/* Windows */
|
||||
#define WINDOW_RESID 1001
|
||||
|
||||
|
||||
/* Controls */
|
||||
#define CONTROL_TEXT_EDIT 1001
|
||||
|
||||
|
||||
/* Tools */
|
||||
#define TOOL_STARTUP 1
|
||||
|
||||
|
360
BuGS/main.rez
360
BuGS/main.rez
@ -25,349 +25,6 @@ resource rVersion (1) {
|
||||
"Copyright \$A9 2020 Jeremy Rand"
|
||||
};
|
||||
|
||||
#if MESSAGE_CENTER == 1
|
||||
/* Bunde resource */
|
||||
resource rBundle (1, preload, nospecialmemory) {
|
||||
nil, /* rIcon ID for application if you wish a custom icon */
|
||||
1,
|
||||
{
|
||||
{
|
||||
native + LaunchThis,
|
||||
{0}, /* rFinderPath ID for this document */
|
||||
{nil}, /* rIcon ID for large icon for document */
|
||||
{nil}, /* rIcon ID for small icon for document */
|
||||
"", /* String to describe this type of document */
|
||||
},
|
||||
Filetype + AuxType, /* Match field bits */
|
||||
MatchFileType {{$04}}, /* File type to match */
|
||||
MatchAuxType { /* Auxiliary file type to match */
|
||||
{$00000000,$00000000}
|
||||
},
|
||||
empty {},
|
||||
empty {},
|
||||
empty {},
|
||||
empty {},
|
||||
empty {},
|
||||
empty {},
|
||||
empty {},
|
||||
empty {},
|
||||
empty {},
|
||||
empty {}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/* Menu bars */
|
||||
resource rMenuBar (MENU_BAR) {
|
||||
{
|
||||
APPLE_MENU,
|
||||
FILE_MENU,
|
||||
EDIT_MENU
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/* Menus */
|
||||
resource rMenu (APPLE_MENU) {
|
||||
APPLE_MENU,
|
||||
refIsResource * menuTitleRefShift
|
||||
+ refIsResource * itemRefShift
|
||||
+ fAllowCache,
|
||||
APPLE_MENU,
|
||||
{
|
||||
APPLE_ABOUT
|
||||
};
|
||||
};
|
||||
resource rPString (APPLE_MENU, noCrossBank) {"@"};
|
||||
|
||||
resource rMenu (FILE_MENU) {
|
||||
FILE_MENU,
|
||||
refIsResource * menuTitleRefShift
|
||||
+ refIsResource * itemRefShift
|
||||
+ fAllowCache,
|
||||
FILE_MENU,
|
||||
{
|
||||
FILE_NEW,
|
||||
FILE_OPEN,
|
||||
FILE_SAVE,
|
||||
FILE_SAVE_AS,
|
||||
FILE_CLOSE,
|
||||
FILE_PAGE_SETUP,
|
||||
FILE_PRINT,
|
||||
FILE_QUIT
|
||||
};
|
||||
};
|
||||
resource rPString (FILE_MENU, noCrossBank) {" File "};
|
||||
|
||||
resource rMenu (EDIT_MENU) {
|
||||
EDIT_MENU,
|
||||
refIsResource * menuTitleRefShift
|
||||
+ refIsResource * itemRefShift
|
||||
+ fAllowCache,
|
||||
EDIT_MENU,
|
||||
{
|
||||
EDIT_UNDO,
|
||||
EDIT_CUT,
|
||||
EDIT_COPY,
|
||||
EDIT_PASTE,
|
||||
EDIT_CLEAR
|
||||
};
|
||||
};
|
||||
resource rPString (EDIT_MENU, noCrossBank) {" Edit "};
|
||||
|
||||
|
||||
/* Menu items */
|
||||
resource rMenuItem (EDIT_UNDO) {
|
||||
EDIT_UNDO,
|
||||
"Z", "z",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
EDIT_UNDO
|
||||
};
|
||||
resource rPString (EDIT_UNDO, noCrossBank) {"Undo"};
|
||||
|
||||
resource rMenuItem (EDIT_CUT) {
|
||||
EDIT_CUT,
|
||||
"X", "x",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
EDIT_CUT
|
||||
};
|
||||
resource rPString (EDIT_CUT, noCrossBank) {"Cut"};
|
||||
|
||||
resource rMenuItem (EDIT_COPY) {
|
||||
EDIT_COPY,
|
||||
"C", "c",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
EDIT_COPY
|
||||
};
|
||||
resource rPString (EDIT_COPY, noCrossBank) {"Copy"};
|
||||
|
||||
resource rMenuItem (EDIT_PASTE) {
|
||||
EDIT_PASTE,
|
||||
"V", "v",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
EDIT_PASTE
|
||||
};
|
||||
resource rPString (EDIT_PASTE, noCrossBank) {"Paste"};
|
||||
|
||||
resource rMenuItem (EDIT_CLEAR) {
|
||||
EDIT_CLEAR,
|
||||
"", "",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
EDIT_CLEAR
|
||||
};
|
||||
resource rPString (EDIT_CLEAR, noCrossBank) {"Clear"};
|
||||
|
||||
resource rMenuItem (FILE_NEW) {
|
||||
FILE_NEW,
|
||||
"N", "n",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
FILE_NEW
|
||||
};
|
||||
resource rPString (FILE_NEW, noCrossBank) {"New"};
|
||||
|
||||
resource rMenuItem (FILE_OPEN) {
|
||||
FILE_OPEN,
|
||||
"O", "o",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
FILE_OPEN
|
||||
};
|
||||
resource rPString (FILE_OPEN, noCrossBank) {"Open"};
|
||||
|
||||
resource rMenuItem (FILE_SAVE) {
|
||||
FILE_SAVE,
|
||||
"S", "s",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
FILE_SAVE
|
||||
};
|
||||
resource rPString (FILE_SAVE, noCrossBank) {"Save"};
|
||||
|
||||
resource rMenuItem (FILE_SAVE_AS) {
|
||||
FILE_SAVE_AS,
|
||||
"", "",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
FILE_SAVE_AS
|
||||
};
|
||||
resource rPString (FILE_SAVE_AS, noCrossBank) {"Save As..."};
|
||||
|
||||
resource rMenuItem (FILE_CLOSE) {
|
||||
FILE_CLOSE,
|
||||
"W", "w",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
FILE_CLOSE
|
||||
};
|
||||
resource rPString (FILE_CLOSE, noCrossBank) {"Close"};
|
||||
|
||||
resource rMenuItem (FILE_PAGE_SETUP) {
|
||||
FILE_PAGE_SETUP,
|
||||
"", "",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
FILE_PAGE_SETUP
|
||||
};
|
||||
resource rPString (FILE_PAGE_SETUP, noCrossBank) {"Page Setup..."};
|
||||
|
||||
resource rMenuItem (FILE_PRINT) {
|
||||
FILE_PRINT,
|
||||
"P", "p",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
FILE_PRINT
|
||||
};
|
||||
resource rPString (FILE_PRINT, noCrossBank) {"Print..."};
|
||||
|
||||
resource rMenuItem (FILE_QUIT) {
|
||||
FILE_QUIT,
|
||||
"Q", "q",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift,
|
||||
FILE_QUIT
|
||||
};
|
||||
resource rPString (FILE_QUIT, noCrossBank) {"Quit"};
|
||||
|
||||
resource rMenuItem (APPLE_ABOUT) {
|
||||
APPLE_ABOUT,
|
||||
"", "",
|
||||
0,
|
||||
refIsResource * itemTitleRefShift
|
||||
+ fDivider,
|
||||
APPLE_ABOUT
|
||||
};
|
||||
resource rPString (APPLE_ABOUT, noCrossBank) {"About BuGS..."};
|
||||
|
||||
|
||||
/* Error strings */
|
||||
resource rCString (TOOL_ERROR_STRING) {"\n\nTool error code = $%04x"};
|
||||
resource rCString (NEW_WINDOW_ERROR_STRING) {"Error occurred when creating a new window"};
|
||||
resource rCString (MALLOC_ERROR_STRING) {"Out of memory"};
|
||||
resource rCString (OPEN_FILE_ERROR_STRING) {"Error opening file"};
|
||||
resource rCString (SAVE_FILE_ERROR_STRING) {"Error saving file"};
|
||||
resource rCString (PRINT_ERROR_STRING) {"Error printing document"};
|
||||
|
||||
|
||||
/* Other strings */
|
||||
resource rCString (UNTITLED_STRING) {" Untitled %d "};
|
||||
resource rPString (OPEN_FILE_STRING, noCrossBank) {"Choose a file to open..."};
|
||||
resource rPString (SAVE_FILE_STRING, noCrossBank) {"Save file as..."};
|
||||
resource rPString (HELLO_WORLD_STRING, noCrossBank) {"Hello, world!"};
|
||||
|
||||
|
||||
/* Alert strings */
|
||||
resource rAlertString (ABOUT_ALERT_STRING) {
|
||||
"0" /* Custom size */
|
||||
#if DESKTOP_RES_MODE == 320
|
||||
"\$38\$00" /* Upper Y coordinate at 56 */
|
||||
"\$10\$00" /* Left X coordinate at 16 */
|
||||
"\$90\$00" /* Lower Y coorinate at 144 */
|
||||
"\$30\$01" /* Right X coordinate at 304 */
|
||||
#else
|
||||
"\$38\$00" /* Upper Y coordinate at 56 */
|
||||
"\$90\$00" /* Left X coordinate at 144 */
|
||||
"\$90\$00" /* Lower Y coorinate at 144 */
|
||||
"\$F0\$01" /* Right X coordinate at 496 */
|
||||
#endif
|
||||
"3/"
|
||||
"BuGS\n"
|
||||
" by Jeremy Rand\n"
|
||||
"\n"
|
||||
"Copyright \$A9 2020 Jeremy Rand\n"
|
||||
"\n"
|
||||
"Contains libraries from ORCAC,\n"
|
||||
"Copyright \$A9 1991, Byte Works Inc."
|
||||
"/^#0\$00";
|
||||
};
|
||||
|
||||
resource rAlertString (ERROR_ALERT_STRING) {
|
||||
"42/"
|
||||
"*0\n"
|
||||
"*1"
|
||||
"/^#0\$00";
|
||||
};
|
||||
|
||||
resource rAlertString (SAVE_BEFORE_CLOSING) {
|
||||
"34/"
|
||||
"Save changes to *0 before closing?"
|
||||
"/^#2/#3/#1\$00";
|
||||
};
|
||||
|
||||
|
||||
/* Windows */
|
||||
resource rWindParam1 (WINDOW_RESID) {
|
||||
/* wFrameBits */
|
||||
fTitle + fClose + fZoom + fMove + fVis + fAllocated + fHilited,
|
||||
nil, /* wTitle */
|
||||
0, /* wRefCon */
|
||||
{0, 0, 0, 0}, /* ZoomRect */
|
||||
$07FF0001, /* wColor ID */
|
||||
{0, 0}, /* Origin */
|
||||
{0, 0}, /* data size */
|
||||
{0, 0}, /* max height-width */
|
||||
{8, 8}, /* scroll ver hors */
|
||||
{0, 0}, /* page ver horiz */
|
||||
0, /* winfoRefCon */
|
||||
10, /* wInfoHeight */
|
||||
#if DESKTOP_RES_MODE == 320
|
||||
{30, 10, 183, 300}, /* wposition */
|
||||
#else
|
||||
{30, 10, 183, 602}, /* wposition */
|
||||
#endif
|
||||
infront, /* wPlane */
|
||||
CONTROL_TEXT_EDIT, /* wStorage */
|
||||
$0802 /* wInVerb */
|
||||
};
|
||||
|
||||
|
||||
/* Controls */
|
||||
resource rControlTemplate (CONTROL_TEXT_EDIT) {
|
||||
CONTROL_TEXT_EDIT, /* Application defined ID */
|
||||
#if DESKTOP_RES_MODE == 320
|
||||
{0,0,165,300}, /* Bounding rectangle */
|
||||
#else
|
||||
{0,0,165,620}, /* Bounding rectangle */
|
||||
#endif
|
||||
editTextControl {
|
||||
{
|
||||
$0000, /* Flags */
|
||||
/* More flags */
|
||||
FctlCanBeTarget + FctlWantsEvents + FctlProcNotPtr + FctlTellAboutSize + FctlIsMultiPart,
|
||||
0, /* Refcon */
|
||||
/* Text flags */
|
||||
fSingleFormat + fSmartCutPaste + fGrowRuler + fDrawInactiveSelection,
|
||||
{-1,-1,-1,-1}, /* Indent rectangle */
|
||||
$FFFFFFFF, /* Vertical bar */
|
||||
0, /* Vertical amount */
|
||||
nil, /* Horizontal bar */
|
||||
0, /* Horizontal amount */
|
||||
nil, /* Style ref */
|
||||
/* Text descriptor */
|
||||
refIsResource * 8 + dataIsPString,
|
||||
HELLO_WORLD_STRING, /* Text ref */
|
||||
0, /* Text length */
|
||||
nil, /* Maximum chars */
|
||||
nil, /* Maximum lines */
|
||||
nil, /* Maximum chars per line */
|
||||
nil, /* Max height */
|
||||
nil, /* Color ref */
|
||||
4, /* Drawing mode */
|
||||
nil, /* Filter procedure */
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Tools */
|
||||
resource rToolStartup (TOOL_STARTUP) {
|
||||
@ -378,22 +35,5 @@ resource rToolStartup (TOOL_STARTUP) {
|
||||
#endif
|
||||
{
|
||||
3, $0100, /* Misc Tool */
|
||||
4, $0100, /* Quickdraw */
|
||||
5, $0100, /* Desk Manager */
|
||||
6, $0100, /* Event Manager */
|
||||
11, $0100, /* Int Math */
|
||||
14, $0300, /* Window Manager */
|
||||
15, $0300, /* Menu Manager */
|
||||
16, $0300, /* Control Manager */
|
||||
18, $0200, /* QD Aux */
|
||||
19, $0100, /* Print Manager */
|
||||
20, $0100, /* LineEdit Tool */
|
||||
21, $0100, /* Dialog Manager */
|
||||
22, $0100, /* Scrap Manager */
|
||||
23, $0100, /* Standard File */
|
||||
27, $0100, /* Font Manager */
|
||||
28, $0100, /* List Manager */
|
||||
30, $0100, /* Resource Manager */
|
||||
34, $0100 /* TextEdit */
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
# GSport configuration file version 0.31
|
||||
# GSplus configuration file version 0.14
|
||||
|
||||
s5d1 =
|
||||
s5d2 =
|
||||
@ -6,9 +6,8 @@ s5d2 =
|
||||
s6d1 =
|
||||
s6d2 =
|
||||
|
||||
s7d1 = ../BuGS.2mg
|
||||
s7d1 = /Users/jrand/Library/Developer/Xcode/DerivedData/BuGS-bffpexoblaghkzcbtjtzxeulnuto/Build/Products/Debug/BuGS.2mg
|
||||
|
||||
g_joystick_type = 0
|
||||
g_limit_speed = 0
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user