Code: Select all
7-6-5-4-3-2-1-0
Code: Select all
flags equ (audio_clock+SizeWord)
FLAG_FRET_GREEN equ 0x1
FLAG_FRET_RED equ 0x2
FLAG_FRET_YELLOW equ 0x4
// now set it
?????
Sincerely,
Scorpion Illuminati
Moderator: BigEvilCorporation
Code: Select all
7-6-5-4-3-2-1-0
Code: Select all
flags equ (audio_clock+SizeWord)
FLAG_FRET_GREEN equ 0x1
FLAG_FRET_RED equ 0x2
FLAG_FRET_YELLOW equ 0x4
// now set it
?????
Code: Select all
// To set a bit
var = var | (1 << bit);
// To clear a bit
var = var & (~(1 << bit));
Code: Select all
#define BITSET(x, y) x = x | ( 1 << y)
#define BITCLR(x, y) x = x & (~(1 << y))
// You can now do this:
BITSET(var, 2); // Set bit 2
BITCLR(var, 0); // Clear bit 0
Code: Select all
rsset 0
FLAG_FRET_GREEN rs.b 1
FLAG_FRET_RED rs.b 1
FLAG_FRET_YELLOW rs.b 1
Code: Select all
btst #pad_button_a, d0 ; Check A button
bne @NoA ; Branch if button off
bset #FLAG_FRET_GREEN, (fret_flags) ; set the green fret bit
@NoA:
bclr #FLAG_FRET_GREEN, (fret_flags) ; clear the green fret bit
Code: Select all
btst #pad_button_a, d0 ; Check A button
bne @NoA ; Branch if button off
bset #FLAG_FRET_GREEN, (fret_flags) ; set the green fret bit
bra @GotA
@NoA:
bclr #FLAG_FRET_GREEN, (fret_flags) ; clear the green fret bit
@GotA:
Any way to shorten it to not use the bra instruction?Mask of Destiny wrote:You don't have a branch instruction after the bset, so after it sets the flag, the bclr instruction runs and clears it. Instead you want something like this:
Code: Select all
btst #pad_button_a, d0 ; Check A button bne @NoA ; Branch if button off bset #FLAG_FRET_GREEN, (fret_flags) ; set the green fret bit bra @GotA @NoA: bclr #FLAG_FRET_GREEN, (fret_flags) ; clear the green fret bit @GotA:
Code: Select all
moveq #0, d1
btst #pad_button_a, d0
bne @NoA
bset #FLAG_FRET_GREEN, d1
@NoA:
;handle other buttons here
move.b d1, fret_flags
Code: Select all
bclr #FLAG_FRET_GREEN, (fret_flags) ; clear the green fret bit first
btst #pad_button_a, d0 ; Check A button
bne @NoA ; if button is off, skip setting the bit
bset #FLAG_FRET_GREEN, (fret_flags) ; set the green fret bit
@NoA: