Try this out:
Include "modedefs.bas" ' Include serial modes
DEFINE OSC 4
TRISA=$1b : trisb=$db : a var word : done var bit : x var byte : percent var byte : total var word : premios var word : cambio var word : mac var byte : t0 var total.byte0 : t1 var total.byte1
p0 var premios.byte0 : p1 var premios.byte1 : c0 var cambio.byte0 : c1 var cambio.byte1 : coinout var portb.0 : coinin var portb.1 : done=0 : percent=50
DISABLE
GOSUB READIT
loop:
IF PORTB.6 = 1 THEN LLACONECTED
IF COININ = 1 THEN COUNT1COIN
IF COINout = 1 THEN COINOUT100 'this is the problem
GOTO LOOP
COUNT1COIN: PAUSE 20 : IF COININ=1 THEN COUNT1COIN
TOTAL=TOTAL+1 : GOSUB WRITEIT:GOTO LOOP
LLACONECTED: gosub readit : pause 500:for x=1 to 5:gosub info:next x : goto borrar
BORRAR: SERIN2 PORTA.3,16780, 500,BORRAR,[WAIT ("CB"),DEC1 DONE]
IF DONE=1 THEN BORRAR1
IF DONE=0 THEN
gosub info:gosub info:gosub info
endif
GOTO BORRAR
BORRAR1: total=0 : premios=0:cambio=0:gosub writeit:for x=1 to 5 : gosub info:next x:goto loop
writeit: write 0,t0:write 1,t1:write 2,p0:write 3,p1:write 4,c0:write 5,c1 : return
readit: read 0,t0:read 1,t1:read 2,p0:read 3,p1:read 4,c0:read 5,c1:read 6,mac:return
info: serout2 porta.2,16780,["M",dec3 mac] : pause 100:serout2 porta.2,16780,["T",dec5 total] : pause 100:serout2 porta.2,16780,["P",dec5 premios] : pause 100:serout2 porta.2,16780,["S",dec5 cambio]
pause 100:return
CNT: COUNTER=1:PAUSE 20:COUNTER=0:PAUSE 20:RETURN
COINOUT100:
PREMIOS=PREMIOS+1:if total > 0 then TOTAL=TOTAL-1
GOSUB WRITEIT:GOTO LOOP
END
Bookmarks