🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.atari16
Article #730

ramdisk source -- part II

#730
From: ACS19
Date: Fri, 16 May 1986 22:32
145 lines
4780 bytes
/* HERE IS THE SECOND PART OF THE RAMDISK ACCESSORY */
/*Copyright 1986 Michael Vederman, distribute freely with proper credit*/
/**************************************************************************/
/* BEGIN PART II */
clear_fat()  /* erase any erroneous junk */
{
char	*temp;

	for(temp=ramdisk_ptr; temp < ramdisk_ptr+9216; temp++)
		*temp = 0;
}
/**************************************************************************/

install()  /* install ramdisk handler vectors */
{
         getbpb  = (PL) *bpbvect;
         mediach = (PW) *mcvect;
         rwabs   = (PL) *rwvect;
		*bpbvect = rdgetbpb;
		*mcvect  = rdmediach;
		*rwvect  = rdrwabs;
         *devset  = *devset | (0x8L);  /* set drive bits - 0x4L for C, etc. */
}
/*************************************************************************/
deinstall()  /* very interesting little fact:  ROM TOS does not re-init
              the device bits, if you reset, the ramdisk drive is still
              there, unless you do an xbios(38, deinstall) in main() */


{
         *devset  = *devset & 0xfffffff7L; /* clear drive bits */
}
/*************************************************************************/

main()
{
	appl_init();
	phys_handle=graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox);
	menu_id=menu_register( gl_apid,"  Mike's Ramdisk " );
/* put name into desk menu */

	wind_get( 0, WF_WORKXYWH, &xdesk, &ydesk, &wdesk, &hdesk);
/* get max size of window */

    xbios(38, deinstall); /* deinstall vectors (just in case of reset)*/
    in_place = FALSE; /* ramdisk is not installed yet (for alert box) */
	wi_handle=(-1);
	start();
}
/**************************************************************************/
LONG atoi(s) /* convert the size entered by user to integer */
char s[];

{
WORD     n, i;
		
	for(i=0, n=0; s[i] >= '0' && s[i] <= '9' && i < 5; ++i)
		n = 10 * n +s[i] - '0';
	return(n);
}	

/**************************************************************************/
do_ramdisk()
{
	ok = FALSE;
 	maxsize = Malloc(-1L);
	size=atoi(rs_tedinfo[0].te_ptext);

/* In the following, we should probably limit the max size so as to not
screw up the system, but what the heck, you can allocate all your
memory, but for safety sake, it should be about 50-60K less */

		if (size)
		    {
			newsize=(size+9)*1024;
			newmaxsize = maxsize/1024-9;
			   if ( newsize > maxsize )
			     {
				form_alert(1,&alert1);
				newsize=maxsize;
				size=newmaxsize;
			     }
			ramdisk_ptr = Malloc(newsize);
			if (ramdisk_ptr)
			    {
				in_place=TRUE;
                   rdiskbpb.numcl=(WORD)size * 2;
				clear_fat();
				xbios(38,install);
				form_alert(1,&alert3);
				ok = TRUE;
			    }
			else
				form_alert(1,&alert2);
		     }
		else
			form_alert(1,&alert7);
}
/**************************************************************************/
open_vwork()  /* standard stuff */
{
int i;
	for( i=0; i<10; work_in[i++]=1 ); work_in[10]=2;
	handle=phys_handle;
	v_opnvwk( work_in, &handle, work_out );
}

/*********************************************************************/

clear_window()
/* paint it white (could be a good song if it was black) */
{
int temp[4];
    graf_mouse(M_OFF,0x0L);/* mistake by many programs leaves mouse on */
	vsf_interior(handle,2);
	vsf_style(handle,8);
	vsf_color(handle,0);
	temp[0]=xwork;
	temp[1]=ywork;
	temp[2]=xwork+wwork;
	temp[3]=ywork+hwork;
	v_bar(handle,temp);
	graf_mouse(M_ON,0x0L);
}
/**************************************************************************/

open_window()
{
	wi_handle=wind_create( NAME, xdesk, ydesk, wdesk, hdesk );
	wind_set( wi_handle, WF_NAME," Mike's Ramdisk v 0.9 ", 0, 0 );
	graf_growbox( 15, 27, 160,8, xdesk, ydesk, wdesk,hdesk );
    wind_open( wi_handle, xdesk, ydesk, wdesk - 1, hdesk - 1 );
    wind_get( wi_handle, WF_WORKXYWH, &xwork, &ywork, &wwork, &hwork );
}

/**************************************************************************/
remove_rdisk() /* see ya later ramdisk */
{
rdiskbpb.numcl=(int)0;
xbios(38, deinstall);
dinstal=TRUE;
Mfree(ramdisk_ptr);
}

/* END PART II */
Technical Details
Message-ID: <8605170014.AA23950@ucbvax.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ucbvax!UHUPVM1.BITNET!ACS19

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ucbvax!UHUPVM1.BITNET!ACS19
From: ACS19@UHUPVM1.BITNET
Newsgroups: net.micro.atari16
Subject: ramdisk source -- part II
Message-ID: <8605170014.AA23950@ucbvax.Berkeley.EDU>
Date: Fri, 16-May-86 18:32:07 EDT
Article-I.D.: ucbvax.8605170014.AA23950
Posted: Fri May 16 18:32:07 1986
Date-Received: Mon, 19-May-86 01:32:22 EDT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: ACS19%UHUPVM1.BITNET@WISCVM.WISC.EDU
Organization: The ARPA Internet
Lines: 145