Author Topic: HOW TO DISABLE AND AGAIN ENABLE KEYSCAN IN IRQ?  (Read 373 times)

0 Members and 1 Guest are viewing this topic.

Offline MIRKOSOFT

  • C128 user
  • ******
  • Posts: 785
  • Age: 33
  • Location: Zvolen
  • Activity:
    3.6%
  • Country: sk
  • Reputation: 188
  • Gender: Male
  • C128 programmer
  • With us since: 13/02/2009
    YearsYearsYearsYears
    • View Profile
    • MIRKOSOFT
HOW TO DISABLE AND AGAIN ENABLE KEYSCAN IN IRQ?
« on: June 16, 2012, 02:43 AM »
Hi!


I'm programming keyboard driver for advanced functions of keyboard.


E.g.:


Cursor key Up has function HOME (to begin of current line)


It works, but pressed cursor key IRQ performs also... so, HOW TO DISABLE KEYSCAN IF IS FUNCTION KEY PRESSED?


And also, how to ENABLE KEYSCAN WHEN IS PRESSED STANDARD KEY?


Many thanks for every help, reply or comments...


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

64ever 128her
sixty-for-ever one-twenty-either

C128 = C64² + more

http://www.mirkosoft.sk

Offline MIRKOSOFT

  • C128 user
  • ******
  • Posts: 785
  • Age: 33
  • Location: Zvolen
  • Activity:
    3.6%
  • Country: sk
  • Reputation: 188
  • Gender: Male
  • C128 programmer
  • With us since: 13/02/2009
    YearsYearsYearsYears
    • View Profile
    • MIRKOSOFT
Hi!


Solving this problem can be also by other way...


EXIT IRQ WITHOUT KEYSCAN AGAIN....


If anyone knows how to exit IRQ without KEYSCAN again, it will be helpful...


'Cause IRQ is not possible to exit with RTI...


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

64ever 128her
sixty-for-ever one-twenty-either

C128 = C64² + more

http://www.mirkosoft.sk

Offline MIRKOSOFT

  • C128 user
  • ******
  • Posts: 785
  • Age: 33
  • Location: Zvolen
  • Activity:
    3.6%
  • Country: sk
  • Reputation: 188
  • Gender: Male
  • C128 programmer
  • With us since: 13/02/2009
    YearsYearsYearsYears
    • View Profile
    • MIRKOSOFT
IRQ: WHAT HAPPENS BEFORE CALLING OWN ROUTINE $0314 ?
« Reply #2 on: June 16, 2012, 10:51 PM »
Hi!


Now I'm sure that before calling own IRQ routine with vectors at $0314 happens anything... IRQ calls $0314 not as first...


When I add function HOME to NumKey 7, it writes to screen first character 7 and then performs my routine HOME (to begin of current line)...


How to call $0314 as first?


Many thanks for every help, reply or comments....


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

64ever 128her
sixty-for-ever one-twenty-either

C128 = C64² + more

http://www.mirkosoft.sk

Offline Hydrophilic

  • 128D user
  • *******
  • Posts: 1214
  • Age: 41
  • Location: Earth... still!
  • Activity:
    0%
  • Reputation: 232
  • Gender: Male
  • With us since: 25/01/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • H2Obsesson
Re: HOW TO DISABLE AND AGAIN ENABLE KEYSCAN IN IRQ?
« Reply #3 on: June 17, 2012, 01:11 AM »
The KERENAL does call ($314) first.  The CPU will first jump to vector at $FFFE which normally points to KERNAL code that saves registers on stack, sets BANK 15, and then JMP ($314) unless it was BRK opcode.
 
Removing keyscan is very difficult, because the call to keyscan is burried deep in the IRQ routine after checking/changing various VIC registers.
 
You can disable processing of key scan values by re-direct vector $33a.  Point it to an RTS and no keys will be processed by KERNAL.  You should never do this in direct mode because it will 'kill' the keyboard.  In a program, remember to restore the vector later.
 
Edit
I want to emphasize that this does not disable keyscan... keyboard will still be scanned and scan code saved in 212, but afterwords nothing happens (it will just RTS).  Instead of simple RTS, you may want to test the scan code and decide if you should restore original decode vector.
 
Code: [Select]
;note IRQs must be disabled to change vector, for example inside an IRQ routine
ldx $33a
ldy $33b
stx save_decode
sty save_decode+1
 
ldx #<dummy
ldy #>dummy
stx $33a
sty $33b
...
 
;do not execute this directly, called by KERNAL
 
dummy:
;A = new scan code (same as 212)
cmp 213 ;compare with old
sta 213 ;save as old
bne exit ;different
cmp #88 ;no key
bne exit ;some key pressed
 
ldx save_decode
ldy save_decode+1
stx $33a
sty $33b
 
exit:
rts
So what that does is redirect the decode.  The dummy decode just saves the current keyscan into old keyscan and tests if they are the same.  If they are different then nothing happens.  If they are the same and equal to 'no key' then it will restore the original keyboard decode.
 
This is just a simple example, you may need to do more complex testing.
 
Also, it sounds like your software is too slow!  That is, KERNAL is detecting and processing key normally (in one IRQ) but in the next IRQ your software decides to do something special... but it is too late.
« Last Edit: June 17, 2012, 01:49 AM by Hydrophilic »
I'm kupo for kupo nuts!

Offline MIRKOSOFT

  • C128 user
  • ******
  • Posts: 785
  • Age: 33
  • Location: Zvolen
  • Activity:
    3.6%
  • Country: sk
  • Reputation: 188
  • Gender: Male
  • C128 programmer
  • With us since: 13/02/2009
    YearsYearsYearsYears
    • View Profile
    • MIRKOSOFT
Re: HOW TO DISABLE AND AGAIN ENABLE KEYSCAN IN IRQ?
« Reply #4 on: June 29, 2012, 08:06 PM »
Hi Robert!


I found solution:


In IRQ as first DISABLE KEYSCAN
Use own KEYSCAN
Then test own KEYBOARD SHORTCUT
And finlly ENABLE KEYSCAN


Disable keyscan:

lda #<own
ldx #>own
sta $033a
stx $033b


own keyscan:
jsr $ff9f


Mant many thanks.


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

64ever 128her
sixty-for-ever one-twenty-either

C128 = C64² + more

http://www.mirkosoft.sk

Offline wte

  • C64 user
  • *****
  • Posts: 342
  • Location: Frankfurt
  • Activity:
    0%
  • Country: de
  • Reputation: 10
  • Gender: Male
  • With us since: 18/03/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • http://blog.c128.net
EXIT IRQ WITHOUT KEYSCAN AGAIN....

If anyone knows how to exit IRQ without KEYSCAN again, it will be helpful...

'Cause IRQ is not possible to exit with RTI...
You may just change the code tables (see addresses at 033e-0349) with your own one and "redesign" the whole keybord.

 



Back to top