assembly - 比较击键 - assembly CCS64

标签 assembly c64 6502 6510

我想比较汇编中的击键 (CCS64)。 如果我连续输入相同的键,我想做某事 例如: A A = 执行此操作

但是如果我输入:A B = 做其他事情

建议?

最佳答案

我按照您的要求为您准备了一个示例。如果连续按两次相同的键,边框颜色将变为红色,否则保持黑色。

警告!此示例使用kernal 例程。没有什么不妥。但还有一种较低级别的方法可以在不使用 $ffd2(输出向量,chrout)和 $ffe4(从键盘获取)内核调用的情况下执行此操作。但由于理解起来要复杂得多,我更喜欢这个例子。

如果您想了解幕后发生的情况(内核调用),您可以轻松地从 AAY64 文档中跟踪内核 ROM 代码。以下是链接:

AAY主页:http://www.the-dreams.de/aay.html

AAY64在线HTML版本:http://unusedino.de/ec64/technical/aay/c64/

内核ROM列表:http://unusedino.de/ec64/technical/aay/c64/krnromma.htm

$ffd2(输出向量,chrout):http://unusedino.de/ec64/technical/aay/c64/romffd2.htm

$ffe4(从键盘获取):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

关于assembly - 比较击键 - assembly CCS64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7960338/

相关文章:

assembly - x86 RCL/RCR 指令的实际应用是什么?

assembly - 如何关闭LLVM的集成汇编程序?

basic - 是否可以在 Commodore BASIC 的 DATA 语句字符串中存储任何 PETSCII 字符?

coordinate-transformation - 打印出屏幕任意位置的字母

assembly - 自修改内存复制例程练习,6502 ASM

graphics - 如何在基于字符的图形系统上保留适当的背景?

javascript - 有没有办法将 6502 程序集添加到 Google Code Prettify 中?

c - linux 内核的 ext2 函数 ext2_statfs() 中的内存屏障

assembly - 从最高有效位或高位开始提取寄存器的位

function - Commodore 64 BASIC 中的多行功能