Hi Everyone,
I'm going through Brad Smith's (rainwarrior) ca65 example, and I'm confused about how the BIT opcode works.
Inside of his reset, he's doing a bit operation on the PPU STATUS ($2002) register and I'm trying to figure out why bpl (Branch on Plus) is used to branch back around waiting for the first V-Blank.
bit $2002
:
bit $2002
bpl :-
Earlier he loads #$40 into the Accumulator using an LDA
lda #$40
Is BIT comparing the A register to what's in $2002? If that's the case, isn't $40 = %0100 0000? According to the Yoshi document, the status register looks like this:
| $2002 | R | vhs00000 | PPU Status Register [PPUSTAT] |
where the vblank status is v, meaning in the left most bit. So I'm really confused as to how this part of the code works.
I would really appreciate it if someone could let me know why I'm failing so miserably to understand what is going on here.
Thanks for your help,
Rick
I'm going through Brad Smith's (rainwarrior) ca65 example, and I'm confused about how the BIT opcode works.
Inside of his reset, he's doing a bit operation on the PPU STATUS ($2002) register and I'm trying to figure out why bpl (Branch on Plus) is used to branch back around waiting for the first V-Blank.
bit $2002
:
bit $2002
bpl :-
Earlier he loads #$40 into the Accumulator using an LDA
lda #$40
Is BIT comparing the A register to what's in $2002? If that's the case, isn't $40 = %0100 0000? According to the Yoshi document, the status register looks like this:
| $2002 | R | vhs00000 | PPU Status Register [PPUSTAT] |
where the vblank status is v, meaning in the left most bit. So I'm really confused as to how this part of the code works.
I would really appreciate it if someone could let me know why I'm failing so miserably to understand what is going on here.
Thanks for your help,
Rick