;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
;`~`    Simpleterm Version 1.0 - Totally Public Domain Freeware!      ~`~
;~`~           Source Code For - Simpleterm Version 1.0               `~`
;`~`             Programmed by - Luciano Bertato                      ~`~
;~`~                CompuServe - 73246,1744                           `~`
;`~`     Canada Remote Systems - LUCIANO BERTATO (Amiga Conference)   ~`~
;~`~                      Date - Monday August 1, 1988                `~`
;`~`                                                                  ~`~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
; - To contact me through the BBS's, ie. A thank you, or a SIMPLE question:
;   Compuserve 73246,1744 and CRS (Amiga Conference) 231-0538 or 232-0442.
;
; - The files in this package includes:
;
;   Simpleterm - the working program.
;   Simpleterm.asm - the source code, this file.
;   Simpleterm.o - the object code.
;   exec.lib - my library for CreateExtIO and DeleteExtIO (public domain).
;   Make - execute program to assemble and link Simpleterm.
;   ExecuteMe - used to rename files after unarcing the arced package.
;   ReadMe - read the instructions.
;
; - You have to provide your Blink, Assem, amiga.lib files yourself.
;
; - I wrote this simple no frills terminal for educational purposes!!
;
; - The Amiga Assembler community NEEDED easy to understand fully
;   documented, up to date 68000 source code for a terminal program!!
;
; - I ask you to PLEASE spread the Simpleterm Arc'ed package to as
;   many sources as possible, such as BBS's and public domain
;   disks, etc..... But PLEASE keep all files together!!
;
; - I also ask you to not alter this source code, because it will
;   only screw things up!! I wrote this program for educational
;   purposes, NOT for adding extra features, thereby confusing
;   the heck out of assembler programmers, thereby making them
;   hate assembler!!
;
; - I learned alot during the writing of this program, and you will
;   too!! I would like to thank all the people on the BBS's that
;   helped me out. 
;
; - You don't need any include files for this program, as I defined
;   all of the symbols in the equates section of this source code.
;   when you link this program, you'll need two libraries. Of course,
;   you'll need the amiga.lib, and you'll need a lib called exec.lib,
;   which has _CreateExtIO and _DeleteExtIO. 'exec.lib' is included
;   in the arc'ed package.
;
; - Simpleterm will open an 8 color CUSTOMSCREEN (for color BBS's), then
;   open a console on the CUSTOMSCREEN, then open the serial port. The
;   code is clear on how it is done.
;
; - To set the baud rate, just change the DEF_BAUD value found in the
;   'my equates' section of this source code.
;
; - To exit Simpleterm, press the ESC key.
;
; - To dial a BBS, for pulse dialing: ATDP 232-0442 <ret>
;
; - To dial a BBS, for tone dialing: ATDT 231-0538 <ret>
;
; - This terminal can also be used in color BBS's. Looks nice!!
;
; - If Simpleterm aborts when loading (look at the code to see why),
;   it's because it couldn't set up or open something properly, such as:
;
;     - couldn't open the console or serial port
;     - couldn't allocate memory, or couldn't open a library, etc...
;
; - I used the Metacomco assembler. Therefore to assemble the program:
;
;     Assem Simpleterm.asm -o Simpleterm.o -c W50000
;
; - Using Blink:
;
;     Blink Simpleterm.o to Simpleterm LIB amiga.lib+exec.lib
;
; - Simpleterm is only 3672 bytes, and can be shortened even further,
;   because I left in some 'movea.l  _SysBase,a6' lines that are not
;   needed. Also, there are other unnessesary lines that can be taken
;   out! 3672 bytes for a terminal program!! Wow...now that's the
;   beauty of assembly programming!!
;
; - Have fun....................
;
;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
;~`                             Exported                               ~`
;`~                                                                    `~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`
   XDEF     _SysBase

;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
;~`                              Macros                                ~`
;`~                                                                    `~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`

CALL        MACRO
              XREF    _LVO\1
              JSR     _LVO\1(a6)
            ENDM

LIBCALL     MACRO
              XREF    _\1
              JSR     _\1
            ENDM

;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
;~`                              Equates                               ~`
;`~                                                                    `~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`

* system equates

_SysBase        EQU  4

* include file equates

CUSTOMSCREEN    EQU  15
V_HIRES         EQU  $8000
SMART_REFRESH   EQU  0
BORDERLESS      EQU  $800
ACTIVATE        EQU  $1000
CMD_WRITE       EQU  3
CMD_READ        EQU  2
IO_DATA         EQU  $28
IO_LENGTH       EQU  $24
IO_DEVICE       EQU  $14
IO_UNIT         EQU  $18
IO_COMMAND      EQU  $1c
IO_ACTUAL       EQU  $20
IO_SERFLAGS     EQU  $4f
IO_CTLCHAR      EQU  $30
IO_RBUFLEN      EQU  $34
IO_WBUFLEN      EQU  $38
IO_BAUD         EQU  $3c
IO_BRKTIME      EQU  $40
IO_TERMARRAY1   EQU  $44
IO_TERMARRAY2   EQU  $48
IO_READLEN      EQU  $4c
IO_WRITELEN     EQU  $4d
IO_STOPBITS     EQU  $4e
IO_FLAGS        EQU  $1e
IOEXTSER_SIZE   EQU  $52
IOF_QUICK       EQU  1
SDCMD_SETPARAMS EQU  $b
SDCMD_QUERY     EQU  9
SERF_SHARED     EQU  $20
SERF_XDISABLED  EQU  $80
SERF_RAD_BOOGIE EQU  $10
SERF_7WIRE      EQU  4
MP_SIZE         EQU  $22
MP_SIGTASK      EQU  $10
MP_SIGBIT       EQU  $f
MN_REPLYPORT    EQU  $e
nw_Screen       EQU  30
wd_RPort        EQU  $32
wd_WScreen      EQU  $2e
sc_ViewPort     EQU  $2c

* my equates

DEF_BAUD        EQU  1200
DEF_RBUFLEN     EQU  4096
DEF_WBUFLEN     EQU  4096
DEF_BRKTIME     EQU  750000
DEF_READLEN     EQU  8
DEF_WRITELEN    EQU  8
DEF_STOPBITS    EQU  1
DEF_TERMARRAY1  EQU  0
DEF_TERMARRAY2  EQU  0
DEF_SERFLAGS    EQU  SERF_SHARED!SERF_XDISABLED!SERF_RAD_BOOGIE

;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
;~`                           Assembly Code                            ~`
;`~                                                                    `~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`

* start

_main:
   movem.l  d0-d7/a0-a6,-(sp)        save registers

* open intuition library

   lea      IntuiName,a1             open intuition library
   clr      d0
   movea.l  _SysBase,a6
   CALL     OpenLibrary
   move.l   d0,IntuitionBase
   beq      exit

* open dos library

   lea      DosName,a1               open dos library
   clr      d0
   CALL     OpenLibrary
   move.l   d0,DosBase
   beq      exit2

* open graphics library

   lea      GfxName,a1               open graphics library
   clr      d0
   CALL     OpenLibrary
   move.l   d0,GfxBase
   beq      exit3

* open the screen

   lea      newscreen,a0             open the screen
   movea.l  IntuitionBase,a6
   CALL     OpenScreen
   move.l   d0,screenptr
   beq      exit4

* open window #1

   lea      newwindow1,a0            open window #1
   move.l   d0,nw_Screen(a0)
   CALL     OpenWindow
   move.l   d0,windowptr1
   beq      exit5

   move.l   d0,a0                    get RP and VP
   move.l   wd_RPort(a0),windowRPort
   move.l   wd_WScreen(a0),a0
   move.l   a0,screenptr
   add.l    #sc_ViewPort,a0
   move.l   a0,screenVPort

* make read and write ports for console

   clr.l    -(sp)                    make write message port
   pea      MyConWrite               for console
   LIBCALL  CreatePort
   move.l   d0,conWPort
   addq.l   #8,sp
   tst.l    d0
   beq      exit6

   move.l   d0,-(sp)                 make write IOStdReq structure
   LIBCALL  CreateStdIO              for console
   move.l   d0,writereqcon
   addq.l   #4,sp
   tst.l    d0
   beq      exit7

   clr.l    -(sp)                    make read message port
   pea      MyConRead                for console
   LIBCALL  CreatePort
   move.l   d0,conRPort
   addq.l   #8,sp
   tst.l    d0
   beq      exit8

   move.l   d0,-(sp)                 make read IOStdReq structure
   LIBCALL  CreateStdIO              for console
   move.l   d0,readreqcon
   addq.l   #4,sp
   tst.l    d0
   beq      exit9

* open the console

   move.l   writereqcon,a1          open console device
   move.l   windowptr1,IO_DATA(a1)
   moveq.l  #0,d0
   move.l   d0,d1
   lea      conname,a0
   movea.l  _SysBase,a6
   CALL     OpenDevice
   tst.l    d0
   bne      exit10

   move.l   writereqcon,a1             copy initialized write
   move.l   readreqcon,a2              request to read request
   move.l   IO_DEVICE(a1),IO_DEVICE(a2)
   move.l   IO_UNIT(a1),IO_UNIT(a2)
   move.w   #CMD_WRITE,IO_COMMAND(a1)   set structures to write
   move.w   #CMD_READ,IO_COMMAND(a2)    or read

* make read and write ports for serial.device

   clr.l    -(sp)                    make write message port
   pea      MySerWrite               for serial.device
   LIBCALL  CreatePort
   move.l   d0,serWPort
   addq.l   #8,sp
   tst.l    d0
   beq      exit11

   move.l   #IOEXTSER_SIZE,-(sp)     make write IOExtReq structure
   move.l   d0,-(sp)                 for serial.device
   LIBCALL  CreateExtIO
   move.l   d0,writereqser
   addq.l   #8,sp
   tst.l    d0
   beq      exit12

   clr.l    -(sp)                    make read message port
   pea      MySerRead                for serial.device
   LIBCALL  CreatePort
   move.l   d0,serRPort
   addq.l   #8,sp
   tst.l    d0
   beq      exit13

   move.l   #IOEXTSER_SIZE,-(sp)     make read IOExtReq structure
   move.l   d0,-(sp)                 for serial.device
   LIBCALL  CreateExtIO
   move.l   d0,readreqser
   addq.l   #8,sp
   tst.l    d0
   beq      exit14

* open the serial.device for output and input

   move.l   writereqser,a1                open the serial.device
   move.b   #SERF_SHARED,IO_SERFLAGS(a1)  for output
   moveq.l  #0,d0
   move.l   d0,d1
   lea      sername,a0
   movea.l  _SysBase,a6
   CALL     OpenDevice
   tst.l    d0
   bne      exit15

   move.l   readreqser,a1                 open the serial.device
   move.b   #SERF_SHARED,IO_SERFLAGS(a1)  for input
   moveq.l  #0,d0
   move.l   d0,d1
   lea      sername,a0
   movea.l  _SysBase,a6
   CALL     OpenDevice
   tst.l    d0
   bne      exit16

* set the default parameters for the serial.device

   bsr      SetDefaultParms          call subroutine to set default params
   tst.l    d0
   bne      exit17

   move.l   writereqser,a1            set structures to write
   move.l   readreqser,a2             or read
   move.w   #CMD_WRITE,IO_COMMAND(a1)
   move.w   #CMD_READ,IO_COMMAND(a2)

* set console and serial devices to get 1 character

   bsr      ConGetChar
   bsr      SerGetChar

* main loop of the program

mainloop:
   move.l   conRPort,a0              set the signals for the
   clr.l    d3                       console and serial devices
   move.b   MP_SIGBIT(a0),d3
   moveq.l  #1,d1
   lsl.l    d3,d1
   move.l   serRPort,a0
   clr.l    d3
   move.b   MP_SIGBIT(a0),d3
   moveq.l  #1,d2
   lsl.l    d3,d2
   move.l   d1,d0
   or.l     d2,d0
   move.l   _SysBase,a6
   CALL     Wait                     wait for a signal from the
   cmp.l    d1,d0                    console or serial devices
   beq      maincon
   cmp.l    d2,d0
   bne      mainloop

mainser:
   move.l   readreqser,a1            print all characters that are received
   move.l   _SysBase,a6              from the serial device to the console
   CALL     CheckIO
   beq      mainloop
   move.l   readreqser,a1
   move.l   _SysBase,a6
   CALL     WaitIO
   bne      mainloop
   move.l   #SerReadCharBuff,d0
   bsr      ConWriteChar
   move.l   readreqser,a1
   move.w   #SDCMD_QUERY,IO_COMMAND(a1)
   move.l   _SysBase,a6
   CALL     DoIO
   move.l   readreqser,a1
   move.w   #CMD_READ,IO_COMMAND(a1)
   move.b   #IOF_QUICK,IO_FLAGS(a1)
   move.l   IO_ACTUAL(a1),IO_LENGTH(a1)
   move.l   #SerReadCharBuff,IO_DATA(a1)
   move.l   _SysBase,a6
   CALL     DoIO
   move.l   readreqser,a1
   move.l   IO_DATA(a1),d1
   move.l   IO_ACTUAL(a1),d2
   bsr      ConWrite
   bsr      SerGetChar               loop back to mainser to see if
   bra      mainser                  there's any more characters

maincon:
   move.l   readreqcon,a1            get the characters that were
   move.l   _SysBase,a6              typed from the console, and
   CALL     CheckIO                  send them to the serial.device
   beq      mainser
   move.l   readreqcon,a1
   move.l   _SysBase,a6
   CALL     WaitIO
   bne      mainloop
   move.l   #ConReadCharBuff,a0
   cmpi.b   #$1b,(a0)                to quit program >> press ESC key
   beq      exit17
   move.l   a0,d0
   bsr      SerWriteChar
   bsr      ConGetChar               loop back to maincon to see if
   bra      maincon                  there's any more characters

* close serial.device for input

exit17:
   move.l   readreqser,a1            close serial.device for input or
   movea.l  _SysBase,a6              abort because can't set
   CALL     CloseDevice              default parms for serial.device

* close serial.device for output

exit16:
   move.l   writereqser,a1           close serial.device for output or
   movea.l  _SysBase,a6              abort because can't open
   CALL     CloseDevice              the serial.device for input

* delete serial.device read IOExtSer structure

exit15:
   move.l   #IOEXTSER_SIZE,-(sp)
   move.l   readreqser,-(sp)         delete serial.device read IOExtSer
   LIBCALL  DeleteExtIO              structure or abort because can't open
   addq.l   #8,sp                    serial.device for output

* close serial.device read message port

exit14:
   move.l   serRPort,-(sp)           close serial.device read message port
   LIBCALL  DeletePort               or abort because can't open read
   addq.l   #4,sp                    IOExtSer structure for serial.device

* delete serial.device write IOExtSer structure

exit13:
   move.l   #IOEXTSER_SIZE,-(sp)
   move.l   writereqser,-(sp)        delete serial.device write IOExtSer
   LIBCALL  DeleteExtIO              structure or abort because can't open
   addq.l   #8,sp                    read message port for serial.device

* close serial.device write message port

exit12:
   move.l   serWPort,-(sp)           close serial.device write message port
   LIBCALL  DeletePort               or abort because can't open write
   addq.l   #4,sp                    IOExtSer structure for serial.device

* close console

exit11:
   move.l   writereqcon,a1           close console.device or abort
   movea.l  _SysBase,a6              because can't open write 
   CALL     CloseDevice              message port for serial.device

* delete console.device read IOStdReq structure

exit10:
   move.l   readreqcon,-(sp)         delete console.device read IOStdReq
   LIBCALL  DeleteStdIO              structure or abort because can't open
   addq.l   #4,sp                    console.device

* close console.device read message port

exit9:
   move.l   conRPort,-(sp)           close console.device read message port
   LIBCALL  DeletePort               or abort because can't open read
   addq.l   #4,sp                    IOStdReq structure for console.device

* delete console.device write IOStdReq structure

exit8:
   move.l   writereqcon,-(sp)        delete console.device write IOStdReq
   LIBCALL  DeleteStdIO              structure or abort because can't open
   addq.l   #4,sp                    read message port for console.device

* close console.device write message port

exit7:
   move.l   conWPort,-(sp)           close console.device write message port
   LIBCALL  DeletePort               or abort because can't open write
   addq.l   #4,sp                    IOStdReq structure for console.device

* close window #1

exit6:
   movea.l  windowptr1,a0            close window #1 or abort because
   movea.l  IntuitionBase,a6         can't open write message port
   CALL     CloseWindow              for console.device

* close the screen

exit5:
   movea.l  screenptr,a0             close the screen or abort
   movea.l  IntuitionBase,a6         because of window for I/O
   CALL     CloseScreen              open error

* close graphics library

exit4:
   movea.l  GfxBase,a1               close graphics library or
   movea.l  _SysBase,a6              abort because of screen
   CALL     CloseLibrary             open error

* close dos library

exit3:
   movea.l  DosBase,a1               close dos library or abort
   movea.l  _SysBase,a6              because of graphics open
   CALL     CloseLibrary             error

* close intuition library

exit2:
   movea.l  IntuitionBase,a1         close intuition library or
   movea.l  _SysBase,a6              abort because of dos open
   CALL     CloseLibrary             error

* exit program

exit:
   movem.l  (sp)+,d0-d7/a0-a6        exit or abort because
   clr.l    d0                       of intuition open error
   rts

;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
;~`                            Subroutines                             ~`
;`~                                                                    `~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`

*
* set the serial.device to default parameters
*
*  error = SetDefaultParms()
*   d0

SetDefaultParms:
   move.l   writereqser,a1
   bsr      SetDefaultParms_sub
   bne      SetDefaultParms_error
   move.l   readreqser,a1
   bsr      SetDefaultParms_sub
SetDefaultParms_error:
   rts
SetDefaultParms_sub:
   move.l   #DEF_RBUFLEN,IO_RBUFLEN(a1)
   move.w   #DEF_WBUFLEN,IO_WBUFLEN(a1)
   move.l   #DEF_BAUD,IO_BAUD(a1)
   move.l   #DEF_BRKTIME,IO_BRKTIME(a1)
   move.b   #DEF_READLEN,IO_READLEN(a1)
   move.b   #DEF_WRITELEN,IO_WRITELEN(a1)
   move.b   #DEF_STOPBITS,IO_STOPBITS(a1)
   move.b   #DEF_SERFLAGS,IO_SERFLAGS(a1)
   move.l   #DEF_TERMARRAY1,IO_TERMARRAY1(a1)
   move.l   #DEF_TERMARRAY2,IO_TERMARRAY2(a1)
   move.w   #SDCMD_SETPARAMS,IO_COMMAND(a1)
   move.l   _SysBase,a6
   CALL     DoIO
   rts

*
* write to the console.device
*
*  actual_length = ConWrite(buffer,length)
*     d0                      d1     d2

ConWrite:
   movem.l  a0-a7/d1-d7,-(sp)
   move.l   writereqcon,a1
   move.l   a1,-(sp)
   move.l   d1,IO_DATA(a1)
   move.l   d2,IO_LENGTH(a1)
   movea.l  _SysBase,a6
   CALL     DoIO
   move.l   (sp)+,a1
   move.l   IO_ACTUAL(a1),d0
   movem.l  (sp)+,a0-a7/d1-d7
   rts

*
* write to the serial.device
*
*  actual_length = SerWrite(buffer,length)
*     d0                      d1     d2

SerWrite:
   movem.l  a0-a7/d1-d7,-(sp)
   move.l   writereqser,a1
   move.l   a1,-(sp)
   move.l   d1,IO_DATA(a1)
   move.l   d2,IO_LENGTH(a1)
   movea.l  _SysBase,a6
   CALL     DoIO
   move.l   (sp)+,a1
   move.l   IO_ACTUAL(a1),d0
   movem.l  (sp)+,a0-a7/d1-d7
   rts

*
* set console read port to wait for 1 character
*
*  ConGetChar()
*

ConGetChar:
   movem.l  a0-a7/d0-d7,-(sp)
   move.l   readreqcon,a1
   move.l   #ConReadCharBuff,IO_DATA(a1)
   move.l   #1,IO_LENGTH(a1)
   move.l   _SysBase,a6
   CALL     SendIO
   movem.l  (sp)+,a0-a7/d0-d7
   rts

*
* set serial read port to wait for 1 character
*
*  SerGetChar()
*

SerGetChar:
   movem.l  a0-a7/d0-d7,-(sp)
   move.l   readreqser,a1
   move.l   #SerReadCharBuff,IO_DATA(a1)
   move.l   #1,IO_LENGTH(a1)
   move.l   _SysBase,a6
   CALL     SendIO
   movem.l  (sp)+,a0-a7/d0-d7
   rts

*
* write 1 character to the console
*
*  actual_length = ConWriteChar(buffer)
*     d0                          d0

ConWriteChar:
   movem.l  a0-a7/d1-d7,-(sp)
   move.l   writereqcon,a1
   move.l   a1,-(sp)
   move.l   d0,IO_DATA(a1)
   move.l   #1,IO_LENGTH(a1)
   movea.l  _SysBase,a6
   CALL     DoIO
   move.l   (sp)+,a1
   move.l   IO_ACTUAL(a1),d0
   movem.l  (sp)+,a0-a7/d1-d7
   rts

*
* write 1 character to the serial device
*
*  actual_length = SerWriteChar(buffer)
*     d0                          d0

SerWriteChar:
   movem.l  a0-a7/d1-d7,-(sp)
   move.l   writereqser,a1
   move.l   a1,-(sp)
   move.l   d0,IO_DATA(a1)
   move.l   #1,IO_LENGTH(a1)
   movea.l  _SysBase,a6
   CALL     DoIO
   move.l   (sp)+,a1
   move.l   IO_ACTUAL(a1),d0
   movem.l  (sp)+,a0-a7/d1-d7
   rts

;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
;~`                          Initialized Data                          ~`
;`~                                                                    `~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`

   SECTION   data,DATA

IntuiName:
   dc.b     'intuition.library',0
   cnop     0,2
GfxName:
   dc.b     'graphics.library',0
   cnop     0,2
DosName:
   dc.b     'dos.library',0
   cnop     0,2
screenname:
   dc.b     'Simpleterm V1.0, August 1988, By Luciano Bertato',0
   cnop     0,2
newscreen:
   dc.w     0,0,640,200,3
   dc.b     0,1
   dc.w     V_HIRES,CUSTOMSCREEN
   dc.l     0,screenname,0,0
newwindow1:
   dc.w     0,13,640,187
   dc.b     0,1
   dc.l     0
   dc.l     SMART_REFRESH!ACTIVATE!BORDERLESS
   dc.l     0,0,0,0,0
   dc.w     640,200,640,200,CUSTOMSCREEN
conname:
   dc.b     'console.device',0
   cnop     0,2
sername:
   dc.b     'serial.device',0
   cnop     0,2
MyConWrite:
   dc.b     'ConCreateIO.write',0
   cnop     0,2
MyConRead:
   dc.b     'ConCreateIO.read',0
   cnop     0,2
MySerWrite:
   dc.b     'SerCreateIO.write',0
   cnop     0,2
MySerRead:
   dc.b     'SerCreateIO.read',0
   cnop     0,2

;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~
;~`                         Uninitialized Data                         ~`
;`~                                                                    `~
;~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`

   SECTION   mem,BSS

IntuitionBase:
   ds.l     1          ; intuition base address pointer
DosBase:
   ds.l     1          ; dos base address pointer
GfxBase:
   ds.l     1          ; graphics base address pointer
screenptr:
   ds.l     1          ; screen pointer
windowptr1:
   ds.l     1          ; window for I/O pointer
windowRPort:
   ds.l     1          ; RP of window1
screenVPort:
   ds.l     1          ; VP of screen
writereqcon:
   ds.l     1          ; pointer to write IOStdReq structure for console
readreqcon:
   ds.l     1          ; pointer to read IOStdReq structure for console
conWPort:
   ds.l     1          ; pointer to write message port for console
conRPort:
   ds.l     1          ; pointer to read message port for console
writereqser:
   ds.l     1          ; pointer to write IOExtSer structure for serial.device
readreqser:
   ds.l     1          ; pointer to read IOExtSer structure for serial.device
serWPort:
   ds.l     1          ; pointer to write message port for serial.device
serRPort:
   ds.l     1          ; pointer to read message port for serial.device
ConReadCharBuff:
   ds.w     1          ; 1 character buffer for the console input port
SerReadCharBuff:
   ds.b     4096       ; character buffer for the serial input port

;`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~

   END

