A couple of days ago I found this cute little game for OS X called »Chopper«. I played it several times but I couldn’t make it to the last level although I played it on »easy«. Since it is open source I thought I could compile it with more lives but unfortunetly it didn’t compile because the file libfmodUniversal.a was missing for some reason. Good to have hackers around though – with the help of one of them I used »gdb« to get the job done. This is what I did (with Chopper Version 1.04):
First download Chopper and its Source from majicjungle.com. Then I navigated to the source folder for chopper and started gdb in that directory with the executable path
$> cd /Volumes/Data/Downloads/Chopper_104_src/Source
/Volumes/Data/Downloads/Chopper_104_src/Source $> gdb /Volumes/Data/Downloads/Chopper\ 1.0.4/Chopper.app/Contents/MacOS/Chopper
Then I set a breakpoint in playerStats.m on line 33. This is where the initial lives are set.
(gdb) break playerStats.m:33
Breakpoint 1 at 0x23ede: file /Users/davidframpton/Documents/Code/Old Projects/Chopper_104/Source/playerStats.m, line 33.
Then run the app:
(gdb) run
Starting program: /Volumes/Data/Downloads/Chopper 1.0.4/Chopper.app/Contents/MacOS/Chopper
Reading symbols for shared libraries ............................................................................ done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries ... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries .. done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Now click »new game« with whatever difficulty you prefer. Now press escape to switch to windowed mode so you can see the terminal output. As you can see gdb stopped at the breakpoint we set before:
Breakpoint 1, -[playerStats init] (self=0x17198290, _cmd=0x90a64924) at /Users/davidframpton/Documents/Code/Old Projects/Chopper_104/Source/playerStats.m:33
warning: Source file is more recent than executable.
33 lives = startLives;
(gdb)
Now press »n« to step into
(gdb) n
34 nextExtraLife = 2000;
If you now enter the following you see the original number of lives to start with:
(gdb) print lives
$1 = 4
Now set your preferred number of initial lives
(gdb) print lives=1000
$2 = 1000
Now enter »c« to continue
(gdb) c
Continuing.
Now switch back to Chopper and have endless fun! Cool huh?
Main entry continued