GameHacking

From Yabause
Jump to: navigation, search

Introduction

This is basically a handy list of info that has been collected for the sake of helping people out who would like to contribute to Yabause by debugging emulation. Though this information could also be useful for those doing game translations, etc.

Program Information

Most games are compiled using the GNU C compiler. There are some however that used the Hitachi Compiler or used some form of assembly, but the vast majority used GNU C. Also, a vast majority of games used libraries from Sega called the SBL and SGL. So make sure you have some kind of reference material on those libraries.

Here's a chart showing how the registers are usually used:

What Registers are used for Registers
Function returns r0
Scratch r1-r3
Function arguments r4-r7(arguments over 4 are saved directly to the stack)
Preserved across calls r8-r13
Frame pointer, preserved across calls r14
Stack pointer, preserved across calls r15
In games using the SGL, it's set to point at the library's global variables gbr

(mostly gleaned from: http://ecos.sourceware.org/docs-1.3.1/ref/gnupro-ref/sh/SH_ch01.html)