Customizing KEYSCAN routine (my own keyboard)

Started by MIRKOSOFT, August 30, 2010, 08:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!


I tried to customize KEYSCAN routine for my own Slovak keyboard.
So, I redirected vector at $033c to my own routine and test only one key (other yet inactive), but always when I press a key it jumps to ML monitor as error and PC shows illogical address which has nothing with my routine. Where I'm doing it wrong?
Here's bit of code:




.var toscreen = $ffd2
.var rvs = $f3

.pc=$2000 "Charset"
.import c64 "sk-font.bin"

.pc=$2800 "SK-activator"      // $2800 = #10240

   lda #$15
   ldx #$28
   sta $033c
   stx $033d
   rts

.pc=$2815 "SK-driver"

slovak:
   cpx #00
   beq ok
   jmp original_scan
ok:   stx csflag
   pha
!loop:
   cmp #$31      // 1
   bne !+
   jsr key1
   jmp endofscan
!:   cmp #$32      // 2
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$33      // 3
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$34      // 4
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$35      // 5
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$36      // 6
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$37      // 7
   bne !+
   jsr donothing
   jmp endofscan
!:   cmp #$38      // 8
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$39      // 9
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$30      // 0
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$2b      // +
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$2d      // -
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$5c      // Ł
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$3d      // =
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$5a      // Z
   bne !+
   jsr donothing
   jmp original_scan
!:   cmp #$59      // Y
   bne original_scan
   jsr donothing
   jmp original_scan
original_scan:
   jmp $c6ad
donothing:
   rts
endofscan:
   lda #29
   jsr toscreen
   ldx csflag
   pla
   jmp $c6c4
   
csflag:
.byte 0

line:
.byte 0

column:
.byte 0





Many thanks for every help.


Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

Hydrophilic

First problem is you are corrupting the stack when you get an unknown key.  At start of routine ('ok') you issue PHA but this is only fixed by PLA if a known key is pressed ('endofscan').  When other key is pressed, it exits via 'original_scan', but it does not PLA.  So stack is corrupt and eventually CPU goes to wrong location (via RTS or RTI).

A second minor problem is with the name, vector $33C is for KEYCHK not KEYSCAN.  This caused me confusion at first!  The vector is taken, if a key is pressed, sometime during Editor routine SCNKEY ($C012: JMP $C55D).
I'm kupo for kupo nuts!