
; RTL.ACT
; Copyright (c) 1986,  Paul van de Graaf
; Permission is granted for members of
; Usenet & Arpanet to use this program.
; It is NOT to be distributed beyond
; Usenet & Arpanet sites; sold, or traded
; without consent of the author.

SET $E   = $4000
SET $491 = $4000

DEFINE R     =   "4",  RW    =  "12",
       JMP   = "$4C",  EOL   = "$9B",
       CLEAR = "125",  OPEN  = "$03",
       PUTC  = "$0B",  CLOSE = "$0C"

BYTE IC0CMD  = $342,  IC7CMD  = $3B2,
     IC0AUX  = $34A,  IC7AUX  = $3BA,
     IC0AUX2 = $34B,  IC7AUX2 = $3BB,
     RAMSIZ  = $2E4,  RAMTOP  = $6A

CARD IC0BUF  = $344,  IC7BUF  = $3B4,
     IC0BLEN = $348,  IC7BLEN = $3B8

CHAR ARRAY editor = [ 'E ': EOL ],
           keybrd = [ 'K ': EOL ]

PROC CIO = $E456(BYTE Areg, Xreg)

PROC Put(CHAR chr)
  
  IC0CMD = PUTC
  IC0BLEN = 0
  CIO(chr,0)
RETURN

PROC Print(CHAR ARRAY msg)

  IC0CMD = PUTC
  IC0BUF = msg + 1
  IC0BLEN = msg(0)
  CIO(0,0)
RETURN

PROC main()
  BYTE POINTER ErrorAdr = Error

  IF RAMTOP >= $C0 THEN
    IC0CMD = CLOSE
    CIO(0,0)      ; Close(0)

    ; Bump down top of memory so the
    ; copy of the Action! cartridge
    ; won't clobber display memory.

    RAMTOP = $A0  RAMSIZ = $A0

    IC0CMD = OPEN
    IC0BUF = editor
    IC0AUX = RW
    IC0AUX2 = 0
    CIO(0,0)      ; Open(0,"E:",RW,0)

    IC7CMD = OPEN
    IC7BUF = keybrd
    IC7AUX = R
    IC7AUX2 = 0
    CIO(0,$70)    ; Open(7,"K:",R,0)

    ; Set up the Error Handler:
    ; On an Error, Action! jumps to
    ; the address Error, which we
    ; set to contain a JMP $A3A2.

    ErrorAdr^ = JMP
    Error = $A3A2
  ELSE
    Put(CLEAR)
    Print("The Home-Brew Action! ")
    Print(" Run-time Library")
    Print("requires at least 48K ")
    Print("bytes of memory.")
    Put(EOL)
    Put(EOL)
    Print("Please Remove Cartridge(s)!")
    DO
    OD            ; Hang in a loop.
  FI
RETURN

--- CUT HERE ---

; FIXACT.ACT
; Copyright (c) 1986,  Paul van de Graaf 
; Permission is granted for members of
; Usenet & Arpanet to use this program.
; It is NOT to be distributed beyond
; Usenet & Arpanet sites; sold, or traded
; without consent of the author.

SET $E   = $4000
SET $491 = $4000

DEFINE NOP = "$EA", RTS = "$60"

PROC main()
  ; Change STA $A04A in the
  ; multiply routine to NOPs.

  Poke($A036,NOP) 
  Poke($A037,NOP) 
  Poke($A038,NOP) 

  ; Change JMP $B889 in the default
  ; error handler to an RTS.

  Poke($A3A2,RTS) 

  ; Change DEC $A395,X in the CIO
  ; error check routine to NOPs.  

  Poke($A3BD,NOP) 
  Poke($A3BE,NOP) 
  Poke($A3BF,NOP) 

  ; Change JSR $B8C2 and JMP $A339
  ; in the PrintF() routine to NOPs.

  Poke($A438,NOP)  Poke($A439,NOP)
  Poke($A43A,NOP)  Poke($A43B,NOP)
  Poke($A43C,NOP)  Poke($A43D,NOP)

  ; Change STA ($A5),Y in the
  ; Close() routine to NOPs.

  Poke($B02A,NOP)
  Poke($B02B,NOP)
RETURN

--- CUT HERE ---

; CLEANUP.ACT
; Copyright (c) 1986,  Paul van de Graaf
; Permission is granted for members of
; Usenet & Arpanet to use this program.
; It is NOT to be distributed beyond
; Usenet & Arpanet sites; sold, or traded
; without consent of the author.

SET $E   = $4000
SET $491 = $4000

DEFINE RW = "12"

BYTE RAMSIZ = $2E4, RAMTOP = $6A

PROC main()
  
  Close(7)
  Close(0)
  RAMSIZ = $C0  RAMTOP = $C0
  Open(0,"E:",RW,0)
RETURN
