📄 iop.asm
字号:
;;;;spca718 system clock is 67.5MHZ
;;;;spca716 system clock is 54MHZ
SYSTEM_81_MHZ equ 0
SYSTEM_67_MHZ equ 1
SYSTEM_54_MHZ equ 0
IR_NEC equ 1
IR_PHILIPS equ 0
SUPPORT_VFD equ 0
SUPPORT_VFD_SWITCH equ 0
SUPPORT_VFD_ROLL equ 0
SUPPORT_LCD equ 0
SUPPORT_SPL10 equ 0
SUPPORT_QCODE equ 1
SUPPORT_QCODE_PTOW equ 0
SUPPORT_DSA equ 0
SUPPORT_DISCMAN equ 0 ;;if have mcu for dsa communication =1;
SUPPORT_DEMO equ 1 ;;sony small board =1;
SUPPORT_GUANGLING equ 0
VFD_COUNT_BASE equ $400
VFD_BUFFER_BASE equ $401
QCODE_BUFFER equ $420
SPL10_WR_CMD equ a0h
SPL10_RD_CMD equ c0h
SPL10_BUFFER_SIZE equ 0ch
SPL10_BUFFER_BASE equ $404
;;**************************************************************************;;
;; Function : Main program entry ;;
;; Input : NONE ;;
;; Output : NONE ;;
;;**************************************************************************;;
.CHIP R65C02
.SYNTAX 6502
.LINKLIST
.SYMBOLS
.MACFIRST ON
;;**************************************************************************;;
;;include ;;
;;**************************************************************************;;
.include 6502s.inc
.include iop.inc
;;**************************************************************************;;
;;work ram ;;
;;**************************************************************************;;
.PAGE0
RAM_TOP equ $
time10ms ds 1
time1ms ds 1
Vfd_init1 ds 1
;;NEC IR control
.ifnz IR_NEC
rIrNewStatus: ds 1
rIrOldStatus: ds 1
rIrState: ds 1
rIrCountH: ds 1
rIrCountLbuf: ds 1
rIrLoopcount: ds 1
rIrReceiver: ds 4
rIrIncount: ds 1
rIrHeadStatus: ds 1
.endif
.ifnz IR_PHILIPS
rIrOldStatus: ds 1
rIrNewStatus: ds 1
rIrState: ds 1
rIrCountH: ds 1
rIrLoopcount: ds 1
rIrReceiver: ds 2
rIrIncount: ds 1
.endif
;;SUPPORT VFD control
.ifnz SUPPORT_VFD
rVfdstatus: ds 1
rVfdstate: ds 1
rVfdloopcount: ds 1
rVfddata: ds 1
rVfdtempdata: ds 1
rVfddataold: ds 1
rVfdsendcount: ds 1
rVfdkeydata: ds 1
rVfdscantime: ds 1
rVfdreptime: ds 1
rVfdcmdcount: ds 1
rVfdswdata: ds 1
rVfdswindex: ds 1
rVfdswbuf: ds 5
rGamepad1_data: ds 1
rGamepad2_data: ds 1
rGameflag: ds 1
.endif
.ifnz SUPPORT_LCD
rLcddata: ds 2
rLcdstate: ds 1
rLcdloopcount: ds 1
rLcdscantime: ds 1
rLcdsendcount: ds 1
rLcdtemp: ds 1
rLcdgamecount: ds 1
rGamepad1_data: ds 1
rGamepad2_data: ds 1
.endif
.ifnz SUPPORT_SPL10
spl10_service_status: ds 1
spl10_wr_status: ds 1
spl10_buf_count: ds 1
spl10_rd_status: ds 1
spl10_sync_status: ds 1
write_byte_status: ds 1
spl10_wr_data: ds 1
spl10_write_count: ds 1
read_byte_status: ds 1
spl10_rd_data: ds 1
spl10_read_count: ds 1
spl10_scan_time: ds 1
rd_old_data: ds 1
spl10_rep_time ds 1
spl10_rep_count ds 1
.endif
.ifnz SUPPORT_DSA
rDsastate: ds 1
rDsastatus: ds 1
rDsaloopcount: ds 1
rDsatimeout ds 1
.endif
.ifnz SUPPORT_QCODE
rQcodestatus: ds 1
rQcodecount: ds 1
rQcodebitcount: ds 1
;rQcodecrc: ds 1
rQcodetimer: ds 1
rQcodedata: ds 10
.ifnz SUPPORT_QCODE_PTOW
rQcodedata1: ds 1
rQcodedata2: ds 1
rQcodecountH: ds 1
rQcodecountL: ds 1
.endif
.endif
RAM_BOTTOM equ $
;;**************************************************************************;;
;; code ;;
;; 1. system have 512 byte SRAM inside ;;
;; 2. $0 ~ $40 -> direct I/O control register (no include in SRAM area) ;;
;; $40 ~ $ff -> zero page free ;;
;; $100 ~ $105 -> each vector ;;
;; $106 ~ 1ff -> page 1 ;;
;; $200 ~ 240 -> cache ram for $200 ~ $ffff ;;
;; design $100 ~ $105 for each vector to reduce code size ;;
;;**************************************************************************;;
SRAM_PG0: .section
vIrq:
pha ;;interrupt service routine
lda IntFlag
sta IntFlag ;;clear intr flag
;; now only timerB enable
.ifnz IR_PHILIPS
lda rIrCountH
cmp #22
bcs Ircheckdata
.endif
inc rIrCountH
Ircheckdata:
dec time1ms
bne Istime100us
lda #10
sta time1ms
smb 0,IOP_DATA5_H
Istime100us:
dec time10ms
bne Not10ms
lda #100
sta time10ms
smb 1,IOP_DATA5_H
.ifnz SUPPORT_DSA
inc rDsatimeout
bbr 2,rDsatimeout,Dsanotimeout
stz rDsatimeout
stz DSA_PORT_CFG
stz rDsastatus
stz rDsastate
Dsanotimeout:
.endif
.ifnz SUPPORT_QCODE
;; inc rQcodetimer
.endif
lda rIrIncount
beq Not10ms
dec rIrIncount
Not10ms:
.ifnz SUPPORT_VFD
.ifnz SUPPORT_QCODE
.ifnz SUPPORT_QCODE_PTOW
.else
bbs 1,rQcodestatus,Vfdscan
.endif
.endif
lda rVfdscantime
beq Vfdscan
dec rVfdscantime
Vfdscan:
.endif
.ifnz SUPPORT_LCD
lda rLcdscantime
beq Lcdscan
dec rLcdscantime
Lcdscan:
.endif
.ifnz SUPPORT_SPL10
lda spl10_scan_time
beq Spl10scan
dec spl10_scan_time
Spl10scan:
.endif
; rmb VFDB_CLK,VFD_PORT
pla
vNmi:
rti
;;**************************************************************************;;
;; sdram write back ;;
;;**************************************************************************;;
Flashinout:
pha
lda $1000
lda $1040
pla
rts
.ifnz IR_PHILIPS
;;**************************************************************************;;
;; Repeat IR command and data ;;
;;**************************************************************************;;
Irservice:
lda IR_PORT
and #IR_IN
sta rIrNewStatus
eor rIrOldStatus
beq Ircheckindata
lda rIrNewStatus
sta rIrOldStatus
lda rIrCountH
cmp #22
bcc Irstartcount
lda #1
sta rIrReceiver
sta rIrReceiver+1
lda #15
sta rIrLoopcount
Irstartcount:
jsr IrdealHtoL
Irclearcount:
stz rIrCountH
Ircheckindata:
lda rIrCountH
cmp #21
bne Irrteurn
lda rIrLoopcount
cmp #1
bne Irrteurn
dec rIrLoopcount
lda rIrReceiver
sta IOP_DATA6_L ;;save to IOP_DATA6_L
lda rIrReceiver+1
eor IOP_DATA6_H
and #%00001000
bne Irisnotzero
lda IOP_DATA6_H
bne Irisrepeat
Irisnotzero:
lda rIrReceiver+1
and #%00111111
sta IOP_DATA6_H ;;save to IOP_DATA6_L
lda rIrIncount
bne Irisrepeat
smb IR_RD,IOP_DATA5_H
rmb IR_RP,IOP_DATA5_H
bra Irsetrepeat
Irisrepeat:
smb IR_RP,IOP_DATA5_H
rmb IR_RD,IOP_DATA5_H
Irsetrepeat:
lda #14
sta rIrIncount
Irrteurn:
rts
;;**************************************************************************;;
SRAM_PG1: .section ;;PAGE1 start ;;
;;**************************************************************************;;
;;**************************************************************************;;
;; Deal IR command ;;
;;**************************************************************************;;
IrdealHtoL:
lda rIrLoopcount
beq Irnotdata
lda rIrCountH
cmp #15
bcs IrHtoL0
cmp #13
bcs Iriserror
cmp #5
bcs IrHtoL1
Iriserror:
lda #ffH
sta rIrLoopcount
rts
IrHtoL0:
sta rIrState
clc
bbs 0,rIrReceiver,Irkeepstatus
sec
Irkeepstatus:
rol rIrReceiver
rol rIrReceiver+1
Ircollectexit:
dec rIrLoopcount
rts
IrHtoL1:
lda rIrState
bne Irclearstate
clc
bbr 0,rIrReceiver,Irsetdata1
sec
Irsetdata1:
rol rIrReceiver
rol rIrReceiver+1
inc rIrState
bra Ircollectexit
Irclearstate:
stz rIrState
Irnotdata:
rts
.endif
.ifnz IR_NEC
;;**************************************************************************;;
;; Read IR command ;;
;;**************************************************************************;;
Irservice:
lda IR_PORT
and #IR_IN
sta rIrNewStatus
eor rIrOldStatus
beq Irkeepstatus
lda rIrNewStatus
sta rIrOldStatus
beq Irportislow
lda rIrCountH
sta rIrCountLbuf
bra Irclearcount
Irportislow:
lda rIrLoopcount ;rIrHeadStatus
beq Irnothead
jsr Irdatacollect
bra Irclearcount
Irnothead:
lda rIrCountLbuf
cmp #80
bcc Irclearcount
cmp #98
bcs Irclearcount
lda rIrCountH
cmp #50
bcs Irclearcount
cmp #20
bcc Irclearcount
cmp #35
bcc Irisrepeat
cmp #40
bcc Irclearcount
lda #32
sta rIrLoopcount
stz rIrCountLbuf
bra Irclearcount
Irisrepeat:
lda rIrIncount
beq Irclearcount
smb IR_RP,IOP_DATA5_H
rmb IR_RD,IOP_DATA5_H
lda #14
sta rIrIncount
Irclearcount:
stz rIrCountH
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -