Author Topic: Direct Input + GetCSC = Fail?  (Read 4907 times)

0 Members and 1 Guest are viewing this topic.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Direct Input + GetCSC = Fail?
« on: October 17, 2010, 07:57:05 am »
If I use Direct input OR GetCSC to react to keypresses, it works fine.
If I use them both however, GetCSC results in a crash:

This works:
Code: [Select]
    b_call _GetCSC
    CP     skDel
    JP     Z, Label
This works too:
Code: [Select]
    LD     A, %10111111
    OUT    (1), A
ld b,%11101101
    IN     A, (1)
    CP     %11101111
    JP     Z, presyequ
    CP     %11110111
    JP     Z, preswindow
    CP     %11111011
    JP     Z, preszoom
    CP     %11111101
    JP     Z, prestrace
    CP     %11111110
    JP     Z, presgraph
But here comes the fun thing, pressing DEL will result in Ram-Reset:
Code: [Select]
    b_call _GetCSC
    CP     skDel
    JP     Z, Label
    LD     A, %10111111
    OUT    (1), A
ld b,%11101101
    IN     A, (1)
    CP     %11101111
    JP     Z, presyequ
    CP     %11110111
    JP     Z, preswindow
    CP     %11111011
    JP     Z, preszoom
    CP     %11111101
    JP     Z, prestrace
    CP     %11111110
    JP     Z, presgraph
Now, an obvious solution would be:
Code: [Select]
    LD     A, %10111111
    OUT    (1), A
ld b,%11101101
    IN     A, (1)
    CP     %11101111
    JP     Z, presyequ
    CP     %11110111
    JP     Z, preswindow
    CP     %11111011
    JP     Z, preszoom
    CP     %11111101
    JP     Z, prestrace
    CP     %11111110
    JP     Z, presgraph
CP %11111111
JP Z, Label
BUT when I do that, it will go to "Label" each pass, no matter what buttons you press.
Am I missing something obvious here? How to make both DEL and the other buttons work?
« Last Edit: October 17, 2010, 07:57:26 am by Jerros »


79% of all statistics are made up randomly.

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: Direct Input + GetCSC = Fail?
« Reply #1 on: October 17, 2010, 12:53:17 pm »
Using direct input and GetCSC together should not cause any problems. It would have to be with how you are implementing it. During the interrupts, the OS actually does a big direct keyscan to create the value that GetCSC is going to return. GetCSC is actually a really short bcall that just fetches a byte from memory.

One thing you could do to make your code easier would be to check for each button individually. So you would do something like this:
Code: [Select]
ld a, %10111111
out (01), a
nop
nop
in a, (01)

bit 0, a
call z, graphPressed ;you must make sure that these do not destroy A
bit 1, a
call z, tracePressed
bit 2, a
call z, zoomPressed
bit 3, a
call z, windowPressed
bit 4, a
call z, yEquPressed
bit 7, a
call z, delPressed

jr buttonsDone



graphPressed:
push af
;blah
;blah
;blah
pop af
ret

This would take care of quite a bit of the hassles you are having. Plus, it completely eliminates the GetCSC.

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 Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Direct Input + GetCSC = Fail?
« Reply #2 on: October 17, 2010, 01:28:06 pm »
This would take care of quite a bit of the hassles you are having. Plus, it completely eliminates the GetCSC.
Okay, I'll try.
Though will it fix the weird "DEL" thingy too?
I'm talking about that this:
Code: [Select]
   LD     A, %10111111
    OUT    (1), A
ld b,%11101101
    IN     A, (1)
CP %11111111
JP Z, Label
will result in a jump to Label EVERY pass, even when the DEL button isn't being hold down.
It only does this with DEL, any other button works fine....


79% of all statistics are made up randomly.

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: Direct Input + GetCSC = Fail?
« Reply #3 on: October 17, 2010, 02:03:10 pm »
I think that's because all of the other buttons are filtered off above. That little bit of code you posted will jump to label if and only if none of the buttons from the %1011111 group are being pressed. But the only time that execution reaches that point is if the other five buttons aren't being pressed, which is why it seems like delete is being special.

It will probably fix the weird DEL thingy, but that is probably more of what you are doing when you see that DEL is being pressed.
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 Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Direct Input + GetCSC = Fail?
« Reply #4 on: October 18, 2010, 08:42:24 am »
It will probably fix the weird DEL thingy, but that is probably more of what you are doing when you see that DEL is being pressed.
So the error is in the Label tht Del jumps too? That's very possible.:) Though when I use onlyGetCSC and press Del, then all works fine. But I still can't stand that it crashes when using GetCSC for DEL when also using direct input for other buttons. It shouldn't , so there's likely to be something wrong...

Oh, and on a sidenote, noticed that you used two NOP commands for the delay. Quigibo once told me that you shouldn't use NOP commands for that, but rather use some dummy instructions that last the same time. Don't know why, but he seems to know alot, so I'd just take his advice on that one. :P
« Last Edit: October 18, 2010, 12:49:04 pm by Jerros »


79% of all statistics are made up randomly.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Direct Input + GetCSC = Fail?
« Reply #5 on: October 20, 2010, 10:56:29 am »
I might be able to bypass the problem if... Can you use Get_CSC with cp skOn? Or is there no way to jump to a label when the ON button is pressed?


79% of all statistics are made up randomly.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Direct Input + GetCSC = Fail?
« Reply #6 on: October 20, 2010, 05:54:30 pm »
You can, but you can't use Get_CSC. The [ON] key is special, and there is no skOn.
The code to test if the [ON] key is pressed is this:
Code: [Select]
in a,($04)
bit 3,a
jr z,ON_pressed
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Re: Direct Input + GetCSC = Fail?
« Reply #7 on: October 22, 2010, 07:17:49 am »
K, I'll try that.
May save a lot of work.

EDIT: Yay, works fine now! Thank you.
« Last Edit: October 25, 2010, 04:09:18 am by Jerros »


79% of all statistics are made up randomly.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Direct Input + GetCSC = Fail?
« Reply #8 on: October 25, 2010, 09:45:40 am »
Nice to hear.
Glad to help. :)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.