langsmoke/ref_6502

934 lines
13 KiB
Plaintext
Raw Normal View History

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