+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  WS Pointers make me cry.
Pages: [1]
Author Topic: WS Pointers make me cry.  (Read 1 times)
Kylara
Guest
« on: April 24, 2010, 04:26:04 am »

Well, not really, but still! I need some help, here. There's pretty much zero info on WonderSwan in general, and literally zero on pointers. So, here's what I've done so far.

-made my table for Neon Genesis Evangelion: Shito Ikusei
-used SwanTool to dump the banks of the rom to study individually (it was just easier...)
-found that script resides in banks 11 and 12 (17 and 18 in dec.)
-dumped a messy, ugly script and said "I need pointers. Crap."

So, um... Any suggestions/help?
rmco2003
Guest
« Reply #1 on: April 24, 2010, 04:27:35 am »

The Digimon games used a certain kind of pointer but I think it was only for that series, other games seem to use entirely different systems :/

Someone was working on a tool to handle repointing for wonderswan games but I think they gave up.
Kylara
Guest
« Reply #2 on: April 24, 2010, 04:31:55 am »

Yeah, I tried the WonderSwan Pointer-somethingorother-izer, but to no avail. SwanTool supposedly can hunt pointers, but just crashes when I do anything but dump banks.
KingMike
Guest
« Reply #3 on: April 24, 2010, 07:40:05 pm »

As I understand, WS uses a X86 clone, which has the potential to make pointers very evil to find.
It uses a segment:offset system where the CPU address = (segment x $10) + offset (giving a 1MB (20-bit or 5 hex digits) range).

If I am understanding the little existing documentation right, $20000-2FFFF and $30000-3FFFF can be mapped to any 64KB ROM bank, but $40000-FFFFF must be mapped to a contiguous section of ROM $x40000-xFFFFF.

so, if they were nice, they'd use segement:offset pairs like 1000:2345 to mean CPU address $12345, but they could do something like 1001:2335, 1002:2325, 1003:2315, etc to achieve the same result.
Kylara
Guest
« Reply #4 on: April 25, 2010, 05:27:27 pm »

I guess I just don't understand. Can you suggest any reading that might help me understand better? I'm not above learning all that I need to in order to get this done, even if right now this boggles my mind.
Zande
Guest
« Reply #5 on: May 03, 2010, 08:16:57 am »

I'll try to add abit about WonderSwan's memory mapping system for anyone who's interested. I hope it's of more use then it'll confuse. :x

The memory mapper is split into 15 banks segments, where each bank is 64 kB. For selecting a segment, the mapper takes the 4 highest bits from the 20 bit address written to the address bus of the processor, the remaining 16 bits are used for an address within the bank.

The first bank segment (segment 0, and therefore real address range 0x00000-0x0FFFF) is mapped to the internal RAM of the WonderSwan and this mapping can't be changed (however the first WonderSwan, mono, only have a 16 kB of RAM). Segment 1 (real address range 0x10000-0x1FFFF) is mapped to the SRAM of a cartridge and can't be changed either (alltho it's got it's own memory mapper for SRAM sizes exceeding 64 kB).

Segment 2 (0x20000-0x2FFFF) and 3 (0x30000-0x3FFFF) are mapped to ROM banks, and may be changed to any bank within the ROM by writing I/O port 0xC2 (for segment 2) and 0xC3 (for segment 3). The values written to the ports are the inverted offset from the last bank, that is: last bank - not(port value). So a value of 0xFF is the last bank, 0xFE is last bank - 1 (second to last) etc. Both ports inital value is 0xFF (last ROM bank).

The remaining 12 memory segments (4 to 15) can only have a base bank set by writing port 0xC0. This works similar to writing port 0xC2 and 0xC3, but in this case only the lowest four bits are used. If this nibble is set to 0xF (which is the initial value), then segment 15 will be the last ROM bank, segment 14 the second to last, 13 = third from the end, and so on down to segment 4 which will point to the last bank - 11. Fortunately for us, these 12 segments are not changed very often, becuase they usually contains most or all of the game code.

Now the processor uses two words (16 bits) to make up the a 20 bit address, these two words are refered to as segment and offset. An address is written by taking the segment value shifted 4 bits to the left and add the offset value, that is: (segment << 4) + offset. Don't mix up this segement value and the 15 bank segments though, they are different things and only share the name. Alltho, for simplicity reasons, usually only the highest four bits of the segment value are used, so the segment part of the address does effectively become the bank segment selector and the offset becomes the address of the the bank segment.

To elaborate with an example; the WonderSwan boots up from address FFFF:0000. That is segment 0xFFFF and offset 0x0000, when this is written to the address bus it becomes 0xFFFF0 (again: segment << 4 + offset, in this case 0xFFFF << 4 + 0x0000 = 0xFFFF0). Then the memory mapper splits this value in two parts, 0xF for bank segment (highest four bits) and 0xFFF0 for address within the bank. Like I've said before, bank segment 0xF (or 15) is initially set to the last bank of a ROM, so the boot up code is located in the last bank of a ROM at address 0xFFF0.
If we had an address using segment 0x1000 and offset 0xFF00, this would become real address 0x1FF00 where the highest nibble (for bank segment selection) is 1 and maps to the SRAM, with adress 0xFF00.
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC