A82: Re: My link routines.. what's wrong?


[Prev][Next][Index][Thread]

A82: Re: My link routines.. what's wrong?




I think the ROM uses $FFFF as a counter, so maybe you should try to increase
it. Have you tried to compare you routines with the stuff in the ROM ?
Someone released a document sometime ago which included commented source
code for the link routines in the ROM (85), it might be a good idea to have
a look at those and see what the differences are.

Dines
----- Original Message -----
From: Humberto Yeverino <humberto@engr.csufresno.edu>
To: Assembly82 <assembly-82@lists.ticalc.org>
Sent: Thursday, January 28, 1999 1:18 PM
Subject: A82: My link routines.. what's wrong?


>
>Here are the routines I wrote a while ago which worked on both the 85 and
>82.  These fail when the batteries are low.  Is there any way to make them
>more reliable?
>
>;Based on routines by Pascal Bouron
>;and by Jimmy Mrdell
>
>;*****
>SendBytes:
>;IN  : hl=(first byte),
>;      bc=# of bytes to send
>;      e=1 (wait for euit key)
>;      e=0 use timer
>;OUT : if carry then NOT SENT,
>;      destroyed: BC, DE, HL, A
>;*****
>  ld a,(hl)
>  push hl
>  call SendByte
>  pop hl
>  ret c
>  inc hl
>  dec bc
>  jr nz,SendBytes
>  or a
>  ret
>
>;*****
>ReceiveBytes:
>;IN  : hl=(first byte),
>;      bc=# of bytes to receive
>;OUT : if carry then NOT RECEIVED,
>;      destroyed: BC, DE, HL, A
>;*****
>  call ReceiveByte
>  ret c
>  ld (hl),a
>  inc hl
>  dec bc
>  jr nz,ReceiveBytes
>  or a
>  ret
>
>;*****
>SendByte:
>;IN  : A=byte to send
>;OUT : if carry then NOT SENT,
>;      destroyed: HL, DE, BC, A
>;*****
>  ld hl,30000 ;Timer
>  ld b,8 ;bits to send
>  ld c,a ;save byte to send in c
>  ld a,$C0
>  out (7),a ;11=ready to send
>WaitSend:
>  call TestON
>  in a,(7)
>  and 3
>  cp 3
>  jr nz,WaitSend ;if calc ready (11), send bit
>CalcBit:
>  srl c ;push bit to send into carry
>  jr nc,SendZero
>  ld a,$E8 ;set bit to 0
>  jr SB_SetPort
>SendZero:
>  ld a,$D4 ;set bit to 1
>SB_SetPort:
>  out (7),a ;write bit to port
>WaitNextSend:
>  call TestON
>  in a,(7)
>  and 3
>  jr nz,WaitNextSend ;Wait for port=00 (means bit was recieved
>  ld a,$C0
>  out (7),a ;set local to 11 (ready to send next)
>  djnz WaitSend ;if more bits, send another
>  or a ;carry=0
>  ret ;return success
>
>TestON:
>  ld a,e
>  cp 0
>  jr z,DoCountdown
>  call GET_KEY
>  cp K_EXIT
>  ret nz
>  pop hl
>LinkFailed:
>  ld a,$C0
>  out (7),a ;Make sure port is off
>  scf
>  ret
>DoCountdown:
>  dec hl
>  ld de,0 ;e is set to 0 again (but already was 0)
>  call CP_HL_DE
>  ret nz
>  pop hl
>  jr LinkFailed
>
>
>;*****
>ReceiveByte:
>;IN  : Nothing
>;OUT : a=received byte,
>;      if carry then NOT RECEIVED,
>;      destroyed: DE, BC, A
>;*****
>  ld e,0
>  ld b,8
>  ld a,$C0
>  out (7),a ;set port to 11 (ready to recieve)
>RB_Wait:
>  dec e
>  jr z,LinkFailed
>  in a,(7)
>  and 3
>  cp 3
>  jr z,RB_Wait ;if remote not 11 then get the bit
>RB_GetBit:
>  cp 2
>  jr z,RB_GetZero
>  scf
>;  rra ;Push sent bit into carry
>  rr c
>  ld a,$D4
>  jr RB_WaitStop
>RB_GetZero:
>  or a
>  rr c
>  ld a,$E8 ;will aways give other calc 00
>  out (7),a
>RB_WaitStop:
>  dec e
>  jr z,LinkFailed
>  in a,(7)
>  and 3
>  jr z,RB_WaitStop ;wait for remote = 11
>  ld a,$C0
>  out (7),a
>  djnz RB_Wait
>  ld a,c
>  or a ;carry=0 (success)
>  ret
>
>
>I'd rather not rely on any ROM routines because I want to be able to
>easily port this game.
>Thanks in advance for any help.
>
>-Humberto Yeverino Jr.
>
>