
    1 **********************************************************
    2 *                                                        *
    3 *         NadaNet Definitions for Applications           *
    4 *                                                        *
    5 *            Michael J. Mahon - Oct 14, 2004             *
    6 *                 Revised Jan 06, 2009                   *
    7 *                                                        *
    8 *            Copyright (c) 2004, 2008, 2009              *
    9 *                                                        *
   10 **********************************************************
   11 
   12 version  equ   $30        ; NadaNet v3.0
   13 
   14 ********** Control Packet Definition **********
   15 
   16          dum   0          ; Control packet format:
   17 rqmd     ds    1          ;   Request & Modifier
   18 frmc     ds    1          ;   Complement of sending ID
   19 dst      ds    1          ;   Destination ID (0 = bcast)
   20 frm      ds    1          ;   Sending ID (never 0)
   21 adr      ds    2          ;   Address field
   22 len      ds    2          ;   Length field
   23                           ; =========================
   24 lenctl   ds    0          ; Length of control packet
   25          dend
   26 
   27 * Request codes (upper 5 bits) and modifiers (lower 3 bits)
   28 
   29 reqfac   equ   8          ; Request code factor (2^3)
   30 reqmask  equ   256-reqfac ; Request code mask (7..3)
   31 modmask  equ   reqfac-1   ; Modifier code mask (2..0)
   32 
   33          dum   reqfac     ; Request codes (0 invalid):
   34 r_PEEK   ds    reqfac     ;   PEEK request
   35 r_POKE   ds    reqfac     ;   POKE request
   36 r_CALL   ds    reqfac     ;   CALL request
   37 r_PUTMSG ds    reqfac     ;   PUTMSG request
   38 r_GETMSG ds    reqfac     ;   GETMSG request
   39 r_GETID  ds    reqfac     ;   GETID request
   40 r_BOOT   ds    reqfac     ;   BOOT request
   41 r_BCAST  ds    reqfac     ;   BCAST request
   42 r_BPOKE  ds    reqfac     ;   Broadcast POKE request
   43 r_PKINC  ds    reqfac     ;   PEEK & INCrement request
   44 r_RUN    ds    reqfac     ;   RUN request
   45 r_BRUN   ds    reqfac     ;   BRUN request
   46                           ; ==========================
   47 maxreq   ds    0          ;   Max request + reqfac
   48          dend
   49 
   50          dum   1          ; Modifier codes (0 invalid):
   51 rm_REQ   ds    1          ;   Request
   52 rm_ACK   ds    1          ;   Acknowledge
   53 rm_DACK  ds    1          ;   Data Acknowledge
   54 rm_NAK   ds    1          ;   Negative Acknowledge
   55          dend
   56 
   57 ***************** BCAST tags *******************
   58 *                                              *
   59 * High byte of BCAST address field.  Tags <$D0 *
   60 * can be confused with RAM addresses. (The low *
   61 * byte may be an additional specification.)    *
   62 *                                              *
   63 ************************************************
   64 
   65 t_BASIC  equ   $E0        ; Applesoft BASIC program
   66 t_SYNTH  equ   $F0        ; Crate SYNTH program
   67 t_VOICE  equ   $F1        ; Crate SYNTH voice
   68 
   69 ************ NadaNet Page 3 Vector *************
   70 
   71          dum   $3CC       ; Fixed memory vector
   72 bootself db    0          ; Machine ID from BOOT
   73 warmstrt jmp   0*0        ; Warm start SERVE loop entry
   74 nadapage equ   *-1        ; NADANET load page
   75          dend
   76 
   77 **************** Entry points *****************
   78 
   79          dum   loadpnt    ; NadaNet load address
   80 
   81 entry    jsr   *          ; BOOT entry: init and
   82 servelp  jsr   *          ;  Run request server
   83          jmp   servelp    ;    forever...
   84 init     jmp   *          ; Initialize and return
   85 serve    jmp   *          ; Run reqest server
   86 peek     jmp   *          ; Peek/Poke 'sbuf+dst' for
   87 poke     jmp   *          ;  'sbuf+len' bytes at 'sbuf+adr'
   88 call     jmp   *          ; Call 'sbuf+dst' at 'sbuf+adr'
   89 putmsg   jmp   *          ; Put message to server
   90 getmsg   jmp   *          ; Get message from server
   91 bcast    jmp   *          ; Broadcast data
   92 bpoke    jmp   *          ; Broadcast 2-byte POKE
   93 peekinc  jmp   *          ; PEEK & INC 2-byte val
   94 run      jmp   *          ; RUN Applseoft prog
   95 brun     jmp   *          ; BRUN M/L prog
   96 rcvctl   jmp   *          ; Receive control pkt
   97 rcvptr   jmp   *          ; Receive to 'ptr'
   98 rarl=>al jmp   *          ; Rbuf adr,len=>address,length
   99 rcvlong  jmp   *          ; Receive long data
  100          pag
  101 ********** Parameters and variables ************
  102 
  103 self     db    0          ; Our own machine ID
  104 sbuf     ds    lenctl     ; Control pkt send buffer
  105 rbuf     ds    lenctl     ; Control pkt receive buffer
  106 locaddr  dw    0          ; Local address of req data
  107 retrylim db    0          ; Limit of REQUEST resends
  108 servecnt db    0          ; SERVE iterations (0=256)
  109 
  110 parmsiz  equ   *-self     ; Size of parameter area
  111 
  112 ************ Counters and Version **************
  113 
  114 arbxv    db    0          ; Arbitrate X iters (modified)
  115 tolim    db    0          ; RCVPKT timeout limit
  116 reqctr   db    8          ; SERVER request counter
  117 reqretry db    0          ; xxxREQ retries remaining
  118 retrycnt db    0          ; REQUEST resend count
  119 errprot  dw    0          ; Protocol error count
  120 ckerr    dw    0          ; Checksum error count
  121 frmcerr  dw    0          ; 'frmc' collision errors
  122 nadaver  db    version    ; NadaNet version 3.0
  123 
  124 * Table of allocated machine IDs (allocated = non-zero)
  125 *        (Only present in "master" machines)
  126 
  127 maxid    equ   31         ; Maximum number of machines
  128 
  129 idtable  db    maxid      ; Table of machine attributes
  130          ds    maxid      ; Rest of ID table (=0)
  131 
  132          dend
