This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 17 Sep 2003 10:19:54 am    Post subject:

I found documentation about it, but the author (Timendus) wrote it and tested it on TI-83. I was wondering if it was the same on TI-83+
So has anyone here ever use this port (B_port = 00h) ?

Take a look at his opinion about TI's way :

Quote:
Port 0 is often being referred to as “BPORT”, since BPORT is equated in Ti83asm.inc, together with the values to load into it according to the official Texas Instruments documentation (see appendix Cool, which I think are incorrect:

;    LINK PORT WRITE EQUATES
;
D0LD1L      .EQU      0C3H  ; Don’t use these values!
D0LD1H      .EQU      0C1H  ; They are incorrect!
D0HD1L      .EQU      0C2H
D0HD1H      .EQU      0C0H
BPORT    .EQU      0

It took me a few weeks to figure out that the values were the reason that all my link port related programs didn’t work (at least not on my calculator), and what the values should have been. Since then I’ve seen a few other programs use the same values, and I’ve tested my own values on every calculator I could get my hands on, and it worked on every single one of them.




And here are his routines to send and receive an entire byte at once !


Code:
Sending

Write:
   ld c,a  ; Store byte
   ld d,1  ; Create bitmask
   ld e,$D1   ; Init linkport value
Write_go:
   ld a,c  ; Retrieve byte
   and d  ; and with bitmask
   or a
   call z,Set_ring_low
   call nz,Set_ring_high; Set data line (ring) according to bit
   rlc d  ; rotate bitmask
   ld a,e  ; retrieve linkport value
   out (0),a   ; Set linkport
   xor 1  ; invert clockstate
   ld e,a  ; store linkport value
   ld b,6
Delay_loop:
   djnz Delay_loop; Short delay
   ld a,d  ; bitmask back to original?
   cp 1
   jr nz,Write_go   ; No: Next bit
   ret  ; Yes: Done
Set_ring_high:
   res 1,e
   ret
Set_ring_low:
   set 1,e
   ret

Receiving

Read:
   ld b,0  ; reset variables (b = byte,
   ld d,1  ; d = bitmask, e = clockstate)
   in a,(0)   ; Get byte and check tip
   bit 2,a
   call z,State_zero
   call nz,State_one
Read_go:
   in a,(0)   ; Is clockstate changed?
   bit 2,a
   ld a,e
   jr z,Clock_is_low
   or a
   jr z,Clockchanged; Yes (High)
   jr Read_go   ; No
Clock_is_low:
   or a
   jr z,Read_go   ; No  (Low)
Clockchanged:  ; Yes
   in a,(0)   ; Get value from port
   bit 2,a
   call z,State_zero; Store new clockstate
   call nz,State_one
   bit 3,a
   call nz,Or_byte; Or them, depending on state of ring
   rlc d
   ld a,d
   cp 1
   jr z,Stop_read   ; Yes: quit
   jr Read_go   ; No, next bit
Or_byte:
   ld a,b
   or d
   ld b,a
   ret
State_zero:
   ld e,0
   ret
State_one:
   ld e,1
   ret
Stop_read:
   ld a,b
   ret
Using these routines is very simple. If you want to send over a byte, you load it in a, and you call the write routine:

ld a,164
call Write

To receive a byte, you call the read routine, that will wait for a byte being sent, and return:

   call Read
   ld l,a
   ld h,0
   call _disphl; or whatever you want to do with a




I think there are other ways to send or receive a BYTE like
B_CALL(_Sendabyte)
or even somethig with ZSQUISH but I don't know how to use it.

Could someone help me ? I'd just like to send/receive one byte.
thx
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 17 Sep 2003 12:10:01 pm    Post subject:

i need a prgm for basic where you give the specified var to get in Ans and the output var in Str0
and you put one calc in "recieve" mode then send the var on the other calc... if anyone can help...
Back to top
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 17 Sep 2003 02:33:45 pm    Post subject:

I was just thinking about a program like that : you put what you want to send in Ans, and then you call a little asm program which sends it !

But I first have to understand how it works...
Back to top
Adm.Wiggin
aka Tianon


Know-It-All


Joined: 02 Jun 2003
Posts: 1874

Posted: 17 Sep 2003 04:36:31 pm    Post subject:

Jbirk : I am going to try this for a ti-keyboard detection routine... i just run the Read (slightly moded so it doenst wait for action) and then check if it equals $E0 or whatever it was! Very Happy it might work, ill try it soon... i have a prog to do just that though! Very Happy
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 17 Sep 2003 05:49:15 pm    Post subject:

Tyraniek wrote:
I was just thinking about a program like that : you put what you want to send in Ans, and then you call a little asm program which sends it !

But I first have to understand how it works...

if you can get it to work, tell me and put it on ticalc or email it to me Smile
Back to top
DarthDevilous


Newbie


Joined: 11 Sep 2003
Posts: 3

Posted: 20 Sep 2003 09:32:16 am    Post subject:

I found a Link tutorial once, and this is the part for sending/receiving:

Code:
;=========================linktutorial example program by merlijn===============
;=================================www.ti-merlijn.tk=============================

#define  player saferam1
#define  errors saferam1+1

start:
   bcall(_cleargbuf)
   ld a,55
   ld (penrow),a
   ld a,53
   ld (pencol),a
   ld hl,presskey
   bcall(_vputs)
   ld a,1
   ld (errors),a
   ld a,0ffh   ;resets the keypad.
   out (1),a

waitkey:
   IN A,(0)   ;check linkport
   AND 3  ;upper bits are not important
   CP 2
   jp z,setup2
   ld a,0D1h
   out (0),a   ;required syntax
   
   ld a,1
   ld (player),a
   ld a,50
   ld (xcoord),a
   ld hl,0

waitplayer:
   inc hl
   IN A,(0)   ; check linkport
   AND 3  ; upper bits are not important
   CP 0
   jp z,intro

   ld a,KeyRow_Top
   out (1),a

   in a,(1)
   cp KMode
   ret z
   jp  waitplayer

setup2:
   ld a,2
   ld (player),a
   ld a,26
   ld (xcoord),a
   ld   a,0D2h
   out  (0),a   ; required syntax

waitothercomes:
   IN A,(0)   ; check linkport
   AND 3  ; upper bits are not important
   CP 1
   jp nz,waitothercomes

...;variable initialization here

mainloop:
...
   call sendreceive;call sendreceive routine
...
   jp mainloop

...
sendreceive:
  ld a,(player)   ;the stored byte
  cp 1
  jp z,send_than_receive;to have a fast link calcs have to do the opposite
  cp 2
  jp z,receive_than_send;to have a fast link calcs have to do the opposite

send_than_receive:
  ld a,(xcoord)   ;the byte you want to send
  ld c,a  ;we actually send c
  call sendbyte   ;call send routine
  call receivebyte;call receive routine
  ld a,e  ;we actually receive e
  ld (xopp),a   ;save received byte
  ret  ;return to mainloop

receive_than_send:
  call receivebyte;call receive routine
  ld a,e  ;we actually receive e
  ld (xopp),a   ;save received byte
  ld a,(xcoord)   ;the byte you want to send
  ld c,a  ;we actually send c
  call sendbyte   ;call send routine
  ret  ;return to mainloop


;=========================================the routines============================================
;====================send routines from venus and synchronising by Merlijn=======================

sendbyte:  ;input: white active, output: continue if red and white active
   IN   A,(0)   ;check linkport
       AND  3                 ;upper bits are not important
       CP   1  ;1 means white is active
   ret z  ;if true other player wants to send
   ld a,0D2h   ;set white wire active
        out (0),a   ;required syntax to send a to the linkport
sendbytewait:
   ld a,KeyRow_Top
   out (1),a
   in a,(1)
   cp KGraph   ;emergency quit key
   jp z,error   ;it is possible to got stuck here if the connection got lost
   cp kDel  ;graph will quit to ion and del will try to restore
   ret z
   IN   A,(0)   ;check linkport
       AND  3                 ;upper bits are not important
       CP   0  ;0 means red and white are active
   jp   nz,sendbytewait;not true check again
   
reswait:
   ld   a,0   ;set timer to zero
wait2:     ;create small delay so other can check port for double activety
   inc a  ;increase timer
   cp 10  ;compare to 20
   jp nz,wait2   ;not true increase more
          ;-----------end of synchronising-------------
vnSendByte:
   ld   b,8
vnSendByteLoop:
   rr   c
vnSendBit0:
   ld   a,$01
   jr   nc,vnSendBit
vnSendBit1:
   inc   a
vnSendBit:
   ld   de,0
   out   (0),a
vnSendBitLoop1:
   dec   de
   ld   a,e
   or   d
   jr   z,vnSendQuit
   in   a,(0)
   and   03h
   jr   nz,vnSendBitLoop1
vnSendQuit:
   out   (0),a
   cp   d
   ret   z
   ld   d,a
   ld   e,a
vnSendBitLoop2:
   dec   de
   ld   a,d
   or   e
   ret   z
   in   a,(0)
   and   03h
   cp   03h
   jr   nz,vnSendBitLoop2
   djnz   vnSendByteLoop
   inc   a
   ld a,0D0h   ;ld set no wire active for next session
        out (0),a   ;required syntax

   ret

;=========================End of send routine====================================================
;=========================receive routine from venus and synchronising by Merlijn================

receivebyte:   
     ;input: red active, output: continue if red and white active
   IN   A,(0)   ;check linkport
       AND  3                 ;upper bits are not important
       CP   2  ;1 means red is active
   ret z  ;if true other player wants to receive
   ld   a,0D1h   ;ld set red wire active
        out  (0),a   ;required syntax

receivebyte2:
   ld a,KeyRow_Top
   out (1),a
   in a,(1)
   cp KGraph   ;emergency quit key
   jp z,error   ;it is possible to got stuck here if the connection got lost
   cp kDel  ;graph will quit to ion and del will try to restore
   ret z
   IN   A,(0)   ;check linkport
       AND  3                 ;upper bits are not important
       CP   0  ;0 means red and white are active
   jp   nz,receivebyte2;not true check again
   ld   a,0   ;set timer to zero
  
wait:     ;create small delay so other can check port for double activety
   inc a  ;increase timer
   cp 30  ;compare to 40
   jp nz,wait   ;not true increase again
          ;-----------end of synchronising-------------
vnReceiveByte:
   ld   b,8
vnReceiveByteLoop:
   ld   hl,0
vnReceiveBitLoop1:
   dec   hl
   ld   a,h
   or   l
   ret   z
   in   a,(0)
   and   03h
   xor   03h
   jr   z,vnReceiveBitLoop1
   ld   d,a
   xor   03h
   cp   02h
   rr   c
   out   (0),a
   ld   hl,0
vnReceiveBitLoop2:
   dec   hl
   ld   a,h
   or   l
   jr   z,vnReceiveQuit
   in   a,(0)
   and   d
   jr   z,vnReceiveBitLoop2
vnReceiveQuit:
   ld   a,$00
   out   (0),a
   ret   z
   djnz   vnReceiveByteLoop
   ld   e,c
   ld a,0D0h   ;ld set no wire active for next session
   out (0),a   ;required syntax
   ret

;=======================End of receive routine============

error:
   xor a
   ld (errors),a
   ret

presskey: .db "Connecting..",0


Last edited by Guest on 20 Sep 2003 09:32:45 am; edited 1 time in total
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement