A83: Link Routines
[Prev][Next][Index][Thread]
A83: Link Routines
Hi,
If anyone could be so kind to try to resolve this problem:
I'm just on the point of finishing a link game, the link routines work well
when tested but the game blocks from time to time, I use a TI-83 and a TI-83
Plus, the TI-83's link port is a bit used. I cannot figure out if it's my
routines, the TI-83 or the constants I use. Anyway, here's my source:
The sensible constant is TimeOut, under 1000h, any higher they block, time
depending on their value, i.e. half a second for 1000h and 2 secs for 5000h
bTransMask is equated to D0LD1H ^ (XOR) D0HD1L
; -------------------------
; | Begin | Link Routines |
CheckByte:
LD A, D0HD1H
OUT (LinkPort), A
IN A, (LinkPort)
AND LinkMask
CP LinkMask
SCF
RET Z
RecieveByte:
PUSH BC
LD B, 08h
RecieveBits:
LD DE, TimeOut
WaitBitRec:
; Recieve Bit 0: 01
; Recieve Bit 1: 10
CALL ScanLink
JR Z, LinkError
CP LinkMask
JR Z, WaitBitRec
CP bLink1
#IfNDef Plus
JR NC, RecHigh
RecLow:
LD A, D0LD1H
JR CommonLinkCode
RecHigh:
LD A, D0HD1L
#EndIf
CommonLinkCode:
RR C
OUT (LinkPort), A
XOR bMaskTrans
#IfNDef Plus
AND LinkMask >> 2
RLA
RLA
#Else
AND LinkMask
#EndIf
LD (AckWait), A
WaitNotZero:
CALL ScanLink
AckWait EQU $ + 01h
SUB NULL
JR NZ, WaitNotZero
ResetLink:
#IfNDef Plus
LD A, D0HD1H
#EndIf
OUT (LinkPort), A
LD D, 04h
WaitReady:
DEC D
JR Z, LinkReady
IN A, (LinkPort)
AND LinkMask
CP LinkMask
JR NZ, WaitReady
LinkReady:
DJNZ RecieveBits
OR A
LD A, C
POP BC
RET
ScanLink:
POP HL
DEC DE
LD A, D
OR E
JR Z, LinkError
BIT OnInterrupt, (IY + OnFlags)
JR NZ, LinkError
IN A, (LinkPort)
AND LinkMask
JP (HL)
LinkError:
POP BC
SCF
RET
SendByte:
PUSH BC
LD C, A
LD B, 09h
JR SendRes
SendBits:
LD A, D0HD1L
RR C
JR C, SendHigh
SendLow:
LD A, D0LD1H
SendHigh:
OUT (LinkPort), A
LD DE, TimeOut
WaitSndCls:
CALL ScanLink
JR NZ, WaitSndCls
SendRes:
LD A, D0HD1H
OUT (LinkPort), A
LD DE, TimeOut
WaitSndReady:
CALL ScanLink
CP LinkMask
JR NZ, WaitSndReady
DJNZ SendBits
POP BC
OR A
RET
; | End | Link Routines |
; -----------------------
Solignac Julien
Alias x1Cygnus
x1cygnus@online.fr
http://x1cygnus.online.fr/