34 System Library
4am edited this page 2020-07-09 20:05:34 -04:00

The baseline CMD system library. It contains some useful functions for machine identification, basic console I/O, rudimentary memory management, and useful math operations.

Compatibility: 1, II, ///

Usage: include "inc/cmdsys.plh"

Values:

//
// Useful values for everyone
//
const _SYSVER_ = $0100 // Version built against
const FALSE    = 0
const TRUE     = not FALSE
const NULL     = 0
//
// Machine ID values
//
const MACHID_CLOCK = $01
const MACHID_80COL = $02
const MACHID_MEM   = $03
const MACHID_64K   = $20
const MACHID_128K  = $30
const MACHID_MODEL = $C8
const MACHID_II    = $00
const MACHID_IIPLUS= $40
const MACHID_IIE   = $80
const MACHID_III   = $C0
const MACHID_IIC   = $88
const MACHID_I     = $08
byte MACHID
//
// System flags: memory allocator screen holes.
//
const restxt1     = $0001
const restxt2     = $0002
const resxtxt1    = $0004
const resxtxt2    = $0008
const reshgr1     = $0010
const reshgr2     = $0020
const resxhgr1    = $0040
const resxhgr2    = $0080
//
// Module don't free memory
//
const modkeep     = $2000
const modinitkeep = $4000
//
// CMD exported interface table
//
struc t_cmdsys
    word sysver
    word syspath
    word cmdline
    word modexec
    byte refcons
    byte devcons
end

Functions:

putc(c)#0
putln()#0
puts(s)#0
puti(i)#0
getc()#1
gets(p)#1
putb(b)#
puth(h)#0
toupper(c)#1
strcpy(dst,src)#1
strcat(dst,src)#1
call(addr,areg,xreg,yreg,status)#1
syscall(cmd,params)#1
heapmark()#1
heapallocalign(size, pow2, freeaddr)#1
heapalloc(size)#1
heaprelease(newheap)#1
heapavail()#1
memset(addr,value,size)#0
memcpy(dst,src,size)#0
sext(a)#1
divmod(a,b)#2
isugt(a,b)#1
isuge(a,b)#1
isult(a,b)#1
isule(a,b)#1

Source Code: cmd.pla, a1cmd.pla, soscmd.pla

Sample Code: hello.pla, test.pla, testlib.pla