edit: rewording this entire post below for clarity and simplicity
Does anyone know what the z80 equivalent is to sending a list in TI basic where we just use Send({})?

Here's an example of what I want to do.
What do I need to write in the commented section in the Continue label? Do I need to alter anything else?

    LD     A, %10111111   
    OUT    (C), A
    IN     A, (C)
    BIT    7, A                   
    JR     NZ, Continue    ;exit if [DEL] pressed, else Continue
    LD     A, $FF         
    OUT    (C), A

    LD     A, $FF         
    OUT    (C), A

   ;the z80 equivilent of sending a list in TI Basic goes here
   ;[  Send({0})  ]  ;always sends a list with 0 if [DEL] not pressed

   JP     InKey
You want to look into the Send BCalls on WikiTI in combination with documentation on the linking protocol, but I suspect it's something like SendHeaderPacket in combination with SendRAMVarData.

Since I believe you're using this in conjunction with ArTICL, the best thing is probably to peak at ArTICL to see exactly what packet types it's expecting.
You probably want to create a list yourself, then use _SendVariable. It's also possible to construct and stream one manually, but that's rather more work.
_SendVarCmd may also be useful, but i'm not sure how that differs at a protocol level- _SendVariable is a silent link, whereas _SendVarCmd is documented to be used with CBL/CBR.
If you want to read multiple keypresses, you'll want to use direct input. The keyboard is divided into 7 scan groups (the last bit isn't used). The keyboard port is port 1, so first you use out to tell which group you want to read from then you use in to read the current value. For example:

    ld a,%11111110 ;this scans the arrow keys
    out (1),a
    push af
    pop af
    in a,(1) ;get the current value of group 0 (now you can test A to find which keys have been pressed, each bit corresponds to a key).

If you want to scan the entire keyboard, there's a shortcut you can use:

    ld hl,saferam1 ;the current state of the keyboard will be saved to these 7 bytes
    ld bc,$0701  ;repeat 7 times
    ld de,$FEFF ;d = $FE (%11111110, reads first bit), e = $FF (resets the keyboard)
    out (c),e  ;output $FF to port 1 to reset keyboard
    out (c),d  ;
    rlc d ;shift d left one bit, now we have the next scan group byte in d
    ; i'm not sure if you'll need a longer delay here or not, you might need a couple filler instructions here
    ini ;decs b and reads a byte from port c and stores it to (hl), then incs hl.
     jr nz,keyloop
Now if you want to test if a key has been pressed you can test the bits from saferam1 to saferam1+6. Alternatively, you could load saferam1 (or wherever you store the values) into ix and use bit to test which keys were pressed, eg. bit 1,(ix+2) would test bit 1 of key group 2, ie the [3] key.
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
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum