This shows you the differences between two versions of the page.
adding_two_buttons_for_l_r_sid_selection_instead_of_one [2008/02/21 11:22] |
adding_two_buttons_for_l_r_sid_selection_instead_of_one [2008/02/21 11:22] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Adding two buttons for L/R SID selection instead of one in mbSID v2 ====== | ||
+ | ====== Overview ====== | ||
+ | |||
+ | Using two buttons to select the L/R SID is pretty easy, just follow the step-by-step procedure described below. | ||
+ | |||
+ | Difficulty level: | ||
+ | |||
+ | * easy <sub>0-1-</sub>**2**<sub>-3-4-5-6-7-8-9</sub> hard | ||
+ | |||
+ | Required actions: | ||
+ | |||
+ | * Search/insert | ||
+ | * Compile | ||
+ | |||
+ | Affected files [2]: | ||
+ | |||
+ | * ''src/cs_menu_buttons.inc'' | ||
+ | * ''setup_*.inc'' | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ====== Step-by-Step description ====== | ||
+ | ===== 1. Adding the button ===== | ||
+ | * Open ''setup_*.asm''. | ||
+ | * Find ''CS_MENU_DIN_TABLE'' | ||
+ | * After this line insert:<code asm> DIN_ENTRY CS_MENU_BUTTON_SID_R, 4, 2 ; direct access to L/R toggling | ||
+ | DIN_ENTRY CS_MENU_BUTTON_SID_L, 4, 3 ; direct access to L/R toggling</code> | ||
+ | * Make sure the SR pins are set correctly according to where your buttons are connected (here ''4,2'' and ''4,3'') | ||
+ | * If you don't have status LEDs for this function - you're done already. | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | === Before the mod: === | ||
+ | |||
+ | |||
+ | <code asm>DIN_ENTRY_EOT MACRO | ||
+ | dw 0x0000, 0x0000 | ||
+ | ENDM | ||
+ | |||
+ | CS_MENU_DIN_TABLE | ||
+ | ;; Function name SR# Pin# | ||
+ | DIN_ENTRY CS_MENU_BUTTON_Dec, 1, 0 ; only valid if rotary encoder not assigned to these pins | ||
+ | DIN_ENTRY CS_MENU_BUTTON_Inc, 1, 1 ; (see mios_tables.inc) and CS_MENU_USE_INCDEC_BUTTONS == 1</code> | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | === After the mod: === | ||
+ | |||
+ | <code asm>DIN_ENTRY_EOT MACRO | ||
+ | dw 0x0000, 0x0000 | ||
+ | ENDM | ||
+ | |||
+ | CS_MENU_DIN_TABLE | ||
+ | ;; Function name SR# Pin# | ||
+ | DIN_ENTRY CS_MENU_BUTTON_SID_R, 4, 2 ; direct access to L/R toggling | ||
+ | DIN_ENTRY CS_MENU_BUTTON_SID_L, 4, 3 ; direct access to L/R toggling | ||
+ | DIN_ENTRY CS_MENU_BUTTON_Dec, 1, 0 ; only valid if rotary encoder not assigned to these pins | ||
+ | DIN_ENTRY CS_MENU_BUTTON_Inc, 1, 1 ; (see mios_tables.inc) and CS_MENU_USE_INCDEC_BUTTONS == 1</code> | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ===== 2. Adding the LEDs ===== | ||
+ | * Find ''CS_MENU_DOUT_TABLE'' | ||
+ | * After this line insert: | ||
+ | <code asm> DOUT_ENTRY TMP4, 6, 1, 6 ; LEFT Sid LED | ||
+ | DOUT_ENTRY TMP4, 7, 1, 7 ; RIGHT Sid LED</code> | ||
+ | * Be sure to change the pins (here ''1,6'' and ''1,7'') according to where you wired your two status LEDs | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | === Before the mod: === | ||
+ | |||
+ | <code asm>DOUT_ENTRY_EOT MACRO | ||
+ | dw 0x0000, 0x0000 | ||
+ | ENDM | ||
+ | |||
+ | CS_MENU_DOUT_TABLE | ||
+ | ;; Register and bit SR# Pin# Description | ||
+ | DOUT_ENTRY CS_MENU_SELECTED_SID_FLAGS, 0, 1, 0 ; SID1 LED (Note: Pin #0 is the D7 output of first SR) | ||
+ | DOUT_ENTRY CS_MENU_SELECTED_SID_FLAGS, 1, 1, 1 ; SID2 LED | ||
+ | DOUT_ENTRY CS_MENU_SELECTED_SID_FLAGS, 2, 1, 2 ; SID3 LED | ||
+ | DOUT_ENTRY CS_MENU_SELECTED_SID_FLAGS, 3, 1, 3 ; SID4 LED</code> | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | === After the mod: === | ||
+ | |||
+ | |||
+ | <code asm>DOUT_ENTRY_EOT MACRO | ||
+ | dw 0x0000, 0x0000 | ||
+ | ENDM | ||
+ | |||
+ | CS_MENU_DOUT_TABLE | ||
+ | ;; Register and bit SR# Pin# Description | ||
+ | DOUT_ENTRY TMP4, 6, 1, 6 ; LEFT Sid LED | ||
+ | DOUT_ENTRY TMP4, 7, 1, 7 ; RIGHT Sid LED | ||
+ | DOUT_ENTRY CS_MENU_SELECTED_SID_FLAGS, 0, 1, 0 ; SID1 LED (Note: Pin #0 is the D7 output of first SR) | ||
+ | DOUT_ENTRY CS_MENU_SELECTED_SID_FLAGS, 1, 1, 1 ; SID2 LED | ||
+ | DOUT_ENTRY CS_MENU_SELECTED_SID_FLAGS, 2, 1, 2 ; SID3 LED | ||
+ | DOUT_ENTRY CS_MENU_SELECTED_SID_FLAGS, 3, 1, 3 ; SID4 LED</code> | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ===== 3. Adding the button handler ===== | ||
+ | * Open ''src/cs_menu_buttons.inc'' | ||
+ | * Find ''CS_MENU_BUTTON_SID_LR'' | ||
+ | * Right before this line insert: | ||
+ | <code asm>;; ------------------------------------------------------------------ | ||
+ | CS_MENU_BUTTON_SID_L | ||
+ | movlw 0x01 | ||
+ | goto CS_MENU_BUTTON_SID_TOGGLE | ||
+ | ;; ------------------------------------------------------------------ | ||
+ | CS_MENU_BUTTON_SID_R | ||
+ | movlw 0x02 | ||
+ | ;; goto CS_MENU_BUTTON_SID_TOGGLE | ||
+ | CS_MENU_BUTTON_SID_TOGGLE | ||
+ | ;; do nothing if button has been depressed | ||
+ | btfsc MIOS_PARAMETER2, 0 | ||
+ | return | ||
+ | ;; exit with message if SID player mode enabled and SID1 selected | ||
+ | BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg | ||
+ | ;; toggle L/R | ||
+ | xorwf CS_MENU_SELECTED_SID_LR, 1 | ||
+ | bsf CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ | ||
+ | return</code> | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | === Before the mod: === | ||
+ | |||
+ | <code asm> bsf CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ | ||
+ | return | ||
+ | |||
+ | ;; ------------------------------------------------------------------ | ||
+ | CS_MENU_BUTTON_SID_LR | ||
+ | ;; do nothing if button has been depressed | ||
+ | btfsc MIOS_PARAMETER2, 0 | ||
+ | return | ||
+ | ;; exit with message if SID player mode enabled and SID1 selected | ||
+ | BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg | ||
+ | |||
+ | ;; toggle L/R | ||
+ | incf CS_MENU_SELECTED_SID_LR, W | ||
+ | andlw 0x03 | ||
+ | skpnz | ||
+ | addlw 1 | ||
+ | movwf CS_MENU_SELECTED_SID_LR | ||
+ | |||
+ | bsf CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ | ||
+ | return | ||
+ | |||
+ | ;; ------------------------------------------------------------------ | ||
+ | CS_MENU_BUTTON_Sync | ||
+ | ;; do nothing if button has been depressed | ||
+ | btfsc MIOS_PARAMETER2, 0</code> | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | === After the mod: === | ||
+ | |||
+ | <code asm> bsf CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ | ||
+ | return | ||
+ | |||
+ | ;; ------------------------------------------------------------------ | ||
+ | CS_MENU_BUTTON_SID_L | ||
+ | movlw 0x01 | ||
+ | goto CS_MENU_BUTTON_SID_TOGGLE | ||
+ | ;; ------------------------------------------------------------------ | ||
+ | CS_MENU_BUTTON_SID_R | ||
+ | movlw 0x02 | ||
+ | ;; goto CS_MENU_BUTTON_SID_TOGGLE | ||
+ | CS_MENU_BUTTON_SID_TOGGLE | ||
+ | ;; do nothing if button has been depressed | ||
+ | btfsc MIOS_PARAMETER2, 0 | ||
+ | return | ||
+ | ;; exit with message if SID player mode enabled and SID1 selected | ||
+ | BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg | ||
+ | ;; toggle L/R | ||
+ | xorwf CS_MENU_SELECTED_SID_LR, 1 | ||
+ | bsf CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ | ||
+ | return | ||
+ | |||
+ | ;; ------------------------------------------------------------------ | ||
+ | CS_MENU_BUTTON_SID_LR | ||
+ | ;; do nothing if button has been depressed | ||
+ | btfsc MIOS_PARAMETER2, 0 | ||
+ | return | ||
+ | ;; exit with message if SID player mode enabled and SID1 selected | ||
+ | BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg | ||
+ | |||
+ | ;; toggle L/R | ||
+ | incf CS_MENU_SELECTED_SID_LR, W | ||
+ | andlw 0x03 | ||
+ | skpnz | ||
+ | addlw 1 | ||
+ | movwf CS_MENU_SELECTED_SID_LR | ||
+ | |||
+ | bsf CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ | ||
+ | return | ||
+ | |||
+ | ;; ------------------------------------------------------------------ | ||
+ | CS_MENU_BUTTON_Sync | ||
+ | ;; do nothing if button has been depressed | ||
+ | btfsc MIOS_PARAMETER2, 0</code> | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ===== 4. Recompile ===== | ||
+ | |||
+ | * Now recompile the setup_*.asm | ||
+ | * Send it to your mbSID via MIOSStudio | ||
+ | * You're all done! |