From: Rick_Michael_Cortese@cup.portal.com
Newsgroups: comp.sys.atari.8bit
Subject: Re: Quest for Refresh
Date: Fri,  2 Oct 92 13:57:02 PDT
Organization: The Portal System (TM)
 muohio.edu> <92270.164344JJMCWILL@MTUS5.BITNET>
  <66704@cup.portal.com><92272.202908JJMCWILL@MTUS5.BITNET>
  <66832@cup.portal.com> <92273.141031JJMCWILL@MTUS5.BITNET>
  <66857@cup.portal.com>

;I know it's supposed to be 80 columns
;but I decided to add a few other modes
;just to show how you can mix modes
;The term just uses 80X24 though
;user prompts can be anything including
;Drawto x,y etc.
;
;The character set is laid out in the
;middle of standard set. It's shrunk
;down to 80X32 so it can be redone for
;a little more detail.  Depending on
;where it goes, it shifted RT or LFT
;then combined with the existing screen
;data:
;
;00000000    00000000
;000X0000    0X000000
;00X0X000    X0X00000
;00XXX000 => XXX00000
;00X0X000    X0X00000
;00X0X000    X0X00000
;00X0X000    X0X00000
;00000000    00000000
;
;I'm going to be moving the screen from
;just under cart to 4k below, it has
;to be 4k to make the GR. 8 screen RAM
;properly aligned for DR. xxx,xxx etc.
;this gives me the ability to scroll
;W/O moving the 1st 320 bytes of the
;Cart to screen RAM. Since I've got
;all that extra space, I'll put some
;variables & Buffers there. There's
;enough room left to add a PM cursor
;& some transfer utilities. Just don't
;have the time myself right now, but
;anyone who want's to add them is more
;then welcome. The .COM file has been
;compiled & had the P:R: handler
;appended. You may have to change the
;program start depending on the DOS
;you use & size of your handler.
;Keep the FONTs on drive 1 unless
;you want to recompile with different
;defaults. Rick Cortese 3/91
;
SET 14=$2400
SET $491=$2400
;INCLUDE "D:RUNTIME.ACT"
BYTE ARRAY Test1=
"This is an 80X24 column test!",
Test2=
"This is an 40X24 column test!",
Test3=
"This is an 40X32 column test!",
Test4=
"This is an 80X32 column test!",
Term80fnt(1023)=$9C00,
Term40fnt(1023)=$9800,
Buffer=$9200
;
;Buffer can go from $9200 to $9C00 W/O
;hitting anything =>size=2560 bytes
;Just enough for 8 scan lines!
;
BYTE POINTER Bptr,Scrptr
BYTE Xpos=[0],Bctr,a
CARD Msc=88,Charset80X24,Charset40X32,
     RamChSet,Ypos=[0]

PROC Plot40X32(CARD Zap)
;
;I know Zap is a byte, but by cheating
;a little I get a 10% speed increase
;You can't ASL a byte 3 times
;1st: Ordinary PUT to E:, alpha numeric
;Most things will be lower case so do
;it 1st for speed
;
IF Zap>95 AND Zap<128
 THEN
 Bptr=Term40fnt+Zap LSH 3
 Scrptr=Msc+Xpos+Ypos
 FOR
  Scrptr=Scrptr TO Scrptr+200 STEP 40
   DO
      Scrptr^=Bptr^
   Bptr==+1
   OD
Xpos==+1
;
;Upper case conversion to screen byte
;
ELSEIF Zap>31 AND Zap<96
 THEN Zap==-32
 Bptr=Term40fnt+Zap lsh 3
 Scrptr=Msc+Xpos+Ypos
 FOR
  Scrptr=Scrptr TO Scrptr+200 STEP 40
   DO
    Scrptr^=Bptr^
    Bptr==+1
   OD
Xpos==+1
;
;Well then was it and Atari EOL?
;
ELSEIF Zap=155
 THEN Xpos=0
  Ypos==+240
;
;How about an ASCII CR?
;
ELSEIF Zap=13
 THEN
  Xpos=0
;
;An ASCII Line feed?
;
ELSEIF Zap=10
 THEN
  Ypos==+240
;
;An ASCII Back Space?
;
ELSEIF Zap=8
 THEN
  IF Xpos>0
   Then
    Xpos==-1
  FI
FI
;
;FI=>I give up! Just ignore it for now
;
IF Xpos>39
 THEN Xpos=0
  Ypos==+240
FI
;
;The screen scroll! This
;would not be a problem if
;the text lines were at least 50 chars
;wide even to 2400 baud, but if the
;host sends a bunch of line feeds to
;scroll/clear the screen or a bunch of
;40 byte lines=>OVERFLOW!
;
IF Ypos>7440 THEN
MoveBlock(Msc,Msc+240,7680)
Ypos=7440
Xpos=0
FI

RETURN


PROC Plot80X32(CARD Zap)

IF Ypos>7440 THEN Ypos=7280 FI
IF Zap>95 AND Zap<128
 THEN
 Bptr=Charset80X24+(Zap LSH 3)
 Scrptr=Msc+Xpos RSH 1+Ypos
 a=Xpos MOD 2
 FOR
  Scrptr=Scrptr TO Scrptr+200 STEP 40
   DO
    IF a
     THEN
      Scrptr^=Bptr^ RSH 2
       %
      Scrptr^
    ELSE
     Scrptr^=Bptr^ LSH 2
      %
     Scrptr^
    FI
   Bptr==+1
   OD
Xpos==+1
;
;Upper case conversion to screen byte
;
ELSEIF Zap>31 AND Zap<96
 THEN Zap==-32
 Bptr=Charset80X24+Zap LSH 3
 Scrptr=Msc+Xpos RSH 1+Ypos
 a=Xpos MOD 2
 FOR
  Scrptr=Scrptr TO Scrptr+200 STEP 40
   DO
    IF a
     THEN
      Scrptr^=Bptr^ RSH 2
       %
      Scrptr^
     ELSE
      Scrptr^=Bptr^ LSH 2
       %
      Scrptr^
    FI
   Bptr==+1
   OD
Xpos==+1
;
;Well then was it and Atari EOL?
;
ELSEIF Zap=155
 THEN Xpos=0
  Ypos==+240
;
;How about an ASCII CR?
;
ELSEIF Zap=13
 THEN
  Xpos=0
;
;An ASCII Line feed?
;
ELSEIF Zap=10
 THEN
  Ypos==+240
;
;An ASCII Back Space?
;
ELSEIF Zap=8
 THEN
  IF Xpos>0
   Then
    Xpos==-1
  FI
FI
;
;FI=>I give up! Just ignore it for now
;
IF Xpos>79
 THEN Xpos=0
  Ypos==+240
FI
;
;The screen scroll!
;
IF Ypos>7440 THEN
MoveBlock(Msc,Msc+240,7680)
Ypos=7440
Xpos=0
FI

RETURN

PROC Plot40(CARD Zap)

IF Zap>95 AND Zap<128
 THEN
 Bptr=RamChSet+Zap LSH 3
 Scrptr=Msc+Xpos+Ypos
 FOR
  Scrptr=Scrptr TO Scrptr+280 STEP 40
   DO
      Scrptr^=Bptr^
   Bptr==+1
   OD
Xpos==+1
;
;Upper case conversion to screen byte
;
ELSEIF Zap>31 AND Zap<96
 THEN Zap==-32
 Bptr=$E000+Zap LSH 3
 Scrptr=Msc+Xpos+Ypos
 FOR
  Scrptr=Scrptr TO Scrptr+280 STEP 40
   DO
      Scrptr^=Bptr^
   Bptr==+1
   OD
Xpos==+1
;
;Well then was it and Atari EOL?
;
ELSEIF Zap=155
 THEN Xpos=0
  Ypos==+320
;
;How about an ASCII CR?
;
ELSEIF Zap=13
 THEN
  Xpos=0
;
;An ASCII Line feed?
;
ELSEIF Zap=10
 THEN
  Ypos==+320
;
;An ASCII Back Space?
;
ELSEIF Zap=8
 THEN
  IF Xpos>0
   Then
    Xpos==-1
  FI
FI
;
;FI=>I give up! Just ignore it for now
;
IF Xpos>39
 THEN Xpos=0
  Ypos==+320
FI
;
;The screen scroll!
;
IF Ypos>7360 THEN
MoveBlock(Msc,Msc+320,7680)
Ypos=7360
Xpos=0
FI

RETURN


PROC Plot80(CARD Zap)

IF Zap>95 AND Zap<128
 THEN
 Bptr=Charset80X24+(Zap LSH 3)
 Scrptr=Msc+Xpos RSH 1+Ypos
 a=Xpos MOD 2
 FOR
  Scrptr=Scrptr TO Scrptr+280 STEP 40
   DO
    IF a
     THEN
      Scrptr^=Bptr^ RSH 2
       %
      Scrptr^
    ELSE
     Scrptr^=Bptr^ LSH 2
      %
     Scrptr^
    FI
   Bptr==+1
   OD
Xpos==+1
;
;Upper case conversion to screen byte
;
ELSEIF Zap>31 AND Zap<96
 THEN Zap==-32
 Bptr=Charset80X24+Zap LSH 3
 Scrptr=Msc+Xpos RSH 1+Ypos
 a=Xpos MOD 2
 FOR
  Scrptr=Scrptr TO Scrptr+280 STEP 40
   DO
    IF a
     THEN
      Scrptr^=Bptr^ RSH 2
       %
      Scrptr^
     ELSE
      Scrptr^=Bptr^ LSH 2
       %
      Scrptr^
    FI
   Bptr==+1
   OD
Xpos==+1
;
;Well then was it and Atari EOL?
;
ELSEIF Zap=155
 THEN Xpos=0
  Ypos==+320
;
;How about an ASCII CR?
;
ELSEIF Zap=13
 THEN
  Xpos=0
;
;An ASCII Line feed?
;
ELSEIF Zap=10
 THEN
  Ypos==+320
;
;An ASCII Back Space?
;
ELSEIF Zap=8
 THEN
  IF Xpos>0
   Then
    Xpos==-1
 Scrptr=Msc+Xpos RSH 1+Ypos
 a=Xpos MOD 2
 FOR
  Scrptr=Scrptr TO Scrptr+280 STEP 40
   DO
    IF a
     THEN
      Scrptr^== & $F0
    ELSE
     Scrptr^== & $0F
    FI
   Bptr==+1
   OD
  FI
FI
;
;FI=>I give up! Just ignore it for now
;
IF Xpos>79
 THEN Xpos=0
  Ypos==+320
FI
;
;The screen scroll!
;
IF Ypos>7360 THEN
MoveBlock(Msc,Msc+320,7680)
Ypos=7360
Xpos=0
FI

RETURN

PROC INIT()

CARD Counter

Charset80X24=Term80fnt

Xpos=0
Ypos=0
Poke(709,14)
Poke(712,144)
Poke(710,144)
Close (3)
Open(3,"D:TRM80X24.FNT",4,0)
FOR Counter=0 TO 1023
 DO
  Term80fnt(Counter)=GetD(3)
 OD
Close (3)
Open(3,"D:TRM40X32.FNT",4,0)
FOR Counter=0 TO 1023
 DO
  Term40fnt(Counter)=GetD(3)
 OD
Close (3)

RETURN

PROC Print40X32E(BYTE ARRAY Message)

FOR Bctr=1 TO Message(0)
 DO
  Plot40X32(Message(Bctr))
 OD
Plot40X32(155)
RETURN

PROC Print40X32(BYTE ARRAY Message)

FOR Bctr=1 TO Message(0)
 DO
  Plot40X32(Message(Bctr))
 OD

RETURN
PROC Print80X32E(BYTE ARRAY Message)

FOR Bctr=1 TO Message(0)
 DO
  Plot80X32(Message(Bctr))
 OD
Plot80X32(155)

RETURN

PROC Print80X32(BYTE ARRAY Message)

FOR Bctr=1 TO Message(0)
 DO
  Plot80X32(Message(Bctr))
 OD

RETURN

PROC Print40E(BYTE ARRAY Message)

FOR Bctr=1 TO Message(0)
 DO
  Plot40(Message(Bctr))
 OD
Plot40(155)
RETURN

PROC Print40(BYTE ARRAY Message)

FOR Bctr=1 TO Message(0)
 DO
  Plot40(Message(Bctr))
 OD

RETURN
PROC Print80E(BYTE ARRAY Message)

FOR Bctr=1 TO Message(0)
 DO
  Plot80(Message(Bctr))
 OD
Plot80(155)

RETURN

PROC Print80(BYTE ARRAY Message)

FOR Bctr=1 TO Message(0)
 DO
  Plot80(Message(Bctr))
 OD

RETURN

PROC MINIT(BYTE CHAN)
BYTE Ch,Bctr

CLOSE(2)
CLOSE(1)
OPEN(1,"K:",4,0);

PRINT40E("Input BAUD rate!")
PRINT40E("  (1)=300 BAUD")
PRINT40E("  (2)=1200 BAUD")
PRINT40E("  (3)=2400 BAUD")
DO
 Ch=GETD(1)
UNTIL
Ch < 52 and Ch > 48
OD
;DTR CTS stuff
XIO(Chan,0,34,192,0,"R:")
XIO(Chan,0,38,0,0,"R:")
;
;We don't need concurent since we do
;our own screen routines, I used 13
;instead of 12 though to be sure of
;being 850 compatable
;
OPEN(Chan,"R:",13,0)
;
;BAUD
;
IF Ch='1
 THEN
  XIO(Chan,0,36,8,0,"R:")
ELSEIF Ch='2
 THEN
  XIO(Chan,0,36,10,0,"R:")
ELSEIF Ch='3
 THEN
  XIO(Chan,0,36,12,0,"R:")
FI
;
;Light ASCII translation
;
XIO(Chan,0,40,0,0,"R:")
GRAPHICS(8+32)
PRINT("Number to dial? ")
INPUTS(Test1)
PRINTD(2,"ATDT")
PRINTDE(2,TEST1)
GRAPHICS(8+32+16)


RETURN


PROC Main()

CARD Ch,Cctr
BYTE SavRamTop,Caps=[0]

SavRamTop=Peek(106)
Poke(106,144)
Graphics(24)
Zero(Msc,8001)
Poke(559,0)
Ch=Peek(20)
WHILE Ch=Peek(20) DO OD
INIT()
Poke(559,34)
RamChSet=Peek(756)*$100
Close(2)
FOR Cctr=0 TO 3
 DO
  Print40E(Test2)
 OD
FOR Cctr=0 TO 3
 DO
  Print80E(Test1)
 OD
FOR Cctr=0 TO 3
 DO
  Print80X32E(Test4)
 OD
FOR Cctr=0 TO 3
 DO
  Print40X32E(Test3)
 OD
;
;now the modem INIT
;
MINIT(2)
DO
;
;Status
;
XIO (2,0,13,0,0,"R:")
IF PEEK(747)
 THEN
  Ch=GetD(2)
  PLOT80(Ch)
FI
IF peek(764)<>255
 then
  IF PEEK(764)=60
   THEN
    Caps==XOR 64
    Poke(702,Caps)
    Poke(764,255)
  Else
   Ch=GetD(1)
    IF Ch=126 then Ch=8 FI
   PUTD(2,Ch)
  FI
FI

UNTIL (Peek(53279) & 7)<> 7
od
Graphics(0)
Close(2)
Close(1)
WHILE Peek(764)=255 DO OD
Poke(764,255)
Poke(106,SavRamTop)
Graphics(0)
RETURN