Button quicky

For a more efficient way than BIOS functions look at the following macro. It leaves with the state of all 8 buttons in register A.

(expects DP set to d0)

MY_READ_BUTTONS_A macro                  
            direct  $d0                  
            LDA     #$0E                ;Sound chip register 0E to port A 
            STA     <VIA_port_a          
            LDD     #$1901              ;sound BDIR on, BC1 on, mux off 
            STA     <VIA_port_b          
            NOP                         ;pause 
            STB     <VIA_port_b         ;sound BDIR off, BC1 off, mux off 
            CLR     <VIA_DDR_a          ;DDR A to input 
            LDD     #$0901              ;sound BDIR off, BC1 on, mux off 
            STA     <VIA_port_b          
            NOP                         ;pause 
            LDA     <VIA_port_a         ;Read buttons 
            STB     <VIA_port_b         ;sound BDIR off, BC1 off, mux off 
            LDB     #$FF                 
            STB     <VIA_DDR_a          ;DDR A to output 
            endm