# Omnimaga

## Calculator Community => TI Calculators => ASM => Topic started by: Jerros on October 17, 2010, 07:57:05 am

Title: Direct Input + GetCSC = Fail?
Post by: Jerros 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?
Title: Re: Direct Input + GetCSC = Fail?
Post by: thepenguin77 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 buttonsDonegraphPressed: 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.

Title: Re: Direct Input + GetCSC = Fail?
Post by: Jerros 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?
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....
Title: Re: Direct Input + GetCSC = Fail?
Post by: thepenguin77 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.
Title: Re: Direct Input + GetCSC = Fail?
Post by: Jerros 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
Title: Re: Direct Input + GetCSC = Fail?
Post by: Jerros 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?
Title: Re: Direct Input + GetCSC = Fail?
Post by: calcdude84se 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,ajr z,ON_pressed`
Title: Re: Direct Input + GetCSC = Fail?
Post by: Jerros 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.
Title: Re: Direct Input + GetCSC = Fail?
Post by: calcdude84se on October 25, 2010, 09:45:40 am
Nice to hear.