/*    ACEC IO ROUTINES    */›/* To reduce the CCC file size, no arguements are defined in the assembly */›/* language functions.  The arguements that should be passed if any, */›/* will be in the comment after the function name. */›/* */›/* Be sure to read the file FLOAT.TXT for a description of floating point */›/* functions. */›/* */›abs() /* (i) RETURNS absolute value of integer (removes the sign if any) */›/* same as Basic only with an integer value */›  asm 0x2C03;›alpha() /* (c) RETURNS 1 if c is aplabetic, 0 if not ('_' is alphabetic) */›  asm 0x2C06;›atof() /* (fp,asc) converts aschii to floating point. */›  asm 0x2C09;›bgets() /* (addr,len,iocb) get len# of bytes from iocb and put into addr.›/* RETURNS: actual length transferred */›  asm 0x2C0C;›bputs() /* (addr,len,iocb) put len# of bytes into iocb. */›/* returns 1 if okay, else negative error number */›  asm 0x2C0F;›cgetc() /* (iocb) returns char from iocb, else negative of error number */›  asm 0x2C12;›cgets() /* (addr,iocb) gets a record from iocb (everything up to the */›/* next RETURN.  Returns the length */›/* Like BASIC: INPUT #iocb,str$ */›  asm 0x2C15;›ciov() /* (iocb,command,addr,len,ax1,ax2) RETURNS: Y register (Y=1 if okay) */›/* Like Basic XIO command */›/* Used to call Operating System CIO.  Use -1 to ignore any operand */›  asm 0x2C18;›clear() /* (addr,len) put zero into locations from addr through addr+len.*/›  asm 0x2C1B;›clog() /* (a,b) b=clog(a) Floating Point only! (same as Basic) */›  asm 0x2C1E;›close() /* (iocb) close iocb (same as BASIC: CLOSE #iocb)*/›  asm 0x2C21;›color() /* (col) set color for plotting (same as Basic) */›  asm 0x2C24;›copen() /* (name,mode) open filename in mode specified */›/* r-read, w-write, u-update, a-append, d-directory */›/* example: copen(filename,'r'); */›  asm 0x2C27;›cputc() /* (c,iocb) put byte c to iocb. RETURNS: - if error */›/* same as BASIC: PUT #iocb,c */›  asm 0x2C2A;›cputs() /* (addr,iocb) send string at addr to iocb. RETURNS: - if error */›  asm 0x2C2D;›dpeek() /* (addr) RETURNS word at addr */›  asm 0x2C30;›dpoke() /* (addr,word) poke word into addr. RETURNS: previous value (word) */›  asm 0x2C33;›drawto() /* (x,y) draw to x,y using color specified in color(c) */›  asm 0x2C36;›exit() /* return to DOS */›  asm 0x2C39;›exp() /* (a,b,c) c=a^b (floating point only!) */›  asm 0x2C3C;›fadd() /* (a,b,c) c=a+b (floating point only!) */›  asm 0x2C3F;›fast() /* turn off screen, turn on critic - results in faster computations */›/* [see slow()] */›  asm 0x2C42;›fdiv() /* (a,b,c) c=a/b floating division */›  asm 0x2C45;›find() /* (addr,len,c) look for character c starting at addr though addr+len */›/* returns position, or -1 if not found */›  asm 0x2C48;›fmul() /* (a,b,c) c=a*b floating multiplication */›  asm 0x2C4B;›fsub() /* (a,b,c) c=a-b floating subtraction */›  asm 0x2C4E;›ftoi() /* (f.p.) return integer value of floating point (will round off decimal part) */›  asm 0x2C51;›getchar() /* returns aschii key and echos it to the screen */›  asm 0x2C54;›getkey() /* returns asckii key but does not affect the screen */›/* Same as BASIC: OPEN #1,0,4,"K:":GET #1,var */›  asm 0x2C57;›gets() /* (addr) returns a string from the editor */›/* Same as BASIC: INPUT STR$ */›  asm 0x2C5A;›graphics() /* (num) closes, then opens iocb #6 in graphics mode specified (same as Basic) */›  asm 0x2C5D;›gtime() /* returns the integer value of the internal clock in 60ths of a second */›/* to clear the clock, use the C function: dpoke(19,0); */›  asm 0x2C60;›itof() /* (i,fp) converts integer i to floating point (fp) */›  asm 0x2C63;›locate() /* (x,y) returns the color at screen location x,y */›/* (same as Basic) */›  asm 0x2C66;›log() /* (a,b) b=log(a) floating point only! (same as Basic) */›  asm 0x2C69;›match() /* (s1,s2) return false if strings are different, 1 if the same */›/* It will return a 1 if s2 is equal to s1 even if s1 is longer. */›/* Example: match("testpattern","test"); will return true (1) */›  asm 0x2C6C;›move() /* (from,to,len) move len# of bytes at address one, to address two. */›/* No check is made to see if from string is overwriting to string */›  asm 0x2C6F;›normalize() /* (filename,ext) will convert filename to uppercase, */›/* append the extension if there isn't one already, */›/* and add D1: to the front if a drive isn't specified */›/* Example: normalize(fname,"C") where fname="test" will change fname to: */›/* "D1:TEST.C" */›/* One can change the default drive with the statement: */›/* poke(dpeek(0x2CB4),'n'); where n is the drive number */›/* To make it permanent, you must now save it to ENGINE.OBJ */›/* The load parameters can be found by using COMPACT.COM.  (see COMPACT.TXT) */›  asm 0x2C72;›open() /* (iocb,ax1,ax2,fname) same as Basic open */›  asm 0x2C75;›peek() /* (addr) returns byte at addr (same as Basic) */›  asm 0x2C78;›plot() /* (x,y) plot point at x,y.  Point color set by color(c) */›  asm 0x2C7B;›poke() /* (addr,c) poke c into addr, returns previous value */›  asm 0x2C7E;›position() /* (x,y) position cursor at x,y (same as Basic) */›  asm 0x2C81;›printf() /* see file PRINTF.TXT for explanation */›  asm 0x2C84;›putchar() /* (c) send c to the screen */›  asm 0x2C87;›rnd() /* (n) return random integer between 0 and n inclusive. */›/* if you want 0-255, use rnd(0) which is faster */›  asm 0x2C8A;›sfind() /* (s1,s2) search for string s2 in s1 and return position if found, */›/* else return -1 */›  asm 0x2C8D;›slow() /* turn on screen again after fast() */›  asm 0x2C90;›sound() /* (voice,pitch,distortion,volume) same as Basic */›  asm 0x2C93;›stick() /* (n) returns value of joystick #n */›  asm 0x2C96;›strcat() /* (s1,s2) append string 2 to end of string 1 */›  asm 0x2C99;›strcmp() /* (s1,s2) subtracts string 2 from string 1. */›/* It will return the first non-zero difference. */›/* Example: strcmp("Ab","ab") returns -32 */›/* Example: strcmp("ab","Ab") returns 32 */›/* Example: strcmp("ab","ab") returns 0 */›  asm 0x2C9C;›strcpy() /* (to,from) copy string 2 to string 1 */›  asm 0x2C9F;›strig() /* (n) return trigger button value of joystick #n */›  asm 0x2CA2;›strlen() /* (str) returns length of string */›  asm 0x2CA5;›tolower() /* (c) return lowercase value of c */›  asm 0x2CA8;›toupper() /* (c) returns uppercase value of c */›  asm 0x2CAB;›usr() /* (addr,args) does a JSR to addr, returns integer (A=low byte, X=high byte */›/* 0xBF=number of arguements, 0xC6=stack pointer to arguements */›  asm 0x2CAE;›val() /* (addr) returns integer value of string at addr (same as Basic) */›  asm 0x2CB1;›closeall() $( /* close all iocb's */›  int i;›  for(i=1;i<8;++i) close(i);›$)›getread(s,ext) /* get the file name from the user, */›/* normalize it with the extension, and open it for reading */›/* Returns the iocb number */›char s[],ext[];›$(›  int iocb;›  getname(s);›  iocb=0;›  while(iocb<1) $(›    normalize(s,ext);›    iocb=copen(s,'r');›    if(iocb<1) $(›      printf("can't open %s\n",s);›      getname(s);›    $)›  $)›  return iocb;›$)›getname(s) /* request the filename from the user */›char s[];›$(›  printf("filename (or RETURN to exit)? ");›  gets(s);›  if(!s[0]) $(›    putchar('');›    putchar('');›    exit();›  $)›$)›