Я подготовил вам пример, как вы и хотели. Если дважды нажать одни и те же клавиши подряд, цвет рамки изменится на красный, в противном случае он останется черным.
Внимание! В этом примере используются процедуры kernal
. Там нет ничего плохого. Но есть и низкоуровневый способ сделать это без использования вызовов Kernel $ffd2
(Output Vector, chrout) и $ffe4
(Get From Keyboad). Но так как это понять гораздо сложнее, я предпочел этот пример.
Если вы хотите знать, что происходит за кулисами (вызовы Kernal), вы можете легко отследить коды ROM Kernel из документации AAY64
. Вот ссылки:
Главная страница AAY: http://www.the -dreams.de / aay.html
AAY64 Онлайн HTML-версия: http://unusedino.de/ec64/technical/aay/c64/
Листинг Kernal ROM: http://unusedino.de/ec64/technical/aay/c64/krnromma.htm
$ffd2
(вектор выхода, chrout): http://unusedino.de/ec64/technical/aay/c64/romffd2.htm
$ffe4
(Get From Keyboad): http://unusedino.de/ec64/technical/aay/c64/romffe4.htm
Вы можете просматривать глубже, нажимая ссылки на коды операций и адреса.
Вот пример кода. Вы можете скомпилировать этот код, используя ACME Crossassembler
, который вы можете найти здесь -> http://www.esw -heim.tu-clausthal.de / ~ marco / smorbrod / acme /
!to "keycomp.prg",cbm
zpBuffer = $fa ; $fa-$fb are reserved for 2 bytes of key buffer
* = $0801
!byte $0c, $08, $00, $00, $9e, $32, $30, $36, $31, $00, $00, $00
* = $080d
; key buffer initialization
ldx #$f0 ; initialize key buffer
stx zpBuffer ; with two different
inx ; values to avoid instant
stx zpBuffer+1 ; match at the beginning
; border color initialization
lda #$00 ; set startup border color to black
sta $d020 ; which means "no match"
; main loop
mainloop
lda zpBuffer ; shift key buffer
sta zpBuffer+1 ; by one
readKey
jsr $ffe4 ; read key
beq readKey ; if no key pressed loop forever
jsr $ffd2 ; show key on the screen
sta zpBuffer ; store the key to key buffer
lda zpBuffer ; compare the last stored key
cmp zpBuffer+1 ; with the old key value
beq cmpMatch ; if there is a match jmp to cmpMatch
lda #$00 ; if two pressed keys are different
sta $d020 ; change border color to black
jmp cmpOut ; skip the other condition code block
cmpMatch
lda #$02 ; if there is a repeated key
sta $d020 ; change border color to red
cmpOut
jmp mainloop ; wait for the next key