[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/vr/ - Retro Games

Search:


View post   

>> No.3046315 [DELETED]  [View]
File: 25 KB, 640x476, 1455333881268.png [View same] [iqdb] [saucenao] [google]
3046315

>>3046186
To a CPU, memory looks like a big linear array of bytes indexed by a single number called the "address".

A CPU is free to specify any integer address in the range [0,2^n-1], where "n" is the number of bits in a fully specified address. This range is called the "address space" of the CPU.

All external memories (ROM, RAM, external registers) connected to a CPU's "address bus" are assigned an address in the address space. When the CPU puts an address on the address bus, it can then read/write from that location using the "data bus". In this way the CPU can uniquely access code, data, and hardware mapped I/O all in the same manner.

An address, being just a number, can itself be stored in memory. When an address is stored in memory, it is called a "pointer".

Pointers, being located in memory, are stored at their own addresses. The address a pointer is stored at is in general different from the value of the pointer. This is the main point of confusion when people first encounter pointers. However when memory is viewed as above, I hope this is obvious for you.

By using pointers, one can very efficiently refer to data in a program by address only, rather than having to copy the data. The savings are critical when you consider huge data structures like level data.

As mentioned, everything is uniquely identified by its address. That includes the locations of programs, graphics, music, and even the text you are trying to edit. If you move anything around in memory that is referred to by a hardcoded pointer in ROM, then you have to "fix" the pointer or else the program will access the wrong data. This is complicated by the fact that a ROM is "mapped" to the CPU in nontrivial ways (ie ROM file address 0 != CPU address 0).

To perform most non-trivial hacks, you must first locate the data you want to edit in ROM, understand how the program accesses that data, and then fix any hardcoded pointers used in that process. This is highly game dependent.

Navigation
View posts[+24][+48][+96]