From 5fe534f6b104ab3e0065a20ebcb6bd1ba6daf2bf Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sun, 17 Dec 2017 13:55:29 -0800 Subject: [PATCH 1/3] Text formatting clean-up --- src/toolsrc/ed.pla | 181 ++++++++++++++---------------- src/toolsrc/sb.pla | 108 +++++++++--------- sysfiles/filetype_extensions.conf | 9 ++ 3 files changed, 147 insertions(+), 151 deletions(-) create mode 100644 sysfiles/filetype_extensions.conf diff --git a/src/toolsrc/ed.pla b/src/toolsrc/ed.pla index eb7a518..7a4ee93 100755 --- a/src/toolsrc/ed.pla +++ b/src/toolsrc/ed.pla @@ -79,7 +79,7 @@ word strlinbuf = $1000 word strpoolmap = $1F00 word strpoolmsz = 224 // $E0 = 28K is memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map word strpool = $4800 -word strpoolsz = $7000 +word strpoolsz = $7000 byte flags = 0 byte flash = 0 word numlines = 0 @@ -96,7 +96,7 @@ predef cmdmode // Defines for ASM routines // asm equates - !SOURCE "vmsrc/plvmzp.inc" + !SOURCE "vmsrc/plvmzp.inc" end //def toupper(c) // if c >= 'a' @@ -217,7 +217,7 @@ def newstr(strptr) strlen = ^strptr while (strptr).[strlen] == $8D or (strptr).[strlen] == $A0 - strlen = strlen - 1 + strlen-- loop if strlen == 0 return @nullstr @@ -238,7 +238,6 @@ def inittxtbuf#0 strpoolmsz = 224 // $E0 = 28K is memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map strpool = $4800 strpoolsz = $7000 - memset(strpoolmap, strheapmsz, 0) memset(strlinbuf, maxfill * 2, @nullstr) numlines = 1 @@ -297,14 +296,6 @@ def txtlower#0 strlower(strlinbuf:[i]) next end -def prbyte(h)#0 - cout('$') - call($FDDA, h, 0, 0, 0) -end -def prword(h)#0 - cout('$') - call($F941, h >> 8, h, 0, 0) -end def print(i)#0 byte numstr[7] byte place, sign @@ -319,13 +310,13 @@ def print(i)#0 while i >= 10 numstr[place] = i % 10 + '0' i = i / 10 - place = place - 1 + place-- loop numstr[place] = i + '0' - place = place - 1 + place-- if sign numstr[place] = '-' - place = place - 1 + place-- fin numstr[place] = 6 - place puts(@numstr[place]) @@ -340,27 +331,27 @@ end def readtxt(filename)#0 byte txtbuf[81], refnum, i, j - refnum = open(filename, sysbuf) + refnum = fileio:open(filename) if refnum newline(refnum, $7F, $0D) repeat - txtbuf = read(refnum, @txtbuf + 1, maxlnlen) + txtbuf = fileio:read(refnum, @txtbuf + 1, maxlnlen) if txtbuf sethibit(@txtbuf) if flags & uppercase; strupper(@txtbuf); fin strlinbuf:[numlines] = newstr(@txtbuf) - numlines = numlines + 1 + numlines++ fin if !(numlines & $0F); cout('.'); fin until txtbuf == 0 or numlines == maxlines - close(refnum) - // - // Make sure there is a blank line at the end of the buffer - // - if numlines < maxlines and strlinbuf:[numlines - 1] <> @nullstr - strlinbuf:[numlines] = @nullstr - numlines = numlines + 1 - fin + fileio:close(refnum) + // + // Make sure there is a blank line at the end of the buffer + // + if numlines < maxlines and strlinbuf:[numlines - 1] <> @nullstr + strlinbuf:[numlines] = @nullstr + numlines++ + fin fin end def writetxt(filename)#0 @@ -368,9 +359,9 @@ def writetxt(filename)#0 byte j, chr word i, strptr - destroy(filename) - create(filename, $C3, $04, $00) // full access, TXT file - refnum = open(filename, sysbuf) + fileio:destroy(filename) + fileio:create(filename, $04, $00) // full access, TXT file + refnum = fileio:open(filename) if refnum == 0 return fin @@ -385,15 +376,15 @@ def writetxt(filename)#0 cpyln(strlinbuf:[i], @txtbuf) txtbuf = txtbuf + 1 txtbuf[txtbuf] = $0D - write(refnum, @txtbuf + 1, txtbuf) + fileio:write(refnum, @txtbuf + 1, txtbuf) if !(i & $0F); cout('.'); fin next - close(refnum) + fileio:close(refnum) end // // Screen routines // -def clrscrn@0 +def clrscrn#0 call($FC58, 0, 0, 0, 0) end def drawrow(row, ofst, strptr)#0 @@ -420,30 +411,30 @@ def drawscrn(toprow, ofst)#0 if ofst for row = 0 to 23 strptr = strlinbuf:[toprow + row] - scrnptr = txtscrn[row] - if ofst >= ^strptr - numchars = 0 - else + scrnptr = txtscrn[row] + if ofst >= ^strptr + numchars = 0 + else numchars = ^strptr - ofst - fin - if numchars >= 40 + fin + if numchars >= 40 numchars = 40 - else - memset(scrnptr + numchars, 40 - numchars, $A0A0) - fin - memcpy(scrnptr, strptr + ofst + 1, numchars) + else + memset(scrnptr + numchars, 40 - numchars, $A0A0) + fin + memcpy(scrnptr, strptr + ofst + 1, numchars) next else for row = 0 to 23 strptr = strlinbuf:[toprow + row] - scrnptr = txtscrn[row] - numchars = ^strptr - if numchars >= 40 + scrnptr = txtscrn[row] + numchars = ^strptr + if numchars >= 40 numchars = 40 - else - memset(scrnptr + numchars, 40 - numchars, $A0A0) - fin - memcpy(scrnptr, strptr + 1, numchars) + else + memset(scrnptr + numchars, 40 - numchars, $A0A0) + fin + memcpy(scrnptr, strptr + 1, numchars) next fin end @@ -507,9 +498,9 @@ end def cursup#0 if cursrow > 0 cursoff - cursrow = cursrow - 1 + cursrow-- if cursy > 0 - cursy = cursy - 1 + cursy-- else scrntop = cursrow drawscrn(scrntop, scrnleft) @@ -527,9 +518,9 @@ end def cursdown#0 if cursrow < numlines - 1 cursoff - cursrow = cursrow + 1 + cursrow++ if cursy < 23 - cursy = cursy + 1 + cursy++ else scrntop = cursrow - 23 drawscrn(scrntop, scrnleft) @@ -547,9 +538,9 @@ end def cursleft#0 if curscol > 0 cursoff - curscol = curscol - 1 + curscol-- if cursx > 0 - cursx = cursx - 1 + cursx-- else scrnleft = curscol drawscrn(scrntop, scrnleft) @@ -567,9 +558,9 @@ end def cursright#0 if curscol < 80 cursoff - curscol = curscol + 1 + curscol++ if cursx < 39 - cursx = cursx + 1 + cursx++ else scrnleft = curscol - 39 drawscrn(scrntop, scrnleft) @@ -651,7 +642,7 @@ def openline(row) if numlines < maxlines memcpy(@strlinbuf:[row + 1], @strlinbuf:[row], (numlines - row) * 2) strlinbuf:[row] = @nullstr - numlines = numlines + 1 + numlines++ flags = flags | changed return TRUE fin @@ -663,7 +654,7 @@ def cutline#0 cutbuf = strlinbuf:[cursrow] memcpy(@strlinbuf:[cursrow], @strlinbuf:[cursrow + 1], (numlines - cursrow) * 2) if numlines > 1 - numlines = numlines - 1 + numlines-- fin flags = flags | changed if cursrow == numlines @@ -675,7 +666,7 @@ def pasteline#0 if cutbuf and numlines < maxlines memcpy(@strlinbuf:[cursrow + 1], @strlinbuf:[cursrow], (numlines - cursrow) * 2) strlinbuf:[cursrow] = newstr(cutbuf) - numlines = numlines + 1 + numlines++ flags = flags | changed redraw else @@ -694,7 +685,7 @@ def joinline#0 freestr(strlinbuf:[cursrow]) strlinbuf:[cursrow] = newstr(@joinstr) freestr(strlinbuf:[cursrow + 1]) - numlines = numlines - 1 + numlines-- memcpy(@strlinbuf:[cursrow + 1], @strlinbuf:[cursrow + 2], (numlines - cursrow) * 2) flags = flags | changed redraw @@ -757,34 +748,34 @@ def editline(key) if curscol > 0 if curscol <= editstr memcpy(@editstr[curscol], @editstr[curscol + 1], editstr - curscol) - editstr = editstr - 1 + editstr-- fin - curscol = curscol - 1 + curscol-- cursoff if cursx > 0 - cursx = cursx - 1 + cursx-- drawrow(cursy, scrnleft, @editstr) else - scrnleft = scrnleft - 1 + scrnleft-- drawscrn(scrntop, scrnleft) fin curson fin elsif curscol < maxlnlen - curscol = curscol + 1 - cursx = cursx + 1 + curscol++ + cursx++ if flags & insmode if editstr < maxlnlen or editstr.maxlnlen == $A0 - editstr = editstr + 1 + editstr++ if curscol >= editstr editstr = curscol else memcpy(@editstr[curscol + 1], @editstr[curscol], editstr - curscol) fin else - curscol = curscol - 1 - cursx = cursx - 1 - key = editstr[curscol] + curscol-- + cursx-- + key = editstr[curscol] bell fin else @@ -797,8 +788,8 @@ def editline(key) if cursx <= 39 drawrow(cursy, scrnleft, @editstr) else - scrnleft = scrnleft + 1 - cursx = 39 + scrnleft++ + cursx = 39 drawscrn(scrntop, scrnleft) fin curson @@ -809,7 +800,7 @@ def editline(key) if curscol < editstr strcpy(undoline, @editstr) memcpy(@editstr[curscol + 1], @editstr[curscol + 2], editstr - curscol) - editstr = editstr - 1 + editstr-- cursoff drawrow(cursy, scrnleft, @editstr) curson @@ -859,15 +850,15 @@ def editmode#0 is keyctrlv pasteline; break is keyctrlf - if numlines < maxlines and cursrow == numlines - 1 + if numlines < maxlines and cursrow == numlines - 1 strlinbuf:[numlines] = @nullstr - numlines = numlines + 1 - fin - cursdown + numlines++ + fin + cursdown is keyctrlo openline(cursrow) redraw - break + break is keyenter if flags & insmode splitline @@ -876,7 +867,7 @@ def editmode#0 cursdown redraw fin - break + break is keyctrlt joinline; break is keyctrli @@ -887,7 +878,7 @@ def editmode#0 flags = flags | insmode curschr = '+' fin - break + break is keyctrlc if flags & uppercase txtlower @@ -895,12 +886,12 @@ def editmode#0 txtupper fin redraw - break + break is keyescape cursoff cmdmode redraw - break + break wend until false end @@ -944,12 +935,12 @@ def prfiles(optpath) puts(entry) if type & $F0 == $D0 // Is it a directory? cout('/') - len = len + 1 + len++ fin for len = 20 - len downto 1 cout(' ') next - filecnt = filecnt - 1 + filecnt-- fin entry = entry + entrylen next @@ -965,7 +956,7 @@ end def striplead(strptr, chr)#0 while ^strptr and ^(strptr + 1) == chr memcpy(strptr + 1, strptr + 2, ^strptr) - ^strptr = ^strptr - 1 + ^strptr-- loop end def parsecmd(strptr) @@ -976,7 +967,7 @@ def parsecmd(strptr) if ^strptr cmd = ^(strptr + 1) memcpy(strptr + 1, strptr + 2, ^strptr) - ^strptr = ^strptr - 1 + ^strptr-- fin if ^strptr striplead(strptr, ' ') @@ -999,7 +990,7 @@ def quit#0 exit fin end -def cmdmode +def cmdmode#0 byte slot word cmdptr @@ -1013,17 +1004,17 @@ def cmdmode is 'A' readtxt(cmdptr) flags = flags | changed - break + break is 'R' if chkchng inittxtbuf - numlines = 0 + numlines = 0 strcpy(@txtfile, cmdptr) readtxt(@txtfile) - if numlines == 0; numlines = 1; fin + if numlines == 0; numlines = 1; fin flags = flags & ~changed fin - break + break is 'W' if ^cmdptr strcpy(@txtfile, cmdptr) @@ -1031,7 +1022,7 @@ def cmdmode writetxt(@txtfile) //if flags & changed; fin flags = flags & ~changed - break + break is 'C' prfiles(cmdptr); break is 'P' @@ -1043,7 +1034,7 @@ def cmdmode slot = 1 fin printtxt(slot) - break + break is 'Q' quit is 'E' @@ -1054,7 +1045,7 @@ def cmdmode inittxtbuf strcpy(@txtfile, "UNTITLED") fin - break + break otherwise bell cout('?') diff --git a/src/toolsrc/sb.pla b/src/toolsrc/sb.pla index d6d058e..4d28d29 100644 --- a/src/toolsrc/sb.pla +++ b/src/toolsrc/sb.pla @@ -2024,7 +2024,7 @@ end // def emit_byte(bval)#0 ^codeptr = bval - codeptr = codeptr + 1 + codeptr++ end def emit_word(wval)#0 *codeptr = wval @@ -2087,14 +2087,14 @@ def emit_data(vartype, consttype, constval, constsize) size = constsize emit_fill(constsize) elsif consttype == STR_TYPE - size = constsize - chrptr = constval - constsize = constsize - 1 + size = constsize + chrptr = constval + constsize-- emit_byte(constsize) while constsize > 0 emit_byte(^chrptr) - chrptr = chrptr + 1 - constsize = constsize - 1 + chrptr++ + constsize-- loop else if vartype & BYTE_TYPE @@ -2105,7 +2105,7 @@ def emit_data(vartype, consttype, constval, constsize) if consttype == CONSTADDR_TYPE emit_addr(constval) else - emit_word(constval) + emit_word(constval) fin fin fin @@ -2375,9 +2375,9 @@ def emit_drop#0 end def emit_leave#0 if framesize - emit_op($5A) + emit_op($5A) else - emit_op($5C) + emit_op($5C) fin end def emit_enter(cparams)#0 @@ -2408,7 +2408,7 @@ def idmatch(nameptr, len, idptr, idcnt) fin fin idptr = idptr + idptr->idname + idrecsz - idcnt = idcnt - 1 + idcnt-- loop return 0 end @@ -2431,7 +2431,7 @@ def dumpsym(idptr, idcnt)#0 fin crout idptr = idptr + idptr->idname + idrecsz - idcnt = idcnt - 1 + idcnt-- loop end def id_lookup(nameptr, len) @@ -2455,7 +2455,7 @@ def idlocal_add(namestr, len, type, size) lastlocal=>idval = framesize lastlocal->idtype = type | LOCAL_TYPE nametostr(namestr, len, lastlocal + idname) - locals = locals + 1 + locals++ lastlocal = lastlocal + idrecsz + len if lastlocal > idlocal_tbl + idlocal_tblsz prstr(@local_sym_overflw) @@ -2463,8 +2463,7 @@ def idlocal_add(namestr, len, type, size) fin framesize = framesize + size if framesize > 255 - prstr(@local_overflw) - return FALSE + return parse_err(@local_overflw) fin return TRUE end @@ -2474,7 +2473,7 @@ def iddata_add(namestr, len, type, size) lastglobal->idtype = type nametostr(namestr, len, lastglobal + idname) emit_iddata(datasize, size, lastglobal + idname) - globals = globals + 1 + globals++ lastglobal = lastglobal + idrecsz + len if lastglobal > idglobal_tbl + idglobal_tblsz prstr(@global_sym_overflw) @@ -2496,7 +2495,7 @@ def idglobal_add(namestr, len, type, value) lastglobal=>idval = value lastglobal->idtype = type nametostr(namestr, len, lastglobal + idname) - globals = globals + 1 + globals++ lastglobal = lastglobal + idrecsz + len if lastglobal > idglobal_tbl + idglobal_tblsz prstr(@global_sym_overflw) @@ -2639,7 +2638,7 @@ def pop_val(valptr, sizeptr, typeptr) ^sizeptr = sizestack[valsp] ^typeptr = typestack[valsp] valsp-- - return valsp + 1 + return valsp + 1 end // // Lexical anaylzer @@ -2878,16 +2877,12 @@ def nextln cpyln(strlinbuf:[lineno], instr) lineno++ if !(lineno & $0F); cout('.'); fin - print(lineno);cout(':');print(numlines) - cout('>') - prstr(instr) - crout + //print(lineno);cout(':');print(numlines);cout('>');prstr(instr);crout scan else - cout('<') - crout - ^instr = 0 - ^inbuff = 0 + //cout('<');crout + *instr = 0 + //^inbuff = 0 token = DONE_TKN fin fin @@ -2973,7 +2968,7 @@ def parse_constval when token is SUB_TKN mod = mod | 1; break - is ALT_COMP_TKN + is ALT_COMP_TKN is COMP_TKN mod = mod | 2; break is LOGIC_NOT_TKN @@ -3012,7 +3007,7 @@ def parse_constval if !idptr; return parse_err(@bad_cnst); fin type = idptr->idtype if type & ADDR_TYPE - if mod <> 8; return parse_err(@bad_cnst); fin + if mod <> 8; return parse_err(@bad_cnst); fin type = CONSTADDR_TYPE fin value = idptr=>idval @@ -3139,20 +3134,20 @@ def parse_value(rvalue) if deref push_op(token, 0) else - deref = deref + 1 - type = type | BPTR_TYPE + deref++ + type = type | BPTR_TYPE fin break is WPTR_TKN if deref push_op(token, 0) else - deref = deref + 1 - type = type | WPTR_TYPE + deref++ + type = type | WPTR_TYPE fin break is AT_TKN - deref = deref - 1 + deref-- break is SUB_TKN is ALT_COMP_TKN @@ -3184,14 +3179,14 @@ def parse_value(rvalue) // type = type | WORD_TYPE emit_val = TRUE break - is STR_TKN - // - // Special case - // - emit_constr(constval, tknlen - 1) - scan - return WORD_TYPE - break + is STR_TKN + // + // Special case + // + emit_constr(constval, tknlen - 1) + scan + return WORD_TYPE + break otherwise return 0 wend @@ -3205,16 +3200,16 @@ def parse_value(rvalue) is NEG_TKN pop_op value = -value - break + break is ALT_COMP_TKN is COMP_TKN pop_op value = ~value - break + break is LOGIC_NOT_TKN pop_op value = !value - break + break otherwise cparams = FALSE wend @@ -3238,7 +3233,8 @@ def parse_value(rvalue) ref_offset = 0 fin if ref_type & BPTR_TYPE; emit_lb - elsif ref_type & WPTR_TYPE; emit_lw; fin + elsif ref_type & WPTR_TYPE; emit_lw + fin if lookahead <> CLOSE_PAREN_TKN emit_push fin @@ -3847,7 +3843,7 @@ def parse_var(type) byte consttype, constsize, idlen word idptr, constval, arraysize, size - cout('T') + //cout('T') idlen = 0 size = 1 if scan == OPEN_BRACKET_TKN @@ -3903,7 +3899,7 @@ def parse_struc byte type, idlen, struclen, constsize word size, offset, idstr - cout('S') + //cout('S') struclen = 0 if scan == ID_TKN struclen = tknlen @@ -3959,7 +3955,7 @@ def parse_vars byte idlen, type, size word value, idptr - cout('V') + //cout('V') when token is CONST_TKN if scan <> ID_TKN @@ -4012,7 +4008,7 @@ def parse_defs word func_tag, idptr if token == DEF_TKN - cout('D') + //cout('D') if scan <> ID_TKN; return parse_err(@bad_decl); fin cfnparms = 0 infunc = TRUE @@ -4028,12 +4024,12 @@ def parse_defs idlocal_init if scan == OPEN_PAREN_TKN repeat - if scan == ID_TKN - cfnparms = cfnparms + 1 - idlocal_add(tknptr, tknlen, WORD_TYPE, 2) - scan - fin - until token <> COMMA_TKN + if scan == ID_TKN + cfnparms = cfnparms + 1 + idlocal_add(tknptr, tknlen, WORD_TYPE, 2) + scan + fin + until token <> COMMA_TKN if token <> CLOSE_PAREN_TKN return parse_err(@bad_decl) fin @@ -4070,7 +4066,7 @@ def parse_module while parse_defs nextln loop - cout('I') + //cout('I') framesize = 0 entrypoint = codeptr emit_enter(0) @@ -4080,7 +4076,7 @@ def parse_module nextln loop fin - cout('!') + //cout('!') if prevstmnt <> RETURN_TKN emit_const(0) emit_leave diff --git a/sysfiles/filetype_extensions.conf b/sysfiles/filetype_extensions.conf new file mode 100644 index 0000000..ce0c75f --- /dev/null +++ b/sysfiles/filetype_extensions.conf @@ -0,0 +1,9 @@ +# Filetype extension configuration file for Geany +# Insert as many items as you want, separate them with a ";". +# See Geany's main documentation for details. +[Extensions] +PLASMA=*.pla;*.plh; + +# Note: restarting is required after editing groups +[Groups] +Programming=PLASMA; From 33bc191a150ed65ac03dce281977776eba3812c2 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sun, 17 Dec 2017 14:29:22 -0800 Subject: [PATCH 2/3] Geany editor syntax highlighter for PLASMA --- sysfiles/filetypes.plasma.conf | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 sysfiles/filetypes.plasma.conf diff --git a/sysfiles/filetypes.plasma.conf b/sysfiles/filetypes.plasma.conf new file mode 100644 index 0000000..71d410c --- /dev/null +++ b/sysfiles/filetypes.plasma.conf @@ -0,0 +1,80 @@ +# For complete documentation of this file, please see Geany's main documentation +[styling] +# Edit these in the colorscheme .conf file instead +default=default +commentline=comment_line +number=number_1 +string=string_1 +character=character +word=keyword_1 +global=type +symbol=preprocessor +classname=class +defname=function +operator=operator +identifier=identifier_1 +modulename=type +backticks=backticks +instancevar=default +classvar=default +datasection=default +heredelim=operator +worddemoted=keyword_1 +stdin=default +stdout=default +stderr=default +regex=regex +here_q=here_doc +here_qq=here_doc +here_qx=here_doc +string_q=string_2 +string_qq=string_2 +string_qx=string_2 +string_qr=string_2 +string_qw=string_2 +upper_bound=default +error=error +pod=comment_doc + +[keywords] +# all items must be in one line +primary=done include import export struc const word byte and predef asm def end not or repeat until break for to downto next when wend is otherwise if else elsif fin while loop return + +[settings] +# default extension used when saving files +extension=pla + +# MIME type +mime_type=application/x-plasma + +# the following characters are these which a "word" can contains, see documentation +$wordchars=$_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + +# single comments, like # in this file +comment_single=// +# multiline comments +#comment_open==begin +#comment_close==end + +# set to false if a comment character/string should start at column 0 of a line, true uses any +# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d + #command_example(); +# setting to false would generate this +# command_example(); +# This setting works only for single line comments +comment_use_indent=true + +# context action command (please see Geany's main documentation for details) +context_action_cmd= + +lexer_filetype=C + +[indentation] +width=4 +# 0 is spaces, 1 is tabs, 2 is tab & spaces +type=0 + +[build-menu] +# %f will be replaced by the complete filename +# %e will be replaced by the filename without extension +# (use only one of it at one time) From ab283cb0bfa4be0e09652bfb9fd7a6865b117981 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sun, 17 Dec 2017 15:40:47 -0800 Subject: [PATCH 3/3] Initial module version of ED --- src/makefile | 8 +-- src/toolsrc/ed.pla | 143 +++++++++++++++++++-------------------------- 2 files changed, 64 insertions(+), 87 deletions(-) diff --git a/src/makefile b/src/makefile index dce4ea5..997e798 100755 --- a/src/makefile +++ b/src/makefile @@ -6,7 +6,7 @@ PLVM02 = PLASMA.SYSTEM\#FF2000 PLVM802 = PLASMA16.SYSTEM\#FF2000 PLVM03 = SOS.INTERP\#050000 CMD = CMD\#FF2000 -ED = ED\#FF2000 +ED = ED\#FE1000 SB = SB\#FF2000 ROD = ROD\#FE1000 SIEVE = SIEVE\#FE1000 @@ -69,7 +69,7 @@ TXTTYPE = .TXT #SYSTYPE = \#FF2000 #TXTTYPE = \#040000 -all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM802) $(PLVM03) $(CMD) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(SB) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1) $(TONE) $(DGR) $(DGRTEST) $(FILEIO) $(CONIO) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(RPNCALC) +all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM802) $(PLVM03) $(CMD) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(ED) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1) $(TONE) $(DGR) $(DGRTEST) $(FILEIO) $(CONIO) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(RPNCALC) clean: -rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) @@ -122,8 +122,8 @@ test: samplesrc/test.pla samplesrc/testlib.pla $(PLVM) $(PLASM) ./$(PLVM) TEST $(ED): toolsrc/ed.pla $(PLVM02) $(PLASM) toolsrc/ed.pla - ./$(PLASM) -AOW < toolsrc/ed.pla > toolsrc/ed.a - acme --setpc 8192 -o $(ED) toolsrc/ed.a + ./$(PLASM) -AMOW < toolsrc/ed.pla > toolsrc/ed.a + acme --setpc 4094 -o $(ED) toolsrc/ed.a $(SB): toolsrc/sb.pla $(PLVM02) $(PLASM) toolsrc/sb.pla ./$(PLASM) -AOW < toolsrc/sb.pla > toolsrc/sb.a diff --git a/src/toolsrc/ed.pla b/src/toolsrc/ed.pla index 7a4ee93..f93a9f4 100755 --- a/src/toolsrc/ed.pla +++ b/src/toolsrc/ed.pla @@ -7,6 +7,8 @@ include "inc/cmdsys.plh" include "inc/args.plh" include "inc/fileio.plh" +const FALSE = 0 +const TRUE = not FALSE // // Hardware constants // @@ -16,6 +18,7 @@ const pushbttn2 = $C062 const pushbttn3 = $C063 const keyboard = $C000 const keystrobe = $C010 +const cmdline = $01FF // // ASCII key values // @@ -75,21 +78,22 @@ word = $0450,$04D0,$0550,$05D0,$0650,$06D0,$0750,$07D0 // byte nullstr = "" byte[64] txtfile = "UNTITLED" -word strlinbuf = $1000 -word strpoolmap = $1F00 -word strpoolmsz = 224 // $E0 = 28K is memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map -word strpool = $4800 -word strpoolsz = $7000 +word strlinbuf = $1000 +word strpoolmap = $1F00 +word strpoolmsz = 224 // $E0 = 28K is memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map +word strpool = $4800 +word strpoolsz = $7000 +byte exit = FALSE byte flags = 0 byte flash = 0 word numlines = 0 word cutbuf = 0 -byte perr, cursx, cursy, scrnleft, curscol, underchr, curschr +byte cursx, cursy, scrnleft, curscol, underchr, curschr word keyin, cursrow, scrntop, cursptr // // Predeclared functions // -predef cmdmode +predef cmdmode#0 // // Utility functions // @@ -98,26 +102,6 @@ predef cmdmode asm equates !SOURCE "vmsrc/plvmzp.inc" end -//def toupper(c) -// if c >= 'a' -// if c <= 'z' -// return c - $20 -// fin -// fin -// return c -//end -asm toupper - LDA ESTKL,X - AND #$7F - CMP #'a' - BCC + - CMP #'z'+1 - BCS + - SEC - SBC #$20 -+ STA ESTKL,X - RTS -end asm clrhibit(strptr) LDA ESTKL,X STA SRCL @@ -181,11 +165,8 @@ CPLNLP LDA (SRC),Y RTS end -def crout - cout($0D) -end def bell - cout($07) + putc($07) end // // Memory management routines @@ -204,11 +185,11 @@ def delstr(strptr) byte mask, ofst if strptr and strptr <> @nullstr - mask = sizemask(^strptr + 1) - ofst = (strptr - strheap) >> 4 - mask = mask << (ofst & $07) - ofst = ofst >> 3 - strpoolmap->[ofst] = strpoolmap->[ofst] & ~mask +// mask = sizemask(^strptr + 1) +// ofst = (strptr - strheap) >> 4 +// mask = mask << (ofst & $07) +// ofst = ofst >> 3 +// strpoolmap->[ofst] = strpoolmap->[ofst] & ~mask fin end def newstr(strptr) @@ -222,24 +203,24 @@ def newstr(strptr) if strlen == 0 return @nullstr fin - newptr = strpoolalloc(strlen + 1) - if newptr - memcpy(newptr, strptr, strlen + 1) - ^newptr = strlen - return newptr - fin +// newptr = strpoolalloc(strlen + 1) +// if newptr +// memcpy(newptr, strptr, strlen + 1) +// ^newptr = strlen +// return newptr +// fin return @nullstr end def inittxtbuf#0 word i - strlinbuf = $1000 - strpoolmap = $1F00 - strpoolmsz = 224 // $E0 = 28K is memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map - strpool = $4800 - strpoolsz = $7000 - memset(strpoolmap, strheapmsz, 0) - memset(strlinbuf, maxfill * 2, @nullstr) +// strlinbuf = $1000 +// strpoolmap = $1F00 +// strpoolmsz = 224 // $E0 = 28K is memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map +// strpool = $4800 +// strpoolsz = $7000 +// memset(strpoolmap, strheapmsz, 0) +// memset(strlinbuf, maxfill * 2, @nullstr) numlines = 1 cursrow = 0 curscol = 0 @@ -342,7 +323,7 @@ def readtxt(filename)#0 strlinbuf:[numlines] = newstr(@txtbuf) numlines++ fin - if !(numlines & $0F); cout('.'); fin + if !(numlines & $0F); putc('.'); fin until txtbuf == 0 or numlines == maxlines fileio:close(refnum) // @@ -377,7 +358,7 @@ def writetxt(filename)#0 txtbuf = txtbuf + 1 txtbuf[txtbuf] = $0D fileio:write(refnum, @txtbuf + 1, txtbuf) - if !(i & $0F); cout('.'); fin + if !(i & $0F); putc('.'); fin next fileio:close(refnum) end @@ -634,7 +615,7 @@ def printtxt(slot)#0 for i = 0 to numlines - 1 cpyln(strlinbuf:[i], @txtbuf) puts(@txtbuf) - crout + putln next *csw = scrncsw end @@ -650,7 +631,7 @@ def openline(row) return FALSE end def cutline#0 - freestr(cutbuf) + delstr(cutbuf) cutbuf = strlinbuf:[cursrow] memcpy(@strlinbuf:[cursrow], @strlinbuf:[cursrow + 1], (numlines - cursrow) * 2) if numlines > 1 @@ -682,9 +663,9 @@ def joinline#0 if joinlen < 80 memcpy(@joinstr + joinstr + 1, strlinbuf:[cursrow + 1] + 1, ^(strlinbuf:[cursrow + 1])) joinstr = joinlen - freestr(strlinbuf:[cursrow]) + delstr(strlinbuf:[cursrow]) strlinbuf:[cursrow] = newstr(@joinstr) - freestr(strlinbuf:[cursrow + 1]) + delstr(strlinbuf:[cursrow + 1]) numlines-- memcpy(@strlinbuf:[cursrow + 1], @strlinbuf:[cursrow + 2], (numlines - cursrow) * 2) flags = flags | changed @@ -706,7 +687,7 @@ def splitline#0 strlinbuf:[cursrow + 1] = newstr(@splitstr) memcpy(@splitstr + 1, strlinbuf:[cursrow] + 1, curscol) splitstr = curscol - freestr(strlinbuf:[cursrow]) + delstr(strlinbuf:[cursrow]) strlinbuf:[cursrow] = newstr(@splitstr) fin else @@ -818,7 +799,7 @@ def editline(key) else strlinbuf:[cursrow] = @nullstr fin - freestr(undoline) + delstr(undoline) fin return key end @@ -893,7 +874,7 @@ def editmode#0 redraw break wend - until false + until exit end // // Command mode @@ -904,22 +885,23 @@ def prfiles(optpath) byte firstblk byte entrylen, entriesblk byte i, type, len - word entry, filecnt + word databuff, entry, filecnt if ^optpath strcpy(@path, optpath) else getpfx(@path) puts(@path) - crout + putln fin - refnum = open(@path, sysbuf) + databuff = heapalloc(512) + refnum = fileio:open(@path) if perr return perr fin firstblk = 1 repeat - if read(refnum, databuff, 512) == 512 + if fileio:read(refnum, databuff, 512) == 512 entry = databuff + 4 if firstblk entrylen = databuff.$23 @@ -934,11 +916,11 @@ def prfiles(optpath) ^entry = len puts(entry) if type & $F0 == $D0 // Is it a directory? - cout('/') + putc('/') len++ fin for len = 20 - len downto 1 - cout(' ') + putc(' ') next filecnt-- fin @@ -949,8 +931,9 @@ def prfiles(optpath) filecnt = 0 fin until filecnt == 0 - close(refnum) - crout + fileio:close(refnum) + heaprelease(databuff) + putln return 0 end def striplead(strptr, chr)#0 @@ -978,28 +961,22 @@ def chkchng if flags & changed puts("LOSE CHANGES TO FILE (Y/N)?") if toupper(keyin()) == 'N' - crout + putln return FALSE fin - crout + putln fin return TRUE end -def quit#0 - if chkchng - exit - fin -end def cmdmode#0 byte slot word cmdptr clrscrn - puts("PLASMA ][ EDITOR VERSION 0.99") - crout - while TRUE + puts("PLASMA ][ EDITOR VERSION 0.99\n") + while not exit puts(@txtfile) - cmdptr = rdstr($BA) + cmdptr = gets($BA) when toupper(parsecmd(cmdptr)) is 'A' readtxt(cmdptr) @@ -1036,7 +1013,7 @@ def cmdmode#0 printtxt(slot) break is 'Q' - quit + exit = chkchng is 'E' is 0 return @@ -1048,8 +1025,8 @@ def cmdmode#0 break otherwise bell - cout('?') - crout + putc('?') + putln wend if perr puts("ERROR: $") @@ -1057,7 +1034,7 @@ def cmdmode#0 else puts("OK") fin - crout + putln loop end // @@ -1070,8 +1047,8 @@ else keyin = @keyin2e fin inittxtbuf -if argbuff - strcpy(@txtfile, @argbuff) +if ^argNext(argFirst) + strcpy(@txtfile, cmdline) puts(@txtfile) numlines = 0 readtxt(@txtfile)