;›; AUTO.ACT›;›; Copyright 1984 by Action Computer Services›; All Rights Reserved›;››; last modified January 11, 1984›››DEFINE STRING = "CHAR ARRAY"›DEFINE JMP = "$4C" ; JMP addr16››TYPE INSTR=[BYTE op CARD addr]›INSTR mvec=$4F2››BYTE linemax=$4CF›BYTE COLCRS=$55, LMARGIN=$52›STRING buf(0)=$9B^››; version 3.0 ROM:›;PROC CSRet=$A4A6()[]›;PROC Back=$AA24()[]››; version 3.1 to 3.6 ROM:›PROC CSRet=$A4A9()[]›PROC Back=$AA2E()[]›››PROC InsertCh() ; actual address filled›; in Init below.››PROC Auto()› CHAR c› BYTE i, j› BYTE indent=$9A, choff=$8D, sp=$8C›› InsertCh()›› IF sp>=linemax THEN› i = buf(0)› IF buf(i)=' THEN› c = buf(i-1)› IF c='. OR c='? OR c=': OR› c='! OR c='; THEN› i = i - 2› FI› FI› WHILE buf(i)#' AND i#0 DO› i = i - 1› OD› IF i>1 THEN› FOR j = i TO buf(0)-1 DO› buf(j) = buf(j+1)› OD› buf(0) ==- 1› i = i - 1› choff = i+LMARGIN-COLCRS-indent› FI› CSRet()› Back()› FI›RETURN››; only code generated before Init is›; allocated space. Init will be›; garbage collected (well kind of).›; Rest of code is safe as long as›; cartridge is not booted (cold start).››PROC Init()› CARD codeBlock, bsize, csize, nBlock› CARD POINTER cur, next› CARD ARRAY codeBase=$491››; find code block entry in free list› codeBlock = codeBase^ - 4› next = $80 ; AFbase› DO› cur = next› next = next^› IF next=0 THEN ; can't find block› PutE()› PrintE("ýI can't allocate space for your code")› PrintE("You better Boot and try again!")› RETURN› FI› UNTIL next=codeBlock OD››; setup screen› LMARGIN = 0› linemax = 40››; link in our routine› InsertCh = mvec.addr› mvec.op = JMP› mvec.addr = Auto››; actually reserve space for routines›; assume we can split block› csize = @codeBlock-codeBlock› nBlock = next^› bsize = next(1) - csize› next = @codeBlock› cur^ = next› next^ = nBlock› next(1) = bsize› codeBase^ = @codeBlock›RETURN››