News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: How does SNES RAM memory address vs ROM address play a part in creating an emula  (Read 1098 times)

johnyparker

  • Newbie
  • *
  • Posts: 1
    • View Profile
hello,
greetings community
If you are making an emulator, does the ROM's machine code reference it's own addresses? Does it refer to locations that it gets mapped to in SNES memory?

When manuals are talking about Direct Paging, absolute, long, etc addressing modes -- they are referring to the SNES's WRAM memory, is this correct?

So when interpreting the machine code of a ROM, do you have to convert to SNES memory locations?


Nox Free Download Download ShowBox APK VidMate for Android
« Last Edit: October 02, 2018, 06:15:32 am by johnyparker »

FAST6191

  • Hero Member
  • *****
  • Posts: 2518
    • View Profile
WRAM aka Work RAM is the memory the system uses to store data during runtime which is not immediately being used in the CPU registers, typically contrasted with VRAM which is where graphics are loaded and sometimes manipulated a bit.
I don't know if you are confusing the concept with a memory bus wherein various components (normal memory, things like registers to handle controller reads, VRAM, the game cart, or at least a small window of the game cart, the fancy chip attached to the game cart, audio processing/handling...) get attached and available in various means to general memory (be it CPU directed or DMA directed*), do note though that not all systems will attach everything and some things will not be visible on the bus and need other means of writing or getting their information (if you can at all). Most people will be copying things to and from WRAM, VRAM and the ROM for most things they care about, obviously you will need to speak to something else eventually but if you are a new hacker concerned with finding data in ROMs, making cheats and such things then it will be WRAM, VRAM and ROM sections that you spend a lot of time contemplating.

*computer system designers realised many years ago that having a CPU be taken over by having to copy data from ROM or something into memory was not good and got in the way of doing useful things with it so they made Direct Memory Access instead to allow the machine to fetch data from ROM or something independently of the CPU, and indeed the ability of many CPUs to fetch data and write it directly to memory is often quite limited and if it is available it might be a trick of your assembler.

"does the ROM's machine code reference it's own addresses?"
As in like you or I would if I we were pointing someone at a part of the ROM to look at in a hex editor? Not unless the system you are using maps the address to the 0 to whatever range of memory to the ROM (or first window in some instances but let us not go there right now) which is not the most common. To take another system the GBA maps the whole ROM section to multiple locations in memory but typically the 08000000 to 09000000 range is used. To that end 5400000 in the ROM would be 85400000 in the memory. The GBA however allows for a simpler working than a lot of older consoles that were pushing limits and had to use tricks to have more space available (if you only have 16 bits to play with for an address then you have 2^16 locations and if doing bytewise* addressing and that is not an awful lot). Said tricks are what give you the various terms you listed there, and if you are operating within a small section then you can ignore some of the overhead (the SNES uses 24 bits as a full address but as it is only a 16 bit processor it means multiple instructions to generate a 24 bit value somewhere, as not everything will be in a completely different location then you might either do some maths on the old value or use a shorthand form that only works within a given section to speed things up).

*as opposed to sector addressing used by a lot of optical media and hard drives (why a file might say size and size on disc when you view its properties on your PC) where you might call say 200 bytes a sector and even if you only use 70 bytes of it you ignore the rest.

https://en.wikibooks.org/wiki/Super_NES_Programming/SNES_memory_map is a nice overview.

I have probably just confused things even more for you but it sounds like you need to get some fundamental concepts straight in your head.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6846
  • *sigh* A changed avatar. Big deal.
    • View Profile
hello,
greetings community
If you are making an emulator, does the ROM's machine code reference it's own addresses? Does it refer to locations that it gets mapped to in SNES memory?

When manuals are talking about Direct Paging, absolute, long, etc addressing modes -- they are referring to the SNES's WRAM memory, is this correct?

So when interpreting the machine code of a ROM, do you have to convert to SNES memory locations?
They are talking about how the CPU parses an instruction. It could be anything mappdd to the CPU. WRAM, ROM, IO.
"My watch says 30 chickens" Google, 2018