📄 iop.asm
字号:
;;------------------------------------------------------------------
;; File Name : IOP.asm
;;
;; Description : This module customers and function define
;; It is used for normal play.
;;
;; Version : IOP.01.040924
;;
;; Rev Date Author(s) Status & Comments
;;-------------------------------------------------------------------
;; 2004/9/24 LIJD Updating
;;
;;-------------------------------------------------------------------
;;===================================================================
;;Define DVD Module
;;===================================================================
SUNPLUS_DVD equ 1
QISHENG_DVD equ 0
PULIANG_DVD equ 0
HUAJIA_DVD equ 0
APOLLO_DVD equ 0
YADAI_DVD equ 0
PANDA_DVD equ 0
TTE_DVD equ 0
;;===================================================================
;;Define Customers Config
;;===================================================================
.ifnz SUNPLUS_DVD
.include .\\customers\sunplus.asm
.endif
;;===================================================================
.ifnz QISHENG_DVD
.include .\\customers\qisheng.asm
.endif
;;===================================================================
.ifnz PULIANG_DVD
.include .\\customers\puliang.asm
.endif
;;===================================================================
.ifnz HUAJIA_DVD
.include .\\customers\huajia.asm
.endif
;;===================================================================
.ifnz APOLLO_DVD
.include .\\customers\apollo.asm
.endif
;;===================================================================
.ifnz YADAI_DVD
.include .\\customers\yadai.asm
.endif
;;===================================================================
.ifnz PANDA_DVD
.include .\\customers\panda.asm
.endif
;;===================================================================
.ifnz TTE_DVD
.include .\\customers\tte.asm
.endif
;;===================================================================
;; Function : Main program entry
;; Input : NONE
;; Output : NONE
;;===================================================================
.SYNTAX 6502
.CHIP r65c02
.LINKLIST
.SYMBOLS
.MACFIRST ON
.include 6502s.inc
.include iop.inc
;;===================================================================
;;Define variable
;;===================================================================
.PAGE0
RAM_TOP equ $
;;public variable
rVfdPollingTm ds 1
rOutBuffer ds 1
bPortBuff ds 1
rSysCtrlFlag ds 1
rDataLen ds 1
;;----------------------------------------------------------------------------------------
.ifnz GAMEPAD_SUPPORT
bGamePortBuff ds 1
.endif
.ifnz PCA9564
pca9564_state ds 1
pca9564_rx_in_ptr ds 1
pca9564_tx_out_ptr ds 1
rx_buffer_full_flag ds 1
tx_buffer_empty_flag ds 1
stop_timeout_counter ds 1
temp ds 1
Translate_data_flag ds 1
rOutBuffer_9564 ds 1
.endif
.ifnz HT1621
bPortBuff_1621 ds 1
.endif
.ifnz STANDBY_6313
standby_flag_first ds 1
standby_flag_end ds 1
.endif
.ifnz IOP_RESET_RISC
awakeup_time_1 ds 1
awakeup_time_2 ds 1
awaken_flag ds 1
.endif
.ifnz SPL10308
rAddress ds 1
DelayLoopCnt ds 1
rPort7Cfg ds 1
.endif
.ifnz SPL10
rAddress ds 1
rSpl10CtrlFlag ds 1
rCounter ds 1
bPortBuff_clk ds 1
bPortBuff_data ds 1
rDataLen_spl10 ds 1
.endif
.ifnz PMP_MCU810_DRIVER
rSpl10CtrlFlag ds 1
rCounter ds 1
bPortBuff_clk ds 1
bPortBuff_data ds 1
rDataLen_spl10 ds 1
.endif
.ifnz PT6554
pt6554_count ds 1
pt6554_display_length ds 1
pt6554_count_key ds 1
pt6554_receiver ds 4
.endif
.ifnz AD7312
WriteToRegData ds 1
DataReadFromReg ds 1
FirstConnectPowerFlag ds 1
AD7312RegAddr ds 1
.endif
.ifnz HC164
rRegister164 ds 1
rOutBuffer_164 ds 1
.endif
.ifnz HC164_2
rRegister164 ds 1
rOutBuffer_164 ds 1
.endif
.ifnz GT1128
rLcddata: ds 2
rLcdstate: ds 1
rLcdloopcount: ds 1
rLcdscantime: ds 1
rLcdsendcount: ds 1
rLcdtemp: ds 1
rLcdreadcount ds 1
rLcdKeyData ds 4
.endif
;;I2C function
.ifnz I2C_SUPPORT
rCtrlByte ds 1
rAddr ds 1
rData ds 1
.endif
;;UART
.ifnz UART_SUPPORT
rIntFlag ds 1
rTxdRegister ds 2
rUartSendLen ds 1
rUartTranCnt ds 1
rUartRecvCnt ds 1
rUartRecvFlag ds 1
rUartRecvLen ds 1
rRxdRegister ds 2
.endif
;;NEC IR control
.ifnz IR_NEC
rIrCustCode ds 2
rIrState ds 1
rIrBitKeepLen ds 1
rIrBitKeepLenH ds 1
rIrBitStatus ds 1
rIrReceiver ds 4
rIrRepeateRate ds 1
rRepValid ds 1
.endif
;;philips IR control
.ifnz IR_PHILIPS
rIrBitKeepLen ds 1
rIrBitKeepLenH ds 1
rIrBitStatus ds 1
rHasBitBefore ds 1
rStartBit ds 1
rIrReceiver ds 2
rRolCnt ds 1
rIrRepeateRate ds 1
rRepValid ds 1
rIrCodePerv ds 1
.endif
.ifnz IR_THOMSON
markcount ds 1
spacecount ds 1
synccount ds 1
bit01count ds 1
IrStateFlag ds 1
bitis0 ds 1
bitis1 ds 1
Receiver1 ds 1
Receiver2 ds 1
datacount ds 1
repeattimes ds 1
.endif
.ifnz IR_M50560
MarkCounter ds 1
SpaceCounter ds 1
SyncCounter ds 1
Bit01Counter ds 1
Low4msCounter ds 1
IrStateFlag ds 1
BitIs1 ds 1
BitIs0 ds 1
RepTimes ds 1
CustomCode ds 1
DataCode ds 1
BitsCounter ds 1
Flag4Ms ds 1
.endif
.ifnz IR_AS1213
MarkCounter ds 1
SpaceCounter ds 1
SyncCounter ds 1
Bit01Counter ds 1
IrStateFlag ds 1
BitIs1 ds 1
BitIs0 ds 1
RepRate ds 1
Repdata ds 1
rReceive1 ds 1
rReceive2 ds 1
rReceive3 ds 1
rReceive4 ds 1
BitsCounter ds 1
.endif
.ifnz IR_M3004
IrStateFlag ds 1
First_pulse_flag ds 1
Idle_counter ds 1
Bit01_counter ds 1
Level_high_flag ds 1
First_5bit_data ds 1
Last_8bit_data ds 1
Data_bit_counter ds 1
Prev_last8bit ds 1
Prev_first5bit ds 1
DataRepeatCounter ds 1
.endif
.ifnz IR_KONKA
IrStateFlag ds 1
IO_high_counter ds 1
IO_low_counter ds 1
Data_Customer_Code ds 1
Data_IR_Code ds 1
Data_bits_counter ds 1
First_send_data_flag ds 1
Repeat_counter ds 1
Prev_ir_data ds 1
Idle_counter ds 1
.endif
.ifnz IR_TDP101
IrStateFlag ds 1
IO_high_counter ds 1
IO_low_counter ds 1
Custom_code ds 1
Custom_code_reverse ds 1
IR_data ds 1
IR_data_reverse ds 1
Data_bit_counter ds 1
Repeat_counter ds 1
Separate_flag ds 1
Separate_counter ds 1
.endif
RAM_BOTTOM equ $
;;===================================================================
;; code
;; 1. system have 512 byte SRAM inside (0x0040 ~ 0x0240)
;; 2. $0 ~ $40 -> direct I/O control register (no include in SRAM area)
;; $40 ~ $ff -> zero page free
;; $100 ~ 1ff -> page 1
;; $200 ~ $205 -> each vector
;; $206 ~ $23f -> free direct-mapping area
;; $240 ~ $ -> cached ram for $240 ~ $ffff
;;
;; design $200 ~ $205 for each vector to reduce code size
;;===================================================================
SRAM_PG0: .section
vIrq:
pha
phx
;;interrupt service routine
lda IntFlag
sta IntFlag ;;clear intr flag
;;now only timerA,timerB enable
.ifnz IOP_RESET_RISC
lda awaken_flag
cmp #1
bne clear_counter
inc awakeup_time_1
bra count_end
clear_counter:
lda #0
sta awakeup_time_1
lda #0
sta awakeup_time_2
count_end:
.endif
.ifnz UART_SUPPORT
.include UART.asm
.endif
.ifnz IR_NEC
.include .\IR\IR_NEC.asm
.endif
.ifnz IR_PHILIPS
.include .\IR\IR_PHILIPS.asm
.endif
.ifnz IR_THOMSON
.include .\IR\IR_THOMSON.asm
.endif
.ifnz IR_M50560
.include .\IR\IR_M50560.asm
.endif
.ifnz IR_AS1213
.include .\IR\IR_AS1213.asm
.endif
.ifnz IR_M3004
.include .\IR\IR_M3004.asm
.endif
.ifnz IR_KONKA
.include .\IR\IR_KONKA.asm
.endif
.ifnz IR_TDP101
.include .\IR\IR_TDP101.asm
.endif
.ifnz PCA9564
.include .\IR\PCA9564_INT.asm
.endif
;;for timerB (IR) irq exit
lIrqIrExit:
lda rVfdPollingTm
beq lIrqExit
dec rVfdPollingTm
lIrqExit:
plx
pla
vNmi:
rti
;;===================================================================
GAMEPAD_PG: .section
;;===================================================================
.if UART_SUPPORT
.CODE
.endif
.ifnz GAMEPAD_SUPPORT
.include GAME.asm
.endif
.CODE
;;===================================================================
;;Reset entry
;;===================================================================
vReset:
;;initialize stack point
sei
ldx #FFH
txs
;;Clear work ram (all variable = 0 from reset )
ldx #RAM_TOP
lClearAllRAM:
stz 0,X
inx
cpx #RAM_BOTTOM
bne lClearAllRAM
;;===================================================================
;;initialize I/O
;;===================================================================
;;init i2c
.ifnz I2C_SUPPORT
.ifnz I2C_8202_16bit
smb I2C_SDA_bit,I2C_SDA_PORT_CFG
smb I2C_SCL_bit,I2C_SCL_PORT_CFG
smb I2C_SDA_bit,bPortBuff
lda bPortBuff
sta I2C_SDA_PORT
smb I2C_SCL_bit,bPortBuff
lda bPortBuff
sta I2C_SCL_PORT
.else
smb I2C_SDA_bit,I2C_PORT_CFG
smb I2C_SCL_bit,I2C_PORT_CFG
smb I2C_SDA_bit,bPortBuff
smb I2C_SCL_bit,bPortBuff
lda bPortBuff
sta I2C_PORT
.endif
.endif
;;init ir
rmb IR_IN_bit,IR_PORT_CFG
;;init vfd
.ifnz NEC16312
smb VFD_STB_bit,VFD_PORT_CFG
smb VFD_CLK_bit,VFD_PORT_CFG
smb VFD_DATA_bit,VFD_DATA_PORT_CFG
rmb VFD_STB_bit,VFD_PORT
smb VFD_CLK_bit,VFD_PORT
rmb VFD_DATA_bit,VFD_DATA_PORT
.endif
.ifnz HT1621
smb VFD_STB_bit,VFD_PORT_CFG
smb VFD_CLK_bit,VFD_PORT_CFG
smb VFD_DATA_bit,VFD_DATA_PORT_CFG
smb VFD_STB_bit,bPortBuff_1621
smb VFD_CLK_bit,bPortBuff_1621 ;; set CLK = 1
lda bPortBuff_1621
sta VFD_PORT
smb VFD_DATA_bit,bPortBuff_1621
lda bPortBuff_1621
sta VFD_DATA_PORT
.endif
.ifnz SPL10
smb VFD_CLK_bit,VFD_PORT_CFG ;; set output enable
rmb VFD_STB_bit,VFD_PORT_CFG
smb VFD_DATA_bit,VFD_DATA_PORT_CFG
smb VFD_CLK_bit,bPortBuff_clk
lda bPortBuff_clk
sta VFD_PORT
smb VFD_DATA_bit,bPortBuff_data
lda bPortBuff_data
sta VFD_DATA_PORT
.endif
.ifnz PMP_MCU810_DRIVER
smb VFD_CLK_bit,VFD_PORT_CFG ;; set output enable
rmb VFD_STB_bit,VFD_PORT_CFG
smb VFD_DATA_bit,VFD_DATA_PORT_CFG
smb VFD_CLK_bit,VFD_PORT
smb VFD_DATA_bit,VFD_DATA_PORT
.endif
.ifnz AD7312
smb VFD_STB_bit,VFD_PORT_CFG
smb VFD_CLK_bit,VFD_PORT_CFG
smb VFD_DATA_bit,VFD_DATA_PORT_CFG
rmb VFD_STB_bit,VFD_PORT
smb VFD_CLK_bit,VFD_PORT
rmb VFD_DATA_bit,VFD_DATA_PORT
.endif
.ifnz PT6554
smb VFD_CLK_bit,VFD_PORT_CFG ;; set output enable
smb VFD_STB_bit,GPIO_IO6_CFG
smb VFD_DATA_bit,GPIO_IO7_CFG
rmb VFD_DATA_IN_bit,GPIO_IO0_CFG
rmb VFD_CLK_bit,VFD_PORT
.endif
.ifnz HC164
smb VFD_CLK_bit,VFD_PORT_CFG ;; set output enable
rmb VFD_STB_bit,GPIO_IO6_CFG
smb VFD_DATA_bit,GPIO_IO7_CFG
.endif
.ifnz HC164_2
rmb VFD_STB_bit,VFD_PORT_CFG
smb VFD_CLK_bit,VFD_PORT_CFG
smb VFD_DATA_bit,VFD_DATA_PORT_CFG
smb VFD_CLK_bit,VFD_PORT
smb VFD_DATA_bit,VFD_DATA_PORT
.endif
.ifnz SPL10308
rmb VFD_STB_bit,bPortBuff
smb VFD_CLK_bit,VFD_PORT_CFG ;; set output enable
smb VFD_CLK_bit,bPortBuff ;; set CLK = 1
lda bPortBuff
sta VFD_PORT
rmb VFD_DATA_bit,bPortBuff
lda bPortBuff
sta VFD_DATA_PORT
.endif
.ifnz GT1128
smb VFD_STB_bit,VFD_PORT_CFG
smb VFD_CLK_bit,VFD_PORT_CFG
smb VFD_DATA_bit,VFD_DATA_PORT_CFG
smb VFD_STB_bit,VFD_PORT
smb VFD_CLK_bit,VFD_PORT
smb VFD_DATA_bit,VFD_DATA_PORT
.endif
.ifnz PCA9564
;; WR output 1
smb PCA9564_WR_bit,PCA9564_WR_CFG
smb PCA9564_WR_bit,PCA9564_WR_PORT
;; RD output 1
smb PCA9564_RD_bit,PCA9564_RD_CFG
smb PCA9564_RD_bit,PCA9564_RD_PORT
;; CE output 1
smb PCA9564_CE_bit,PCA9564_CE_CFG
smb PCA9564_CE_bit,PCA9564_CE_PORT
;; A0 output 1
smb PCA9564_A0_bit,PCA9564_A0_CFG
smb PCA9564_A0_bit,PCA9564_A0_PORT
;; A1 output 1
smb PCA9564_A1_bit,PCA9564_A1_CFG
smb PCA9564_A1_bit,PCA9564_A1_PORT
;; INT INPUT
rmb PCA9564_INT_bit,PCA9564_INT_CFG
;; RESET output 1
smb PCA9564_RESET_bit,PCA9564_RESET_CFG
smb PCA9564_RESET_bit,PCA9564_RESET_PORT
;; DATA output #%11111111
lda #%11111111
sta PCA9564_DATA_CFG
lda #%11111111
sta PCA9564_DATA_PORT
.endif
;;initialize game port
.ifnz GAMEPAD_SUPPORT
.ifnz SPHE8202
.ifnz GAMEPAD_FOR_128PIN
rmb GPAD_D0,GPAD_PORT_CFG_D0
rmb GPAD_D1,GPAD_PORT_CFG_D1
.else
rmb GPAD_D0,bGamePortBuff
lda bGamePortBuff
sta GPAD_PORT_CFG_D0_D1
rmb GPAD_D1,bGamePortBuff
lda bGamePortBuff
sta GPAD_PORT_CFG_D0_D1
.endif
.endif
.ifnz SPHE8200
lda GPAD_PORT_CFG_D0_D1
and #GPAD_CFG_D0_D1
sta GPAD_PORT_CFG_D0_D1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -