Lisa_Boot_ROM_RM248

        .NOLIST
;===============================================================================;
;									        ;
;		     LL	       II    SSSSSSS	   AAA			        ;
;		     LL	       II    SS		  AA AA			        ;
;		     LL	       II    SSSSSSS	 AAAAAAA		        ;
;		     LL	       II	  SS    AA     AA		        ;
;		     LLLLLLL   II    SSSSSSS   AA       AA		        ;
;									        ;
;									        ;
;   BBBBBB     OOOOO	 OOOOO	  TTTTTTTT      RRRRRR	   OOOOO    MMM	  MMM   ;
;   BB	 BB   OO   OO   OO   OO	     TT	        RR   RR	  OO   OO   MM M M MM   ;
;   BBBBBB    OO   OO   OO   OO	     TT	        RRRRRR	  OO   OO   MM  M  MM   ;
;   BB	 BB   OO   OO   OO   OO	     TT	        RR RR	  OO   OO   MM	   MM   ;
;   BBBBBB     OOOOO	 OOOOO	     TT	        RR   RR	   OOOOO    MM	   MM   ;
;									        ;
;									        ;
;       Copyright 1983, 1984 Apple Computer Inc.			        ;
;       Revision 2H							        ;
;									        ;
;===============================================================================;
;
; Filename:  RMXXX.Y.TEXT, XXX = ROM VERSION # (e.g., 200 for 2.00)
;			     Y = E (equates)
;			       = K (kernel tests)
;			       = S (secondary tests)
;			       = B (bootstrap code)
;			       = M (monitor code)
;			       = G (graphics, icon and message display)
;
; Function:  Initializes LISA system for use and performs preliminary
;	     diagnostic checks.	 If all tests pass, the system then
;	     does a keyboard scan to check for user input.  If any key
;	     is hit other than caps lock or the mouse button,
;	     a menu is displayed on the screen showing the available
;	     boot devices.  If a valid COMMAND key sequence is detected,
;	     a boot from an alternate device is attempted (see below).
;	     If no keyboard input is detected, the system first checks
;	     parameter memory for a valid boot device and, if none, defaults
;	     to booting from a Profile attached to the builtin parallel port
;	     for Lisa 1 systems.
;
;	     For Lisa 2 systems, a check is first made to verify a disk
;	     (internal or external) is connected before defaulting to the
;	     hard disk boot.  If no disk is detected, the system defaults
;	     to booting from the floppy drive.
;
;
;
; Inputs:    Checks for keyboard input from the user.  Currently, the following
;	     key sequences are honored if input after the system "clicks" the
;	     speaker (CMD refers to the Apple key on the keyboard):
;
;	        CMD/1 - boot from Twiggy drive #1 or integral hard disk
;	        CMD/2 - boot from Twiggy drive #2 or SONY drive
;	        CMD/3 - boot from Profile attached to parallel port or integral hard disk
;	        CMD/4 - boot from I/O slot #1, port 1
;	        CMD/5 - boot from I/O slot #1, port 2
;	        CMD/6 - boot from I/O slot #2, port 1
;	        CMD/7 - boot from I/O slot #2, port 2
;	        CMD/8 - boot from I/O slot #3, port 1
;	        CMD/9 - boot from I/O slot #3, port 2
;	        CMD/ENTER (on key pad) - abort boot, branch to ROM monitor
;	        CMD/SHIFT/P - abort boot, do power cycling
;
;  OUTPUTS:  Saves various results and contents of system registers in memory
;	     for examination by system programs or with the ROM monitor.
;
;	        $180-183 : Power-up status (x0000000 = ok)
;	        $184-185 : Memory sizing error results
;	        $186-1A5 : Results of memory read/write tests
;	        $1A6-1A9 : Parity error memory address (if error during mem test)
;	        $1AA-1AB : Memory error address latch
;	        $1AC-1AF : D7 save on exception errors
;	        $1B0-1B1 : Results of MMU tests (context/data bits)
;	        $1B2	 : Keyboard ID (00 = no ID received)
;	        $1B3	 : Boot device ID
;	        $1B4-1B9 : Boot failure data
;	        $1BA-1BF : Clock setting (Ey,dd,dh,hm,ms,st)
;	        $1C0-1DF : Data reg save area (D0 - D7)
;	        $1E0-1FF : Address reg save area (A0 - A7, A7 = USP)
;	        $240-260 : System serial #
;	        $260-267 : Scratch area
;	        $268-26B : Suspected (logical) memory error address for parity error
;	        $26C-26F : Save of data written to suspected error address
;	        $270-273 : Actual (logical) error address found during search
;	        $274-277 : Save of data read during parity error search
;	        $278-27B : (Physical) error address read from parity error address latch
;	        $27C	 : Error row for parity chip failure (0 = first row, 7 = last row)
;	        $27D	 : Error column for parity chip failure (9 or 14)
;	        $27E-280 : Reserved
;	        $280-293 : Exception data save area
;			    (FC/EXCADR/IR/SR/PC/EXCTYPE/SSP)
;			    44 = NMI or other interrupt
;			    45 = bus error
;			    46 = address error
;			    47 = other exception/interrupt
;			    48 = illegal instruction error
;			    49 = line 1010 or 1111 trap
;			    50 = bus error accessing keyboard VIA
;			    51 = bus error accessing parallel port VIA
;			    57 = bus error accessing disk controller
;	        $294-297 : Maximum physical memory address + 1
;	        $298-299 : I/O slot 1 card id (0 = no card present)
;	        $29A-29B : I/O slot 2 card id
;	        $29C-29D : I/O slot 3 card id
;	        $29E	 : Reserved
;	        $29F	 : Reserved
;	        $2A0	 : Reserved
;	        $2A1	 : Disk ROM id
;	        $2A2-2A3 : Reserved
;	        $2A4-2A7 : Minimum physical address
;	        $2A8-2AB : Total memory (Max-Min)
;	        $2AC	 : SCC test results
;	        $2AD	 : Slot # of memory board if memory error
;	        $2AE	 : Result of disk controller self-test
;	        $2AF	 : System type (0 = Lisa 1, 1 = Lisa 2, 2 = Lisa 2 with external hard disk,
;				        3 = Lisa 2 with internal hard disk)
;	        $2B0-2BF : Keyboard queue (16 bytes)
;	        $2C0-480 : ROM scratchpad/stack area
;	        $480-800 : Reserved for ROM local variable usage
;
;	     Also saves data in special parameter memory area reserved for boot ROM use if error
;	     encountered.  Usage is as follows:
;
;	        $FCC161	    : Error code
;	        $FCC163-165 : Contents of memory error address latch if parity error
;	        $FCC167	    : Memory board slot # if memory error
;	        $FCC169-173 : Last value read from clock
;	        $FCC175-17B : Reserved
;	        $FCC17D-17F : Checksum
;
;
; Originator:  Rich Castro  7/30/81 - Version 0.0 released to manufacturing
;
; Modified by: Rich Castro  7/30 - 11/3/81 - Made the following changes:
;				       1) Twiggy bootstrap capability
;				       2) Initial COPS test and keyboard scan
;				       3) Moved parallel card to slot 2
;				       4) Changed ROM interrupt/exception vectors,
;				       5) Created jump table for ROM routines
;
;			    11/3/81  - Version 0.7 released to the world
;
;			    11/4/81 - 1/15/82 - Made the following changes:
;				       1) Added support for new memory cards
;				       2) Added warm-start capability and jump
;					  table for ROM subroutine usage
;				       3) Modified MMU reset routine to support
;					  single step board usage
;				       4) Added full memory initialization
;				       5) Added 256K memory parity test
;				       6) Modified COPS initialization so that
;					  keyboard commands can be sensed more
;					  reliably
;				       7) Added error code display routines and
;					  display of CPU and IO ROM versions
;				       8) Added preliminary disk controller test
;				       9) Updated warm-start check
;				      10) Modified disk interface test
;				      11) Changed low memory assignments
;				      12) Made corrections for no I/O board, disk
;					  interface error and contrast setting
;				      13) Modified memory sizing routine to
;					  catch memory errors
;				      14) Modify MMU test to avoid context 0
;					  destruction, add contrast setting for
;					  new machines, correct disk error and
;					  CPU ROM messages
;				      15) Move stack so old memory test still runs
;
;			        1/15/82 - Release version 0.16
;			        1/18/82 - Fix stack problem and release vrsn 0.17
;			        1/19/82 - Change stack for call routine and version
;					  to 0.18
;			        1/27/82 - Change MMU error routine to do address
;					  and data line toggling
;			        1/28/82 - Add video circuitry test
;			        1/30/82 - Add write wrong parity test
;			        1/31/82 - Move run time stack to $180
;			        2/6/82  - Add Profile bootstrap with upgrade for
;					  OS use (add jump table entries also)
;			        2/15/82 - Update Twiggy bootstrap and add entry
;					  for OS use; also add MMU test to
;					  conditional assembly and add context
;					  saving to MMUTST2 routine
;			        2/17/82 - Add correction to memory test for
;					  reboot problem and leave parity on
;			        2/24/82 - Add code for clock test and special
;					  burn-in cycling
;			        2/25/82 - Add code to simulate soft on switch
;					  pressed for COPS problem
;			        3/1/82  - Removed all changes since ROM 0.18
;					  release except for parity enabling,
;					  no reset feature, memory sizing change
;					  and Profile booting
;			        3/1/82  - Restore default stack ptr loc to $300
;			        3/1/82  - Move default stack to $0400, restore
;					  everything except MMU testing
;			        3/4/82  - Add MMU initialization and modify
;					  Twiggy, Profile boot routines for new
;					  load point
;			        3/10/82 - Add change for new I/O addresses and
;					  fix for Twiggy routine
;			        3/10/82 - Change contrast value for new I/O's
;			        3/15/82 - Add correction for Profile and COPS
;					  routines and display msg when booting
;			        3/17/82 - Restore version # at end of file
;			        3/18/82 - Release version 0.22
;
;			        4/5/82  - Make initial 2732 version (1.00); add
;					  following changes:
;					    1) correct MMU error routine bug
;					    2) change stack for CALL to $0400
;					    3) add parity disable to WWP routine
;					    4) change MMU I/O space code to '9'
;					    5) add invalid boot code message
;			        4/6/82  - Add speaker click after COPS check
;			        4/7/82  - Add jump table entry for speaker
;					  routine, 1 second delay before "click"
;					  and alpha lock key check
;
;			        4/8/82  - Release version 1.00
;
;			        5/5/82  - Add I/O slot configuration check and
;					  I/O slot booting.  Also add change to
;					  Profile read routine for PCR setting.
;			        5/12/82 - Add burnin power-cycling routine as
;					  boot option invoked by CMD/P.
;			        5/13/82 - Add changes for COPS command timing,
;					  Twiggy timeout, Twiggy booting, and
;					  add power-cycling routine.
;			        5/14/82 - Add fixes for booting via parameter
;					  memory and COPS timing experiment.
;			        5/17/82 - Add display of loop count and run time,
;					  and alter parameter memory useage for
;					  power-cycling option.
;			        5/18/82 - Add display of Twiggy errors, change
;					  COPS routine for precheck code.
;			        5/20/82 - Add contrast reset for "warm start",
;					  add cycle value display, restore COPS
;					  timeout code.
;
;			        5/21/82 - Release version 1.02
;
;			        5/26/82 - Begin addition of ROM monitor; set
;					  default to Apple if PM = 00.
;			        6/1/82  - Make following changes:
;					  1) Memory sizing retry count to 64
;					  2) Save results on memory sizing errors
;					  3) Update NMI routine to check for parity
;					     errors.
;					  4) Restore default NMI vector after
;					     memory test.
;					  5) Create read clock subroutine and call
;					     when doing clock display.
;					  6) Add boot fix to save device id.
;			        6/1/82  - Change to new sizing algorithm and retry
;					  count back to 32.
;			        6/3/82  - Convert to version 1.03
;			        6/3/82  - Made following changes:
;					   1)Localize message display to TSTCHK
;					   2)Do clear screen only in INITVCT and
;					     in TSTCHK and second monitor level.
;					   3)Change default video page to last.
;					   4)Complete first edition of monitor.
;			        6/7/82  - Modify monitor level2 user interface.
;			        6/10/82 - Made following changes:
;					   1)Add boot from Apple as CMD/A.
;					   2)Clear screen and display only in
;					     routine TSTCHK.
;					   3)Add ROM checksum error bit.
;					   4)Add exception error check to TSTCHK.
;					   5)Add speaker click just before
;					     keyboard scan.
;					   6)Reset to first video page for boot
;					     from Apple.
;					   7)Merge in changes from 1.03 file.
;					   8)Add parity error check to TSTCHK
;					   9)Change power-cycling so that double
;					     bus fault used to restart diags
;			        6/11/82 - Made following changes:
;					   1)Increase Twiggy timeout to 2 mins.
;					   2)Add 5 sec delay in power-cycle mode
;					     before shutting down.
;
;			        6/14/82 - Release version 1.04
;
;			        6/22/82 - Add loop after COPS test if error
;					  since keyboard not accessible.  Also add
;					  fix for NMI restore after memory test.
;			        6/30/82 - Made following changes:
;					   1)Add parameter memory and I/O boot
;					     checksum routines.
;					   2)Remove boot id save to parameter
;					     memory, except for power-cycle.
;					   3)Change to new boot device id's.
;			        7/1/82  -  1)Add changes for new Twiggy firmware.
;					   2)Add fixes for bugs in 1.04:
;					    a)Add row setting before error display
;					      to avoid writing over menu line.
;					    b)Set device codes for Profile and
;					      I/O slots to allow display if error.
;					    c)Enable setting of timeout for Twiggy
;					      reads.
;					    d)Save error codes for I/O boot in
;					      memory.
;					    e)Add option of clearing memory in
;					      INITMON routine.
;			        7/7/82  - Made following changes:
;					   1)Modify checksum routines
;					   2)Add keyboard/mouse check/reset code
;			        7/13/82 - Add speed parameter for new Twiggy code
;			        7/14/82 - Add check for DSKDIAG in disk test,
;					  change to new Twiggy error codes
;			        7/15/82 - Made following changes:
;					   1)Add Profile routine updates.
;					   2)Restore old boot id codes - new ones
;					     used only when new Twiggy code
;					     released.
;					   3)Upgrade burnin code for new parameter
;					     memory usage.
;					   4)Attempt to enable keyboard after MMU
;					     errors.
;					   5)Remove I/O boot checksum code until
;					     conversion to new Twiggy code.
;					   6)Add video pattern display code..
;					   7)Remove characters from table and
;					     make other changes to save bytes.
;					   8)Upgrade service mode display option
;					     to handle count up to $FFFF.
;
;			        7/16/82 - Create version 1.05
;			        7/19/82 - Add bug fixes for MMU testing, power-
;					  cycle memory testing, Profile boot
;					  and service mode display option.
;
;			        7/19/82 - Create version 1.06
;			        7/20/82 - Add fix for MMU testing to properly
;					  record context in error
;
;			        7/20/82 - Release version 1.07
;
;			        7/21/82 - Make keyboard/mouse reset code changes
;					  and move check to before first "click"
;			        7/23/82 - Add extended memory tests
;			        7/27/82 - Add screen memory test and VIA tests.
;					  Change default boot for new Twiggy code
;					  to upper Twiggy.  Add conditionals for
;					  Apple code.
;			        7/29/82 - Add SCC test, optimize code.
;			        7/30/82 - Add RAM address uniqueness test.
;			        8/4/82  - Added the following:
;					   1)Twiggy mods for interleave
;					   2)Monitor options CONTINUE and LOOP
;					   3)Exception routine for line 1111 and
;					     line 1010 errors.
;			        8/9/82  - Add Twiggy mod for disk clamp, add mods
;					  for kernel test failures such as screen
;					  flash on MMU error.
;			        8/11/82 - Add memory sizing fix, increase delay
;					  for COPS and change default boot to
;					  TWIGGY!!
;			        8/12/82 - Begin code changes for new user interface
;					  and add hooks for icon display.
;			        8/14/82 - Add mods for Twiggy changes to monitor
;					  DSKDIAG line and add initial timeout.
;					  Continue user interface changes.
;			        8/18/82 - Add mouse, cursor code and changes for
;					  Customer mode to use mouse.
;			        8/23/82 - Add controls for 2716 version of ROM.
;					  Add changes for Service mode to use
;					  pull down menu, eliminate keyboard
;					  queuing while awaiting input.
;			        8/24/82 - Add dialog box, and window to service
;					  mode with modified scroll and character
;					  output routines.
;			        8/25/82 - Add icons along with routines to display
;					  during test and for errors.
;			        8/27/82 - Add routines for displaying and using
;					  boot icon menu.
;			        8/30/82 - Add auto boot from Applenet.
;			        8/31/82 - Add minor additions to Service mode
;					  for Set and Loop options.
;
;			        8/31/82 - Create and do internal release of
;					  2716 (0.24), 2732 (1.15) and 2764 (2.00)
;					  ROM versions.
;
;			        9/8/82  - Add fixes for I/O slot icon display
;					  and Profile icon display.
;			        9/9/82  - Add fix for reboot problem in 2716 ROM.
;					  Add serial # read routine and test for
;					  2732 and 2764 ROM versions.  Expand
;					  stack for serial read routine.
;			        9/10/82 - Add fix for device code display for ROM
;					  versions 0.24 and 1.15.
;
;			        9/10/82 - Create and do internal release of new
;					  ROM versions 0.25, 1.16 and 2.01.
;
;			        9/13/82 - Add fixes for memory sizing and I/O
;					  slot booting.
;
;			        9/14/82 - Create and release ROM versions 0.26,
;					  1.17 and 2.02.
;
;			        9/22/82 - Add fixes and code for:
;					   1)Default video latch setting
;					   2)Mask for I/O and exception errors
;					   3)Message display on external calls
;					      to ROM monitor
;					   4)Contrast setting before screen test
;					   5)Disable of NMI key on power-up
;					   6)Boot failure after first load
;					   7)Error tones for failures
;					   8)Loop mode setting of NMI key
;			        9/23/82 - Add
;					   1)Power cycling
;					   2)Full service mode menu
;					   3)Loop mode test choice display
;			        9/24/82 - Add dump memory option to service mode
;			        9/25/82 - Modify display memory option to allow
;					  count and address data on same line
;			        9/29/82 - Add jump table entry for READMMU
;			        9/30/82 - Add:
;					   1)"No reset" feature
;					   2)Verify Disk option for service mode
;					   3)Optimize cursor routines and
;					     remove unused CursorShield routine.
;					   4)Invert rectangles when selected from
;					     keyboard.
;					   5)Display boot menu only if down keycode
;					     detected.
;			        10/5/82 - Add:
;					   1)Memory error decoding to board level
;					   2)New size and position for alert box
;					   3)New test icon display
;					   4)Diskette # for Twiggy errors
;			        10/6/82 - Add:
;					   1)Continue keyboard scan after COPS
;					     errors
;					   2)Set extended memory test bit for
;					     loop on memory test option
;					   3)Display I/O slot card # on errors
;					   4)Change boot menu to "pull-down" format
;					   5)Change to new icons
;			        10/7/82 - Add:
;					   1)SCC test
;					   2)Error if no serial # (allow continue)
;					   3)Two passes of memory tests for extended
;					     mode, one for regular mode
;			        10/9/82 - Create version 2.03
;			        10/10/82 - Add bug fixes and I/O slot ROM check in
;					   config scan.
;
;			        10/12/82 - Create and release version 2.04.
;
;			        10/13/82 - Make following changes:
;					    1)Add keyboard reset code
;					    2)Remove SCC test
;					    3)Add bug fixes for making alert box
;					      and displaying bad keyboard
;			        10/14/82 - Add display of check marks for test icons
;			        10/18/82 - Add fixes for Monitor entry, Profile boot,
;					   looping on diag tests
;			        10/20/82 - Add message translations
;			        10/21/82 - 1)Adjust alert box and button dimensions
;					   2)Add boot from all ports on I/O slots
;					   3)Add fix for CMD key detection in monitor
;					   4)Change powercycle window to alert box
;					   5)Extend verify timeout to 4 minutes
;			        10/22/82 - 1)Add keyboard reset on external entry to ROM
;					     monitor
;					   2)Make Dump Memory routine conditional on
;					     final LISA ROM
;			        10/25/82 - 1)Change wait for disk error to branch to
;					     monitor - CONTINUE option then continues
;					     with the same boot device
;					   2)Change RETRY phrase to RESTART
;			        10/27/82 - Made following changes:
;					    1)RESET instruction on startup
;					    2)Jump table entries for access to memory
;					      test and display decimal routines
;					    3)Optimize warm start reset check and
;					      MMU error loop routines
;					    4)Change default video page to $2F for
;					      no memory found.
;					    5)Rewrite screen memory test. Change main
;					      memory test to go from low memory
;					      to base of screen memory.
;					    6)Move inverse video check to after screen
;					      test, doing rewrite only of screen page.
;					    7)Add new boot failure code, with hooks to
;					      catch booting errors after ROM has
;					      released control to boot loader for Twiggy
;					      and Profile booting.
;			        10/29/82 - Add display for uncompressed slot card icons.
;					   Modify TONE routine to init PCR reg.
;			        11/1/82	 - Change external entry to monitor interface
;					   so that error code displayed on same line as
;					   message if no icon displayed
;			        11/3/82	 - Made following changes:
;					    1)Move creation of test icon display till
;					      after keyboard reset so translation can
;					      be done if necessary
;					    2)Do cursor, mouse init only once so
;					      cursor posn not reset
;					    3)Optimize mouse, cursor routines
;					    4)Correct COPSCMD routine
;					    5)Upgrade check for Profile routine and
;					      optimize Profile read code
;			        11/8/82	 - Conditionally add check for keyboard connected
;					   routine.
;			        11/9/82	 - Create version 2.07
;			        11/11/82 - Modify ROM checksum algorithm
;			        11/12/82 - Add diskette eject on power-off
;			        11/13/82 - 1)Remove Dump Memory/Verify Disk from Service
;					     mode menu
;					   2)Add speaker beep and specific read/write
;					     loop for memory sizing and lo mem errors
;			        11/15/82 - 1)Add keyboard/mouse disconnect check
;					   2)Remove memory "clear" from sizing test - now
;					     done after memory testing
;			        11/16/82 - 1)Change power-cycle invoking to CMD/SHIFT/P
;					     key sequence.
;					   2)Change customer monitor mode invoking to
;					     CMD/ENTER (on key pad) key sequence.
;					   3)Add wait for profile loop in boot menu
;					     display routine
;					   4)Add timeout to general wait for clock
;					     input routine
;					   5)Increase delay for poweroff wait loop
;					   6)Optimize character display routine
;			        11/18/82 - 1)Add save of error code to special parameter
;					     memory area for use during burnin.
;					   2)Add context check for MMU testing
;					   3)Create version 2.08 for internal release
;			        11/19/82 - 1)Change initial position of cursor to center
;					     of screen.
;
;			        11/19/82 -  Release versions 2.08 (internal) and
;					    2.09 (for manufacturing)
;
;			        12/15/82 -  Add:
;					    1)Setting of VIA PCR reg for later use
;					    2)Reset of keyboard before boot
;					    3)Fix for slot 3 card check for boot menu
;			        12/16/82 -  Add:
;					    1)Move Profile cmd buffer to location $304
;					    2)Change default boot device to Profile
;					    3)Remove support for third boot port on
;					      each slot
;					    4)Expand id range for test card search
;					    5)Don't display Restart button after boot
;					      error
;					    6)New icons
;			        12/18/82 -  Fix memory test bug
;
;				 1/3/83	 -  Fix bug in reporting parity circuitry
;					    failure.  Change version to 2.10.
;				 1/7/83	 -  Make following changes:
;					    1)Change keyboard sequences for I/O slot
;					      booting
;					    2)Extend timeout for inital Profile check
;				 1/11/83 -  Change SCC test to use max baud rate for
;					    loopback test
;				 1/12/83 -  Add running of expansion card status routines
;					    when configuration check is done
;				 1/18/83 -  Add fixes for:
;					    1)Continuing after memory error
;					    2)Checking for no reset function
;					    3)Memory sizing - search entire possible 2 meg
;					    4)Read of I/O slot ROM for icon data -
;					      ensure odd address for icon count
;					    5)Default boot setting when loop on memory
;					      test selected
;				 1/21/83 -  Add save of disk controller self-test status
;
;				 1/28/83 -  Create and release ROM version 2.11
;
;				 3/15/83 -  Extend Profile timeout for case where drive
;					    may be parking head. (bug RM016)
;				 4/20/83 -  Add fixes for:
;					     1)Memory sizing (bug RM015).
;					     2)Garbage sent out serial port (RM014).
;					     3)Removed 6504 (bug RM013).
;					     4)Never ready Profile (bug RM011).
;					    Also do some code optimization in icon
;					    routines to make room for fixes. (RM000)
;				 4/22/83 -  Do code optimization for setting bus error
;					    vector (labeled as RM000).
;					    Add changes for following requests:
;					     1)Display ROM id's on bootup  (CHG001)
;					     2)Loop on address 1Meg-2 if sizing error  (CHG002)
;					     3)Turn off contrast before doing poweroff (CHG003)
;					     4)Change copyright notice.	 (CHG005)
;					       Also modify alert msg display routine (CHG005).
;				 4/26/83 -  Add loop on CPU diags if no memory or I/O
;					    board installed.  Also toggle LED. (CHG004)
;				 4/27/83 -  Do only basic memory test on warm-start. (CHG006)
;					    Add fix for NMI bug (RM010).
;				 5/9/83	 -  Made following changes:
;					     1)Change ROM id display to rev # (D) (CHG001)
;					     2)Change ROM test failure to loop at fixed address
;					       $00FE00C8  (end of jump table)  (CHG007)
;					     3)Make correction for screen not cleared when
;					       continuing from I/O slot error to boot menu.
;					       (CHG008)
;				 5/10/83 -  Add change to enable display of uncompressed icons
;					    upon external entry to ROM Monitor (CHG008).
;
;				 5/12/83 -  Create and release rev D of boot ROM.
;
;				 8/8/83	 -  Add changes for Pepsi system:   (CHG009)
;					    1) New icons.
;					    2) Display of icons with id #'s.
;				 8/9/83	 -  Add save of disk ROM id in low memory. (CHG010)
;					    Add fixes for:
;					    1) SCC init for Applebus.  (CHG011)
;					    2) Test card boot search.  (CHG012)
;				 8/10/83 -  Delete inverse video check. (CHG013)
;					    Add fix to beep routine.    (CHG014)
;				 8/16/83 -  Delete memory address and ping pong routines,
;					    add routines to decode parity error to
;					    chip.       (CHG015)
;				 9/1/83	 -  Add retry for hard disk booting.  (CHG016)
;					    Add jump table entry for write to
;					    parameter memory routine.   (CHG017)
;				 9/2/83	 -  Add new font, modify display routines. (CHG018)
;					    Add wait for hard disk ready when
;					    power-cycling.  (CHG019)
;				 9/6/83	 -  Add setting of video latch whenever boot
;					    error causes jump to ROM low memory default
;					    vectors. (CHG020)
;					    Add fix for memory test/initialization
;					    bug. (CHG021)
;				 9/7/83	 -  Add read of disk controller ROM self-test
;					    results.  (CHG022)
;					    Add skip of disk eject on power-off if any
;					    disk controller errors occurred.  (CHG023)
;
;				 9/8/83	 -  Release for testing (rev 3B) with Pepsi systems.
;
;				 10/10/83 - 1)Make Pepsi icon changes.  (CHG024)
;					    2)Add fix for proper setting of carry bit
;					      on floppy or hard disk boots. (CHG025)
;					    3)Add fix for video reset on boot from not ready
;					      Profile. (CHG026)
;				 10/12/83 - Add change to reset SCC for Applebus before
;					    doing memory test.  (CHG027)
;				 10/20/83 - Add fix for service mode bus error problem. (CHG028)
;
;
;				 10/20/83 - Release as rev E for Lisa and Pepsi systems.
;
;				 12/15/83 - 1)Add new code to determine system type. (CHG029)
;					    2)Change default boot device for Lisa 2
;					       system if no hard disk connected. (CHG030)
;					    3)Extend timeout for hard disk ready. (CHG031)
;					    4)Add bug fix for wrong icon display on Lisa 2.
;					       (CHG032)
;					    5)Add bug fix for menu display when mouse or
;					      keyboard not connected. (CHG033)
;					    6)Remove save of error code in parameter memory.
;					      (CHG034)
;				 12/16/83 - Release as rev 'X' for testing
;
;				 12/21/83 - Release as official rev 'F' for all systems
;
;				 1/25/84  - 1)Add code to properly initialize Profile-reset
;					      and parity-reset lines for Profile booting    (CHG036)
;
;				 2/7/84	  - 1)Extend hard disk default read timeout to 16
;					      seconds for Widget systems. (CHG037)
;					    2)Add delay after hard disk reset for Widget
;					      systems. (CHG038)
;				 2/8/84	  - Release as rev G for testing
;
;				 2/24/84  - Release as official rev H
;
;-----------------------------------------------------------------------------------------------------
        .PAGE
;-----------------------------------------------------------------------------------------------------
;  Macro definitions
;-----------------------------------------------------------------------------------------------------

        .MACRO  BSR6
        LEA     @1,A6
        BRA     %1
@1
        .ENDM

        .MACRO  BSRS6
        LEA     @1,A6
        BRA.S   %1
@1
        .ENDM

        .MACRO  RTS6
        JMP     (A6)
        .ENDM

        .MACRO  BSR4
        LEA     @1,A4
        BRA     %1
@1
        .ENDM

        .MACRO  BSRS4
        LEA     @1,A4
        BRA.S   %1
@1
        .ENDM

        .MACRO  RTS4
        JMP     (A4)
        .ENDM

        .MACRO  BSR2
        LEA     @1,A2
        BRA     %1
@1
        .ENDM

        .MACRO  BSRS2
        LEA     @1,A2
        BRA.S   %1
@1
        .ENDM

        .MACRO  RTS2
        JMP     (A2)
        .ENDM

        .MACRO  DISABLE
        MOVE    SR,-(SP)
        ORI     #$0700,SR
        .ENDM

        .MACRO  ENABLE
        MOVE    (SP)+,SR
        .ENDM

        .PAGE
;--------------------------------------------------------------------------
;       Conditionals for assembly
;--------------------------------------------------------------------------

DIAGS	        .EQU    1	        ;controls assembly of selected diags
NEWLISA	        .EQU    1	        ;controls extra code for new LISA's
BURNIN	        .EQU    1	        ;controls code for burnin cycling
NORESET	        .EQU    1	        ;controls code for reset feature
EXTERNAL        .EQU    0	        ;controls listing of externally
                                        ; callable routines only (w/ EQU's)
ROM16K	        .EQU    1	        ;controls code to be added when 16K
                                        ; ROM's available
NEWTWIG	        .EQU    1	        ;controls code for new Twiggy firmware
                                        ; interface
FINLISA	        .EQU    0	        ;controls code for final LISA's
FINKBD	        .EQU    1	        ;controls check for final keyboard
AAPL	        .EQU    0	        ;controls Apple monitor code
USERINT	        .EQU    1	        ;controls code for new user interface
DEBUG	        .EQU    0	        ;controls global equate allocation
ROM4K	        .EQU    0	        ;controls code for 2716 version
ROM8K	        .EQU    0	        ;controls code for 2732 version
BMENU	        .EQU    1	        ;controls format of boot menu
                                        ;  1 = pull down menu
FULLSCC	        .EQU    1	        ;controls code for SCC tests
INVERTCK        .EQU    0	        ;controls code for inverse video check	        CHG013

        .IF     EXTERNAL = 1
        .LIST
;-----------------------------------------------------------------------------
;  This is a listing of LISA boot ROM routines which are externally callable
;  by other programs.  Calls are made via a jump table resident at a fixed
;  location in the ROM (see listing).  Also listed are equates used by these
;  routines.  If you have any questions/comments/suggestions, please call Rich
;  Castro, x2504.
;-----------------------------------------------------------------------------
        .ENDC
        .PAGE
;--------------------------------------------------------------------------
;       GENERAL EQUATES
;--------------------------------------------------------------------------
ROMBASE	        .EQU    $00FE0000       ;BASE ADDRESS FOR ROM
ROMSLCT	        .EQU    $00FE	        ;MSB'S OF ROM ADDRESS
IOSPACE	        .EQU    $00FC0000       ;START OF IO SPACE
VIDLTCH	        .EQU    $00FCE800       ;VIDEO ADDRESS LATCH
DEFVID	        .EQU    $2F	        ;default setting for video latch
                                        ; (end of 512K board in slot 1)
DEFVID2	        .EQU    $AF	        ;default video latch setting and LED on

        .IF  DEBUG = 0
SCRNBASE        .EQU    $110	        ;ptr to base address for video page
        .ELSE
SCRNBASE        .EQU    $160	        ;ptr to base address for video page
        .ENDC

        .IF  USERINT = 0
RBYTES	        .EQU    900	        ;BYTES FOR EACH DISPLAY ROW
        .ELSE
RBYTES	        .EQU    90	        ;BYTES FOR EACH DISPLAY ROW
        .ENDC
TOPOFFSET       .EQU    270	        ;offset for first row from top of screen
RLONGS	        .EQU    225	        ;longs for each row
R0	        .EQU    0	        ;ROW 0 OFFSET
R1	        .EQU    R0+90	        ;ROW 1 OFFSET, ETC.
R2	        .EQU    R1+90
R3	        .EQU    R2+90
R4	        .EQU    R3+90
R5	        .EQU    R4+90
R6	        .EQU    R5+90
R7	        .EQU    R6+90
BUSVCTR	        .EQU    $0008	        ;BUS EXCEPTION VECTOR
ADRVCTR	        .EQU    $000C	        ;ADDRESS EXCEPTION VECTOR
ILLVCTR	        .EQU    $0010	        ;ILLEGAL INSTRUCTION VECTOR
L10VCTR	        .EQU    $0028	        ;line 1010 trap
L11VCTR	        .EQU    $002C	        ;line 1111 trap
NMIVCT	        .EQU    $007C	        ;NMI VECTOR LOCATION
TRPVCT0	        .EQU    $0080	        ; TRAP 0 VECTOR LOCATION
MAXADR	        .EQU    $00200000       ; MAX RAM ADDRESS + 1 (2 meg)
ONEMEG	        .EQU    $00100000       ; 1 meg in hex
HALFMEG	        .EQU    $00080000       ; 1/2 meg
QTRMEG	        .EQU    $00040000       ; 256K
ROW2ADR	        .EQU    $00020000       ; 128K - START OF 2ND MEMORY ROW
STKBASE	        .EQU    $0480	        ; DEFAULT BASE FOR STACK
CALLBASE        .EQU    $0480	        ; STACK BASE FOR USE BY CALL ROUTINE
SETUP	        .EQU    $00FCE012       ; ADDRESS TO TURN SETUP BIT OFF
SETUPON	        .EQU    $00FCE010       ; ADDRESS TO TURN SETUP ON
PATRN	        .EQU    $AA55A55A       ; PATTERN FOR MEMORY TESTING
PATRN2	        .EQU    $A55A	        ; PATTERN FOR MMU TEST
PARON	        .EQU    $00FCE01E       ;PARITY ENABLE
PAROFF	        .EQU    $00FCE01C       ;PARITY DISABLE
MEALTCH	        .EQU    $00FCF000       ;MEMORY ERROR ADDRESS LATCH
STATREG	        .EQU    $00FCF801       ;ERROR STATUS REGISTER
SFER	        .EQU    0	        ; SOFT ERROR BIT
PBIT	        .EQU    1	        ; HARD ERROR (PARITY) BIT
VRBIT	        .EQU    2	        ; VR BIT LOCATION
VIDBIT	        .EQU    4	        ; VID BIT
CSBIT	        .EQU    5	        ; CSYNC BIT
INVIDBIT        .EQU    6	        ; INVERSE VIDEO BIT
RETRYCNT        .EQU    32	        ;RETRY COUNT FOR MEMORY SIZING
VTIRDIS	        .EQU    $00FCE018       ;VERTICAL RETRACE DISABLE
VTIRENB	        .EQU    $00FCE01A       ;VERTICAL RETRACE ENABLE
HEX512K	        .EQU    $80000	        ;512K in hex
HEX128K	        .EQU    $20000	        ;128K in hex
HEX96K	        .EQU    $18000	        ;96K in hex
HEX32K	        .EQU    $8000	        ;32K in hex
HEX8K	        .EQU    $2000	        ;8K in hex
HEX2K	        .EQU    $0800	        ;2K in hex
LOMEM	        .EQU    HEX2K	        ;amount of memory initially tested
DG2ON	        .EQU    $00FCE006       ;WRITE WRONG PARITY ENABLE
DG2OFF	        .EQU    $00FCE004       ;WRITE WRONG PARITY DISABLE
ONESEC	        .EQU    $3D090	        ;1 second delay constant
TWOSEC	        .EQU    ONESEC*2        ;2 second delay
FIVESEC	        .EQU    ONESEC*5        ;5 second delay
QTRSEC	        .EQU    ONESEC/4        ;0.25 second delay
TNTHSEC	        .EQU    ONESEC/10       ;0.1 second delay
KBDDLY	        .EQU    /10  ;1.7 second delay
HALFSEC	        .EQU    ONESEC/2        ;0.5 second delay

;  Equates for memory parity error routine

MSRCHSZ	        .EQU    64	        ;main memory error range	        CHG015
VSRCHSZ	        .EQU    32768	        ;video memory error range	        CHG015
VMSK	        .EQU    $FFFF8000       ;mask for video errors		        CHG015
ADRMSK	        .EQU    $03	        ;mask for error byte address	        CHG015
PHYTOLOG        .EQU    $80000	        ;physical to logical address offset     CHG015

        .IF     EXTERNAL = 1
        .NOLIST
        .ENDC

;  Equates for VIA registers (offsets from $XXD181 or $XXD101)

VIA1BASE        .EQU    $00FCDD81       ;BASE ADDRESS FOR COPS 6522
ORB1	        .EQU    $0	        ;PORT B OUTPUT REG
ORA1	        .EQU    $2	        ;PORT A OUTPUT REG
DDRB1	        .EQU    $4	        ;PORT B DATA DIRECTION REG
DDRA1	        .EQU    $6	        ;PORT A DATA DIRECTION REG
T1LL1	        .EQU    $C	        ;LOW ORDER T1 LATCH
T1LH1	        .EQU    $E	        ;HIGH ORDER T1 LATCH
T2CL1	        .EQU    $10	        ;LOW ORDER T2 COUNTER
T2CH1	        .EQU    $12	        ;HIGH ORDER T2 COUNTER
SHR1	        .EQU    $14	        ;SHIFT REG
ACR1	        .EQU    $16	        ;AUXILIARY CONTROL REG
PCR1	        .EQU    $18	        ;PERIPHERAL CONTROL REG
IFR1	        .EQU    $1A	        ;INTERRUPT FLAG REG
IER1	        .EQU    $1C	        ;INTRPT ENABLE REG
PORTA1	        .EQU    $1E	        ;PORT A WITH NO HANDSHAKE

FDIR	        .EQU    4	        ;PORT B, BIT 4 HAS FDIR STATE

VIA2BASE        .EQU    $00FCD901       ;BASE ADDRESS FOR OTHER 6522
ORB2	        .EQU    $0	        ;PORT B OUTPUT REG
IRB2	        .EQU    $0	        ;PORT B INPUT REG
ORA2	        .EQU    $8	        ;PORT A OUTPUT REG
IRA2	        .EQU    $8	        ;PORT A INPUT REG
DDRB2	        .EQU    $10	        ;PORT B DATA DIRECTION REG
DDRA2	        .EQU    $18	        ;PORT A DATA DIRECTION REG
T1LL2	        .EQU    $30	        ;LOW ORDER T1 LATCH
T1LH2	        .EQU    $38	        ;HIGH ORDER T1 LATCH
T2CL2	        .EQU    $40	        ;LOW ORDER T2 COUNTER
T2CH2	        .EQU    $48	        ;HIGH ORDER T2 COUNTER
PCR2	        .EQU    $60	        ;PERIPHERAL CONTROL REG
PORTA2	        .EQU    $78	        ;PORT A WITH NO HANDSHAKE

DSKDIAG	        .EQU    6	        ;port B, bit 6 is disk alive indicator

CSTRB	        .EQU    $00FCD01C       ;STROBE FOR CONTRAST LATCH

;  Equates for PIA registers (offsets from $XXA001) (SLOT 2)

PIABASE	        .EQU    $00FCA001       ;BASE ADDRESS FOR PIA CARD IN SLOT 2
INDATA	        .EQU    $0
OUTDATA	        .EQU    $2
INCSR	        .EQU    $4
OUTCSR	        .EQU    $6

;  Equates for SCC

SCCBCTL	        .EQU    $FCD241	        ;SCC channel B control
ACTL	        .EQU    2	        ;offset to SCC channel A control
SCCDATA	        .EQU    4	        ;offset to SCC data regs
RXBF	        .EQU    0	        ;receive buffer full bit
TXBE	        .EQU    2	        ;transmit buffer empty bit

        .PAGE
        .IF  USERINT = 0
;  The following equates are used as error indicators

CPUSEL	        .EQU    0	        ;CPU selection logic error
MMU	        .EQU    1	        ;MMU ERROR
VID	        .EQU    2	        ;CPU VIDEO LOGIC ERROR
PAR	        .EQU    3	        ;CPU PARITY LOGIC ERROR
CPUINTR	        .EQU    4	        ;UNEXPECTED INTERRUPT OCCURRED
BUSEXCP	        .EQU    5	        ;BUS ERROR
ADREXCP	        .EQU    6	        ;ADDRESS ERROR
MISEXCP	        .EQU    7	        ;MISC EXCEPTION
ILLEXCP	        .EQU    8	        ;ILLEGAL INSTRUCTION ERROR
TRPEXCP	        .EQU    9	        ;line 1111 or 1010 trap

VIA1	        .EQU    10	        ;COPS VIA ERROR
VIA2	        .EQU    11	        ;PARALLEL PORT VIA ERROR
IOCOPS	        .EQU    12	        ;IO BOARD COPS ERROR
KBDCOPS	        .EQU    13	        ;KEYBOARD COPS ERROR
CLK	        .EQU    14	        ;CLOCK ERROR
RS232A	        .EQU    15	        ;RS232 PORT A ERROR
RS232B	        .EQU    16	        ;RS232 PORT B ERROR
DISK	        .EQU    17	        ;DISK ERROR
IOEXCP	        .EQU    18	        ;UNEXPECTED IO EXCEPTION OCCURRED
IOCOPS2	        .EQU    19	        ;COPS reset code error

MEM	        .EQU    20	        ;MEMORY ERROR
MPAR	        .EQU    21	        ;memory parity error
IOKBD	        .EQU    23	        ;I/O or keyboard failure

KBDOUT	        .EQU    24	        ;KEYBOARD DISCONNECTED
MOUSOUT	        .EQU    25	        ;MOUSE DISCONNECTED
IO1ERR	        .EQU    26	        ;I/O slot 1 failure
IO2ERR	        .EQU    27	        ;I/O slot 2 failure
IO3ERR	        .EQU    28	        ;I/O slot 3 failure
ALTBOOT	        .EQU    29	        ;alternate boot key request
WRMSTRT	        .EQU    30	        ;warm-start indicator

LOOP	        .EQU    31	        ;loop on test

ERRMSK	        .EQU    $00FFFFFF       ;MASK FOR ERROR CHECKING
CPUMSK	        .EQU    $0000000F       ;MASK FOR CPU ERROR CHECKING
EXMSK	        .EQU    $000003F0       ;mask for exception error checking
MEMMSK	        .EQU    $00700000       ;mask for memory error checking
IOMSK	        .EQU    $008FDC00       ;MASK FOR I/O ERROR CHECKING
OTHRMSK	        .EQU    $03000000       ;mask for keyboard/mouse check
CONTMSK	        .EQU    $00CE3FFC       ;mask for CONTINUE option
        .ELSE
MMU	        .EQU    0	        ;MMU ERROR
CPUSEL	        .EQU    1	        ;CPU selection logic error
VID	        .EQU    2	        ;CPU VIDEO LOGIC ERROR
PAR	        .EQU    3	        ;CPU PARITY LOGIC ERROR
CPUINTR	        .EQU    4	        ;UNEXPECTED INTERRUPT OCCURRED
BUSEXCP	        .EQU    5	        ;BUS ERROR
ADREXCP	        .EQU    6	        ;ADDRESS ERROR
MISEXCP	        .EQU    7	        ;MISC EXCEPTION
ILLEXCP	        .EQU    8	        ;ILLEGAL INSTRUCTION ERROR
TRPEXCP	        .EQU    9	        ;line 1111 or 1010 trap

VIA1	        .EQU    10	        ;COPS VIA ERROR
VIA2	        .EQU    11	        ;PARALLEL PORT VIA ERROR
IOCOPS	        .EQU    12	        ;IO BOARD COPS ERROR
KBDCOPS	        .EQU    13	        ;KEYBOARD COPS ERROR
CLK	        .EQU    14	        ;CLOCK ERROR
RS232A	        .EQU    15	        ;RS232 PORT A ERROR
RS232B	        .EQU    16	        ;RS232 PORT B ERROR
DISK	        .EQU    17	        ;DISK ERROR
IOEXCP	        .EQU    18	        ;UNEXPECTED IO EXCEPTION OCCURRED
IOCOPS2	        .EQU    19	        ;COPS reset code error
IOKBD	        .EQU    20	        ;I/O or keyboard failure

MEM	        .EQU    21	        ;MEMORY ERROR
MPAR	        .EQU    22	        ;memory parity error

KBDOUT	        .EQU    23	        ;KEYBOARD DISCONNECTED
MOUSOUT	        .EQU    24	        ;MOUSE DISCONNECTED
IO1ERR	        .EQU    25	        ;I/O slot 1 failure
IO2ERR	        .EQU    26	        ;I/O slot 2 failure
IO3ERR	        .EQU    27	        ;I/O slot 3 failure

ALTBOOT	        .EQU    28	        ;alternate boot key request
BTMENU	        .EQU    29	        ;boot menu request
WRMSTRT	        .EQU    30	        ;warm-start indicator

LOOP	        .EQU    31	        ;loop on test

ERRMSK	        .EQU    $0E7FFFFF       ;MASK FOR ERROR CHECKING
CPUMSK	        .EQU    $0000000F       ;MASK FOR CPU ERROR CHECKING
EXMSK	        .EQU    $000003F0       ;mask for exception error checking
IOMSK	        .EQU    $001FDC00       ;MASK FOR I/O ERROR CHECKING
MEMMSK	        .EQU    $00600000       ;mask for memory error checking
OTHRMSK	        .EQU    $01800000       ;mask for keyboard/mouse check
IOSMSK	        .EQU    $0E000000       ;mask for I/O slot error checking
CONTMSK	        .EQU    $001E3FFA       ;mask for CONTINUE option - allow continue
                                        ; for MMU,VIDEO,CLK,RS232,MEM,MPAR,KBDOUT,
                                        ; MOUSOUT,and IO slot errors
SCANMSK	        .EQU    $00183000       ;mask for results of initial keyboard scan
ALTBMSK	        .EQU    $70000000       ;mask for D7 when CONTINUE option invoked
BOOTMSK	        .EQU    $008FFFFF       ;mask for errors that continue to boot attempt
CPIOMSK	        .EQU    $001FFFFF       ;mask for checking for CPU and IO errors
        .ENDC

;  Equates for error codes displayed to user

        .IF  NEWTWIG = 0
ECPUSEL	        .EQU    0	        ;CPU selection logic error
EMMU	        .EQU    1	        ;MMU ERROR
EVID	        .EQU    2	        ;CPU VIDEO LOGIC ERROR
ECPAR	        .EQU    3	        ;CPU PARITY LOGIC ERROR
ECPUINTR        .EQU    4	        ;UNEXPECTED INTERRUPT OCCURRED
EBUSEXCP        .EQU    5	        ;BUS ERROR
EADREXCP        .EQU    6	        ;ADDRESS ERROR
EMISEXCP        .EQU    7	        ;MISC EXCEPTION
EILLEXCP        .EQU    8	        ;ILLEGAL INSTRUCTION ERROR
ETRPEXCP        .EQU    9	        ;line 1111 or 1010 trap

EVIA1	        .EQU    $10	        ;COPS VIA ERROR
EVIA2	        .EQU    $11	        ;PARALLEL PORT VIA ERROR
EIOCOP	        .EQU    $12	        ;IO BOARD COPS ERROR
EKBDCOP	        .EQU    $13	        ;KEYBOARD COPS ERROR
ECLK	        .EQU    $14	        ;CLOCK ERROR
ERS232A	        .EQU    $15	        ;RS232 PORT A ERROR
ERS232B	        .EQU    $16	        ;RS232 PORT B ERROR
EDISK	        .EQU    $17	        ;DISK ERROR
EIOEXCP	        .EQU    $18	        ;UNEXPECTED IO EXCEPTION OCCURRED
EIOCOP2	        .EQU    $19	        ;IO board COPS code error

EMEM	        .EQU    $20	        ;R/W MEMORY ERROR
EPAR	        .EQU    $21	        ;PARITY ERROR
EIOKBD	        .EQU    $23	        ;I/O or keyboard error

;  Special COPS error codes for burnin cycling

SERR1	        .EQU    $32	        ;error setting initial time
SERR2	        .EQU    $33	        ;error setting alarm

        .ELSE
EMMU	        .EQU    40	        ;MMU ERROR
ECPUSEL	        .EQU    41	        ;CPU selection logic error
EVID	        .EQU    42	        ;CPU VIDEO LOGIC ERROR
ECPAR	        .EQU    43	        ;CPU PARITY LOGIC ERROR
ECPUINTR        .EQU    44	        ;UNEXPECTED INTERRUPT OCCURRED
EBUSEXCP        .EQU    45	        ;BUS ERROR
EADREXCP        .EQU    46	        ;ADDRESS ERROR
EMISEXCP        .EQU    47	        ;MISC EXCEPTION
EILLEXCP        .EQU    48	        ;ILLEGAL INSTRUCTION ERROR
ETRPEXCP        .EQU    49	        ;line 1111 or 1010 trap

EVIA1	        .EQU    50	        ;COPS VIA ERROR
EVIA2	        .EQU    51	        ;PARALLEL PORT VIA ERROR
EIOCOP	        .EQU    52	        ;IO BOARD COPS ERROR
EKBDCOP	        .EQU    53	        ;KEYBOARD COPS ERROR
ECLK	        .EQU    54	        ;CLOCK ERROR
ERS232A	        .EQU    55	        ;RS232 PORT A ERROR
ERS232B	        .EQU    56	        ;RS232 PORT B ERROR
EDISK	        .EQU    57	        ;DISK ERROR
EIOEXCP	        .EQU    58	        ;UNEXPECTED IO EXCEPTION OCCURRED
EIOCOP2	        .EQU    59	        ;IO board COPS code error
EIOKBD	        .EQU    60	        ;I/O or keyboard error

EMEM	        .EQU    70	        ;R/W MEMORY ERROR
EPAR	        .EQU    71	        ;PARITY ERROR

EBOOT	        .EQU    75	        ;general boot failure error code

;  Special COPS error codes for burnin cycling

SERR1	        .EQU    61	        ;error setting initial time
SERR2	        .EQU    62	        ;error setting alarm

        .ENDC

;  Secondary status flag (STATFLGS) equates

NORSTRT	        .EQU    0	        ;governs display of restart button
NOCONT	        .EQU    1	        ;error disallows Monitor CONTINUE option
MSBUTN	        .EQU    2	        ;mouse button detected
CMDFLG	        .EQU    3	        ;cmd button up/down
MOUSE	        .EQU    4	        ;mouse button up/down
CHKCMD	        .EQU    5	        ;if =1 user input from keyboard must
                                        ; be prefaced by CMD key
BTN	        .EQU    6	        ;flag for button use
MENU	        .EQU    7	        ;flag for menu use

;  MMU equates

MMUSADRL        .EQU    $00008000       ;STARTING MMU LIMIT ADDRESS
MMUSADRB        .EQU    $00008008       ;STARTING MMU BASE ADDRESS
MMUEADRL        .EQU    $00FE8000       ;ENDING MMU LIMIT ADDRESS
MMUEADRB        .EQU    $00FE8008       ;ENDING MMU BASE ADDRESS
ADR128K	        .EQU    $00020000       ;128K IN HEX - INCR FOR MMU REGS PTRS
PAG128K	        .EQU    $00000100       ;128K PAGE INCREMENT FOR ORG REGS
MEMLMT	        .EQU    $0700	        ;LIMIT VALUE FOR MEMORY SEGMENTS
NMEMLMT	        .EQU    $08FF	        ;INVERSE OF VALUE (HIGH NIBBLE IGNORED)

        .IF  ROM4K = 0
IOLMT	        .EQU    $0900	        ;LIMIT VALUE FOR I/O SEGMENT
NIOLMT	        .EQU    $06FF	        ;INVERSE
IOLMT2	        .EQU    $0901	        ;limit value for no reset feature
RSTLMT	        .EQU    $0FFE	        ;inverse mask for no reset feature
        .ELSE
IOLMT	        .EQU    $0800	        ;LIMIT VALUE FOR I/O SEGMENT
NIOLMT	        .EQU    $07FF	        ;INVERSE
        .ENDC
SPLMT	        .EQU    $0F00	        ;LIMIT VALUE FOR SPECIAL I/O SPACE
NSPLMT	        .EQU    $00FF	        ;INVERSE
INVPAG	        .EQU    $0C00	        ;INVALID PAGE LIMIT
MMU0B	        .EQU    $00008008       ;ADRESS OF ORG REG 0 (FOR LOW MEMORY)
MMU0L	        .EQU    $00008000       ;ADDRESS OF LIMIT REG 0
MMU126B	        .EQU    $00FC8008       ;ADDRESS OF ORG REG 126 (FOR I/O SPACE)
MMU126L	        .EQU    $00FC8000       ;ADDRESS OF LIMIT REG 126
MMU127B	        .EQU    $00FE8008       ;ADDRESS OF BASE REG 127 (FOR ROM SPACE)
MMU127L	        .EQU    $00FE8000       ;ADDRESS OF LIMIT REG 127
SEG1ON	        .EQU    $00FCE00A       ;CONTEXT SELECTION BIT 1 ENABLE
SEG1OFF	        .EQU    $00FCE008       ;CONTEXT SELECTION BIT 1 DISABLE
SEG2ON	        .EQU    $00FCE00E       ;CONTEXT SELECTION BIT 2 ENABLE
SEG2OFF	        .EQU    $00FCE00C       ;CONTEXT SELECTION BIT 2 DISABLE

; Equates for serial number read routine

Dlycnst	        .equ    9	        ;constant for delay loop
TKiller	        .equ    172	        ;time killer constant
BytesPerRead    .equ    7	        ;bytes per read
WordsPerRead    .equ    BytesPerRead*2  ;during reading one byte fits into one word
HalfSize        .equ    WordsPerRead*8  ;half the size of ScrachSize
ScrachSize      .equ    HalfSize*2      ;size of the scrach array
                                        ;I/O segment 126
Snum	        .equ    $0fe8000        ;location of SN1 & SN2
                                        ;special I/O segment 127
dLcnt	        .equ    -4	        ;displacement for local variable LOOP COUNTER
dSavArry        .equ    dLcnt-4	        ;disp. for Save Array pointer
dScrach	        .equ    dSavArry-ScrachSize
                                        ;disp. for pointer to local array SCRACH
dStack	        .equ    dScrach	        ;disp. for the Link

; Equates for COPS and keyboard scan

MOUSDWN	        .EQU    $86	        ;MOUSE BUTTON PRESSED
CMDKEY	        .EQU    $FF	        ;LEFT COMMAND KEY
ALPHKEY	        .EQU    $FD	        ;ALPHA LOCK KEY "DOWN"

        .IF NEWTWIG = 0
AKEY	        .EQU    $F0	        ;'A' key - for boot from Apple ][
MKEY	        .EQU    $D8	        ;'M' key - for abort to monitor
FKEY	        .EQU    $E9	        ;'F' key - for Twiggy #1 boot
GKEY	        .EQU    $EA	        ;'G' key - for Twiggy #2 boot
HKEY	        .EQU    $EB	        ;'H' key - for Hard disk boot
PKEY	        .EQU    $C4	        ;'P' key - for Power-cycling
KEY1	        .EQU    $F4	        ;'1' key - for I/O slot #1
KEY2	        .EQU    $F1	        ;'2' key - for I/O slot #2
KEY3	        .EQU    $F2	        ;'3' key - for I/O slot #3
        .ELSE
KEY1	        .EQU    $F4	        ;'1' key - for Twiggy #1 boot
KEY2	        .EQU    $F1	        ;'2' key - for Twiggy #2 boot
KEY3	        .EQU    $F2	        ;'3' key - for Profile boot
AKEY	        .EQU    $F0	        ;'A' key - for I/O slot #3, port 1
BKEY	        .EQU    $EE	        ;'B' key - for I/O slot #3, port 2
CKEY	        .EQU    $ED	        ;'C' key - for I/O slot #3, port 3
;DKEY		 .EQU	 $FB		 ;'D' key - for I/O slot #1, port 4
;EKEY		 .EQU	 $E0		 ;'E' key - for I/O slot #2, port 4
;FKEY		 .EQU	 $E9		 ;'F' key - for I/O slot #3, port 4
ENTRKEY	        .EQU    $AF	        ;Right ENTER key - for Monitor invoking
SHFTKEY	        .EQU    $FE	        ;Shift key - used for power-cycling
PKEY	        .EQU    $C4	        ;'P' key - for Power-cycling
        .ENDC

RSTCODE	        .EQU    $80	        ;reset code
KUNPLG	        .EQU    $FD	        ;keyboard unplugged
ICERR	        .EQU    $FE	        ;I/O board COPS RAM error
KCERR	        .EQU    $FF	        ;keyboard COPS RAM error
MSUNPLG	        .EQU    $07	        ;mouse unplugged
MSPLG	        .EQU    $87	        ;mouse plugged in

        .IF     EXTERNAL = 1
        .LIST
        .PAGE
        .ENDC

; Equates for Boot device id's

        .IF     NEWTWIG = 0
TWIG1	        .EQU    FKEY		  ;TWIGGY DRIVE #1
TWIG2	        .EQU    GKEY		  ;TWIGGY DRIVE #2
PROFILE	        .EQU    HKEY		  ;PROFILE HARD DISK
IO1PORT1        .EQU    KEY1		  ;I/O SLOT 1, port 1
IO2PORT1        .EQU    KEY2		  ;I/O SLOT 2, port 1
IO3PORT1        .EQU    KEY3		  ;I/O SLOT 3, port 1
PC	        .EQU    PKEY		  ;power-cycle id
MON	        .EQU    MKEY		  ;abort boot, go to monitor id
APPLE	        .EQU    AKEY		  ;abort boot, go to Apple id
        .ELSE
TWIG1	        .EQU    $0	        ;TWIGGY DRIVE #1
TWIG2	        .EQU    $1	        ;TWIGGY DRIVE #2
PROFILE	        .EQU    $2	        ;PROFILE HARD DISK
IO1PORT1        .EQU    $3	        ;I/O SLOT 1, port 1
IO1PORT2        .EQU    $4	        ;I/O SLOT 1, port 2
IO2PORT1        .EQU    $6	        ;I/O SLOT 2, port 1
IO2PORT2        .EQU    $7	        ;I/O SLOT 2, port 2
IO3PORT1        .EQU    $9	        ;I/O SLOT 3, port 1
IO3PORT2        .EQU    $A	        ;I/O SLOT 3, port 2
PC	        .EQU    $F	        ;power cycle mode
MON	        .EQU    $10	        ;abort boot, go to monitor id

        .ENDC

        .IF USERINT = 0
PC	        .EQU    $C	        ;power-cycle id
APPLE	        .EQU    $E	        ;abort boot, go to Apple id
        .ENDC

; Equates for device code display (ASCII codes)

        .IF  NEWTWIG = 0
IOS1	        .EQU    $31	        ;I/O slot 1
IOS2	        .EQU    $32	        ;I/O slot 2
IOS3	        .EQU    $33	        ;I/O slot 3
TWG1	        .EQU    $46	        ;Twiggy drive #1
TWG2	        .EQU    $47	        ;Twiggy drive #2
PRO	        .EQU    $48	        ;Profile
        .ELSE
TWG1	        .EQU    $31	        ;Twiggy drive #1
TWG2	        .EQU    $32	        ;Twiggy drive #2
PRO	        .EQU    $33	        ;Profile
IOS1	        .EQU    $34	        ;I/O slot 1
IOS2	        .EQU    $37	        ;I/O slot 2
IOS3	        .EQU    $41	        ;I/O slot 3
        .ENDC

;----------------------------------------------------------------------------------
; Equates for Disk controller shared memory/Twiggy boot
;----------------------------------------------------------------------------------

TWIGGY	        .EQU    1	        ;controls Twiggy code assembly (1 = YES)
DISKMEM	        .EQU    $00FCC001       ;base address of shared memory
CMD	        .EQU    2	        ;offset for command byte
DRV	        .EQU    CMD+2	        ;offset for drive #
SIDE	        .EQU    DRV+2	        ;side #
SCTR	        .EQU    SIDE+2	        ;sector #
TRAK	        .EQU    SCTR+2	        ;track #

        .IF  NEWTWIG = 0
STAT	        .EQU    TRAK+2	        ;ERROR STATUS
CHKCNT	        .EQU    STAT+2	        ;CHECKSUM ERROR COUNT
HDR	        .EQU    CHKCNT+2        ;HEADER BYTES
ROMV	        .EQU    $30	        ;ROM VERSION #
INTSTAT	        .EQU    $74	        ;INTERRUPT STATUS
DSKSTAT	        .EQU    $7A	        ;DISK STATUS
DISKROM	        .EQU    $00FCC031       ;absolute address for disk ROM #
HDRSTRT	        .EQU    $FCC4BB	        ;ADDRESS OF HEADER BUFFER
DSKBFR	        .EQU    $FCC601	        ;DISK BUFFER ADDRESS

SEEK	        .EQU    0	        ;FOLLOWING ARE COMMAND BYTES
READS	        .EQU    1	        ;READ SECTOR
CLAMP	        .EQU    3	        ;CLAMP DISKETTE
STATS	        .EQU    4	        ;STATUS REQUEST CMD
UNCLAMP	        .EQU    5	        ;UNCLAMP DISKETTE
FORMAT	        .EQU    6	        ;format disk
VERIFY	        .EQU    7	        ;verify disk
        .ENDC
        .IF  NEWTWIG = 1
SPEED	        .EQU    TRAK+2	        ;motor speed control
CNFRM	        .EQU    SPEED+2	        ;confirm for format cmd
STAT	        .EQU    CNFRM+2	        ;error status
INTLV	        .EQU    STAT+2	        ;interleave factor		        CHG022
TYPE	        .EQU    INTLV+2	        ;drive type id			        CHG009
STST	        .EQU    TYPE+2	        ;self-test result		        CHG022
ROMV	        .EQU    $30	        ;ROM version #
RTRYCNT	        .EQU    $58	        ;retry count
INTSTAT	        .EQU    $5E	        ;interrupt status
CHKCNT	        .EQU    $BA	        ;data checksum error count
CHKCNT2	        .EQU    $C4	        ;address checksum error count
DSKBUFF	        .EQU    $3E8	        ;start of disk buffer
DSKDATA	        .EQU    DSKBUFF+24      ;first 12 bytes are header
DISKROM	        .EQU    $FCC031	        ;absoulte address for disk ROM id
SLOTMR	        .EQU    5	        ;id bit for slow timers		        CHG029
FASTMR	        .EQU    6	        ;id bit for fast timers		        CHG029

READS	        .EQU    0	        ;read sector w/checksum
WRT	        .EQU    1
UNCLAMP	        .EQU    2	        ;unclamp diskette
FMT	        .EQU    3
VFY	        .EQU    4	        ;verify disk
CLAMP	        .EQU    9	        ;clamp disk
OK	        .EQU    $FF	        ;confirmation for format

SEEK	        .EQU    $83	        ;seek cmd
        .ENDC

EXRW	        .EQU    $81	        ;execute cmd
CLRSTAT	        .EQU    $85	        ;clear status cmd
ENBLINT	        .EQU    $86	        ;enable intrpt
DSABLINT        .EQU    $87	        ;disable intrpt
SLEEP	        .EQU    $88	        ;loop in RAM cmd
DIE	        .EQU    $89	        ;loop in ROM cmd

DRV1	        .EQU    0	        ;drive #1 ID
DRV2	        .EQU    $80	        ;drive #2 ID
TRK1	        .EQU    1	        ;track 1
TOPSIDE	        .EQU    0	        ;top side of disk
BOTSIDE	        .EQU    1	        ;bottom side of disk

        .IF NEWTWIG = 0
HDRLEN	        .EQU    12	        ;LENGTH OF HEADER ON TWIGGY
SECLEN	        .EQU    256	        ;LENGTH OF 1 SECTOR
TWGHDR	        .EQU    $1FFE8	        ;ADDRESS TO LOAD BOOT HEADER
TWGDATA	        .EQU    $20000	        ;ADDRESS TO LOAD BOOT DATA
        .ENDC
        .IF NEWTWIG = 1
HDRLEN	        .EQU    12	        ;length of Twiggy header
SECLEN	        .EQU    512	        ;length of one sector
TWGHDR	        .EQU    $1FFF4	        ;address to load boot header
TWGDATA	        .EQU    $20000	        ;address to load boot data
LASTBLK	        .EQU    1702	        ;last block #
DSKSIZE	        .EQU    1702	        ;total amount of blocks
        .ENDC

;  Equates for parameter memory used by boot ROM

STATSTRT        .EQU    $FCC161	        ;start of special parameter memory area for boot ROM
STATSAV	        .EQU    STATSTRT        ;save of error code
STATSUM	        .EQU    $FCC17D	        ;checksum word for special area
STATWRDS        .EQU    8	        ;length in words (16 bytes)

PMSTRT	        .EQU    $FCC181	        ;start of system paramter memory
DVCCODE	        .EQU    $FCC189	        ;boot device code
MEMCODE	        .EQU    $FCC18D	        ;mouse/memory test indicator byte
MOUSEON	        .EQU    7	        ;bit for mouse attached (1=yes)
EXMEM	        .EQU    6	        ;bit for extended memory test (1=yes)
PMCHKSM	        .EQU    $FCC1FD	        ;checksum word
PMWRDS	        .EQU    32	        ;length in words (64 bytes)

;  Equates for disk errors

        .IF  NEWTWIG = 0
TIMOUT	        .EQU    $10	        ;TIMEOUT ERROR
WRPERR	        .EQU    $20	        ;WRITE PROTECT ERROR
DRVERR	        .EQU    $40	        ;DRIVE ERROR (NO DISK IN PLACE)
FMTERR	        .EQU    $60	        ;FORMAT ERROR
RDWRERR	        .EQU    $80	        ;READ/WRITE ERROR

CMDTIME	        .EQU    $100000	        ;TIMEOUT FOR TAKING COMMAND (7 secs)
FDIRTIME        .EQU    $C00000	        ;TIMEOUT FOR SETTING FDIR (2 mins)
        .ENDC
        .IF  NEWTWIG = 1	        ;new firmware, new error codes
DRVERR	        .EQU    07	        ;no disk in drive
NODISK	        .EQU    DRVERR	        ;another name for it
WRPERR	        .EQU    20	        ;write protect error
CLMPERR	        .EQU    22	        ;clamp error
RDWRERR	        .EQU    23	        ;read error
UCLMPERR        .EQU    25	        ;unclamp error
BADTHDR	        .EQU    38	        ;bad header (not a boot file id)
TIMOUT	        .EQU    39	        ;timeout error

CMDTIME	        .EQU    $120000	        ;timeout for taking command (15 secs)
FDIRTIME        .EQU    $C00000	        ;timeout for setting FDIR (2 mins)
VFYTIME	        .EQU        ;timeout for verify disk operation (4 mins)
EJCTTIME        .EQU    $180000	        ;timeout for ejecting disk (15 secs)
DSKTMOUT        .EQU    $1C8000	        ;timeout for initial speed check (15 secs)
INSRTTIM        .EQU    FDIRTIME        ;timeout for disk to be inserted (2 mins)
FMTTIME	        .EQU    VFYTIME	        ;timeout for format operation
        .ENDC

;  Equates for disk interrupt status

DSK1IN	        .EQU    0	        ;drive #1 disk in place
BUTN1	        .EQU    1	        ;drive #1 button pushed
RWF1	        .EQU    2	        ;read/write/format done on drive #1
DSK2IN	        .EQU    4	        ;drive #2 disk in place
BUTN2	        .EQU    5	        ;drive #2 button pushed
RWF2	        .EQU    6	        ;read/write/format done on drive #2

;  Equates for disk status command response

DSKIN	        .EQU    2	        ;disk inserted
BUTN	        .EQU    3	        ;button pressed

DRVTYPE	        .EQU    $FCC015	        ;drive type id (0 = Twiggy,		        CHG009
                                        ; 1 = single SONY, 2 = double SONY)	        CHG009

        .PAGE
;----------------------------------------------------------------------------
;  Equates for use with Profile boot
;----------------------------------------------------------------------------

PROFLE	        .EQU    1	        ;controls assembly of Profile code
OCD	        .EQU    0	        ;OPEN CABLE DETECT INPUT
BSY	        .EQU    1	        ;BUSY LINE INPUT
CMDBUFR	        .EQU    $304	        ;BUFFER FOR COMMAND BYTES
STATBFR	        .EQU    $1B4	        ;STATUS BYTE BUFFER (uses BOOTDATA area)
STAT1	        .EQU    $1B4	        ;STATUS BYTE 1
STAT2	        .EQU    $1B5	        ;STATUS BYTE 2
STAT3	        .EQU    $1B6	        ;STATUS BYTE 3
STAT4	        .EQU    $1B6	        ;STATUS BYTE 4
STATMSK	        .EQU    $C140C000       ;MASK FOR DON'T CARE STATUS BITS	        CHG016
PCMDSZ	        .EQU    5	        ;BYTES FOR READ CMD - 1
PCMD	        .EQU    0	        ; COMMAND CODE
BLKH	        .EQU    1	        ; HIGH BLOCK ADDRESS
BLKM	        .EQU    2	        ; MID BLOCK ADDRESS
BLKL	        .EQU    3	        ; LOW BLOCK ADDRESS
RETRY	        .EQU    4	        ; RETRY COUNT
THRESH	        .EQU    5	        ; THRESHOLD COUNT
HDRBUFR	        .EQU    $1FFEC	        ;BUFFER FOR HEADER
FILEID	        .EQU    4	        ; OFFSET TO FILEID
BOOTPAT	        .EQU    $AAAA	        ;FILEID FOR BOOT PATTERN
DATABFR	        .EQU    $20000	        ;BUFFER FOR DATA
HDRSIZE	        .EQU    20	        ;HEADER LENGTH
BLKSIZE	        .EQU    512	        ;BLOCK SIZE
STRTIME	        .EQU    $1200000        ;STARTUP TIMEOUT after power-up = about 3 minutes
RSTRTIME        .EQU    $900000	        ;STARTUP TIMEOUT after reset = ABOUT 100 SECS
RDTIME	        .EQU    $180000	        ;READ TIMEOUT = ABOUT 16 SECS		        CHG037
BSYTIME	        .EQU    $0500	        ;Wait for busy high = about 10 ms
RSPTIME	        .EQU    $FFFF	        ;RESPONSE TIMEOUT = ABOUT 500 ms
RCNT	        .EQU    10	        ;BOOT RETRY COUNT
TCNT	        .EQU    3	        ;THRESHOLD COUNT FOR 30% SPARING

;  Equates for Profile boot error conditions

        .IF  NEWTWIG = 0
TMOUT	        .EQU    $10	        ;TIMEOUT ERROR
NODSK	        .EQU    $11	        ;NO DISK ATTACHED
DSKBSY	        .EQU    $12	        ;DISK NOT READY
BADRSP	        .EQU    $14	        ;UNEXPECTED RESPONSE
STATNZ	        .EQU    $15	        ;NONZERO STATUS BYTE
BADHDR	        .EQU    $16	        ;INCORRECT HEADER
        .ELSE
NODSK	        .EQU    80	        ;DISK NOT ATTACHED
DSKBSY	        .EQU    81	        ;DISK NOT READY
BADRSP	        .EQU    82	        ;UNEXPECTED RESPONSE
STATNZ	        .EQU    83	        ;NONZERO STATUS BYTE
BADHDR	        .EQU    84	        ;INCORRECT HEADER
TMOUT	        .EQU    85	        ;TIMEOUT ERROR
        .ENDC

        .PAGE
;----------------------------------------------------------------------------
;  Equates for I/O slot booting
;----------------------------------------------------------------------------

SLOT1L	        .EQU    $FC0001	        ;I/O slot 1 SL address
SLOT2L	        .EQU    $FC4001	        ;I/O slot 2 SL address
SLOT3L	        .EQU    $FC8001	        ;I/O slot 3 SL address
STBIT	        .EQU    14	        ;status bit in id
ICBIT	        .EQU    13	        ;icon bit in id
TSTBIT	        .EQU    12	        ;test card bit in id
STENTRY	        .EQU    $20000	        ;entry point for status routine
BTENTRY	        .EQU    $20002	        ;boot routine entry point
ICONPTR	        .EQU    $20004	        ;pointer to icons, if any
APPLENET        .EQU    $8001	        ;id for Applenet card
APPLQUAL        .EQU    $9FFF	        ;qualifier for Applenet search
TSTCRD	        .EQU    $1000	        ;id for test card
TSTQUAL	        .EQU    $1800	        ;qualifier for test card search

;  Error codes for I/O slot booting

        .IF NEWTWIG = 0
NOC	        .EQU    $30	        ;no card installed
INV	        .EQU    $31	        ;not bootable card
BADSM	        .EQU    $32	        ;invalid checksum
BADST	        .EQU    $33	        ;bad status returned
        .ELSE
NOC	        .EQU    90	        ;no card installed
INV	        .EQU    91	        ;not bootable card
BADSM	        .EQU    92	        ;invalid checksum
BADST	        .EQU    93	        ;bad status returned
        .ENDC


        .PAGE
        .IF     BURNIN = 1
;----------------------------------------------------------------------------
;  Special equates for burnin cylcing code
;----------------------------------------------------------------------------

INITFLG	        .EQU    $FCC191	        ;first pass flag (01 = no)
HOURSAV	        .EQU    $FCC193	        ;save of last hour value from clock
LCNTHI	        .EQU    $FCC195	        ;loop count
LCNTLO	        .EQU    $FCC197
TIMFLG	        .EQU    $FCC199	        ;flag to indicate hour save needed
MINSAV	        .EQU    $FCC19B	        ;save of minute value for Twiggy test
DSKCNTH	        .EQU    $FCC19D	        ;disk read error count - high byte
DSKCNTL	        .EQU    $FCC19F	        ;disk read error count - low byte
CLKSAVE	        .EQU    $FCC1A1	        ;saved clock value
ALRMSAV	        .EQU    $FCC1B1	        ;saved alarm value last set
CYCLCNT	        .EQU    $FCC1C1	        ;count of minutes for power cycling
CYCLVAL	        .EQU    $FCC1C3	        ;# of mins between power cycles
MINCNT	        .EQU    $FCC1C5	        ;count of minutes for debug mode
ENDPM	        .EQU    $FCC1FF	        ;end of parameter memory
SET1	        .EQU    $0	        ;initial alarm/year/dd setting
SET2	        .EQU    $10000000       ;d/hh/mm/ss/t setting
HOUR	        .EQU    $1BC	        ;location of latest hour value read
MINUTE	        .EQU    $1BD	        ;location of latest minute value read
ONEHOUR	        .EQU    $00E0F000       ;one hour setting for alarm
ONEMIN	        .EQU    $0003C000       ;one minute setting for alarm
TENSECS	        .EQU    $00009000       ;ten seconds
DLYTIME	        .EQU    $100000	        ;delay for screen display

        .ENDC

        .PAGE
;----------------------------------------------------------------------------
;  Equates for Monitor code and screen handling
;----------------------------------------------------------------------------

;  Ascii code equates

QUESTN	        .EQU    $3F	        ; ?
RET	        .EQU    $0D	        ; CR
BS	        .EQU    $08	        ; backspace

;  Keyboard code equates

KEY4	        .EQU    $F3	        ;'4'
KEY5	        .EQU    $E4	        ;'5'
KEY6	        .EQU    $E1	        ;'6'
KEY7	        .EQU    $E2	        ;'7'
KEY8	        .EQU    $E3	        ;'8'
KEY9	        .EQU    $D0	        ;'9'
SKEY	        .EQU    $F6	        ;'S'
CmdDwn	        .EQU    CMDKEY	        ;Command key down
CmdUp	        .EQU    $7F	        ;Command key up
MousUp	        .EQU    $06	        ;Mouse button up

;  Low memory usage

KBDBFR	        .EQU    $2C0	        ;keyboard buffer start
KBDEND	        .EQU    $300	        ; and end (64 chars max)

        .IF  USERINT = 0
CRTROW	        .EQU    $300	        ;display row ptr
CRTCOL	        .EQU    $301	        ;display col ptr
        .ELSE
CRTROW	        .EQU    $300	        ;display row ptr
CRTCOL	        .EQU    $302	        ;display col ptr
        .ENDC

MAXTEST	        .EQU    12	        ;max test # for LOOP option

        .IF  USERINT = 0
FIRSTROW        .EQU    3	        ;first row for display of msgs
FIRSTCOL        .EQU    1	        ;first column
LASTROW	        .EQU    32	        ;last row for display
LASTCOL	        .EQU    88	        ;last column

        .ELSE
;  Equates for new user interface code

ROWBYTES        .EQU    90	        ;width of screen in bytes
MaxX	        .EQU    720	        ;width in pixels
MaxY	        .EQU    364	        ;length in pixels
MENULINE        .EQU    1440	        ;bottom line loc for menu
DESKLINE        .EQU    1530	        ;top line loc for desktop
DESKLMT	        .EQU    32760	        ;bottom line loc for desktop
DESKPATRN       .EQU    $AAAA5555       ;pattern for "grey" desktop

WROW	        .EQU    20		        ;window row
WCOL	        .EQU    2		        ;starting window col
WINDWIDTH       .EQU    86		        ;width of window in bytes
WINDHIGH        .EQU    320		        ;heigth of window in pixel lines
WMIDROW	        .EQU    +WROW       ;middle row in window
WMIDCOL	        .EQU    +WCOL      ;middle col in window
W14COL	        .EQU    +WCOL      ;col 1/4 across window
W34COL	        .EQU    *3+WCOL    ;col 3/4 across window
WINDSTRT        .EQU    +WCOL    ;start of window

ALBOXROW        .EQU    49			     ;starting row for alert box
ALBOXCOL        .EQU    6			     ;starting col for alert box
ALRTWIDTH       .EQU    78			     ;width of alert box
ALRTHIGH        .EQU    164			     ;heigth of alert box
ALRTSTRT        .EQU    +ALBOXCOL ;upper left corner of alert box
MIDALROW        .EQU    ALBOXROW+	     ;middle row of alert box
MIDALCOL        .EQU    ALBOXCOL+	     ;middle col of alert box

BTNWIDTH        .EQU    10		        ;width of button
BTNHIGH	        .EQU    28		        ;heigth of button
BTNSPC	        .EQU    48*ROWBYTES	        ;space between upper left corner of buttons
BTNMSPC	        .EQU    <10*ROWBYTES>+BTNWIDTH+4 ;position of button label relative to button
BTNROW	        .EQU    ALBOXROW+20	        ;starting display row for buttons
BTNCOL	        .EQU    52		        ;starting display col for buttons
BTN1STRT        .EQU    +BTNCOL ;location of first button
BTN2STRT        .EQU    BTN1STRT+BTNSPC	        ;location of second button
BTN3STRT        .EQU    BTN2STRT+BTNSPC	        ;location of third button
BTN1MSG	        .EQU    BTN1STRT+BTNMSPC        ;location of button descriptions
BTN2MSG	        .EQU    BTN2STRT+BTNMSPC
BTN3MSG	        .EQU    BTN3STRT+BTNMSPC

MENUSTRT        .EQU    MENULINE+2      ;start of pull down menu
MENULEN	        .EQU    11	        ;length of menu per entry
MENUSPC	        .EQU    990	        ;vertical space between menu entries
MENUWIDTH       .EQU    18	        ;width of pull down menu
MENULOC	        .EQU    273	        ;start pt for menu heading
MENU1MSG        .EQU    MENUSTRT+182    ;location of first menu entry
MBARLEN	        .EQU    16	        ;heigth of menu bar

MITEMS	        .EQU    7			   ;number of menu items
MENUEND	        .EQU    MENUSTRT+  ;bottom of menu

        .IF  BMENU = 1
BMENUWIDTH      .EQU    MENUWIDTH       ;width of pull down menu
BMENULEN        .EQU    34	        ;length of each boot menu entry
BMENUSPC        .EQU       ;vertical space between boot menu entries
        .ENDC

DBOXWIDTH       .EQU    84-MENUWIDTH		   ;width of dialog box
DBOXHIGH        .EQU    20			   ;heigth of dialog box
DBOXTOP	        .EQU    4*ROWBYTES		   ;dialog box spacing down from menu line
DBOXLEFT        .EQU    MENUWIDTH+2		   ;dialog box spacing left from menu
DBOXSTRT        .EQU    MENUSTRT+DBOXLEFT+DBOXTOP  ;start of dialog box
DBOXROW	        .EQU    +4		   ;pixel row for dialog msg
DBOXCOL	        .EQU    MENUWIDTH+6		   ;byte col for dialog msg

SVCTOP	        .EQU    *ROWBYTES	   ;service window spacing down
                                                   ; from top of dialog box
SVCLEFT	        .EQU    MENUWIDTH+2		   ;service window spacing left from menu
SVCSTRT	        .EQU    DBOXSTRT+SVCTOP		   ;left corner for service window
SVCWIDTH        .EQU    84-MENUWIDTH		   ;width of service window
SVCHIGH	        .EQU    320			   ;length of service window

FIRSTROW        .EQU    +20		   ;first row for display of msgs
FIRSTCOL        .EQU    MENUWIDTH+6		   ;first column
ROWSLEFT        .EQU    SVCHIGH-20		   ;pixel rows to bottom of service window
CHARROWS        .EQU    -3		   ;rows used for character display
LASTROW	        .EQU    +FIRSTROW	   ;last pixel row for display
LASTCOL	        .EQU    FIRSTCOL+SVCWIDTH-2	   ;last column
ROWLINES        .EQU    10			   ;pixel row lines per character
ROWLEN	        .EQU    |1+1	   ;bytes per pixel row (must be even!)
NROWS	        .EQU    /ROWLINES ;number of character rows
CHRHIGH	        .EQU    8			   ;character heigth in pixel lines
CHRWIDTH        .EQU    1			   ;width of char in bytes
CHRSPC	        .EQU    CHRHIGH+2		   ;vert pixel lines between chars

ICONWIDTH       .EQU    6		        ;width in bytes of icons
ICONHIGH        .EQU    32		        ;heigth of icons in pixel rows

TSTROW	        .EQU    ALBOXROW	        ;starting row for test alert box
TSTCOL	        .EQU    10			 ;starting col for test alert box
TSTWSTRT        .EQU    +TSTCOL ;test alert box start
TSTWWIDTH       .EQU    70			 ;width for test alert box
TSTWHIGH        .EQU    84		        ;heigth for test alert box
TSTMROW	        .EQU    TSTROW+15	        ;row for test message display
TSTMCOL	        .EQU    TSTCOL+4	        ;col for test message display
MIDTSTROW       .EQU    TSTROW+     ;middle row of test box
CHKROW	        .EQU    MIDTSTROW-  ;row for check mark display
TSTIROW	        .EQU    CHKROW+10	        ;row for test icon display
TSTICOL	        .EQU    TSTCOL+10	        ;col for test icon display
TSTISPC	        .EQU    ICONWIDTH+8	        ;space between test icons

CPUSTRT	        .EQU    +TSTICOL ;upper left corner for CPU icon
MEMSTRT	        .EQU    CPUSTRT+TSTISPC		   ;upper left corner for MEM icon
IOSTRT	        .EQU    MEMSTRT+TSTISPC		   ;upper left corner for I/O icon
XCRDSTRT        .EQU    IOSTRT+TSTISPC		   ;upper left corner for slot icon

ERRROW	        .EQU    MIDALROW-   ;row for error icon display
ERRCOL	        .EQU    ALBOXCOL+10	        ;col for error icon display
ERRSTRT	        .EQU    +ERRCOL ;start address for error icon display
ALRTROW	        .EQU    ERRROW		        ;row for alert icon display
ALRTCOL	        .EQU    ERRCOL		        ;col for alert icon display
CODEROW	        .EQU    ERRROW+36	        ;row for error code display
CODECOL	        .EQU    ERRCOL+2	        ;col for error code display
MSGROW	        .EQU    ALRTROW+11	        ;row for alert/error message display
MSGCOL	        .EQU    ALRTCOL+8	        ;col for alert/error message display
MEMROW	        .EQU    16		        ;offset row for memory board id # display
MEMCOL	        .EQU    4		        ;offset col for memory board id # display
DISKROW	        .EQU    18		        ;offset row for diskette id # display
DISKCOL	        .EQU    4		        ;offset col for diskette id # display	 CHG024
SLOTROW	        .EQU    22		        ;offset row for slot card id # display
SLOTCOL	        .EQU    3		        ;offset col for slot card id # display
DRVROW	        .EQU    6		        ;offset row for drive id # display	 CHG009
DRVCOL	        .EQU    3		        ;offset col for drive id # display	 CHG009
INSRTROW        .EQU    5		        ;offset row for insert rqst id # display CHG009/CHG024
INSRTCOL        .EQU    4		        ;offset col for insert rqst id # display CHG009


DEFROW	        .EQU    WMIDROW-	  ;row for default boot icon display
DEFCOL	        .EQU    W34COL-	  ;col for default boot icon display
DEFSTRT	        .EQU    +DEFCOL  ;start address for default boot icon
ALTCOL	        .EQU    W14COL-	  ;col for alternate boot icon display
COL1STRT        .EQU    <78*ROWBYTES>+6		  ;start for first column of boot icons
COL2STRT        .EQU    COL1STRT+12		  ;start for second col of boot icons
COL2MID	        .EQU    +ALTCOL  ;middle of second col
COL3STRT        .EQU    COL2STRT+12		  ;start for third col of boot icons
ICONCSPC        .EQU    <64*ROWBYTES>		  ;space between left corner of icons in col
ICONMSPC        .EQU    <12*ROWBYTES>+6+2	  ;start addr offset for boot icon alternate keycode
ICONRSPC        .EQU    12			  ;space in between cols in same row

ALTKYADDR       .EQU    ICONMSPC+5      ;address offset for display of alternate keycode in menu bar

PCWIDTH	        .EQU    86	        ;width of window for power cycling msgs
PCHIGH	        .EQU    192	        ;height of window
PCSTRT	        .EQU    WINDSTRT        ;upper left corner of window
PCROW	        .EQU    ALBOXROW+40     ;first row for power cycle msgs
PCCOL	        .EQU    ALBOXCOL+6      ;first col for power cycle msgs

ROMIDROW        .EQU    3	        ;cursor row ptr for ROM id display	        CHG001
ROMIDCOL        .EQU    80	        ;cursor col ptr for ROM id display	        CHG001

        .IF  DEBUG = 0
GLOBALS	        .EQU    STKBASE	        ;start of global area for mouse/cursor
        .ELSE
GLOBALS	        .EQU    $900	        ;place here in debug mode
        .ENDC

ClockBytes      .EQU    Globals	        ;clock data save area
MousX	        .EQU    ClockBytes+6    ;mouse X-coordinate (word)
MousY	        .EQU    MousX+2	        ;mouse Y-coordinate (word)
MousDx	        .EQU    MousY+2	        ;mouse delta-x (byte)
MousDy	        .EQU    MousDx+1        ;mouse delta-y (byte)
MousScaling     .EQU    MousDy+1        ;0=disabled, else=enabled (byte)
MousThresh      .EQU    MousScale|1+1   ;mouse movement threshold (word)

CrsrHotx        .EQU    MousThresh+2    ;hotspot X-coordinate (word)
CrsrHoty        .EQU    CrsrHotX+2      ;hotspot Y-coordinate (word)
CrsrHeight      .EQU    CrsrHotY+2      ;cursor height, 0-32 (word)
CrsrX	        .EQU    CrsrHeight+2    ;cursor X-coordinate (word)
CrsrY	        .EQU    CrsrX+2	        ;cursor Y-coordinate (word)
CrsrTracking    .EQU    CrsrY+2	        ;0=disabled, else=enabled (byte)
CrsrBusy        .EQU    CrsrTracking+1  ;0=not busy, else=busy (byte)
CrsrVisible     .EQU    CrsrBusy+1      ;0=not visible, else=visible (byte)
CrsrHidden      .EQU    CrsrVisible|1+1 ;<=0 implies hiddden (word)
CrsrObscured    .EQU    CrsrHidden+2    ;0=not obscured, else=obscured (byte)

SavedData       .EQU    CrsrObscured+2  ;data from under cursor (128 bytes)
SavedX	        .EQU    SavedData+128   ;saved data X-coordinate (word)
SavedY	        .EQU    SavedX+2        ;saved data Y-coordinate (word)
SavedRows       .EQU    SavedY+2        ;rows of saved data (word)
SavedAddr       .EQU    SavedRows+2     ;saved data screen address (long)

LwrRight        .EQU    SavedAddr+4     ;saved lower right corner address (word)
MsgLen	        .EQU    LwrRight+2      ;length of dialog box msg (word)

        .IF  BMENU = 0
IconBase        .EQU    Msglen+2        ;base address for first alternate boot icon (word)
IconAddr        .EQU    IconBase+2      ;address for last boot icon displayed (word)
        .ELSE
MenuBase        .EQU    Msglen+2        ;address of last boot menu "box" (word)
IconAddr        .EQU    MenuBase+2      ;address for last boot icon displayed (word)
        .ENDC

IconCnt	        .EQU    IconAddr+2      ;count of boot icons displayed (byte)

DRIVE	        .EQU    IconCnt+1       ;drive id for dump/verify options (byte)
BLKNUM	        .EQU    DRIVE+1	        ;block # for dump option (word)
CONTXT	        .EQU    BLKNUM+2        ;context for dump of MMU contents (byte)

RectCnt	        .EQU    CONTXT+2        ;count for active rect table (word)
RectTable       .EQU    RectCnt	        ;active rectangle table (same start)

        .ENDC
        .PAGE
;----------------------------------------------------------------------------
; The following memory locations are reserved for ROM use to save test data
;----------------------------------------------------------------------------

STATUS	        .EQU    $0180	        ;POWER-UP STATUS (0=OK)
SIZRSLT	        .EQU    STATUS+4        ;memory sizing test results
MEMRSLT	        .EQU    SIZRSLT+2       ;MEMORY TEST RESULTS
BOOTMEM	        .EQU    MEMRSLT+2       ;result for boot area of memory (128K)
PEADDR	        .EQU    MEMRSLT+32      ;PARITY ERROR ADDRESS
ADRLTCH	        .EQU    PEADDR+4        ;CONTENTS OF MEMORY ADDRESS LATCH
D7SAV	        .EQU    ADRLTCH+2       ;save for D7 when exception occurs
MMURSLT	        .EQU    $01B0	        ;MMU TEST RESULTS
KEYID	        .EQU    $01B2	        ;Keyboard ID
BOOTDVCE        .EQU    $01B3	        ;BOOT DEVICE CODE
BOOTDATA        .EQU    $01B4	        ;BOOT FAILURE DATA
CLKDATA	        .EQU    $01BA	        ;CLOCK SETTING READ
DATARGS	        .EQU    $01C0	        ;DATA REG SAVE AREA
ADRREGS	        .EQU    $01E0	        ;ADDRESS REG SAVE AREA
A6SAV	        .EQU    $01F8	        ;SAVE AREA FOR REG A6
USPSAV	        .EQU    $01FC	        ;SAVE AREA FOR USER STACK PTR

SERNUM	        .EQU    $0240	        ;saved serial number (28 bytes)
KBDQPTR	        .EQU    $0260	        ;ptr for keyboard queue

XPCTADDR        .EQU    $0268	        ;memory test address for parity error	        CHG015
XPCTDATA        .EQU    $026C	        ;memory test expected data		        CHG015
ACTADDR	        .EQU    $0270	        ;parity error address, phase 2		        CHG015
ACTDATA	        .EQU    $0274	        ;actual data read on parity error, phase 2      CHG015
PEADR2	        .EQU    $0278	        ;address read from error latch		        CHG015
PCHPROW	        .EQU    $027C	        ;parity chip row			        CHG015
PCHIP	        .EQU    $027D	        ;parity chip id				        CHG015

EXCFC	        .EQU    $0280	        ; bus function code
EXCADR	        .EQU    $0282	        ; address of error
EXCIR	        .EQU    $0286	        ; instruction reg
EXCSR	        .EQU    $0288	        ; status reg
EXCPC	        .EQU    $028A	        ; PC at time of exception
EXCTYPE	        .EQU    $028E	        ; exception type
SUPSTK	        .EQU    $0290	        ;SUPERVISOR STACK PTR
MAXMEM	        .EQU    $0294	        ;MAX MEMORY ADDRESS + 1
IO1ID	        .EQU    $0298	        ;I/O SLOT 1 ID
IO2ID	        .EQU    $029A	        ;I/O SLOT 2 ID
IO3ID	        .EQU    $029C	        ;I/O SLOT 3 ID
IO1STAT	        .EQU    $029E	        ;I/O SLOT 1 STATUS
IO2STAT	        .EQU    $029F	        ;I/O SLOT 2 STATUS
IO3STAT	        .EQU    $02A0	        ;I/O SLOT 3 STATUS
IOROM	        .EQU    $02A1	        ;I/O ROM VERSION #
STATFLGS        .EQU    $02A2	        ;additional status indicators
MINMEM	        .EQU    $02A4	        ;MINIMUM PHYSICAL ADDRESS
TOTLMEM	        .EQU    $02A8	        ;total amount of memory
SCCRSLT	        .EQU    $02AC	        ;SCC test results
MEMSLOT	        .EQU    $02AD	        ;Slot # for memory board if memory error
DSKRSLT	        .EQU    $02AE	        ;Disk controller self-test status byte (0=no error)
SYSTYPE	        .EQU    $02AF	        ;System type (0 = Lisa 1; 1, 2, 3 = Lisa 2)	   CHG029
KBDQ	        .EQU    $02B0	        ;KEYBOARD QUEUE
QEND	        .EQU    $02C0	        ;END OF Q

        .INCLUDE RM248.K.TEXT
        .INCLUDE RM248.S.TEXT
        .INCLUDE RM248.B.TEXT
        .INCLUDE RM248.M.TEXT
        .INCLUDE RM248.G.TEXT