*--------------------------------------------------------------------------
* Mini 68008 BIOS Interface
* Mike Christle 2016
*--------------------------------------------------------------------------

*-----------------------------------------------------------------------------
*                        TERMS OF USE: MIT License
*-----------------------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*-----------------------------------------------------------------------------

*-----------------------------------------------------------------------------
* 68681 DUART Register Port Addresses
*-----------------------------------------------------------------------------
DUART_MR1A        EQU   $8000
DUART_MR2A        EQU   $8000
DUART_SRA         EQU   $8002
DUART_CSRA        EQU   $8002
DUART_BRG_TEST    EQU   $8004
DUART_CRA         EQU   $8004
DUART_RHRA        EQU   $8006
DUART_THRA        EQU   $8006
DUART_IPCR        EQU   $8008
DUART_ACR         EQU   $8008
DUART_ISR         EQU   $800A
DUART_IMR         EQU   $800A
DUART_CTU         EQU   $800C
DUART_CTUR        EQU   $800C
DUART_CTL         EQU   $800E
DUART_CTLR        EQU   $800E
DUART_MR1B        EQU   $8010
DUART_MR2B        EQU   $8010
DUART_SRB         EQU   $8012
DUART_CSRB        EQU   $8012
DUART_1X_TEST     EQU   $8014
DUART_CRB         EQU   $8014
DUART_RHRB        EQU   $8016
DUART_THRB        EQU   $8016
DUART_IVR         EQU   $8018
DUART_IN_PORT     EQU   $801A
DUART_OPCR        EQU   $801A
DUART_START_CNTR  EQU   $801C
DUART_SOPR        EQU   $801C
DUART_STOP_CNTR   EQU   $801E
DUART_ROPR        EQU   $801E

*-----------------------------------------------------------------------------
* 68681 Interrupt Service Register Constants
*-----------------------------------------------------------------------------
INPORT_INT_BIT  EQU     7
BREAKB_INT_BIT  EQU     6
RXRDYB_INT_BIT  EQU     5
TXRDYB_INT_BIT  EQU     4
CTRRDY_INT_BIT  EQU     3
BREAKA_INT_BIT  EQU     2
RXRDYA_INT_BIT  EQU     1
TXRDYA_INT_BIT  EQU     0

*--------------------------------------------------------------------------
* GETC
* D2.B = Char, 0 If Buffer Empty
*--------------------------------------------------------------------------
#macro          GETC
                MOVE.W  #0, D0
                TRAP    #0
#endmacro

*--------------------------------------------------------------------------
* PUTC
* D2.B = Char
*--------------------------------------------------------------------------
#macro          PUTC
                MOVE.W  #1, D0
                TRAP    #0
#endmacro

*--------------------------------------------------------------------------
* GETS
* A2.L = Pointer to buffer
* D4.W = Buffer size
* Terminates on CR
*--------------------------------------------------------------------------
#macro          GETS
                MOVE.W  #2, D0
                TRAP    #0
#endmacro

*--------------------------------------------------------------------------
* PUTS
* A2.L = Pointer to NULL terminated string
*--------------------------------------------------------------------------
#macro          PUTS
                MOVE.W  #3, D0
                TRAP    #0
#endmacro

*--------------------------------------------------------------------------
* PRINT_HEX
* D4.L = Value
* D5.W = Number of bytes
*--------------------------------------------------------------------------
#macro          PRINT_HEX
                MOVE.W  #4, D0
                TRAP    #0
#endmacro

*--------------------------------------------------------------------------
* ENABLE_ISR VECTOR_NO, ISR_ADDRESS
*--------------------------------------------------------------------------
#macro          ENABLE_ISR VN, ISR
                MOVE.W  #%VN, D1
                MOVEA.L #%ISR, A1
                MOVE.W  #5, D0
                TRAP    #0
#endmacro

*--------------------------------------------------------------------------
* DISABLE_ISR VECTOR_NO
*--------------------------------------------------------------------------
#macro          DISABLE_ISR VN
                MOVE.W  #%VN, D1
                MOVE.W  #6, D0
                TRAP    #0
#endmacro
