Hacking PSP ASM Hacking for Variable Width Font

JamRules

.....
Member
Joined
Jan 9, 2014
Messages
527
Trophies
1
XP
2,207
Country
United States
It's not like it's difficult. I insert my code with armips anyway, the symbols are just a bonus.


Yeah, once setup you just need to type an extra word where you want it to be, also it's faster to type compared to assemble opcode since that needs to be done one by one
 

flame1234

Well-Known Member
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
Okay, before I go further into this:
Are there utilities available that tell me data about ELF files?:
Header Data
Segment Data (virtual address, memory address, size)
Section Data (virtual address, memory address, size)

It seems not too hard to write my own, but if it's already been done, then...
 

Scorp

Well-Known Member
Member
Joined
Sep 23, 2010
Messages
248
Trophies
0
XP
296
Country
Kazakhstan
Well, I wrote myself a php code for that. You really need that? As for ex ChepChep was against that :)
 

StorMyu

"I'm way too old for this"
Member
Joined
Jan 2, 2010
Messages
943
Trophies
1
Age
97
XP
1,093
Country
France
If you're planning on enlarging .elf, you should just reconsider a simple idea.
- Is there a file that's always in memory in that game ?
If yes, you just have to enlarge it and put your code at the end. Tada. It's magical.
 

thexyz

Active Member
Newcomer
Joined
Jan 8, 2014
Messages
40
Trophies
0
Age
54
XP
180
Country
Serbia, Republic of
Okay, before I go further into this:
Are there utilities available that tell me data about ELF files?:
Header Data
Segment Data (virtual address, memory address, size)
Section Data (virtual address, memory address, size)

It seems not too hard to write my own, but if it's already been done, then...
Yes, see readelf.
 
  • Like
Reactions: flame1234

Scorp

Well-Known Member
Member
Joined
Sep 23, 2010
Messages
248
Trophies
0
XP
296
Country
Kazakhstan
If you're planning on enlarging .elf, you should just reconsider a simple idea.
- Is there a file that's always in memory in that game ?
If yes, you just have to enlarge it and put your code at the end. Tada. It's magical.
Yeah, and this file is named "eboot.bin" :) Tada! :)
 

ChepChep

Well-Known Member
OP
Member
Joined
Feb 9, 2011
Messages
611
Trophies
0
XP
876
Country
United States
Scorp,

Thanks for the compliment. I appreciate it :)

Good news I got my ASM code all working that will convert all ASCII characters to SHIFT-JIS. :) Now just to find the stupid 38 char limit in the game I am working on.
 

flame1234

Well-Known Member
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
Is there a tutorial available somewhere about graphics debugging?
So there's a whole separate processor in the PSP that does graphics processing?
How does GE (the graphics processor) know it can go? How does R4000 (the CPU) know it can go? Do they both go at the same time?
I get that "Step Tex" in GE debugger will go until the loaded texture changes. What do the other buttons in the GE debugger do?
What is a texture? I looked here but it is not written for someone unfamiliar with the topic: en.wikipedia.org/wiki/Texture_mapping
What is the format of PSP textures / how can I change them?
Is there a list of GE commands somewhere so I can try to understand what is happening?
It seems the GE debugger knows the memory address of the currently loaded texture. How can I dump the texture and view or change it?
Sometimes it's drawing 30 or more squares at a time. Where are the positions and sizes of those coming from?

I don't need variable-width font, but I want to try to implement the half-width font in Nanatama: Chronicle of the Dungeon Maker (really Dungeon Maker 3), that was used in Dungeon Maker and Dungeon Maker 2. I tried replacing some printing characters, which are encoded in SHIFT-JIS, with ASCII and it doesn't show up. I tried stepping through in GE debugger. It seems there are three textures with letters on them and none of them have lowercase letters. But I don't really know.

Shall I make a new topic for this?
 

StorMyu

"I'm way too old for this"
Member
Joined
Jan 2, 2010
Messages
943
Trophies
1
Age
97
XP
1,093
Country
France
Please use the good words, GE means Graphic Engine, it's not a processor.
Everything Graphic related is always done by the GPU (Graphics Processing Unit, that's probably your confusion here)

- What is a texture:
It's just a "file" (let's keep it simple) who contains lots of image (or just one actually, doesn't matter) by Texture mapping it means they'll know where they belong.
For instance now it's easy to do a mario game and you could just need one texture for the whole background.
This is a texture:
2il2edj.png


- What is the format of PSP textures"
whatever the programmer wanted it to be, even if there's some "classic" format but it's not really PSP related.

- I tried replacing some printing characters, which are encoded in SHIFT-JIS, with ASCII and it doesn't show up. I tried stepping through in GE debugger.
That has nothing to do with graphics. It's comprehension related. You can take your own example backwards btw, you're trying to force English into something Japanese. Where does it says that Japanese cares about English ? Do they really need their games to have support for ASCII if they don't need it ?
Same goes for you, why would you use only ASCII and not the whole shift-jis encoding ? (ok there's UTF but I'm just explaining here)
If you want a concrete example, half of the text of Sword Art Online: Infinity Moment does NOT support Ascii at all. The japanese uses UTF8 and UTF16 as encoding (my guess is that there were multiple teams and they didn't bother to get the same encoding)
So what I did is simple, I've fucked UTF16 so it'll only accept single byte characters no matter what. Because it was: A=0x0041, not A=0x41 so AB = 0x00410042 (useless heh ? Try that one btw, it might work out for you)

And I'm a bit tired to answer everything so I'll leave at that right now :P
 

ChepChep

Well-Known Member
OP
Member
Joined
Feb 9, 2011
Messages
611
Trophies
0
XP
876
Country
United States
I have another quick ASM question...

I have added ASM that will overcome a 38 char limit in the game and make it 64 chars. There is room in memory for the content to just expand but I need to adjust memory addresses. Unfortunately, the code where I need to adjust from 38 to 64 char is used all over the place for rendering other things than the story line where I need to increase char count. The issue I am running into is that I do not want adjust the pointer everytime since it will break the game since the code is used for other rendering.

So I got my code all work in PPSSPP but I had to hard code a branch statement when particular addresses were used for storing the extra 26 chars. I tried running the code on the PSP and it does not branch at those conditions.

Does the PSP use different memory addresses than PPSSPP?

Is there a way to figure out what the PSP is actually using for address so I can branch when it is seen?

Thanks,
-Chep
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,377
Country
United Kingdom
Ahh inaccuracies in emulation vs hardware, especially when code reuse is in play. Give or take dynamic memory allocation then the emulator will use the same addresses (code would not work otherwise) but I have not assessed PPSSPP on the accuracy front so I can not say what goes exactly (by and large these early stage emulators are not so concerned with accuracy as much as working).

The usual suspects are

Flags for your conditional branches are not set properly or are cleared somehow. This is the classical reason why you are told not to call a function within a function in C family programming.
Illegal reads/alignment commands/whatever. The emulator might not emulate the alignment requirements, properly emulate read latencies or implement the full protocol if you are fiddling with DMA or something.
Some kind of dynamic memory allocation. This is more subtle but if an emulator sets memory to all 00 or something and the game uses some kind of unset memory based random number generator then it will work across boots in an emulator but might fail in hardware.

For alignment stuff then make sure you are using legal read commands or properly set up DMA. For latency, and for some aspects of flags, then add a bunch of nops before the branch on conditional happens. For flags then first you want to confirm it and

Alternatively if you know where the script engine is then copy the altered function somewhere new and have the script engine call that instead. Not ideal and very annoying to do but I have seen it a few times where you might have the same engine used for the menu and the story or something.
 

thexyz

Active Member
Newcomer
Joined
Jan 8, 2014
Messages
40
Trophies
0
Age
54
XP
180
Country
Serbia, Republic of
I have another quick ASM question...

I have added ASM that will overcome a 38 char limit in the game and make it 64 chars. There is room in memory for the content to just expand but I need to adjust memory addresses. Unfortunately, the code where I need to adjust from 38 to 64 char is used all over the place for rendering other things than the story line where I need to increase char count. The issue I am running into is that I do not want adjust the pointer everytime since it will break the game since the code is used for other rendering.

So I got my code all work in PPSSPP but I had to hard code a branch statement when particular addresses were used for storing the extra 26 chars. I tried running the code on the PSP and it does not branch at those conditions.

Does the PSP use different memory addresses than PPSSPP?

Is there a way to figure out what the PSP is actually using for address so I can branch when it is seen?

Thanks,
-Chep

Yes, it's possible that memory addresses will be different. You could use psplink to debug it on a PSP. But the idea of hardcoding memory addresses is very very bad and you shouldn't ever do this.
 

ChepChep

Well-Known Member
OP
Member
Joined
Feb 9, 2011
Messages
611
Trophies
0
XP
876
Country
United States
I know its a bad idea but it was a first try and was planning on fixing it. I was just curious how the PSP memory worked compared with the PPSSPP emulator.

Thanks for the tip on TempAR and also psplink. Just slowly learning ASM for the PSP and curious how things work.
 

ChepChep

Well-Known Member
OP
Member
Joined
Feb 9, 2011
Messages
611
Trophies
0
XP
876
Country
United States
Turns out I found a very simple and elegant way to fix the issue I had. I was literally able to change one line of assembly and get my code working.
0x088CDA94 - li v1,0x8 -> 0x9

This one line allows me to change where the text I am rendering is stored for both write and read. The asm calculates the memory address based on the value store in v1.

Thanks again for everyone's help.
-Chep
 

flame1234

Well-Known Member
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
If you're planning on enlarging .elf, you should just reconsider a simple idea.
- Is there a file that's always in memory in that game ?
If yes, you just have to enlarge it and put your code at the end. Tada. It's magical.
Well it didn't work exactly that way, but for Ys vs. Trails in the Sky I found a file with unused data (in the middle of the file) and put the extra data that I wanted there.
But yeah, it really was quite easy to do :)
I tried Stormyu's way first and it didn't work :( I was hitting loader code when I tried to debug it. Loader code is tough to debug :(
So, that's also a way to go if you're looking for more space in the executable.

I tried adding a program header, too. It worked on emulator, but not on a real PSP. I didn't get PSPlink to debug it, but I think the PSP was not even loading the extra program header.

A fourth solution I can think of (did not try):
Instead of adding a program header, you can extend an existing program header. It's way tougher because of all the ELF jumps you need to fix.
Once it's loaded, near where the program starts off, you can jump to your new section, move the whole section to wherever you want in memory using memcpy and then reset it back to zero using memset.
 

StorMyu

"I'm way too old for this"
Member
Joined
Jan 2, 2010
Messages
943
Trophies
1
Age
97
XP
1,093
Country
France
A fourth solution I can think of (did not try):
Instead of adding a program header, you can extend an existing program header. It's way tougher because of all the ELF jumps you need to fix.
Once it's loaded, near where the program starts off, you can jump to your new section, move the whole section to wherever you want in memory using memcpy and then reset it back to zero using memset.

sounds way more complicated than it should be.
just add a blank file to the game, use this to help you do it, and then insert your new code there, that way you just have to jump back to the elf everytime that's all.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    D @ diamondsofmayhem: G'night!