; ============================================================================
|
; ============================================================================
|
; __
|
; __
|
; \\__/ o\ (C) 2013-2022 Robert Finch, Waterloo
|
; \\__/ o\ (C) 2013-2022 Robert Finch, Waterloo
|
; \ __ / All rights reserved.
|
; \ __ / All rights reserved.
|
; \/_// robfinch@opencores.org
|
; \/_// robfinch@opencores.org
|
; ||
|
; ||
|
;
|
;
|
;
|
;
|
; BSD 3-Clause License
|
; BSD 3-Clause License
|
; Redistribution and use in source and binary forms, with or without
|
; Redistribution and use in source and binary forms, with or without
|
; modification, are permitted provided that the following conditions are met:
|
; modification, are permitted provided that the following conditions are met:
|
;
|
;
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
; 1. Redistributions of source code must retain the above copyright notice, this
|
; list of conditions and the following disclaimer.
|
; list of conditions and the following disclaimer.
|
;
|
;
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
; this list of conditions and the following disclaimer in the documentation
|
; this list of conditions and the following disclaimer in the documentation
|
; and/or other materials provided with the distribution.
|
; and/or other materials provided with the distribution.
|
;
|
;
|
; 3. Neither the name of the copyright holder nor the names of its
|
; 3. Neither the name of the copyright holder nor the names of its
|
; contributors may be used to endorse or promote products derived from
|
; contributors may be used to endorse or promote products derived from
|
; this software without specific prior written permission.
|
; this software without specific prior written permission.
|
;
|
;
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
;
|
;
|
; ============================================================================
|
; ============================================================================
|
;
|
;
|
CR EQU $0D ;ASCII equates
|
OPT include "d:\cores2022\rf6809\software\boot\mon_equates.asm"
|
LF EQU $0A
|
OPT include "d:\cores2022\rf6809\software\boot\io_equates.asm"
|
TAB EQU $09
|
|
CTRLC EQU $03
|
|
CTRLH EQU $08
|
|
CTRLI EQU $09
|
|
CTRLJ EQU $0A
|
|
CTRLK EQU $0B
|
|
CTRLM EQU $0D
|
|
CTRLS EQU $13
|
|
CTRLT EQU $14
|
|
CTRLX EQU $18
|
|
XON EQU $11
|
|
XOFF EQU $13
|
|
|
|
FIRST_CORE EQU 1
|
|
MAX_TASKNO EQU 63
|
|
DRAM_BASE EQU $10000000
|
|
|
|
|
OPC_SWI EQU $03F
|
ScreenLocation EQU $10
|
ScreenLocation EQU $10
|
ColorCodeLocation EQU $14
|
ColorCodeLocation EQU $14
|
ScreenLocation2 EQU $18
|
ScreenLocation2 EQU $18
|
BlkcpySrc EQU $1C
|
BlkcpySrc EQU $1C
|
BlkcpyDst EQU $20
|
BlkcpyDst EQU $20
|
Strptr EQU $24
|
Strptr EQU $24
|
PICptr EQU $28
|
PICptr EQU $28
|
; Forth Area
|
; Forth Area
|
; 0x30-0x60
|
; 0x30-0x60
|
|
|
RunningID EQU $800000
|
|
|
|
; Task control blocks, room for 256 tasks
|
; Task control blocks, room for 256 tasks
|
TCB_NxtRdy EQU $00 ; next task on ready / timeout list
|
TCB_NxtRdy EQU $00 ; next task on ready / timeout list
|
TCB_PrvRdy EQU $04 ; previous task on ready / timeout list
|
TCB_PrvRdy EQU $04 ; previous task on ready / timeout list
|
TCB_NxtTCB EQU $08
|
TCB_NxtTCB EQU $08
|
TCB_Timeout EQU $0C
|
TCB_Timeout EQU $0C
|
TCB_Priority EQU $10
|
TCB_Priority EQU $10
|
TCB_MSGPTR_D1 EQU $14
|
TCB_MSGPTR_D1 EQU $14
|
TCB_MSGPTR_D2 EQU $18
|
TCB_MSGPTR_D2 EQU $18
|
TCB_hJCB EQU $1C
|
TCB_hJCB EQU $1C
|
TCB_Status EQU $1E
|
TCB_Status EQU $1E
|
TCB_CursorRow EQU $20
|
TCB_CursorRow EQU $20
|
TCB_CursorCol EQU $21
|
TCB_CursorCol EQU $21
|
TCB_hWaitMbx EQU $22 ; handle of mailbox task is waiting at
|
TCB_hWaitMbx EQU $22 ; handle of mailbox task is waiting at
|
TCB_mbq_next EQU $24 ; mailbox queue next
|
TCB_mbq_next EQU $24 ; mailbox queue next
|
TCB_mbq_prev EQU $28 ; mailbox queue previous
|
TCB_mbq_prev EQU $28 ; mailbox queue previous
|
TCB_iof_next EQU $2C
|
TCB_iof_next EQU $2C
|
TCB_iof_prev EQU $30
|
TCB_iof_prev EQU $30
|
TCB_SPSave EQU $34 ; TCB_SPSave area
|
TCB_SPSave EQU $34 ; TCB_SPSave area
|
TCB_mmu_map EQU $38
|
TCB_mmu_map EQU $38
|
|
|
KeybdHead EQU $FFFFFC800
|
KeybdHead EQU $FFFFFC800
|
KeybdTail EQU $FFFFFC900
|
KeybdTail EQU $FFFFFC900
|
KeybdEcho EQU $FFFFFCA00
|
KeybdEcho EQU $FFFFFCA00
|
KeybdBad EQU $FFFFFCB00
|
KeybdBad EQU $FFFFFCB00
|
KeybdAck EQU $FFFFFCC00
|
KeybdAck EQU $FFFFFCC00
|
KeybdLocks EQU $FFFFFCD00
|
KeybdLocks EQU $FFFFFCD00
|
KeybdBuffer EQU $FFFFFC000 ; buffer is 16 chars
|
KeybdBuffer EQU $FFFFFC000 ; buffer is 16 chars
|
|
|
COREID EQU $FFFFFFFE0
|
|
MSCOUNT EQU $FFFFFFFE4
|
|
LEDS EQU $FFFE60001
|
|
VIA EQU $FFFE60000
|
|
VIA_PA EQU 1
|
|
VIA_DDRA EQU 3
|
|
VIA_ACR EQU 11
|
|
VIA_IFR EQU 13
|
|
VIA_IER EQU 14
|
|
VIA_T3LL EQU 18
|
|
VIA_T3LH EQU 19
|
|
VIA_T3CMPL EQU 20
|
|
VIA_T3CMPH EQU 21
|
|
TEXTSCR EQU $FFFE00000
|
|
TEXTREG EQU $FFFE0DF00
|
|
TEXT_COLS EQU 0
|
|
TEXT_ROWS EQU 1
|
|
TEXT_CURPOS EQU 34
|
|
ACIA EQU $FFFE30100
|
|
ACIA_TX EQU 0
|
|
ACIA_RX EQU 0
|
|
ACIA_STAT EQU 1
|
|
ACIA_CMD EQU 2
|
|
ACIA_CTRL EQU 3
|
|
ACIA_CTRL2 EQU 11
|
|
RTC EQU $FFFE30500 ; I2C
|
|
RTCBuf EQU $7FC0
|
|
|
|
KEYBD EQU $FFFE30400
|
|
KEYBDCLR EQU $FFFE30402
|
|
PIC EQU $FFFE3F000
|
|
SPRITE_CTRL EQU $FFFE10000
|
|
SPRITE_EN EQU $3C0
|
|
|
|
OUTSEMA EQU $EF0000
|
|
SEMAABS EQU $1000
|
|
OSSEMA EQU $EF0010
|
|
|
|
BIOS_SCREENS EQU $17000000 ; $17000000 to $171FFFFF
|
BIOS_SCREENS EQU $17000000 ; $17000000 to $171FFFFF
|
|
|
; EhBASIC vars:
|
; EhBASIC vars:
|
;
|
;
|
NmiBase EQU $FF0013
|
NmiBase EQU $FFC013
|
IrqBase EQU $FF0014
|
IrqBase EQU $FFC014
|
|
|
IOFocusNdx EQU $100
|
IOFocusNdx EQU $100
|
|
|
; These variables in global OS storage area
|
; These variables in global OS storage area
|
|
|
IOFocusList EQU $FF0000 ; to $FF000F
|
IOFocusList EQU $FFC000 ; to $FF000F
|
IOFocusID EQU $FF0010
|
IOFocusID EQU $FFC010
|
IrqSource EQU $FF0011
|
IrqSource EQU $FFC011
|
IRQFlag EQU $FF0012
|
IRQFlag EQU $FFC012
|
|
RunningID EQU $FFC013
|
|
|
; These variables use direct page access
|
; These variables use direct page access
|
CursorRow EQU $110
|
CursorRow EQU $110
|
CursorCol EQU $111
|
CursorCol EQU $111
|
CharColor EQU $112
|
CharColor EQU $112
|
ScreenColor EQU $113
|
ScreenColor EQU $113
|
CursorFlash EQU $114
|
CursorFlash EQU $114
|
KeyState1 EQU $120
|
KeyState1 EQU $120
|
KeyState2 EQU $121
|
KeyState2 EQU $121
|
KeyLED EQU $122
|
KeyLED EQU $122
|
KeybdID EQU $124
|
KeybdID EQU $124
|
KeybdBlock EQU $126
|
KeybdBlock EQU $126
|
kbdHeadRcv EQU $127
|
kbdHeadRcv EQU $127
|
kbdTailRcv EQU $128
|
kbdTailRcv EQU $128
|
kbdFifo EQU $40 ; in local RAM
|
kbdFifo EQU $40 ; in local RAM
|
kbdFifoAlias EQU $C00040 ; to $C0007F ; alias for $40 to $7F
|
kbdFifoAlias EQU $C00040 ; to $C0007F ; alias for $40 to $7F
|
SerhZero EQU $130
|
SerhZero EQU $130
|
SerHeadRcv EQU $131
|
SerHeadRcv EQU $131
|
SertZero EQU $132
|
SertZero EQU $132
|
SerTailRcv EQU $133
|
SerTailRcv EQU $133
|
SerHeadXmit EQU $136
|
SerHeadXmit EQU $136
|
SerTailXmit EQU $138
|
SerTailXmit EQU $138
|
SerRcvXon EQU $139
|
SerRcvXon EQU $139
|
SerRcvXoff EQU $140
|
SerRcvXoff EQU $140
|
SerRcvBuf EQU $BFF000 ; 4kB serial recieve buffer
|
SerRcvBuf EQU $BFF000 ; 4kB serial recieve buffer
|
|
|
farflag EQU $15F
|
farflag EQU $15F
|
asmbuf EQU $160 ; to $17F
|
asmbuf EQU $160 ; to $17F
|
|
|
QNdx0 EQU $780
|
QNdx0 EQU $780
|
QNdx1 EQU QNdx0+2
|
QNdx1 EQU QNdx0+2
|
QNdx2 EQU QNdx1+2
|
QNdx2 EQU QNdx1+2
|
QNdx3 EQU QNdx2+2
|
QNdx3 EQU QNdx2+2
|
QNdx4 EQU QNdx3+2
|
QNdx4 EQU QNdx3+2
|
FreeTCB EQU QNdx4+2
|
FreeTCB EQU QNdx4+2
|
TimeoutList EQU FreeTCB+2
|
TimeoutList EQU FreeTCB+2
|
FreeMbx EQU RunningTCB + 2
|
FreeMbx EQU RunningTCB + 2
|
nMailbox EQU FreeMbx + 2
|
nMailbox EQU FreeMbx + 2
|
FreeMsg EQU nMailbox + 2
|
FreeMsg EQU nMailbox + 2
|
nMsgBlk EQU FreeMsg + 2
|
nMsgBlk EQU FreeMsg + 2
|
|
|
|
|
CharOutVec EQU $800
|
CharOutVec EQU $800
|
CharInVec EQU $804
|
CharInVec EQU $804
|
CmdPromptJI EQU $808
|
CmdPromptJI EQU $808
|
MonErrVec EQU $80C
|
MonErrVec EQU $80C
|
|
BreakpointFlag EQU $810
|
|
NumSetBreakpoints EQU $811
|
|
Breakpoints EQU $820 ; to $82F
|
|
BreakpointBytes EQU $830 ; to $83F
|
|
mon_vectb EQU $880
|
|
|
; Register save area for monitor
|
; Register save area for monitor
|
mon_DSAVE EQU $900
|
mon_DSAVE EQU $900
|
mon_XSAVE EQU $902
|
mon_XSAVE EQU $902
|
mon_YSAVE EQU $904
|
mon_YSAVE EQU $904
|
mon_USAVE EQU $906
|
mon_USAVE EQU $906
|
mon_SSAVE EQU $908
|
mon_SSAVE EQU $908
|
mon_PCSAVE EQU $90A
|
mon_PCSAVE EQU $90A
|
mon_DPRSAVE EQU $90E
|
mon_DPRSAVE EQU $90E
|
mon_CCRSAVE EQU $90F
|
mon_CCRSAVE EQU $90F
|
|
|
mon_numwka EQU $910
|
mon_numwka EQU $910
|
mon_r1 EQU $920
|
mon_r1 EQU $920
|
mon_r2 EQU $924
|
mon_r2 EQU $924
|
|
jmpvec EQU $928
|
|
|
; The ORG directive must set an address a multiple of 4 in order for the Verilog
|
; The ORG directive must set an address a multiple of 4 in order for the Verilog
|
; output to work correctly.
|
; output to work correctly.
|
|
|
org $FFD0AC
|
org $FFD0AC
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
XBLANK
|
XBLANK
|
ldb #' '
|
ldb #' '
|
lbsr OUTCH
|
lbsr OUTCH
|
rts
|
rts
|
|
|
org $FFD0D0
|
org $FFD0D0
|
nop
|
nop
|
nop
|
nop
|
CRLF
|
CRLF
|
CRLF1:
|
CRLF1:
|
ldb #CR
|
ldb #CR
|
lbsr OUTCH
|
lbsr OUTCH
|
ldb #LF
|
ldb #LF
|
lbsr OUTCH
|
lbsr OUTCH
|
rts
|
rts
|
|
|
org $FFD0F0
|
org $FFD0F0
|
nop
|
nop
|
bra CRLF1
|
bra CRLF1
|
|
|
org $FFD1DC
|
org $FFD1DC
|
ONEKEY
|
ONEKEY
|
jmp [CharInVec]
|
jmp [CharInVec]
|
|
|
org $FFD2C0
|
org $FFD2C0
|
nop
|
nop
|
LETTER
|
LETTER
|
lbsr OUTCH
|
lbsr OUTCH
|
rts
|
rts
|
|
|
org $FFD2CC
|
org $FFD2CC
|
nop
|
nop
|
nop
|
nop
|
HEX2
|
HEX2
|
lbsr DispByteAsHex
|
lbsr DispByteAsHex
|
rts
|
rts
|
HEX4
|
HEX4
|
lbsr DispWordAsHex
|
lbsr DispWordAsHex
|
rts
|
rts
|
|
|
org $FFD300
|
org $FFD300
|
ClearScreenJmp
|
ClearScreenJmp
|
lbra ClearScreen
|
lbra ClearScreen
|
org $FFD308
|
org $FFD308
|
HomeCursorJmp
|
HomeCursorJmp
|
lbra HomeCursor
|
lbra HomeCursor
|
|
|
org $FFD400
|
org $FFD400
|
|
|
; Local RAM test routine
|
; Local RAM test routine
|
; Checkerboard testing.
|
; Checkerboard testing.
|
; There is 70kB of local RAM
|
; There is 70kB of local RAM
|
; Does not use any RAM including no stack
|
; Does not use any RAM including no stack
|
|
|
ramtest:
|
ramtest:
|
ldy #0
|
ldy #0
|
lda #1
|
lda #1
|
sta LEDS
|
sta LEDS
|
ldd #$AAA555
|
ldd #$AAA555
|
ramtest1:
|
ramtest1:
|
std ,y++
|
std ,y++
|
cmpy #$8000
|
cmpy #$8000
|
blo ramtest1
|
blo ramtest1
|
; now readback values and compare
|
; now readback values and compare
|
ldy #0
|
ldy #0
|
ramtest3:
|
ramtest3:
|
ldd ,y++
|
ldd ,y++
|
cmpd #$AAA555
|
cmpd #$AAA555
|
bne ramerr
|
bne ramerr
|
cmpy #$8000
|
cmpy #$8000
|
blo ramtest3
|
blo ramtest3
|
lda #2
|
lda #2
|
sta LEDS
|
sta LEDS
|
jmp ,u
|
jmp ,u
|
ramerr:
|
ramerr:
|
lda #$80
|
lda #$80
|
sta LEDS
|
sta LEDS
|
ldx #TEXTSCR
|
ldx #TEXTSCR
|
ldb COREID
|
ldb COREID
|
abx
|
abx
|
lda #'F'
|
lda #'F'
|
sta ,x
|
sta ,x
|
sync
|
sync
|
jmp ,u
|
jmp ,u
|
|
|
|
dramtest:
|
|
ldy #$10000 ; DRAM starts here
|
|
lda #1
|
|
sta LEDS
|
|
ldu #$AAA555
|
|
lbsr CRLF
|
|
dramtest1:
|
|
deca
|
|
bne dramtest4
|
|
tfr y,d
|
|
lbsr DispWordAsHex
|
|
ldb #CR
|
|
lbsr OUTCH
|
|
dramtest4:
|
|
stu ,y++
|
|
cmpy #$E00000 ; DRAM ends here
|
|
blo dramtest1
|
|
; now readback values and compare
|
|
ldy #$10000
|
|
lda #1
|
|
lbsr CRLF
|
|
dramtest3:
|
|
deca
|
|
bne dramtest5
|
|
tfr y,d
|
|
lbsr DispWordAsHex
|
|
ldb #CR
|
|
lbsr OUTCH
|
|
dramtest5:
|
|
cmpu ,y++
|
|
bne dramerr
|
|
cmpy #$E00000
|
|
blo dramtest3
|
|
lda #2
|
|
sta LEDS
|
|
lbra Monitor
|
|
dramerr:
|
|
lda #$80
|
|
sta LEDS
|
|
ldx #TEXTSCR
|
|
ldb COREID
|
|
abx
|
|
lda #'F'
|
|
sta ,x
|
|
lbra Monitor
|
|
|
org $FFE000
|
org $FFE000
|
FDB Monitor
|
FDB Monitor
|
FDB DumRts ; NEXTCMD
|
FDB DumRts ; NEXTCMD
|
FDB INCH
|
FDB INCH
|
FDB INCHE
|
FDB INCHE
|
FDB INCHEK
|
FDB INCHEK
|
FDB OUTCH
|
FDB OUTCH
|
FDB PDATA
|
FDB PDATA
|
FDB PCRLF
|
FDB PCRLF
|
FDB PSTRNG
|
FDB PSTRNG
|
FDB DumRts ; LRA
|
FDB DumRts ; LRA
|
FDB DumRts
|
FDB DumRts
|
FDB DumRts
|
FDB DumRts
|
FDB DumRts
|
FDB DumRts
|
FDB DumRts ; VINIZ
|
FDB DumRts ; VINIZ
|
FDB DisplayChar ; VOUTCH
|
FDB DisplayChar ; VOUTCH
|
FDB DumRts ; ACINIZ
|
FDB DumRts ; ACINIZ
|
FDB DumRts ; AOUTCH
|
FDB DumRts ; AOUTCH
|
|
|
DumRts:
|
DumRts:
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
start:
|
start:
|
lda #$FFF ; all cores can do this
|
lda #$FFF ; all cores can do this
|
sta VIA+VIA_DDRA
|
sta VIA+VIA_DDRA
|
lda #$55 ; see if we can at least set LEDs
|
lda #$55 ; see if we can at least set LEDs
|
sta LEDS
|
sta LEDS
|
lda #1 ; prime OS semaphore
|
lda #1 ; prime OS semaphore
|
sta OSSEMA+$1000
|
sta OSSEMA+$1000
|
|
sta OUTSEMA+$1000
|
ldu #st6 ; U = return address
|
ldu #st6 ; U = return address
|
jmp ramtest ; JMP dont JSR
|
jmp ramtest ; JMP dont JSR
|
st6:
|
st6:
|
lds #$6FFF ; boot up stack area
|
lds #$6FFF ; boot up stack area
|
lda COREID
|
lda COREID
|
cmpa #FIRST_CORE
|
cmpa #FIRST_CORE
|
; beq st8
|
; beq st8
|
; sync ; halt cores other than 2
|
; sync ; halt cores other than 2
|
st8:
|
st8:
|
; bne skip_init
|
; bne skip_init
|
; bsr romToRam
|
; bsr romToRam
|
; ldd #st7 & $FFFF
|
; ldd #st7 & $FFFF
|
; tfr d,x
|
; tfr d,x
|
; jmp ,x ; jump to the BIOS now in local RAM
|
; jmp ,x ; jump to the BIOS now in local RAM
|
st7:
|
st7:
|
bsr Delay3s ; give some time for devices to reset
|
bsr Delay3s ; give some time for devices to reset
|
|
clr BreakpointFlag
|
|
clr NumSetBreakpoints
|
lda #$AA
|
lda #$AA
|
sta LEDS
|
sta LEDS
|
lda #FIRST_CORE
|
lda #FIRST_CORE
|
sta IOFocusID ; core #2 has focus
|
sta IOFocusID ; core #2 has focus
|
sta RunningID
|
sta RunningID
|
; Clear IO focus list
|
; Clear IO focus list
|
ldx #0
|
ldx #0
|
st9:
|
st9:
|
clr IOFocusList,x
|
clr IOFocusList,x
|
inx
|
inx
|
cmpx #16
|
cmpx #16
|
blo st9
|
blo st9
|
lda #24
|
lda #24
|
sta IOFocusList+FIRST_CORE
|
sta IOFocusList+FIRST_CORE
|
|
|
lda #$0CE
|
lda #$0CE
|
sta ScreenColor
|
sta ScreenColor
|
sta CharColor
|
sta CharColor
|
bsr ClearScreen
|
bsr ClearScreen
|
ldd #DisplayChar
|
ldd #DisplayChar
|
std CharOutVec
|
std CharOutVec
|
ldd #SerialPeekCharDirect
|
ldd #SerialPeekCharDirect
|
std CharInVec
|
std CharInVec
|
ldb #24 ; request IO focus
|
; swi
|
lbsr OSCall
|
; fcb MF_OSCALL
|
|
; fcb 24 ; request IO focus
|
ldb COREID
|
ldb COREID
|
cmpb #FIRST_CORE
|
cmpb #FIRST_CORE
|
beq init
|
beq init
|
bra skip_init
|
bra skip_init
|
bra multi_sieve
|
bra multi_sieve
|
st3:
|
st3:
|
lda #$FF
|
lda #$FF
|
sta LEDS
|
sta LEDS
|
bra st3
|
bra st3
|
|
|
; initialize interrupt controller
|
; initialize interrupt controller
|
; first, zero out all the vectors
|
; first, zero out all the vectors
|
init:
|
init:
|
lbsr rtc_read ; get clock values
|
lbsr rtc_read ; get clock values
|
ldx #kbdHeadRcv
|
ldx #kbdHeadRcv
|
ldb #32 ; number of bytes to zero out
|
ldb #32 ; number of bytes to zero out
|
init1:
|
init1:
|
clr ,x+
|
clr ,x+
|
decb
|
decb
|
bne init1
|
bne init1
|
lbsr TimerInit
|
lbsr TimerInit
|
lbsr InitSerial
|
lbsr InitSerial
|
ldx #128
|
ldx #128
|
lda #1 ; set irq(bit0), clear firq (bit1), disable int (bit 6), clear edge sense(bit 7)
|
lda #1 ; set irq(bit0), clear firq (bit1), disable int (bit 6), clear edge sense(bit 7)
|
ldb #FIRST_CORE ; serving core id
|
ldb #FIRST_CORE ; serving core id
|
st1:
|
st1:
|
clr PIC,x ; cause code
|
clr PIC,x ; cause code
|
sta PIC+1,x
|
sta PIC+1,x
|
stb PIC+2,x
|
stb PIC+2,x
|
leax 4,x
|
leax 4,x
|
cmpx #256
|
cmpx #256
|
blo st1
|
blo st1
|
; lda #4 ; make the timer interrupt edge sensitive
|
; lda #4 ; make the timer interrupt edge sensitive
|
; sta PIC+4 ; reg #4 is the edge sensitivity setting
|
; sta PIC+4 ; reg #4 is the edge sensitivity setting
|
; sta PIC ; reg #0 is interrupt enable
|
; sta PIC ; reg #0 is interrupt enable
|
lda #$81 ; make irq edge sensitive
|
lda #$81 ; make irq edge sensitive
|
sta PIC+$FD
|
sta PIC+$FD
|
lda #31 ; enable timer interrupt
|
lda #31 ; enable timer interrupt
|
; sta PIC+9
|
sta PIC+9
|
ldb #1
|
ldb #1
|
stb OUTSEMA+SEMAABS ; set semaphore to 1 available slot
|
stb OUTSEMA+SEMAABS ; set semaphore to 1 available slot
|
skip_init:
|
skip_init:
|
andcc #$EF ; unmask irq
|
andcc #$EF ; unmask irq
|
lda #56
|
lda #COLS
|
sta TEXTREG+TEXT_COLS
|
sta TEXTREG+TEXT_COLS
|
lda #29
|
lda #ROWS
|
sta TEXTREG+TEXT_ROWS
|
sta TEXTREG+TEXT_ROWS
|
bsr ClearScreen
|
bsr ClearScreen
|
bsr HomeCursor
|
bsr HomeCursor
|
lda #5
|
lda #5
|
sta LEDS
|
sta LEDS
|
ldd #msgStartup
|
ldd #msgStartup
|
bsr DisplayString
|
bsr DisplayString
|
ldx #0
|
ldx #0
|
ldd #0
|
ldd #0
|
lbsr ShowSprites
|
lbsr ShowSprites
|
lbsr KeybdInit
|
lbsr KeybdInit
|
ldd KeybdID
|
ldd KeybdID
|
bsr DispWordAsHex
|
bsr DispWordAsHex
|
jmp MonitorStart
|
jmp MonitorStart
|
|
|
msgStartup
|
msgStartup
|
fcb "rf6809 12-bit System Starting.",CR,LF,0
|
fcb "rf6809 12-bit System Starting.",CR,LF,0
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; The checkpoint register must be cleared within 1 second or a NMI interrupt
|
; The checkpoint register must be cleared within 1 second or a NMI interrupt
|
; will occur. checkpoint should be called with a JSR so that the global ROM
|
; will occur. checkpoint should be called with a JSR so that the global ROM
|
; routine is called.
|
; routine is called.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
checkpoint:
|
checkpoint:
|
clr $FFFFFFFE1 ; writing any value will do
|
clr $FFFFFFFE1 ; writing any value will do
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Copy the system ROM to local RAM
|
; Copy the system ROM to local RAM
|
; Running the code from local RAM is probably an order of magnitude faster
|
; Running the code from local RAM is probably an order of magnitude faster
|
; then running from the global ROM. It also reduces the network traffic to
|
; then running from the global ROM. It also reduces the network traffic to
|
; run from local RAM.
|
; run from local RAM.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; d,x,y
|
; d,x,y
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
romToRam:
|
romToRam:
|
ldx #$FFC000
|
ldx #$FFC000
|
ldy #$00C000
|
ldy #$00C000
|
romToRam1:
|
romToRam1:
|
ldd ,x++
|
ldd ,x++
|
std ,y++
|
std ,y++
|
cmpx #0
|
cmpx #0
|
bne romToRam1
|
bne romToRam1
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Multi-core sieve program.
|
; Multi-core sieve program.
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
; First fill screen chars with 'P' indicating prime positions
|
; First fill screen chars with 'P' indicating prime positions
|
; Each core is responsible for the Nth position where N is the
|
; Each core is responsible for the Nth position where N is the
|
; core number minus two.
|
; core number minus two.
|
;
|
;
|
multi_sieve:
|
multi_sieve:
|
lda #'P' ; indicate prime
|
lda #'P' ; indicate prime
|
ldb COREID ; find out which core we are
|
ldb COREID ; find out which core we are
|
subb #FIRST_CORE
|
subb #FIRST_CORE
|
ldx #0 ; start at first char of screen
|
ldx #0 ; start at first char of screen
|
abx
|
abx
|
multi_sieve3:
|
multi_sieve3:
|
sta TEXTSCR,x ; store 'P'
|
sta TEXTSCR,x ; store 'P'
|
leax 8,x ; advance to next position
|
leax 8,x ; advance to next position
|
cmpx #4095
|
cmpx #4095
|
blo multi_sieve3
|
blo multi_sieve3
|
jsr checkpoint
|
jsr checkpoint
|
addb #2 ; start sieve at 2 (core id)
|
addb #2 ; start sieve at 2 (core id)
|
lda #'N' ; flag position value of 'N' for non-prime
|
lda #'N' ; flag position value of 'N' for non-prime
|
multi_sieve2:
|
multi_sieve2:
|
ldx #0
|
ldx #0
|
abx ; skip the first position - might be prime
|
abx ; skip the first position - might be prime
|
multi_sieve1:
|
multi_sieve1:
|
abx ; increment
|
abx ; increment
|
sta TEXTSCR,x
|
sta TEXTSCR,x
|
cmpx #4095
|
cmpx #4095
|
blo multi_sieve1
|
blo multi_sieve1
|
jsr checkpoint
|
jsr checkpoint
|
addb #8 ; number of cores working on it
|
addb #8 ; number of cores working on it
|
cmpb #4080
|
cmpb #4080
|
blo multi_sieve2
|
blo multi_sieve2
|
multi_sieve4: ; hang machine
|
multi_sieve4: ; hang machine
|
sync
|
sync
|
lbra Monitor
|
lbra Monitor
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Single core sieve.
|
; Single core sieve.
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
sieve:
|
sieve:
|
lda #'P' ; indicate prime
|
lda #'P' ; indicate prime
|
ldx #0 ; start at first char of screen
|
ldx #0 ; start at first char of screen
|
sieve3:
|
sieve3:
|
sta TEXTSCR,x ; store 'P'
|
sta TEXTSCR,x ; store 'P'
|
inx ; advance to next position
|
inx ; advance to next position
|
cmpx #4095
|
cmpx #4095
|
blo sieve3
|
blo sieve3
|
ldb #2 ; start sieve at 2
|
ldb #2 ; start sieve at 2
|
lda #'N' ; flag position value of 'N' for non-prime
|
lda #'N' ; flag position value of 'N' for non-prime
|
sieve2:
|
sieve2:
|
ldx #0
|
ldx #0
|
abx ; skip the first position - might be prime
|
abx ; skip the first position - might be prime
|
sieve1:
|
sieve1:
|
abx ; increment
|
abx ; increment
|
sta TEXTSCR,x
|
sta TEXTSCR,x
|
cmpx #4095
|
cmpx #4095
|
blo multi_sieve1
|
blo multi_sieve1
|
incb ; number of cores working on it
|
incb ; number of cores working on it
|
cmpb #4080
|
cmpb #4080
|
blo sieve2
|
blo sieve2
|
sieve4: ; hang machine
|
sieve4: ; hang machine
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Three second delay for user convenience and to allow some devices time to
|
; Three second delay for user convenience and to allow some devices time to
|
; reset.
|
; reset.
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
Delay3s:
|
Delay3s:
|
ldd #9000000
|
ldd #9000000
|
dly3s1:
|
dly3s1:
|
cmpb #$FF
|
cmpb #$FF
|
bne dly3s2
|
bne dly3s2
|
dly3s2:
|
dly3s2:
|
sta LEDS
|
sta LEDS
|
subd #1
|
subd #1
|
bne dly3s1
|
bne dly3s1
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
ShiftLeft5:
|
ShiftLeft5:
|
aslb
|
aslb
|
rola
|
rola
|
aslb
|
aslb
|
rola
|
rola
|
aslb
|
aslb
|
rola
|
rola
|
aslb
|
aslb
|
rola
|
rola
|
aslb
|
aslb
|
rola
|
rola
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Parameters:
|
; Parameters:
|
; b = core id of core to copy
|
; b = core id of core to copy
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
CopyVirtualScreenToScreen:
|
CopyVirtualScreenToScreen:
|
pshs d,x,y,u
|
pshs d,x,y,u
|
; Compute virtual screen location for core passed in accb.
|
; Compute virtual screen location for core passed in accb.
|
tfr b,a
|
tfr b,a
|
asla
|
asla
|
asla
|
asla
|
asla
|
asla
|
asla
|
asla
|
ora #$C00
|
ora #$C00
|
clrb
|
clrb
|
tfr d,x
|
tfr d,x
|
pshs d
|
pshs d
|
ldy #TEXTSCR
|
ldy #TEXTSCR
|
ldu #56*29/2
|
ldu #COLS*ROWS/2
|
cv2s1:
|
cv2s1:
|
ldd ,x++
|
ldd ,x++
|
std ,y++
|
std ,y++
|
leau -1,u
|
leau -1,u
|
cmpu #0
|
cmpu #0
|
bne cv2s1
|
bne cv2s1
|
; reset the cursor position in the text controller
|
; reset the cursor position in the text controller
|
puls x
|
puls x
|
ldb CursorRow,x
|
ldb CursorRow,x
|
lda #56
|
lda #COLS
|
mul
|
mul
|
tfr d,y
|
tfr d,y
|
ldb CursorCol,x
|
ldb CursorCol,x
|
tfr y,x
|
tfr y,x
|
abx
|
abx
|
stx TEXTREG+TEXT_CURPOS
|
stx TEXTREG+TEXT_CURPOS
|
puls d,x,y,u,pc
|
puls d,x,y,u,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
CopyScreenToVirtualScreen:
|
CopyScreenToVirtualScreen:
|
pshs d,x,y,u
|
pshs d,x,y,u
|
bsr GetScreenLocation
|
bsr GetScreenLocation
|
tfr d,y
|
tfr d,y
|
ldx #TEXTSCR
|
ldx #TEXTSCR
|
ldu #56*29/2
|
ldu #COLS*ROWS/2
|
cs2v1:
|
cs2v1:
|
ldd ,x++
|
ldd ,x++
|
std ,y++
|
std ,y++
|
leau -1,u
|
leau -1,u
|
cmpu #0
|
cmpu #0
|
bne cs2v1
|
bne cs2v1
|
puls d,x,y,u,pc
|
puls d,x,y,u,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
fcb "TEXTSCR "
|
fcb "TEXTSCR "
|
fcw TextOpen
|
fcw TextOpen
|
fcw TextClose
|
fcw TextClose
|
fcw TextRead
|
fcw TextRead
|
fcw TextWrite
|
fcw TextWrite
|
fcw TextSeek
|
fcw TextSeek
|
|
|
TextOpen:
|
TextOpen:
|
rts
|
rts
|
TextClose:
|
TextClose:
|
rts
|
rts
|
TextRead:
|
TextRead:
|
rts
|
rts
|
TextWrite:
|
TextWrite:
|
rts
|
rts
|
TextSeek:
|
TextSeek:
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Clear the screen and the screen color memory
|
; Clear the screen and the screen color memory
|
; We clear the screen to give a visual indication that the system
|
; We clear the screen to give a visual indication that the system
|
; is working at all.
|
; is working at all.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
ClearScreen:
|
ClearScreen:
|
pshs d,x,y,u
|
pshs d,x,y,u
|
ldx #56*29
|
ldx #COLS*ROWS
|
tfr x,u
|
tfr x,u
|
bsr GetScreenLocation
|
bsr GetScreenLocation
|
tfr d,y
|
tfr d,y
|
ldb #' ' ; space char
|
ldb #' ' ; space char
|
cs1:
|
cs1:
|
stb ,y+ ; set text to space
|
stb ,y+ ; set text to space
|
leax -1,x ; decrement x
|
leax -1,x ; decrement x
|
bne cs1
|
bne cs1
|
ldb COREID ; update colors only if we have focus
|
ldb COREID ; update colors only if we have focus
|
cmpb IOFocusID
|
cmpb IOFocusID
|
bra cs3
|
bra cs3
|
ldy #TEXTSCR+$2000
|
ldy #TEXTSCR+$2000
|
; lda CharColor
|
; lda CharColor
|
lda #$0CE
|
lda #$0CE
|
tfr u,x ; get back count
|
tfr u,x ; get back count
|
cs2:
|
cs2:
|
sta ,y+
|
sta ,y+
|
dex ; decrement x
|
dex ; decrement x
|
bne cs2
|
bne cs2
|
cs3:
|
cs3:
|
puls d,x,y,u,pc
|
puls d,x,y,u,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Scroll text on the screen upwards
|
; Scroll text on the screen upwards
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
ScrollUp:
|
ScrollUp:
|
pshs d,x,y,u
|
pshs d,x,y,u
|
ldy #(56*29-1)/2 ; y = num chars/2 to move
|
ldy #(COLS*ROWS-1)/2 ; y = num chars/2 to move
|
bsr GetScreenLocation
|
bsr GetScreenLocation
|
tfr d,x
|
tfr d,x
|
tfr d,u
|
tfr d,u
|
leax 56,x ; x = index to source row
|
leax COLS,x ; x = index to source row
|
scrup1:
|
scrup1:
|
ldd ,x++ ; move 2 characters
|
ldd ,x++ ; move 2 characters
|
std ,u++
|
std ,u++
|
dey
|
dey
|
bne scrup1
|
bne scrup1
|
lda #29
|
lda #ROWS-1
|
bsr BlankLine
|
bsr BlankLine
|
puls d,x,y,u,pc
|
puls d,x,y,u,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Blank out a line on the display
|
; Blank out a line on the display
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
; Parameters:
|
; Parameters:
|
; acca = line number to blank
|
; acca = line number to blank
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
BlankLine:
|
BlankLine:
|
pshs d,x
|
pshs d,x
|
pshs a
|
pshs a
|
bsr GetScreenLocation
|
bsr GetScreenLocation
|
tfr d,x
|
tfr d,x
|
puls a
|
puls a
|
ldb #56 ; b = # chars to blank out from video controller
|
ldb #COLS ; b = # chars to blank out from video controller
|
mul ; d = screen index (row# * #cols)
|
mul ; d = screen index (row# * #cols)
|
leax d,x
|
leax d,x
|
lda #' '
|
lda #' '
|
ldb #56 ; b = # chars to blank out from video controller
|
ldb #COLS ; b = # chars to blank out from video controller
|
blnkln1:
|
blnkln1:
|
sta ,x+
|
sta ,x+
|
decb
|
decb
|
bne blnkln1
|
bne blnkln1
|
puls d,x,pc
|
puls d,x,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Get the location of the screen memory. The location
|
; Get the location of the screen memory. The location
|
; depends on whether or not the task has the output focus.
|
; depends on whether or not the task has the output focus.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; d
|
; d
|
; Retuns:
|
; Retuns:
|
; d = screen location
|
; d = screen location
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
GetScreenLocation:
|
GetScreenLocation:
|
lda COREID ; which core are we?
|
lda COREID ; which core are we?
|
cmpa IOFocusID ; do we have the IO focus
|
cmpa IOFocusID ; do we have the IO focus
|
bne gsl1 ; no, go pick virtual screen address
|
bne gsl1 ; no, go pick virtual screen address
|
ldd #TEXTSCR ; yes, we update the real screen
|
ldd #TEXTSCR ; yes, we update the real screen
|
rts
|
rts
|
gsl1:
|
gsl1:
|
ldd #$7800
|
ldd #$7800
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; HomeCursor
|
; HomeCursor
|
; Set the cursor location to the top left of the screen.
|
; Set the cursor location to the top left of the screen.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
HomeCursor:
|
HomeCursor:
|
pshs d,x
|
pshs d,x
|
clr CursorRow
|
clr CursorRow
|
clr CursorCol
|
clr CursorCol
|
ldb COREID
|
ldb COREID
|
cmpb IOFocusID
|
cmpb IOFocusID
|
bne hc1
|
bne hc1
|
clra
|
clra
|
sta TEXTREG+TEXT_CURPOS
|
sta TEXTREG+TEXT_CURPOS
|
hc1:
|
hc1:
|
puls d,x,pc
|
puls d,x,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Update the cursor position in the text controller based on the
|
; Update the cursor position in the text controller based on the
|
; CursorRow,CursorCol.
|
; CursorRow,CursorCol.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
UpdateCursorPos:
|
UpdateCursorPos:
|
pshs d,x
|
pshs d,x
|
ldb COREID ; update cursor position in text controller
|
ldb COREID ; update cursor position in text controller
|
cmpb IOFocusID ; only for the task with the output focus
|
cmpb IOFocusID ; only for the task with the output focus
|
bne ucp1
|
bne ucp1
|
lda CursorRow
|
lda CursorRow
|
anda #$3F ; limit of 63 rows
|
anda #$3F ; limit of 63 rows
|
ldb TEXTREG+TEXT_COLS
|
ldb TEXTREG+TEXT_COLS
|
mul
|
mul
|
tfr d,x
|
tfr d,x
|
ldb CursorCol
|
ldb CursorCol
|
abx
|
abx
|
stx TEXTREG+TEXT_CURPOS
|
stx TEXTREG+TEXT_CURPOS
|
ucp1:
|
ucp1:
|
puls d,x,pc
|
puls d,x,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Calculate screen memory location from CursorRow,CursorCol.
|
; Calculate screen memory location from CursorRow,CursorCol.
|
; Also refreshes the cursor location.
|
; Also refreshes the cursor location.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; d
|
; d
|
; Returns:
|
; Returns:
|
; d = screen location
|
; d = screen location
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
CalcScreenLoc:
|
CalcScreenLoc:
|
pshs x
|
pshs x
|
lda CursorRow
|
lda CursorRow
|
ldb #56
|
ldb #COLS
|
mul
|
mul
|
tfr d,x
|
tfr d,x
|
ldb CursorCol
|
ldb CursorCol
|
abx
|
abx
|
ldb COREID ; update cursor position in text controller
|
ldb COREID ; update cursor position in text controller
|
cmpb IOFocusID ; only for the task with the output focus
|
cmpb IOFocusID ; only for the task with the output focus
|
bne csl1
|
bne csl1
|
stx TEXTREG+TEXT_CURPOS
|
stx TEXTREG+TEXT_CURPOS
|
csl1:
|
csl1:
|
bsr GetScreenLocation
|
bsr GetScreenLocation
|
leax d,x
|
leax d,x
|
tfr x,d
|
tfr x,d
|
puls x,pc
|
puls x,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Display a character on the screen.
|
; Display a character on the screen.
|
; If the task doesn't have the I/O focus then the character is written to
|
; If the task doesn't have the I/O focus then the character is written to
|
; the virtual screen.
|
; the virtual screen.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
; Parameters:
|
; Parameters:
|
; accb = char to display
|
; accb = char to display
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
DisplayChar:
|
DisplayChar:
|
lbsr SerialPutChar
|
lbsr SerialPutChar
|
pshs d,x
|
pshs d,x
|
cmpb #CR ; carriage return ?
|
cmpb #CR ; carriage return ?
|
bne dccr
|
bne dccr
|
clr CursorCol ; just set cursor column to zero on a CR
|
clr CursorCol ; just set cursor column to zero on a CR
|
bsr UpdateCursorPos
|
bsr UpdateCursorPos
|
dcx14:
|
dcx14:
|
lbra dcx4
|
lbra dcx4
|
dccr:
|
dccr:
|
cmpb #$91 ; cursor right ?
|
cmpb #$91 ; cursor right ?
|
bne dcx6
|
bne dcx6
|
lda CursorCol
|
lda CursorCol
|
cmpa #56
|
cmpa #COLS
|
bhs dcx7
|
bhs dcx7
|
inca
|
inca
|
sta CursorCol
|
sta CursorCol
|
dcx7:
|
dcx7:
|
bsr UpdateCursorPos
|
bsr UpdateCursorPos
|
puls d,x,pc
|
puls d,x,pc
|
dcx6:
|
dcx6:
|
cmpb #$90 ; cursor up ?
|
cmpb #$90 ; cursor up ?
|
bne dcx8
|
bne dcx8
|
lda CursorRow
|
lda CursorRow
|
beq dcx7
|
beq dcx7
|
deca
|
deca
|
sta CursorRow
|
sta CursorRow
|
bra dcx7
|
bra dcx7
|
dcx8:
|
dcx8:
|
cmpb #$93 ; cursor left ?
|
cmpb #$93 ; cursor left ?
|
bne dcx9
|
bne dcx9
|
lda CursorCol
|
lda CursorCol
|
beq dcx7
|
beq dcx7
|
deca
|
deca
|
sta CursorCol
|
sta CursorCol
|
bra dcx7
|
bra dcx7
|
dcx9:
|
dcx9:
|
cmpb #$92 ; cursor down ?
|
cmpb #$92 ; cursor down ?
|
bne dcx10
|
bne dcx10
|
lda CursorRow
|
lda CursorRow
|
cmpa #29
|
cmpa #ROWS
|
beq dcx7
|
beq dcx7
|
inca
|
inca
|
sta CursorRow
|
sta CursorRow
|
bra dcx7
|
bra dcx7
|
dcx10:
|
dcx10:
|
cmpb #$94 ; cursor home ?
|
cmpb #$94 ; cursor home ?
|
bne dcx11
|
bne dcx11
|
lda CursorCol
|
lda CursorCol
|
beq dcx12
|
beq dcx12
|
clr CursorCol
|
clr CursorCol
|
bra dcx7
|
bra dcx7
|
dcx12:
|
dcx12:
|
clr CursorRow
|
clr CursorRow
|
bra dcx7
|
bra dcx7
|
dcx11:
|
dcx11:
|
cmpb #$99 ; delete ?
|
cmpb #$99 ; delete ?
|
bne dcx13
|
bne dcx13
|
bsr CalcScreenLoc
|
bsr CalcScreenLoc
|
tfr d,x
|
tfr d,x
|
lda CursorCol ; acc = cursor column
|
lda CursorCol ; acc = cursor column
|
bra dcx5
|
bra dcx5
|
dcx13
|
dcx13
|
cmpb #CTRLH ; backspace ?
|
cmpb #CTRLH ; backspace ?
|
bne dcx3
|
bne dcx3
|
lda CursorCol
|
lda CursorCol
|
beq dcx4
|
beq dcx4
|
deca
|
deca
|
sta CursorCol
|
sta CursorCol
|
bsr CalcScreenLoc
|
bsr CalcScreenLoc
|
tfr d,x
|
tfr d,x
|
lda CursorCol
|
lda CursorCol
|
dcx5:
|
dcx5:
|
ldb 1,x
|
ldb 1,x
|
stb ,x++
|
stb ,x++
|
inca
|
inca
|
cmpa #56
|
cmpa #COLS
|
blo dcx5
|
blo dcx5
|
ldb #' '
|
ldb #' '
|
dex
|
dex
|
stb ,x
|
stb ,x
|
bra dcx4
|
bra dcx4
|
dcx3:
|
dcx3:
|
cmpb #LF ; linefeed ?
|
cmpb #LF ; linefeed ?
|
beq dclf
|
beq dclf
|
pshs b
|
pshs b
|
bsr CalcScreenLoc
|
bsr CalcScreenLoc
|
tfr d,x
|
tfr d,x
|
puls b
|
puls b
|
stb ,x
|
stb ,x
|
; ToDo character color
|
; ToDo character color
|
; lda CharColor
|
; lda CharColor
|
; sta $2000,x
|
; sta $2000,x
|
bsr IncCursorPos
|
bsr IncCursorPos
|
bra dcx4
|
bra dcx4
|
dclf:
|
dclf:
|
bsr IncCursorRow
|
bsr IncCursorRow
|
dcx4:
|
dcx4:
|
puls d,x,pc
|
puls d,x,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Increment the cursor position, scroll the screen if needed.
|
; Increment the cursor position, scroll the screen if needed.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
IncCursorPos:
|
IncCursorPos:
|
pshs d,x
|
pshs d,x
|
lda CursorCol
|
lda CursorCol
|
inca
|
inca
|
sta CursorCol
|
sta CursorCol
|
cmpa #56
|
cmpa #COLS
|
blo icc1
|
blo icc1
|
clr CursorCol ; column = 0
|
clr CursorCol ; column = 0
|
bra icr1
|
bra icr1
|
IncCursorRow:
|
IncCursorRow:
|
pshs d,x
|
pshs d,x
|
icr1:
|
icr1:
|
lda CursorRow
|
lda CursorRow
|
inca
|
inca
|
sta CursorRow
|
sta CursorRow
|
cmpa #29
|
cmpa #ROWS
|
blo icc1
|
blo icc1
|
deca ; backup the cursor row, we are scrolling up
|
deca ; backup the cursor row, we are scrolling up
|
sta CursorRow
|
sta CursorRow
|
bsr ScrollUp
|
bsr ScrollUp
|
icc1:
|
icc1:
|
bsr UpdateCursorPos
|
bsr UpdateCursorPos
|
icc2:
|
icc2:
|
puls d,x,pc
|
puls d,x,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Display a string on the screen.
|
; Display a string on the screen.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; none
|
; none
|
; Parameters:
|
; Parameters:
|
; d = pointer to string
|
; d = pointer to string
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
DisplayString:
|
DisplayString:
|
pshs d,x
|
pshs d,x
|
tfr d,x
|
tfr d,x
|
dspj2: ; lock semaphore for access
|
dspj2: ; lock semaphore for access
|
lda OUTSEMA+1
|
lda OUTSEMA+1
|
beq dspj2
|
beq dspj2
|
dspj1B:
|
dspj1B:
|
ldb ,x+ ; move string char into acc
|
ldb ,x+ ; move string char into acc
|
beq dsretB ; is it end of string ?
|
beq dsretB ; is it end of string ?
|
lbsr OUTCH ; display character
|
lbsr OUTCH ; display character
|
bra dspj1B
|
bra dspj1B
|
dsretB:
|
dsretB:
|
clr OUTSEMA+1 ; unlock semaphore
|
clr OUTSEMA+1 ; unlock semaphore
|
puls d,x,pc
|
puls d,x,pc
|
|
|
DisplayStringCRLF:
|
DisplayStringCRLF:
|
pshs d
|
pshs d
|
bsr DisplayString
|
bsr DisplayString
|
ldb #CR
|
ldb #CR
|
lbsr OUTCH
|
lbsr OUTCH
|
ldb #LF
|
ldb #LF
|
lbsr OUTCH
|
lbsr OUTCH
|
puls d,pc
|
puls d,pc
|
|
|
;
|
;
|
; PRINT CR, LF, STRING
|
; PRINT CR, LF, STRING
|
;
|
;
|
PSTRNG
|
PSTRNG
|
BSR PCRLF
|
BSR PCRLF
|
BRA PDATA
|
BRA PDATA
|
PCRLF
|
PCRLF
|
PSHS X
|
PSHS X
|
LDX #CRLFST
|
LDX #CRLFST
|
BSR PDATA
|
BSR PDATA
|
PULS X
|
PULS X
|
RTS
|
RTS
|
|
|
PRINT
|
PRINT
|
JSR OUTCH
|
JSR OUTCH
|
PDATA
|
PDATA
|
LDB ,X+
|
LDB ,X+
|
CMPB #$04
|
CMPB #$04
|
BNE PRINT
|
BNE PRINT
|
RTS
|
RTS
|
|
|
CRLFST
|
CRLFST
|
fcb CR,LF,4
|
fcb CR,LF,4
|
|
|
DispDWordAsHex:
|
DispDWordAsHex:
|
bsr DispWordAsHex
|
bsr DispWordAsHex
|
exg d,x
|
exg d,x
|
bsr DispWordAsHex
|
bsr DispWordAsHex
|
exg d,x
|
exg d,x
|
rts
|
rts
|
|
|
DispWordAsHex:
|
DispWordAsHex:
|
exg a,b
|
exg a,b
|
bsr DispByteAsHex
|
bsr DispByteAsHex
|
exg a,b
|
exg a,b
|
bsr DispByteAsHex
|
bsr DispByteAsHex
|
rts
|
rts
|
|
|
DispByteAsHex:
|
DispByteAsHex:
|
pshs b
|
pshs b
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
bsr DispNyb
|
bsr DispNyb
|
puls b
|
puls b
|
pshs b
|
pshs b
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
lsrb
|
bsr DispNyb
|
bsr DispNyb
|
puls b
|
puls b
|
|
|
DispNyb
|
DispNyb
|
pshs b
|
pshs b
|
andb #$0F
|
andb #$0F
|
cmpb #10
|
cmpb #10
|
blo DispNyb1
|
blo DispNyb1
|
addb #'A'-10
|
addb #'A'-10
|
lbsr OUTCH
|
lbsr OUTCH
|
puls b,pc
|
puls b,pc
|
DispNyb1
|
DispNyb1
|
addb #'0'
|
addb #'0'
|
lbsr OUTCH
|
lbsr OUTCH
|
puls b,pc
|
puls b,pc
|
|
|
;==============================================================================
|
;==============================================================================
|
; Timer
|
; Timer
|
;==============================================================================
|
;==============================================================================
|
|
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\timer.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\timer.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\i2c.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\i2c.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\rtc_driver.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\rtc_driver.asm"
|
|
|
;==============================================================================
|
;==============================================================================
|
; Keyboard I/O
|
; Keyboard I/O
|
;==============================================================================
|
;==============================================================================
|
|
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\scancodes.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\scancodes.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\keyboard.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\keyboard.asm"
|
|
|
fcb "KEYBOARD"
|
fcb "KEYBOARD"
|
fcw KeybdOpen
|
fcw KeybdOpen
|
fcw KeybdClose
|
fcw KeybdClose
|
fcw KeybdRead
|
fcw KeybdRead
|
fcw KeybdWrite
|
fcw KeybdWrite
|
fcw KeybdSeek
|
fcw KeybdSeek
|
|
|
; Keyboard Open:
|
; Keyboard Open:
|
; Initialize the keyboard buffer head and tail indexes
|
; Initialize the keyboard buffer head and tail indexes
|
;
|
;
|
KeybdOpen:
|
KeybdOpen:
|
rts
|
rts
|
|
|
; Keyboard Close:
|
; Keyboard Close:
|
; Nothing to do except maybe clear the keyboard buffer
|
; Nothing to do except maybe clear the keyboard buffer
|
;
|
;
|
KeybdClose:
|
KeybdClose:
|
rts
|
rts
|
;
|
;
|
KeybdRead:
|
KeybdRead:
|
rts
|
rts
|
;
|
;
|
KeybdWrite:
|
KeybdWrite:
|
rts
|
rts
|
|
|
KeybdSeek:
|
KeybdSeek:
|
rts
|
rts
|
|
|
;==============================================================================
|
;==============================================================================
|
; Serial I/O
|
; Serial I/O
|
;==============================================================================
|
;==============================================================================
|
|
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\serial.asm"
|
OPT INCLUDE "d:\cores2022\rf6809\software\boot\serial.asm"
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Check if there is a keyboard character available. If so return true (<0)
|
; Check if there is a keyboard character available. If so return true (<0)
|
; otherwise return false (0) in accb.
|
; otherwise return false (0) in accb.
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
KeybdCheckForKeyDirect:
|
KeybdCheckForKeyDirect:
|
bra DBGCheckForKey
|
bra DBGCheckForKey
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
INCH:
|
INCH:
|
pshs b
|
pshs b
|
INCH2:
|
INCH2:
|
ldb COREID
|
ldb COREID
|
cmpb IOFocusID ; if we do not have focus, block
|
cmpb IOFocusID ; if we do not have focus, block
|
bne INCH2
|
bne INCH2
|
; ldb #$800 ; block if no key available, get scancode directly
|
; ldb #$800 ; block if no key available, get scancode directly
|
; bra GetKey
|
; bra GetKey
|
; jsr [CharInVec] ; vector is being overwritten somehow
|
; jsr [CharInVec] ; vector is being overwritten somehow
|
lbsr SerialPeekCharDirect
|
lbsr SerialPeekCharDirect
|
tsta
|
tsta
|
bmi INCH1 ; block if no key available
|
bmi INCH1 ; block if no key available
|
leas 1,s ; get rid of blocking status
|
leas 1,s ; get rid of blocking status
|
rts
|
rts
|
INCH1:
|
INCH1:
|
puls b ; check blocking status
|
puls b ; check blocking status
|
tstb
|
tstb
|
bmi INCH ; if blocking, loop
|
bmi INCH ; if blocking, loop
|
ldd #-1 ; return -1 if no char available
|
ldd #-1 ; return -1 if no char available
|
rts
|
rts
|
|
|
INCHE:
|
INCHE:
|
bsr INCH
|
bsr INCH
|
bra INCHEK3
|
bra INCHEK3
|
|
|
INCHEK:
|
INCHEK:
|
bsr INCH
|
bsr INCH
|
tst KeybdEcho
|
tst KeybdEcho
|
beq INCHEK1
|
beq INCHEK1
|
INCHEK3:
|
INCHEK3:
|
cmpa #CR
|
cmpa #CR
|
bne INCHEK2
|
bne INCHEK2
|
lbsr CRLF
|
lbsr CRLF
|
bra INCHEK1
|
bra INCHEK1
|
INCHEK2:
|
INCHEK2:
|
lbsr DisplayChar
|
lbsr DisplayChar
|
INCHEK1:
|
INCHEK1:
|
rts
|
rts
|
|
|
OUTCH:
|
OUTCH:
|
jmp [CharOutVec]
|
jmp [CharOutVec]
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; r1 0=echo off, non-zero = echo on
|
; r1 0=echo off, non-zero = echo on
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
SetKeyboardEcho:
|
SetKeyboardEcho:
|
stb KeybdEcho
|
stb KeybdEcho
|
rts
|
rts
|
|
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Parameters:
|
; Parameters:
|
; x,d bitmap of sprites to enable
|
; x,d bitmap of sprites to enable
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
ShowSprites:
|
ShowSprites:
|
stx SPRITE_CTRL+SPRITE_EN
|
stx SPRITE_CTRL+SPRITE_EN
|
std SPRITE_CTRL+SPRITE_EN+2
|
std SPRITE_CTRL+SPRITE_EN+2
|
rts
|
rts
|
|
|
;==============================================================================
|
;==============================================================================
|
; Femtiki Operating System.
|
; Femtiki Operating System.
|
;==============================================================================
|
;==============================================================================
|
|
|
OSCallTbl:
|
OSCallTbl:
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw 0
|
fcw ReleaseIOFocus
|
fcw ReleaseIOFocus
|
fcw 0
|
fcw 0
|
fcw RequestIOFocus
|
fcw RequestIOFocus
|
|
|
OSCall:
|
NumOSFuncs EQU (*-OSCallTbl)/2
|
; wait for availability
|
|
osc1:
|
|
tst OSSEMA+1
|
|
beq osc1
|
|
aslb
|
|
ldx #OSCallTbl
|
|
abx
|
|
tst ,x
|
|
beq oscx
|
|
jmp [,x]
|
|
oscx:
|
|
clr OSSEMA+1
|
|
rts
|
|
|
|
RequestIOFocus:
|
RequestIOFocus:
|
ldb COREID
|
ldb COREID
|
ldx #IOFocusList
|
ldx #IOFocusList
|
abx
|
abx
|
sta ,x
|
sta ,x
|
tst IOFocusID
|
tst IOFocusID
|
lbne oscx
|
lbne oscx
|
stb IOFocusID
|
stb IOFocusID
|
lbra oscx
|
lbra oscx
|
|
|
ReleaseIOFocus:
|
ReleaseIOFocus:
|
ldb COREID
|
ldb COREID
|
ldx #IOFocusList
|
ldx #IOFocusList
|
abx
|
abx
|
clr ,x ; clear the request indicator
|
clr ,x ; clear the request indicator
|
lbsr CopyScreenToVirtualScreen
|
lbsr CopyScreenToVirtualScreen
|
cmpb IOFocusID ; are we the one with the focus?
|
cmpb IOFocusID ; are we the one with the focus?
|
lbne oscx
|
lbne oscx
|
; We had the focus, so now a new core needs the focus.
|
; We had the focus, so now a new core needs the focus.
|
; Search the focus list for a requestor. If no requester
|
; Search the focus list for a requestor. If no requester
|
; is found, give focus to core #1.
|
; is found, give focus to core #1.
|
lda #15
|
lda #15
|
riof2:
|
riof2:
|
incb
|
incb
|
andb #15
|
andb #15
|
abx
|
abx
|
tst ,x
|
tst ,x
|
bne riof1
|
bne riof1
|
deca
|
deca
|
bne riof2
|
bne riof2
|
; If no focus is requested by anyone, give to core #1
|
; If no focus is requested by anyone, give to core #1
|
ldb #1
|
ldb #1
|
lda #24
|
lda #24
|
sta ,x
|
sta ,x
|
riof1:
|
riof1:
|
stb IOFocusID
|
stb IOFocusID
|
lbsr CopyVirtualScreenToScreen
|
lbsr CopyVirtualScreenToScreen
|
lbra oscx
|
lbra oscx
|
|
|
|
|
;==============================================================================
|
;==============================================================================
|
; Disassembler
|
|
;==============================================================================
|
;==============================================================================
|
|
|
OPT include "d:\cores2022\rf6809\software\boot\disassem.asm"
|
;------------------------------------------------------------------------------
|
|
; Seed the random number generator. All channels are seeded with the same
|
|
; value.
|
|
;
|
|
; Parameters:
|
|
; d = 'z' part of seed
|
|
; x = 'w' part of seed
|
|
; Returns:
|
|
; none
|
|
;------------------------------------------------------------------------------
|
|
|
|
mon_srand:
|
|
ldy #0
|
|
mon_srand1:
|
|
sty PRNG+4 ; select channel
|
|
clr PRNG+8
|
|
clr PRNG+9
|
|
std PRNG+10 ; update low half of value
|
|
clr PRNG+12
|
|
clr PRNG+13
|
|
stx PRNG+14 ; update low half of value
|
|
iny
|
|
cmpy #$400 ; 1k channels
|
|
blo mon_srand1
|
|
rts
|
|
|
|
;------------------------------------------------------------------------------
|
|
; Get a random number and generate the next one.
|
|
;
|
|
; Parameters:
|
|
; d = channel to use
|
|
; Returns:
|
|
; x,d = 36 bit random value
|
|
;------------------------------------------------------------------------------
|
|
|
|
mon_rand:
|
|
std PRNG+4 ; select channel
|
|
ldx PRNG+0
|
|
ldd PRNG+2
|
|
stb PRNG+3 ; trigger calc of next number
|
|
rts
|
|
|
;==============================================================================
|
;==============================================================================
|
; System Monitor
|
; System Monitor
|
;==============================================================================
|
;==============================================================================
|
|
|
|
; Command Tables
|
|
|
|
cmdTable1:
|
|
fcb '<','>'+$800
|
|
fcb 'b','s'+$800
|
|
fcb 'b','c'+$800
|
|
fcb 'D','R'+$800
|
|
fcb 'D'+$800
|
|
fcb ':'+$800
|
|
fcb "FI",'G'+$800
|
|
fcb "FI",'L'+$800
|
|
fcb 'F','L'+$800
|
|
fcb 'J'+$800
|
|
fcb "RAMTES",'T'+$800
|
|
fcb "SP",'D'+$800
|
|
fcb "TI",'R'+$800
|
|
fcb 'U'+$800
|
|
fcb "exi",'t'+$800
|
|
fcb '?'+$800
|
|
fcb "CL",'S'+$800
|
|
fcw 0
|
|
|
|
cmdTable2:
|
|
fcw Redirect
|
|
fcw ArmBreakpoint
|
|
fcw DisarmBreakpoint
|
|
fcw DumpRegs
|
|
fcw DumpMemory
|
|
fcw EditMemory
|
|
fcw $FE0000 ; FIG forth
|
|
fcw FillMemory
|
|
fcw DumpIOFocusList
|
|
fcw jump_to_code
|
|
fcw dramtest
|
|
fcw $FF8000 ; sprite demo
|
|
fcw rtc_read
|
|
fcw $FF8003 ; unassembler
|
|
fcw xitMonitor
|
|
fcw PromptHelp
|
|
fcw PromptClearscreen
|
|
|
CmdPrompt:
|
CmdPrompt:
|
lbsr CRLF
|
lbsr CRLF
|
ldb #'$'
|
ldb #'$'
|
lbsr OUTCH
|
lbsr OUTCH
|
lbra OUTCH
|
lbra OUTCH
|
|
|
msgF09Starting:
|
msgF09Starting:
|
fcb "Femtiki F09 Multi-core OS Starting",CR,LF,0
|
fcb "Femtiki F09 Multi-core OS Starting",CR,LF,0
|
|
|
MonitorStart:
|
MonitorStart:
|
|
clr BreakpointFlag
|
|
clr NumSetBreakpoints
|
|
ldd #123
|
|
ldx #654
|
|
lbsr mon_srand
|
ldd #msgF09Starting
|
ldd #msgF09Starting
|
lbsr DisplayString
|
lbsr DisplayString
|
ldd #HelpMsg
|
ldd #HelpMsg
|
lbsr DisplayString
|
lbsr DisplayString
|
ldd #CmdPrompt
|
ldd #CmdPrompt
|
std CmdPromptJI
|
std CmdPromptJI
|
ldd #DisplayErr
|
ldd #DisplayErr
|
std MonErrVec
|
std MonErrVec
|
ldd #$63FF ; default app stack
|
ldd #$63FF ; default app stack
|
std mon_SSAVE
|
std mon_SSAVE
|
|
clr mon_DPRSAVE ;
|
|
tfr ccr,a
|
|
sta mon_CCRSAVE
|
|
clr mon_PCSAVE
|
|
ldd #Monitor
|
|
std mon_PCSAVE+1
|
|
clr mon_XSAVE
|
|
clr mon_YSAVE
|
|
clr mon_USAVE
|
Monitor:
|
Monitor:
|
leas $6FFF ; reset stack pointer
|
leas $6FFF ; reset stack pointer
|
clrb ; turn off keyboard echo
|
clrb ; turn off keyboard echo
|
lbsr SetKeyboardEcho
|
lbsr SetKeyboardEcho
|
; Reset IO vectors
|
; Reset IO vectors
|
ldd #SerialPeekCharDirect
|
ldd #SerialPeekCharDirect
|
std CharInVec
|
std CharInVec
|
ldd #DisplayChar
|
ldd #DisplayChar
|
std CharOutVec
|
std CharOutVec
|
ldd #CmdPrompt
|
ldd #CmdPrompt
|
std CmdPromptJI
|
std CmdPromptJI
|
; jsr RequestIOFocus
|
; jsr RequestIOFocus
|
PromptLn:
|
PromptLn:
|
jsr [CmdPromptJI]
|
jsr [CmdPromptJI]
|
|
|
; Get characters until a CR is keyed
|
; Get characters until a CR is keyed
|
|
|
Prompt3:
|
Prompt3:
|
ldd #-1 ; block until key present
|
ldd #-1 ; block until key present
|
lbsr INCH
|
lbsr INCH
|
cmpb #CR
|
cmpb #CR ; carriage return?
|
beq Prompt1
|
beq Prompt1
|
lbsr OUTCH
|
lbsr OUTCH ; spit out the character
|
bra Prompt3
|
bra Prompt3 ; and keep going
|
|
|
; Process the screen line that the CR was keyed on
|
; Process the screen line that the CR was keyed on
|
;
|
;
|
Prompt1:
|
Prompt1:
|
ldd #$5050
|
ldd #$5050
|
std LEDS
|
std LEDS
|
; ldb RunningID
|
; ldb RunningID
|
; cmpb #61
|
; cmpb #61
|
; bhi Prompt3
|
; bhi Prompt3
|
ldd #$5151
|
|
std LEDS
|
|
clr CursorCol ; go back to the start of the line
|
clr CursorCol ; go back to the start of the line
|
lbsr CalcScreenLoc ; calc screen memory location
|
lbsr CalcScreenLoc ; calc screen memory location
|
tfr d,y
|
tfr d,y
|
ldd #$5252
|
|
std LEDS
|
|
skipDollar:
|
skipDollar:
|
bsr MonGetNonSpace
|
bsr MonGetNonSpace
|
cmpb #'$'
|
cmpb #'$'
|
beq skipDollar ; skip over '$' prompt character
|
beq skipDollar ; skip over '$' prompt character
|
lda #$5353
|
|
std LEDS
|
|
|
|
; Dispatch based on command character
|
; Dispatch based on command
|
;
|
;
|
Prompt2:
|
dey
|
cmpb #'<'
|
tfr y,u ; save off input position
|
bne PromptHelp
|
clrb
|
bsr MonGetch
|
ldx #cmdTable1
|
cmpb #'>'
|
parseCmd1:
|
bne Monitor
|
lda ,y+ ; get input character
|
|
tst ,x ; test for end of command
|
|
bmi endOfWord ;
|
|
cmpa ,x+ ; does input match command?
|
|
beq parseCmd1
|
|
scanNextWord:
|
|
tst ,x+
|
|
beq Monitor ; if end of table reached, not a command
|
|
bpl scanNextWord
|
|
incb
|
|
tfr u,y ; reset input pointer
|
|
bra parseCmd1 ; try again
|
|
endOfWord:
|
|
eora ,x
|
|
asla
|
|
bne scanNextWord
|
|
; we found the command in the table
|
|
aslb ; b = word index
|
|
ldx #cmdTable2
|
|
jmp [b,x] ; execute command
|
|
|
|
Redirect:
|
bsr MonGetch
|
bsr MonGetch
|
cmpb #'s'
|
cmpb #'s'
|
bne Prompt2a
|
bne Prompt2a
|
ldd #SerialPeekCharDirect
|
ldd #SerialPeekCharDirect
|
std CharInVec
|
std CharInVec
|
ldd #SerialPutChar
|
ldd #SerialPutChar
|
std CharOutVec
|
std CharOutVec
|
bra Monitor
|
bra Monitor
|
Prompt2a:
|
Prompt2a:
|
cmpb #'c'
|
cmpb #'c'
|
bne Monitor
|
bne Monitor
|
ldd #GetKey
|
ldd #GetKey
|
std CharInVec
|
std CharInVec
|
ldd #DisplayChar
|
ldd #DisplayChar
|
std CharOutVec
|
std CharOutVec
|
bra Monitor
|
bra Monitor
|
|
|
PromptHelp:
|
PromptHelp:
|
cmpb #'?' ; $? - display help
|
|
bne PromptC
|
|
ldd #HelpMsg
|
ldd #HelpMsg
|
lbsr DisplayString
|
lbsr DisplayString
|
bra Monitor
|
bra Monitor
|
PromptC:
|
|
cmpb #'C'
|
PromptClearscreen:
|
bne PromptD
|
|
lbsr ClearScreen
|
lbsr ClearScreen
|
lbsr HomeCursor
|
lbsr HomeCursor
|
bra Monitor
|
bra Monitor
|
PromptD:
|
|
cmpb #'D'
|
|
bne PromptColon
|
|
bsr MonGetch
|
|
cmpb #'R'
|
|
bne DumpMemory
|
|
bra DumpRegs
|
|
PromptColon:
|
|
cmpb #':'
|
|
bne PromptF
|
|
lbra EditMemory
|
|
PromptF:
|
|
cmpb #'F'
|
|
bne PromptJ
|
|
bsr MonGetch
|
|
cmpb #'I'
|
|
bne PromptFL
|
|
bsr MonGetch
|
|
cmpb #'G'
|
|
bne Monitor
|
|
jmp $FE0000
|
|
PromptFL:
|
|
cmpb #'L'
|
|
bne Monitor
|
|
lbra DumpIOFocusList
|
|
PromptJ:
|
|
cmpb #'J'
|
|
lbeq jump_to_code
|
|
PromptR:
|
|
cmpb #'R'
|
|
bne Prompt_s
|
|
ldu #Monitor
|
|
lbra ramtest
|
|
Prompt_s:
|
|
cmpb #'s'
|
|
bne PromptT
|
|
lbsr SerialOutputTest
|
|
bra Monitor
|
|
PromptT:
|
|
cmpb #'T'
|
|
bne PromptU
|
|
bsr MonGetch
|
|
cmpb #'I'
|
|
bne Monitor
|
|
bsr MonGetch
|
|
cmpb #'R'
|
|
bne Monitor
|
|
lbsr rtc_read
|
|
bra Monitor
|
|
PromptU:
|
|
cmpb #'U'
|
|
bne Monitor
|
|
lbra disassem
|
|
|
|
MonGetch:
|
MonGetch:
|
ldb ,y
|
ldb ,y
|
iny
|
iny
|
rts
|
rts
|
|
|
MonGetNonSpace:
|
MonGetNonSpace:
|
bsr MonGetCh
|
bsr MonGetCh
|
cmpb #' '
|
cmpb #' '
|
beq MonGetNonSpace
|
beq MonGetNonSpace
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Ignore blanks in the input
|
; Ignore blanks in the input
|
; Y = text pointer
|
; Y = text pointer
|
; D destroyed
|
; D destroyed
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
ignBlanks:
|
ignBlanks:
|
ignBlanks1:
|
ignBlanks1:
|
bsr MonGetch
|
bsr MonGetch
|
cmpb #' '
|
cmpb #' '
|
beq ignBlanks1
|
beq ignBlanks1
|
dey
|
dey
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
; Multiply number in work area by 10.
|
|
;------------------------------------------------------------------------------
|
|
Times10:
|
|
ldd mon_numwka ; make a copy of the number
|
|
std mon_numwka+8
|
|
ldd mon_numwka+2
|
|
std mon_numwka+10
|
|
asl mon_numwka+3 ; shift left = *2
|
|
rol mon_numwka+2
|
|
rol mon_numwka+1
|
|
rol mon_numwka+0
|
|
asl mon_numwka+3 ; shift left = *4
|
|
rol mon_numwka+2
|
|
rol mon_numwka+1
|
|
rol mon_numwka+0
|
|
ldd mon_numwka+2 ; add in original value
|
|
addd mon_numwka+10 ; = *5
|
|
ldb mon_numwka+1
|
|
adcb mon_numwka+9
|
|
stb mon_numwka+1
|
|
lda mon_numwka+0
|
|
adca mon_numwka+8
|
|
sta mon_numwka+0
|
|
asl mon_numwka+3 ; shift left = * 10
|
|
rol mon_numwka+2
|
|
rol mon_numwka+1
|
|
rol mon_numwka+0
|
|
rts
|
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
GetTwoParams:
|
GetTwoParams:
|
bsr ignBlanks
|
bsr ignBlanks
|
bsr GetHexNumber ; get start address of dump
|
bsr GetHexNumber ; get start address of dump
|
ldd mon_numwka
|
ldd mon_numwka
|
std mon_r1
|
std mon_r1
|
ldd mon_numwka+2
|
ldd mon_numwka+2
|
std mon_r1+2
|
std mon_r1+2
|
bsr ignBlanks
|
bsr ignBlanks
|
bsr GetHexNumber ; get end address of dump
|
bsr GetHexNumber ; get end address of dump
|
ldd mon_numwka
|
ldd mon_numwka
|
std mon_r2
|
std mon_r2
|
ldd mon_numwka+2
|
ldd mon_numwka+2
|
std mon_r2+2
|
std mon_r2+2
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Get a range, the end must be greater or equal to the start.
|
; Get a range, the end must be greater or equal to the start.
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
GetRange:
|
GetRange:
|
bsr GetTwoParams
|
bsr GetTwoParams
|
ldd mon_r2+2
|
ldd mon_r2+2
|
subd mon_r1+2
|
subd mon_r1+2
|
ldd mon_r2
|
ldd mon_r2
|
sbcb mon_r1+1
|
sbcb mon_r1+1
|
sbca mon_r1
|
sbca mon_r1
|
lbcc grng1
|
lbcc grng1
|
jsr [MonErrVec]
|
jsr [MonErrVec]
|
lbra Monitor
|
lbra Monitor
|
grng1:
|
grng1:
|
rts
|
rts
|
|
|
shl_numwka:
|
shl_numwka:
|
asl mon_numwka+3
|
asl mon_numwka+3
|
rol mon_numwka+2
|
rol mon_numwka+2
|
rol mon_numwka+1
|
rol mon_numwka+1
|
rol mon_numwka
|
rol mon_numwka
|
rts
|
rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Get a hexidecimal number. Maximum of twelve digits.
|
; Get a hexidecimal number. Maximum of twelve digits.
|
;
|
;
|
; Modifies:
|
; Modifies:
|
; Y = text pointer (updated)
|
; Y = text pointer (updated)
|
; D = number of digits
|
; D = number of digits
|
; mon_numwka contains number
|
; mon_numwka contains number
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
GetHexNumber:
|
GetHexNumber:
|
clrd
|
clrd
|
std mon_numwka ; zero out work area
|
std mon_numwka ; zero out work area
|
std mon_numwka+2
|
std mon_numwka+2
|
pshs x
|
pshs x
|
ldx #0 ; max 12 eight digits
|
ldx #0 ; max 12 eight digits
|
gthxn2:
|
gthxn2:
|
bsr MonGetch
|
bsr MonGetch
|
bsr AsciiToHexNybble
|
bsr AsciiToHexNybble
|
cmpb #-1
|
cmpb #-1
|
beq gthxn1
|
beq gthxn1
|
bsr shl_numwka
|
bsr shl_numwka
|
bsr shl_numwka
|
bsr shl_numwka
|
bsr shl_numwka
|
bsr shl_numwka
|
bsr shl_numwka
|
bsr shl_numwka
|
andb #$0f
|
andb #$0f
|
orb mon_numwka+3
|
orb mon_numwka+3
|
stb mon_numwka+3
|
stb mon_numwka+3
|
inx
|
inx
|
cmpx #12
|
cmpx #12
|
blo gthxn2
|
blo gthxn2
|
gthxn1:
|
gthxn1:
|
tfr x,d
|
tfr x,d
|
puls x,pc
|
puls x,pc
|
|
|
;GetDecNumber:
|
;GetDecNumber:
|
; phx
|
; phx
|
; push r4
|
; push r4
|
; push r5
|
; push r5
|
; ldx #0
|
; ldx #0
|
; ld r4,#10
|
; ld r4,#10
|
; ld r5,#10
|
; ld r5,#10
|
;gtdcn2:
|
;gtdcn2:
|
; jsr MonGetch
|
; jsr MonGetch
|
; jsr AsciiToDecNybble
|
; jsr AsciiToDecNybble
|
; cmp #-1
|
; cmp #-1
|
; beq gtdcn1
|
; beq gtdcn1
|
; mul r2,r2,r5
|
; mul r2,r2,r5
|
; add r2,r1
|
; add r2,r1
|
; dec r4
|
; dec r4
|
; bne gtdcn2
|
; bne gtdcn2
|
;gtdcn1:
|
;gtdcn1:
|
; txa
|
; txa
|
; pop r5
|
; pop r5
|
; pop r4
|
; pop r4
|
; plx
|
; plx
|
; rts
|
; rts
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Convert ASCII character in the range '0' to '9', 'a' to 'f' or 'A' to 'F'
|
; Convert ASCII character in the range '0' to '9', 'a' to 'f' or 'A' to 'F'
|
; to a hex nybble.
|
; to a hex nybble.
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;
|
;
|
AsciiToHexNybble:
|
AsciiToHexNybble:
|
cmpb #'0'
|
cmpb #'0'
|
blo gthx3
|
blo gthx3
|
cmpb #'9'
|
cmpb #'9'
|
bhi gthx5
|
bhi gthx5
|
subb #'0'
|
subb #'0'
|
rts
|
rts
|
gthx5:
|
gthx5:
|
cmpb #'A'
|
cmpb #'A'
|
blo gthx3
|
blo gthx3
|
cmpb #'F'
|
cmpb #'F'
|
bhi gthx6
|
bhi gthx6
|
subb #'A'
|
subb #'A'
|
addb #10
|
addb #10
|
rts
|
rts
|
gthx6:
|
gthx6:
|
cmpb #'a'
|
cmpb #'a'
|
blo gthx3
|
blo gthx3
|
cmpb #'z'
|
cmpb #'z'
|
bhi gthx3
|
bhi gthx3
|
subb #'a'
|
subb #'a'
|
addb #10
|
addb #10
|
rts
|
rts
|
gthx3:
|
gthx3:
|
ldb #-1 ; not a hex number
|
ldb #-1 ; not a hex number
|
rts
|
rts
|
|
|
AsciiToDecNybble:
|
AsciiToDecNybble:
|
cmpb #'0'
|
cmpb #'0'
|
bcc gtdc3
|
bcc gtdc3
|
cmpb #'9'+1
|
cmpb #'9'+1
|
bcs gtdc3
|
bcs gtdc3
|
subb #'0'
|
subb #'0'
|
rts
|
rts
|
gtdc3:
|
gtdc3:
|
ldb #-1
|
ldb #-1
|
rts
|
rts
|
|
|
DisplayErr:
|
DisplayErr:
|
ldd #msgErr
|
ldd #msgErr
|
lbsr DisplayString
|
lbsr DisplayString
|
jmp Monitor
|
jmp Monitor
|
|
|
DisplayStringDX
|
DisplayStringDX
|
std Strptr
|
std Strptr
|
stx Strptr+2
|
stx Strptr+2
|
jsr DisplayString
|
jsr DisplayString
|
rts
|
rts
|
|
|
msgErr:
|
msgErr:
|
fcb "**Err",CR,LF,0
|
fcb "**Err",CR,LF,0
|
|
|
HelpMsg:
|
HelpMsg:
|
fcb "? = Display help",CR,LF
|
fcb "? = Display help",CR,LF
|
fcb "CLS = clear screen",CR,LF
|
fcb "CLS = clear screen",CR,LF
|
|
fcb "bs = set breakpoint",CR,LF
|
|
fcb "bc = clear breakpoint",CR,LF
|
; db "S = Boot from SD Card",CR,LF
|
; db "S = Boot from SD Card",CR,LF
|
fcb ": = Edit memory bytes",CR,LF
|
fcb ": = Edit memory bytes",CR,LF
|
; db "L = Load sector",CR,LF
|
; db "L = Load sector",CR,LF
|
; db "W = Write sector",CR,LF
|
; db "W = Write sector",CR,LF
|
fcb "DR = Dump registers",CR,LF
|
fcb "DR = Dump registers",CR,LF
|
fcb "D = Dump memory",CR,LF
|
fcb "D = Dump memory",CR,LF
|
; db "F = Fill memory",CR,LF
|
fcb "F = Fill memory",CR,LF
|
fcb "FL = Dump I/O Focus List",CR,LF
|
fcb "FL = Dump I/O Focus List",CR,LF
|
fcb "FIG = start FIG Forth",CR,LF
|
fcb "FIG = start FIG Forth",CR,LF
|
; db "KILL n = kill task #n",CR,LF
|
; db "KILL n = kill task #n",CR,LF
|
; db "B = start tiny basic",CR,LF
|
; db "B = start tiny basic",CR,LF
|
; db "b = start EhBasic 6502",CR,LF
|
; db "b = start EhBasic 6502",CR,LF
|
fcb "J = Jump to code",CR,LF
|
fcb "J = Jump to code",CR,LF
|
fcb "RAM = test RAM",CR,LF
|
fcb "RAM = test RAM",CR,LF
|
; db "R[n] = Set register value",CR,LF
|
; db "R[n] = Set register value",CR,LF
|
; db "r = random lines - test bitmap",CR,LF
|
; db "r = random lines - test bitmap",CR,LF
|
; db "e = ethernet test",CR,LF
|
; db "e = ethernet test",CR,LF
|
fcb "s = serial output test",CR,LF
|
fcb "s = serial output test",CR,LF
|
|
fcb "SP = sprite demo",CR,LF
|
; db "T = Dump task list",CR,LF
|
; db "T = Dump task list",CR,LF
|
; db "TO = Dump timeout list",CR,LF
|
; db "TO = Dump timeout list",CR,LF
|
fcb "TI = display date/time",CR,LF
|
fcb "TI = display date/time",CR,LF
|
; db "TEMP = display temperature",CR,LF
|
; db "TEMP = display temperature",CR,LF
|
fcb "U = unassemble",CR,LF
|
fcb "U = unassemble",CR,LF
|
; db "P = Piano",CR,LF,0
|
; db "P = Piano",CR,LF
|
|
fcb "x = exit monitor",CR,LF
|
fcb 0
|
fcb 0
|
|
|
msgRegHeadings
|
msgRegHeadings
|
fcb CR,LF," D/AB X Y U S PC DP CCR",CR,LF,0
|
fcb CR,LF," D/AB X Y U S PC DP CCR",CR,LF,0
|
|
|
nHEX4:
|
nHEX4:
|
jsr HEX4
|
jsr HEX4
|
rts
|
rts
|
|
|
nXBLANK:
|
nXBLANK:
|
ldb #' '
|
ldb #' '
|
lbra OUTCH
|
lbra OUTCH
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Dump Memory
|
; Dump Memory
|
;
|
;
|
; Usage:
|
; Usage:
|
; $D FFFC12 FFFC20
|
; $D FFFC12 FFFC20
|
;
|
;
|
; Dump formatted to look like:
|
; Dump formatted to look like:
|
; :FFFC12 012 012 012 012 555 666 777 888
|
; :FFFC12 012 012 012 012 555 666 777 888
|
;
|
;
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
DumpMemory:
|
DumpMemory:
|
bsr GetRange
|
bsr GetRange
|
ldy #0
|
ldy #0
|
ldy mon_r1+2
|
ldy mon_r1+2
|
dmpm2:
|
dmpm2:
|
lbsr CRLF
|
lbsr CRLF
|
ldb #':'
|
ldb #':'
|
lbsr OUTCH
|
lbsr OUTCH
|
tfr y,d
|
tfr y,d
|
;addd mon_r1+2 ; output the address
|
;addd mon_r1+2 ; output the address
|
lbsr DispWordAsHex
|
lbsr DispWordAsHex
|
ldb #' '
|
ldb #' '
|
lbsr OUTCH
|
lbsr OUTCH
|
ldx #8 ; number of bytes to display
|
ldx #8 ; number of bytes to display
|
dmpm1:
|
dmpm1:
|
; ldb far [mon_r1+1],y
|
; ldb far [mon_r1+1],y
|
;ldb [mon_r1+2],y
|
;ldb [mon_r1+2],y
|
ldb ,y
|
ldb ,y
|
iny
|
iny
|
lbsr DispByteAsHex ; display byte
|
lbsr DispByteAsHex ; display byte
|
ldb #' ' ; followed by a space
|
ldb #' ' ; followed by a space
|
lbsr OUTCH
|
lbsr OUTCH
|
clrb
|
clrb
|
clra
|
clra
|
lbsr INCH
|
lbsr INCH
|
cmpb #CTRLC
|
cmpb #CTRLC
|
beq dmpm3
|
beq dmpm3
|
dex
|
dex
|
bne dmpm1
|
bne dmpm1
|
; Now output ascii
|
; Now output ascii
|
ldb #' '
|
ldb #' '
|
lbsr OUTCH
|
lbsr OUTCH
|
ldx #8 ; 8 chars to output
|
ldx #8 ; 8 chars to output
|
leay -8,y ; backup pointer
|
leay -8,y ; backup pointer
|
dmpm5:
|
dmpm5:
|
; ldb far [mon_r1+1],y ; get the char
|
; ldb far [mon_r1+1],y ; get the char
|
; ldb [mon_r1+2],y ; get the char
|
; ldb [mon_r1+2],y ; get the char
|
ldb ,y
|
ldb ,y
|
cmpb #$20 ; is it a control char?
|
cmpb #$20 ; is it a control char?
|
bhs dmpm4
|
bhs dmpm4
|
ldb #'.'
|
ldb #'.'
|
dmpm4:
|
dmpm4:
|
lbsr OUTCH
|
lbsr OUTCH
|
iny
|
iny
|
dex
|
dex
|
bne dmpm5
|
bne dmpm5
|
cmpy mon_r2+2
|
cmpy mon_r2+2
|
blo dmpm2
|
blo dmpm2
|
dmpm3:
|
dmpm3:
|
lbsr CRLF
|
lbsr CRLF
|
lbra Monitor
|
lbra Monitor
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Edit Memory
|
; Edit Memory
|
;
|
;
|
; Usage:
|
; Usage:
|
; $$:FFFC12 8 "Hello World!" 0
|
; $$:FFFC12 8 "Hello World!" 0
|
;
|
;
|
; Dump formatted to look like:
|
; Dump formatted to look like:
|
; :FFFC12 012 012 012 012 555 666 777 888
|
; :FFFC12 012 012 012 012 555 666 777 888
|
;
|
;
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
EditMemory:
|
EditMemory:
|
ldu #8 ; set max byte count
|
ldu #8 ; set max byte count
|
lbsr GetHexNumber ; get the start address
|
lbsr GetHexNumber ; get the start address
|
ldx mon_numwka+2
|
ldx mon_numwka+2
|
EditMem2:
|
EditMem2:
|
lbsr ignBlanks ; skip over blanks
|
lbsr ignBlanks ; skip over blanks
|
lbsr GetHexNumber ; get the byte value
|
lbsr GetHexNumber ; get the byte value
|
tstb ; check for valid value
|
tstb ; check for valid value
|
bmi EditMem1 ; if invalid, quit
|
beq EditMem1 ; if invalid, quit
|
ldb mon_numwka+3 ; get value
|
ldb mon_numwka+3 ; get value
|
stb ,x+ ; update memory at address
|
stb ,x+ ; update memory at address
|
leau -1,u ; decremeent byte count
|
leau -1,u ; decremeent byte count
|
cmpu #0
|
cmpu #0
|
bne EditMem2 ; go back for annother byte
|
bne EditMem2 ; go back for annother byte
|
EditMem1:
|
EditMem1:
|
lbsr MonGetch ; see if a string is being entered
|
lbsr MonGetch ; see if a string is being entered
|
cmpb #'"'
|
cmpb #'"'
|
bne EditMem3 ; no string, we're done
|
bne EditMem3 ; no string, we're done
|
ldu #40 ; string must be less than 40 chars
|
ldu #40 ; string must be less than 40 chars
|
EditMem4:
|
EditMem4:
|
lbsr MonGetch ; look for close quote
|
lbsr MonGetch ; look for close quote
|
cmpb #'"'
|
cmpb #'"'
|
bne EditMem6 ; end of string?
|
bne EditMem6 ; end of string?
|
ldu #8 ; reset the byte count
|
ldu #8 ; reset the byte count
|
bra EditMem2
|
bra EditMem2
|
EditMem6:
|
EditMem6:
|
stb ,x+ ; store the character in memory
|
stb ,x+ ; store the character in memory
|
leau -1,u ; decrement byte count
|
leau -1,u ; decrement byte count
|
cmpu #0
|
cmpu #0
|
bhi EditMem4 ; max 40 chars
|
bhi EditMem4 ; max 40 chars
|
EditMem3:
|
EditMem3:
|
lbra Monitor
|
lbra Monitor
|
|
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
; Fill Memory
|
|
;
|
|
; Usage:
|
|
; $$F FFFC12 FFFC30 89F
|
|
;
|
|
;------------------------------------------------------------------------------
|
|
|
|
FillMemory:
|
|
lbsr GetRange ; get address range to fill
|
|
lbsr ignBlanks
|
|
lbsr GetHexNumber ; get target byte to write
|
|
ldb mon_numwka+3
|
|
ldx mon_r1+2
|
|
clra
|
|
fillm1: ; Check for a CTRL-C every page of memory
|
|
tsta
|
|
bne fillm2
|
|
clrb ; we want a non-blocking check
|
|
clra
|
|
lbsr INCH
|
|
cmpb #CTRLC
|
|
lbeq Monitor
|
|
ldb mon_numwka+3 ; reset target byte
|
|
fillm2:
|
|
stb ,x+
|
|
cmpx mon_r2+2
|
|
bls fillm1
|
|
fillm3:
|
|
lbra Monitor
|
|
|
|
;------------------------------------------------------------------------------
|
; Dump Registers
|
; Dump Registers
|
;
|
;
|
; Usage:
|
; Usage:
|
; $DR
|
; $DR
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
DumpRegs:
|
DumpRegs:
|
ldd #msgRegHeadings
|
ldd #msgRegHeadings
|
lbsr DisplayString
|
lbsr DisplayString
|
bsr nXBLANK
|
bsr nXBLANK
|
ldd mon_DSAVE
|
ldd mon_DSAVE
|
bsr nHEX4
|
bsr nHEX4
|
bsr nXBLANK
|
bsr nXBLANK
|
ldd mon_XSAVE
|
ldd mon_XSAVE
|
bsr nHEX4
|
bsr nHEX4
|
bsr nXBLANK
|
bsr nXBLANK
|
ldd mon_YSAVE
|
ldd mon_YSAVE
|
bsr nHEX4
|
bsr nHEX4
|
bsr nXBLANK
|
bsr nXBLANK
|
ldd mon_USAVE
|
ldd mon_USAVE
|
bsr nHEX4
|
bsr nHEX4
|
bsr nXBLANK
|
bsr nXBLANK
|
ldd mon_SSAVE
|
ldd mon_SSAVE
|
bsr nHEX4
|
bsr nHEX4
|
bsr nXBLANK
|
bsr nXBLANK
|
ldb mon_PCSAVE+1
|
ldb mon_PCSAVE+1
|
lbsr DispByteAsHex
|
lbsr DispByteAsHex
|
ldd mon_PCSAVE+2
|
ldd mon_PCSAVE+2
|
bsr nHEX4
|
bsr nHEX4
|
bsr nXBLANK
|
bsr nXBLANK
|
ldd mon_DPRSAVE
|
ldd mon_DPRSAVE
|
jsr HEX2
|
jsr HEX2
|
bsr nXBLANK
|
bsr nXBLANK
|
lda mon_CCRSAVE
|
lda mon_CCRSAVE
|
lbsr HEX2
|
lbsr HEX2
|
bsr nXBLANK
|
bsr nXBLANK
|
lbra Monitor
|
lbra Monitor
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
; Jump to code
|
; Jump to code
|
;
|
;
|
; Registers are loaded with values from the monitor register save area before
|
; Registers are loaded with values from the monitor register save area before
|
; the code is jumped to.
|
; the code is jumped to.
|
;
|
;
|
; J
|
; J
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
jump_to_code:
|
jump_to_code:
|
bsr GetHexNumber
|
bsr GetHexNumber
|
sei
|
sei
|
lds mon_SSAVE
|
lds mon_SSAVE
|
ldd #
|
ldd #
|
pshs d
|
pshs d
|
ldb #>jtc_exit
|
ldb #>jtc_exit
|
pshs b
|
pshs b
|
ldd mon_numwka+2 ; get the address parameter
|
ldd mon_numwka+2 ; get the address parameter
|
pshs d
|
pshs d
|
ldb mon_numwka+1
|
ldb mon_numwka+1
|
pshs b
|
pshs b
|
ldd mon_USAVE
|
ldd mon_USAVE
|
pshs d
|
pshs d
|
ldd mon_YSAVE
|
ldd mon_YSAVE
|
pshs d
|
pshs d
|
ldd mon_XSAVE
|
ldd mon_XSAVE
|
pshs d
|
pshs d
|
lda mon_DPRSave
|
lda mon_DPRSAVE
|
pshs a
|
pshs a
|
ldd mon_DSAVE
|
ldd mon_DSAVE
|
pshs d
|
pshs d
|
lda mon_CCRSAVE
|
lda mon_CCRSAVE
|
pshs a
|
pshs a
|
puls far ccr,d,dpr,x,y,u,pc
|
puls far ccr,d,dpr,x,y,u,pc
|
jtc_exit:
|
jtc_exit:
|
sts >mon_SSAVE ; need to use extended addressing, no direct page setting
|
sts >mon_SSAVE ; need to use extended addressing, no direct page setting
|
leas $6FFF ; reset stack to system area, dont modify flags register!
|
leas $6FFF ; reset stack to system area, dont modify flags register!
|
pshs ccr ; now the stack can be used
|
pshs ccr ; now the stack can be used
|
pshs a ; save acca register so we can use it
|
pshs a ; save acca register so we can use it
|
tfr dpr,a ; a = outgoing dpr value
|
tfr dpr,a ; a = outgoing dpr value
|
sta >mon_DPRSAVE ; force extended addressing mode usage here dpr is not set
|
sta >mon_DPRSAVE ; force extended addressing mode usage here dpr is not set
|
clra ; dpg register must be set to zero before values are
|
clra ; dpg register must be set to zero before values are
|
tfr a,dpr ; saved in the monitor register save area.
|
tfr a,dpr ; saved in the monitor register save area.
|
puls a ; get back acca
|
puls a ; get back acca
|
std mon_DSAVE ; save regsters, can use direct addressing now
|
std mon_DSAVE ; save regsters, can use direct addressing now
|
stx mon_XSAVE
|
stx mon_XSAVE
|
sty mon_YSAVE
|
sty mon_YSAVE
|
stu mon_USAVE
|
stu mon_USAVE
|
puls a ; get back ccr
|
puls a ; get back ccr
|
sta mon_CCRSAVE ; and save it too
|
sta mon_CCRSAVE ; and save it too
|
; Reset vectors in case they got toasted.
|
; Reset vectors in case they got toasted.
|
ldd #SerialPeekCharDirect
|
ldd #SerialPeekCharDirect
|
std CharInVec
|
std CharInVec
|
ldd #DisplayChar
|
ldd #DisplayChar
|
std CharOutVec
|
std CharOutVec
|
ldd DisplayErr
|
ldd DisplayErr
|
std MonErrVec
|
std MonErrVec
|
; todo set according to coreid
|
; todo set according to coreid
|
lbra DumpRegs ; now go do a register dump
|
lbra DumpRegs ; now go do a register dump
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
|
|
DumpIOFocusList:
|
DumpIOFocusList:
|
ldx #0
|
ldx #0
|
dfl2:
|
dfl2:
|
ldb IOFocusList,x
|
ldb IOFocusList,x
|
cmpb #24
|
cmpb #24
|
bne dfl1
|
bne dfl1
|
tfr x,d
|
tfr x,d
|
lbsr DispByteAsHex
|
lbsr DispByteAsHex
|
ldb #' '
|
ldb #' '
|
lbsr OUTCH
|
lbsr OUTCH
|
dfl1:
|
dfl1:
|
inx
|
inx
|
cmpx #16
|
cmpx #16
|
blo dfl2
|
blo dfl2
|
lbsr CRLF
|
lbsr CRLF
|
lbra Monitor
|
lbra Monitor
|
|
|
|
bootpg:
|
|
fcb $000
|
|
boot_stack:
|
|
fcw $006FFF
|
|
numBreakpoints:
|
|
fcb 8
|
|
mon_rom_vectab:
|
|
fcw mon_rom_vecs
|
|
mon_rom_vecs:
|
|
fcw Monitor ; enter monitor program
|
|
fcw INCH ; input a character
|
|
fcw OUTCH ; output a character
|
|
fcw CRLF ; output carriage-return, line feed
|
|
fcw DisplayString
|
|
fcw DispByteAsHex
|
|
fcw DispWordAsHex
|
|
fcw ShowSprites
|
|
fcw mon_srand
|
|
fcw mon_rand
|
|
fcw 0 ; operating system call
|
|
fcw GetRange
|
|
|
|
NumFuncs EQU (*-mon_rom_vectab)/2
|
|
|
|
;------------------------------------------------------------------------------
|
|
; SWI routine.
|
|
;
|
|
; SWI is used to call ROM monitor routines and process breakpoints.
|
|
;
|
|
; swi
|
|
; fcb
|
|
;------------------------------------------------------------------------------
|
|
|
|
swi_rout:
|
|
ldb bootpg,pcr ; reset direct page
|
|
tfr b,dp
|
|
swi_rout1:
|
|
ldu 11,s ; get program counter (low order 2 bytes)
|
|
leau -1,u ; backup a byte
|
|
tst BreakpointFlag ; are we in breakpoint mode?
|
|
beq swiNotBkpt
|
|
ldu #Breakpoints
|
|
ldb NumSetBreakpoints
|
|
beq swiNotBkpt
|
|
swi_rout2:
|
|
cmpu ,y++
|
|
beq processBreakpoint
|
|
decb
|
|
bne swi_rout2
|
|
swiNotBkpt:
|
|
clr BreakpointFlag
|
|
pulu d ; get function #, increment PC
|
|
cmpb #NumFuncs
|
|
lbhi DisplayErr
|
|
stu 11,s ; save updated PC on stack
|
|
cmpb #MF_OSCALL
|
|
beq swiCallOS
|
|
aslb ; 2 bytes per vector
|
|
ldx mon_rom_vectab,pcr
|
|
abx
|
|
ldx ,x
|
|
stx jmpvec
|
|
sts mon_SSAVE ; save the stack pointer
|
|
ldd 1,s ; get back D
|
|
ldx 4,s ; get back X
|
|
ldy 6,s ; get back Y
|
|
ldu 8,s ; get back U
|
|
lds boot_stack,pcr ; and use our own stack
|
|
jsr [jmpvec] ; call the routine
|
|
swi_rout3:
|
|
lds mon_SSAVE ; restore stack
|
|
rti
|
|
|
|
processBreakpoint:
|
|
lda ,s
|
|
sta mon_CCRSAVE
|
|
ldd 1,s
|
|
std mon_DSAVE
|
|
ldb 3,s
|
|
stb mon_DPRSAVE
|
|
ldd 4,s
|
|
std mon_XSAVE
|
|
ldd 6,s
|
|
std mon_YSAVE
|
|
ldd 8,s
|
|
std mon_USAVE
|
|
sts mon_SSAVE
|
|
ldd 11,s
|
|
std mon_PCSAVE
|
|
lds boot_stack,pcr
|
|
ldd #swi_rout3 ; setup so monitor can return
|
|
pshs d
|
|
bsr DisarmAllBreakpoints
|
|
lbra DumpRegs
|
|
|
|
xitMonitor:
|
|
bsr ArmAllBreakpoints
|
|
rts
|
|
|
|
swiCallOS:
|
|
leau 1,u ; next byte is func number
|
|
ldb ,u+
|
|
cmpb #NumOSFuncs ; check for valid range
|
|
lbhi DisplayErr
|
|
stu 11,s ; save updateed PC on stack
|
|
aslb ; compute vector address
|
|
ldx #OSCallTbl
|
|
tst b,x ; check for non-zero vector
|
|
beq swi_rout3
|
|
osc1:
|
|
; tst OSSEMA+1 ; wait for availability
|
|
; beq osc1
|
|
jsr [b,x] ; call the OS routine
|
|
oscx:
|
|
clr OSSEMA+1
|
|
bra swi_rout3
|
|
|
|
DisarmAllBreakpoints:
|
|
pshs d,x,y
|
|
ldy #0
|
|
clrb
|
|
ldx #BreakpointBytes ; x = breakpoint byte table address
|
|
disarm2:
|
|
cmpb #numBreakpoints ; safety check
|
|
bhs disarm1
|
|
cmpb NumSetBreakpoints
|
|
bhs disarm1
|
|
lda b,x ; get memory byte
|
|
sta [Breakpoints,y] ; and store it back to memory
|
|
leay 2,y ; increment for next address
|
|
incb ; increment to next byte
|
|
bra disarm2 ; loop back
|
|
disarm1:
|
|
puls d,x,y,pc
|
|
|
|
ArmAllBreakpoints:
|
|
pshs d,x,y
|
|
ldy #0
|
|
clrb
|
|
ldx #BreakpointBytes ; x = breakpoint byte table address
|
|
arm2:
|
|
cmpb numBreakpoints ; safety check
|
|
bhs arm1
|
|
cmpb NumSetBreakpoints
|
|
bhs arm1
|
|
lda [Breakpoints,y] ; load byte at memory address
|
|
sta b,x ; save in table
|
|
leay 2,y ; increment for next address
|
|
incb ; increment to next byte
|
|
bra arm2 ; loop back
|
|
arm1:
|
|
puls d,x,y,pc
|
|
|
|
ArmBreakpoint:
|
|
pshs d,x,y
|
|
lda NumSetBreakpoints ; check if too many breakpoints set
|
|
cmpa numBreakpoints
|
|
lbhs DisplayErr
|
|
lbsr GetHexNumber ; get address parameter
|
|
ldb NumSetBreakpoints ; bv= number of set breakpoints
|
|
ldy mon_numwka+2 ; get address
|
|
lda ,y ; get byte at address
|
|
ldx #BreakpointBytes ; and store byte in a table
|
|
lda #OPC_SWI ; put a SWI instruction in place
|
|
sta ,y
|
|
sta b,x
|
|
ldx #Breakpoints ; also store the address in a table
|
|
aslb ; index for 2 byte values
|
|
sty b,x
|
|
lsrb ; size back to single byte
|
|
incb
|
|
stb NumSetBreakpoints
|
|
puls d,x,y,pc
|
|
|
|
DisarmBreakpoint:
|
|
pshs d,x,y,u
|
|
lbsr GetHexNumber
|
|
clrb
|
|
clrb
|
|
tfr d,x ; x = zero too
|
|
disarm6:
|
|
cmpb numBreakpoints ; no more than this many may be set
|
|
bhs disarm4
|
|
cmpb NumSetBreakpoints ; number actually set
|
|
bhs disarm4
|
|
ldy Breakpoints,x ; y = breakpoint address
|
|
cmpy mon_numwka+2 ; is it the one we want?
|
|
bne disarm3 ; if not, go increment to next
|
|
ldx mon_numwka+2 ; x = memory address
|
|
ldy #BreakpointBytes
|
|
lda b,y ; get saved byte from table
|
|
sta ,x ; set the byte at the memory address
|
|
; compress breakpoint table by removing breakpoint
|
|
dec NumSetBreakpoints ; set the new number of set breakpoints
|
|
pshs b ; save the position we're removing from
|
|
disarm7:
|
|
incb ; set index for next byte
|
|
lda b,y ; get byte
|
|
decb ; and store it back
|
|
sta b,y
|
|
incb ; move to next position
|
|
cmpb numBreakpoints ; hit end of table?
|
|
blo disarm7
|
|
puls b ; get back position
|
|
aslb ; times two for word index
|
|
clra
|
|
tfr d,y
|
|
lsrb ; back to byte index value
|
|
disarm8:
|
|
ldu 2,y ; get next breakpoint address
|
|
stu ,y++ ; store in current pos, increment
|
|
incb ; increment count
|
|
cmpb numBreakpoints ; hit end of table?
|
|
blo disarm8
|
|
puls d,x,y,u,pc
|
|
disarm3:
|
|
leax 2,x
|
|
incb
|
|
bra disarm6
|
|
disarm4:
|
|
puls d,x,y,u,pc
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
swi3_rout:
|
swi3_rout:
|
sei
|
sei
|
puls a
|
lda ,s
|
sta mon_CCRSAVE
|
sta mon_CCRSAVE
|
puls D,DPR,X,Y,U
|
ldd 1,s
|
std mon_DSAVE
|
std mon_DSAVE
|
stx mon_XSAVE
|
ldb 3,s
|
sty mon_YSAVE
|
stb mon_DPRSAVE
|
stu mon_USAVE
|
ldd 4,s
|
tfr dpr,a
|
std mon_XSAVE
|
sta mon_DPRSAVE
|
ldd 6,s
|
puls a
|
std mon_YSAVE
|
sta mon_PCSAVE
|
ldd 8,s
|
puls D
|
std mon_USAVE
|
std mon_PCSAVE+1
|
sts mon_SSAVE
|
|
ldd 11,s
|
|
std mon_PCSAVE
|
sts mon_SSAVE
|
sts mon_SSAVE
|
lds #$3FFF
|
lds #$3FFF
|
|
ldd #swi3_exit
|
|
pshs d
|
cli
|
cli
|
jmp DumpRegs
|
jmp DumpRegs
|
swi3_exit:
|
swi3_exit:
|
sei
|
|
lds mon_SSAVE
|
lds mon_SSAVE
|
ldd mon_PCSAVE+1
|
|
pshs d
|
|
lda mon_PCSAVE
|
|
pshs a
|
|
ldu mon_USAVE
|
|
ldy mon_YSAVE
|
|
ldx mon_XSAVE
|
|
pshs x,y,u
|
|
lda mon_DPRSAVE
|
|
pshs a
|
|
ldd mon_DSAVE
|
|
pshs d
|
|
lda mon_CCRSAVE
|
|
pshs a
|
|
tfr a,ccr
|
|
cli
|
|
rti
|
rti
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
firq_rout:
|
firq_rout:
|
rti
|
rti
|
|
|
irq_rout:
|
irq_rout:
|
; lbsr SerialIRQ ; check for recieved character
|
; lbsr SerialIRQ ; check for recieved character
|
; lbsr TimerIRQ
|
lbsr TimerIRQ
|
|
|
; Reset the edge sense circuit in the PIC
|
; Reset the edge sense circuit in the PIC
|
lda #31 ; Timer is IRQ #31
|
; lda #31 ; Timer is IRQ #31
|
sta IrqSource ; stuff a byte indicating the IRQ source for PEEK()
|
; sta IrqSource ; stuff a byte indicating the IRQ source for PEEK()
|
sta PIC+16 ; register 16 is edge sense reset reg
|
; sta PIC+16 ; register 16 is edge sense reset reg
|
lda VIA+VIA_IFR
|
; lda VIA+VIA_IFR
|
bpl notTimerIRQ2
|
; bpl notTimerIRQ2
|
bita #$800
|
; bita #$800
|
beq notTimerIRQ2
|
; beq notTimerIRQ2
|
clr VIA+VIA_T3LL
|
; clr VIA+VIA_T3LL
|
clr VIA+VIA_T3LH
|
; clr VIA+VIA_T3LH
|
inc $E00037 ; update timer IRQ screen flag
|
; inc $E00037 ; update timer IRQ screen flag
|
notTimerIRQ2:
|
;notTimerIRQ2:
|
|
|
lda IrqBase ; get the IRQ flag byte
|
lda IrqBase ; get the IRQ flag byte
|
lsra
|
lsra
|
ora IrqBase
|
ora IrqBase
|
anda #$E0
|
anda #$FE0
|
sta IrqBase
|
sta IrqBase
|
|
|
; inc TEXTSCR+54 ; update IRQ live indicator on screen
|
; inc TEXTSCR+54 ; update IRQ live indicator on screen
|
|
|
; flash the cursor
|
; flash the cursor
|
; only bother to flash the cursor for the task with the IO focus.
|
; only bother to flash the cursor for the task with the IO focus.
|
; lda COREID
|
; lda COREID
|
; cmpa IOFocusID
|
; cmpa IOFocusID
|
; bne tr1a
|
; bne tr1a
|
; lda CursorFlash ; test if we want a flashing cursor
|
; lda CursorFlash ; test if we want a flashing cursor
|
; beq tr1a
|
; beq tr1a
|
; lbsr CalcScreenLoc ; compute cursor location in memory
|
; lbsr CalcScreenLoc ; compute cursor location in memory
|
; tfr d,y
|
; tfr d,y
|
; lda $2000,y ; get color code $2000 higher in memory
|
; lda $2000,y ; get color code $2000 higher in memory
|
; ldb IRQFlag ; get counter
|
; ldb IRQFlag ; get counter
|
; lsrb
|
; lsrb
|
; lsra
|
; lsra
|
; lsra
|
; lsra
|
; lsra
|
; lsra
|
; lsra
|
; lsra
|
; lsrb
|
; lsrb
|
; rola
|
; rola
|
; lsrb
|
; lsrb
|
; rola
|
; rola
|
; lsrb
|
; lsrb
|
; rola
|
; rola
|
; lsrb
|
; lsrb
|
; rola
|
; rola
|
; sta $E00000,y ; store the color code back to memory
|
; sta $E00000,y ; store the color code back to memory
|
tr1a:
|
tr1a:
|
rti
|
rti
|
|
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
nmi_rout:
|
nmi_rout:
|
ldb COREID
|
ldb COREID
|
lda #'I'
|
lda #'I'
|
ldx #TEXTSCR+40
|
ldx #TEXTSCR+40
|
sta b,x
|
sta b,x
|
rti_insn:
|
rti_insn:
|
rti
|
rti
|
|
|
; Special Register Area
|
; Special Register Area
|
org $FFFFE0
|
org $FFFFE0
|
|
|
; Interrupt vector table
|
; Interrupt vector table
|
|
|
org $FFFFF0
|
org $FFFFF0
|
fcw rti_insn ; reserved
|
fcw rti_insn ; reserved
|
fcw swi3_rout ; SWI3
|
fcw swi3_rout ; SWI3
|
fcw rti_insn ; SWI2
|
fcw rti_insn ; SWI2
|
fcw firq_rout ; FIRQ
|
fcw firq_rout ; FIRQ
|
fcw irq_rout ; IRQ
|
fcw irq_rout ; IRQ
|
fcw start ; SWI
|
fcw swi_rout ; SWI
|
fcw nmi_rout ; NMI
|
fcw nmi_rout ; NMI
|
fcw start ; RST
|
fcw start ; RST
|
|
|