User Tools

Site Tools


adding_two_buttons_for_l_r_sid_selection_instead_of_one

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 0-1-2-3-4-5-6-7-8-9 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:
    	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
  • 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:

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



After the mod:

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




2. Adding the LEDs

  • Find CS_MENU_DOUT_TABLE
  • After this line insert:
	DOUT_ENTRY	TMP4, 6,			1,  6	; LEFT Sid LED
	DOUT_ENTRY	TMP4, 7,			1,  7	; RIGHT Sid LED
  • Be sure to change the pins (here 1,6 and 1,7) according to where you wired your two status LEDs



Before the mod:

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



After the mod:

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




3. Adding the button handler

  • Open src/cs_menu_buttons.inc
  • Find CS_MENU_BUTTON_SID_LR
  • Right before this line insert:
;; ------------------------------------------------------------------
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



Before the mod:

	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



After the mod:

	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




4. Recompile

  • Now recompile the setup_*.asm
  • Send it to your mbSID via MIOSStudio
  • You're all done!
adding_two_buttons_for_l_r_sid_selection_instead_of_one.txt · Last modified: 2008/02/21 11:22 by 127.0.0.1