Add framework for NetDisk CDev.

The CDev currently runs and displays the UI, but doesn't actually do anything.
This commit is contained in:
Stephen Heumann 2018-08-11 16:33:18 -05:00
parent 610a638e5c
commit 2d00030eba
4 changed files with 400 additions and 4 deletions

View File

@ -11,13 +11,13 @@ NETDISKINIT_OBJS = initstart.a netdiskinit.a hostname.a http.a readtcp.a seturl.
# NETDISKINIT_RSRC =
NETDISKINIT_PROG = NetDiskInit
# NETDISKCDEV_OBJS =
# NETDISKCDEV_RSRC =
# NETDISKCDEV_CDEV =
NETDISKCDEV_OBJS = cdev.a cdevutil.a
NETDISKCDEV_RSRC = cdev.rez
NETDISKCDEV_CDEV = NetDisk
MACROS = asmglue.macros
PROGS = $(HTTPTEST_PROG) $(NETDISKINIT_PROG) $(MOUNTURL_PROG)
PROGS = $(HTTPTEST_PROG) $(NETDISKINIT_PROG) $(MOUNTURL_PROG) $(NETDISKCDEV_CDEV)
.PHONY: default
default: $(PROGS)
@ -32,6 +32,13 @@ $(NETDISKINIT_PROG): $(NETDISKINIT_OBJS)
$(CC) $(CFLAGS) -o $@ $^
iix chtyp -tpif $@
cdev.obj: $(NETDISKCDEV_OBJS)
$(CC) $(CFLAGS) -o $@ $^
$(NETDISKCDEV_CDEV): cdev.obj $(NETDISKCDEV_RSRC)
occ $(NETDISKCDEV_RSRC) -o $@
iix chtyp -tcdv $@
%.macros: %.asm
iix macgen $< $@ 13/ORCAInclude/m16.= < /dev/null > /dev/null

122
cdev.c Normal file
View File

@ -0,0 +1,122 @@
#pragma cdev cdevMain
#include <types.h>
#include <stddef.h>
#include <gsos.h>
#include <orca.h>
#include <quickdraw.h>
#include <window.h>
#include <control.h>
#include <lineedit.h>
#include <desk.h>
#define MachineCDEV 1
#define BootCDEV 2
#define InitCDEV 4
#define CloseCDEV 5
#define EventsCDEV 6
#define CreateCDEV 7
#define AboutCDEV 8
#define RectCDEV 9
#define HitCDEV 10
#define RunCDEV 11
#define EditCDEV 12
#define imageURLTxt 2
#define urlLine 3
#define mountBtn 1
//#define optionsPopUp 6
//#define trianglePic 7
extern void FreeAllCDevMem(void);
char urlBuf[257];
WindowPtr wPtr = NULL;
void DoMount(void)
{
GetLETextByID(wPtr, urlLine, (StringPtr)&urlBuf);
//TODO
}
void DoHit(long ctlID, CtlRecHndl ctlHandle)
{
CtlRecHndl oldMenuBar;
Word menuItem;
if (!wPtr) /* shouldn't happen */
return;
if (ctlID == mountBtn) {
DoMount();
}
return;
}
long DoMachine(void)
{
return 1;
}
void DoEdit(Word op)
{
CtlRecHndl ctl;
GrafPortPtr port;
if (!wPtr)
return;
port = GetPort();
SetPort(wPtr);
ctl = FindTargetCtl();
if (toolerror() || GetCtlID(ctl) != urlLine)
goto ret;
switch (op) {
case cutAction: LECut((LERecHndl) GetCtlTitle(ctl));
if (LEGetScrapLen() > 0)
LEToScrap();
break;
case copyAction: LECopy((LERecHndl) GetCtlTitle(ctl));
if (LEGetScrapLen() > 0)
LEToScrap();
break;
case pasteAction: LEFromScrap();
LEPaste((LERecHndl) GetCtlTitle(ctl));
break;
case clearAction: LEDelete((LERecHndl) GetCtlTitle(ctl));
break;
}
ret:
SetPort(port);
}
void DoCreate(WindowPtr windPtr)
{
int mode;
wPtr = windPtr;
mode = (GetMasterSCB() & scbColorMode) ? 640 : 320;
NewControl2(wPtr, resourceToResource, mode);
}
LongWord cdevMain (LongWord data2, LongWord data1, Word message)
{
long result = 0;
switch(message) {
case MachineCDEV: result = DoMachine(); break;
case HitCDEV: DoHit(data2, (CtlRecHndl)data1); break;
case EditCDEV: DoEdit(data1 & 0xFFFF); break;
case CreateCDEV: DoCreate((WindowPtr)data1); break;
case CloseCDEV: wPtr = NULL; break;
}
ret:
FreeAllCDevMem();
return result;
}

257
cdev.rez Normal file
View File

@ -0,0 +1,257 @@
#include "types.rez"
resource rVersion (1) {
{ 1,0,0,beta,1 },
verUS,
"NetDisk",
"By Stephen Heumann"
};
resource rComment (1) {
"The NetDisk control panel allows you to mount disk images "
"hosted on HTTP servers.\n"
"\n"
"Copyright 2018 Stephen Heumann\n"
"\n"
"This program contains material from the ORCA/C Run-Time Libraries, "
"copyright 1987-1996 by Byte Works, Inc. Used with permission."
};
resource rCDEVFlags (1) {
wantMachine+wantHit+wantClose+wantEdit+wantCreate,
1, /* enabled */
1, /* version */
1, /* min ROM version */
0, /* reserved */
{0, 0, 55, 320}, /* rectangle */
"NetDisk", /* name */
"Stephen Heumann", /* author */
"v1.0a1" /* version string */
};
read rCDevCode (0x1,convert,locked) "cdev.obj";
resource rIcon (1) {
0x8000, /* color icon */
20, /* dimensions */
28,
//TODO change icon
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"F00000000FFFFFFFFFFFFFFFFFFF"
$"F0DDDDDD0FFFFFFFFFFFFFFFFFFF"
$"F0DDDDDD04FFFFFFFF4FFFFFFFFF"
$"F0DDDDDD04FFFFFFFF4F0FF000FF"
$"F0DDDDDD444FFFFF0444A0F0DD0F"
$"F0000000444FFFF0E4440A00DD0F"
$"FF0FFFF4F4F4FFF04E404AA0DD0F"
$"F000000404F4FFF04E404A00DD0F"
$"F0F4FF4F04FF4F04004004000000"
$"F000040004FFF44303433343330F"
$"4444444444444444444444444444"
$"3333333334333333334333333333"
$"4444444444444444444444444444"
$"FFFFFFFFF4FFFFFFFF4FFFFFFFFF"
$"FFFFFFFFF4FFFFFFFF4FFFFFFFFF"
$"FFFFFFFFF4FFFFFFFF4FFFFFFFFF"
$"FFFFFFFFF4FFFFFFFF4FFFFFFFFF",
$"0000000000000000000000000000"
$"0000000000000000000000000000"
$"0000000000000000000000000000"
$"0FFFFFFFF0000000000000000000"
$"0FFFFFFFF0000000000000000000"
$"0FFFFFFFFF00000000F000000000"
$"0FFFFFFFFF00000000F0F00FFF00"
$"0FFFFFFFFFF00000FFFFFF0FFFF0"
$"0FFFFFFFFFF0000FFFFFFFFFFFF0"
$"00FFFFFF0F0F000FFFFFFFFFFFF0"
$"0FFFFFFFFF0F000FFFFFFFFFFFF0"
$"0FFFFFFFFF00F0FFFFFFFFFFFFFF"
$"0FFFFFFFFF000FFFFFFFFFFFFFF0"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"000000000F00000000F000000000"
$"000000000F00000000F000000000"
$"000000000F00000000F000000000"
$"000000000F00000000F000000000"
};
#define cdevWindow 1000
#define helpWindow 2000
#define imageURLTxt 2
#define urlLine 3
#define mountBtn 1
//#define optionsPopUp 6
//#define trianglePic 7
#define helpTxt 5
/*
* Controls in the control panel window (for 640 mode or 320 mode)
*/
resource rControlList (640) {
{
cdevWindow+imageURLTxt,
cdevWindow+urlLine,
cdevWindow+mountBtn,
//cdevWindow+trianglePic,
//cdevWindow+optionsPopUp
};
};
resource rControlList (320) {
{
cdevWindow+imageURLTxt,
cdevWindow+urlLine,
cdevWindow+mountBtn,
//cdevWindow+trianglePic+320,
//cdevWindow+optionsPopUp+320
};
};
resource rControlTemplate (cdevWindow+imageURLTxt) {
imageURLTxt, /* control ID */
{4, 10, 15, 270}, /* control rect */
statTextControl {{
fBlastText, /* flags */
$1000+RefIsResource, /* moreFlags */
0, /* refCon */
cdevWindow+imageURLTxt /* title ref */
}};
};
resource rTextForLETextBox2 (cdevWindow+imageURLTxt) {
"Disk Image URL:"
};
resource rControlTemplate (cdevWindow+urlLine) {
urlLine,
{15, 10, 28, 310},
editLineControl {{
0,
$7000+RefIsResource,
0,
255, /* max size */
cdevWindow+urlLine /* text ref */
}};
};
resource rPString (cdevWindow+urlLine) { "http://" };
resource rControlTemplate (cdevWindow+mountBtn) {
mountBtn,
{35, 156, 0, 0},
SimpleButtonControl {{
DefaultButton,
$3000+RefIsResource,
0,
cdevWindow+mountBtn,
0, /* color table ref */
{"\$0D","\$0D",0,0} /* key equivalent = Return */
}};
};
resource rPString(cdevWindow+mountBtn) { "Mount Disk Image" };
#if 0
/* Options menu pop-up -- separate versions for 640 mode and 320 mode */
resource rControlTemplate (cdevWindow+optionsPopUp) {
optionsPopUp,
{5, 282, 13, 310 },
PopUpControl {{
fDontDrawTitle+fDontDrawResult,
fCtlProcNotPtr+RefIsResource/*+fDrawPopDownIcon*/,
0,
0,
optionsMenu, /* menu ref */
afpOverTCPOptionsItem, /* initial value */
0
}};
};
resource rControlTemplate (cdevWindow+optionsPopUp+ 320) {
optionsPopUp,
{5, 296, 13, 310 },
PopUpControl {{
fDontDrawTitle+fDontDrawResult,
fCtlProcNotPtr+RefIsResource/*+fDrawPopDownIcon*/,
0,
0,
optionsMenu, /* menu ref */
afpOverTCPOptionsItem, /* initial value */
0
}};
};
/* Triangle to draw on options pop-up */
resource rControlTemplate (cdevWindow+trianglePic) {
trianglePic,
{7, 286, 11, 302},
PictureControl {{
CtlInactive,
fCtlProcNotPtr+RefIsResource,
0,
trianglePic /* picture reference */
}};
};
resource rControlTemplate (cdevWindow+trianglePic+320) {
trianglePic,
{7, 298, 0, 0},
PictureControl {{
CtlInactive,
fCtlProcNotPtr+RefIsResource,
0,
trianglePic /* picture reference */
}};
};
data rPicture (trianglePic) {
$"8000 0000 0000 0400 1000 1182 0100 0A00"
$"01C0 01C0 FF3F FF3F 9000 8000 0000 0400"
$"0000 0000 0400 1000 0000 0000 0400 1000"
$"0000 0000 0400 1000 0000 0000 0000 F000"
$"000F FF00 00FF FFF0 0FFF"
};
resource rMenu (optionsMenu) {
optionsMenu, /* menu ID */
refIsResource*menuTitleRefShift + refIsResource*itemRefShift,
optionsMenu, /* menu title ref (not drawn) */
{
//items go here
};
};
resource rPString(optionsMenu,noCrossBank) { "" };
#endif
/*
* Controls in the help window
*/
resource rControlList (2) {
{
helpWindow+helpTxt
};
};
resource rControlTemplate (helpWindow+helpTxt) {
helpTxt,
{38, 5, 138, 280},
statTextControl {{
0, /* flags */
$1000+RefIsResource, /* moreFlags */
0, /* refCon */
helpWindow+helpTxt /* title ref */
}};
};
resource rTextForLETextBox2 (helpWindow+helpTxt) {
"The NetDisk control panel allows you to mount disk images "
"hosted on HTTP servers.\n"
};

10
cdevutil.asm Normal file
View File

@ -0,0 +1,10 @@
case on
dummy private
end
FreeAllCDevMem start
pea 0
jsl ~DAID
rtl
end