mads 2.1.6 build 9 (30 Aug 22)
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
     1 				; Programa Test Joystick 2b+
     2 				; Por Abel Carrasco
     3 				;------------------------------
     4 				; 01/05/2019 - first version 
     5 				; 06/04/2019 - change graphics
     6 				; 11/04/2021 - changes shared by Eyvind Bernhardsen :
     7 				;			 * allow testing of non-Joy2B sticks
     8 				;			 * buttons 2 and 3 only appear if they are present
     9 				;			 * tweak and add decay to the sounds
    10 				;			 * make the direction rose point in eight directions instead of four
    11 				; 12/04/2021 - change of text to english and new version 
    12
    13 = 0014			RTCLOK = $14
    14 = 004D			ATRACT = $4d
    15 = 0200			VDSLST = $200
    16 = 0230			SDLSTL = $230
    17 = 0270			PADDL0 = $270
    18 = 0271			PADDL1 = $271
    19 = 0272			PADDL2 = $272
    20 = 0273			PADDL3 = $273
    21 = 0278			STICK0 = $278
    22 = 0279			STICK1 = $279
    23 = 02C5			COLOR1 = $2c5
    24 = 02C6			COLOR2 = $2c6
    25 = D010			STRIG0 = $d010
    26 = D011			STRIG1 = $d011
    27 = D016			COLPF0 = $d016
    28 = D01A			COLBK  = $d01a
    29 = D200			AUDF1  = $d200
    30 = D201			AUDC1  = $d201
    31 = D202			AUDF2  = $d202
    32 = D203			AUDC2  = $d203
    33 = D204			AUDF3  = $d204
    34 = D205			AUDC3  = $d205
    35 = D206			AUDF4  = $d206
    36 = D207			AUDC4  = $d207
    37 = D208			AUDCTL = $d208
    38 = D300			PORTA  = $d300
    39 = D40A			WSYNC  = $d40a
    40 = D40E			NMIEN  = $d40e
    41
    42 					org $2000
    43
    44 				; Program start
    45 				start
    46 FFFF> 2000-2555> A9 00 + 	mva #0 AUDCTL
    47 2005 A9 3B 8D 00 D2		mva #59 AUDF1
    48 200A A9 47 8D 02 D2		mva #71 AUDF2
    49 200F A9 54 8D 04 D2		mva #84 AUDF3
    50 2014 A9 6B 8D 06 D2		mva #107 AUDF4
    51 2019 A9 44 8D 30 02 A9 + 	mwa #dl SDLSTL
    52 2023 A9 09 8D 00 02 A9 + 	mwa #dli VDSLST
    53 202D A9 C0 8D 0E D4		mva #$c0 NMIEN
    54 2032 A9 30 8D C6 02		mva #$30 COLOR2
    55 2037 A9 0F 8D C5 02		mva #$f COLOR1
    56
    57 				; Joystick control
    58 203C			joystick
    59 203C A9 00 85 4D			mva #0 ATRACT
    60 2040 AD 78 02			lda STICK0
    61 2043				drawDirection #%0101, #%0000, #$47, joy1_1+10	; up + left
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2043 48				pha
     2 2044 29 05			and #%0101
     3 2046 C9 00			cmp #%0000
     4 2048 D0 04			bne clear
     5 204A A9 47			lda #$47
     6 204C D0 02			bne draw
     7 204E			clear
     8 204E A9 00			lda #0
     9 2050			draw
    10 2050 8D D3 23			sta JOY1_1+10
    11 2053 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    62 2054				drawDirection #%1101, #%1100, #$7c, joy1_1+11	; up
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2054 48				pha
     2 2055 29 0D			and #%1101
     3 2057 C9 0C			cmp #%1100
     4 2059 D0 04			bne clear
     5 205B A9 7C			lda #$7C
     6 205D D0 02			bne draw
     7 205F			clear
     8 205F A9 00			lda #0
     9 2061			draw
    10 2061 8D D4 23			sta JOY1_1+11
    11 2064 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    63 2065				drawDirection #%1001, #%0000, #$46, joy1_1+12	; up + right
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2065 48				pha
     2 2066 29 09			and #%1001
     3 2068 C9 00			cmp #%0000
     4 206A D0 04			bne clear
     5 206C A9 46			lda #$46
     6 206E D0 02			bne draw
     7 2070			clear
     8 2070 A9 00			lda #0
     9 2072			draw
    10 2072 8D D5 23			sta JOY1_1+12
    11 2075 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    64 2076				drawDirection #%0111, #%0011, #$52, joy1_2+10	; left
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2076 48				pha
     2 2077 29 07			and #%0111
     3 2079 C9 03			cmp #%0011
     4 207B D0 04			bne clear
     5 207D A9 52			lda #$52
     6 207F D0 02			bne draw
     7 2081			clear
     8 2081 A9 00			lda #0
     9 2083			draw
    10 2083 8D FB 23			sta JOY1_2+10
    11 2086 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    65 2087				drawDirection #%1011, #%0011, #$52, joy1_2+12	; right
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2087 48				pha
     2 2088 29 0B			and #%1011
     3 208A C9 03			cmp #%0011
     4 208C D0 04			bne clear
     5 208E A9 52			lda #$52
     6 2090 D0 02			bne draw
     7 2092			clear
     8 2092 A9 00			lda #0
     9 2094			draw
    10 2094 8D FD 23			sta JOY1_2+12
    11 2097 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    66 2098				drawDirection #%0110, #%0000, #$46, joy1_3+10	; down + left
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2098 48				pha
     2 2099 29 06			and #%0110
     3 209B C9 00			cmp #%0000
     4 209D D0 04			bne clear
     5 209F A9 46			lda #$46
     6 20A1 D0 02			bne draw
     7 20A3			clear
     8 20A3 A9 00			lda #0
     9 20A5			draw
    10 20A5 8D 23 24			sta JOY1_3+10
    11 20A8 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    67 20A9				drawDirection #%1110, #%1100, #$7c, joy1_3+11	; down
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 20A9 48				pha
     2 20AA 29 0E			and #%1110
     3 20AC C9 0C			cmp #%1100
     4 20AE D0 04			bne clear
     5 20B0 A9 7C			lda #$7C
     6 20B2 D0 02			bne draw
     7 20B4			clear
     8 20B4 A9 00			lda #0
     9 20B6			draw
    10 20B6 8D 24 24			sta JOY1_3+11
    11 20B9 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    68 20BA				drawDirection #%1010, #%0000, #$47, joy1_3+12	; down + right
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 20BA 48				pha
     2 20BB 29 0A			and #%1010
     3 20BD C9 00			cmp #%0000
     4 20BF D0 04			bne clear
     5 20C1 A9 47			lda #$47
     6 20C3 D0 02			bne draw
     7 20C5			clear
     8 20C5 A9 00			lda #0
     9 20C7			draw
    10 20C7 8D 25 24			sta JOY1_3+12
    11 20CA 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    69 20CB				setVolume prev_s1, vol_s1
Macro: SETVOLUME [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 20CB CD 3C 23			cmp PREV_S1
     2 20CE F0 0F			beq unchanged
     3 20D0 8D 3C 23			sta PREV_S1
     4 20D3 C9 0F			cmp #$f
     5 20D5 F0 04			beq not_held
     6 20D7 A9 8F			lda #$8f
     7 20D9 D0 0C			bne setvol
     8 20DB			not_held
     9 20DB A9 00			lda #0
    10 20DD F0 08			beq setvol
    11 20DF			unchanged
    12 20DF AD 3A 23			lda VOL_S1
    13 20E2 F0 06			beq skip
    14 20E4 38				sec
    15 20E5 E9 01			sbc #1
    16 20E7			setvol
    17 20E7 8D 3A 23			sta VOL_S1
    18 20EA			skip
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    70
    71 20EA AD 79 02			lda STICK1
    72 20ED				drawDirection #%0101, #%0000, #$47, joy2_1+10	; up + left
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 20ED 48				pha
     2 20EE 29 05			and #%0101
     3 20F0 C9 00			cmp #%0000
     4 20F2 D0 04			bne clear
     5 20F4 A9 47			lda #$47
     6 20F6 D0 02			bne draw
     7 20F8			clear
     8 20F8 A9 00			lda #0
     9 20FA			draw
    10 20FA 8D 4B 24			sta JOY2_1+10
    11 20FD 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    73 20FE				drawDirection #%1101, #%1100, #$7c, joy2_1+11	; up
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 20FE 48				pha
     2 20FF 29 0D			and #%1101
     3 2101 C9 0C			cmp #%1100
     4 2103 D0 04			bne clear
     5 2105 A9 7C			lda #$7C
     6 2107 D0 02			bne draw
     7 2109			clear
     8 2109 A9 00			lda #0
     9 210B			draw
    10 210B 8D 4C 24			sta JOY2_1+11
    11 210E 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    74 210F				drawDirection #%1001, #%0000, #$46, joy2_1+12	; up + right
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 210F 48				pha
     2 2110 29 09			and #%1001
     3 2112 C9 00			cmp #%0000
     4 2114 D0 04			bne clear
     5 2116 A9 46			lda #$46
     6 2118 D0 02			bne draw
     7 211A			clear
     8 211A A9 00			lda #0
     9 211C			draw
    10 211C 8D 4D 24			sta JOY2_1+12
    11 211F 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    75 2120				drawDirection #%0111, #%0011, #$52, joy2_2+10	; left
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2120 48				pha
     2 2121 29 07			and #%0111
     3 2123 C9 03			cmp #%0011
     4 2125 D0 04			bne clear
     5 2127 A9 52			lda #$52
     6 2129 D0 02			bne draw
     7 212B			clear
     8 212B A9 00			lda #0
     9 212D			draw
    10 212D 8D 73 24			sta JOY2_2+10
    11 2130 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    76 2131				drawDirection #%1011, #%0011, #$52, joy2_2+12	; right
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2131 48				pha
     2 2132 29 0B			and #%1011
     3 2134 C9 03			cmp #%0011
     4 2136 D0 04			bne clear
     5 2138 A9 52			lda #$52
     6 213A D0 02			bne draw
     7 213C			clear
     8 213C A9 00			lda #0
     9 213E			draw
    10 213E 8D 75 24			sta JOY2_2+12
    11 2141 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    77 2142				drawDirection #%0110, #%0000, #$46, joy2_3+10	; down + left
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2142 48				pha
     2 2143 29 06			and #%0110
     3 2145 C9 00			cmp #%0000
     4 2147 D0 04			bne clear
     5 2149 A9 46			lda #$46
     6 214B D0 02			bne draw
     7 214D			clear
     8 214D A9 00			lda #0
     9 214F			draw
    10 214F 8D 9B 24			sta JOY2_3+10
    11 2152 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    78 2153				drawDirection #%1110, #%1100, #$7c, joy2_3+11	; down
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2153 48				pha
     2 2154 29 0E			and #%1110
     3 2156 C9 0C			cmp #%1100
     4 2158 D0 04			bne clear
     5 215A A9 7C			lda #$7C
     6 215C D0 02			bne draw
     7 215E			clear
     8 215E A9 00			lda #0
     9 2160			draw
    10 2160 8D 9C 24			sta JOY2_3+11
    11 2163 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    79 2164				drawDirection #%1010, #%0000, #$47, joy2_3+12	; down + right
Macro: DRAWDIRECTION [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2164 48				pha
     2 2165 29 0A			and #%1010
     3 2167 C9 00			cmp #%0000
     4 2169 D0 04			bne clear
     5 216B A9 47			lda #$47
     6 216D D0 02			bne draw
     7 216F			clear
     8 216F A9 00			lda #0
     9 2171			draw
    10 2171 8D 9D 24			sta JOY2_3+12
    11 2174 68				pla
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    80 2175				setVolume prev_s2, vol_s2
Macro: SETVOLUME [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2175 CD 3D 23			cmp PREV_S2
     2 2178 F0 0F			beq unchanged
     3 217A 8D 3D 23			sta PREV_S2
     4 217D C9 0F			cmp #$f
     5 217F F0 04			beq not_held
     6 2181 A9 8F			lda #$8f
     7 2183 D0 0C			bne setvol
     8 2185			not_held
     9 2185 A9 00			lda #0
    10 2187 F0 08			beq setvol
    11 2189			unchanged
    12 2189 AD 3B 23			lda VOL_S2
    13 218C F0 06			beq skip
    14 218E 38				sec
    15 218F E9 01			sbc #1
    16 2191			setvol
    17 2191 8D 3B 23			sta VOL_S2
    18 2194			skip
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    81
    82 2194				sound vol_s1, vol_s2, AUDC1
Macro: SOUND [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2194 AD 3A 23			lda VOL_S1
     2 2197 CD 3B 23			cmp VOL_S2
     3 219A B0 03 AD 3B 23		scs:lda VOL_S2
     4 219F 4A				lsr
     5 21A0 4A				lsr
     6 21A1 4A				lsr
     7 21A2 4A				lsr
     8 21A3 F0 02 09 A0			seq:ora #$a0
     9 21A7 8D 01 D2			sta AUDC1
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    83
    84
    85 				; Buttons
    86 21AA AD 10 D0			lda STRIG0
    87 21AD				readButton #$01, #"1", joy1_2+18, vol_a1
Macro: READBUTTON [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 21AD F0 11			beq pressed
     2 21AF AD 39 23			lda :exists
     3 21B2 09 01			ora #$01
     4 21B4 8D 39 23			sta :exists
     5 21B7 A9 91 8D 03 24		mva #"1"+128 JOY1_2+18
     6 21BC A9 00			lda #0
     7 21BE F0 1B			beq setvol
     8 21C0			pressed
     9 21C0 AD 39 23			lda :exists
    10 21C3 29 01			and #$01
    11 21C5 F0 17			beq next
    12 21C7 A9 11 8D 03 24		mva #"1" JOY1_2+18
    13 21CC AD 3E 23			lda VOL_A1
    14 21CF D0 04			bne decay
    15 21D1 A9 8F			lda #$8f
    16 21D3 D0 06			bne setvol
    17 21D5			decay
    18 21D5 C9 0F			cmp #$f
    19 21D7 90 05			bcc next
    20 21D9 E9 01			sbc #1
    21 21DB			setvol
    22 21DB 8D 3E 23			sta VOL_A1
    23 21DE			next
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    88 21DE AD 11 D0			lda STRIG1
    89 21E1				readButton #$10, #"1", joy2_2+18, vol_a2
Macro: READBUTTON [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 21E1 F0 11			beq pressed
     2 21E3 AD 39 23			lda :exists
     3 21E6 09 10			ora #$10
     4 21E8 8D 39 23			sta :exists
     5 21EB A9 91 8D 7B 24		mva #"1"+128 JOY2_2+18
     6 21F0 A9 00			lda #0
     7 21F2 F0 1B			beq setvol
     8 21F4			pressed
     9 21F4 AD 39 23			lda :exists
    10 21F7 29 10			and #$10
    11 21F9 F0 17			beq next
    12 21FB A9 11 8D 7B 24		mva #"1" JOY2_2+18
    13 2200 AD 3F 23			lda VOL_A2
    14 2203 D0 04			bne decay
    15 2205 A9 8F			lda #$8f
    16 2207 D0 06			bne setvol
    17 2209			decay
    18 2209 C9 0F			cmp #$f
    19 220B 90 05			bcc next
    20 220D E9 01			sbc #1
    21 220F			setvol
    22 220F 8D 3F 23			sta VOL_A2
    23 2212			next
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    90 2212				sound vol_a1, vol_a2, AUDC2
Macro: SOUND [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2212 AD 3E 23			lda VOL_A1
     2 2215 CD 3F 23			cmp VOL_A2
     3 2218 B0 03 AD 3F 23		scs:lda VOL_A2
     4 221D 4A				lsr
     5 221E 4A				lsr
     6 221F 4A				lsr
     7 2220 4A				lsr
     8 2221 F0 02 09 A0			seq:ora #$a0
     9 2225 8D 03 D2			sta AUDC2
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    91
    92 2228 AD 70 02			lda PADDL0
    93 222B C9 E4			cmp #$e4
    94 222D				readButton #$02, #"2", joy1_2+23, vol_b1
Macro: READBUTTON [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 222D F0 11			beq pressed
     2 222F AD 39 23			lda :exists
     3 2232 09 02			ora #$02
     4 2234 8D 39 23			sta :exists
     5 2237 A9 92 8D 08 24		mva #"2"+128 JOY1_2+23
     6 223C A9 00			lda #0
     7 223E F0 1B			beq setvol
     8 2240			pressed
     9 2240 AD 39 23			lda :exists
    10 2243 29 02			and #$02
    11 2245 F0 17			beq next
    12 2247 A9 12 8D 08 24		mva #"2" JOY1_2+23
    13 224C AD 40 23			lda VOL_B1
    14 224F D0 04			bne decay
    15 2251 A9 8F			lda #$8f
    16 2253 D0 06			bne setvol
    17 2255			decay
    18 2255 C9 0F			cmp #$f
    19 2257 90 05			bcc next
    20 2259 E9 01			sbc #1
    21 225B			setvol
    22 225B 8D 40 23			sta VOL_B1
    23 225E			next
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    95 225E AD 72 02			lda PADDL2
    96 2261 C9 E4			cmp #$e4
    97 2263				readButton #$20, #"2", joy2_2+23, vol_b2
Macro: READBUTTON [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2263 F0 11			beq pressed
     2 2265 AD 39 23			lda :exists
     3 2268 09 20			ora #$20
     4 226A 8D 39 23			sta :exists
     5 226D A9 92 8D 80 24		mva #"2"+128 JOY2_2+23
     6 2272 A9 00			lda #0
     7 2274 F0 1B			beq setvol
     8 2276			pressed
     9 2276 AD 39 23			lda :exists
    10 2279 29 20			and #$20
    11 227B F0 17			beq next
    12 227D A9 12 8D 80 24		mva #"2" JOY2_2+23
    13 2282 AD 41 23			lda VOL_B2
    14 2285 D0 04			bne decay
    15 2287 A9 8F			lda #$8f
    16 2289 D0 06			bne setvol
    17 228B			decay
    18 228B C9 0F			cmp #$f
    19 228D 90 05			bcc next
    20 228F E9 01			sbc #1
    21 2291			setvol
    22 2291 8D 41 23			sta VOL_B2
    23 2294			next
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    98 2294				sound vol_b1, vol_b2, AUDC3
Macro: SOUND [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2294 AD 40 23			lda VOL_B1
     2 2297 CD 41 23			cmp VOL_B2
     3 229A B0 03 AD 41 23		scs:lda VOL_B2
     4 229F 4A				lsr
     5 22A0 4A				lsr
     6 22A1 4A				lsr
     7 22A2 4A				lsr
     8 22A3 F0 02 09 A0			seq:ora #$a0
     9 22A7 8D 05 D2			sta AUDC3
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
    99
   100 22AA AD 71 02			lda PADDL1
   101 22AD C9 E4			cmp #$e4
   102 22AF				readButton #$04, #"3", joy1_2+28, vol_c1
Macro: READBUTTON [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 22AF F0 11			beq pressed
     2 22B1 AD 39 23			lda :exists
     3 22B4 09 04			ora #$04
     4 22B6 8D 39 23			sta :exists
     5 22B9 A9 93 8D 0D 24		mva #"3"+128 JOY1_2+28
     6 22BE A9 00			lda #0
     7 22C0 F0 1B			beq setvol
     8 22C2			pressed
     9 22C2 AD 39 23			lda :exists
    10 22C5 29 04			and #$04
    11 22C7 F0 17			beq next
    12 22C9 A9 13 8D 0D 24		mva #"3" JOY1_2+28
    13 22CE AD 42 23			lda VOL_C1
    14 22D1 D0 04			bne decay
    15 22D3 A9 8F			lda #$8f
    16 22D5 D0 06			bne setvol
    17 22D7			decay
    18 22D7 C9 0F			cmp #$f
    19 22D9 90 05			bcc next
    20 22DB E9 01			sbc #1
    21 22DD			setvol
    22 22DD 8D 42 23			sta VOL_C1
    23 22E0			next
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
   103 22E0 AD 73 02			lda PADDL3
   104 22E3 C9 E4			cmp #$e4
   105 22E5				readButton #$40, #"3", joy2_2+28, vol_c2
Macro: READBUTTON [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 22E5 F0 11			beq pressed
     2 22E7 AD 39 23			lda :exists
     3 22EA 09 40			ora #$40
     4 22EC 8D 39 23			sta :exists
     5 22EF A9 93 8D 85 24		mva #"3"+128 JOY2_2+28
     6 22F4 A9 00			lda #0
     7 22F6 F0 1B			beq setvol
     8 22F8			pressed
     9 22F8 AD 39 23			lda :exists
    10 22FB 29 40			and #$40
    11 22FD F0 17			beq next
    12 22FF A9 13 8D 85 24		mva #"3" JOY2_2+28
    13 2304 AD 43 23			lda VOL_C2
    14 2307 D0 04			bne decay
    15 2309 A9 8F			lda #$8f
    16 230B D0 06			bne setvol
    17 230D			decay
    18 230D C9 0F			cmp #$f
    19 230F 90 05			bcc next
    20 2311 E9 01			sbc #1
    21 2313			setvol
    22 2313 8D 43 23			sta VOL_C2
    23 2316			next
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
   106 2316				sound vol_c1, vol_c2, AUDC4
Macro: SOUND [Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm]
     1 2316 AD 42 23			lda VOL_C1
     2 2319 CD 43 23			cmp VOL_C2
     3 231C B0 03 AD 43 23		scs:lda VOL_C2
     4 2321 4A				lsr
     5 2322 4A				lsr
     6 2323 4A				lsr
     7 2324 4A				lsr
     8 2325 F0 02 09 A0			seq:ora #$a0
     9 2329 8D 07 D2			sta AUDC4
Source: D:\!Delphi\mads\examples\Joy2BPlus\TestJ2b.asm
   107
   108 232C A2 00			ldx #0
   109 232E A0 03			ldy #3
   110 2330			delay
   111 2330 CA				dex
   112 2331 D0 FD			bne delay
   113 2333 88				dey
   114 2334 D0 FA			bne delay
   115 2336 4C 3C 20			jmp joystick
   116
   117
   118 				; The drawDirection macro pushes the accumulator to the stack on entry
   119 				; and pops it back off on exit to allow chaining.
   120
   121 				.macro drawDirection mask, value, char, pos
   122 					pha
   123 					and :mask
   124 					cmp :value
   125 					bne clear
   126 					lda :char
   127 					bne draw
   128 				clear
   129 					lda #0
   130 				draw
   131 					sta :pos
   132 					pla
   133 				.endm
   134
   135 				.macro setVolume prev, vol
   136 					cmp :prev
   137 					beq unchanged
   138 					sta :prev
   139 					cmp #$f
   140 					beq not_held
   141 					lda #$8f
   142 					bne setvol
   143 				not_held
   144 					lda #0
   145 					beq setvol
   146 				unchanged
   147 					lda :vol
   148 					beq skip
   149 					sec
   150 					sbc #1
   151 				setvol
   152 					sta :vol
   153 				skip
   154 				.endm
   155
   156 				.macro sound v1, v2, channel
   157 					lda :v1
   158 					cmp :v2
   159 					scs:lda :v2
   160 					lsr
   161 					lsr
   162 					lsr
   163 					lsr
   164 					seq:ora #$a0
   165 					sta :channel
   166 				.endm
   167
   168 				.macro readButton mask, char, pos, vol
   169 					beq pressed
   170 					lda :exists
   171 					ora :mask
   172 					sta :exists
   173 					mva :char+128 :pos
   174 					lda #0
   175 					beq setvol
   176 				pressed
   177 					lda :exists
   178 					and :mask
   179 					beq next
   180 					mva :char :pos
   181 					lda :vol
   182 					bne decay
   183 					lda #$8f
   184 					bne setvol
   185 				decay
   186 					cmp #$f
   187 					bcc next
   188 					sbc #1
   189 				setvol
   190 					sta :vol
   191 				next
   192 				.endm
   193
   194 2339			exists
   195 2339 00				.byte 0
   196 233A			vol_s1
   197 233A 00				.byte 0
   198 233B			vol_s2
   199 233B 00				.byte 0
   200 233C			prev_s1
   201 233C 00				.byte 0
   202 233D			prev_s2
   203 233D 00				.byte 0
   204 233E			vol_a1
   205 233E 00				.byte 0
   206 233F			vol_a2
   207 233F 00				.byte 0
   208 2340			vol_b1
   209 2340 00				.byte 0
   210 2341			vol_b2
   211 2341 00				.byte 0
   212 2342			vol_c1
   213 2342 00				.byte 0
   214 2343			vol_c2
   215 2343 00				.byte 0
   216
   217 				; Display list
   218 2344			dl
   219 2344 70 70 70		:3	.byte $70
   220 2347 F0				.byte $70+$80
   221 2348 47				.byte $47
   222 2349 79 23			.word title
   223 234B 40 46			.byte $40,$46
   224 234D 8D 23			.word author
   225 234F 70 70			.byte $70,$70
   226 2351 42				.byte $42
   227 2352 A1 23			.word blankline
   228 2354 42				.byte $42
   229 2355 C9 23			.word joy1_1
   230 2357 42				.byte $42
   231 2358 F1 23			.word joy1_2
   232 235A 42				.byte $42
   233 235B 19 24			.word joy1_3
   234 235D 42				.byte $42
   235 235E A1 23			.word blankline
   236 2360 70				.byte $70
   237 2361 42				.byte $42
   238 2362 A1 23			.word blankline
   239 2364 42				.byte $42
   240 2365 41 24			.word joy2_1
   241 2367 42				.byte $42
   242 2368 69 24			.word joy2_2
   243 236A 42				.byte $42
   244 236B 91 24			.word joy2_3
   245 236D 42				.byte $42
   246 236E A1 23			.word blankline
   247 2370 70 70 42			.byte $70,$70,$42
   248 2373 B9 24			.word messages
   249 2375 02				.byte $02
   250 2376 41				.byte $41
   251 2377 44 23			.word dl
   252
   253 				; Diseño de textos
   254 2379			title
   255 2379 00 00 00 34 25 33 + 	.byte "   TESTER JOY 2B+   "
   256 238D			author
   257 238D 00 00 30 2F 32 00 + 	.byte "  POR ASCRNET 2021  "
   258
   259 23A1			blankline
   260 23A1 00 00 00 00 00 00 + :40	.byte " "
   261
   262 23C9			joy1_1
   263 23C9 00 00 00 00 00 00 + :10	.byte " "
   264 23D3 00 5C 00			.byte 0,92,0
   265 23D6 00 00 00 00		:4	.byte " "
   266 23DA 48 80 4A			.byte 72," "*,74
   267 23DD 00 00		:2	.byte " "
   268 23DF 48 80 4A			.byte 72," "*,74
   269 23E2 00 00		:2	.byte " "
   270 23E4 48 80 4A			.byte 72," "*,74
   271 23E7 00 00 00 00 00 00 + :10	.byte " "
   272
   273 23F1			joy1_2
   274 23F1 00 00 00 00 00 00 + :10	.byte " "
   275 23FB 5E 2F 5F			.byte 94,"O",95
   276 23FE 00 00 00 00		:4	.byte " "
   277 2402 80 80 80			.byte "   "*
   278 2405 00 00		:2	.byte " "
   279 2407 80 80 80			.byte "   "*
   280 240A 00 00		:2	.byte " "
   281 240C 80 80 80			.byte "   "*
   282 240F 00 00 00 00 00 00 + :10	.byte " "
   283
   284 2419			joy1_3
   285 2419 00 00 00 00 00 00 + :10	.byte " "
   286 2423 00 5D 00			.byte 0,93,0
   287 2426 00 00 00 00		:4	.byte " "
   288 242A CA 80 C8			.byte 202," "*,200
   289 242D 00 00		:2	.byte " "
   290 242F CA 80 C8			.byte 202," "*,200
   291 2432 00 00		:2	.byte " "
   292 2434 CA 80 C8			.byte 202," "*,200
   293 2437 00 00 00 00 00 00 + :10	.byte " "
   294
   295 2441			joy2_1
   296 2441 00 00 00 00 00 00 + :10	.byte " "
   297 244B 00 5C 00			.byte 0,92,0
   298 244E 00 00 00 00		:4	.byte " "
   299 2452 48 80 4A			.byte 72," "*,74
   300 2455 00 00		:2	.byte " "
   301 2457 48 80 4A			.byte 72," "*,74
   302 245A 00 00		:2	.byte " "
   303 245C 48 80 4A			.byte 72," "*,74
   304 245F 00 00 00 00 00 00 + :10	.byte " "
   305
   306 2469			joy2_2
   307 2469 00 00 00 00 00 00 + :10	.byte " "
   308 2473 5E 2F 5F			.byte 94,"O",95
   309 2476 00 00 00 00		:4	.byte " "
   310 247A 80 80 80			.byte "   "*
   311 247D 00 00		:2	.byte " "
   312 247F 80 80 80			.byte "   "*
   313 2482 00 00		:2	.byte " "
   314 2484 80 80 80			.byte "   "*
   315 2487 00 00 00 00 00 00 + :10	.byte " "
   316
   317 2491			joy2_3
   318 2491 00 00 00 00 00 00 + :10	.byte " "
   319 249B 00 5D 00			.byte 0,93,0
   320 249E 00 00 00 00		:4	.byte " "
   321 24A2 CA 80 C8			.byte 202," "*,200
   322 24A5 00 00		:2	.byte " "
   323 24A7 CA 80 C8			.byte 202," "*,200
   324 24AA 00 00		:2	.byte " "
   325 24AC CA 80 C8			.byte 202," "*,200
   326 24AF 00 00 00 00 00 00 + :10	.byte " "
   327
   328 24B9			messages
   329 24B9 00 22 75 74 74 6F + 	dta " Buttons "
   330 24C2 92				dta "2"*
   331 24C3 00 61 6E 64 00		dta " and "
   332 24C8 93				dta "3"*
   333 24C9 00 77 69 6C 6C 00 + 	dta " will be activated when "
   334 24E1 00 00 61 00 6A 6F + 	dta "  a joystick with support is connected  "
   335
   336 				; Display list interrupts
   337 2509			dli
   338 2509 48 8A 48 98 48		phr
   339 250E A2 00			ldx #$0
   340 2510			dli_color1
   341 2510 BD 34 25			lda dli_colores1,x
   342 2513 8D 16 D0			sta COLPF0
   343 2516 8D 0A D4			sta WSYNC
   344 2519 E8				inx
   345 251A E0 10			cpx #16
   346 251C D0 F2			bne dli_color1
   347 251E A2 00			ldx #0
   348 2520			dli_color2
   349 2520 BD 44 25			lda dli_colores2,x
   350 2523 8D 1A D0			sta COLBK
   351 2526 8D 0A D4			sta WSYNC
   352 2529 E8				inx
   353 252A E0 12			cpx #18
   354 252C D0 F2			bne dli_color2
   355 252E 68 A8 68 AA 68		plr
   356 2533 40				rti
   357
   358 				; DLI colors
   359 2534			dli_colores1
   360 2534 B0 B0 B0 BF BF BC + 	.byte $b0,$b0,$b0,$bf,$bf,$bc,$bc,$ba,$ba,$b8,$b8,$b6,$b6,$b4,$b4,$f
   361 2544			dli_colores2
   362 2544 00 00 00 2A 28 24 + 	.byte $0,$0,$0,$2a,$28,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$28,$2a,$0
   363
   364 02E0-02E1> 00 20			run start
