;t200.def-- asm80/zmac constants for m200
;$Id: t200.def,v 1.22 2022/03/14 06:56:31 goosey Exp goosey $

;was m100.def

;from M100 Techref starting at page 79
;typed in by
;Willard Goosey
;goosey@sdc.org
;7/1/2011
;7/4/2011 fix typo in PRINTR EXTREV
;         added SETCUR SNDCOM
;         thanks to Valdis Grinbergs
;         reorganized by function rather than source 
;         of info
;7/5/2011 Bob Pigford notes that INBUF is null 
;         terminated
;         Bob Pigford and Ken Pettit noted that POSIT 
;         sets the cursor location, not get cursor 
;         location
;
;7/6/2011 Web100 mirror at http://www.ordersomewherechaos.com/rosso/fetish/m102/web100/index.html
;         Club 100 at http://www.club100.org/
;                     ftp://ftp.whtech.com/club100
;7/8/2011 added routines from hterm source git:bitchin100.com/pub-git/hterm.git/
;         added routines from club100/ref/sandr.asm
;7/9/2011 added LINNUM, BASEXPR from Ken Pettit
;7/14/2011 added TEXT
;8/1/2011 TEXT is a reservered word in zmac, changed 
;         to TXT
;8/10/2014 added routine from DATE.ADD
;4/5/2017 Mike Nugent corrects BRKCHK, add CTLCHK and SCANSP
;5/6/2017 Ken Pettit add PWRRES
;6/12/2017 fixed KILASC
;7/2/2017 added LNKFIL
;8/13/2017 how to call SNDCOM
;10/19/2017 added MAKFIL
;5/13/2021 becoming m200.def

;sources include:
; club100/ref/map.100
; club100/ref/rcmap*.100
; club100/ref/hooks.100
; club100/ref/sandr.asm
; club100/doc/m100/m100TechReference.pdf
; club100/doc/m102/m102TechReference.pdf
; club100/doc/?/rom_funcs-600.pdf
; web100 "An Assembly Language tutorial for the Model 100"
; web100 "Model 100 Hackers Guide"
; web100 "hints and tricks"
; web100 "Model 100 ROM Calls"
; bitchin100.com/pub-git/hterm.git/m100_unpublished_lib.asm
; club100/?/p100-*.pdf
; cis/Lib-08-TECH-PROGRAMMING/DATE.100
;Terry Kepner, Pico Magazine
;				/DATE.ADD
; Jon Diercks 
; Virtual T source, Ken Pettit
;Mike Nugent
;bitchin100.com/??? NEC 8201 Tech Ref
;Ken Pettit's ROM disassembly from his 
;personal library @club100

;m200 stuff starts with m200 techref page D-1
;ftp.whtech.com/club100/ref/cross1.doc
;ftp.whtech.com/club100/ref/cross2.doc
;;;NOTE on crossx.doc
;;;these files simply list address equivalents between
;;;m100 and t200. Blatantly assumes MS didn't alter the
;;;calling conventions...
;ftp.whtech.com/club100/ref/rcmapX.200
;.... hterm.git/lib/T200rom_published_lib.asm
;     hterm.git/lib/T200rom_unpublished_lib.asm

;;;LCD routines

LCD equ 503ch
;display a character at current cursor position to LCD
;Entry conditions:   A = char to display
;Exit conditions: none


LCDSAFE equ 5030h
;display a character at current cursor position (redirectable to DVI etc)
;Entry conditions:   A = char to display
;Exit conditions: All Registers Preserved
;T200rom_published_lib

LCDSTR equ 6df6h
;print a null-terminated string to LCD
;Entry Conditions: HL=address of string
;Exit Conditions: none?
;cross1.doc

PRBUF equ 3517h
;print a null-terminated string to LCD
;Entry Conditions: HL=address of string
;Exit Conditions: none?
;t200rom_unpublished_lib.asm

NUMPRT equ 470bh
;print integer to LCD
;Entry Conditions: HL=int to print
;Exit  Conditions: all registers destroyed
;cross1.doc

PLOT equ 8d76h
;turns on pixel at specified location
;Entry conditions:D = x (0-239)
;                 E = y (0-127)
;Exit conditions: none

UNPLOT equ 8d77h
;turn off pixel at specified location
;Entry Conditions:D = x (0-239)
;                 E = y (0-127)
;Exit conditions: none

POSIT equ 4f9bh
;set current cursor location
;Entry Conditions: H=column number (1-40)
;                  L=row number (1-16)
;Exit Conditions: None

SETCUR equ 8d6ah
;set curser location
;Entry Conditions: D= column number (1-40)
;		   E= row number (1-16)
;Exit Conditions: None

ESCA equ 4f8fh
;send escape code sequence to lcd
;Entry Conditions: A = escape code
;Exit  Conditions: none

;;;lcd terminal emulator calls
;these (eventually) get called when escape codes are 
;sent to the lcd
;or you can call them directly
;no entry or exit conditions on these

CRLF equ 4f3eh
;print a ^M^J
HOME equ 4f49h
;no escape-code equivelant
CLS equ 4f4dh
;no escape-code
SETSYS equ 4f54h
;escape T
;lock line 16
RSTSYS equ 4f59h
;escape U
;unlock line 16
LOCK equ 4f5eh
;escape Y
;lock screen (no scrolling)
UNLOCK equ 4f63h
;escape W
;unlock screen (allow scrolling)
CURSON equ 4f68h
;escape P
;turn on text cursor
CUROFF equ 4f6dh
;escape Q
;turn text cursor off
DELLIN equ 4f72h
;escape M
;del current text line
INSLIN equ 4f77h
;escape I
;insert line at cursor pos
ERAEOL equ 4f7ch
;escape K
;erase from cursor to end of line
ENTREV equ 4f88h
;escape p
;enter reverse-video mode
EXTREV equ 4f8dh
;escape q
;turn off reverse-video
;;;

;the Bar Cursor is the file cursor in MENU
BARPOS equ 6d51h
;position cursor on one of 24 bar positions
;Entry Conditions: HL=position 0-23
;Exit Conditions: none
;from cross1.doc

BARCUR equ 6d6dh
;toggle bar cursor to opposite state
;Entry Conditions: HL=position 0-23
;Exit Conditions: none
;from cross1.doc

;DTLINE equ 5a18h
;Print day/date/time as it appears on MENU screen
;at current cursor location
;updated time before printing it
;Entry Conditions: None
;Exit Conditions: all registers destroyed?
;from cis/Lib08-TECH-PROGRAMMING/DATE.ADD

TDDPT equ 6d93h
;print time on top line of screen, no cls
;Entry Conditions: none
;Exit  Conditions: all registers destroyed
;from m100rom_unpublished_lib.asm
;t200rom_unpublished_lib.asm



CTDOPT equ 6d97h
;cls, home, print time, day, date
;Entry Conditions: none
;Exit  Conditions: all registers destroyed
;rcmap5.200

PFRE equ 9afdh
;print number of bytes of free memory
;Entry Conditions: none
;Exit  Conditions: none
;from cross1.doc

;;;LCD variables
CSRY equ 0ef06h
;cursor row
CSRX equ 0ef07h
;cursor col
BEGLCD equ 0fa30h
;start of LCD screen image 640 bytes
ENDLCD equ 0fcafh
;end of LCD screen image
ALTLCD equ 0F7B0h
;start of alternate screen image 320 bytes
;from t200rom_unpublished_lib.asm
;ALTLCDE equ 0FA2Fh
;end of alternate LCD screen image
;from t200rom_unpublished_lib.asm
;;;
;;;

;;;Keyboard functions

KYREAD equ  0c00h
;scan keyboard and return with a keypress or without one
;Entry Conditions: None
;Exit  Conditions: A = char, if any
;		   Z: set if no key found
;		   Z: clear if key found
;                  Carry: Set (character in code below)
;                  Carry: clear = normal character
;key pressed   regA
;F1             0
;F2             1
;F3             2
;F4             3
;F5             4
;F6             5
;F7             6
;F8             7
;LABEL          8
;PRINT          9
;shift-PRINT   0Ah
;PASTE         0Bh
;
;;T200rom_published_lib.asm says this is 8B03 TESTME FIXME


CHGET equ  12f7h
;poll keyboard until key pressed
;Entry Conditions: None
;Exit  Conditions: A = character code
;                  Carry set: special key
;                  Carryclear: regular key
;F1-F8 return preprogrammed strings

;KEYWTU equ 5d64h
;wait for key to be pressed, convert it to uppercase
;Entry Conditions: None
;Exit  Conditions: A=uppercase key pressed
;function keys return preprogrammed strings
;m100rom_unpublished_lib.asm


CHSNS equ  1404h
;check keyboard queue for characters
;Entry Conditions: None
;Exit  Conditions: Z flag Set if queue empty
;                  Z flag clear if keys pending
;;;T200rom_published_lib.asm says this is 1422 TESTME FIXME


KEYX equ  8b31h
;check keyboard queue for characters or break
;Entry Conditions:None
;Exit  Conditions: Z flag Set if queue empty
;                  Z flag clear if keys pending
;                  Carry set if BREAK pressed
;                  Carry clear on all other keys
;		   A destroyed

CTLCHK equ  8b4dh
;check for ^C or ^S only
;Entry Conditions:None
;Exit  Conditions: Z clear on ^C or ^S
;		   Z set on no char or reg char
;		   A destroyed
;from cross1.doc

;BRKCHK equ 8b40h
;check to see if SHIFT-BREAK pressed
;Entry Conditions: None
;Exit  Conditions: Carry set on BREAK pressed
;		   A destroyed

;SCANSP equ 72B1h
;scan keyboard column of BREAK,CAPS,NUM,CODE,GRAPH,CONTROL,
;SHIFT key. Reset bits in A corresponding to the key pressed
;Entry Conditions: None
;Exit  Conditions: A=(BREAK,CAPS...)

INLIN equ  54f6h
;Read line from keyboard
;Entry Conditions:None
;Exit  Conditions: Line starts at F685

INBUF equ 0f685h
;INPUT buffer
;253 bytes long (map,100)
;null terminated -- Bob Pigford & MikeS, from The Hidden 
;Powers (p. 55)

;;;FUNCTION Key routines

FCTER equ 80h
;terminate entry in function table entry, either by 
;itself or ORed with the last byte of entry
;an example function key table
;  fctab defm 'files' ;f1
;        defb 0dh
;        defb 80h
;        defm 'load'   ;f2
;        defb 80h
;         defb 80h      ; no function for f3
;......
;        defm 'menu',8dh ; f8

STFNK equ  6e20h
;set function key table
;Entry Conditions: HL = address of table (see above)
;Exit  Conditions: None

CLRFLK  equ  6e1dh
CLRFNK equ CLRFLK ;name given in t200rom_unpublished_lib.asm
;clear function key table
;Entry Conditions: None
;Exit  Conditions: None

DSPFNK  equ 4fc7h
;display function keys
;Entry Conditions: none
;Exit  Conditions: none

STDSPF equ  4fc4h
;set and display function keys
;Entry Conditions: HL = address of function key labels 
;                  (see above)
;Exit  Conditions: none

ERAFNK equ  4fa9h
;erase function key display
;Entry Conditions: None
;Exit  Conditions: None

FNKSB  equ  6e42h
;display function key table if enabled
;Entry Conditions: None
;Exit  Conditions: None

;CSFKEY equ 5b46h
;cold start function key table address
;2 bytes
;"Model 100 ROM Calls", web100

BASFKY equ 0f0f5h
;BASIC's function key table
;cross2.doc

BK2SK equ 83E2h
;install BASIC fucntion key table
;Entry Conditions: none
;Exit Conditions: none
;from cross1.doc

FKCTRL equ 0ef32h
;1 byte
;holds 0 or 80h
;if 0, F-keys return string from system table
;if 80, F-keys skip first 4 bytes and return what's left
;from cross2.doc
;marked as from unreliable source, confirm?
;confirmed from rcmap7.200


LBENBL equ 0ef0ah
;1 byte
;set to FFh to enable the label line
;from cross2.doc
;marked as from unreliable soure, confirm?
;confirmed by rcmap7.200


;;;printer routines

PRINTR  equ  84c9h
PRINTER equ PRINTR ;m200 techref name
;send a character to the printer
;Entry Conditions: A = char to be printed
;Exit  Conditions: Carry Set if BREAK sent
;                  Carry clear on success

;FIXED scan not clear! can't see address!
PNOTAB  equ 1590h
CHPLPT equ PNOTAB ;m200 techref  name
;print character without expanding tabs
;Entry Conditions:A = char to print
;Exit  Conditions: Unknown 

PRTTAB  equ  5a14h
OUTDLP equ PRTTAB ;m200 techref name
;print character expanding tab to spaces
;Entry Conditions: A = character to print
;Exit  Conditions: unknown

PRTLCD equ  2946h
LCOPY equ PRTLCD ;m200 techref name
;dump lcd to printer
;Entry Conditions: None
;Exit  Conditions: None

;;;MODEM and RS-232 functions

DISC  equ  61bah
DISHC equ DISC  ;m200 techref name
;disconnect phone line
;Entry Conditions: None
;Exit  Conditions: None

CONN  equ  61d0h
CONHHC equ CONN ;m200 techref name
;connect phone line
;Entry Conditions: None
;Exit  Conditions: None
 
DIAL  equ  622bh
ATDIAL equ DIAL ;m200 techref name
;dial specified phone number
;Entry Conditions: HL = address of phone number
;Exit  Conditions: None

RCVX  equ  8508h
;check RS232 queue for characters
;Entry Conditions: None
;Exit  Conditions: A = number of characters in queue
;                  Z flag set if no data
;                  Z flag clear if data present

RV232C  equ   8519h
;gets a character from rs232 queue
;Entry Conditions: None
;Exit  Conditions: A = character recieved
;                  Z flag set if OK
;                  Z flag clear on error
;                  Carry set if BREAK
;                  Carry clear otherwise

SENDCQ  equ  8608h
SNDCQ equ SENDCQ ;m200 techref name
; send XON (^Q) to serial port
;Entry Conditions: None
;Exit  Conditions: None

SENDCS  equ  6e1eh
SNDCS equ SENDCS ; m200 techref name
;send XOFF (^S) to serial port
;Entry Conditions: None
;Exit  Conditions: None
;T200rom_published_lib.asm says 8617 TESTME FIXME



SD232C  equ  8643h
;send character to serial port (with xon/xoff)
;Entry Conditions: A = character to send
;Exit  Conditions: Carry set if BREAK pressed 

;FIXED scan not clear!!!!!
SNDCOM  equ  864fh
;send a character to RS232-C or modem (without
;XON/XOFF flow control)
;This is a jump into the middle of SD232C
;and when run with this entry, does a POP
;before returning without doing a PUSH first.
;Entry conditions: C = character to be sent
;	dummy value on stack to protect return address
;Exit conditions:  unknown
;sample: do_sndcom
;	[...]
;	push b
;	jmp SNDCOM
;;;from cross2.doc
;;;marked as unreliable source, confirm?
;;;;;;;confirmed by t200rom_unpublished_lib.asm
;;;also confirm if m200 sd232 preserves BC which causes
;;;this to need the dummy value on the stack

CARDET  equ  874ah
;detect carrier on modem only
;Entry Conditions: None
;Exit  Conditions: A = 0 if carrier
;                  Z flag set if carrier
;                  Z flag clear otherwise

BAUDST  equ  86adh
;set baud rate on rs232c
;Entry Conditions: H = baud rate (1-9,M)
;Exit  Conditions: None

;FIXED can't read scan!!!!
INZCOM  equ  86DEh
;initialize rs232 and modem
;Entry Conditions:H = baud rate (1-9,M)
;                 L = UART config code see below
;                 Carry set if RS232
;                 Carry clear if modem
;Exit  Conditions: None
;from rcmap5.200

;bits description
; 7-6 stop bits: 00= none 10=1, 01=1.5, 11=2
;   5 parity: 0=odd 1=even
;   4 parity enable: 0=disable 1=enable
; 3-2 word length: 00=5, 10=6,01=7,11=8
; 1-0 baud rate: 00=none, 10=x1 01=x16 11=x64

COMSTR equ 0ef3cH
;current STAT settings, 7 bytes not null terminated
;baud,length,parity,stop bits, xon/off,ignore control, ignore lf

SETSER  equ  191dh
;set serial params, activate rs232 or modem
;Entry Conditions:  HL=address of STAT string terminated 
;                   by 0   (88N1D,0)
;                   Carry set for rs232
;                   Carry clear for modem
;Exit  Conditions: None

CLSCOM  equ  87b6h
;deactivate rs232/modem
;Entry Conditions: None 
;Exit  Conditions: None

;t200rom_published_lib.asm says CLDCOM at 87b5 FIXME TESTME

;;;;Cassette functions

DATAR equ  88b3h
;read character from cassette no checksum
;Entry Conditions: None
;Exit  Conditions: D= char read
;		carry set if break pressed

CTON  equ  15c0h
;turn on motor
;Entry Conditions: none
;Exit  Conditions: none

CTOFF  equ  15c2h
;turn off motor
;Entry Conditions: none
;Exit  Conditions: none

CASIN  equ  15c8h
;read a character and update checksum
;Entry Conditions: C = current checksum
;Exit  Conditions: A = character
;                  C = new checksum

CSOUT  equ  15d9h
;write char to cassette and update checksum
;Entry Conditions: A = character to send
;                  C = current checksum
;Exit  Conditions: C = new checksum

SYNCW  equ  87d1h
;write cassette header and sync byte
;Entry Conditions: none
;Exit  Conditions: Carry set if break pressed

SYNCR  equ  8810h
;read cassette header and sync byte
;Entry Conditions: none
;Exit  Conditions: Carry set if break pressed

DATAW  equ  87e6h
;write a char to cassette no checksum
;Entry Conditions: A = character to write
;Exit  Conditions: none

;FINDFREQ equ 6FDBH   
;Find the frequency of the cassette port.  This routine
;measures the duration from the start to the stop of half of
;the wave presented on the cassette port.  The result is the
;number of 29 t-state cycles required to find the end of the
;wave.  The byte at FF8EH determines if the count will trigger
;on a high or low pulse.  For example, a 1200 hz signal, which
;would take 416 ms to go through half of the wave, would cause
;this routine to exit with a value aound 35.  If the sound
;option is turned on (see FF44H), this routine will click the
;beeper on each call.  Note:  Although this routine analyses
;the cassette port in 29 T-state intervals, the actual routine
;requires much more time to execute.
;Entry Conditions: TRIGFLAG (FF8E) set
;		SOUNDFLAG (FF44) set
;Exit  Conditions:
;                C - Number of 29 T-state cycles
;                A - Destroyed
;           C flag - Set if the routine was canceled by a shift break

;CRECIN equ 2413H 
;Load a record from cassette and put it in the buffer pointed to
;by HL.
;Entry Conditions:
;      HL - Points to start of receiving buffer
;      DE - Number of bytes to load.
;Exit  Conditions:
;      All registers destroyed
;from Mike Nugent


;;; RAM file routines

DIRECTORY equ 0f252h
DIRTBL	equ 0f252h
;DIRTBL is NEC name
;RAM file directory

;dir entry is 11 bytes long
;byte 0     directory flag 
;              FF=end of directory
;byte 1-2   address of file
;byte 3-10  filename 8 bytes

;directory flag byte
;bit 7 (msb)   1 if valid entry
;bit 6         1=ascii (DO)
;bit 5         1=machine language (CO)
;bit 4         1=ROM file
;bit 3	       1=invisible file
;bit 2	       reserved
;bit 1	       reserved
;bit 0	       internal use only

ENDDIR equ 0FFh 
;this value in byte 1 means no further entries

FILNAM equ 0f746h
;standard filename variable 8 bytes

FDIR equ 0f2b5h
USRDIR equ FDIR
;2 bytes
;points to first file in directory
;USRDIR is the NEC name
;from cross2.doc

PRSNAM equ 5acah
;parse a filename "file.do" into FILNAM
;Entry Conditions: HL->file name
;                  E=length of file name
;Exit  Conditions: filename into FILNAM (fc93)
;from cross1.doc

MAKTXT  equ  2d7ch
;create a text file
;Entry Conditions: filename must be in FILNAM, extention 
;                  not required
;Exit  Conditions: HL=top of new file
;                  DE=address of directory entry
;                  Carry set if file exists
;                  Carry clear if new file

CHKDC equ  6e4dh
;search for 4.2 filename
;Entry Conditions: DE=address of null-terminated 
;                  filename to find
;Exit  Conditions: HL=address of directory entry
;                  Z flag = 0 if file found
;                  Z flag = 1 if file not found

FNDFIL equ 2bcch
;search directory for file named at FILNAM
;Entry Conditions: FC93h+ contains filename
;Exit Conditions: if Z clear the HL->directory
;                    Z set, no file found
;from cross1.doc
;marked as from unreliable source, confirm?
;confirmed by rcmap2.200


CHKFN equ 6E4Fh
;search for a full-size filename
;this is a workaround for the fact that chkdc can only 
;find 4 letter names like note.do and adrs.do
;Entry Conditions: A=0ah
;                  DE=address of null-terminated 
;                  filename
;Exit Conditions:  HL=address of directory entry
;                  Z flag=0 if file found
;                  Z flag=1 if file not found
;; from cross1.doc
;; marked as from unreliable source, confirm?
;confirmed by rcmap5.200

;MKPNAM equ 59ADh
;convert dir entry style filename 'FILE  DO' to 
;'FILE.DO'
;Entry Conditions: DE -> directory name
;                  HL -> output buffer
;Exit Conditions: none
;from sandr.asm

DIROK equ 2C62h
LNKFIL equ DIROK
;fix directory pointers after file growth/shrink
;LNKFIL is the NEC name.
;Entry Conditions: none
;Exit Conditions: none
;from cross1.doc
;marked as from unreliable source, confirm?

GTXTTB  equ  6e8ch
GETTP equ GTXTTB ; name in t200rom_unpublished_lib.asm
;gets top address of file
;Entry Conditions: HL=address of directory entry
;Exit  Conditions: HL=address of top of file
;t200rom_unpublished_lib.asm says GETTOP is 6e8d TESTME FIXME


KILASC  equ  2ab5h
;delete a text file
;Entry Conditions: DE=address of top of file
;                  HL=address of directory entry
;Exit  Conditions: None
;t200ROM_PUBLISHED_LIB.ASM says 2ab4 TESTME FIXME



INSCHR equ  829ch
;insert a character in a file
;Entry Conditions: A = character to insert
;                  HL=address to insert character
;Exit  Conditions: HL=HL+1
;                  Carry set if out of memory

MAKHOL equ  82a8h
;insert a number of spaces
;Entry Conditions: BC=number of spaces
;                   HL=address to insert at
;Exit  Conditions: HL & BC are preserved
;                  Carry set if out of memory

MASDEL equ  82dah
;delete a number of characters
;Entry Conditions: BC=number of characters to delete
;                  HL=address to delete from 
;Exit  Conditions: HL & BC are preserved

NXTDIR equ 2Bf2h
;retrieve the next directory entry of an active file
;Entry Conditions: HL should point to directory entry 
;   before the starting point.  search routine begins 
;   by pointing to the next entry
;Exit  Conditions: Z set = no more entries
;                   Z clear, HL -> dir. entry of an 
;                            active file
;from cross1.doc 


;FREDIR  equ 20ech
;locate an empty directory slot
;Entry Conditions: none
;Exit  Conditions: HL -> free slot
;	drops to BASIC with an FL error if no free slots
;from sandr.asm

MAKFIL equ 2dacH
;Insert entry into directory.
;         Entry:
;               HL - Points to empty directory slot
;               DE - Contains address of file in RAM
;                A - Attribute (80h=.BA, C0h=.DO, A0h=.CO, etc.)
;         Note: Routine gets filename from FC93H, where it must be stored
;               padded with spaces, no delimiter.
;         Exit: DE - Unchanged
;from cross1.doc

;KILDC equ 2aa2h
;Kill DO CO file type
;???
;from t200rom_unpublished_lib.asm

;KILB equ 2B0Ch
;kill BA file
;????
;from t200rom_unpublished_lib.asm

KILD equ 2ab5h
; entry that kills .DO and returns properly
;?????
;from t200rom_unpublished_lib.asm

;KILC    equ    2ACEH           
; entry that kills .CO and returns properly
;?????
;from t200rom_unpublished_lib.asm



;;;Other functions

POPALL equ 1604h 
;pop all registers and return
;Entry Conditions: registers were pushed in 
;      H,D,B,PSW order
;Exit Conditions: none
;from p100-8812
;t200 address from Stephen Adolh

INITIO  equ  841ch
;cold start
;Entry Conditions: None
;Exit  Conditions: None

IOINIT  equ  8439h
;warm start
;Entry Conditions: None
;Exit  Conditions: None

;BOOT equ 7d33h
;reboot.  rst 0 jumps here
;Entry Conditions: none
;Exit  Conditions: none
;from m100rom_unpublished_lib.asm

MENU equ  67a4h
;go to main menu
;Entry Conditions: None
;Exit  Conditions: None

;PWRRES equ 143Fh
;POWER OFF, RESUME
;Shuts the machine off. Program continues
;when its turned back on.
;Entry Conditions: None
;Exit Conditions: None

MUSIC equ  8bc0h
;generates a tone
;Entry Conditions: DE=frequency
;                  B=duration
;Exit  Conditions: None

BEEP equ 4f45h
;BASIC BEEP
;Entry Conditions: none
;Exit  Conditions: A=7
;from cross1.doc

TIME equ  1a7eh
;read system clock
;Entry Conditions: HL=address of 8-byte buffer
;Exit  Conditions: buffer holds current time (hh:mm:ss) 

DATE equ  1a9eh
;read system clock
;Entry Conditions: HL=address of 8-byte buffer
;Exit  Conditions: buffer holds current date (mm/dd/yy)

DAY equ  1ac5h
;read system clock
;Entry Conditions: HL=address of 3-byte buffer
;Exit  Conditions: buffer holds day


BLKMV equ 41bah
;move B bytes from (DE) to M with increment
;Entry Conditions: DE -> start of block to move
;                  HL -> destination block
;                  B = bytes to move
;Exit  Conditions: HL=DE=HL+B+1
;                  A, B destroyed
;from cross1.doc

MVHBI equ 32A7h
;move B bytes from M to (DE) with decrement
;Entry Conditions: HL -> start of block to move
;		   B = number of bytes to move
;		   DE -> destination block
;Exit  Conditions: ????
;from t200rom_unpublished_lib.asm

MVHBCI equ 8316h
;move BC bytes from M to (DE) incrementing BC
;Entry Conditions: HL-> start of block to move
;		   DE-> destination block
;		   BC = number of bytes to move
;Exit  Conditions: ?????
;from t200rom_unpublished_lib.asm

MVNBCD equ 8321h
;Move from HL to DE (decrementing) for BC bytes
;Entry Conditions: HL -> start of block to move
;		   DE -> destination block
;		   BC = number of bytes to move
;Exit  Conditions: ????
;from t200rom_unpublished_lib.asm


LINNUM equ 0916h
;convert ascii string to BASIC line number
;ascii-to-integer, except that there's a range of
;invalid BASIC line numbers that this won't return
;(number < 65529)
;Entry conditions: HL -> string to convert to int
;Exit  Conditions: DE=integer
;                  Carry set if a number was present
;rcmap1.200

;BASEXPR equ 1297h
;BASIC expression parser
;for simple integer-digit conversion only.
;Will dump you into BASIC with a ?SN ERROR on error...
;use carefully
;Entry Conditions: HL -> string to parse
;Exit  Conditions: DE=result of expression
;Ken Pettit

UPCAS equ 1014h
;convert a character to uppercase
;Entry Conditions: A=char to convert
;Exit  Conditions: A holds uppercase character
;from cross1.doc


;PRGADD equ 344ah
;return starting address of file
;Entry Conditions: HL->dir entry
;Exit  Conditions: DE=address
;p100-8709

RSTDOG equ 2697h
;reset power-off watchdog
;Entry Conditions: none
;Exit  Conditions: none
;from Douglas Quigliana via cross1.doc

;;;the ROM apps
;clobbers non-file ram on entry
;exit to MENU
TXT equ 719Dh
;from cross1.doc
;TEXT is a reserved word in zmac
BASIC equ 838fh
TELCOM equ 5ffdh
ADDRSS equ 6ee7h
SCHEDL equ 6eedh
;cross1.doc
;
;SABASE equ 5b74h
;common database code for addrss/schedl
;entry conditions: A=0 "Adrs" prompt
;                  A!=0 "Schd" prompt
;                  DE -> 8 byte null terminated filename
;                    -or-
;                  DE=FDD9h
;                  FDD9 = full size null terminated 
;                         filename

;ADSCFILE equ 0FFD9h
;null-terminated filename buffer for addrss/schedl
;p100-8403     

;TXTENT equ 05f71h
;entry into init of TEXT
;p100-8812

;FILOFF equ 0f6e7h
;2 bytes
;offset from the beginning of the file being edited by 
;TEXT, so TEXT knows where to display
;p100-8812


;;;I/O ports
;I had no idea I/O ports were so screwy on the m100!
;70h-7fh free
;80h-8fh optional i/o controller
;90h-9fh optional answering modem

;A0h-AFh bit 0: on/off for relay for signal selection
;               of telephone unit
;        bit 1: generate ENABLE signal for modem
;b0h-bfh 8155 PIO
;c0h-cfh enable data i/o on uart
;d0h-dfh enable config on uart
;e0h-efh enable signal for STROM, REMOTE
;        also parallel port strobe and read keyboard
;f0h-ffh enable signal for LCD

;PHONEPORT equ 0a0h


;b0=b8=command/status
;b1=b9=port A
;b2=ba=port B
;b3=bb=port C
;b4=bc=timer register low byte
;b5=bd=timer register high byte

;PIOCMD equ 0b0h
;PIOA equ 0b1h
;PIOB equ 0b2h
;PIOC equ 0b3h
;PIOTL equ 0b4h
;PIOTH equ 0b5h

;UARTDAT equ 0C0h
;UARTCFG equ 0D0h

;KEYPORT equ 0E0h
;LCDPORT equ 0F0h
 

;;;interesting variables and constants

STKTOP equ 0f650h
;2 bytes
;holds the beginning address of the stack
;rcmap7.200

PTIMER equ 0ef38h
;1 byte
;Number of 6-second intervals before the m100 
;shuts itself off.
;0=disable power-off timer
;;from cross2.doc

POWERFLAG equ 0f222h
;1 byte
;0=do not shut off m100
;from Douglas Quiagliana via cross2.doc
;marked as from unrelible source, confirm?


;PASTEPTR equ 0f88ch
;SCRDIR   equ 0f88ch
;2 byte value
;points to paste buffer file
;paste buffer is null-terminated
;SCRDIR is the NEC name
;; from web100 "Model 100 hints and ticks"

;SHPRTPTR equ 0f88ah
;2 byte pointer
;points to null-teriminated string returned by 
;   shft-print key 
;"llist\n" by default
;; from web100 "Model 100 hints and ticks"

BRKDIS equ 0EF32h
;1 byte
;store 80h here to disable the top row of keys (Fx, 
;print, arrows)
;store 0h here to enable top row of keys
;; from cross2.doc
;; marked as from unreliable source, confirm?

MAXRAM equ 61104
;top of user ram, above this are system vars that 
;shouldn't be frobbed casually....61104 decimal
;;from "An Assembly language Tutorial for the Model 100"
;;Mike Berro, 1984
;T200rom_unpublished_lib.asm

HIMEM equ 0EEB4h
;2 bytes -- bottom of protected memory for binaries
;from cross2.doc

FREBAS equ 0f295h
NULDIR equ FREBAS
;2 bytes
;points to start of free BASIC memory
;NULDIR is the NEC name
;(contents of Hidden file Suzuki)
;from cross2.doc
;also lists f4bbh as from an unreliable source! Confirm?
;confirmed by rcmap7.200

MAXFILE equ 0f735h
;1 byte
;number of file buffers reserved
;from cross2.doc

NEXTTXT equ 0F2A0h
;2 bytes
;address of next text file
;from cross2.doc

DOSTART equ 0F661h
ASCTAB equ DOSTART
;2 bytes
;start of DO files
;ASCTAB is the NEC name
;from cross2.doc
;marked as from unreliable source, confirm?
;confirmed by rcmap7.200


COSTART equ 0f663h
BINTAB equ  BINTAB
;2 bytes
;start of CO files
;BINTAB is NEC's name
;from cross2.doc
;marked as from unreliable source, confirm?
;confirmed by rcmap7.200


VARSTART equ 0f665h
VARTAB equ VARSTART
;2 bytes
;start of BASIC variable space
;VARTAB is the NEC name
;from cross2.doc

ARRSTART equ 0f667h
ARYTAB equ ARRSTART
;2 bytes
;start of BASIC arrays
;ARYTAB is the NEC name
;from cross2.doc

FRESTART equ 0f669h
STREND equ FRESTART
;2 bytes
;start of free memory
;STREND is the NEC name;
;from cross2.doc

;FILEEND equ 0f88ch
;2 bytes
;end of file storage

;SYSRAM equ 0fac0h
;2 bytes
;lowest ram used by system


HOOK equ 0f507h
;RST7 hook table address
;you can call the Nth function in the table by:
;rst7
;db 2n
;and RST7 will call HOOK+2n
;;;from cross2.doc

SOUNDFLAG equ 0fcf4h
;cassette input echoed out speaker
;1 byte
;0=on
;from cross2.doc

;TRIGFLAG equ 0FF8Eh
;High or low cassette level trigger flag for FINDFREQ
;1 byte

;;;;end t200.def
