934 lines
13 KiB
Plaintext
934 lines
13 KiB
Plaintext
|
|
*=$1000
|
|
LDA #$00
|
|
STA REV
|
|
JSR Init_6551
|
|
CHESS CLD
|
|
LDX #$FF
|
|
TXS
|
|
LDX #$C8
|
|
STX SP2
|
|
OUT JSR pout
|
|
JSR KIN
|
|
CMP #$43
|
|
BNE NOSET
|
|
LDX #$1F
|
|
WHSET LDA SETW,X
|
|
STA BOARD,X
|
|
DEX
|
|
BPL WHSET
|
|
LDX #$1B
|
|
STX OMOVE
|
|
LDA #$CC
|
|
BNE CLDSP
|
|
NOSET CMP #$45
|
|
BNE NOREV
|
|
JSR REVERSE
|
|
SEC
|
|
LDA #$01
|
|
SBC REV
|
|
STA REV
|
|
LDA #$EE
|
|
BNE CLDSP
|
|
NOREV CMP #$40
|
|
BNE NOGO
|
|
JSR GO
|
|
CLDSP STA DIS1
|
|
STA DIS2
|
|
STA DIS3
|
|
BNE CHESS
|
|
NOGO CMP #$0D
|
|
BNE NOMV
|
|
JSR MOVE
|
|
JMP DISP
|
|
NOMV CMP #$41
|
|
BEQ DONE
|
|
JMP INPUT
|
|
DONE JMP $FF00
|
|
|
|
JANUS LDX STATE
|
|
BMI NOCOUNT
|
|
COUNTS LDA PIECE
|
|
BEQ OVER
|
|
CPX #$08
|
|
BNE OVER
|
|
CMP BMAXP
|
|
BEQ XRT
|
|
OVER INC MOB,X
|
|
CMP #$01
|
|
BNE NOQ
|
|
INC MOB,X
|
|
NOQ BVC NOCAP
|
|
LDY #$0F
|
|
LDA SQUARE
|
|
ELOOP CMP BK,Y
|
|
BEQ FOUN
|
|
DEY
|
|
BPL ELOOP
|
|
FOUN LDA POINTS,Y
|
|
CMP MAXC,X
|
|
BCC LESS
|
|
STY PCAP,X
|
|
STA MAXC,X
|
|
LESS CLC
|
|
PHP
|
|
ADC CC,X
|
|
STA CC,X
|
|
PLP
|
|
NOCAP CPX #$04
|
|
BEQ ON4
|
|
BMI TREE
|
|
XRT RTS
|
|
ON4 LDA XMAXC
|
|
STA WCAP0
|
|
LDA #$00
|
|
STA STATE
|
|
JSR MOVE
|
|
JSR REVERSE
|
|
JSR GNMZ
|
|
JSR REVERSE
|
|
LDA #$08
|
|
STA STATE
|
|
JSR UMOVE
|
|
JMP STRATGY
|
|
NOCOUNT CPX #$F9
|
|
BNE TREE
|
|
LDA BK
|
|
CMP SQUARE
|
|
BNE RETJ
|
|
LDA #$00
|
|
STA INCHEK
|
|
RETJ RTS
|
|
TREE BVC RETJ
|
|
LDY #$07
|
|
LDA SQUARE
|
|
LOOPX CMP BK,Y
|
|
BEQ FOUNX
|
|
DEY
|
|
BEQ RETJ
|
|
BPL LOOPX
|
|
FOUNX LDA POINTS,Y
|
|
CMP BCAP0,X
|
|
BCC NOMAX
|
|
STA BCAP0,X
|
|
NOMAX DEC STATE
|
|
LDA #$FB
|
|
CMP STATE
|
|
BEQ UPTREE
|
|
JSR GENRM
|
|
UPTREE INC STATE
|
|
RTS
|
|
INPUT CMP #$08
|
|
BCS ERROR
|
|
JSR DISMV
|
|
DISP LDX #$1F
|
|
SEARCH LDA BOARD,X
|
|
CMP DIS2
|
|
BEQ HERE
|
|
DEX
|
|
BPL SEARCH
|
|
HERE STX DIS1
|
|
STX PIECE
|
|
ERROR JMP CHESS
|
|
GNMZ LDX #$10
|
|
GNMX LDA #$00
|
|
CLEAR STA COUNT,X
|
|
DEX
|
|
BPL CLEAR
|
|
GNM LDA #$10
|
|
STA PIECE
|
|
NEWP DEC PIECE
|
|
BPL NEX
|
|
RTS
|
|
NEX JSR RESET
|
|
LDY PIECE
|
|
LDX #$08
|
|
STX MOVEN
|
|
CPY #$08
|
|
BPL PAWN
|
|
CPY #$06
|
|
BPL KNIGHT
|
|
CPY #$04
|
|
BPL BISHOP
|
|
CPY #$01
|
|
BEQ QUEEN
|
|
BPL ROOK
|
|
KING JSR SNGMV
|
|
BNE KING
|
|
BEQ NEWP
|
|
QUEEN JSR LINE
|
|
BNE QUEEN
|
|
BEQ NEWP
|
|
ROOK LDX #$04
|
|
STX MOVEN
|
|
AGNR JSR LINE
|
|
BNE AGNR
|
|
BEQ NEWP
|
|
BISHOP JSR LINE
|
|
LDA MOVEN
|
|
CMP #$04
|
|
BNE BISHOP
|
|
BEQ NEWP
|
|
KNIGHT LDX #$10
|
|
STX MOVEN
|
|
AGNN JSR SNGMV
|
|
LDA MOVEN
|
|
CMP #$08
|
|
BNE AGNN
|
|
BEQ NEWP
|
|
PAWN LDX #$06
|
|
STX MOVEN
|
|
P1 JSR CMOVE
|
|
BVC P2
|
|
BMI P2
|
|
JSR JANUS
|
|
P2 JSR RESET
|
|
DEC MOVEN
|
|
LDA MOVEN
|
|
CMP #$05
|
|
BEQ P1
|
|
P3 JSR CMOVE
|
|
BVS NEWP
|
|
BMI NEWP
|
|
JSR JANUS
|
|
LDA SQUARE
|
|
AND #$F0
|
|
CMP #$20
|
|
BEQ P3
|
|
JMP NEWP
|
|
SNGMV JSR CMOVE
|
|
BMI ILL1
|
|
JSR JANUS
|
|
ILL1 JSR RESET
|
|
DEC MOVEN
|
|
RTS
|
|
LINE JSR CMOVE
|
|
BCC OVL
|
|
BVC LINE
|
|
OVL BMI ILL
|
|
PHP
|
|
JSR JANUS
|
|
PLP
|
|
BVC LINE
|
|
ILL JSR RESET
|
|
DEC MOVEN
|
|
RTS
|
|
REVERSE LDX #$0F
|
|
ETC SEC
|
|
LDY BK,X
|
|
LDA #$77
|
|
SBC BOARD,X
|
|
STA BK,X
|
|
STY BOARD,X
|
|
SEC
|
|
LDA #$77
|
|
SBC BOARD,X
|
|
STA BOARD,X
|
|
DEX
|
|
BPL ETC
|
|
RTS
|
|
|
|
CMOVE LDA SQUARE
|
|
LDX MOVEN
|
|
CLC
|
|
ADC MOVEX,X
|
|
STA SQUARE
|
|
AND #$88
|
|
BNE ILLEGAL
|
|
LDA SQUARE
|
|
LDX #$20
|
|
LOOP DEX
|
|
BMI NO
|
|
CMP BOARD,X
|
|
BNE LOOP
|
|
CPX #$10
|
|
BMI ILLEGAL
|
|
LDA #$7F
|
|
ADC #$01
|
|
BVS SPX
|
|
NO CLV
|
|
SPX LDA STATE
|
|
BMI RETL
|
|
CMP #$08
|
|
BPL RETL
|
|
|
|
CHKCHK PHA
|
|
PHP
|
|
LDA #$F9
|
|
STA STATE
|
|
STA INCHEK
|
|
JSR MOVE
|
|
JSR REVERSE
|
|
JSR GNM
|
|
JSR RUM
|
|
PLP
|
|
PLA
|
|
STA STATE
|
|
LDA INCHEK
|
|
BMI RETL
|
|
SEC
|
|
LDA #$FF
|
|
RTS
|
|
RETL CLC
|
|
LDA #$00
|
|
RTS
|
|
ILLEGAL LDA #$FF
|
|
CLC
|
|
CLV
|
|
RTS
|
|
RESET LDX PIECE
|
|
LDA BOARD,X
|
|
STA SQUARE
|
|
RTS
|
|
GENRM JSR MOVE
|
|
GENR2 JSR REVERSE
|
|
JSR GNM
|
|
RUM JSR REVERSE
|
|
UMOVE TSX
|
|
STX SP1
|
|
LDX SP2
|
|
TXS
|
|
PLA
|
|
STA MOVEN
|
|
PLA
|
|
STA PIECE
|
|
TAX
|
|
PLA
|
|
STA BOARD,X
|
|
PLA
|
|
TAX
|
|
PLA
|
|
STA SQUARE
|
|
STA BOARD,X
|
|
JMP STRV
|
|
MOVE TSX
|
|
STX SP1
|
|
LDX SP2
|
|
TXS
|
|
LDA SQUARE
|
|
PHA
|
|
TAY
|
|
LDX #$1F
|
|
CHECK CMP BOARD,X
|
|
BEQ TAKE
|
|
DEX
|
|
BPL CHECK
|
|
TAKE LDA #$CC
|
|
STA BOARD,X
|
|
TXA
|
|
PHA
|
|
LDX PIECE
|
|
LDA BOARD,X
|
|
STY BOARD,X
|
|
PHA
|
|
TXA
|
|
PHA
|
|
LDA MOVEN
|
|
PHA
|
|
STRV TSX
|
|
STX SP2
|
|
LDX SP1
|
|
TXS
|
|
RTS
|
|
CKMATE LDY BMAXC
|
|
CPX POINTS
|
|
BNE NOCHEK
|
|
LDA #$00
|
|
BEQ RETV
|
|
NOCHEK LDX BMOB
|
|
BNE RETV
|
|
LDX WMAXP
|
|
BNE RETV
|
|
LDA #$FF
|
|
RETV LDX #$04
|
|
STX STATE
|
|
PUSH CMP BESTV
|
|
BCC RETP
|
|
BEQ RETP
|
|
STA BESTV
|
|
LDA PIECE
|
|
STA BESTP
|
|
LDA SQUARE
|
|
STA BESTM
|
|
RETP LDA #"."
|
|
Jmp syschout
|
|
GO LDX OMOVE
|
|
BMI NOOPEN
|
|
LDA DIS3
|
|
CMP OPNING,X
|
|
BNE END
|
|
DEX
|
|
LDA OPNING,X
|
|
STA DIS1
|
|
DEX
|
|
LDA OPNING,X
|
|
STA DIS3
|
|
DEX
|
|
STX OMOVE
|
|
BNE MV2
|
|
END LDA #$FF
|
|
STA OMOVE
|
|
NOOPEN LDX #$0C
|
|
STX STATE
|
|
STX BESTV
|
|
LDX #$14
|
|
JSR GNMX
|
|
LDX #$04
|
|
STX STATE
|
|
JSR GNMZ
|
|
LDX BESTV
|
|
CPX #$0F
|
|
BCC MATE
|
|
MV2 LDX BESTP
|
|
LDA BOARD,X
|
|
STA BESTV
|
|
STX PIECE
|
|
LDA BESTM
|
|
STA SQUARE
|
|
JSR MOVE
|
|
JMP CHESS
|
|
MATE LDA #$FF
|
|
RTS
|
|
DISMV LDX #$04
|
|
DROL ASL DIS3
|
|
ROL DIS2
|
|
DEX
|
|
BNE DROL
|
|
ORA DIS3
|
|
STA DIS3
|
|
STA SQUARE
|
|
RTS
|
|
STRATGY CLC
|
|
LDA #$80
|
|
ADC WMOB
|
|
ADC WMAXC
|
|
ADC WCC
|
|
ADC WCAP1
|
|
ADC WCAP2
|
|
SEC
|
|
SBC PMAXC
|
|
SBC PCC
|
|
SBC BCAP0
|
|
SBC BCAP1
|
|
SBC BCAP2
|
|
SBC PMOB
|
|
SBC BMOB
|
|
BCS POS
|
|
LDA #$00
|
|
POS LSR
|
|
CLC
|
|
ADC #$40
|
|
ADC WMAXC
|
|
ADC WCC
|
|
SEC
|
|
SBC BMAXC
|
|
LSR
|
|
CLC
|
|
ADC #$90
|
|
ADC WCAP0
|
|
ADC WCAP0
|
|
ADC WCAP0
|
|
ADC WCAP0
|
|
ADC WCAP1
|
|
SEC
|
|
SBC BMAXC
|
|
SBC BMAXC
|
|
SBC BMCC
|
|
SBC BMCC
|
|
SBC BCAP1
|
|
LDX SQUARE
|
|
CPX #$33
|
|
BEQ POSN
|
|
CPX #$34
|
|
BEQ POSN
|
|
CPX #$22
|
|
BEQ POSN
|
|
CPX #$25
|
|
BEQ POSN
|
|
LDX PIECE
|
|
BEQ NOPOSN
|
|
LDY BOARD,X
|
|
CPY #$10
|
|
BPL NOPOSN
|
|
POSN CLC
|
|
ADC #$02
|
|
NOPOSN JMP CKMATE
|
|
POUT jsr pout9
|
|
jsr pout13
|
|
JSR POUT10
|
|
LDY #$00
|
|
JSR POUT5
|
|
POUT1 lDA #"|"
|
|
JSR syschout
|
|
LDX #$1F
|
|
POUT2 TYA
|
|
match
|
|
CMP BOARD,X
|
|
BEQ POUT4
|
|
type
|
|
DEX
|
|
BPL POUT2
|
|
tya
|
|
and #$01
|
|
sta temp
|
|
tya
|
|
lsr
|
|
lsr
|
|
lsr
|
|
lsr
|
|
and #$01
|
|
clc
|
|
adc temp
|
|
square color
|
|
and #$01
|
|
bne pout25
|
|
lda #"*"
|
|
.byte $2c
|
|
POUT25 LDA #$20
|
|
JSR syschout
|
|
JSR syschout
|
|
POUT3 INY
|
|
TYA
|
|
AND #$08
|
|
BEQ POUT1
|
|
LDA #"|"
|
|
JSR syschout
|
|
jsr pout12
|
|
JSR POUT9
|
|
JSR POUT5
|
|
CLC
|
|
TYA
|
|
ADC #$08
|
|
TAY
|
|
CPY #$80
|
|
BEQ POUT8
|
|
BNE POUT1
|
|
POUT4 LDA REV
|
|
BEQ POUT41
|
|
LDA cpl+16,X
|
|
BNE POUT42
|
|
POUT41 LDA cpl,x
|
|
POUT42 JSR syschout
|
|
lda cph,x
|
|
jsr syschout
|
|
BNE POUT3
|
|
POUT5 TXA
|
|
PHA
|
|
LDX #$19
|
|
LDA #"-"
|
|
POUT6 JSR syschout
|
|
DEX
|
|
BNE POUT6
|
|
PLA
|
|
TAX
|
|
JSR POUT9
|
|
RTS
|
|
POUT8 jsr pout10
|
|
LDA $FB
|
|
JSR syshexout
|
|
LDA #$20
|
|
JSR syschout
|
|
LDA $FA
|
|
JSR syshexout
|
|
LDA #$20
|
|
JSR syschout
|
|
LDA $F9
|
|
JSR syshexout
|
|
POUT9 LDA #$0D
|
|
JSR syschout
|
|
LDA #$0A
|
|
JSR syschout
|
|
RTS
|
|
pout10 ldx #$00
|
|
POUT11 lda #$20
|
|
jsr syschout
|
|
txa
|
|
jsr syshexout
|
|
INX
|
|
CPX #$08
|
|
BNE POUT11
|
|
BEQ POUT9
|
|
POUT12 TYA
|
|
and #$70
|
|
JSR syshexout
|
|
rts
|
|
Pout13 ldx #$00
|
|
Pout14 lda banner,x
|
|
beq POUT15
|
|
jsr syschout
|
|
inx
|
|
bne POUT14
|
|
POUT15 rts
|
|
KIN LDA #"?"
|
|
JSR syschout
|
|
JSR syskin
|
|
AND #$4F
|
|
RTS
|
|
Init_6551 lda #$1F
|
|
sta ACIActl
|
|
lda #$0B
|
|
dtr active low
|
|
sta ACIAcmd
|
|
rts
|
|
syskin lda ACIASta
|
|
and #$08
|
|
beq syskin
|
|
Lda ACIAdat
|
|
RTS
|
|
syschout PHA
|
|
ACIA_Out1 lda ACIASta
|
|
and #$10
|
|
beq ACIA_Out1
|
|
PLA
|
|
sta ACIAdat
|
|
RTS
|
|
syshexout PHA
|
|
LSR
|
|
LSR
|
|
LSR
|
|
LSR
|
|
JSR PrintDig
|
|
PLA
|
|
PrintDig PHY
|
|
AND #$0F
|
|
TAY
|
|
LDA Hexdigdata,Y
|
|
PLY
|
|
jmp syschout
|
|
TMP EQU $6
|
|
WEEKDAY:
|
|
CPX #3
|
|
BCS MARCH
|
|
DEY
|
|
MARCH EOR #$7F
|
|
CPY #200
|
|
ADC MTAB-1,X
|
|
STA TMP
|
|
TYA
|
|
JSR MOD7
|
|
SBC TMP
|
|
STA TMP
|
|
TYA
|
|
LSR
|
|
LSR
|
|
CLC
|
|
ADC TMP
|
|
MOD7 ADC #7
|
|
BCC MOD7
|
|
RTS
|
|
AST 32
|
|
JSR SAVE
|
|
PLA
|
|
STA R15L
|
|
PLA
|
|
STA R15H
|
|
SW16B JSR SW16C
|
|
JMP SW16B
|
|
SW16C INC R15L
|
|
BNE SW16D
|
|
INC R15H
|
|
SW16D LDA >SET
|
|
PHA
|
|
LDY $0
|
|
LDA (R15L),Y
|
|
AND $F
|
|
ASL
|
|
TAX
|
|
LSR
|
|
EOR (R15L),Y
|
|
BEQ TOBR
|
|
STX R14H
|
|
LSR
|
|
LSR
|
|
LSR
|
|
TAY
|
|
LDA OPTBL-2,Y
|
|
PHA
|
|
RTS
|
|
TOBR INC R15L
|
|
BNE TOBR2
|
|
INC R15H
|
|
TOBR2 LDA BRTBL,X
|
|
PHA
|
|
LDA R14H
|
|
LSR
|
|
RTS
|
|
RTNZ PLA
|
|
PLA
|
|
JSR RESTORE
|
|
JMP (R15L)
|
|
SETZ LDA (R15L),Y
|
|
STA R0H,X
|
|
DEY
|
|
LDA (R15L),Y
|
|
STA R0L,X
|
|
TYA
|
|
SEC
|
|
ADC R15L
|
|
STA R15L
|
|
BCC SET2
|
|
INC R15H
|
|
SET2 RTS
|
|
OPTBL DFB SET-1
|
|
BRTBL DFB RTN-1
|
|
DFB LD-1
|
|
DFB BR-1
|
|
DFB ST-1
|
|
DFB BNC-1
|
|
DFB LDAT-1
|
|
DFB BC-1
|
|
DFB STAT-1
|
|
DFB BP-1
|
|
DFB LDDAT-1
|
|
DFB BM-1
|
|
DFB STDAT-1
|
|
DFB BZ-1
|
|
DFB POP-1
|
|
DFB BNZ-1
|
|
DFB STPAT-1
|
|
DFB BM1-1
|
|
DFB ADD-1
|
|
DFB BNM1-1
|
|
DFB SUB-1
|
|
DFB BK-1
|
|
DFB POPD-1
|
|
DFB RS-1
|
|
DFB CPR-1
|
|
DFB BS-1
|
|
DFB INR-1
|
|
DFB NUL-1
|
|
DFB DCR-1
|
|
DFB NUL-1
|
|
DFB NUL-1
|
|
DFB NUL-1
|
|
SET BPL SETZ
|
|
LD LDA R0L,X
|
|
BK EQU *-1
|
|
STA R0L
|
|
LDA R0H,X
|
|
STA R0H
|
|
RTS
|
|
ST LDA R0L
|
|
STA R0L,X
|
|
LDA R0H
|
|
STA R0H,X
|
|
RTS
|
|
STAT LDA R0L
|
|
STAT2 STA (R0L,X)
|
|
LDY $0
|
|
STAT3 STY R14H
|
|
INR INC R0L,X
|
|
BNE INR2
|
|
INC R0H,X
|
|
INR2 RTS
|
|
LDAT LDA (R0L,X)
|
|
STA R0L
|
|
LDY $0
|
|
STY R0H
|
|
BEQ STAT3
|
|
POP LDY $0
|
|
BEQ POP2
|
|
POPD JSR DCR
|
|
LDA (R0L,X)
|
|
TAY
|
|
POP2 JSR DCR
|
|
LDA (R0L,X)
|
|
STA R0L
|
|
STY R0H
|
|
POP3 LDY $0
|
|
STY R14H
|
|
RTS
|
|
LDDAT JSR LDAT
|
|
LDA (R0L,X)
|
|
STA R0H
|
|
JMP INR
|
|
STDAT JSR STAT
|
|
LDA R0H
|
|
STA (R0L,X)
|
|
JMP INR
|
|
STPAT JSR DCR
|
|
LDA R0L
|
|
STA (R0L,X)
|
|
JMP POP3
|
|
DCR LDA R0L,X
|
|
BNE DCR2
|
|
DEC R0H,X
|
|
DCR2 DEC R0L,X
|
|
RTS
|
|
SUB LDY $0
|
|
CPR SEC
|
|
LDA R0L
|
|
SBC R0L,X
|
|
STA R0L,Y
|
|
LDA R0H
|
|
SBC R0H,X
|
|
SUB2 STA R0H,Y
|
|
TYA
|
|
ADC $0
|
|
STA R14H
|
|
RTS
|
|
ADD LDA R0L
|
|
ADC R0L,X
|
|
STA R0L
|
|
LDA R0H
|
|
ADC R0H,X
|
|
LDY $0
|
|
BEQ SUB2
|
|
BS LDA R15L
|
|
JSR STAT2
|
|
LDA R15H
|
|
JSR STAT2
|
|
BR CLC
|
|
BNC BCS BNC2
|
|
BR1 LDA (R15L),Y
|
|
BPL BR2
|
|
DEY
|
|
BR2 ADC R15L
|
|
STA R15L
|
|
TYA
|
|
ADC R15H
|
|
STA R15H
|
|
BNC2 RTS
|
|
BC BCS BR
|
|
RTS
|
|
BP ASL
|
|
TAX
|
|
LDA R0H,X
|
|
BPL BR1
|
|
RTS
|
|
BM ASL
|
|
TAX
|
|
LDA R0H,X
|
|
BMI BR1
|
|
RTS
|
|
BZ ASL
|
|
TAX
|
|
LDA R0L,X
|
|
ORA R0H,X
|
|
BEQ BR1
|
|
RTS
|
|
BNZ ASL
|
|
TAX
|
|
LDA R0L,X
|
|
ORA R0H,X
|
|
BNE BR1
|
|
RTS
|
|
BM1 ASL
|
|
TAX
|
|
LDA R0L,X
|
|
AND R0H,X
|
|
EOR $FF
|
|
BEQ BR1
|
|
RTS
|
|
BNM1 ASL
|
|
TAX
|
|
LDA R0L,X
|
|
AND R0H,X
|
|
EOR $FF
|
|
BNE BR1
|
|
NUL RTS
|
|
RS LDX $18
|
|
JSR DCR
|
|
LDA (R0L,X)
|
|
STA R15H
|
|
JSR DCR
|
|
LDA (R0L,X)
|
|
STA R15L
|
|
RTS
|
|
RTN JMP RTNZ
|
|
.org $f000
|
|
init:
|
|
lda #$00
|
|
sta mtalock
|
|
lda #$40
|
|
sta acr
|
|
lda #$c0
|
|
sta ier
|
|
ldy #0
|
|
lda #0
|
|
stinit: sta $100,y
|
|
iny
|
|
bne stinit
|
|
lda #$00
|
|
sta mtatask
|
|
ldy #maxtask-1
|
|
initloop:
|
|
lda mtasini,y
|
|
sta mtastab,y
|
|
tax
|
|
lda #$b0
|
|
sta $0104,x
|
|
tya
|
|
asl a
|
|
tax
|
|
stx mtatemp
|
|
lda ent_tab,x
|
|
ldx mtastab,y
|
|
sta $0105,x
|
|
ldx mtatemp
|
|
lda ent_tab+1,x
|
|
ldx mtastab,y
|
|
sta $0106,x
|
|
dey
|
|
bpl initloop
|
|
ldx #$3f
|
|
txs
|
|
lda #0
|
|
sta t1lsl
|
|
lda #40
|
|
sta t1csh
|
|
cli
|
|
jmp ent_task0
|
|
ent_tab:
|
|
.word ent_task0
|
|
.word ent_task1
|
|
.word ent_task2
|
|
.word ent_task3
|
|
mtaentry:
|
|
php
|
|
pha
|
|
txa
|
|
pha
|
|
tya
|
|
pha
|
|
tsx
|
|
inc $105,x
|
|
bne mtaent01
|
|
inc $106,x
|
|
mtaent01:
|
|
lda #$00
|
|
sta mtalock
|
|
jmp mtaswitch
|
|
irq:
|
|
pha
|
|
txa
|
|
pha
|
|
tya
|
|
pha
|
|
lda t1csl
|
|
lda #$c0
|
|
sta ifr
|
|
lda mtalock
|
|
beq mtaswitch
|
|
inc mtalock
|
|
jmp irq_ret
|
|
mtaswitch:
|
|
ldy mtatask
|
|
tsx
|
|
stx mtastab,y
|
|
iny
|
|
cpy #maxtask
|
|
bcc mtanumok
|
|
ldy #0
|
|
mtanumok:
|
|
sty mtatask
|
|
ldx mtastab,y
|
|
txs
|
|
irq_ret:
|
|
pla
|
|
tay
|
|
pla
|
|
tax
|
|
pla
|
|
rti
|
|
.end |