I wrote this test link program, the idea is to have the calc that fist runs it to invevitably display 0, and the second to display 1.
Code:
After running it on one calc, when I attach the link cable (wabbitemu virtual link) the program ends and displays 0 (the calcs also freeze, but I think this is a problem with the emulator, because opening/closing the debugger fixes it). I've compared this with some other similar routines and I can't find the issue, anybody have any ideas?
Code:
call linkConnect
ld a, 0
ld (curCol), a
ld (curRow), a
ld hl, (currentLine)
bcall(_DispHL)
ret
linkConnect:
in a, (0) ;Check if the other calc is waiting
and 3
cp 2
jr z, _setCurrentLine1
ld a, 0
ld (currentLine), a
_waitLoop:
ld a, 1 ;Pulling our line low
out (0), a
in a, (0) ;Waiting for both lines to be low
and 3
cp 0
jr nz, _waitLoop
jr _endLinkConnect
_setCurrentLine1:
ld a, 1
ld (currentLine), a
ld a, 2 ;Setting the line low
out (0), a
_endLinkConnect:
ret
currentLine:
.db 0
After running it on one calc, when I attach the link cable (wabbitemu virtual link) the program ends and displays 0 (the calcs also freeze, but I think this is a problem with the emulator, because opening/closing the debugger fixes it). I've compared this with some other similar routines and I can't find the issue, anybody have any ideas?