[comp.sources.amiga] v02i006: suplib - Matt's support library, Part02/02

page@swan.ulowell.edu (Bob Page) (10/22/88)

Submitted-by: dillon@cory.berkeley.edu (Matt Dillon)
Posting-number: Volume 2, Issue 6
Archive-name: util/suplib.2

# This is a shell archive.  Remove anything before this line
# then unpack it by saving it in a file and typing "sh file"
# (Files unpacked will be owned by you and have default permissions).
# This archive contains the following files:
#	./include/local/res.h
#	./include/local/ipc.h
#	./include/local/Makefile
#	./include/local/deemu.h
#	./include/local/typedefs.h
#	./include/local/xmisc.h
#	./include/local/file.i
#	./include/local/makesymbols.c
#	./include/local/dio.h
#	./suplib/mntreq.c
#	./suplib/bset.asm
#	./suplib/resetbreak.c
#	./suplib/scandir.c
#	./suplib/initdeemunw.c
#	./suplib/tags
#	./suplib/xfio.c
#	./suplib/closelibs.c
#	./suplib/wildcmp.c
#	./suplib/datetos.c
#	./suplib/checkbreak.c
#	./suplib/bcmp.asm
#	./suplib/bmov.asm
#	./suplib/semaphore.c
#	./suplib/llink.c
#	./suplib/openlibs.c
#	./suplib/dead.c
#	./suplib/getfont.c
#	./suplib/Makefile
#	./suplib/AUX/qint_test.c
#	./suplib/fhprintf.asm
#
if `test ! -d ./include`
then
  mkdir ./include
  echo "mkdir ./include"
fi
if `test ! -d ./include/local`
then
  mkdir ./include/local
  echo "mkdir ./include/local"
fi
if `test ! -s ./include/local/res.h`
then
echo "writing ./include/local/res.h"
cat > ./include/local/res.h << '\Rogue\Monster\'

#define SHARABLE    0x0001  /*	shareable			*/
#define GLOBAL	    0x0002  /*	global access			*/
#define NAMED	    0x0004  /*	if shared, can access by name	*/
#define SWAPABLE    0x0008  /*	swap enabled			*/
#define LOCKED	    0x0010  /*	locked into mem 		*/

#define SWAPPED     0x0100  /*	swapped to disk */
#define SLOCKED     0x0200  /*	temporary lock	*/

#define HAVHANDLE   0x0400  /*	have a filehndl */
#define HAVLOCK     0x0800  /*	have a filelock */

#define RESMLNAME   "DRES"  /*  MemList node name   */

\Rogue\Monster\
else
  echo "will not over write ./include/local/res.h"
fi
if [ `wc -c ./include/local/res.h | awk '{printf $1}'` -ne 516 ]
then
echo `wc -c ./include/local/res.h | awk '{print "Got " $1 ", Expected " 516}'`
fi
if `test ! -s ./include/local/ipc.h`
then
echo "writing ./include/local/ipc.h"
cat > ./include/local/ipc.h << '\Rogue\Monster\'

#ifndef LOCAL_TYPEDEFS_H
#include <local/typedefs.h>
#endif

#ifndef LOCAL_IPC_H
#define LOCAL_IPC_H

#define IPCMSG	struct _IPCMSG
#define IPCPORT struct _IPCPORT

IPCPORT {
    PORT    Port;
    long    Flags;	/*  Open flags for port */
};

IPCMSG {
    MSG     Msg;	/*  EXEC message header */
    MNODE   ANode;	/*  Application node	*/
    long    Error;	/*  optional error code */
    IPCPORT *ToPort;
    void    (*Confirm)();

    APTR    TBuf;	/*  Sender Command	*/
    long    TLen;
    long    TFlags;

    APTR    RBuf;	/*  Receiver Reply	*/
    long    RLen;
    long    RFlags;
};

#define IF_NOCOPY   0x0001	/*  Do allocate a copy of the buffer	  */
#define IF_ALLOC    0x0002	/*  Message was allocated		  */
#define IF_NOTFND   0x0004	/*  Command not found	       (+IF_ERROR)*/
#define IF_ERROR    0x0008	/*  Error occured			  */

#define IF_NOAPP    0x0020	/*  Req. Application not found (+IF_ERROR)*/
#define IF_GLOBAL   0x0040	/*  global message... sent to all servers */
#define IF_ALLOCMSG 0x8000	/*  IPCMSG structure was allocated	  */

#define PERR_NOMEM  1		/*  Ran out of memory parsing command	  */
#define PERR_NOVAR  2		/*  Could not find string variable	  */

extern PORT *OpenIPC();

#endif



\Rogue\Monster\
else
  echo "will not over write ./include/local/ipc.h"
fi
if [ `wc -c ./include/local/ipc.h | awk '{printf $1}'` -ne 1223 ]
then
echo `wc -c ./include/local/ipc.h | awk '{print "Got " $1 ", Expected " 1223}'`
fi
if `test ! -s ./include/local/Makefile`
then
echo "writing ./include/local/Makefile"
cat > ./include/local/Makefile << '\Rogue\Monster\'


#   Make the precompiled symbol table
#
#   Warning: This makefile can be executed from ANY directory... paths
#   must be absolute

all:
    cc +L +Hinclude:symbols.m include:local/makesymbols.c -o ram:junk
    -delete ram:junk

\Rogue\Monster\
else
  echo "will not over write ./include/local/Makefile"
fi
if [ `wc -c ./include/local/Makefile | awk '{printf $1}'` -ne 232 ]
then
echo `wc -c ./include/local/Makefile | awk '{print "Got " $1 ", Expected " 232}'`
fi
if `test ! -s ./include/local/deemu.h`
then
echo "writing ./include/local/deemu.h"
cat > ./include/local/deemu.h << '\Rogue\Monster\'

#define DMSTRT	'ST','RT'
#define DMEND	'EN','D '
#define DMNW	'NW','  '
#define DMTEXT	'TE','XT'

\Rogue\Monster\
else
  echo "will not over write ./include/local/deemu.h"
fi
if [ `wc -c ./include/local/deemu.h | awk '{printf $1}'` -ne 99 ]
then
echo `wc -c ./include/local/deemu.h | awk '{print "Got " $1 ", Expected " 99}'`
fi
if `test ! -s ./include/local/typedefs.h`
then
echo "writing ./include/local/typedefs.h"
cat > ./include/local/typedefs.h << '\Rogue\Monster\'

/*
 * TYPEDEFS.H
 *
 *	Feel free to add extern's that should be stuck in here... send
 *	me the additions!
 */

#ifndef LOCAL_TYPEDEFS_H
#define LOCAL_TYPEDEFS_H

typedef unsigned char	ubyte;
typedef unsigned short	uword;
typedef unsigned long	ulong;

typedef struct MsgPort		PORT;
typedef struct Message		MSG;
typedef struct List		LIST;
typedef struct Node		NODE;
typedef struct MinList		MLIST;
typedef struct MinNode		MNODE;
typedef struct Device		DEV;
typedef struct Library		LIB;
typedef struct ExecBase 	EXECBASE;
typedef struct SignalSemaphore	SIGSEM;
typedef struct Semaphore	SEM;
typedef struct MemEntry 	MEMENTRY;
typedef struct MemList		MEMLIST;
typedef struct MemHeader	MEMHEADER;
typedef struct Interrupt	INTERRUPT;
typedef struct Custom		CUST;

#define WINSTD	(WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE)

typedef struct BoolInfo 	BOOLINFO;
typedef struct Border		BORDER;
typedef struct Gadget		GADGET;
typedef struct Image		IMAGE;
typedef struct IntuiMessage	IMESS;
typedef struct IntuiText	ITEXT;
typedef struct Menu		MENU;
typedef struct MenuItem 	ITEM;
typedef struct NewScreen	NS;
typedef struct NewWindow	NW;
typedef struct Preferences	PREFS;
typedef struct PropInfo 	PROPINFO;
typedef struct Remember 	REMEMBER;
typedef struct Requester	REQUESTER;
typedef struct Screen		SCR;
typedef struct StringInfo	STRINGINFO;
typedef struct Window		WIN;

typedef struct copinit		COPINIT;

typedef struct GListEnv 	GLISTENV;
typedef struct GadgetInfo	GADGETINFO;
typedef struct IBox		IBOX;
typedef struct IntuitionBase	IBASE;
typedef struct PenPair		PENPAIR;
typedef struct Point		POINT;

typedef struct IOAudio		IOAUD;

typedef struct BootBlock	BOOTBLOCK;

typedef struct IOClipReq	    IOCLIPREQ;
typedef struct ClipboardUnitPartial CLIPUNIT;
typedef struct SatisfyMsg	    SATISFYMSG;

typedef struct ConUnit		CONUNIT;
typedef struct IOStdReq 	IOCON;
typedef struct IOExtSer 	IOSER;

typedef struct InputEvent	IE;

typedef struct TextAttr 	TA;
typedef struct TextFont 	FONT;
typedef struct Layer		LAYER;
typedef struct Layer_Info	LAYERINFO;
typedef struct Region		REGION;
typedef struct ClipRect 	CLIPRECT;
typedef struct BitMap		BM;
typedef struct RastPort 	RP;
typedef struct TmpRas		TMPRAS;
typedef struct AreaInfo 	AREAINFO;
typedef struct View		VIEW;
typedef struct ViewPort 	VP;
typedef struct ColorMap 	CM;
typedef struct GfxBase		GFXBASE;

typedef struct Process		PROC;
typedef struct Task		TASK;
typedef struct FileInfoBlock	FIB;
typedef struct FileLock 	LOCK;
typedef struct DateStamp	DATESTAMP;

typedef struct timeval		TV;
typedef struct timerequest	IOT;

typedef struct PrinterData	PD;
typedef struct PrinterExtendedData PED;


/*
 *  Intuition
 */

extern WIN	*OpenWindow();
extern SCR	*OpenScreen();
extern void	*AllocRemember();
extern void	*ItemAddress();
extern PREFS	*GetPrefs();
extern PREFS	*GetDefPrefs();
extern VIEW	*ViewAddress();
extern VP	*ViewPortAddress();

/*
 *  Graphics
 */

extern void	*AllocRaster();
extern TMPRAS	*InitTmpRas();
extern AREAINFO *InitArea();

/*
 *  Exec / Exec-Support
 */

extern char	*GetDEnv();
extern void	*GetMsg(), *RemHead(), *RemTail();
extern void	*GetHead(), *GetTail(), *GetSucc(), *GetPred();
extern void	*GetHeadOff(), *GetTailOff(), *GetSuccOff(), *GetPredOff();
extern void	*OpenLibrary();

extern SIGSEM	*FindSemaphore();
extern void	*AllocMem();
extern void	*AllocEntry();
extern PORT	*FindPort();
extern PORT	*CreatePort();
extern TASK	*CreateTask();
extern INTERRUPT *SetIntVector();
extern PROC	*CreateProc();
extern void	*FindTask();    /*  task or proc    */
extern LIB	*MakeLibrary();

extern FONT	*OpenFont();
extern FONT	*OpenDiskFont();

extern void	*malloc();

extern void	*FindName2();

#endif


\Rogue\Monster\
else
  echo "will not over write ./include/local/typedefs.h"
fi
if [ `wc -c ./include/local/typedefs.h | awk '{printf $1}'` -ne 3691 ]
then
echo `wc -c ./include/local/typedefs.h | awk '{print "Got " $1 ", Expected " 3691}'`
fi
if `test ! -s ./include/local/xmisc.h`
then
echo "writing ./include/local/xmisc.h"
cat > ./include/local/xmisc.h << '\Rogue\Monster\'

/*
 * XMISC.H
 */

#ifndef MYLIB_XMISC_H
#define MYLIB_XMISC_H

#define GRAPHICS_LIB	    0x0001L
#define INTUITION_LIB	    0x0002L
#define EXPANSION_LIB	    0x0004L
#define DISKFONT_LIB	    0x0008L
#define TRANSLATOR_LIB	    0x0010L
#define ICON_LIB	    0x0020L
#define MATH_LIB	    0x0040L
#define MATHTRANS_LIB	    0x0080L
#define MATHIEEEDOUBBAS_LIB 0x0100L
#define MATHIEEESINGBAS_LIB 0x0200L
#define LAYERS_LIB	    0x0400L
#define CLIST_LIB	    0x0800L
#define POTGO_LIB	    0x1000L
#define TIMER_LIB	    0x2000L
#define DRES_LIB	    0x4000L

#define ADRLOCK struct _ADRLOCK
#define XLIST struct _XLIST

ADRLOCK {
    long    ad_Wait;
    unsigned char  ad_Bits;
};

XLIST {
    XLIST *next;
    XLIST **prev;
};

#endif


\Rogue\Monster\
else
  echo "will not over write ./include/local/xmisc.h"
fi
if [ `wc -c ./include/local/xmisc.h | awk '{printf $1}'` -ne 729 ]
then
echo `wc -c ./include/local/xmisc.h | awk '{print "Got " $1 ", Expected " 729}'`
fi
if `test ! -s ./include/local/file.i`
then
echo "writing ./include/local/file.i"
cat > ./include/local/file.i << '\Rogue\Monster\'

		;
		;
		;

LFF_NBLOCK	equ	$80000000
LFF_REMOTE	equ	$40000000

LF_OPEN 	equ	256
LF_CLOSE	equ	257
LF_DUP		equ	258
LF_READ 	equ	259
LF_WRITE	equ	260
LF_NREAD	equ	(261 | LFF_NBLOCK)
LF_NWRITE	equ	(262 | LFF_NBLOCK)
LF_RIOCTL	equ	263
LF_RSIGNAL	equ	264
LF_WSIGNAL	equ	265
LF_SEEK 	equ	266
LF_WSIGMARK	equ	267
LF_RSIGMARK	equ	268
LF_GETBSIZE	equ	269
LF_SETRBUF	equ	270
LF_SETWBUF	equ	271

LF_OVRIDE	equ	272
LF_UNRIDE	equ	273

\Rogue\Monster\
else
  echo "will not over write ./include/local/file.i"
fi
if [ `wc -c ./include/local/file.i | awk '{printf $1}'` -ne 423 ]
then
echo `wc -c ./include/local/file.i | awk '{print "Got " $1 ", Expected " 423}'`
fi
if `test ! -s ./include/local/makesymbols.c`
then
echo "writing ./include/local/makesymbols.c"
cat > ./include/local/makesymbols.c << '\Rogue\Monster\'

#include <exec/types.h>
#include <exec/alerts.h>
#include <exec/devices.h>
#include <exec/errors.h>
#include <exec/exec.h>
#include <exec/execbase.h>
#include <exec/execname.h>
#include <exec/interrupts.h>
#include <exec/io.h>
#include <exec/libraries.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include <exec/nodes.h>
#include <exec/ports.h>
#include <exec/resident.h>
#include <exec/semaphores.h>
#include <exec/tasks.h>
#include <clib/macros.h>
#include <devices/audio.h>
#include <devices/bootblock.h>
#include <devices/clipboard.h>
#include <devices/console.h>
#include <devices/conunit.h>
#include <devices/gameport.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <devices/keyboard.h>
#include <devices/keymap.h>
#include <devices/narrator.h>
#include <devices/parallel.h>
#include <devices/printer.h>
#include <devices/prtbase.h>
#include <devices/serial.h>
#include <devices/timer.h>
#include <devices/trackdisk.h>
#include <graphics/clip.h>
#include <graphics/collide.h>
#include <graphics/copper.h>
#include <graphics/display.h>
#include <graphics/gels.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <graphics/gfxmacros.h>
#include <graphics/graphint.h>
#include <graphics/layers.h>
#include <graphics/rastport.h>
#include <graphics/regions.h>
#include <graphics/sprite.h>
#include <graphics/text.h>
#include <graphics/view.h>
#include <hardware/adkbits.h>
#include <hardware/blit.h>
#include <hardware/cia.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <hardware/intbits.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <intuition/preferences.h>
#include <intuition/screens.h>
#include <libraries/configregs.h>
#include <libraries/configvars.h>
#include <libraries/diskfont.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <libraries/expansion.h>
#include <libraries/expansionbase.h>
#include <libraries/filehandler.h>
#include <libraries/mathffp.h>
#include <libraries/romboot_base.h>
#include <libraries/translator.h>
#include <resources/cia.h>
#include <resources/disk.h>
#include <resources/misc.h>
#include <resources/potgo.h>
#include <workbench/icon.h>
#include <workbench/startup.h>
#include <workbench/workbench.h>

\Rogue\Monster\
else
  echo "will not over write ./include/local/makesymbols.c"
fi
if [ `wc -c ./include/local/makesymbols.c | awk '{printf $1}'` -ne 2270 ]
then
echo `wc -c ./include/local/makesymbols.c | awk '{print "Got " $1 ", Expected " 2270}'`
fi
if `test ! -s ./include/local/dio.h`
then
echo "writing ./include/local/dio.h"
cat > ./include/local/dio.h << '\Rogue\Monster\'

/*
 * DIO.H
 *
 *  (C)Copyright 1987 Matthew Dillon, All Rights Reserved
 *  Freely distributable.  Donations welcome, I guess.
 *
 *	Matthew Dillon
 *	891 Regal Rd.
 *	Berkeley, Ca.	94708
 *
 */

#ifndef LOCAL_DIO_H
#define LOCAL_DIO_H
#include <exec/types.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <exec/ports.h>
#include <devices/timer.h>
#ifndef LOCAL_TYPEDEFS_H
#include <local/typedefs.h>
#endif

typedef struct IORequest IOR;
typedef struct IOStdReq  STD;

/*
 *	'to' is in microsections.  The IO request structure
 *  pointer is optional to dio_open().  If NULL, dio_open()
 *  initializes it's own IO request (to mostly zero).  You have
 *  to provide an IO request structure, for instance, if openning
 *  a console device since the window pointer must be passed to
 *  OpenDevice().
 *
 *	each DFD descriptor has it's own signal.
 *
 *	dio_isdone() returns 1 if the channel is clear, 0 otherwise.
 */

extern long dio_open();         /* dfd    = dio_open(devname,unit,flags,req)*/
extern long dio_dup();          /* newdfd = dio_dup(dfd)    */
extern STD *dio_ctl();          /* req  = dio_ctl(dfd,com,buf,len)          */
extern STD *dio_ctl_to();       /* req  = dio_ctl_to(dfd,com,buf,len,to)    */
extern STD *dio_wait();         /* req  = dio_wait(dfd)     */
extern STD *dio_abort();        /* req  = dio_abort(dfd)    */
extern STD *dio_isdone();       /* req  = dio_isdone(dfd)   */
extern int dio_signal();        /* signm= dio_signal(dfd)   */
extern void dio_close();        /*  dio_close(dfd)          */
extern void dio_cloesgroup();   /*  dio_closegroup(dfd)     */
extern void dio_cact();         /*  dio_cact(dfd,bool)      */



/*
 * dio_simple() and related macros return the !io_Error field. That
 * is, 0=ERROR, 1=OK
 *
 * dio_actual() returns the io_Actual field.
 *
 * NOTE: the io_Actual field may not be set by the device if an
 * error condition exists.  To make the io_ctl() and io_ctl_to()
 * call automatically clear the io_Actual field before doing the
 * io operation, use the DIO_CACT() call.  The reason this isn't
 * done automatically by default is that some devices require
 * parameters to be passed in the io_Actual field (like the
 * timer.device).
 *
 *  Remember, Asyncronous IO is done by sending -com instead of com.
 *
 *	CALL			    Syncronous IO   Asyncronous IO
 *
 *  dio_simple(dfd,com)             0=ERROR, 1=OK   undefined
 *  dio_actual(dfd,com)             io_Actual       undefined
 *  dio_reset(dfd)                  0=ERROR, 1=OK   n/a
 *  dio_update(dfd)                 0=ERROR, 1=OK   n/a
 *  dio_clear(dfd)                  0=ERROR, 1=OK   n/a
 *  dio_stop(dfd)                   0=ERROR, 1=OK   n/a
 *  dio_start(dfd)                  0=ERROR, 1=OK   n/a
 *  dio_flush(dfd)                  0=ERROR, 1=OK   n/a
 *  dio_getreq(dfd)                 returns a ptr to the IO
 *				    request structure
 *  NOTE: If you use the following, you probably want to have the
 *  device library automatically clear the io_Actual field before
 *  sending the request so you get 0 if an error occurs.  That
 *  is: dio_cact(dfd,1);
 *
 *
 *  dio_read(dfd,buf,len)           returns actual bytes read
 *  dio_write(dfd,buf,len)          returns actual bytes written
 *
 *	The timeout argument for dio_readto() and dio_writeto()
 *	is in MICROSECONDS, up to 2^31uS.
 *
 *  dio_readto(dfd,buf,len,to)      returns actual bytes read
 *  dio_writeto(dfd,buf,len,to)     returns actual bytes written
 *
 *	The asyncronous dio_reada() and dio_writea() do not
 *	return anything.
 *
 *  dio_reada(dfd,buf,len)          begin asyncronous read
 *  dio_writea(dfd,buf,len)         begin asyncronous write
 */

#define dio_mask(dfd)           (1 << dio_signal(dfd))

#define dio_simple(dfd,com)     (!dio_ctl(dfd,com,0,0)->io_Error)
#define dio_actual(dfd,com)     ( dio_ctl(dfd,com,0,0)->io_Actual)
#define dio_reset(dfd)          dio_simple(dfd,CMD_RESET)
#define dio_update(dfd)         dio_simple(dfd,CMD_UPDATE)
#define dio_clear(dfd)          dio_simple(dfd,CMD_CLEAR)
#define dio_stop(dfd)           dio_simple(dfd,CMD_STOP)
#define dio_start(dfd)          dio_simple(dfd,CMD_START)
#define dio_flush(dfd)          dio_simple(dfd,CMD_FLUSH)
#define dio_getreq(dfd)         dio_ctl(dfd,0,0,0)

#define dio_read(dfd,buf,len)       (dio_ctl(dfd,CMD_READ,buf,len)->io_Actual)
#define dio_write(dfd,buf,len)      (dio_ctl(dfd,CMD_WRITE,buf,len)->io_Actual)
#define dio_readto(dfd,buf,len,to)  (dio_ctl_to(dfd,CMD_READ,buf,len,to)->io_Actual)
#define dio_writeto(dfd,buf,len,to) (dio_ctl_to(dfd,CMD_WRITE,buf,len,to)->io_Actual)
#define dio_reada(dfd,buf,len)      ((void)dio_ctl(dfd,-CMD_READ,buf,len))
#define dio_writea(dfd,buf,len)     ((void)dio_ctl(dfd,-CMD_WRITE,buf,len))

#endif


\Rogue\Monster\
else
  echo "will not over write ./include/local/dio.h"
fi
if [ `wc -c ./include/local/dio.h | awk '{printf $1}'` -ne 4754 ]
then
echo `wc -c ./include/local/dio.h | awk '{print "Got " $1 ", Expected " 4754}'`
fi
if `test ! -d ./suplib`
then
  mkdir ./suplib
  echo "mkdir ./suplib"
fi
if `test ! -s ./suplib/mntreq.c`
then
echo "writing ./suplib/mntreq.c"
cat > ./suplib/mntreq.c << '\Rogue\Monster\'

extern struct Process *FindTask();

mountrequest(bool)
{
    static APTR original_pr_WindowPtr;
    register struct Process *proc;

    proc = FindTask(0);
    if (!bool && proc->pr_WindowPtr != (APTR)-1) {
	original_pr_WindowPtr = proc->pr_WindowPtr;
	proc->pr_WindowPtr = (APTR)-1;
    }
    if (bool && proc->pr_WindowPtr == (APTR)-1)
	proc->pr_WindowPtr = original_pr_WindowPtr;
}


\Rogue\Monster\
else
  echo "will not over write ./suplib/mntreq.c"
fi
if [ `wc -c ./suplib/mntreq.c | awk '{printf $1}'` -ne 388 ]
then
echo `wc -c ./suplib/mntreq.c | awk '{print "Got " $1 ", Expected " 388}'`
fi
if `test ! -s ./suplib/bset.asm`
then
echo "writing ./suplib/bset.asm"
cat > ./suplib/bset.asm << '\Rogue\Monster\'

		public	_bzero		; Zero a block of memory
		public	_bset		; Set a block of memory to (byte val)

		;   BSET(buffer, len, byte)
		;   BZERO(buffer, len)

		public	_bset
		public	_bzero

_bzero: 	moveq.l #0,D1
		bra	.bz0
_bset:		move.b	12+3(sp),D1
.bz0		move.l	4(sp),A0
		move.l	8(sp),D0

		add.l	D0,A0	    ; start at end of address
		cmp.l	#40,D0	    ; unscientifically chosen
		bls	.bs2
		bra	.bs10
.bs1		move.b	D1,-(A0)    ; any count < 65536
.bs2		dbf	D0,.bs1
		rts

				    ; at least 2 bytes in count (D0)
.bs10		movem.l D2-D7/A2-A6,-(sp)   ;ant count > 4
		move.l	A0,D2
		btst.l	#0,D2	    ; is it aligned?
		beq	.bs22
		move.b	D1,-(A0)    ; no, copy one byte
		subq.l	#1,D0

.bs22		andi.l	#$FF,D1     ; expand data D1.B -> D2-D7/A1-A6
		move.l	D1,D2	    ; D1 000000xx   D2 000000xx
		asl.w	#8,D2	    ;		       0000xx00
		or.w	D2,D1	    ;	 0000xxxx
		move.w	D1,D2	    ;	 0000xxxx      0000xxxx
		swap	D2	    ;	 0000xxxx      xxxx0000
		or.l	D1,D2	    ; D2.L
		move.l	D2,D3
		move.l	D2,D4
		move.l	D2,D5
		move.l	D2,D6
		move.l	D2,D7
		move.l	D2,A1
		move.l	D2,A2
		move.l	D2,A3
		move.l	D2,A4
		move.l	D2,A5
		move.l	D2,A6	    ; D2-D7/A1-A6   (12 registers)
		move.l	#12*4,D1    ; bytes per transfer (48)
.bs30		sub.l	D1,D0	    ; pre subtract
		bmi	.bs40
.bs31		movem.l D2-D7/A1-A6,-(A0)
		sub.l	D1,D0
		bpl	.bs31
.bs40		add.w	D1,D0	    ; less than 48 bytes remaining

		move.w	#4,D1	    ; by 4's
		sub.w	D1,D0
		bmi	.bs50
.bs41		move.l	D2,-(A0)
		sub.w	D1,D0
		bpl	.bs41
.bs50		add.w	D1,D0
		bra	.bs52
.bs51		move.b	D2,-(A0)    ; by 1's
.bs52		dbf	D0,.bs51
		movem.l (sp)+,D2-D7/A2-A6
		rts

\Rogue\Monster\
else
  echo "will not over write ./suplib/bset.asm"
fi
if [ `wc -c ./suplib/bset.asm | awk '{printf $1}'` -ne 1598 ]
then
echo `wc -c ./suplib/bset.asm | awk '{print "Got " $1 ", Expected " 1598}'`
fi
if `test ! -s ./suplib/resetbreak.c`
then
echo "writing ./suplib/resetbreak.c"
cat > ./suplib/resetbreak.c << '\Rogue\Monster\'

/*
 * reset the break signal and return the break status
 */

#define SBF (SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D)

resetbreak()
{
    return(SetSignal(0,SBF) & SBF);
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/resetbreak.c"
fi
if [ `wc -c ./suplib/resetbreak.c | awk '{printf $1}'` -ne 166 ]
then
echo `wc -c ./suplib/resetbreak.c | awk '{print "Got " $1 ", Expected " 166}'`
fi
if `test ! -s ./suplib/scandir.c`
then
echo "writing ./suplib/scandir.c"
cat > ./suplib/scandir.c << '\Rogue\Monster\'

/*
 *  SCANDIR.C
 *
 *  SD {
 *	SD *next;
 *	char buf[];
 *  };
 *
 *  SD *sd;
 *
 *  sd = ScanDir(dir, match)
 *	 FreeDirScan(sd)
 */

#include <local/typedefs.h>

#define SD  struct _SD
#define DBLK	32
#define ALIGNL(ptr) (void *)(((long)ptr + 3) & ~3)

SD {
    SD	    *next;
    char    buf[4];
};

/*BREAKUP   ScanDir.c	*/
SD *
ScanDir(dir, match, abortflag)
char *dir, *match;
char *abortflag;
{
    char buf[sizeof(FIB)+3];
    register FIB *fib = ALIGNL(buf);
    register SD  *sd;
    SD	*sbase;
    long lock;
    char ok = 0;

    geta4();
    sd = (SD *)&sbase;
    lock = Lock(dir, SHARED_LOCK);
    if (lock && Examine(lock, fib) && fib->fib_DirEntryType > 0) {
	while (ExNext(lock, fib)) {
	    if (*abortflag)
		break;
	    if (wildcmp(match, fib->fib_FileName)) {
		sd->next = AllocMem(sizeof(SD) - 3 + strlen(fib->fib_FileName), MEMF_PUBLIC);
		sd = sd->next;
		strcpy(sd->buf, fib->fib_FileName);
	    }
	}
	UnLock(lock);
	sd->next = NULL;
	return(sbase);
    }
    if (lock)
	UnLock(lock);
    return(NULL);
}

/*BREAKUP   FreeDirScan.c   */
void
FreeDirScan(sd)
register SD *sd;
{
    register SD *nextsd;

    geta4();
    while (sd) {
	nextsd = sd->next;
	FreeMem(sd, sizeof(SD) - 3 + strlen(sd->buf));
	sd = nextsd;
    }
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/scandir.c"
fi
if [ `wc -c ./suplib/scandir.c | awk '{printf $1}'` -ne 1250 ]
then
echo `wc -c ./suplib/scandir.c | awk '{print "Got " $1 ", Expected " 1250}'`
fi
if `test ! -s ./suplib/initdeemunw.c`
then
echo "writing ./suplib/initdeemunw.c"
cat > ./suplib/initdeemunw.c << '\Rogue\Monster\'

/*
 *  DEEMU NW structure auto init.
 *
 *  Intuition must be openned.
 */

typedef struct NewWindow NW;
typedef struct Screen	 SCR;

InitDeemuNW(ary, nw)
register short *ary;
register NW *nw;
{
    register short alen = ary[3];
    SCR Scr;

    if (GetScreenData(&Scr, sizeof(Scr), nw->Type, nw->Screen) == 0) {
	Scr.Width = 320;
	Scr.Height= 200;
    }
    if (alen >= 8) {
	if ((nw->Width   = ary[6]) < 0)
	    nw->Width += Scr.Width;
	if ((nw->Height  = ary[7]) < 0)
	    nw->Height+= Scr.Height;
    }
    if (alen >= 4) {
	if ((nw->LeftEdge= ary[4]) < 0)
	    nw->LeftEdge += Scr.Width - nw->Width;
	if ((nw->TopEdge = ary[5]) < 0)
	    nw->TopEdge += Scr.Height - nw->Height;
    }
    if (nw->LeftEdge < 0 || nw->TopEdge < 0 || nw->Width < 0 || nw->Height < 0 ||
	nw->LeftEdge + nw->Width > Scr.Width || nw->TopEdge + nw->Height > Scr.Height) {

	nw->LeftEdge = nw->TopEdge = 0;
	nw->Width = 320;
	nw->Height= 100;
    }
    if (alen >= 9)
	nw->DetailPen = ary[8] >> 8;
    if (alen >= 10)
	nw->BlockPen  = ary[8];
}


\Rogue\Monster\
else
  echo "will not over write ./suplib/initdeemunw.c"
fi
if [ `wc -c ./suplib/initdeemunw.c | awk '{printf $1}'` -ne 1029 ]
then
echo `wc -c ./suplib/initdeemunw.c | awk '{print "Got " $1 ", Expected " 1029}'`
fi
if `test ! -s ./suplib/tags`
then
echo "writing ./suplib/tags"
cat > ./suplib/tags << '\Rogue\Monster\'
NewAsyncOp asyncop.c /^NewAsyncOp(
StartAsyncOp asyncop.c /^StartAsyncOp(
CheckAsyncOp asyncop.c /^CheckAsyncOp(
WaitAsyncOp asyncop.c /^WaitAsyncOp(
CloseAsyncOp asyncop.c /^CloseAsyncOp(
asyhandler asyncop.c /^asyhandler(
disablebreak break.c /^disablebreak(
enablebreak break.c /^enablebreak(
checkbreak checkbreak.c /^checkbreak(
GetConWindow conwin.c /^GetConWindow(
datetos datetos.c /^datetos(
dio_open dio.c /^dio_open(
dio_dfm dio.c /^dio_dfm(
dio_ddl dio.c /^dio_ddl(
dio_cact dio.c /^dio_cact(
dio_close dio.c /^dio_close(
dio_closegroup dio.c /^dio_closegroup(
dio_dup dio.c /^dio_dup(
dio_signal dio.c /^dio_signal(
dio_flags dio.c /^dio_flags(
dio_ctl_to dio.c /^dio_ctl_to(
dio_ctl dio.c /^dio_ctl(
dio_isdone dio.c /^dio_isdone(
dio_wait dio.c /^dio_wait(
dio_abort dio.c /^dio_abort(
llink llink.c /^llink(
lunlink lunlink.c /^lunlink(
mountrequest mntreq.c /^mountrequest(
openlibs openlibs.c /^openlibs(
closelibs openlibs.c /^closelibs(
resetbreak resetbreak.c /^resetbreak(
ScanDir scandir.c /^ScanDir(
FreeDirScan scandir.c /^FreeDirScan(
setfiledate setfiledate.c /^setfiledate(
wildcmp wildcmp.c /^wildcmp(
xfopen xfio.c /^xfopen(
xfclose xfio.c /^xfclose(
xfgets xfio.c /^xfgets(
xfread xfio.c /^xfread(
xfwrite xfio.c /^xfwrite(
xfstartasync xfio.c /^xfstartasync(
bcmp bcmp.asm /^_bcmp
bset bset.asm /^_bset
bmov bmov.asm /^_bmov
bzero bset.asm /^_bzero
fhprintf fhprintf.asm /^_fhprintf
AutoAllocMiscResource resource.asm /^_AutoAllocMiscResource
AutoFreeMiscResource /^_AutoFreeMiscResource


\Rogue\Monster\
else
  echo "will not over write ./suplib/tags"
fi
if [ `wc -c ./suplib/tags | awk '{printf $1}'` -ne 1522 ]
then
echo `wc -c ./suplib/tags | awk '{print "Got " $1 ", Expected " 1522}'`
fi
if `test ! -s ./suplib/xfio.c`
then
echo "writing ./suplib/xfio.c"
cat > ./suplib/xfio.c << '\Rogue\Monster\'

/*
 *  XFIO.C
 *
 *  Simple File IO with asyncronous READ and WRITE capability
 *  Perfect for protocol transfer applications
 *
 *  xfi = xfopen(name, modes, bufsize)	("r", "w", "w+")
 *   n	= xfread(xfi, buf, bytes)   ASYNCRONOUS READ
 *  err = xfwrite(xfi, buf, bytes)  ASYNCRONOUS WRITE
 *  err = xfclose(xfi)
 *
 *  RESTRICTIONS:   NO seeking.  You can do one of xfread() or xfwrite()
 *  for a given open XFIle handle (not both).
 *
 *  xfwrite() returns a cumulative error (once an error occurs, it will not
 *  do any more writes).  xfclose() returns the cumulative write error
 *  (since the last write may have been asyncronous and thus the error
 *  unknown at the time).
 *
 *  Two buffers are created each bufsize/2 bytes in size.  for writing,
 *  one buffers is sent asyncronously while the other fills.  For reading,
 *  one buffer is filling while the other is being read.
 */

#define XFI	    struct _XFI
#define XFBUF	    struct _XFBUF
#define MSGPORT     struct MsgPort
#define FH	    struct FileHandle
#define STDPKT	    struct StandardPacket


XFBUF {
    long   bufsize;
    long   idx;
    long   max;
    char    buf[4];	/*  actually bufsize bytes long */
};

XFI {
    char    ro; 	/*  read only, else write only	*/
    char    pend;	/*  packet pending		*/
    char    err;	/*  cumulative error		*/
    char    reserved;
    XFBUF   *asbuf;
    XFBUF   *usbuf;
    FH	    *fh;
    STDPKT  sp; 	/*  asyncronous message 	*/
    MSGPORT rp; 	/*  reply port for pending pkts */
};

extern FH *Open();
extern void *malloc(), *FindTask();

void *
xfopen(file, mode, bytes)
char *file;
char *mode;
{
    register XFI *xfi = malloc(sizeof(XFI));
    register long nbytes = bytes >> 1;
    int ap = 0;

    bzero(xfi, sizeof(XFI));
    if (mode[0] == 'w') {
	if (mode[1] == '+') {
	    ap = 1;
	    if ((xfi->fh = Open(file, 1005)) == NULL)
		xfi->fh = Open(file, 1006);
	    goto ok;
	}
	xfi->fh = Open(file, 1006);
	goto ok;
    }
    xfi->fh = Open(file, 1005);
ok:
    if (xfi->fh) {
	if (ap)
	    Seek(xfi->fh, 0, 1);
	xfi->fh = (FH *)((long)xfi->fh << 2);
	xfi->asbuf = malloc(sizeof(XFBUF) + nbytes);	/* a little more    */
	xfi->usbuf = malloc(sizeof(XFBUF) + nbytes);	/* then we need     */
	bzero(xfi->asbuf, sizeof(XFBUF));
	bzero(xfi->usbuf, sizeof(XFBUF));
	xfi->ro = (mode[0] == 'r');
	xfi->asbuf->bufsize = xfi->usbuf->bufsize = nbytes;
	xfi->rp.mp_Node.ln_Type = NT_MSGPORT;
	xfi->rp.mp_Node.ln_Name = "XFIO-Async";
	xfi->rp.mp_Flags = PA_SIGNAL;
	xfi->rp.mp_SigBit = AllocSignal(-1);
	xfi->rp.mp_SigTask = FindTask(NULL);
	NewList(&xfi->rp.mp_MsgList);
	if (xfi->ro)
	    xfstartasync(xfi, ACTION_READ);
    } else {
	free(xfi);
	xfi = NULL;
    }
    return(xfi);
}

xfclose(xfi)
register XFI *xfi;
{
    int err = 1;
    if (xfi) {
	if (xfi->pend) {
	    xfi->pend = 0;
	    WaitPort (&xfi->rp);
	    GetMsg   (&xfi->rp);
	}
	if (!xfi->ro && xfi->usbuf->idx)
	    Write((long)xfi->fh >> 2, xfi->usbuf->buf, xfi->usbuf->idx);
	err = xfi->err;
	Close((long)xfi->fh >> 2);
	free(xfi->asbuf);
	free(xfi->usbuf);
	FreeSignal(xfi->rp.mp_SigBit);
	free(xfi);
    }
    return(err);
}

xfgets(xfi, buf, n)
XFI *xfi;
char *buf;
{
    register XFBUF *usbuf = xfi->usbuf;
    register int i, idx;
    if (!xfi->ro)
	return(-1);
    --n;
    for (i = 0;;) {
	for (idx = usbuf->idx; idx < usbuf->max && i < n; ++idx, ++i) {
	    if ((buf[i] = usbuf->buf[idx]) == '\n') {
		buf[i] = 0;
		usbuf->idx = idx+1;
		return(i);
	    }
	}
	usbuf->idx = idx;
	buf[i] = 0;
	if (i == n)
	    return(i);
	if (xfi->pend == 0)				/* EOF	    */
	    return(-1);
	WaitPort (&xfi->rp);
	GetMsg	 (&xfi->rp);
	xfi->pend = 0;
	if (xfi->sp.sp_Pkt.dp_Res1 <= 0) {		/* EOF	    */
	    if (i == 0)
		return(-1);
	    return(i);
	}
	xfi->asbuf->max = xfi->sp.sp_Pkt.dp_Res1;
	xfi->asbuf->idx = 0;
	usbuf = xfi->asbuf;				/* swap bufs*/
	xfi->asbuf = xfi->usbuf;
	xfi->usbuf = usbuf;
	xfstartasync(xfi, ACTION_READ); 		/* new async*/
    }
}


xfread(xfi, buf, n)
XFI *xfi;
char *buf;
{
    register XFBUF *usbuf = xfi->usbuf;
    register int orig = n;
    register int diff;

    if (!xfi->ro)
	return(0);
    while ((diff = usbuf->max - usbuf->idx) < n) {
	movmem(usbuf->buf + usbuf->idx, buf, diff);	/* copy entire buf */
	buf += diff;
	n -= diff;
	if (xfi->pend == 0) {
	    xfi->usbuf->idx = xfi->usbuf->max;
	    return(orig - n);
	}
	WaitPort (&xfi->rp);
	GetMsg	 (&xfi->rp);
	xfi->pend = 0;
	if (xfi->sp.sp_Pkt.dp_Res1 <= 0) {		/* EOF	    */
	    xfi->usbuf->idx = xfi->usbuf->max;
	    return(orig - n);
	}
	xfi->asbuf->max = xfi->sp.sp_Pkt.dp_Res1;
	xfi->asbuf->idx = 0;
	usbuf = xfi->asbuf;				/* swap bufs*/
	xfi->asbuf = xfi->usbuf;
	xfi->usbuf = usbuf;
	xfstartasync(xfi, ACTION_READ); 		/* new async*/
    }
    movmem(usbuf->buf + usbuf->idx, buf, n);
    usbuf->idx += n;
    return(orig);
}

xfwrite(xfi, buf, n)
XFI *xfi;
char *buf;
{
    register XFBUF *usbuf = xfi->usbuf;
    register int diff;

    if (xfi->ro || xfi->err)
	return(1);
    while ((diff = usbuf->bufsize - usbuf->idx) < n) {
	movmem(buf, usbuf->buf + usbuf->idx, diff);	/*  copy buf	*/
	buf += diff;
	n -= diff;
	if (xfi->pend) {
	    WaitPort(&xfi->rp);
	    GetMsg  (&xfi->rp);
	    xfi->pend = 0;
	    if (xfi->sp.sp_Pkt.dp_Res1 != xfi->sp.sp_Pkt.dp_Arg3) {
		xfi->err = 1;
		return(1);
	    }
	}
	usbuf = xfi->asbuf;
	xfi->asbuf = xfi->usbuf;
	xfi->usbuf = usbuf;
	usbuf->idx = 0;
	xfstartasync(xfi, ACTION_WRITE);
    }
    movmem(buf, usbuf->buf + usbuf->idx, n);
    usbuf->idx += n;
    return(xfi->err);
}

static
xfstartasync(xfi, action)
register XFI *xfi;
{
    xfi->sp.sp_Msg.mn_Node.ln_Name = (char *)&(xfi->sp.sp_Pkt);
    xfi->sp.sp_Pkt.dp_Link = &(xfi->sp.sp_Msg);
    xfi->sp.sp_Pkt.dp_Port = &xfi->rp;
    xfi->sp.sp_Pkt.dp_Type = action;
    xfi->sp.sp_Pkt.dp_Arg1 = xfi->fh->fh_Arg1;
    xfi->sp.sp_Pkt.dp_Arg2 = (long)xfi->asbuf->buf;
    xfi->sp.sp_Pkt.dp_Arg3 = xfi->asbuf->bufsize;
    PutMsg (xfi->fh->fh_Type, &xfi->sp);
    xfi->pend = 1;
}


\Rogue\Monster\
else
  echo "will not over write ./suplib/xfio.c"
fi
if [ `wc -c ./suplib/xfio.c | awk '{printf $1}'` -ne 5958 ]
then
echo `wc -c ./suplib/xfio.c | awk '{print "Got " $1 ", Expected " 5958}'`
fi
if `test ! -s ./suplib/closelibs.c`
then
echo "writing ./suplib/closelibs.c"
cat > ./suplib/closelibs.c << '\Rogue\Monster\'

/*
 * CLOSELIBS(mask)
 *
 *	Close the indicated libraries.	Does not close libraries which
 *	have not been openned.
 */

#include "xmisc.h"

extern struct OLI strvar[];

closelibs(mask)
register unsigned short mask;
{
    register struct OLI *sv;

    for (sv = &strvar[0]; mask && sv->name; mask >>= 1, ++sv){
	if ((mask & 1) && *sv->var) {
	    CloseLibrary(*sv->var);
	    *sv->var = 0L;
	}
    }
}



\Rogue\Monster\
else
  echo "will not over write ./suplib/closelibs.c"
fi
if [ `wc -c ./suplib/closelibs.c | awk '{printf $1}'` -ne 406 ]
then
echo `wc -c ./suplib/closelibs.c | awk '{print "Got " $1 ", Expected " 406}'`
fi
if `test ! -s ./suplib/wildcmp.c`
then
echo "writing ./suplib/wildcmp.c"
cat > ./suplib/wildcmp.c << '\Rogue\Monster\'

/*
 * Compare a wild card name with a normal name
 */

#define MAXB   8


wildcmp(wild, name)
char *wild, *name;
{
    register char *w = wild;
    register char *n = name;
    char *back[MAXB][2];
    register short bi = 0;
    register char c1, c2;

    while (*n || *w) {
        switch (*w) {
        case '*':
            if (bi == MAXB) {
                puts ("Too many levels of '*'");
                return (0);
            }
            back[bi][0] = w;
            back[bi][1] = n;
            ++bi;
            ++w;
            continue;
goback:
            --bi;
            while (bi >= 0 && *back[bi][1] == '\0')
                --bi;
            if (bi < 0)
                return (0);
            w = back[bi][0] + 1;
            n = ++back[bi][1];
            ++bi;
            continue;
        case '?':
            if (!*n) {
                if (bi)
                    goto goback;
                return (0);
            }
            break;
        default:
            if ((c1 = *n) >= 'A' && c1 <= 'Z')
                c1 |= 0x20;
            if ((c2 = *w) >= 'A' && c2 <= 'Z')
                c2 |= 0x20;
            if (c1 != c2) {
                if (bi)
                    goto goback;
                return (0);
            }
            break;
        }
        if (*n)  ++n;
        if (*w)  ++w;
    }
    return (1);
}


\Rogue\Monster\
else
  echo "will not over write ./suplib/wildcmp.c"
fi
if [ `wc -c ./suplib/wildcmp.c | awk '{printf $1}'` -ne 1360 ]
then
echo `wc -c ./suplib/wildcmp.c | awk '{print "Got " $1 ", Expected " 1360}'`
fi
if `test ! -s ./suplib/datetos.c`
then
echo "writing ./suplib/datetos.c"
cat > ./suplib/datetos.c << '\Rogue\Monster\'

/*
 *  datetos(date, str, ctl)
 */

#include <local/typedefs.h>

static char dim[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static char *Month[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul",
			   "Aug","Sep","Oct","Nov","Dec" };

char *
datetos(date, str, ctl)
DATESTAMP *date;
char *str;
char *ctl;
{
    long days, years;
    short leap, month;

    if (ctl == NULL)
	ctl = "D M Y h:m:s";
    days = date->ds_Days + 731; 	    /*	1976	    */
    years = days / (365*3+366);             /*  #quad yrs   */
    days -= years * (365*3+366);
    leap = (days < 366);                    /*  is a leap yr*/
    years = 1976 + 4 * years;
    if (!leap) {
	days -= 366;
	++years;
    }
    years += days / 365;
    days -= (days / 365) * 365;
    for (month = 0; (month==1) ? (days >= 28 + leap) : (days >= dim[month]); ++month)
	days -= (month==1) ? (28 + leap) : dim[month];
    {
	register short i = 0;
	for (; *ctl; ++ctl) {
	    switch(*ctl) {
	    case 'h':
		sprintf(str+i, "%02d", date->ds_Minute / 60);
		break;
	    case 'm':
		sprintf(str+i, "%02d", date->ds_Minute % 60);
		break;
	    case 's':
		sprintf(str+i, "%02d", date->ds_Tick / 50 % 60);
		break;
	    case 'Y':
		sprintf(str+i, "%ld", years);
		break;
	    case 'M':
		strcpy(str+i, Month[month]);
		break;
	    case 'D':
		sprintf(str+i,"%2ld", days+1);
		break;
	    default:
		str[i] = *ctl;
		str[i+1] = 0;
		break;
	    }
	    i += strlen(str+i);
	}
    }
    return(str);
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/datetos.c"
fi
if [ `wc -c ./suplib/datetos.c | awk '{printf $1}'` -ne 1466 ]
then
echo `wc -c ./suplib/datetos.c | awk '{print "Got " $1 ", Expected " 1466}'`
fi
if `test ! -s ./suplib/checkbreak.c`
then
echo "writing ./suplib/checkbreak.c"
cat > ./suplib/checkbreak.c << '\Rogue\Monster\'

/*
 * CHECKBREAK()
 *
 *	Return	1 = break pressed,
 *		0 = break not pressed
 */

#define SBF  (SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D)

checkbreak()
{
    return(SetSignal(0,0) & SBF);
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/checkbreak.c"
fi
if [ `wc -c ./suplib/checkbreak.c | awk '{printf $1}'` -ne 185 ]
then
echo `wc -c ./suplib/checkbreak.c | awk '{print "Got " $1 ", Expected " 185}'`
fi
if `test ! -s ./suplib/bcmp.asm`
then
echo "writing ./suplib/bcmp.asm"
cat > ./suplib/bcmp.asm << '\Rogue\Monster\'

		public	_bcmp	    ; compare two blocks of memory

		;   BCMP(src, dst, len)

_bcmp:		move.l	4(sp),A0
		move.l	8(sp),A1
		move.l	12(sp),D0
		beq	.bcsucc
		cmp.w	D0,D0	    ; set Z bit.
		bra	.bc2
.bc1		cmpm.b	(A0)+,(A1)+
.bc2		dbne	D0,.bc1
		bne	.bcfail
		sub.l	#$10000,D0
		bcc	.bc1
.bcsucc 	moveq.l #1,D0
		rts
.bcfail 	moveq.l #0,D0
		rts


		;   OLD BCMP HAD BUGS ... alignment problems.
		;

;		 move.w  D0,D1	     ;longword align address
;		 neg.w	 D1
;		 and.w	 #3,D1
;		 cmp.w	 D0,D0	     ;force Z bit
;		 bra	 .bc2
;.bc1		 cmpm.b  (A0)+,(A1)+
;.bc2		 dbne	 D1,.bc1
;		 bne	 .bcfail
;		 move.l  D0,D1
;		 lsr.l	 #2,D1	     ;# of longwords to compare
;		 cmp.w	 D0,D0	     ;force Z bit
;		 bra	 .bc11
;.bc10		 cmpm.l  (A0)+,(A1)+
;.bc11		 dbne	 D1,.bc10
;		 bne	 .bcfail
;		 sub.l	 #$10000,D0
;		 bcc	 .bc10
;		 and.w	 #3,D0	     ;remaining bytes to compare
;		 cmp.w	 D0,D0	     ;force Z bit
;		 bra	 .bc21
;.bc20		 cmpm.b  (A0)+,(A1)+
;.bc21		 dbne	 D0,.bc20
;		 bne	 .bcfail
;		 moveq.l #1,D0	     ;success!
;		 rts
;.bcfail	 moveq.l #0,D0	     ;failure!
;		 rts

\Rogue\Monster\
else
  echo "will not over write ./suplib/bcmp.asm"
fi
if [ `wc -c ./suplib/bcmp.asm | awk '{printf $1}'` -ne 1074 ]
then
echo `wc -c ./suplib/bcmp.asm | awk '{print "Got " $1 ", Expected " 1074}'`
fi
if `test ! -s ./suplib/bmov.asm`
then
echo "writing ./suplib/bmov.asm"
cat > ./suplib/bmov.asm << '\Rogue\Monster\'

		;   BMOV(src, dst, len)
		;
		;   The memory move algorithm is somewhat more of a mess
		;   since we must do it either ascending or decending.

		public	_bmov
_bmov:		move.l	4(sp),A0
		move.l	8(sp),A1
		move.l	12(sp),D0
		cmp.l	A0,A1		;move to self
		beq	.bmend
		bls	.bmup
.bmdown 	adda.l	D0,A0		;descending copy
		adda.l	D0,A1
		move.w	A0,D1		;CHECK WORD ALIGNED
		btst.l	#0,D1
		bne	.bmdown1
		move.w	A1,D1
		btst.l	#0,D1
		bne	.bmdown1
		cmp.l	#259,D0 	    ;chosen by calculation.
		blo	.bmdown8

		move.l	D0,D1		    ;overhead for bmd44: ~360
		divu	#44,D1
		bvs	.bmdown8	    ;too big (> 2,883,540)
		movem.l D2-D7/A2-A6,-(sp)   ;use D2-D7/A2-A6 (11 regs)
		move.l	#11*4,D0
		bra	.bmd44b
.bmd44a 	sub.l	D0,A0		    ;8		total 214/44bytes
		movem.l (A0),D2-D7/A2-A6    ;12 + 8*11  4.86 cycles/byte
		movem.l D2-D7/A2-A6,-(A1)   ; 8 + 8*11
.bmd44b 	dbf	D1,.bmd44a	    ;10
		swap	D1		    ;D0<15:7> already contain 0
		move.w	D1,D0		    ;D0 = remainder
		movem.l (sp)+,D2-D7/A2-A6

.bmdown8	move.w	D0,D1		    ;D1<2:0> = #bytes left later
		lsr.l	#3,D0		    ;divide by 8
		bra	.bmd8b
.bmd8a		move.l	-(A0),-(A1)         ;20         total 50/8bytes
		move.l	-(A0),-(A1)         ;20         = 6.25 cycles/byte
.bmd8b		dbf	D0,.bmd8a	    ;10
		sub.l	#$10000,D0
		bcc	.bmd8a
		move.w	D1,D0		    ;D0 = 0 to 7 bytes
		and.l	#7,D0
		bne	.bmdown1
		rts

.bmd1a		move.b	-(A0),-(A1)         ;12         total 22/byte
.bmdown1				    ;		= 22 cycles/byte
.bmd1b		dbf	D0,.bmd1a	    ;10
		sub.l	#$10000,D0
		bcc	.bmd1a
		rts

.bmup		move.w	A0,D1		    ;CHECK WORD ALIGNED
		btst.l	#0,D1
		bne	.bmup1
		move.w	A1,D1
		btst.l	#0,D1
		bne	.bmup1
		cmp.l	#259,D0 	    ;chosen by calculation
		blo	.bmup8

		move.l	D0,D1		    ;overhead for bmu44: ~360
		divu	#44,D1
		bvs	.bmup8		    ;too big (> 2,883,540)
		movem.l D2-D7/A2-A6,-(sp)   ;use D2-D7/A2-A6 (11 regs)
		move.l	#11*4,D0
		bra	.bmu44b
.bmu44a 	movem.l (A0)+,D2-D7/A2-A6   ;12 + 8*11  ttl 214/44bytes
		movem.l D2-D7/A2-A6,(A1)    ;8  + 8*11  4.86 cycles/byte
		add.l	D0,A1		    ;8
.bmu44b 	dbf	D1,.bmu44a	    ;10
		swap	D1		    ;D0<15:7> already contain 0
		move.w	D1,D0		    ;D0 = remainder
		movem.l (sp)+,D2-D7/A2-A6

.bmup8		move.w	D0,D1		    ;D1<2:0> = #bytes left later
		lsr.l	#3,D0		    ;divide by 8
		bra	.bmu8b
.bmu8a		move.l	(A0)+,(A1)+         ;20         total 50/8bytes
		move.l	(A0)+,(A1)+         ;20         = 6.25 cycles/byte
.bmu8b		dbf	D0,.bmu8a	    ;10
		sub.l	#$10000,D0
		bcc	.bmu8a
		move.w	D1,D0		    ;D0 = 0 to 7 bytes
		and.l	#7,D0
		bne	.bmup1
		rts

.bmu1a		move.b	(A0)+,(A1)+
.bmup1
.bmu1b		dbf	D0,.bmu1a
		sub.l	#$10000,D0
		bcc	.bmu1a
.bmend		rts


\Rogue\Monster\
else
  echo "will not over write ./suplib/bmov.asm"
fi
if [ `wc -c ./suplib/bmov.asm | awk '{printf $1}'` -ne 2621 ]
then
echo `wc -c ./suplib/bmov.asm | awk '{print "Got " $1 ", Expected " 2621}'`
fi
if `test ! -s ./suplib/semaphore.c`
then
echo "writing ./suplib/semaphore.c"
cat > ./suplib/semaphore.c << '\Rogue\Monster\'

/*
 *  The bindings for the following semaphore functions are incorrect
 *  in the lattice/manx 1.2 clibs:
 *
 *	RemSemaphore
 *	FindSemaphore
 *	AddSemaphore
 */

#include <local/typedefs.h>

#asm
		public	_LVOFindSemaphore
		public	_LVORemSemaphore
		public	_SysBase
		public	_RemSemaphore
		public	_FindSemaphore

_RemSemaphore:	move.l	4(sp),A1
		move.l	_SysBase,A6
		jmp	_LVORemSemaphore(A6)

_FindSemaphore: move.l	4(sp),A1
		move.l	_SysBase,A6
		jmp	_LVOFindSemaphore(A6)

#endasm

extern EXECBASE *SysBase;

AddSemaphore(ss)
SIGSEM *ss;
{
    InitSemaphore(ss);
    Forbid();
    Enqueue(&SysBase->SemaphoreList,ss);
    Permit();
}



\Rogue\Monster\
else
  echo "will not over write ./suplib/semaphore.c"
fi
if [ `wc -c ./suplib/semaphore.c | awk '{printf $1}'` -ne 644 ]
then
echo `wc -c ./suplib/semaphore.c | awk '{print "Got " $1 ", Expected " 644}'`
fi
if `test ! -s ./suplib/llink.c`
then
echo "writing ./suplib/llink.c"
cat > ./suplib/llink.c << '\Rogue\Monster\'

#include <local/xmisc.h>

XLIST *
llink(list, en)
register XLIST *en, **list;
{
    en->next = *list;
    en->prev = list;
    *list = en;
    if (en->next)
	en->next->prev = &en->next;
    return(en);
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/llink.c"
fi
if [ `wc -c ./suplib/llink.c | awk '{printf $1}'` -ne 206 ]
then
echo `wc -c ./suplib/llink.c | awk '{print "Got " $1 ", Expected " 206}'`
fi
if `test ! -s ./suplib/openlibs.c`
then
echo "writing ./suplib/openlibs.c"
cat > ./suplib/openlibs.c << '\Rogue\Monster\'

#include <local/xmisc.h>

static long OpenMask = 0;

long GfxBase;
long IntuitionBase;
long ExpansionBase;
long DiskfontBase;
long TranslatorBase;
long IconBase;
long MathBase;
long MathTransBase;
long MathIeeeDoubBasBase;
long MathIeeeSingBasBase;
long LayersBase;
long ClistBase;
long PotgoBase;
long TimerBase;
long DResBase;
long xfiller15;

struct OLI {
    char *name;
    long *var;
};

struct OLI strvar[] = {
  "graphics",           &GfxBase,
  "intuition",          &IntuitionBase,
  "expansion",          &ExpansionBase,
  "diskfont",           &DiskfontBase,
  "translator",         &TranslatorBase,
  "icon",               &IconBase,
  "mathffp",            &MathBase,
  "mathtrans",          &MathTransBase,
  "mathieeedoubbas",    &MathIeeeDoubBasBase,
  "mathieeesingbas",    &MathIeeeSingBasBase,
  "layers",             &LayersBase,
  "clist",              &ClistBase,
  "potgo",              &PotgoBase,
  "timer",              &TimerBase,
  "dres",               &DResBase,
  "x15",                &xfiller15
};


openlibs(mask)
unsigned short mask;
{
    register struct OLI *sv;
    register short i;
    char buf[64];

    for (i = 0; i < sizeof(strvar)/sizeof(strvar[0]); ++i) {
	sv = strvar + i;
	if (mask & (1 << i)) {
	    strcpy(buf, sv->name);
	    strcat(buf, ".library");
	    if (*sv->var == 0 && (*sv->var = OpenLibrary(buf, 0L)) == 0) {
		closelibs(mask);
		return(0);
	    }
	    OpenMask |= 1 << i;
	}
    }
    return(1);
}

/*
 * CLOSELIBS(mask)
 *
 *	Close the indicated libraries.	Does not close libraries which
 *	have not been openned with OPENLIBS()
 */

closelibs(mask)
unsigned short mask;
{
    register struct OLI *sv;
    register short i;

    for (i = 0; i < sizeof(strvar)/sizeof(strvar[0]); ++i) {
	sv = strvar + i;
	if ((mask & (1 << i)) && *sv->var && (OpenMask & (1 << i))) {
	    CloseLibrary(*sv->var);
	    *sv->var = 0L;
	    OpenMask &= ~(1 << i);
	}
    }
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/openlibs.c"
fi
if [ `wc -c ./suplib/openlibs.c | awk '{printf $1}'` -ne 1921 ]
then
echo `wc -c ./suplib/openlibs.c | awk '{print "Got " $1 ", Expected " 1921}'`
fi
if `test ! -s ./suplib/dead.c`
then
echo "writing ./suplib/dead.c"
cat > ./suplib/dead.c << '\Rogue\Monster\'

/*
 *
 *
 */


DeadKeyConvert(msg,buf,bufsize,keymap)
struct IntuiMessage *msg;
UBYTE *buf;
int bufsize;
struct KeyMap *keymap;
{
    static struct InputEvent ievent = { NULL, IECLASS_RAWKEY };
    if (msg->Class != RAWKEY)
	return(-2);
    ievent.ie_Code = msg->Code;
    ievent.ie_Qualifier = msg->Qualifier;
    ievent.ie_position.ie_addr = *((APTR *)msg->IAddress);
    return(RawKeyConvert(&ievent,buf,bufsize,keymap));
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/dead.c"
fi
if [ `wc -c ./suplib/dead.c | awk '{printf $1}'` -ne 429 ]
then
echo `wc -c ./suplib/dead.c | awk '{print "Got " $1 ", Expected " 429}'`
fi
if `test ! -s ./suplib/getfont.c`
then
echo "writing ./suplib/getfont.c"
cat > ./suplib/getfont.c << '\Rogue\Monster\'

/*
 *  This function properly searches resident and disk fonts for the
 *  font.
 *
 */

#include <local/typedefs.h>
#include <local/xmisc.h>

extern long DiskfontBase;

FONT *
GetFont(name, size)
char *name;
short size;
{
    register FONT *font1;
    TA Ta;
    short libwasopen = (DiskfontBase != NULL);

    Ta.ta_Name	= (ubyte *)name;
    Ta.ta_YSize = size;
    Ta.ta_Style = 0;
    Ta.ta_Flags = 0;

    font1 = OpenFont(&Ta);
    if (font1 == NULL || font1->tf_YSize != Ta.ta_YSize) {
	register FONT *font2;

	if (openlibs(DISKFONT_LIB)) {
	    if (font2 = OpenDiskFont(&Ta)) {
		if (font1)
		    CloseFont(font1);
		font1 = font2;
	    }
	    if (!libwasopen)
		closelibs(DISKFONT_LIB);
	}
    }
    return(font1);
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/getfont.c"
fi
if [ `wc -c ./suplib/getfont.c | awk '{printf $1}'` -ne 728 ]
then
echo `wc -c ./suplib/getfont.c | awk '{print "Got " $1 ", Expected " 728}'`
fi
if `test ! -s ./suplib/Makefile`
then
echo "writing ./suplib/Makefile"
cat > ./suplib/Makefile << '\Rogue\Monster\'

#   Aztec C V3.6 Makefile for sup32.lib, A link-time support library
#   Required to compile most of my sources (DME, etc...)
#
#   Some modifications might be required.  I am not sure if the 3.4 Make
#   support output redirection.



SYMS=	include:symbols.m
SYMC=	include:local/makesymbols.c
SYMR=	T:symbols.m

DEST = clib:sup32.lib
CFLAGS = +BCDL +I$(SYMR)
AFLAGS =

SR01 = checkbreak.c
SR02 = dio.c
SR03 = break.c
SR04 = scandir.c
SR05 = initdeemunw.c
SR06 = mntreq.c
SR07 = openlibs.c
SR08 = resetbreak.c
SR09 = asyncop.c
SR10 = getfont.c
SR11 = wildcmp.c
SR12 = bcmp.asm
SR13 = bmov.asm
SR14 = bset.asm
SR15 = fhprintf.asm
SR16 = xfio.c
SR17 = conwin.c
SR18 = semaphore.c
SR19 = resource.asm
SR20 = llink.c
SR21 = lunlink.c
SR22 = setfiledate.c
SR23 = datetos.c
SR24 = enviroment.c
SR25 = dead.c

OB01 = T:checkbreak.o
OB02 = T:dio.o
OB03 = T:break.o
OB04 = T:scandir.o
OB05 = T:initdeemunw.o
OB06 = T:mntreq.o
OB07 = T:openlibs.o
OB08 = T:resetbreak.o
OB09 = T:asyncop.o
OB10 = T:getfont.o
OB11 = T:wildcmp.o
OB12 = T:bcmp.o
OB13 = T:bmov.o
OB14 = T:bset.o
OB15 = T:fhprintf.o
OB16 = T:xfio.o
OB17 = T:conwin.o
OB18 = T:semaphore.o
OB19 = T:resource.o
OB20 = T:llink.o
OB21 = T:lunlink.o
OB22 = T:setfiledate.o
OB23 = T:datetos.o
OB24 = T:enviroment.o
OB25 = T:dead.o

SRC1 =	       $(SR01) $(SR02) $(SR03) $(SR04)
SRC2 = $(SR05) $(SR06) $(SR07) $(SR08) $(SR09)
SRC3 = $(SR10) $(SR11) $(SR12) $(SR13) $(SR14)
SRC4 = $(SR15) $(SR16) $(SR17) $(SR18) $(SR19)
SRC5 = $(SR20) $(SR21) $(SR22) $(SR23) $(SR24)
SRC6 = $(SR25)

OBJ1 =	       $(OB01) $(OB02) $(OB03) $(OB04)
OBJ2 = $(OB05) $(OB06) $(OB07) $(OB08) $(OB09)
OBJ3 = $(OB10) $(OB11) $(OB12) $(OB13) $(OB14)
OBJ4 = $(OB15) $(OB16) $(OB17) $(OB18) $(OB19)
OBJ5 = $(OB20) $(OB21) $(OB22) $(OB23) $(OB24)
OBJ6 = $(OB25)


all:	$(SYMR) $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ5) $(OBJ6)
	-delete $(DEST)
	Echo "$(OBJ1)" >T:ORD1
	Echo "$(OBJ2)" >T:ORD2
	Echo "$(OBJ3)" >T:ORD3
	Echo "$(OBJ4)" >T:ORD4
	Echo "$(OBJ5)" >T:ORD5
	Echo "$(OBJ6)" >T:ORD6
	Join T:ORD1 T:ORD2 T:ORD3 T:ORD4 T:ORD5 T:ORD6 AS T:ORDIN
	Ord T:ORDIN T:ORDOUT
	Lb $(DEST) -f T:ORDOUT
	delete T:ORDIN T:ORDOUT T:ORD1 T:ORD2 T:ORD3 T:ORD4 T:ORD5 T:ORD6


clean:
	-delete $(OBJ1)
	-delete $(OBJ2)
	-delete $(OBJ3)
	-delete $(OBJ4)
	-delete $(OBJ5)
	-delete $(OBJ6)

$(OB01) : $(SR01)
    cc $(CFLAGS) $(SR01) -o $(OB01)
$(OB02) : $(SR02)
    cc $(CFLAGS) $(SR02) -o $(OB02)
$(OB03) : $(SR03)
    cc $(CFLAGS) $(SR03) -o $(OB03)
$(OB04) : $(SR04)
    cc $(CFLAGS) $(SR04) -o $(OB04)
$(OB05) : $(SR05)
    cc $(CFLAGS) $(SR05) -o $(OB05)
$(OB06) : $(SR06)
    cc $(CFLAGS) $(SR06) -o $(OB06)
$(OB07) : $(SR07)
    cc $(CFLAGS) $(SR07) -o $(OB07)
$(OB08) : $(SR08)
    cc $(CFLAGS) $(SR08) -o $(OB08)
$(OB09) : $(SR09)
    cc $(CFLAGS) $(SR09) -o $(OB09)
$(OB10) : $(SR10)
    cc $(CFLAGS) $(SR10) -o $(OB10)
$(OB11) : $(SR11)
    cc $(CFLAGS) $(SR11) -o $(OB11)
$(OB12) : $(SR12)
    as $(AFLAGS) $(SR12) -o $(OB12)
$(OB13) : $(SR13)
    as $(AFLAGS) $(SR13) -o $(OB13)
$(OB14) : $(SR14)
    as $(AFLAGS) $(SR14) -o $(OB14)
$(OB15) : $(SR15)
    as $(AFLAGS) $(SR15) -o $(OB15)
$(OB16) : $(SR16)
    cc $(CFLAGS) $(SR16) -o $(OB16)
$(OB17) : $(SR17)
    cc $(CFLAGS) $(SR17) -o $(OB17)
$(OB18) : $(SR18)
    cc $(CFLAGS) $(SR18) -o $(OB18)
$(OB19) : $(SR19)
    as $(AFLAGS) $(SR19) -o $(OB19)
$(OB20) : $(SR20)
    cc $(CFLAGS) $(SR20) -o $(OB20)
$(OB21) : $(SR21)
    cc $(CFLAGS) $(SR21) -o $(OB21)
$(OB22) : $(SR22)
    cc $(CFLAGS) $(SR22) -o $(OB22)
$(OB23) : $(SR23)
    cc $(CFLAGS) $(SR23) -o $(OB23)
$(OB24) : $(SR24)
    cc $(CFLAGS) $(SR24) -o $(OB24)
$(OB25) : $(SR25)
    cc $(CFLAGS) $(SR25) -o $(OB25)

$(SYMS):    $(SYMC)
    make -f include:local/Makefile

$(SYMR):    $(SYMS)
    Copy $(SYMS) $(SYMR)

\Rogue\Monster\
else
  echo "will not over write ./suplib/Makefile"
fi
if [ `wc -c ./suplib/Makefile | awk '{printf $1}'` -ne 3737 ]
then
echo `wc -c ./suplib/Makefile | awk '{print "Got " $1 ", Expected " 3737}'`
fi
if `test ! -d ./suplib/AUX`
then
  mkdir ./suplib/AUX
  echo "mkdir ./suplib/AUX"
fi
if `test ! -s ./suplib/AUX/qint_test.c`
then
echo "writing ./suplib/AUX/qint_test.c"
cat > ./suplib/AUX/qint_test.c << '\Rogue\Monster\'

/*
 *  QINT TEST ROUTINE
 *
 *  1> test
 *	    Ctl D   -quit
 *	    Ctl E   -cause test interrupt #1
 *	    Ctl F   -cause test interrupt #0
 *
 *	    (see printf's to understand what it is printing)
 *
 *	Basic idea: Cycle through various priorities.  The Q interrupts
 *	are both set for priority 16, and thus only work when the counter
 *	is 0...15
 *
 *	If you set one of the Q interrupts to, say, 17, you would then
 *	have to worry about the level 17 Q interrupt interrupting the
 *	level 16 interrupt, and thus surround the level 16 interrupt
 *	with:
 *	    char oldpri = SetQPri(127);
 *	    puts("blah");
 *	    SetQPri(oldpri);
 *
 *	As it is, with both at level 16, they cannot interrupt each other
 *	(if one occurs while the other is running, it is queued till the
 *	 other one finishes).
 */

#include <exec/types.h>
#include <exec/tasks.h>

typedef struct Task TASK;

extern TASK *FindTask();

int X;
int Enable_Abort;

void
myhan(sig)
{
    ++X;
    printf("test# %ld\n", sig);
}

main()
{
    short i;
    int j;

    Enable_Abort = 0;

    printf("tcexcept: %08lx\n", FindTask(NULL)->tc_ExceptCode);
    SetQVector(SIGBREAKB_CTRL_F, myhan, 0, 16);
    SetQVector(SIGBREAKB_CTRL_E, myhan, 1, 16);
    printf("tcexcept: %08lx\n", FindTask(NULL)->tc_ExceptCode);
    printf("tcexmask: %08lx\n", FindTask(NULL)->tc_SigExcept);
    for (i = 0; ; ++i) {
	i &= 31;
	SetQPri(127);
	printf("i = %2ld rcvd: %08lx  excp: %08lx  cnt: %6ld\n", i,
	    FindTask(NULL)->tc_SigRecvd, FindTask(NULL)->tc_SigExcept,
	    X
	);
	SetQPri(i);
	for (j = 0; j < 100; ++j);
	if (SetSignal(0,SIGBREAKF_CTRL_D) & SIGBREAKF_CTRL_D)
	    break;
    }
    SetQVector(SIGBREAKB_CTRL_E, NULL, 0, 0);
    SetQVector(SIGBREAKB_CTRL_F, NULL, 0, 0);
    puts("exiting");
    printf("tcexcept: %08lx\n", FindTask(NULL)->tc_ExceptCode);
}

\Rogue\Monster\
else
  echo "will not over write ./suplib/AUX/qint_test.c"
fi
if [ `wc -c ./suplib/AUX/qint_test.c | awk '{printf $1}'` -ne 1824 ]
then
echo `wc -c ./suplib/AUX/qint_test.c | awk '{print "Got " $1 ", Expected " 1824}'`
fi
if `test ! -s ./suplib/fhprintf.asm`
then
echo "writing ./suplib/fhprintf.asm"
cat > ./suplib/fhprintf.asm << '\Rogue\Monster\'

;FHPRINTF.ASM
;
;  Handles formatted printing to Amiga file handles   w/ fhprintf

;
;   Manx assembler FAR stmts.

	FAR code
	FAR data

	xdef  _fhprintf
	xref  _Write
	xref  _LVORawDoFmt
	xref  _SysBase

_fhprintf
	jsr	 xformat   ;same thing
	jsr	 _Write
	lea.l	 268(A7),A7
	rts

	;XFORMAT takes a Xprintf(xx, cs, arg, arg...)  where xx is any
	;integer and returns (xx, buf, bytes) on the stack suitable for an
	;immediate call to xwrite() or Write().  The caller must deallocate
	;268 bytes from the stack when done.
	;
	;	  (oret)
	;  A2 A3 A4 A5 A6 RET FI BUF NUM <thebuffer> printfret fi cs args
	;  ^   ^	 ^
	;  1   2	 3


xformat
	move.l	 A7,A0		;sp now at pos. #3  A0 = pos #3
	sub.l	 #268,A7	;sp now at pos. #2  SP = pos #2
	move.l	 (A0),(A7)      ;copy return address
	move.l	 8(A0),4(A7)    ;copy fi or fh  to FI
	lea.l	 16(A7),A1      ;address of buffer
	move.l	 A1,8(A7)       ;place in     BUF
	movem.l  A2-A6,-(A7)    ;save regs   SP = pos #1
	move.l	 A1,A3		;A3 = buffer pointer
	lea.l	 16(A0),A1      ;A1 = lea of printf arg list
	move.l	 12(A0),A0      ;A0 = control string
	move.l	 #_xc,A2	;A2 = call vector

	move.l	 _SysBase,A6	;exec library call
	jsr	 _LVORawDoFmt(A6)

	move.l	 28(A7),A3      ;buffer start
loop	tst.b	 (A3)+          ;find end of string
	bne	 loop
	sub.l	 28(A7),A3      ;get string length
	subq.l	 #1,A3
	move.l	 A3,32(A7)      ;place in     NUM
	movem.l  (A7)+,A2-A6    ;restore registers used
	rts

_xc
	move.b	 D0,(A3)+
	rts


\Rogue\Monster\
else
  echo "will not over write ./suplib/fhprintf.asm"
fi
if [ `wc -c ./suplib/fhprintf.asm | awk '{printf $1}'` -ne 1473 ]
then
echo `wc -c ./suplib/fhprintf.asm | awk '{print "Got " $1 ", Expected " 1473}'`
fi
echo "Finished archive 2 of 2"
# if you want to concatenate archives, remove anything after this line
exit
-- 
Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
Have five nice days.