Get a very basic NDA up and working

This commit is contained in:
Jeremy Rand 2013-07-25 23:55:28 -05:00
parent 5d6a71da3f
commit 33e5d7970d
5 changed files with 203 additions and 61 deletions

View File

@ -16,12 +16,12 @@ OPS_OBJS=ops/abCOp.o ops/abCOpAdd.o ops/abCOpSubtr.o ops/abCOpMult.o \
SHELL_OBJS=abCMain.o $(CALC_OBJS) $(EXPR_OBJS) $(OPS_OBJS) SHELL_OBJS=abCMain.o $(CALC_OBJS) $(EXPR_OBJS) $(OPS_OBJS)
NDA_OBJS=abCNDA.o $(CALC_OBJS) $(EXPR_OBJS) $(OPS_OBJS) NDA_OBJS=abCalcNDA.o $(CALC_OBJS) $(EXPR_OBJS) $(OPS_OBJS)
NDA_RES=abCNDA.r NDA_RES=abCalcNDA.r
abCMain.o: abCalc.h abCStack.h expr/abCExpr.h ops/abCOp.h abCError.h abCMain.o: abCalc.h abCStack.h expr/abCExpr.h ops/abCOp.h abCError.h
abCNDA.o: abCNDA.defs abCalcNDA.o: abCalcNDA.defs abCalc.h
abCNDA.r: abCNDA.defs abCalcNDA.r: abCalcNDA.defs
abCalc.o: abCalc.h expr/abCExpr.h abCMode.h expr/abCExpReal.h expr/abCExprInt.h \ abCalc.o: abCalc.h expr/abCExpr.h abCMode.h expr/abCExpReal.h expr/abCExprInt.h \
abCStack.h ops/abCOp.h abCError.h abCStack.h ops/abCOp.h abCError.h

View File

@ -12,14 +12,20 @@ all: $(SHELL_NAME) $(NDA_NAME)
CFLAGS=-D ABCALC_GSOS CFLAGS=-D ABCALC_GSOS
$(SHELL_NAME): fixtype $(SHELL_OBJS) $(SHELL_NAME): $(SHELL_OBJS)
occ -o $(SHELL_NAME) $(SHELL_OBJS) occ -o $(SHELL_NAME) $(SHELL_OBJS)
$(NDA_NAME): fixtype $(NDA_OBJS) $(NDA_NAME).r $(NDA_NAME): $(NDA_OBJS) $(NDA_NAME).r
cp $(NDA_NAME).r $(NDA_NAME) cp -f $(NDA_NAME).r $(NDA_NAME)
occ -o $(NDA_NAME) $(NDA_OBJS) occ -o $(NDA_NAME) $(NDA_OBJS)
chtyp -t nda $(NDA_NAME) chtyp -t nda $(NDA_NAME)
abCalcMain.o: abCalcMain.c
occ $(CFLAGS) -c -o $@ $<
$(NDA_NAME).o: $(NDA_NAME).c
occ $(CFLAGS) -c -o $@ $<
clean: clean:
cp -p rm -f $(SHELL_NAME) $(SHELL_OBJS) $(SHELL_NAME).root cp -p rm -f $(SHELL_NAME) $(SHELL_OBJS) $(SHELL_NAME).root
cp -p rm -f $(NDA_NAME) $(NDA_OBJS) $(NDA_NAME).r $(NDA_NAME).root cp -p rm -f $(NDA_NAME) $(NDA_OBJS) $(NDA_NAME).r $(NDA_NAME).root
@ -27,13 +33,18 @@ clean:
cp -p rm -f expr/*.root cp -p rm -f expr/*.root
cp -p rm -f ops/*.root cp -p rm -f ops/*.root
fixtype: fixfiles:
chtyp -l CC *.c *.h tr '\\012' '\\015' < abCalcNDA.defs > /tmp/blah
cp -f /tmp/blah abCalcNDA.defs
tr '\\012' '\\015' < abCalcNDA.rez > /tmp/blah
cp -f /tmp/blah abCalcNDA.rez
chtyp -l CC *.c *.h *.defs
chtyp -l REZ *.rez
chtyp -l CC expr/*.c expr/*.h chtyp -l CC expr/*.c expr/*.h
chtyp -l CC ops/*.c ops/*.h chtyp -l CC ops/*.c ops/*.h
%.o: %.c %.o: %.c
occ $(CFLAGS) -c $< occ $(CFLAGS) -c -o $@ $<
%.r: %.rez %.r: %.rez
compile $< keep=$@ occ -o $@ $<

View File

@ -4,70 +4,147 @@
*/ */
#pragma nda NDAOpen NDAClose NDAAction NDAInit 60 0x03FF " abCalc\\H**" #pragma nda NDAOpen NDAClose NDAAction NDAInit 0 0xFFFF " abCalc\\H**"
#include <types.h> #include <orca.h>
#include <GSOS.h>
#include <QuickDraw.h>
#include <Window.h>
#include <Desk.h>
#include <Resources.h>
#include <Memory.h>
#include <Loader.h>
#include <Control.h>
#include <Event.h>
#include "abCalcNDA.defs"
#include "abCalc.h"
static BOOLEAN gCalcActive; static BOOLEAN gCalcActive = FALSE;
static GrafPortPtr gCalcWinPtr; static GrafPortPtr gCalcWinPtr = NULL;
static unsigned int gUserId;
static unsigned int gResourceId;
void NDAClose(void) void NDAClose(void)
{ {
if (gCalcActive) { if (gCalcActive) {
CloseWindow(gCalcWinPtr); CloseWindow(gCalcWinPtr);
gCalcWinPtr = NULL;
gCalcActive = FALSE; gCalcActive = FALSE;
} }
CloseResourceFile(gResourceId);
ResourceShutDown();
} }
void NDAInit(int code) void NDAInit(int code)
{ {
if (code == 1) if (code) {
gCalcActive = FALSE; gCalcActive = FALSE;
else if (gCalcActive) gUserId = MMStartUp();
} else if (gCalcActive) {
NDAClose(); NDAClose();
}
} }
#pragma databank 1
void DrawContents(void)
{
PenNormal();
DrawControls(GetPort());
}
#pragma databank 0
GrafPortPtr NDAOpen(void) GrafPortPtr NDAOpen(void)
{ {
GrafPortPtr wPtr; Pointer pathToSelf;
unsigned int oldResourceApp;
LevelRecGS levelDCB;
unsigned int oldLevel;
SysPrefsRecGS prefsDCB;
unsigned int oldPrefs;
wPtr = NULL; if (gCalcActive)
if (!clockActive) { return NULL;
if (OpenResourceFork()) {
gCalcWinPtr = NewWindow2("\p abCalc ", 0, NULL, NULL, 0x02, wrNum, rWindParam1); oldResourceApp = GetCurResourceApp();
if (toolerror() == 0) { ResourceStartUp(gUserId);
SetSysWindow(gCalcWinPtr); pathToSelf = LGetPathname2(gUserId, 1);
clockActive = TRUE;
wPtr = clockWinPtr; levelDCB.pCount = 2;
} GetLevelGS(&levelDCB);
CloseResourceFork(); oldLevel = levelDCB.level;
} levelDCB.level = 0;
} SetLevelGS(&levelDCB);
return wPtr;
prefsDCB.pCount = 1;
GetSysPrefsGS(&prefsDCB);
oldPrefs = prefsDCB.preferences;
prefsDCB.preferences = (prefsDCB.preferences & 0x1fff) | 0x8000;
SetSysPrefsGS(&prefsDCB);
gResourceId = OpenResourceFile(readEnable, NULL, pathToSelf);
gCalcWinPtr = NewWindow2("\p abCalc ", 0, DrawContents, NULL, refIsResource,
abCalcWinNum, rWindParam1);
SetSysWindow(gCalcWinPtr);
ShowWindow(gCalcWinPtr);
SelectWindow(gCalcWinPtr);
gCalcActive = TRUE;
prefsDCB.preferences = oldPrefs;
SetSysPrefsGS(&prefsDCB);
levelDCB.level = oldLevel;
SetLevelGS(&levelDCB);
SetCurResourceApp(oldResourceApp);
return gCalcWinPtr;
} }
BOOLEAN NDAAction(int code, EventRecord *sysEvent) BOOLEAN NDAAction(EventRecord *sysEvent, int code)
{ {
int event; int event;
static EventRecord localEvent; static EventRecord localEvent;
unsigned int eventCode;
switch (code) { if (code == runAction)
case eventAction: return FALSE;
localEvent.what = sysEvent->what;
localEvent.message = sysEvent->message; if (code == eventAction) {
localEvent.when = sysEvent->when; BlockMove((Pointer)sysEvent, (Pointer)&localEvent, 16);
localEvent.where = sysEvent->where; localEvent.wmTaskMask = 0x001FFFFF;
localEvent.modifiers = sysEvent->modifiers; eventCode = TaskMasterDA(0, &localEvent);
event = TaskMasterDA(0, &localEvent); switch(eventCode) {
break; case updateEvt:
case runAction: BeginUpdate(gCalcWinPtr);
break; DrawContents();
EndUpdate(gCalcWinPtr);
break;
case wInControl:
break;
}
} }
return FALSE; return FALSE;
} }
/* I shouldn't need a main() but the linker seems to want one when I
link multiple objects together in the final link step. If I only
have a single object, there is no problem. There is probable a
compile incantation which will avoid this but for now... */
int main(void)
{
return 0;
}

View File

@ -1,7 +1,40 @@
/* /* */
abCalcNDA.defs /* abCalcNDA.defs */
By: Jeremy Rand /* By: Jeremy Rand */
*/ /* */
#define ABCALC_WINDOW_NUM 1001 #define abCalcWinNum 1001
#define ABCALC_LINED_COLORS 1002 #define abCalcLinedColors 1002
#define abCalcControlList 1003
#define abCalcBtn0 2001
#define abCalcBtn0Str 2002
#define abCalcBtn1 2003
#define abCalcBtn1Str 2004
#define abCalcBtn2 2005
#define abCalcBtn2Str 2006
#define abCalcBtn3 2007
#define abCalcBtn3Str 2008
#define abCalcBtn4 2009
#define abCalcBtn4Str 2010
#define abCalcBtn5 2011
#define abCalcBtn5Str 2012
#define abCalcBtn6 2013
#define abCalcBtn6Str 2014
#define abCalcBtn7 2015
#define abCalcBtn7Str 2016
#define abCalcBtn8 2017
#define abCalcBtn8Str 2018
#define abCalcBtn9 2019
#define abCalcBtn9Str 2020

View File

@ -1,19 +1,19 @@
/* /* */
abCalcNDA.h /* abCalcNDA.h */
By: Jeremy Rand /* By: Jeremy Rand */
*/ /* */
#include "types.rez" #include "types.rez"
#include "abCalcNda.defs" #include "abCalcNda.defs"
resource rWindParam1 (ABCALC_WINDOW_NUM) { resource rWindParam1 (abCalcWinNum) {
$C0A5, /* wFrameBits */ $C0A5, /* wFrameBits */
nil, /* wTitle */ nil, /* wTitle */
0, /* wRefCon */ 0, /* wRefCon */
{0,0,0,0}, /* ZoomRect */ {0,0,0,0}, /* ZoomRect */
ABCALC_LINED_COLORS, /* wColor ID */ abCalcLinedColors, /* wColor ID */
{0,0}, /* Origin */ {0,0}, /* Origin */
{0,0}, /* data size */ {0,0}, /* data size */
{0,0}, /* max height-width */ {0,0}, /* max height-width */
@ -21,17 +21,38 @@ resource rWindParam1 (ABCALC_WINDOW_NUM) {
{0,0}, /* page ver horiz */ {0,0}, /* page ver horiz */
0, /* winfoRefcon */ 0, /* winfoRefcon */
0, /* wInfoHeight */ 0, /* wInfoHeight */
{50,50,62,200}, /* wposition */ {10,10,180,630}, /* wposition */
infront, /* wPlane */ infront, /* wPlane */
nil, /* wStorage */ abCalcControlList, /* wStorage */
$0800 /* wInVerb */ $0809 /* wInVerb */
}; };
resource rWindColor (ABCALC_LINED_COLORS) { resource rWindColor (abCalcLinedColors) {
0x0000, /* frameColor */ 0x0000, /* frameColor */
0x0F00, /* titleColor */ 0x0F00, /* titleColor */
0x020F, /* tbarColor */ 0x020F, /* tbarColor */
0xF0F0, /* growColor */ 0xF0F0, /* growColor */
0x00F0, /* infoColor */ 0x00F0, /* infoColor */
}; };
resource rControlList (abCalcControlList) {
{
abCalcBtn0
}
};
resource rControlTemplate (abCalcBtn0) {
abCalcBtn0,
{8, 130, 0, 0},
SimpleButtonControl {{
$0002,
$3002,
0,
abCalcBtn0Str
}};
};
resource rPString (abCalcBtn0Str, noCrossBank) { "0" };