Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Learning PSP assembly
12-02-2016, 01:15 PM
Post: #1
Learning PSP assembly
Hello.
I'm new here but I'm pretty used to some retro Assembly languages as 6502 (Nes) and 65816 (Snes).
Now I want to have some fresh air and move to Psp assembly, mainly for the purpose of game translating. I also searched through the net but found no technical document. So I want to ask is there an ideal place to start learning PSP assembly from scratch?
Also, I wonder if there's any document on PSP hardware registers.

Thank you for reading.
Find all posts by this user
Quote this message in a reply
12-02-2016, 09:46 PM
Post: #2
RE: Learning PSP assembly
Wololo.net forums
The used to hold a monthly psp programing competition (they may still). This would be probably one of the better places to find both reasources and people who can help as well, even though the psp forum is now a sub forum under vita.
Find all posts by this user
Quote this message in a reply
12-02-2016, 10:45 PM
Post: #3
RE: Learning PSP assembly
Thank you very much.
I wonder is there any document/guide/tutorial on how to use the debugger in PPSSPP?
Find all posts by this user
Quote this message in a reply
12-03-2016, 05:08 AM
Post: #4
RE: Learning PSP assembly
I would highly recomend not learning to program for the psp in an emulator, but instead use the actual hardware.

Btw, if you are running linux here is a link to the tool chain I used years ago when I was messing around with psp programming.
Find all posts by this user
Quote this message in a reply
12-03-2016, 05:51 PM
Post: #5
RE: Learning PSP assembly
Learning how to write programs for psp will not exactly teach you "PSP assembly" and nobody sane will want to learn asm just to write actual full size programs.

Either way if you don't want to write your software for psp, but instead need asm for modding/cheating/translating existing games - this can be generalized to any platform as there are just 3 things to do:
- check cpu architecture,
- read some generic documents about it,
- practice.

And really especially for that last part emulator > anything real hardware could ever offer.
Sure it's innacurate, and if you commit some lazy coding the shit will break not only on real hardware, but also between different version of the emulator, but that's actually great as it teaches you to do things properly.
PPSSPP can also be modified, you can implement some features to do all kinds of "hardware" mods, for example we can easily make mods to use right analog stick natively or ones that require impossibly heavy overclock to psp cpu.

There are no guides nor tutorials through, if you happen to be interested in debugging games, it's assumed you're already a geek, a quick learner and can figure things out by yourself. Would recommend checking the sources for things that might not be obvious/clickable, like for example disassembly hotkeys and using your favourite search engine(ie google) for any documents made about psp specific stuff.

Depending on your goal you might not need to learn all that much since all asm share some similarities and any basic document about 32bit MIPS R4000 will allow you to understand the differences from whatever asm you already know and start working on whatever you want for psp as well as a bunch of other consoles that might be using similar architecture.
In the end there's not that much knowledge to begin with, asm by nature is very basic and easy to understand going by opcode, it's hard purely by visual lenght that requires lots of practice to quickly read, noone can hold you hand and pass on their experience.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
12-04-2016, 01:32 AM (This post was last modified: 12-04-2016 01:33 AM by Yugisokubodai.)
Post: #6
RE: Learning PSP assembly
@TkSilver, LunaMoo: Thank you for replying me. I'm a Windows user.

As LunaMoo pointed out, I don't intend to make PSP games, but to hack/mod them. That's why I'm asking about the Asm things. Honestly, I have fundamental basic Asm with the Nes and Snes, and some PSX's Mips asm. Learning Assembly itself is not very difficult, but the key is to know clearly about the hardware of the platform. For PSP hardware, my search through the net resulted in vain.

So allow me to ask something about the PPSSPP debugger for more clarity for how the psp works. Maybe emulators are not as exact as the real hardware, but they're great helps for learning.

Let say, I'm debugging the PSP game: Dead or Alive.
Its main data contained in this file:

\PSP_GAME\USRDIAR\doap.arc

This file starts at LBA 250352 and ends at 428333. Each LBA is 2048 bytes in length, so we can say the file starts at: 250352 x 2048 = 512720896 = 0x1E8F8000.

Inside doap.arc are many texture (gim) files, including the font texture.
Now the opening screen and its GE debug looks like this.

(Imgur)
j0QNHu4.png

It says in the yellow circle: Texture L0: 0x091d1c00 (512x512) and 0x211C40 in red one.
The first font data found in doap.arc starts at these addresses:

$F00
$41100
$81300
$C1500

Which equivalent to ISO addresses:

$1E8F8F00
$1E939100
$1E979300
$1E9B9500


I want to ask as following:

1. What is L0?
2. The current texture (font 1) is loaded from 0x091d1c00? This is address is physical memory according to the PSP memory map. Is
0x091d1c00 an address in UMD?
3. Is 0x211C40 the next step to be loaded address of the next texture? Then somehow it becomes 0x09211c40.
4. Assume that I don't know where address of font 1 in doap.arc, so how to find its address with the clue: 0x091d1c00?
5. Is there any log function for PPSSPP? I mean log to text file.

Sorry for long post.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
12-04-2016, 03:04 AM
Post: #7
RE: Learning PSP assembly
1. L0 = short from level 0, when there's more than one "Level-" and "Level+" buttons will activate so you can switch between them.
2. No, it's not an UMD address, it's an address in PSP RAM, textures are generally stored in VRAM for speed, but they can also be stored in RAM - which in normal commercial games will be 24 mb starting from 0x08800000, HD remasters, prototypes and some homebrew would get 56mb(those weird values comes from first 8 mb being reserved for kernel).
3. If I understand correctly that's just an offset to current framebuffer base. So somewhere before there was an instruction saying "Base: 090000" which would be shifted into 0x09000000 and then the offset for texture address which get's added to base to get the address.
4. You would have to use Disassembly(not GEDebugger) set a write breakpoint and check what code writes the texture there starting before the texture get's moved there, then trace back step by step what the game does moving it in memory, extracting and whatever else it could be doing. That might be bothersome and very time consuming since textures does not have to resemble images they are built from, there's lots of weird things psp games can do and there might be many steps to go back from a texture to an image file.
5. Yeah, check bat files which ppsspp is released with. You can log breakpoints as well ~ including values of registers, when setting or editing execute breakpoint, just type into log fmt some description and registers between {}, for example: label1 {a1}, label2 {t2}, note that verbose log can be pretty heavy and in some games breakpoints might cause instability, so stuff might ocassionally crash;p.


When wanting to mess with games textures if you wouldn't care about real hardware, you could also consider just using texture replacement ~ under tools->dev tools there are some options for it, also this thread has lots of info about it. Might be troublesome to use in some games that modify textures or store random and changing data over some unused parts of textures, but in general it's pretty nice feature that avoids all the trouble of messing with game files also allowing custom HD textures.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
12-04-2016, 03:19 AM (This post was last modified: 12-04-2016 03:24 AM by Yugisokubodai.)
Post: #8
RE: Learning PSP assembly
Thank you for your valued information.

Actually I have found the texture with Memory view. Just Jump to address 0x091d1c00 in User ram, and search the values there in the ISo, then convert the found address back to LBA and you know which file contains the data you want.

Unfortunately, the PPSSPP I downloaded (latest one) doesn't come with a bat file. Maybe I need to download older version.
Find all posts by this user
Quote this message in a reply
12-04-2016, 03:45 AM
Post: #9
RE: Learning PSP assembly
I think only nightlies come with it, so check bottom of the download page or here. Either way those bat files just run the commandline:
Code:
--log=filename.txt
which can also include "-d" switch for debug log.


Well yeah not all games are hardcore so good for you, but there's lots of stuff like for example block transfer effects which take tiny fragments and build a texture like a puzzle and if the files have some custom compression/encryption just finding it on iso without reversing the compression/encryption will be impossible and that's rather common.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
12-04-2016, 03:50 AM
Post: #10
RE: Learning PSP assembly
Thank you very much. That helps me greatly!
I'm finding document on DMA transfer, do you know where to get one?
Find all posts by this user
Quote this message in a reply
12-04-2016, 04:16 AM
Post: #11
RE: Learning PSP assembly
Google is your friend on that, I guess there are just 2 related syscalls ~ here.
So you can search for "sceDmacMemcpy", and "sceDmacTryMemcpy", there are some open source psp sdk out there which might be easier to browse/understand than emulator source, I recall [Unknown] was saying they're outdated, but in the end nobody has official and updated SDK and it sucks either way.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
12-04-2016, 07:38 AM
Post: #12
RE: Learning PSP assembly
On joue Monster Hunter Fredom Unite en ligne.
Go Go Go.
À la chasse aux dragons.
OK
Merci
Find all posts by this user
Quote this message in a reply
12-04-2016, 08:18 AM
Post: #13
RE: Learning PSP assembly
I have set breakpoint on some dialogue text, and what suprised me is that the PSP write/read data to/from different memory address each time. This is insane!
For example, the first opening sentence is located at 0x9DDE783 then it becomes 0x9DDDCC3 the other time.
Find all posts by this user
Quote this message in a reply
12-04-2016, 03:17 PM
Post: #14
RE: Learning PSP assembly
Coming fron nes/snes I guess it might be insane, but it's actually a standard from like forever on pc's and should most likely be in more modern consoles as well, dynamic memory allocation is just more efficient when you deal with more memory hungry apps. That being said psp itself has no standards at all, every other game might work differently unless of course it's reusing same engine.

You can make your life easier by abusing savestates and/or rewind to kill off most random factors not counting user input. I think PPSSPP still has some hardcoded seeds for rng as well so it's actually easier to reproduce stuff than on the real thing. Sometimes you will need to set a read/write breakpoint on a larger range to catch something through and then end up having to check much more than you would want, but hey not everything can be easy.

If you're doing something like a fan translation, I would recommend checking GBATemp psp hacking section, since it should have lots of people experienced in exactly that.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
12-09-2016, 01:26 PM
Post: #15
RE: Learning PSP assembly
I notice there's a Ctr in the left corner of the Disassembly windows.
I wonder what is it.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: