Oldbitcollector (Jeff)
01-22-2008, 10:21 AM
I'm attempting to write a gamepad_001 object that will spit out the correct bits when a key is pressed, but I've run into a little snag. For some reason it doesn't seem to work fast enough to do the job. It works, but movement is jerky.
Would someone who understands the gamepad_001 code take a look at this and tell me why it doesn't seem to move fast enough? I've tried both comboKeyboard & keyboard with the same results.
' Keyboard gamepad_001 driver
' AUTHOR: Jeff Ledger
OBJ
key : "Keyboard" ' Keyboard Driver
PUB start : okay
key.start(26, 27)
PUB stop
PUB read : joy_bits | keystroke
' NES bit encodings -- Provided as reference
' NES_RIGHT = %00000001
' NES_LEFT = %00000010
' NES_DOWN = %00000100
' NES_UP = %00001000
' NES_START = %00010000
' NES_SELECT = %00100000
' NES_B = %01000000
' NES_A = %10000000
joy_bits := %00000000
keystroke := key.key
if keystroke == 122 'Keyboard(Z) = A
joy_bits := %10000000
if keystroke == 120 'Keyboard(X) = B
joy_bits := %01000000
if keystroke == 115 'Keyboard(S) = Select
joy_bits := %00100000
if keystroke == 32 'Keyboard(SPACE) = Start
joy_bits := %00010000
if keystroke == 193 'Right Arrow on Keyboard
joy_bits := %00000001
if keystroke == 192 'Left Arrow on Keyboard
joy_bits := %00000010
if keystroke == 195 'Down Arrow on Keyboard
joy_bits := %00000100
if keystroke == 194 'Up Arrow on Keyboard
joy_bits := %00001000
PUB button(WhichOne)
{{ Return value: true or false }}
if WhichOne == read
return true
else
return false
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook (http://ucontroller.com/Propeller%20Protoboard%20Designs%20for%20the%20Beg inner.pdf)
Got an SD card? - PropDOS (http://www.orrtech.net/propdos/)
A Living Propeller FAQ - The Propeller Wiki (http://propeller.wikispaces.com/)
(Got the Knowledge? Got a Moment? Add something today!)
Would someone who understands the gamepad_001 code take a look at this and tell me why it doesn't seem to move fast enough? I've tried both comboKeyboard & keyboard with the same results.
' Keyboard gamepad_001 driver
' AUTHOR: Jeff Ledger
OBJ
key : "Keyboard" ' Keyboard Driver
PUB start : okay
key.start(26, 27)
PUB stop
PUB read : joy_bits | keystroke
' NES bit encodings -- Provided as reference
' NES_RIGHT = %00000001
' NES_LEFT = %00000010
' NES_DOWN = %00000100
' NES_UP = %00001000
' NES_START = %00010000
' NES_SELECT = %00100000
' NES_B = %01000000
' NES_A = %10000000
joy_bits := %00000000
keystroke := key.key
if keystroke == 122 'Keyboard(Z) = A
joy_bits := %10000000
if keystroke == 120 'Keyboard(X) = B
joy_bits := %01000000
if keystroke == 115 'Keyboard(S) = Select
joy_bits := %00100000
if keystroke == 32 'Keyboard(SPACE) = Start
joy_bits := %00010000
if keystroke == 193 'Right Arrow on Keyboard
joy_bits := %00000001
if keystroke == 192 'Left Arrow on Keyboard
joy_bits := %00000010
if keystroke == 195 'Down Arrow on Keyboard
joy_bits := %00000100
if keystroke == 194 'Up Arrow on Keyboard
joy_bits := %00001000
PUB button(WhichOne)
{{ Return value: true or false }}
if WhichOne == read
return true
else
return false
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook (http://ucontroller.com/Propeller%20Protoboard%20Designs%20for%20the%20Beg inner.pdf)
Got an SD card? - PropDOS (http://www.orrtech.net/propdos/)
A Living Propeller FAQ - The Propeller Wiki (http://propeller.wikispaces.com/)
(Got the Knowledge? Got a Moment? Add something today!)