Jump to content
  • entries
    62
  • comments
    464
  • views
    87,106

Four Fast Paddles


Guest

520 views

Reading a paddle on the 2600 is a pain. Reading all four paddles on the 2600 is an even bigger pain. I think I've come up with an approach that will mitigate things somewhat. This technique requires knowing the magic index value for the current scan line; these values go "0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4" etc. corresponding to what bit in a gray code should be flipped. If the magic index value for a scan line is known, reading all four paddles takes 26 cycles; if it's not known, it takes 32 cycles.If the magic index value is known:

; Assume the magic index value for this line is 2.  ldx #127  ; Any value 64-127 will work; if X already contains such a value, save 2 cycles (and avoid trashing X!)  lda INPT0  cpx INPT1  ror  cpx INPT2  ror  cpx INPT3  ror  eor pscratch+2; Magic index value  sta pscratch+2

26 cyclesIf the magic index value is not known (assume scan line counter in Y)

  ldx #127  ; Any value 64-127 will work; if X already contains such a value, save 2 cycles  lda INPT0  cpx INPT1  ror  cpx INPT2  ror  cpx INPT3  ror  ldx PADDLEOFS,y; Get magic index value  eor pscratch,x  sta pscratch,x

32 cyclesNot a humongous gain over other polling methods, but it may be helpful nonetheless. Note that the pscratch will not hold 'directly usable' values; they must be converted to useful form outside the kernel. Assuming 7-bit values, the code for that is something like:

                lda     #16                eor     pscratch+6                sta     pscratch+6                eor     pscratch+5                sta     pscratch+5                eor     pscratch+4                sta     pscratch+4                eor     pscratch+3                sta     pscratch+3                eor     pscratch+2                sta     pscratch+2                eor     pscratch+1                sta     pscratch+1                eor     pscratch                sta     pscratch               ; Now convert paddle positions to values                ldx     #3pqlp:                asl    ; Clear LSB                asl     pscratch+6                rol                asl     pscratch+5                rol                asl     pscratch+4                rol                asl     pscratch+3                rol                asl     pscratch+2                rol                asl     pscratch+1                rol                asl     pscratch                rol                sta     paddles,x                dex                bpl     pqlp                lda     #0                sta     pscratch                sta     pscratch+1                sta     pscratch+2                sta     pscratch+3                sta     pscratch+4                sta     pscratch+5                sta     pscratch+6

A bit bulky, but not unreasonable. And the extra cycles in the kernel may make it worthwhile.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...