15 November 2012, 03:36 | #1 |
Registered User
Join Date: Sep 2009
Location: Sector K240
Posts: 338
|
Disassembling games to find out the game logic?
A lot of real-time strategy games work on rules that aren't explained in the manual or anywhere, but which are very useful for calculating the most effective strategy. Things like weapon damage, a unit's hit points, or hit/miss chances.
I have trouble spotting game logic in disassembly of the game, because it's usually a very small piece of code (e.g. checking a single integer once in the game loop) and I'm not used to assembly. Are there any tricks to finding game rules in the game code? |
15 November 2012, 04:51 | #2 | |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 522
|
Quote:
|
|
15 November 2012, 22:33 | #3 | |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Quote:
Not sure about individual games, but there are alot of tricks in coding that you can only learn from the programmers themselves. I personally hate trying to understand other peoples code (especially disassembled code). As for the movement AI in RTS games, they basically use the A* pathfinding algorithm or a variation on it. There used to be pages documenting it on www.gamedev.net but I can't find them right now. I have them saved to my laptop, so if you are interested I can .lha the webpages and stick them in the zone. Edit: They moved it, it's now here: http://www.gamedev.net/page/resource...eginners-r2003 Last edited by Lonewolf10; 15 November 2012 at 22:43. |
|
16 November 2012, 07:05 | #4 | |
Registered User
Join Date: Nov 2012
Location: Willich/Germany
Posts: 232
|
Quote:
This was helpful for me porting PacMania and Galaga 88 from the X68000 to the Atari Falcon. Cheers Sascha |
|
16 November 2012, 07:17 | #5 | |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 522
|
Quote:
I'm currently working on a disassembler, and have added support for X68000 executable files, and it would be helpful to know for to allow for future expansion. |
|
16 November 2012, 10:28 | #6 | |
Registered User
Join Date: Nov 2012
Location: Willich/Germany
Posts: 232
|
Quote:
Yes, the Line-F calls are indeed only dumped as "dc.w $fxxx" in the source code but detecting its purpose was rather easy since the value is different for each DOS call. Here's a snippet from Galaga 88: Code:
... L_0003200A: move.w %D0,WORD_00041424.l | 0x0003200A 33C0 0004 1424 | move.w #0x0,-(%A7) | 0x00032010 3F3C 0000 | move.l %A0,-(%A7) | 0x00032014 2F08 | dc.w 0xFF3D | 0x00032016 FF3D | _OPEN addq.l #0x6,%A7 | 0x00032018 5C8F | tst.l %D0 | 0x0003201A 4A80 | bmi.s LOAD_FILE | 0x0003201C 6BC2 | move.w %D0,FILE_HANDLE.l | 0x0003201E 33C0 0004 1422 | move.w WORD_00041424.l,%D0 | 0x00032024 3039 0004 1424 | beq.w L_00031DB8 | 0x0003202A 6700 FD8C | subq.w #0x1,%D0 | 0x0003202E 5340 | beq.w L_00031DE6 | 0x00032030 6700 FDB4 | subq.w #0x1,%D0 | 0x00032034 5340 | beq.w L_00031E3A | 0x00032036 6700 FE02 | bra.w L_00031E74 | 0x0003203A 6000 FE38 | L_0003203E: move.w FILE_HANDLE.l,-(%A7) | 0x0003203E 3F39 0004 1422 dc.w 0xFF3E | 0x00032044 FF3E | _CLOSE ... Cheers Sascha |
|
16 November 2012, 20:49 | #7 | |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 522
|
Quote:
Is the %A0 register naming an Atari ST style? As far as I recall, we just go vanilla A0 style in Amiga land. |
|
16 November 2012, 21:08 | #8 | |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 522
|
Quote:
The currently most feasible tool, is to debug the program and get familiar with the code that way. Ideally you would have a debugger that let you relabel addresses, and basically acted as Resource+debugger. I think that Ollydbg is a PC debugger that lets you do this for PC programs. And IDA for the PC probably does the same, but I haven't used it much. But on the Amiga, I think you are out of luck. I know there was one debugger/disassembler combination for the Amiga, but it never worked for me when I tried it and I have no idea how you would obtain it anyway. I think it would not be that much work to disassemble an Amiga debugger and extend it with the ability to edit label/symbol names, and to allow saving of those and source. Another option is to use the WinUAE debugger, but I've always found using it somewhat inscrutable. Another option that is not currently possible is to use a disassembler does some of the legwork for you. I don't know about you, but there's a step when I disassemble a program that was linked against a library where I go through and relabel all the routines that make library calls. Then I go through and relabel all the wrapper routines that call the routines that make library calls. And then I go through and relabel all the wrapper routines that call the wrapper routines.. There's an approach that I think is called library fingerprinting - where IDA Pro or some similar solution has a database of signatures for routines that get linked from the static libraries, and can automatically label them. And similarly, instead of you needing to go find all the "move.l 4.w, A6" and set the symbol for the call into exec or whatever, they also proactively detect these OS calls and automatically put the symbols in place and comments on the arguments passed on the stack. Links: Signatures for Library Functions in Executable Files (citeseer paper page). Unstrip signature detection tool. IDA Pro FLIRT signature detection. Of course, another approach might be to do try IRA. Getting reassembleable source code, and debugging it in the assembler might be somewhat helpful. |
|
16 November 2012, 22:00 | #9 | |
Registered User
Join Date: Nov 2012
Location: Willich/Germany
Posts: 232
|
Quote:
The disassembler can, however, be configured to produce different styles. Cheers Sascha |
|
17 November 2012, 05:02 | #10 |
Registered User
Join Date: Sep 2009
Location: Sector K240
Posts: 338
|
What I've been doing so far is to disassemble with IRA, then when I work out what a label is for, I find-and-replace the label name with a more descriptive one. Amiga system library calls are easy to spot, and from there you can tell which parts of code probably deal with sound, graphics, disk IO, etc. It's like building a jigsaw by finding the edges and working inward.
Finding an individual line of game logic is like looking for a needle in a haystack. If only I had a magnet! |
17 November 2012, 05:43 | #11 | |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 522
|
Quote:
|
|
18 November 2012, 21:10 | #12 |
Registered User
Join Date: Sep 2009
Location: Sector K240
Posts: 338
|
I'm not sure. I think because I couldn't find a full version of ReSource at the time, so I just tried to see what could be done with IRA and the WinUAE debugger. I'm really an asm noob.
|
19 November 2012, 07:23 | #13 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,640
|
|
20 November 2012, 00:42 | #14 |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 522
|
|
20 November 2012, 02:24 | #15 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,640
|
Why wouldn't they? It's a bit pointless having to learn completely new syntax for every different CPU when they all carry out much the same operations, it makes it far easier to read code for unfamiliar CPUs, etc. I really can't think of a single advantage to manufacturer-specific notation (except that you can quickly tell in most cases what CPU the assembly code you are looking at is written for, because of the non-standardization. But generally one would know this in advance anyway).
It's not hard to support, eg. the disassembler subsystem of my emulator supports it for both the supported CPUs (2650 and 6802). Anyway I won't rehash all the arguments in favour of it, I will just give some links which provide justification and reference: http://calm.baillifard.com http://www.pf-soft.ch/ascalm.php?L=E&C=W http://www.didel.com/calm/ Last edited by Minuous; 20 November 2012 at 07:59. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Games which defy logic!! (any platform) | Paul_s | Nostalgia & memories | 188 | 17 July 2018 03:46 |
Disassembling resource | copse | Coders. General | 1 | 02 April 2012 03:36 |
Disassembling and reassembling | absence | Coders. General | 7 | 22 September 2009 15:30 |
Disassembling games for fun | crabfists | Coders. General | 69 | 29 October 2008 11:20 |
A Space Game? FIND and get a GAME [Found: Moon City] | Dr. Dude | Looking for a game name ? | 69 | 22 April 2007 21:01 |
|
|