I'm not new to programming, but I'm new to assembly and low-level programming concepts and so far I'm having an easy time grasping the concepts and everything, but there's one thing right now that I'm having trouble with. Can you write and hold multiple pieces of data (such as multiple sprites) in a single address, like $2007, or can it only hold a single piece of datum (such as a single sprite) at a time? If you can write multiple pieces of data, what's the limit that it can hold?
Each address is one entity in memory. It's just the entities might not really go to the location, but to somewhere else that does something to them. You can write to $2007, but it doesn't hold anything. It passes it to the PPU which saves it to RAM. RAM is $0000-$07FF, and each entity REALLY holds the value written. All other locations from (2000-2007,4000-401whatever) all go to other parts. Most of the time they're not stored at the location as RAM is, but perform a function on a piece of the hardware.
3gengames wrote:
Each address is one entity in memory. It's just the entities might not really go to the location, but to somewhere else that does something to them. You can write to $2007, but it doesn't hold anything. It passes it to the PPU which saves it to RAM. RAM is $0000-$07FF, and each entity REALLY holds the value written. All other locations from (2000-2007,4000-401whatever) all go to other parts. Most of the time they're not stored at the location as RAM is, but perform a function on a piece of the hardware.
So, how does it handle managing multiple pieces of data written to it? Does it act similar to an array?
Does the wikipedia article on
Memory-mapped I/O make sense to you?
lidnariq wrote:
Does the wikipedia article on
Memory-mapped I/O make sense to you?
Yes...I have a basic understanding of memory maps.
v!rg!n wrote:
3gengames wrote:
Each address is one entity in memory. It's just the entities might not really go to the location, but to somewhere else that does something to them. You can write to $2007, but it doesn't hold anything. It passes it to the PPU which saves it to RAM. RAM is $0000-$07FF, and each entity REALLY holds the value written. All other locations from (2000-2007,4000-401whatever) all go to other parts. Most of the time they're not stored at the location as RAM is, but perform a function on a piece of the hardware.
So, how does it handle managing multiple pieces of data written to it? Does it act similar to an array?
It depends, read the Wiki on NESDev on how the registers work. As for $2007, it usually increments by one through the memory, but sometimes it inc's by 32 if you set it to. Yes, basically everything is an array.
With a system like the NES, every address can be read from or written to with 8 bits of information only. What is on the other end of the address is determined by the hardware. If it is RAM it will return or store the 8 bits of information as requested. If it is something else, what happens is determined by that hardware's function.
The NES is almost like two systems (CPU and PPU) with their own RAM, ROM (on the game cart) and communication buses. The NES CPU and PPU communicate through a few memory mapped I/O registers at $2000 to $2007. See:
http://wiki.nesdev.com/w/index.php/PPU_registersEdit: for clarity.
There are two different buses in the NES. The CPU can see only the CPU bus, with RAM at $0000-$07FF, MMIO at $2000-$401F, and ROM at $8000-$FFFF. There is a separate bus connected to the PPU, with pattern tables at $0000-$1FFF, nametables at $2000-$2FFF, and the palette at $3F00-$3F1F. The only way to write to memory on the PPU bus is through the PPU's MMIO ports $2006 and $2007. When you write something to $2007 during vertical blanking or forced blanking, it doesn't actually get stored at $2007 anywhere. The PPU sees it as a request to do the following:
- Write the value at the current VRAM address, which could be pointing to pattern table memory, nametable memory, or palette memory, depending on how $2006 was set
- Add 1 or 32 to the current VRAM address, depending on the increment setting in $2000
Rather, the CPU can send a 16-bit value + 8-bit value pair to the outside world (write), or send a 16-bit value to the outside world along with a request for an 8-bit value back (read). Hardware can do anything with this, as long as the requests for instructions give something meaningful for the CPU to execute. Usually this means giving a meaningful value for the requests from 0xFFFC and 0xFFFD, and then meaningful values for the address formed by those two requests, and whatever else that interpreted as 6502 instructions causes. Read-only memory gives the same value back for a given address, and ignores values sent. Read/write memory (RAM) gives the last sent value back. Things like the PPU's $2007 act as a cursor within some other memory space.
Just for clarification, when you write to $2007 technically you're always writing to the same address, which is a register inside the PPU.
Then the PPU will immediately detect the write to $2007 and transfer it to VRAM. However, it was the PPU that wrote the data to VRAM, not the CPU.
No time to read the whole thread, but I always felt this page explained very well how a cpu interacts with the rom/adressing.
http://lateblt.tripod.com/6502prj1.htmMaybe that'll help you figure out what is actually happening.