.nf .1h t .hd .c C64 PROMAL V2.1 Language Documentation Notes .ce .eh D. CONVERSIONS ~~~~~~~~~~~~~~ INTSTR int,#tostring[,base[,minwidth[,padchar]]] *** INT -> STRING *** int = number to convert base = base, default is base 10 minwidth = minimum width of tostring padchar = defaults to ' ' REALSTR real,#tostring,width[,decimal] *** REAL -> STRING *** width = 3 to 12 if decimal, 7-16 if scientific, omit=scientific decimal < width - 1, omit = scientific byte=STRREAL(#string,#toreal) *** STRING -> REAL *** byte = 0 if not converted, else index to 1st non-real symbol *** STRING -> INT/WORD *** byte=STRVAL(#string,#to.word.or.int[,base[,maxwidth]]) byte = 0 if not converted, else index to 1st non-int/word symbol base = 10 default maxwidth = 255 default WORDSTR word,#tostring[,base[,minwidth[,padchar]]] *** WORD -> STRING *** base = default 10 ninwidth = default 0 padchar = default ' ' E. DISK & FILE I/O ~~~~~~~~~~~~~~~~~~ CLOSE file close a file int=DIR(pattern[,mode true,false,file]) check disk directory pattern = *,?,filename mode = true (default) display, false no display, file to output to int = number of matches, < 0 means error ABS(int)=IOERROR word=GETBLKF(file,#start,maxsize) continuous block read, only EOF recognized word = number bytes actually read sets byte DIOERR byte=GETCF(file,#char) get byte from device byte=false if EOF, else true char=device char byte=GETLF(file,#tostring[,limit]) NOTE: Only reads upto 128 even if limit byte=false if EOF, else true is set greater. limit = 80 default for C-64 (1-128) tostring size must be limit+1 word=OPEN(filename[,mode,[,nocheck[,type]]]) open up to 3 files, 1 for write or append + 2 for read + STDIN & STDOUT if dyno on then 1 read file taken up. word = 0 if error (see IOERROR pp 3-77) else pointer to file descriptor 1-n = filename string word = ? byte = channel number filename = string name or any device as string like "P" for printer mode = 'r' read default, 'w' write, 'a' append, 'b' both nocheck = true is non-PROMAL file, else false type = 'P' for PRG, 'S' for SEQ default, 'U' for USR read directory directory=OPEN("1:$",'r',true) if GETBLKF(directory,#buffer,256) open error channel errorchan=OPEN("%",'b',true) if GETLF(errorchan,#buffer) PUTBLKF errorchan,#buffer,LENSTR(buffer) open any channel chan=OPEN("#",'b',true) bytechannumber=(chan+LENSTR(chan)+2)@< if GETBLKF(chan,#buffer,256) PUTBLKF chan,#buffer,LENSTR(buffer) open PRG file prgfile=OPEN("promal",'r',true,'P') OUTPUTF file,formatstring[,item1,item2,...] formatted output SEE OUTPUT PUTF file,item1,item2,... output strings or bytes PUTBLKF file,#start,size output block of data DIOERR is set byte=RENAME(old,new) rename a file *** DISK *** byte = 0 if ok, else IOERROR value byte=ZAPFILE(filename[,wildflag]) delete a file *** DISK *** byte = 0 if ok else IOERROR value wildflag = true if '*' or '?' allowed in filename, else false .bp Include PROSYS routines ~~~~~~~~~~~~~~~~~~~~~~~ CLSALL close all opened files byte=GETTST(ioflag) test T device send/receive status byte = true if ready, else false See Appendix F. test input means char has been received test output means transmitter is empty, last char sent ioflag = 0 to test input status, 1 to test output status word=GETVER returns PROMAL version code word =byte 1 version ($21=Version 2.1) byte 2 machine ($01=C64, $02=Apple II, $03=IBM PC Jr., $04=IBM PC) word=INLIST(#search.for.string,ptr.list.end[,fold[,limit[,safty]]]) search backwards through a linked list of strings (see pp. 4-26) word = 0 if not found, else is the address of the matched string ptr.list.end = address of the address of the last string entry fold = true if lower=upper case, else false limit = max length of string to match on safty = 8192 by default, max number tries (prevent infinite loop) ptr.list.end --> next available byte $5000 word, address of last string entry | --> the last string entry NOTE: good to word, address of previous string entry have APPENDLIST | INSERTLIST --> previous string entry DELETELIST word, address of first string entry | --> first string entry $4000 $0000 call 6502, 6510, or 65C02 machine language routines JSR [address[,regA[,regX[,regY[,flags]]]]] See Appendix I. reg and flags are type byte flags are the processor status word .bp LOAD pgmname[,bitflags] load PROMAL programs and overlays IF LDERR <> 0 EXIT "Load error (#i), see pp. 3-54",LDERR pagname = string program name (.C not required) bitflags = LDCHAIN $01 - chain, replace calling pgm LDPRCLR $02 - unload all pgms before loading LDRELD $04 - reload pgm from disk LDRECLM $08 - reclaim memory on exit (overlays) LDNOGO $10 - load pgm but do not execute (get) LDUNLD $20 - unload the pgm default $00 - load, execute, return bitflags may be added together to combine functions sets LDERR uses LOFREE - first byte of unused memory value changes when modules are loaded. HIFREE - byte after the last unused byte of memory value changes for shared variables. MEMLIM - maximum HIFREE value. LOMEM - maximum LOFREE value. if LOFREE > HIFREE then no more free space. (See pp. 3-80,81) OVERLAY - no unloading of programs/overlays. PROGRAM - attempt to unload programs/overlays to make room. word=MLGET(filename[,loadaddr]) same as LOAD "PGM",8,1 in basic word = 0 if error, else address of last byte loaded filename = string with exact match, upper/lower case not same. if loadaddr omitted, will take it from the first 2 bytes of the file. memory pointers are not changed. PROQUIT return to BASIC REDIRECT #STDIN[,file] change default file for stdin, or reset #STDOUT[,file] change default file for stdout, or reset #STDJOB[,file] change default file for stdjob, or reset example: newfile=OPEN("W",'w') REDIRECT #STDOUT,newfile PUTF STDOUT,"Hello",nl REDIRECT #STDOUT close newfile .bp Include REALFUNC.S ~~~~~~~~~~~~~~~~~~ real=POWER(real-x,real-y) real-x to the real-y power real=SQRT(real-x) square root of real-x real=EXP(real-x) e to the real-x power real=LOG(real-x) ln real-x real=LOG10(real-x) log real-x real=ATAN(real) arctan, angle in radians real=COS(real) cosin, angle in radians real=SIN(real) sine, angle in radians real=TAN(real) tangent, angle in radians real=FLOOR(real) remove right of decimal with rounding .bp Memory Management ~~~~~~~~~~~~~~~~~ WS CLEAR WPTR=WORG ; RESET WS FILE POINTERS WEOF=WORG WS 0 WORG=WLIM ; NO WORK SPACE AVAILABLE WPTR=WLIM WEOF=WLIM WSIZE=0 WS n OLDSIZE=WEOF - WORG ; SIZE OF DATA IN WS (includes WS 0) OLDWORG=WORG NEWSIZE=N << 10 ; N * 1024 IF OLDSIZE > NEWSIZE ; NEW WS TOO SMALL FOR DATA OLDSIZE = 0 ; CLEAR WS WORG=WLIM - NEWSIZE ; SET NEW ORIGIN ADDRESS ; NEW WS TOO LARGE FOR AVAIL MEMORY IF WORG < LOFREE OR WORG >= HIMEM WORG=LOFREE ; SET TO ALL AVAIL MEMORY HIFREE=WORG ; RESERVE NEW SPACE FROM PROMAL WEOF=WORG + OLDSIZE ; RESET WS FILE POINTERS WPTR=WEOF ; SAME AS IF FILE CLOSED WSIZE=WLIM - WORG ; SET NEW WS SIZE BLKMOV OLDORG,WORG,OLDWSIZE ; RELOCATE CURRENT DATA IN WS Recover EDITor Space for Entire System (destroys only shared variables) maxmemory OLDWSIZE=WSIZE >> 10 ; WSIZE / 1024 HIFREE=MEMLIM ; RE-CLAIM EDITOR SPACE HIMEM=MEMLIM GVORG=MEMLIM ; RE-LOCATE SHARED MEMORY EMPTY WLIM=MEMLIM ; RE-LOCATE WS WITH DATA IN FILE WS OLDWSIZE ; OR [WS 0] ; USE WS 0 TO RE-CLAIM WS