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

Author Topic: Help with WonderSwan pointers  (Read 2036 times)

Kylara

  • Guest
Help with WonderSwan pointers
« on: November 05, 2011, 07:44:35 pm »
So, what I do know, here, is that WonderSwan pointers are a major pain in the arse. The game I'm (still, and probably forever) working on is Neon Genesis Evangelion: Shito Ikusei. I've found the font, and successfully extracted an extremely messy script, but even messy, it seems to be all there. Getting a clean script would be nice, and being able to eventually reinsert would be necessary. I've also managed a decent bit of save state hacking. But, this stuff with pointers, it's simply beyond me. I'm hoping there's someone out there with the ability, time, and willingness to look this over and help get it figured. All information I have can be found here: http://shitoikusei.wordpress.com/   It's technically for my remake of the game project, but I've been told a remake would probably be loads easier with an english original first, and I agree completely. So here's hoping.

Thanks for reading.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6784
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Help with WonderSwan pointers
« Reply #1 on: November 05, 2011, 09:51:28 pm »
Well, WonderSwan reportedly uses an x86 clone CPU.
From what I remember reading, it had bankswap registers to swap one 64KB ROM bank into 20000-2FFFF and another to swap into 30000-3FFFF. And writing a 4-bit value x to another register would swap ROM x40000-xFFFFF into CPU 40000-FFFFF.
So assuming the pointers weren't obfuscated, I'd imagine the pointers would just be the low 16-bits of the address in reverse (little-endian) order.
"My watch says 30 chickens" Google, 2018

esperknight

  • Full Member
  • ***
  • Posts: 130
    • View Profile
Re: Help with WonderSwan pointers
« Reply #2 on: November 05, 2011, 10:19:36 pm »
It does use an x86 clone but sadly it's based off the 286/386 architecture (believe the 386 had the same addressing mode too but I may be wrong :) )  It's the same one used for the PC98.  So luckily they're documented on how to calculated the pointers but not straight forward.  Mind you this is my knowledge based off the PC98 and similar architecture so if it doesn't apply to the Wonderswan sorry!

To calculate the pointers you'd need two registers, the base register, DS or ES, and the indirect (AX, BX, CX, DX I think are the ones... been a bit :) ).  So if you had a memory access using DS and AX it'd look like DS:AX or DS[AX] or DS[AX + 2] or however it's traced out as.  To calculate it you shift DS over 4 bits so if you have 0x7F00 it'll be 0x7F000 and then add AX to it so if AX is 0x8000 it'll be 0x87000 (i.e. (DS << 4) + (AX + n) (n being the number in that third one I listed).

Normally if a game uses a pointer table to grab stuff it'll just load the base and then load the pointers as needed to be added to it so you still see a list of 16 bit values at least.  It just may be a bit harder to transfer it to somewhere else.

If you know assembly I'd recommend using g8tz et al's tool for tracing as it does memory access logging as well and it's incredibly useful for CPUs like this (PC98 at least) : http://www.romhacking.net/utilities/338/

I'm curious, are you translating this yourself then and doing the hacking as you can as well?

Edit: And checking out your blog it seems KingMike already explained the above as well back in 2010... ah well.  May be useful for anyone who looks up the wonderswan for it to be here too :)  Also I should mention my naming of the registers could be off as I'm doing this off memory and I tend to forget such things unless I'm actively working on that system :)

Kylara

  • Guest
Re: Help with WonderSwan pointers
« Reply #3 on: November 08, 2011, 01:26:28 am »
Well, I don't fully understand, and school has been leaving me without time to try again. I did try in the past, with no good success. At least I got some save state hacking done, haha. I think I did a lot of good work with this project, but I also think pointers are where my skill level ends.

I think at this point, I've done the hacking I can, and I do have someone that would help translate, but this has now hit a roadblock. Maybe someone would like to help and turn this from my pet project into a real project? Not going to hold my breath, just throwing that out there.

Edit: Of note, when I can squeeze in time for it, I'm going to work on modifying all the graphical components I can that need translating. It's better than nothing, and there's a fairly significant chunk of stuff on graphical form.

Edit2: Mednafen has a pretty awesome debugging setup, too. Just make sure for WS to be able to see the entire debug screen, change your config so that the screen is 4x original size... Doesn't totally fit on the default 3x.

Edit3: It doesn't look like it USES pointers. Now, bear with me, here, I'm still discovering... I found some empty tiles at the end of the font, and put them to use. Then, found and hex-edited the line I wanted to alter, making the assumption that the blank tiles would follow the same as the rest of the font. After that, I actually REMOVED any excess between the replaced text and the hex that seems to represent "wait for a button press," and then replaced the removed bytes in the empty space at the end of that bank.

Result:

Please note that "SHITO" is just the romanized version of the default name, and in default (and nasty-huge) font for capitals-only English characters. Same goes for that "!" because I didn't want to overwrite any game letters just yet. Because the tiles are 16x16, I opted to cram 2 letters per tile (there are hundreds of kanji in this game. Lack of space for doubled-up letters? Nah.), but you can see where they were paired up because for some reason, they got squished together.

Also note, the play continued beyond this screen just fine. No glitchy/missing/incorrect text, and no crashing. COOL!
« Last Edit: November 10, 2011, 11:57:08 pm by Kylara »