Quick question about PPU warm up code

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
aLaix
Posts: 20
Joined: Thu May 29, 2014 2:48 pm
Location: Mexico
Contact:

Quick question about PPU warm up code

Post by aLaix » Thu May 29, 2014 2:58 pm

My friend and i started coding a NES emulator, the cpu is almost ready, so the APU, so i started coding the PPU but i realized something.
The init code http://wiki.nesdev.com/w/index.php/Init_code has this little piece of code:

Code: Select all

@vblankwait1: 
    bit $2002
    bpl @vblankwait1
If the accumulator is always zero how can the BPL go to next line?

Maybe it could be just a stupid question but i couldn't find the answer neither searching in the wiki, neither the forum.
Thanks in advance
*** O-Nes-Sama emulator team ***

3gengames
Formerly 65024U
Posts: 2269
Joined: Sat Mar 27, 2010 12:57 pm

Re: Quick question about PPU warm up code

Post by 3gengames » Thu May 29, 2014 2:59 pm

When bit 7 is set, it lets it advance. Bit 7 is set at the start of VBlank. It will NOT always be 0.

lidnariq
Posts: 9025
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Quick question about PPU warm up code

Post by lidnariq » Thu May 29, 2014 3:04 pm

BIT does two mostly-unrelated things:

* AND the accumulator with the value of memory at the specified address. Set Z appropriately.
* Copy the 128s and 64s bit of the value of memory at the specified address to the N and V bits, respectively.

BPL doesn't pay attention to Z.

User avatar
Movax12
Posts: 522
Joined: Sun Jan 02, 2011 11:50 am

Re: Quick question about PPU warm up code

Post by Movax12 » Thu May 29, 2014 3:04 pm

aLaix wrote: If the accumulator is always zero how can the BPL go to next line?
BPL doesn't care about the accumulator, it cares about the Negative flag, which will be copied from $2002 when using BIT.

User avatar
aLaix
Posts: 20
Joined: Thu May 29, 2014 2:48 pm
Location: Mexico
Contact:

Re: Quick question about PPU warm up code

Post by aLaix » Mon Jun 02, 2014 7:46 am

lidnariq wrote: * Copy the 128s and 64s bit of the value of memory at the specified address to the N and V bits, respectively.
I knew it was a stupid question!, even though i got reply.
Thank you guys you're awesome!!
*** O-Nes-Sama emulator team ***

Post Reply