It is currently Mon Dec 11, 2017 11:43 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: PPU pinout
PostPosted: Fri Aug 05, 2016 10:23 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1311
Muhammad_R4 wrote:
Quote:
VRAM is accessed exculively with $2006 and $2007


I have a question here, I searched in the PPU registers documentaion about how the PPU differentiate between the read to VRAM and the write to it through both registers , but I found nothing


There is a read/write pin for the 2A03->PPU communication, as well as a read/write pin for the PPU's VRAM bus. The former is driven by the CPU, and the latter is driven by the PPU when appropriate.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Sat Aug 06, 2016 7:01 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
mikejmoffitt wrote:
Muhammad_R4 wrote:
Quote:
VRAM is accessed exculively with $2006 and $2007


I have a question here, I searched in the PPU registers documentaion about how the PPU differentiate between the read to VRAM and the write to it through both registers , but I found nothing


There is a read/write pin for the 2A03->PPU communication, as well as a read/write pin for the PPU's VRAM bus. The former is driven by the CPU, and the latter is driven by the PPU when appropriate.




the first for writing to registers I think

but the pin-out says the the other rd,wr are output from the PPU , shouldn't them be inputs ? to make the CPU access the VRAM ?


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Sat Aug 06, 2016 8:12 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5891
Location: Canada
Muhammad_R4 wrote:
but the pin-out says the the other rd,wr are output from the PPU , shouldn't them be inputs ? to make the CPU access the VRAM ?

VRAM is not inside the PPU, it's a separate RAM chip on the board (or sometimes a RAM or ROM chip inside the cartridge), they are outputs from the PPU to this external device.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Sat Aug 06, 2016 11:04 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
Muhammad_R4 wrote:
to make the CPU access the VRAM ?

The CPU never has access to VRAM. When writing to VRAM, the CPU sends the data to the PPU, and then the PPU forwards it to VRAM. The opposite happens when reading, but since the PPU can't read from the PPU and forward the byte to the CPU fast enough, PPU reads are buffered, so every time the CPU reads from $2007, it gets the value that was fetched during the previous read, and a new byte is buffered for the next read.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Mon Aug 08, 2016 6:55 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
OK I understood this all , but I think I haven't explained it well

my question is how to tell the PPU to write to ( or read from ) the VRAM
for both reading and writing , both registers are used , so I think there must be an input signal according it the PPU will know if the data in the registers is write to VRAM or the opposite.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Mon Aug 08, 2016 7:00 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7312
Location: Chexbres, VD, Switzerland
The CPU R/W pin is connected to the PPU, so the PPU can detect if the registers mapped at $2000-$2007 are written to or read from. A read to $2007 will trigger a VRAM read on next cycle (and the value currently in the buffer is returned to the CPU), a write to $2007 will trigger a VRAM write on next cycle. I am not 100% sure, but I think it is yet unknown if the read buffer is also used when writing, or if a separated buffer is used. This would be very easy to verify, though.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Mon Aug 08, 2016 7:13 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
Muhammad_R4 wrote:
my question is how to tell the PPU to write to ( or read from ) the VRAM

Whenever the CPU accesses an address between $2000 and $3FFF, an address decoder inside the NES will tell the PPU to react to this, and the PPU will decide what to do based the address (register) being accessed and on the CPU's R/W signal.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Mon Aug 08, 2016 7:33 am 
Online
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2982
Location: Tampere, Finland
Bregalad wrote:
I am not 100% sure, but I think it is yet unknown if the read buffer is also used when writing, or if a separated buffer is used. This would be very easy to verify, though.

It has been verified not to be the same buffer. This was that case where capacitance holds the output data on an internal bus long enough until it's written out. (You can find more info by searching.)

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Mon Aug 08, 2016 4:03 pm 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
I will illustrate my question with example
we know that the CPU can't access the VRAM directly, so we need to first to write in 2006 and 2007 ( if writing )

I am not familiar with NES assembly but i will try.

assume i will write FF to the VRAM in address 0x1000
Code:
LDA 00       ; load accumulator
STA 2006    ; 1st write
LDA 10   
STA 2006
LDA FF
STA 2007


now I want to read what I wrote in 0x1000
Code:
LDA 00
STA 2006
LDA 10
STA 2006



both codes will access the VRAM , one for write and one for read
how will the PPU understand that the CPU wants to write to the VRAM in the first code and wants to read from the VRAM in the second code ?

I hope my question is now obvious.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Mon Aug 08, 2016 5:16 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5891
Location: Canada
Muhammad_R4 wrote:
how will the PPU understand that the CPU wants to write to the VRAM in the first code and wants to read from the VRAM in the second code ?

Distinguishing reads from writes is easy:

STA $2007 writes to the PPU.

LDA $2007 reads from the PPU.

The tricky part is that reads are buffered by the PPU, so it's actually always one byte behind.

Code:
LDA #$10
STA $2006
LDA #$00
STA $2006
LDA $2007
LDA $2007 ; this actually gets the byte you were looking for


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Mon Aug 08, 2016 10:01 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
Muhammad_R4 wrote:
I am not familiar with NES assembly but i will try.

You got the basic idea, but you need a # if you want to load immediate values into the CPU registers. And you also need a $ if you're using hex numbers. For example, LDA 00 will put the contents of memory location $0000 into A, while LDA #$00 will put the value 0 into A. Another thing worth pointing out is that addresses written to $2006 are written high byte first.

Quote:
how will the PPU understand that the CPU wants to write to the VRAM in the first code and wants to read from the VRAM in the second code ?

For the $2006 writes, it simply doesn't matter, because nothing is being written or read yet, as the PPU is just seeing up a pointer to access memory later. Once the actual read/write from/to $2007 happens, the CPU will output a signal indicating whether it's reading or writing data. This signal is essential even for memory to work correctly, because memory chips need to know whether they're being written to or read from. Anyway, the PPU too can see this signal, so it knows whether to read from our write to VRAM.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Tue Aug 09, 2016 6:52 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
Quote:
the CPU will output a signal indicating whether it's reading or writing data. This signal is essential even for memory to work correctly, because memory chips need to know whether they're being written to or read from. Anyway, the PPU too can see this signal, so it knows whether to read from our write to VRAM


That's I am talking about , where is this signal in the PPU pinout ?

http://wiki.nesdev.com/w/index.php/PPU_ ... escription


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Tue Aug 09, 2016 6:57 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
It's pin 1 (R/W), apparently:

Quote:
R/W, CPU D0-D7, and CPU A0-A2, are signals from the CPU.


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Tue Aug 09, 2016 7:03 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
Quote:
It's pin 1 (R/W), apparently:



but I think those for reading/ writing to PPU internal registers


Top
 Profile  
 
 Post subject: Re: PPU pinout
PostPosted: Tue Aug 09, 2016 7:06 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
Yes, and $2007 is a PPU register too. When $2007 is accessed, the PPU will check the R/W signal in order to decide whether to read from or write to VRAM.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group