X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fcoinmech.c;h=a6c0e51989248fba35c6f71d728f603d45b2809c;hb=c99662693a4d79f65d406473647debbd33ec521e;hp=b52559da1a09827df5b0e73aad4f2b66e9d836f4;hpb=11baa477da66fe8b2899dd50bd71d11615ff050e;p=uccvend-snackrom.git diff --git a/ROM2/coinmech.c b/ROM2/coinmech.c index b52559d..a6c0e51 100644 --- a/ROM2/coinmech.c +++ b/ROM2/coinmech.c @@ -3,15 +3,15 @@ #define COINMECH_ID 0x20 -u8 last_byte; -u8 packet_pos = 0; -u16 value_1 = 0; -u8 value_2 = 0; -u8 dec_point = 0; +volatile u8 last_byte; +volatile u8 packet_pos = 0; +volatile u16 value_1 = 0; +volatile u8 value_2 = 0; +volatile u8 dec_point = 0; -u16 coin_value = 0; +volatile u16 coin_value = 0; u8 item_cost = 0; -bool have_change = 0; +volatile bool have_change = 0; u8 parity_test(u8 c) { u8 parity = 0; @@ -31,6 +31,8 @@ bool parity_good(u8 c) { * -----+--------- * R8 0 | 1 0 * 1 | 0 1 + * + * equates to even parity? */ u8 R8 = (_io_ports[M6811_SCCR1] & M6811_R8)?1:0; @@ -48,12 +50,6 @@ void send_byte(u8 c) { bclr((void*)&_io_ports[M6811_SCCR1], M6811_T8); } -void ask_for_retrans() { - /* sends an 0xff down the line */ - send_byte(0xff); -} - - #define IS_CTRL(x) (x & 0x10) /* true if this packet is a control packet */ void sci_interrupt() { u8 in; @@ -62,7 +58,7 @@ void sci_interrupt() { /* test for framing errors & parity bit */ if (_io_ports[M6811_SCSR] & M6811_FE || !parity_good(in)) { _io_ports[M6811_SCDR]; /* read of register req'd to clear FE */ - ask_for_retrans(); + send_byte(0xff); /* request a retransmit */ return; } @@ -132,4 +128,5 @@ void coin_eat() { void coin_cost(u16 cost) { item_cost = cost; + while(coin_value); /* wait until coin mech cleared */ }