Example program for the Cidco MailStation Z80 computer

wifi: Preserve upper 4 status bits on CONTROL_PORT

Only the bottom 4 bits of this port are control bits for the
parallel port. The upper 4 are status bits for power, so if we're
constantly clearing them in our WiFiStation routines, we won't get
proper readings of the power button when it's pressed.

+15 -5
+15 -5
lib/wifi.s
··· 27 27 .equ CONTROL_DIR_IN, #0 28 28 29 29 .equ CONTROL_PORT, #0x9 30 + .equ CONTROL_STATUS_MASK, #0xf0 30 31 .equ CONTROL_STROBE_BIT, #0 31 32 .equ CONTROL_STROBE, #(1 << CONTROL_STROBE_BIT) 32 33 .equ CONTROL_LINEFEED_BIT, #1 ··· 48 49 ; lower control lines 49 50 ld a, #CONTROL_DIR_OUT 50 51 out (#CONTROL_DIR), a 51 - xor a 52 + in a, (#CONTROL_PORT) 53 + and #CONTROL_STATUS_MASK 52 54 out (#CONTROL_PORT), a 53 55 ret 54 56 ··· 75 77 ld c, 4(ix) ; char to send 76 78 ld a, #DATA_DIR_OUT 77 79 out (#DATA_DIR), a ; we're sending out 78 - ld a, #CONTROL_STROBE 80 + in a, (#CONTROL_PORT) 81 + and #CONTROL_STATUS_MASK 82 + set #CONTROL_STROBE_BIT, a 79 83 out (#CONTROL_PORT), a ; raise strobe 80 84 ld de, #0xffff 81 85 wait_for_ack: ··· 94 98 ld a, c 95 99 out (#DATA_PORT), a ; write data 96 100 xor a 101 + in a, (#CONTROL_PORT) 102 + and #CONTROL_STATUS_MASK 97 103 out (#CONTROL_PORT), a ; lower strobe 98 104 ld de, #0xffff 99 105 wait_for_final_ack: ··· 114 120 ld hl, #0 ; return 0 115 121 ret 116 122 abort_send: 117 - xor a 123 + in a, (#CONTROL_PORT) 124 + and #CONTROL_STATUS_MASK 118 125 out (#CONTROL_PORT), a ; lower strobe 119 126 pop de 120 127 pop bc ··· 137 144 jr nz, recv_done 138 145 ld a, #DATA_DIR_IN 139 146 out (#DATA_DIR), a ; we're reading in 140 - ld a, #CONTROL_LINEFEED ; raise linefeed 147 + in a, (#CONTROL_PORT) 148 + and #CONTROL_STATUS_MASK 149 + set #CONTROL_LINEFEED_BIT, a ; raise linefeed 141 150 out (#CONTROL_PORT), a 142 151 ld de, #0xffff 143 152 wait_for_busy_ack: ··· 157 166 ld h, #0 158 167 ld l, a 159 168 raise_lf: 160 - xor a 169 + in a, (#CONTROL_PORT) 170 + and #CONTROL_STATUS_MASK 161 171 out (#CONTROL_PORT), a ; lower linefeed 162 172 recv_done: 163 173 pop de