比较击键 - 装配CCS64

Oak*_*kin 4 assembly c64 6502 6510

我想比较汇编中的击键(CCS64).如果我连续输入相同的键我想做一些例子:A A=这样做

但如果我输入这个:A B=做别的事

建议?

Emi*_*dın 7

我就像你想要的那样为你准备了一个例子.如果连续两次按相同的键,边框颜色会变为红色,否则会保持黑色.

警告!此示例使用kernal例程.没有什么不妥.但是,如果不使用$ffd2(输出矢量,chrout)和$ffe4(Get From Keyboad)内核调用,还有一种较低级别的方法.但由于理解起来要复杂得多,我更喜欢这个例子.

如果您想知道幕后发生的事情(内核调用),您可以轻松地从AAY64文档中跟踪内核ROM代码.这是链接:

主要的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(来自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
Run Code Online (Sandbox Code Playgroud)