1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-03-20 03:31:27 +00:00

Use cmdsys.plh include file

This commit is contained in:
Dave Schmenk 2017-11-11 06:50:06 -08:00
parent 50c72063dd
commit e9191c20d8
31 changed files with 950 additions and 1564 deletions

@ -2,13 +2,13 @@ import memmgr
//
// Utility routine
//
predef sweep, brk, sbrk
predef sweep#0, brk(addr), sbrk(size)
//
// Memory routines
//
predef hmemNew, hmemLock, hmemUnlock, hmemRef, hmemDel, hmemFre
predef hmemNew(size), hmemLock(hmem), hmemUnlock(hmem)#0, hmemRef(hmem), hmemDel(hmem), hmemFre(lptr)
//
// Max size of a memory block
//
const MAX_MEMBLK_SIZE = $2000
end
end

@ -1,7 +1,4 @@
import STDLIB
predef syscall, call, memset, getc, putc, puts, modaddr
byte MACHID
end
include "inc/cmdsys.plh"
//
// Handy constants.
//
@ -200,7 +197,7 @@ def a2writeln(string, start, fill)
end
def a2textmode(columns)
call($FB39, 0, 0, 0, 0) // textmode()
return a2home
return a2home
end
def a2grmode(mix)
call($FB2F, 0, 0, 0, 0) // initmode()
@ -216,7 +213,7 @@ end
//
def dev_control(devnum, code, list)
byte params[5]
params.0 = 3
params.1 = devnum
params.2 = code
@ -225,7 +222,7 @@ def dev_control(devnum, code, list)
end
def dev_status(devnum, code, list)
byte params[5]
params.0 = 3
params.1 = devnum
params.2 = code

@ -1,18 +1,4 @@
import cmdsys
predef puts, memset, memcpy, heapmark, heapalloc, heaprelease, call
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
end
include "inc/cmdsys.plh"
sysflags $000F // Reserve all text pages
//
// Apple II hardware constants.

@ -1,12 +1,7 @@
//
// DHCP
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
byte MACHID
end
include "inc/cmdsys.plh"
//
// Net object
//
@ -136,7 +131,7 @@ def puti(i)
end
def putip(ipptr)
byte i
for i = 0 to 2
puti(ipptr->[i]); putc('.')
next
@ -144,7 +139,7 @@ def putip(ipptr)
end
def dumpbytes(buf, len)
word i
for i = 0 to len - 1
putb(buf->[i])
if i & 15 == 15
@ -168,7 +163,7 @@ def dumpdhcp(pkt)
end
def parseopts(opts, match)
byte i
i = 0
while opts->[i] <> $FF and i < 64
while !opts->[i] and i < 64
@ -183,7 +178,7 @@ def parseopts(opts, match)
end
def recvDHCP(remip, remport, pkt, len, param)
word servopts, maskopts, gwopts, dnsopts
//putip(remip);putc(':');puti(remport);putln
//dumpdhcp(pkt)
if pkt=>dhcp_xid:0 == $0201 and pkt=>dhcp_xid:2 == $0403

@ -1,15 +1,4 @@
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef isugt, isuge, isult, isule
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
//
// Module don't free memory
//
const modkeep = $2000
const modinitkeep = $4000
end
include "inc/cmdsys.plh"
//
// Net object
//
@ -244,7 +233,7 @@ CHKLP LDA (SRC),Y
STA ESTKH+2,X
PLA
ADC ESTKL+2,X
STA ESTKL+2,X
STA ESTKL+2,X
INY
BNE +
INC SRCH
@ -268,7 +257,7 @@ def etherSendIP(ipdst, proto, seglist, size)
byte[t_iphdr] hdr
byte retry
word timeout
hdr.ip_vers_hlen = $45
hdr.ip_service = 0
hdr:ip_length = swab(t_iphdr + size)
@ -340,7 +329,7 @@ end
def etherSendUDP(port, ipdst, portdst, data, len)
word[8] seglist // list of data and header segments
byte[t_udphdr] hdr
hdr:udp_src = swab(port=>notify_port)
hdr:udp_dst = swab(portdst)
hdr:udp_len = swab(t_udphdr + len)
@ -391,7 +380,7 @@ end
def etherCloseUDP(port)
word port
byte i
if isuge(port, @portsUDP) and isult(port, @portsUDP + MAX_UDP_NOTIFIES * t_notify)
//
// Clear notiications on this port

@ -1,13 +1,7 @@
//
// Cooperative multi-threading (fiber) scheduler
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
predef isugt, isuge, isult, isule
byte MACHID
end
include "inc/cmdsys.plh"
//
// Maximum number of fibers
//

@ -1,14 +1,9 @@
//
// Handle based swapping memory manager
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
predef isugt, isuge, isult, isule
byte MACHID
end
const iobuffer = $0800
include "inc/cmdsys.plh"
include "inc/fileio.plh"
struc t_initdata
word volptr
word freeblks
@ -88,7 +83,7 @@ word frelst // Free list
byte sweeppg, sweepen
byte[64] swapvol = "/" // Swap volume
byte swapdir = "/SWAP/"
byte hexchar = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
byte hexchar = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
//
// DEBUG
//
@ -109,11 +104,11 @@ byte hexchar = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
//
// Fill block filename
//
def strcharadd(str, char)
def strcharadd(str, char)#0
^str = ^str + 1
str->.[^str] = char
end
def swapfile(filestr, hmem)
def swapfile(filestr, hmem)#0
memcpy(filestr, @swapvol, swapvol + 1)
strcharadd(filestr, 'H')
strcharadd(filestr, hexchar[(hmem >> 12) & $0F])
@ -121,78 +116,6 @@ def swapfile(filestr, hmem)
strcharadd(filestr, hexchar[(hmem >> 4) & $0F])
strcharadd(filestr, hexchar[ hmem & $0F])
end
def open(path)
byte params[6]
params.0 = 3
params:1 = path
params:3 = iobuffer
params.5 = 0
syscall($C8, @params)
return params.5
end
def close(refnum)
byte params[2]
params.0 = 1
params.1 = refnum
return syscall($CC, @params)
end
def read(refnum, buff, len)
byte params[8]
params.0 = 4
params.1 = refnum
params:2 = buff
params:4 = len
params:6 = 0
syscall($CA, @params)
return params:6
end
def write(refnum, buff, len)
byte params[8]
params.0 = 4
params.1 = refnum
params:2 = buff
params:4 = len
params:6 = 0
syscall($CB, @params)
return params:6
end
def get_info(path, infoptr)
byte params[18]
memset(@params, 0, 18)
params.0 = 10
params:1 = path
syscall($C4, @params)
return memcpy(infoptr, @params.3, 15)
end
def create(path, access, type, aux)
byte params[12], kind
kind = $01
if type == $0F
kind = $0D
fin
params.0 = 7
params:1 = path
params.3 = access
params.4 = type
params:5 = aux
params.7 = kind
params:8 = 0
params:10 = 0
return syscall($C0, @params)
end
def destroy(path)
byte params[12]
params.0 = 1
params:1 = path
return syscall($C1, @params)
end
//
// Find exact/best free memory match
//
@ -209,7 +132,7 @@ def unlink(freblk, freprv)
end
def unfre(freblk, freprv, size)
word shrink
if freblk=>fresiz == size
//
// Unlink free block
@ -234,32 +157,32 @@ def unfre(freblk, freprv, size)
end
def addfre(freblk)
word srch
//freblk=>fresiz = freblk=>blksiz
if frelst and frelst < freblk
srch = frelst
while srch=>frenxt
if srch=>frenxt > freblk
//
// Insert into list
//
freblk=>frenxt = srch=>frenxt
srch=>frenxt = freblk
//
// Insert into list
//
freblk=>frenxt = srch=>frenxt
srch=>frenxt = freblk
return
fin
fin
srch = srch=>frenxt
loop
//
// Add to end of list
//
freblk=>frenxt = 0
srch=>frenxt = freblk
//
// Add to end of list
//
freblk=>frenxt = 0
srch=>frenxt = freblk
else
//
// Add to beginning of list
//
// Add to beginning of list
//
freblk=>frenxt = frelst
frelst = freblk
frelst = freblk
fin
end
//
@ -267,58 +190,58 @@ end
//
def coallesce
word srch, combined
combined = 0
srch = frelst
while srch and srch=>frenxt
if srch + srch=>fresiz == srch=>frenxt
//
// Combine adjacent free space
//
//putc('C');putc(' ');puth(srch);putc('+');puth(srch=>frenxt);putc(' ')
//
// Combine adjacent free space
//
//putc('C');putc(' ');puth(srch);putc('+');puth(srch=>frenxt);putc(' ')
srch=>fresiz = srch=>fresiz + srch=>frenxt=>fresiz
srch=>frenxt = srch=>frenxt=>frenxt
srch=>frenxt = srch=>frenxt=>frenxt
combined = 1
else
srch = srch=>frenxt
fin
fin
loop
return combined
end
def compact
word page, entry, memblk, moveblk, size, srch, prev
byte moved
moved = 0
for page = PG_TBL_SIZE - 1 downto 0
if hpgtbl[page]
for entry = 255 downto 0
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
memblk = hpgtbl:[page, entry]
size = memblk=>blksiz
moveblk = 0
prev = 0
size = memblk=>blksiz
moveblk = 0
prev = 0
srch = frelst
while srch and srch < memblk
while srch and srch < memblk
if srch=>fresiz >= size
moveblk = unfre(srch, prev, size)
break
fin
prev = srch
srch = srch=>frenxt
loop
if moveblk
//putc('M');putc(' ');puth(moveblk);putc('=');puth(memblk);putc(' ')
memcpy(moveblk, memblk, size)
hpgtbl:[page, entry] = moveblk
addfre(memblk)
moved = 1
fin
fin
moveblk = unfre(srch, prev, size)
break
fin
prev = srch
srch = srch=>frenxt
loop
if moveblk
//putc('M');putc(' ');puth(moveblk);putc('=');puth(memblk);putc(' ')
memcpy(moveblk, memblk, size)
hpgtbl:[page, entry] = moveblk
addfre(memblk)
moved = 1
fin
fin
next
else
break
fin
fin
next
if moved
coallesce
@ -333,40 +256,40 @@ def swapout(accessed)
byte ref
word page, entry, memblk, hmem, size
byte swapped
swapped = 0
for page = PG_TBL_SIZE - 1 downto 0
if hpgtbl[page]
for entry = 255 downto 0
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
memblk = hpgtbl:[page, entry]
if not (memblk->blklok & accessed)
//
// Swap this block out
//
if not (memblk->blklok & accessed)
//
// Swap this block out
//
size = memblk=>blksiz
hmem.lsb = page
hmem.msb = entry
swapfile(@filename, hmem)
create(@filename, $C3, $00, size) // embed size in aux type
hmem.lsb = page
hmem.msb = entry
swapfile(@filename, hmem)
create(@filename, $C3, $00, size) // embed size in aux type
//puts(@swapoutstr);puts(@filename);putc('@');puth(memblk);putc(':');puth(size);putln
ref = open(@filename)
if ref
//
// Write it out
//
if write(ref, memblk, size) == size
//
// Zero size in page table flags swapin to read from disk
//
hpgtbl:[page, entry] = HMEM_SWAPPED
addfre(memblk)
swapped = 1
fin
close(ref)
fin
fin
fin
ref = open(@filename)
if ref
//
// Write it out
//
if write(ref, memblk, size) == size
//
// Zero size in page table flags swapin to read from disk
//
hpgtbl:[page, entry] = HMEM_SWAPPED
addfre(memblk)
swapped = 1
fin
close(ref)
fin
fin
fin
next
else
break
@ -389,46 +312,46 @@ def findexact(size)
while srch
if srch=>fresiz == size
//putc('E')
return unlink(srch, prev)
fin
prev = srch
return unlink(srch, prev)
fin
prev = srch
srch = srch=>frenxt
loop
end
def findbest(size)
word srch, prev
prev = 0
srch = frelst
while srch
if srch=>fresiz >= size
//putc('B')
return unfre(srch, prev, size)
fin
prev = srch
return unfre(srch, prev, size)
fin
prev = srch
srch = srch=>frenxt
loop
end
def findblk(size)
word addr
if size > MAX_BLK_SIZE; return 0; fin
addr = findexact(size)
if !addr
coallesce
addr = findexact(size)
if !addr
compact
addr = findbest(size)
if !addr
swapout(HMEM_ACCESSED)
addr = findbest(size)
if !addr
swapout(0)
addr = findbest(size)
fin
fin
fin
addr = findexact(size)
if !addr
compact
addr = findbest(size)
if !addr
swapout(HMEM_ACCESSED)
addr = findbest(size)
if !addr
swapout(0)
addr = findbest(size)
fin
fin
fin
fin
//
// Fill in the block
@ -436,8 +359,8 @@ def findblk(size)
//puts(@getblkstr);puth(addr);putc(':');puth(size);putln
if addr
addr=>blksiz = size
addr->blkref = 1
addr->blklok = 0
addr->blkref = 1
addr->blklok = 0
fin
return addr
end
@ -449,33 +372,33 @@ def swapin(hmem)
byte[15] info
byte ref
word memblk, size
size = hpgtbl:[hmem.lsb, hmem.msb] & HMEM_SIZE
if size
//
// This was just uninitialized memory, don't bother reading from file
//
// This was just uninitialized memory, don't bother reading from file
//
memblk = findblk(size)
else
//
// Swap this block back in
//
swapfile(@filename, hmem)
get_info(@filename, @info)
size = info:2 // Size encoded in aux type
// Swap this block back in
//
swapfile(@filename, hmem)
get_info(@filename, @info)
size = info:2 // Size encoded in aux type
memblk = findblk(size)
//puts(@swapinstr);puts(@filename);putc('@');puth(memblk);putc(':');puth(size);putln
if memblk
//
// Read it in
//
ref = open(@filename)
if ref
read(ref, memblk, size)
close(ref)
destroy(@filename)
fin
fin
//puts(@swapinstr);puts(@filename);putc('@');puth(memblk);putc(':');puth(size);putln
if memblk
//
// Read it in
//
ref = open(@filename)
if ref
read(ref, memblk, size)
close(ref)
destroy(@filename)
fin
fin
fin
if memblk
hpgtbl:[hmem.lsb, hmem.msb] = memblk
@ -485,29 +408,29 @@ end
//
// Incrementally clear the ACCESSED BIT
//
export def sweep
export def sweep#0
word memblk
if hpgtbl[sweeppg]
memblk = hpgtbl:[sweeppg, sweepen]
when memblk.lsb & HMEM_STATE
is HMEM_MOVEABLE
is HMEM_LOCKED
memblk = memblk & HMEM_ADDR
if memblk->blklok & HMEM_ACCESSED
memblk->blklok = memblk->blklok & $7F
fin
wend
if sweepen == 255
sweepen = 0
if sweeppg == 0
sweeppg = PG_TBL_SIZE - 1
else
sweeppg = sweeppg - 1
fin
else
sweepen = sweepen + 1
fin
when memblk.lsb & HMEM_STATE
is HMEM_MOVEABLE
is HMEM_LOCKED
memblk = memblk & HMEM_ADDR
if memblk->blklok & HMEM_ACCESSED
memblk->blklok = memblk->blklok & $7F
fin
wend
if sweepen == 255
sweepen = 0
if sweeppg == 0
sweeppg = PG_TBL_SIZE - 1
else
sweeppg = sweeppg - 1
fin
else
sweepen = sweepen + 1
fin
else
sweeppg = PG_TBL_SIZE - 1
fin
@ -517,7 +440,7 @@ end
//
export def brk(addr)
word heapalign, brkblk, brksiz, srch
//
// Check if addr is too high or low
//
@ -525,44 +448,44 @@ export def brk(addr)
if isule(addr, heapmark); return 0; fin
if not pooladdr
//
// Allocate the memory pool
//
// Allocate the memory pool
//
heapalign = (heapmark | MIN_BLK_MASK) + 1
brksiz = addr - heapalign
if isult(brksiz, MAX_BLK_SIZE); return 0; fin // Not enough heap
poolsize = addr - heapmark
pooladdr = heapalloc(poolsize)
if pooladdr
frelst = heapalign
frelst=>fresiz = brksiz
frelst=>frenxt = 0
brksiz = addr - heapalign
if isult(brksiz, MAX_BLK_SIZE); return 0; fin // Not enough heap
poolsize = addr - heapmark
pooladdr = heapalloc(poolsize)
if pooladdr
frelst = heapalign
frelst=>fresiz = brksiz
frelst=>frenxt = 0
else
poolsize = 0
fin
else
poolsize = 0
fin
else
//
// Can we extend the memory pool?
//
if pooladdr + poolsize == heapmark
brksiz = addr - heapmark
// Can we extend the memory pool?
//
if pooladdr + poolsize == heapmark
brksiz = addr - heapmark
brkblk = heapalloc(brksiz)
if brkblk
//
// Add block to end of free list
//
//
// Add block to end of free list
//
poolsize = poolsize + brksiz
brkblk=>fresiz = brksiz
brkblk=>frenxt = 0
if frelst
srch = frelst
while srch=>frenxt; srch = srch=>frenxt; loop
srch=>frenxt = brkblk
else
frelst = brkblk
fin
brkblk=>fresiz = brksiz
brkblk=>frenxt = 0
if frelst
srch = frelst
while srch=>frenxt; srch = srch=>frenxt; loop
srch=>frenxt = brkblk
else
frelst = brkblk
fin
coallesce // combine adjacent free space
fin
fin
fin
fin
fin
return poolsize
end
@ -575,7 +498,7 @@ end
//
export def hmemFre(lptr)
word srch, free, largest
coallesce
while compact; loop
free = 0
@ -599,7 +522,7 @@ end
//
export def hmemNew(size)
word page, entry, hnew, memblk
//
// First, find a free handle
//
@ -609,33 +532,33 @@ export def hmemNew(size)
// Allocate a new page table
//
hpgtbl[page] = heapalloc(PG_SIZE)
memset(hpgtbl[page], HMEM_AVAIL, PG_SIZE)
memset(hpgtbl[page], HMEM_AVAIL, PG_SIZE)
//puts(@allocpgstr);puth(hpgtbl[page]);putln
//
// Check if we need to allocate the memory pool
//
if not pooladdr
//
// Allocate 3/4 of available heap on 128K machine, 1/2 on 64K machine
//
poolsize = ((@page - heapmark) >> 1) & $7FFF
if MACHID & $30 == $30
poolsize = poolsize + (poolsize >> 1)
fin
//
// Check if we need to allocate the memory pool
//
if not pooladdr
//
// Allocate 3/4 of available heap on 128K machine, 1/2 on 64K machine
//
poolsize = ((@page - heapmark) >> 1) & $7FFF
if MACHID & $30 == $30
poolsize = poolsize + (poolsize >> 1)
fin
if isult(poolsize, MAX_BLK_SIZE)
poolsize = MAX_BLK_SIZE
fin
sbrk(poolsize)
fin
sbrk(poolsize)
fin
fin
for entry = 255 downto 0
if hpgtbl:[page, entry].lsb == HMEM_AVAIL
//
// Reserve handle as swapped out block
// Nonzero size will flag swapin to not read from disk
// Nonzero size will flag swapin to not read from disk
//
//putc('N');putc(' ');putb(entry);putb(page);putc('@')
size = ((size + t_memblk) | MIN_BLK_MASK) + 1
size = ((size + t_memblk) | MIN_BLK_MASK) + 1
hpgtbl:[page, entry] = size | HMEM_SWAPPED
hnew.lsb = page
hnew.msb = entry
@ -649,39 +572,39 @@ end
//
export def hmemLock(hmem)
word memblk
memblk = hpgtbl:[hmem.lsb, hmem.msb]
when memblk.lsb & HMEM_STATE
is HMEM_SWAPPED
memblk = swapin(hmem)
if not memblk; return 0; fin
is HMEM_MOVEABLE
hpgtbl:[hmem.lsb, hmem.msb] = memblk | HMEM_LOCKED
memblk = swapin(hmem)
if not memblk; return 0; fin
is HMEM_MOVEABLE
hpgtbl:[hmem.lsb, hmem.msb] = memblk | HMEM_LOCKED
is HMEM_LOCKED
memblk = memblk & HMEM_ADDR
memblk->blklok = (memblk->blklok + 1) | HMEM_ACCESSED
memblk = memblk & HMEM_ADDR
memblk->blklok = (memblk->blklok + 1) | HMEM_ACCESSED
//putc('L');putc(' ');puth(hmem);putc('@');puth(memblk);putln
return memblk + t_memblk
return memblk + t_memblk
wend
end
//
// Unlock memory block
//
export def hmemUnlock(hmem)
export def hmemUnlock(hmem)#0
byte lock
word memblk
memblk = hpgtbl:[hmem.lsb, hmem.msb]
if memblk.lsb & HMEM_STATE == HMEM_LOCKED
memblk = memblk & HMEM_ADDR
lock = memblk->blklok - 1
if lock == HMEM_ACCESSED
//
// Block is now moveable
//
hpgtbl:[hmem.lsb, hmem.msb] = memblk
fin
memblk->blklok = lock
lock = memblk->blklok - 1
if lock == HMEM_ACCESSED
//
// Block is now moveable
//
hpgtbl:[hmem.lsb, hmem.msb] = memblk
fin
memblk->blklok = lock
//putc('U');putc(' ');puth(hmem);putln
fin
end
@ -690,16 +613,16 @@ end
//
export def hmemRef(hmem)
word memblk
memblk = hpgtbl:[hmem.lsb, hmem.msb]
when memblk.lsb & HMEM_STATE
is HMEM_SWAPPED
memblk = swapin(hmem)
memblk = swapin(hmem)
is HMEM_LOCKED
is HMEM_MOVEABLE
memblk = memblk & HMEM_ADDR
if not memblk; return 0; fin
memblk->blkref = memblk->blkref + 1
is HMEM_MOVEABLE
memblk = memblk & HMEM_ADDR
if not memblk; return; fin
memblk->blkref = memblk->blkref + 1
wend
end
//
@ -708,26 +631,26 @@ end
export def hmemDel(hmem)
byte ref
word memblk
memblk = hpgtbl:[hmem.lsb, hmem.msb]
when memblk & HMEM_STATE
is HMEM_SWAPPED
memblk = swapin(hmem)
is HMEM_LOCKED
is HMEM_MOVEABLE
memblk = memblk & HMEM_ADDR
if not memblk; return 0; fin
ref = memblk->blkref - 1
if ref == 0
//
// No more references, free block
//
hpgtbl:[hmem.lsb, hmem.msb] = HMEM_AVAIL
addfre(memblk)
else
memblk->blkref = ref
fin
break
is HMEM_MOVEABLE
memblk = memblk & HMEM_ADDR
if not memblk; return 0; fin
ref = memblk->blkref - 1
if ref == 0
//
// No more references, free block
//
hpgtbl:[hmem.lsb, hmem.msb] = HMEM_AVAIL
addfre(memblk)
else
memblk->blkref = ref
fin
break
wend
end
//
@ -738,7 +661,7 @@ end
initdata = heapmark // Use data at top of heap for initialization
initdata=>volparms.0 = 2
initdata=>volparms.1 = 0
initdata=>volparms:2 = iobuffer
initdata=>volparms:2 = sysbuf
syscall($C5, @initdata=>volparms)
initdata=>volptr = iobuffer
initdata=>ramfree = 0
@ -749,16 +672,16 @@ for sweepen = 0 to 15
memcpy(@swapvol + 2, initdata=>volptr + 1, ^initdata=>volptr)
swapvol = ^initdata=>volptr + 1
get_info(@swapvol, @initdata->volinfo)
initdata=>freeblks = initdata=>volinfo:2 - initdata=>volinfo:5
if initdata=>volptr:1 == $522F and initdata=>volptr:3 == $4D41 // '/RAM'
if isugt(initdata=>freeblks, initdata=>ramfree)
initdata=>ramvol = initdata=>volptr
initdata=>ramfree = initdata=>freeblks
fin
elsif isugt(initdata=>freeblks, initdata=>bestfree)
initdata=>bestvol = initdata=>volptr
initdata=>bestfree = initdata=>freeblks
fin
initdata=>freeblks = initdata=>volinfo:2 - initdata=>volinfo:5
if initdata=>volptr:1 == $522F and initdata=>volptr:3 == $4D41 // '/RAM'
if isugt(initdata=>freeblks, initdata=>ramfree)
initdata=>ramvol = initdata=>volptr
initdata=>ramfree = initdata=>freeblks
fin
elsif isugt(initdata=>freeblks, initdata=>bestfree)
initdata=>bestvol = initdata=>volptr
initdata=>bestfree = initdata=>freeblks
fin
fin
initdata=>volptr = initdata=>volptr + 16
next
@ -780,27 +703,27 @@ initdata->swapstrlen = swapvol
repeat
if read(initdata->catref, @initdata->catalog, 512) == 512
initdata=>catentry = @initdata->catalog.4
if initdata->firstblk
initdata->entrylen = initdata->catalog.$23
initdata->entriesblk = initdata->catalog.$24
initdata=>filecnt = initdata=>catalog:$25
initdata=>catentry = initdata=>catentry + initdata->entrylen
if initdata->firstblk
initdata->entrylen = initdata->catalog.$23
initdata->entriesblk = initdata->catalog.$24
initdata=>filecnt = initdata=>catalog:$25
initdata=>catentry = initdata=>catentry + initdata->entrylen
fin
for sweepen = initdata->firstblk to initdata->entriesblk
^initdata=>catentry = ^initdata=>catentry & $0F
if ^initdata=>catentry
for sweepen = initdata->firstblk to initdata->entriesblk
^initdata=>catentry = ^initdata=>catentry & $0F
if ^initdata=>catentry
memcpy(@swapvol + swapvol + 1, initdata=>catentry + 1, ^initdata=>catentry)
swapvol = swapvol + ^initdata=>catentry
destroy(@swapvol)
destroy(@swapvol)
swapvol = initdata->swapstrlen
fin
initdata=>catentry = initdata=>catentry + initdata->entrylen
fin
initdata=>catentry = initdata=>catentry + initdata->entrylen
next
initdata->firstblk = 0
initdata->firstblk = 0
else
initdata->filecnt = 0
fin
until !initdata->filecnt
close(initdata->catref)
//puts(@swapvol); putln
done
done

@ -1,13 +1,7 @@
//
// Game port I/O library based on the wiring library
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
predef isugt, isuge, isult, isule
byte MACHID
end
include "inc/cmdsys.plh"
const ANN0 = $C058
const ANN1 = $C05A

@ -1,7 +1,5 @@
include "inc/cmdsys.plh"
include "inc/spiport.plh"
import cmdsys
predef call, putc, puts, putln
end
//
// FAT I/O object
@ -21,7 +19,7 @@ word[] = @size, @truncate, @isDir, @isFile
//
def cwd(pathname)
byte namelen
namelen = 0
spiSend(15) // CWD
namelen = spiRecv
@ -55,7 +53,7 @@ end
def openDir(cmd, filename)
byte namelen
namelen = 0
spiSend(cmd)
namelen = spiRecv
@ -148,4 +146,4 @@ end
//
spiSend(14) // SDINIT
return spiReady <> 0 // Is Arduino READY?
done
done

@ -1,6 +1,4 @@
import cmdsys
predef call, putc, puts, putln
end
include "inc/cmdsys.plh"
//
// Bit banged spi over gameport
//

@ -1,13 +1,7 @@
//
// Original Uthernet ethernet card based on Cirrus Logic cs8900a
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef isugt, isuge, isult, isule
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
include "inc/cmdsys.plh"
//
// Include dependency on S/W IP stack
//

@ -4,13 +4,7 @@
// TCP/IP is built into hardware, so no dependencies on the software
// layers, like the Uthernet
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef isugt, isuge, isult, isule
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
include "inc/cmdsys.plh"
//
// Net object
//
@ -417,7 +411,7 @@ def pokeregw(reg, dataw)
end
def peekregw(reg)
word dataw
_pokeiow(reg)
dataw.1 = _peekio()
_pokeiow(reg + 1)
@ -429,7 +423,7 @@ end
//
def wizSendUDP(wiz, ipdst, portdst, data, len)
word wizregs, wizdata, txrr, txwr, splitlen
wizregs = wiz=>channel_regs
wizdata = wiz=>channel_txmem
if !ipdst
@ -633,7 +627,7 @@ end
//
def wizSendTCP(wiz, data, len)
word wizregs, wizdata, txrr, txwr, splitlen
if wiz->channel_state <> TCP_STATE_OPEN; return -1; fin
wizregs = wiz=>channel_regs
wizdata = wiz=>channel_txmem
@ -717,7 +711,7 @@ end
def wizServiceIP
word wiz, wizregs, wizdata, rxlen, rxrr, rxwr, rxpkt, splitlen
byte ir, i, sir
ir = peekreg(WIZ_IR)
if ir
wiz = @wizChannel

@ -4,13 +4,7 @@
// TCP/IP is built into hardware, so no dependencies on the software
// layers, like the Uthernet
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef isugt, isuge, isult, isule
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
include "inc/cmdsys.plh"
//
// Net object
//
@ -426,7 +420,7 @@ def pokeregw(reg, dataw)
end
def peekregw(reg)
word dataw
_pokeiow(reg)
dataw.1 = _peekio()
_pokeiow(reg + 1)
@ -456,7 +450,7 @@ def puti(i)
end
def putip(ipptr)
byte i
for i = 0 to 2
puti(ipptr->[i]); putc('.')
next
@ -467,7 +461,7 @@ end
//
def wizSendUDP(wiz, ipdst, portdst, data, len)
word wizregs, wizdata, txrr, txwr, splitlen
wizregs = wiz=>channel_regs
wizdata = wiz=>channel_txmem
if !ipdst
@ -678,7 +672,7 @@ end
//
def wizSendTCP(wiz, data, len)
word wizregs, wizdata, txrr, txwr, splitlen
if wiz->channel_state <> TCP_STATE_OPEN; return -1; fin
//putc('W');puti(len);putc(':')
wizregs = wiz=>channel_regs
@ -715,7 +709,7 @@ def wizCloseTCP(wiz)
//
// Clear notiications on this port
//
if wiz->channel_proto == WIZ_PROTO_TCP and (wiz->channel_state == TCP_STATE_OPEN or wiz->channel_state == TCP_STATE_CLOSING)
if wiz->channel_proto == WIZ_PROTO_TCP and (wiz->channel_state == TCP_STATE_OPEN or wiz->channel_state == TCP_STATE_CLOSING)
wiz->channel_state = TCP_STATE_CLOSING
pokereg(wiz=>channel_regs + WIZ_SnCR, $08) // DISCON
repeat
@ -768,7 +762,7 @@ end
def wizServiceIP
word wiz, wizregs, wizdata, rxlen, rxrr, rxwr, rxpkt, splitlen
byte ir, i, sir
ir = peekreg(WIZ_IR)
if ir and ir <> $FF // Ignore spurious read of IR
//putc('I');putb(ir)
@ -868,7 +862,7 @@ def wizServiceIP
// Write TCP socket OK
//
//fin
break
break
is WIZ_PROTO_UDP
//putc('U');putb(sir)
if sir & $04
@ -911,7 +905,7 @@ def wizServiceIP
//
pokereg(WIZ_IR, ir)
fin
fin
fin
end
//
// Set the local IP addresses

@ -93,9 +93,6 @@ word[5] arpeggioDuration = DUR16TH, DUR16TH, DUR16TH/2, DUR16TH/3, DUR16TH/4
//
word arg
word ref
asm defs
!SOURCE "../vmsrc/plvmzp.inc"
end
///////////////////////////////////////////////////////////////////////////////
//
// Emulators are broken - they only activate the MockingBoard's 6522 Timer1
@ -105,6 +102,9 @@ end
// disabled. NO INTERRUPTS ARE HANDLED WHEN PLAYING MUSIC! The previous state
// is restored between playing sequences.
//
asm vmincs
!SOURCE "../vmsrc/plvmzp.inc"
end
asm getStatusReg#1
PHP
PLA

@ -1,6 +1,4 @@
import cmdsys
predef puts
end
include "inc/cmdsys.plh"
puts("Hello, world.\n")
done

@ -1,17 +1,4 @@
import cmdsys
predef memset
//
// 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
end
include "inc/cmdsys.plh"
sysflags reshgr1 // Reserve HGR page 1
@ -20,4 +7,4 @@ memset($2000, 0, $2000) // Clear HGR page 1
^$C052
^$C057
^$C050
done
done

@ -1,8 +1,4 @@
import cmdsys
predef memset, memcpy, heapalloc, heapmark, heaprelease
predef puts, putc, gets, getc
predef isugt, isuge, isult, isule
end
include "inc/cmdsys.plh"
import HGR1
end

@ -8,13 +8,7 @@
// - check for binary files and set Content-Type accordingly
// still todo: output base filename for Content-Disposition header
//
import cmdsys
predef syscall, call, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef isugt, isuge, isult, isule
predef heapmark, heapallocalign, heapalloc, heaprelease
byte MACHID
end
include "inc/cmdsys.plh"
//
// Net object
//
@ -116,7 +110,7 @@ def read(refnum, buff, len)
end
def get_eof(refnum)
byte params[5]
params.0 = 2
params.1 = refnum
params:2 = 0
@ -125,7 +119,7 @@ def get_eof(refnum)
return params:2
end
def get_file_info(path)
fileInfo.0 = 10 // param count
fileInfo:1 = path // path name
@ -155,7 +149,7 @@ def puti(i)
end
def putip(ipptr)
byte i
for i = 0 to 2
puti(ipptr->[i]); putc('.')
next
@ -163,7 +157,7 @@ def putip(ipptr)
end
def dumpbytes(buf, len)
word i
for i = 0 to len - 1
putb(buf->[i])
if i & 15 == 15
@ -175,7 +169,7 @@ def dumpbytes(buf, len)
end
def dumpchars(buf, len)
word i
len = len - 1
for i = 0 to len
putc(buf->[i])
@ -194,7 +188,7 @@ def itos(dst, i)
if i < 0; ^dst = '-'; i = -i; dst = dst + 1; fin
if i < 10
^dst = i + '0'
else
else
dst = itos(dst, i / 10)
^dst = i % 10 + '0'
fin
@ -247,7 +241,7 @@ def servHTTP(remip, remport, lclport, data, len, param)
url->1 = url->0 - 1
url = url + 1
fin
fin
fin
strcat(@filename, @prefix, url)
puts("GET:"); puts(@filename);putln
//
@ -271,7 +265,7 @@ def servHTTP(remip, remport, lclport, data, len, param)
//
//puts(@mimeTextHtml) // debug
strcat(@okhdr, @okhdr, @httpContentType)
strcat(@okhdr, @okhdr, @mimeTextHtml)
strcat(@okhdr, @okhdr, @mimeTextHtml)
else
//
// send as binary attachment
@ -285,7 +279,7 @@ def servHTTP(remip, remport, lclport, data, len, param)
//
strcat(@okhdr, @okhdr, @httpContentAttach)
// todo: get the base filename...
fin
fin
strcat(@okhdr, @okhdr, @httpEnd)
//dumpchars(@okhdr + 1, okhdr) // debug
iNet:sendTCP(socketHTTP, @okhdr + 1, okhdr) // send HTTP response header to client
@ -313,8 +307,8 @@ getpfx(@prefix)
//
// Alloc aligned file/io buffers
//
filebuff = heapallocalign(1024, 8, 0)
iobuff = heapallocalign(1024, 8, 0)
filebuff = heapallocalign(1024, 8, 0)
iobuff = heapallocalign(1024, 8, 0)
//
// Service IP
//
@ -329,4 +323,4 @@ repeat
until ^$C000 > 127
^$C010
done
done

@ -1,10 +1,4 @@
import cmdsys
predef syscall, call, memset, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
predef isugt, isuge, isult, isule
byte MACHID
end
include "inc/cmdsys.plh"
import memmgr
predef sweep, brk, sbrk
predef hmemNew, hmemLock, hmemUnlock, hmemRef, hmemDel, hmemFre
@ -76,4 +70,4 @@ if memptr; puth(e); putc('='); puth(*memptr); putln; fin
hmemUnlock(e)
hmemDel(e)
memfre=hmemFre(@memlrgst);puth(memfre); putc(' '); puth(memlrgst); putln
done
done

@ -1,10 +1,4 @@
import cmdsys
predef syscall, call, memset, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
predef isugt, isuge, isult, isule
byte MACHID
end
include "inc/cmdsys.plh"
byte bye = $20, $00, $BF, $65
word paramsptr
byte[7] params = 4
@ -22,4 +16,4 @@ paramsptr = @params
// Call into monitor
//
call(-151, 0, 0, 0, 0)
done
done

@ -1,7 +1,4 @@
import cmdsys
predef syscall(f,p)#1, call(adr,a,x,y,p)#1, memset(d,s,l)#1, getc#1, putc(c)#1, puts(s)#1, modaddr(a)#1
byte MACHID
end
include "inc/cmdsys.plh"
//
// Handy constants.
//

@ -1,9 +1,4 @@
import cmdsys
predef syscall, call, memset, getc, putc, puts, putln
predef memset, memcpy
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
include "inc/cmdsys.plh"
import ROGUEMAP
predef puti, toupper, moveplayer

@ -1,9 +1,4 @@
import cmdsys
predef syscall, call, getc, putc, puts, putln
predef memset, memcpy, modaddr
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
include "inc/cmdsys.plh"
const modkeep = $2000
const modinitkeep = $4000
@ -279,4 +274,4 @@ while ^titlestr
titlestr = titlestr + ^titlestr + 1
loop
done
done

@ -1,12 +1,7 @@
//
// Map module
//
import cmdsys
predef syscall, call, getc, putc, puts, putln
predef memset, memcpy, modaddr
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
include "inc/cmdsys.plh"
import rogueio
const O_READ = 1
@ -767,4 +762,4 @@ export def drawvisentity(xofst, yofst, tile)
fin
end
done
done

@ -1,9 +1,4 @@
import cmdsys
predef syscall, call, memset, getc, gets, putc, puts, putln
predef memset, memcpy
predef heapmark, heapallocalign, heapalloc, heaprelease, heapavail
byte MACHID
end
include "inc/cmdsys.plh"
import roguemap
const xcentr = 20
@ -238,7 +233,7 @@ end
def moveplayer(dir)
byte xmove, ymove
xmove = player.xpos + dir * xdir[player.angle]
ymove = player.ypos + dir * ydir[player.angle]
when getmaptile(xmove, ymove) & MAP_TILE
@ -666,4 +661,3 @@ else
fin
puts(@againstr)
done

@ -1,7 +1,4 @@
import cmdsys
predef syscall, call, memset, getc, putc, puts, putln
byte MACHID
end
include "inc/cmdsys.plh"
const FALSE = 0
const TRUE = !FALSE
@ -48,4 +45,4 @@ beep
beep
puti(count)
puts(@strPrimes)
done
done

File diff suppressed because it is too large Load Diff

@ -79,6 +79,7 @@ byte hpmarkstr[] = "HEAPMARK"
byte hpalignstr[] = "HEAPALLOCALIGN"
byte hpallocstr[] = "HEAPALLOC"
byte hprelstr[] = "HEAPRELEASE"
byte hpavlstr[] = "HEAPAVAIL"
byte memsetstr[] = "MEMSET"
byte memcpystr[] = "MEMCPY"
byte uisgtstr[] = "ISUGT"
@ -100,6 +101,7 @@ word = @hpmarkstr, @markheap
word = @hpallocstr,@allocheap
word = @hpalignstr,@allocalignheap
word = @hprelstr, @releaseheap
word = @hpavlstr, @availheap
word = @memsetstr, @memset
word = @memcpystr, @memcpy
word = @uisgtstr, @uword_isgt

File diff suppressed because it is too large Load Diff

@ -63,7 +63,7 @@ INTERP = $03D0
;*
;* DISCONNECT /RAM
;*
SEI ; DISABLE /RAM
;SEI ; DISABLE /RAM
LDA MACHID
AND #$30
CMP #$30
@ -92,7 +92,7 @@ RAMEXIT LDA NODEV
LDA NODEV+1
STA RAMSLOT+1
DEC DEVCNT
RAMDONE CLI
RAMDONE ;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE
;*
;* MOVE VM INTO LANGUAGE CARD
;*
@ -250,7 +250,7 @@ IINTRPX PLA
STA IFPH
LDA #>OPXTBL
STA OPPAGE
SEI
;SEI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE
STA ALTRDON
!IF SELFMODIFY {
BIT LCRWEN+LCBNK2
@ -1463,9 +1463,9 @@ CALLX +INC_IP
TYA
PHA
STA ALTRDOFF
CLI
;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE
JSR JMPTMP
SEI
;SEI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE
STA ALTRDON
PLA
TAY
@ -1521,9 +1521,9 @@ ICALX LDA ESTKL,X
TYA
PHA
STA ALTRDOFF
CLI
;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE
JSR JMPTMP
SEI
;SEI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE
STA ALTRDON
PLA
TAY
@ -1576,7 +1576,7 @@ ENTER INY
;* LEAVE FUNCTION
;*
LEAVEX STA ALTRDOFF
CLI
;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE
LEAVE PLA ; DEALLOCATE POOL + FRAME
CLC
ADC IFPL
@ -1591,7 +1591,7 @@ LEAVE PLA ; DEALLOCATE POOL + FRAME
RTS
;
RETX STA ALTRDOFF
CLI
;CLI UNTIL I KNOW WHAT TO DO WITH THE UNENHANCED IIE
RET LDA IFPL ; DEALLOCATE POOL
STA PPL
LDA IFPH

@ -74,6 +74,7 @@ byte hpmarkstr[] = "HEAPMARK"
byte hpalignstr[] = "HEAPALLOCALIGN"
byte hpallocstr[] = "HEAPALLOC"
byte hprelstr[] = "HEAPRELEASE"
byte hpavlstr[] = "HEAPAVAIL"
byte memsetstr[] = "MEMSET"
byte memcpystr[] = "MEMCPY"
byte uisgtstr[] = "ISUGT"
@ -96,6 +97,7 @@ word = @hpmarkstr, @markheap
word = @hpallocstr,@allocheap
word = @hpalignstr,@allocalignheap
word = @hprelstr, @releaseheap
word = @hpavlstr, @availheap
word = @memsetstr, @memset
word = @memcpystr, @memcpy
word = @uisgtstr, @uword_isgt