View Single Post
  #21   Spotlight this post!  
Unread 20-02-2006, 02:28
maniac_2040's Avatar
maniac_2040 maniac_2040 is offline
Registered User
AKA: Matt
FRC #3302 (Turbo Trojans)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Clawson, Michigan
Posts: 34
maniac_2040 is infamous around these partsmaniac_2040 is infamous around these partsmaniac_2040 is infamous around these partsmaniac_2040 is infamous around these parts
Send a message via MSN to maniac_2040
Re: White Paper Discuss: Playstation 2 Controller Adapter

I have a question regarding the code. When you're writing the digital outputs you have this smiget of code:

movlw 0x87 ; Write the first set of digital outputs
btfss datast+2, 2 ; L1
xorlw 0x80
btfss datast+2, 0 ; L2
iorlw 0x40
btfss datast+2, 3 ; R1
iorlw 0x20
btfss datast+2, 1 ; R2
iorlw 0x10
movwf digipots+2

On the first line is there any particular reason you used the hex value of 87 and then xor'd the L1 bit(when pressed) to the final output? Couldn't you just movlw 0x00 and the iorlw 0x80 just as you do all the following? I modified the code like such and wanted to know if it'd work:

;Write the first set of digital outputs
movlw 0x00
btfss PS2_BUTTON_BYTE_1, L1_BUTTON
iorlw 0x80
btfss PS2_BUTTON_BYTE_1, L2_BUTTON
iorlw 0x40
btfss PS2_BUTTON_BYTE_1, R1_BUTTON
iorlw 0x20
btfss PS2_BUTTON_BYTE_1, R2_BUTTON
iorlw 0x10
btfss PS2_BUTTON_BYTE_1, TRIANGLE_BUTTON
iorlw 0x08
btfss PS2_BUTTON_BYTE_1, CIRCLE_BUTTON
iorlw 0x04
btfss PS2_BUTTON_BYTE_1, X_BUTTON
iorlw 0x02
btfss PS2_BUTTON_BYTE_1, SQUARE_BUTTON
iorlw 0x01
movwf digipots+2

Yea I changed all the datast and #'s to some defines....will this code work?
Reply With Quote