Skip to content
Permalink
Browse files

YAZ180 - Am9511A banked device driver

  • Loading branch information...
feilipu committed Jun 5, 2018
1 parent bdac4fe commit 74093a424239e56a84b54ed827ef836497c0ae71
@@ -83,16 +83,19 @@

// Functions

extern void apu_init(void);


extern void apu_reset(void);


extern uint8_t apu_chk_idle(void);


extern void apu_cmd_ld(uint32_t operand,uint8_t command);
extern void apu_cmd(uint8_t command);


extern uint8_t apu_op_rem(void * operand);
extern void apu_opp(uint8_t command,int8_t bank,void * operand);



@@ -81,9 +81,10 @@ include(__link__.m4)

// Functions

__OPROTO(`a,b,c,d,e,iyh,iyl',`a,b,c,d,e,iyh,iyl',void,,apu_init,void)
__OPROTO(`a,b,c,d,e,iyh,iyl',`a,b,c,d,e,iyh,iyl',void,,apu_reset,void)
__DPROTO(`b,c,d,e,iyh,iyl',`b,c,d,e,iyh,iyl',uint8_t,,apu_chk_idle,void)
__DPROTO(`iyh,iyl',`iyh,iyl',void,,apu_cmd_ld,uint32_t operand,uint8_t command)
__DPROTO(`iyh,iyl',`iyh,iyl',uint8_t,,apu_op_rem,void * operand)
__OPROTO(`b,c,d,e,iyh,iyl',`b,c,d,e,iyh,iyl',uint8_t,,apu_chk_idle,void)
__DPROTO(`iyh,iyl',`iyh,iyl',void,,apu_cmd,uint8_t command)
__DPROTO(`iyh,iyl',`iyh,iyl',void,,apu_opp,uint8_t command,int8_t bank,void * operand)

#endif
@@ -83,18 +83,21 @@

// Functions

extern void __LIB__ apu_init(void) __smallc;


extern void __LIB__ apu_reset(void) __smallc;


extern uint8_t __LIB__ apu_chk_idle(void) __smallc __z88dk_fastcall;
extern uint8_t __LIB__ apu_chk_idle(void) __smallc;


extern void __LIB__ apu_cmd_ld(uint32_t operand,uint8_t command) __smallc;
extern void __LIB__ apu_cmd_ld_callee(uint32_t operand,uint8_t command) __smallc __z88dk_callee;
#define apu_cmd_ld(a,b) apu_cmd_ld_callee(a,b)
extern void __LIB__ apu_cmd(uint8_t command) __smallc __z88dk_fastcall;


extern uint8_t __LIB__ apu_op_rem(void * operand) __smallc __z88dk_fastcall;
extern void __LIB__ apu_opp(uint8_t command,int8_t bank,void * operand) __smallc;
extern void __LIB__ apu_opp_callee(uint8_t command,int8_t bank,void * operand) __smallc __z88dk_callee;
#define apu_opp(a,b,c) apu_opp_callee(a,b,c)



@@ -83,21 +83,20 @@

// Functions

extern void apu_init(void) __preserves_regs(a,b,c,d,e,iyh,iyl);

extern void apu_reset(void) __preserves_regs(a,b,c,d,e,iyh,iyl);

extern uint8_t apu_chk_idle(void) __preserves_regs(b,c,d,e,iyh,iyl);
extern uint8_t apu_chk_idle_fastcall(void) __preserves_regs(b,c,d,e,iyh,iyl) __z88dk_fastcall;
#define apu_chk_idle(a) apu_chk_idle_fastcall(a)


extern void apu_cmd_ld(uint32_t operand,uint8_t command) __preserves_regs(iyh,iyl);
extern void apu_cmd_ld_callee(uint32_t operand,uint8_t command) __preserves_regs(iyh,iyl) __z88dk_callee;
#define apu_cmd_ld(a,b) apu_cmd_ld_callee(a,b)
extern void apu_cmd(uint8_t command) __preserves_regs(iyh,iyl);
extern void apu_cmd_fastcall(uint8_t command) __preserves_regs(iyh,iyl) __z88dk_fastcall;
#define apu_cmd(a) apu_cmd_fastcall(a)


extern uint8_t apu_op_rem(void * operand) __preserves_regs(iyh,iyl);
extern uint8_t apu_op_rem_fastcall(void * operand) __preserves_regs(iyh,iyl) __z88dk_fastcall;
#define apu_op_rem(a) apu_op_rem_fastcall(a)
extern void apu_opp(uint8_t command,int8_t bank,void * operand) __preserves_regs(iyh,iyl);
extern void apu_opp_callee(uint8_t command,int8_t bank,void * operand) __preserves_regs(iyh,iyl) __z88dk_callee;
#define apu_opp(a,b,c) apu_opp_callee(a,b,c)



@@ -57,9 +57,8 @@ define(`__IO_PCA9665_2_PORT_BASE', 0x8000) # Base Address for PCA9665 2 I/O

# Am9511A-1 APU Definitions

define(`__APU_CMD_SIZE', 0x100) # Size of the CMD Buffer, 256 CMDs
define(`__APU_PTR_SIZE', 0x100) # Size of the Data PTR Buffer
define(`__APU_DATA_SIZE', 0x100) # Size of the DATA Buffer
define(`__APU_CMD_SIZE', 0x100) # Size of the CMD Buffer, 255 Commands
define(`__APU_PTR_SIZE', 0x100) # Size of the Data PTR Buffer, 85 Operands

define(`__IO_APU_PORT_BASE', 0xC000) # Base Address for Am9511A

@@ -103,7 +102,6 @@ PUBLIC `__IO_PCA9665_2_PORT_BASE'

PUBLIC `__APU_CMD_SIZE'
PUBLIC `__APU_PTR_SIZE'
PUBLIC `__APU_DATA_SIZE'

PUBLIC `__IO_APU_PORT_BASE'
')
@@ -142,7 +140,6 @@ defc `__IO_PCA9665_2_PORT_BASE' = __IO_PCA9665_2_PORT_BASE

defc `__APU_CMD_SIZE' = __APU_CMD_SIZE
defc `__APU_PTR_SIZE' = __APU_PTR_SIZE
defc `__APU_DATA_SIZE' = __APU_DATA_SIZE

defc `__IO_APU_PORT_BASE' = __IO_APU_PORT_BASE
')
@@ -182,7 +179,6 @@ ifdef(`CFG_C_DEF',

`#define' `__APU_CMD_SIZE' __APU_CMD_SIZE
`#define' `__APU_PTR_SIZE' __APU_PTR_SIZE
`#define' `__APU_DATA_SIZE' __APU_DATA_SIZE

`#define' `__IO_APU_PORT_BASE' __IO_APU_PORT_BASE
')
@@ -65,7 +65,6 @@

#define __APU_CMD_SIZE 0x100
#define __APU_PTR_SIZE 0x100
#define __APU_DATA_SIZE 0x100

#define __IO_APU_PORT_BASE 0xC000

@@ -60,7 +60,6 @@ defc __IO_PCA9665_2_PORT_BASE = 0x8000

defc __APU_CMD_SIZE = 0x100
defc __APU_PTR_SIZE = 0x100
defc __APU_DATA_SIZE = 0x100

defc __IO_APU_PORT_BASE = 0xC000

@@ -59,7 +59,6 @@ PUBLIC __IO_PCA9665_2_PORT_BASE

PUBLIC __APU_CMD_SIZE
PUBLIC __APU_PTR_SIZE
PUBLIC __APU_DATA_SIZE

PUBLIC __IO_APU_PORT_BASE

@@ -94,7 +93,6 @@ defc __IO_PCA9665_2_PORT_BASE = 0x8000

defc __APU_CMD_SIZE = 0x100
defc __APU_PTR_SIZE = 0x100
defc __APU_DATA_SIZE = 0x100

defc __IO_APU_PORT_BASE = 0xC000

@@ -30,23 +30,23 @@ DEFC _dmac1Lock = $F514
PUBLIC _csioLock
DEFC _csioLock = $F515

PUBLIC _APULock
DEFC _APULock = $F52C
PUBLIC APULock
DEFC APULock = $F527

PUBLIC _bios_ioByte
DEFC _bios_ioByte = $F52D
DEFC _bios_ioByte = $F528

PUBLIC _asci0RxLock
DEFC _asci0RxLock = $F533
PUBLIC asci0RxLock
DEFC asci0RxLock = $F52E

PUBLIC _asci0TxLock
DEFC _asci0TxLock = $F539
PUBLIC asci0TxLock
DEFC asci0TxLock = $F534

PUBLIC _asci1RxLock
DEFC _asci1RxLock = $F53F
PUBLIC asci1RxLock
DEFC asci1RxLock = $F53A

PUBLIC _asci1TxLock
DEFC _asci1TxLock = $F545
PUBLIC asci1TxLock
DEFC asci1TxLock = $F540

PUBLIC _call_far_rst
DEFC _call_far_rst = $F58C
@@ -96,90 +96,90 @@ DEFC _lock_give = $F893
PUBLIC _lock_give_fastcall
DEFC _lock_give_fastcall = $F897

PUBLIC _apu_init
DEFC _apu_init = $F8C9
PUBLIC asm_am9511a_isr
DEFC asm_am9511a_isr = $F8C9

PUBLIC _apu_reset
DEFC _apu_reset = $F971
PUBLIC asm_am9511a_reset
DEFC asm_am9511a_reset = $F993

PUBLIC _apu_chk_idle_fastcall
DEFC _apu_chk_idle_fastcall = $F9D7
PUBLIC asm_am9511a_chk_idle
DEFC asm_am9511a_chk_idle = $F9ED

PUBLIC _apu_cmd_ld_callee
DEFC _apu_cmd_ld_callee = $F9EE
PUBLIC asm_am9511a_opp
DEFC asm_am9511a_opp = $FA04

PUBLIC _apu_op_rem_callee
DEFC _apu_op_rem_callee = $FA31
PUBLIC asm_am9511a_cmd
DEFC asm_am9511a_cmd = $FA40

PUBLIC _asci0_init
DEFC _asci0_init = $FABB
DEFC _asci0_init = $FAB4

PUBLIC _asci0_flush_Rx_di
DEFC _asci0_flush_Rx_di = $FAD4
DEFC _asci0_flush_Rx_di = $FACD

PUBLIC _asci0_flush_Tx_di
DEFC _asci0_flush_Tx_di = $FAEC
DEFC _asci0_flush_Tx_di = $FAE5

PUBLIC _asci0_reset
DEFC _asci0_reset = $FB04
DEFC _asci0_reset = $FAFD

PUBLIC _asci0_getc
DEFC _asci0_getc = $FB0E
DEFC _asci0_getc = $FB07

PUBLIC _asci0_peekc
DEFC _asci0_peekc = $FB24
DEFC _asci0_peekc = $FB1D

PUBLIC _asci0_pollc
DEFC _asci0_pollc = $FB30
DEFC _asci0_pollc = $FB29

PUBLIC _asci0_putc
DEFC _asci0_putc = $FB38
DEFC _asci0_putc = $FB31

PUBLIC _asci1_init
DEFC _asci1_init = $FBD7
DEFC _asci1_init = $FBD0

PUBLIC _asci1_flush_Rx_di
DEFC _asci1_flush_Rx_di = $FBF0
DEFC _asci1_flush_Rx_di = $FBE9

PUBLIC _asci1_flush_Tx_di
DEFC _asci1_flush_Tx_di = $FC08
DEFC _asci1_flush_Tx_di = $FC01

PUBLIC _asci1_reset
DEFC _asci1_reset = $FC20
DEFC _asci1_reset = $FC19

PUBLIC _asci1_getc
DEFC _asci1_getc = $FC2A
DEFC _asci1_getc = $FC23

PUBLIC _asci1_peekc
DEFC _asci1_peekc = $FC40
DEFC _asci1_peekc = $FC39

PUBLIC _asci1_pollc
DEFC _asci1_pollc = $FC4C
DEFC _asci1_pollc = $FC45

PUBLIC _asci1_putc
DEFC _asci1_putc = $FC54
DEFC _asci1_putc = $FC4D

PUBLIC ide_read_sector
DEFC ide_read_sector = $FD9A
DEFC ide_read_sector = $FD93

PUBLIC ide_write_sector
DEFC ide_write_sector = $FDCA
DEFC ide_write_sector = $FDC3

PUBLIC rhex
DEFC rhex = $FE31
DEFC rhex = $FE2A

PUBLIC phexwd
DEFC phexwd = $FE0A
DEFC phexwd = $FE03

PUBLIC phex
DEFC phex = $FE14
DEFC phex = $FE0D

PUBLIC pstring
DEFC pstring = $FDF7
DEFC pstring = $FDF0

PUBLIC pnewline
DEFC pnewline = $FE01
DEFC pnewline = $FDFA

PUBLIC _common1_phase_end
DEFC _common1_phase_end = $FE57
DEFC _common1_phase_end = $FE50

@@ -4,4 +4,5 @@ target/yaz180/device/am9511a/__am9511a_data
target/yaz180/device/am9511a/am9511a_isr
target/yaz180/device/am9511a/am9511a_reset
target/yaz180/device/am9511a/am9511a_check_idle
target/yaz180/device/am9511a/am9511a_command_load
target/yaz180/device/am9511a/am9511a_command
target/yaz180/device/am9511a/am9511a_operand
@@ -0,0 +1,31 @@
;------------------------------------------------------------------------------
; APU_CMD
;
; C = APU COMMAND

INCLUDE "config_private.inc"

SECTION code_driver

PUBLIC asm_am9511a_cmd

EXTERN APUCMDInPtr, APUPTRInPtr
EXTERN APUCMDBufUsed, APUPTRBufUsed


asm_am9511a_cmd:
ld a,(APUCMDBufUsed) ; Get the number of bytes in the COMMAND buffer
cp __APU_CMD_SIZE-1 ; check whether there is space in the buffer
ret NC ; COMMAND buffer full, so exit

ld hl,APUCMDBufUsed
di
inc (hl) ; atomic increment of COMMAND count
ld hl,(APUCMDInPtr) ; get the pointer to where we poke
ei
ld (hl),c ; write the COMMAND byte to the APUCMDInPtr

inc l ; move the COMMAND pointer low byte along, 0xFF rollover
ld (APUCMDInPtr),hl ; write where the next byte should be poked
ret

Oops, something went wrong.

0 comments on commit 74093a4

Please sign in to comment.
You can’t perform that action at this time.