Commodore 128 Alive! > 128 programmers

IRQ and pressed keys: keybuffer clear - key is also performed: how to disable?

(1/1)

MIRKOSOFT:
Hi!


I'm programming keyboard driver for advanced operations with simple method by keyboard...


I used IRQ:



irq:      jsr driver
      lda $d019
      and #$01
      beq no
      lda $d011
      bpl no
      jmp $ff33
no:      jmp $fa65


If is any key combination pressed (e.g. key cursor up equals home) it before RTS clears buffer:



clr_buffer: lda #00
      sta 208
      lda #88
      sta 212
      lda #01
      rts


Action is performed, but key cursor up performs also, so home function sets cursor to begin of line and then one line up...


Which routine to use to disable original key function (move up)?


Or which routine to use as return from IRQ which never performs original key function? (RTI is impossimble)


Many thanks for every help, reply or comments.


Miro

Hydrophilic:
I might be able to help, but I do not understand: how is clr_buffer called by irq ?

MIRKOSOFT:
Hi Robert!


Routine clr_buffer is used in driver before RTS...


So, it uses routine driver...


Do you think that there's problem?


Miro

Hydrophilic:
Without seeing driver I can only guess... one problem might be that clear sets the current keyscan at 212 to value 88 ($58) = no key pressed.  But if a key really is still pressed (for example cursor up) then it will get processed on the next interrupt. 
 
Basically a key is processed immediately if current keyscan not equal last keyscan.  So imagine next IRQ and key is still down (very hard for human to hit a key for only 1 IRQ... makes a fun game!), then keyboard driver finds code for cursor up and checks last keyscan.  Cursor up <> No key, so cursor up gets performed.  Then on next next IRQ it does not matter because new keyscan and value at last keyscan are the same.  Only after many more IRQs will the key get processed again (key repeat).
 
So one thing to try that may fix the problem: do not change current value at 212 (remove lines LDA #88: STA 212), but copy it to old scan value at 213.  Also initialize key repeat timer ($a24) may help.

--- Code: ---lda 212 ;current scan code
sta 213 ;old scan code
lda #16 ;16 jiffies
sta $a24 ;delay until key processed again
lda #0
sta 208
lda #1
rts

--- End code ---

If that does not work, you may need to change the 'key process routine'.  The vector for this is at $33a and normally points to $c5e1.  This is the routine that looks up scan code from correct keyboard table and sticks it in keyboard buffer... but only if new keyscan <> old keyscan or key repeat times out (it also saves new keyscan into old keyscan).
 
Anyway, good luck!

MIRKOSOFT:
Hi Robert!


I tried, helps not....


In this case now I know that KEYSCAN is performad before calling $0314 vector routine...


So, how to disable KEYSCAN or use IRQ jump directly to $0314 vector and then process all what has to be processed?


Many thanks.


Miro

Navigation

[0] Message Index

Go to full version