Author Topic: 8X+ > port 1 questions  (Read 5369 times)

0 Members and 1 Guest are viewing this topic.

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
8X+ > port 1 questions
« on: April 06, 2013, 08:54:51 am »
Hey there...

I wanna code some direct input stuff.
The problem is, i've read so much different things that i'd gladly need some little clarifications :

1) reset usage (writing $FF)
Why and when is it needed exactly ? (Some say you got to do it before each group sending...)

2) delay between writing and reading
Is it really needed ? (some say it is, some say it's not...)
If yes, is there a way to know how many cycles are enough for all calc models ? (considering processor speed may vary)

Thx in advance for your time =]

EDIT :

3) checking the [ON] key
It is said it cannot be done directly.
Is there a way to check it without interrupts ?
« Last Edit: April 06, 2013, 09:12:59 am by the_mad_joob »

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: 8X+ > port 1 questions
« Reply #1 on: April 06, 2013, 12:16:48 pm »
This is just based on my experience, not technical knowledge ;)
1) I really don't think you have to worry about this, i've never had any trouble with this. If you open multiple groups at once keys with the same value will be processed the same, so if you want to use two keys from different groups that have the same key value, you'll have to read the groups separately. But i don't think you need to bother resetting the key port (i never do).
2) Again, i don't put any delay in between reading and writing and haven't ever noticed any problems on actual hardware (83+, 83+SE, and 84+SE). I've heard people say this before, but i've never actually bothered with it and haven't noticed any side effects.
3) I dunno this one, sorry. I just know of the onInterrupt flag "   OnInterrupt,(IY+onFlags)" :/

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: 8X+ > port 1 questions
« Reply #2 on: April 06, 2013, 12:26:59 pm »
Thx 4 reply chicken =]

2) Did you ever try in fast mode ?

3) Hmm... There must be a way with interrupts disabled...

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: 8X+ > port 1 questions
« Reply #3 on: April 06, 2013, 01:16:45 pm »
Yay, an actual question about assembly! (I love answering these)

1. You do not need to reset the port back to $FF. I know at one point I had trouble with this, but that was ages ago (I don't think I was timing it right)

2. You absolutely do need a delay. At 6.5 MHz, you might be able to sneak by every now and then, but honestly, just throw a "ld a, (de)" between your out and your in. It's only 1 byte and gives you 7 t-states. For 15MHz, you'll need more than that. I've historically used 16 t-states for 15MHz so to keep with the optimized delays, you might want to do a "push af \ pop af" or something.

3. Simple, bit 3 of port 4. (WikiTi)
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: 8X+ > port 1 questions
« Reply #4 on: April 06, 2013, 01:47:24 pm »
Thx Mr penguin =]

2) Maybe the wikiti page dedicated to port 1 should be updated then (example section).
3) Good, i'll try that after a "di".

Thx again...

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: 8X+ > port 1 questions
« Reply #5 on: April 06, 2013, 02:13:32 pm »
For the delay, do you mean the delay between writing to select a group and reading the result? At 6MHz, 8 cycles has always always been the traditional safe delay to put between out (1),a and in a,(1), although some implementations have been known to use 7 cycles. At 15MHz, I think the 16 cycles that thepenguin77 has suggested is not enough; Axe used to use 22 cycles and certain people reported that their calculators had issues even with that. I'm not sure of the exact number, but to be safe I'd go with at least 32 cycles or so of delay, if not more. An extra few cycles in a routine like this won't hurt overall performance anyways.
« Last Edit: April 06, 2013, 02:15:16 pm by Runer112 »

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: 8X+ > port 1 questions
« Reply #6 on: April 06, 2013, 07:30:40 pm »
"Resetting" the port after using it may reduce power consumption slightly, and it might also reduce problems with programs that don't use a long enough delay between the output and input.

You'll also see some programs that "reset" the port before using it rather than afterwards; as far as I know that's a cargo-cult technique that has no benefit whatsoever.

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: 8X+ > port 1 questions
« Reply #7 on: April 06, 2013, 09:46:19 pm »
I have never bothered with "resetting" the key port. Here's the new MicrOS GetCSC clone. The delay is 29 cycles.
Code: [Select]
;------ GetCSC -----------------------------------------------------------------
RawGetCSC:
; Scans the keyboard matrix for any pressed key, returning the first it finds,
; or 0 if none.
; Inputs:
;  - None
; Output:
;  - Code in A, or 0 if none
; Destroys:
;  - BC
ld bc, 07BFh
_: ; Matrix scan loop
ld a, c
out (pKey), a
rrca
ld c, a
pop af ; Probably should waste at least 20 cycles here.
push af ; This is legal because F actually does have 8 bits in it.
in a, (pKey)
cp 0ffh
jr nz, +_ ; Any key pressed?
djnz -_
; No keys pressed in any key group, so return 0.
xor a
ret
_: ; Yay! Found a key, now form a scan code
dec b
sla b
sla b
sla b
; Get which bit in A is reset
ld c, 0
_: rrca
inc c
jr c, -_
ld a, c
or b
ret
« Last Edit: April 06, 2013, 09:53:30 pm by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: 8X+ > port 1 questions
« Reply #8 on: April 07, 2013, 04:49:26 am »
Thx a lot guyz for sharing your knowledge.
Really appreciate it =]

Cu around...