ACS19@UHUPVM1.BITNET (05/17/86)
/* This program is divided into three parts to get it over BITNET */
/* There are control characters in this, and square and curly brackets
which may not display on your mainframe terminal. */
/*This program copyright 1986 by Michael Vederman, distribute it freely
so long as proper credit for code is given. The ramdisk resize was not
implemented with this version.*/
/* PART I */
#include "d:portab.h"
#include "d:obdefs.h"
#include "d:define.h"
#include "d:gemdefs.h"
#include "d:osbind.h"
TEDINFO rs_tedinfo[] = {
"00100",
"Size:_____K",
"99999",
3, 6, 2, 0x1073, 0x0, -2, 6,12,
" Enter ramdisk size, then select ", /*THERE IS A CTRL-C AT END*/
"",
"",
3, 6, 0, 0x1180, 0x0, -1, 39,1,
" Type in the size you desire ", /*THERE IS A CTRL-C HERE*/
"",
"",
3, 6, 0, 0x1180, 0x0, -1, 39,1,
" To free ramdisk memory, select ", /*THERE IS A CTRL-C HERE*/
"",
"",
3, 6, 0, 0x1180, 0x0, -1, 39,1,
" First enter new size, then select ", /*THERE IS A CTRL-C HERE*/
"",
"",
3, 6, 0, 0x1180, 0x0, -1, 39,1};
OBJECT rs_object[] = {
-1, 1, 15, G_BOX, NONE, OUTLINED, 0x21143L, 0,0, 576,160,
4, 2, 3, G_BOX, NONE, NORMAL, 0x11172L, 360,48,184,80,
3, -1, -1, G_BUTTON, 0x5, 0x28, "Deallocate Ramdisk", 16,32,152,16,
1, -1, -1, G_BUTTON, 0x5, 0x28, "Resize Ramdisk", 16,64,152,16,
8, 5, 7, G_BOX, NONE, SHADOWED, 0xFE1142L, 376,16,152,16,
6, -1, -1, G_FBOXTEXT, EDITABLE, NORMAL, &rs_tedinfo[0], 24,0,104,16,
7, -1, -1, G_BOXCHAR, NONE, NORMAL, 0x4000142L, 136,0,8,16,
4, -1, -1, G_BOXCHAR, NONE, NORMAL, 0x3000142L, 8,0,8,16,
9, -1, -1, G_BUTTON, 0x7, NORMAL, "EXIT", 136,144,56,16,
10, -1, -1, G_STRING, NONE, NORMAL, "Program by", 40,144,88,16,
11, -1, -1, G_STRING, NONE, NORMAL, "Michael Vederman", 208,144,128,16,
12, -1, -1, G_BOXTEXT, NONE, NORMAL, &rs_tedinfo[1], 32,48,312,16,
13, -1, -1, G_BOXTEXT, NONE, NORMAL, &rs_tedinfo[2], 32,16,312,16,
14, -1, -1, G_BOXTEXT, NONE, DISABLED, &rs_tedinfo[3], 32,80,312,16,
15, -1, -1, G_BOXTEXT, NONE, DISABLED, &rs_tedinfo[4], 32,112,312,16,
0, -1, -1, G_BUTTON, 0x25, SHADOWED, "Allocate Ramdisk", 376,48,152,16};
#define RAM DISK 0
#define SIZEBOX 5
#define ALOCSTR 11
#define DALOCSTR 13
#define RESIZSTR 14
#define ALOCBOX 15
#define DALOCBOX 2
#define RESIZBOX 3
#define GOODBYE 8
struct bpb
{ WORD recsiz,
clsiz,
clsizb,
rdlen,
fsiz,
fatrec,
datrec,
numcl,
bflags;
};
typedef LONG (*PL)(); /*pointer to function returning a long*/
typedef WORD (*PW)(); /*pointer to a function returning a word*/
PL getbpb;
PW mediach;
PL rwabs;
struct bpb rdiskbpb = { 512, 1, 512, 7, 5, 6, 18, 0, 0, +;
/*The 1 after 512 above will give you 1 sector clusters, for more useable
'DISK' space, you can do the same to the boot sector of a disk after you
format it, but before you write to it, by changing the second 02 (I
believe it is byte 12 offset) to a 01. Using the extended formatter
you can get quite a lot of extra disk space.*/
char
alert1[]="[3][YOU HAVE TRIED TO ALLOCATE|TOO MUCH MEMORY. THE MAXIMUM|\
SIZE HAS BEEN ALLOCATED|CHECK DISK D INFO FOR SIZE][ Time to upgrade ]",
alert2[]="[3][COULD NOT ALLOCATE|TRY REBOOTING][ Oh Well... ]",
alert3[]="[1][Memory Allocated][ Thanks ]",
alert4[]="[0][Michael Vederman|15319 Tonya|Houston, Tx 77060|UHACE BBS+
713-820-6120][ A U of H ACEware +",
alert5[]="[0][Memory Deallocate|does not work right|due to GEMDOS bugs.|\
You can reallocate up|to 1K less than before][ OK ]",
alert6[]="[0][Ramdisk Resize| |(under construction)][ OK ]",
alert7[]="[0][No memory allocated| | Enter size and| try again][ OK ]",
alert8[]="[1][Allocate ramdisk FIRST| |Then install drive D][ SURE ]";
extern int gl_apid;
int *ramdisk_ptr;
long size, newmaxsize;
long *bpbvect = 0x472;
long *rwvect = 0x476;
long *mcvect = 0x47e;
long *devset = 0x4c2;
long maxsize,newsize;
char ok, in_place, dinstal;
int event
int gl_hchar, gl_wchar, gl_wbox, gl_hbox,
menu_id, phys_handle, handle, wi_handle,
xdesk, ydesk, hdesk, wdesk, xold, yold, hold, wold,
xwork, ywork, hwork, wwork,
msgbuff[8], ret,
contrl[12], intin[128], ptsin[128], intout[128], ptsout[128],
work_in[11], work_out[57];
int fo_cx, fo_cy, fo_cw, fo_ch,
fo_doreturn;
/**************************************************************************/
/*This is the ramdisk read/write abs routine*/
LONG rdrwabs(rw,buf,count,recno,dev)
WORD rw;
int *buf;
WORD count, recno, dev;
{ int i, *p;
if (dev != 3) /*Drive D -- could be 2 for C, etc...*/
return( (*rwabs)(rw,buf,count,recno,dev) );
else
{ if (rw > 1) rw -=2; /* function number never > 1 */
while ( count > 0 )
{ p = ramdisk_ptr+(((long) recno) * 256L);
if (rw==0) /* read */
for (i=0; i<256; i++) *buf++ = *p++;
else /* write */
for (i=0; i<256; i++) *p++ = *buf++;
count--; recno++;
}
return(0L); /* everything worked (everything ALWAYS works!) */
}
}
/**************************************************************************/
LONG rdgetbpb(dev) /* get our BPB -- this describes certain attributes */
WORD dev;
{
if (dev != 3)
return( (*getbpb)(dev) ); /* real disk BPB */
else
return( &rdiskbpb ); /* ramdisk BPB */
}
/**************************************************************************/
WORD rdmediach(dev) /* has the media changed -- ramdisk reinitted? */
WORD dev;
{
if (dev != 3)
return((*mediach)(dev)) ;
else
if (dinstal){ dinstal=FALSE; return( 2 );}
else
return( 0 ); /* if ramdisk just installed then get bpb else no */
}
/* END PART I */