Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I prepared an example to you just like you've wanted. If you press same keys in a row twice, border color changes to red, otherwise stays black.</p> <p>Warning! This example uses <code>kernal</code> routines. There is nothing wrong with that. But there is also a lower level way to do this without using <code>$ffd2</code> (Output Vector, chrout) and <code>$ffe4</code> (Get From Keyboad) kernal calls. But since it is much more complicated to understand, I prefered this example.</p> <p>If you want to know what is happening behind the scenes (kernal calls), you can easily trace the kernal ROM codes from <code>AAY64</code> documentation. Here is the links:</p> <p>Main AAY Page: <a href="http://www.the-dreams.de/aay.html">http://www.the-dreams.de/aay.html</a></p> <p>AAY64 Online HTML Version: <a href="http://unusedino.de/ec64/technical/aay/c64/">http://unusedino.de/ec64/technical/aay/c64/</a></p> <p>Kernal ROM Listing: <a href="http://unusedino.de/ec64/technical/aay/c64/krnromma.htm">http://unusedino.de/ec64/technical/aay/c64/krnromma.htm</a></p> <p><code>$ffd2</code> (Output Vector, chrout): <a href="http://unusedino.de/ec64/technical/aay/c64/romffd2.htm">http://unusedino.de/ec64/technical/aay/c64/romffd2.htm</a></p> <p><code>$ffe4</code> (Get From Keyboad): <a href="http://unusedino.de/ec64/technical/aay/c64/romffe4.htm">http://unusedino.de/ec64/technical/aay/c64/romffe4.htm</a></p> <p>You can browse deeper by pressing links on the opcodes and addresses.</p> <p>Here goes the example code. You can compile this code using <code>ACME Crossassembler</code> which you can find here -> <a href="http://www.esw-heim.tu-clausthal.de/~marco/smorbrod/acme/">http://www.esw-heim.tu-clausthal.de/~marco/smorbrod/acme/</a></p> <pre><code> !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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload