English Amiga Board


Go Back   English Amiga Board > Main > Retrogaming General Discussion

 
 
Thread Tools
Old 23 August 2011, 01:36   #1
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
Gods reverse engineering

Hello all,

I was curious about the engine used by Gods and how they linked the files built by their own editor to the game (you know, the article shown at Guardians of the Past: http://www.guardiansofthepast.co.uk/...?Version_ID=10).

I have still a lot of work to do like finishing decoding the cripal files, but its on his way.

As you may now (by my other works), i don't have the intention to do any remake. I only want to understand the inner work of the games and how they were coded 20 years ago by coding a custom tool.

To pique your curiosity, here's a little teaser showing a flying enemy wave triggered by an event:
Click image for larger version

Name:	Teaser 01.png
Views:	1810
Size:	109.4 KB
ID:	29349

I will add the possibility to show the event details within the next weeks.

FYI, i use the Atari version of the game because of the powerfull Steem debugger. You may notice some visual differences with the PC or Amiga version. I need to map some hardcoded values to make it compatible.

Cya,
Kroah
Kroah is offline  
Old 23 August 2011, 07:52   #2
Jonathan Drain
Registered User
 
Join Date: Sep 2009
Location: Sector K240
Posts: 338
Awesome work!

When you get done with Gods, perhaps you can help me find some secrets in K240
Jonathan Drain is offline  
Old 23 August 2011, 08:44   #3
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
Well done maybe JOTD might be intrested but still good work Dude
Retro1234 is offline  
Old 23 August 2011, 10:50   #4
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
Quote:
Originally Posted by Jonathan Drain View Post
Awesome work!

When you get done with Gods, perhaps you can help me find some secrets in K240
Gods is one of the biggest game i have ever decompiled with almost 200kb of asm for the main game loop. K240 must be even bigger .
I have never played K240, after finishing Utopia on Amiga (and its data disk), i jumped to Fragile Allegiance on PC. Too bad I've never saw a review of K240 in my french magazines, i think i would have loved it too. You understand, digging in the code of a game you have never played is very tedious.

Quote:
Originally Posted by Boo Boo View Post
Well done maybe JOTD might be interested
He could use it to fine-tune some of the puzzles or the location of the objects, but like he said in a previous thread, importing and using the data would take a lot of time doing it now, especially since he is busy IRL. But who knows...

Last edited by Kroah; 23 August 2011 at 14:22.
Kroah is offline  
Old 23 August 2011, 21:51   #5
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
I am more than interested. As I said the other day there's no trace of the hidden objects, but maybe you can resource enough to make them appear

Kroah I take anything you code! you are really impressive

I'm willing to completely rework my remake if your examination of the data files is worth it. At least the flying monsters trajectories could be imported back in my remake, making them more faithful.

Also we could understand / find the last remaining secrets if there are some.

Can't wait to see an update on this thread.

Last edited by jotd; 23 August 2011 at 22:03.
jotd is offline  
Old 24 August 2011, 15:29   #6
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
Quote:
Originally Posted by jotd View Post
I am more than interested. As I said the other day there's no trace of the hidden objects, but maybe you can resource enough to make them appear
Hidden objects are triggered by events as you may guess. So it's really easy to get the coordinates when you know the event structure.

Quote:
Kroah I take anything you code! you are really impressive
Thanks but it's a little too much . The preliminary works you and Qube have made are useful.
I began to work on the PC version by unpacking the files with your tool (dynamite). Then I have uncompressed the c*.* ST files (packed with a very basic RLE-like encoding).

Quote:
I'm willing to completely rework my remake if your examination of the data files is worth it. At least the flying monsters trajectories could be imported back in my remake, making them more faithful.
With the viewer C# source, you will be able to code the wanted output format or see how to read the data.

Data are quite well ordered. The algorithm is rather simple. I was only surprised the path origin depends on the screen position, i.e. the path coordinates are relative to the scroll position. But most (if not all) events (spawning flying waves) are triggered from only 1 way (left, right, ...). So the scroll position is always the same for the event.

Quote:
Also we could understand / find the last remaining secrets if there are some.
Yes, i hope there are still some extra things we haven't noticed or guessed.

Concerning the event system, it's pretty simple.
There are 6 type of events:
- spawn flying wave
- spawn ground wave
- check a puzzle
- spawn intelligent enemy (todo)
- activate a moving block
- spawn a guardian (boss)

A puzzle event is conditioned by up to 3 conditions (as seen in the bitmap brothers editor). If all conditions are met, the effect is triggered.

There are 7 condition types (with their negative counter part):
- the player is (not) carrying a specific object X
- the player has (not) equipped a specific weapon X
- the event X has (not) already been triggered
- the player health is (not) greater than X
- the elapsed time is (not) greater than X
- the switch X is on/off
- the player score is (not) greater than X
- the player remaining lives is (not) greater than X

There are 15 effects:
- the object X is spawned at x/y
- the weapon X is spawned at x/y
- the door X is opened/closed
- the backdoor X is opened with a type "teleport" or "world completed" (as in the end of level 1)
- the event X is triggered
- the object X is destroyed (only for type 4 objects like spikes, serpent vase, beehive...)
- the trapdoor X is opened/closed
- the player loses the weapon X
- the elapsed time is reset
- boss fight start/end (todo)
- no effect (but the event is still flagged as "triggered")

I'm currently working on rendering these information in the viewer.

Last edited by Kroah; 24 August 2011 at 16:01.
Kroah is offline  
Old 24 August 2011, 16:27   #7
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
excellent work as always.

What about the messages that are displayed on the bottom green bar ? It also is an effect, I don't see it in your list.
Also: there are moving blocks that stop once they have reached their destination, and others which move constantly back and forth.
jotd is offline  
Old 24 August 2011, 17:55   #8
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
Quote:
Originally Posted by jotd View Post
What about the messages that are displayed on the bottom green bar ? It also is an effect, I don't see it in your list.
You're right, i forgot to mention it.
When a puzzle is accepted (all 3 conditions true), the effect is executed AND a message displayed (facultative).
If you want a message to appear when you reach a specific location (without picking up a Hint), just use a puzzle event with a message and without condition, nor effect.

Quote:
Also: there are moving blocks that stop once they have reached their destination, and others which move constantly back and forth.
I still have to decode the moving block parts. I only have the initial state of the moving blocks right now. I will do this after the rendering part and before the CRIPAL part.

Just for info, the files "alfils.0XY" are in fact a concatenation of several files (found in some demos):
- flying waves (missing name)
- godYX.evt
- ground waves (missing name)
- intel.0YX (the cripal file for intelligent AI)
- switches.0YX
- teleport.0YX
- trapdoor.0YX
- mblocks.0YX

Concerning the SMC (self modified code), it seems it's only used to optimize the main game loop (for example, when the player reaches a guardian, most function calls in the main loop ends up to a RTS : no need to check for moving platforms, most collisions, etc...).
Even if this frees up many cpu cycles to avoid unnecessary checks, i don't understand why conditional JSR/BSR are not used like everyone do. I'm not sure the gain is great (without talking about the problem/incompatibility of cache flushing on higher cpu and disabling the JIT in emulator).
On top of that, the JSR/BSR is still executed, using unneeded cycles with the stack.

Example:
Code:
RAM:00019248 MovingBlocks_Update:
RAM:00019248                 nop
RAM:0001924A                 tst.w   (nbMovingBlocksB).w
RAM:0001924E                 bne.s   loc_1925A
RAM:00019250                 move.w  #$4E75,(MovingBlocks_Update).l
RAM:00019258                 rts
RAM:0001925A loc_1925A
[...]
You can see that 4E75 (RTS) is put at the NOP when nbMovingBlocksB=0.
There are around 50 cases like this (more or less equivalent).

Last edited by Kroah; 24 August 2011 at 18:00.
Kroah is offline  
Old 24 August 2011, 20:59   #9
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
Very clever design indeed.

I'm sure of a thing: the "big chest puzzle" at level 3.3 (you have to press 2 or 3 secret buttons, including one button at level 3.2) does not work when JIT is enabled, even with my fixed whdload slave (which fixes a lot of SMC)

About the reason for using SMC, maybe they needed to do it at some point but could not afford to change all the callers, or they wanted to be sure that the call was disabled... yes, not very efficient programming...

I can't wait for a full decode of the game!

Regards
jotd is offline  
Old 25 August 2011, 02:44   #10
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
Quote:
Originally Posted by jotd View Post
I'm sure of a thing: the "big chest puzzle" at level 3.3 (you have to press 2 or 3 secret buttons, including one button at level 3.2) does not work when JIT is enabled, even with my fixed whdload slave (which fixes a lot of SMC)
I keep this in mind for checking later, thank you.

- Here's a screenshot of the viewer:
Click image for larger version

Name:	Teaser 02.png
Views:	1292
Size:	66.2 KB
ID:	29361

- Here's a link to the binary + source of the viewer (7zip - 4.7mb):
http://bringerp.free.fr/Files/Gods/Gods Viewer - 00.7z

This is an early WIP version, don't expect too much .

You can't change the map right now without recompiling (1 map = 2 worlds, here level 1-1 & 1-2).

I will explain later the meaning of the colors, the acronyms and the white box for the waves... time to sleep .

Edit: You need .Net Framework 3.5. The project uses Microsoft Visual C# 2008 Express Edition.

Last edited by Kroah; 25 August 2011 at 18:02.
Kroah is offline  
Old 25 August 2011, 07:45   #11
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
Just ... awesome! BTW I don't see the speed bonus (which should be a gold bag in the center of your display)
jotd is offline  
Old 25 August 2011, 11:59   #12
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
Quote:
Originally Posted by jotd View Post
Just ... awesome! BTW I don't see the speed bonus (which should be a gold bag in the center of your display)
This is the P6 just on the left of the GW12
You can only see it with the viewer, it spawns by an event.

Edit: spawned objects & weapons are now semi-transparent

Last edited by Kroah; 25 August 2011 at 12:44.
Kroah is offline  
Old 25 August 2011, 21:35   #13
CaptainNow
Eleventh Hour Games
 
CaptainNow's Avatar
 
Join Date: Feb 2011
Location: Carnforth, England
Age: 49
Posts: 558
I am forever fascinated and impressed by those possessing programming skills of this level.
I just wanted to say so.
CaptainNow is offline  
Old 25 August 2011, 22:17   #14
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,161
works great! I have already learned some stuff I did not know (like timer on help bonuses). Apart from that we had everything figured out already. But the next levels will certainly reveal secrets.
jotd is offline  
Old 27 August 2011, 18:26   #15
Qube
Registered User
 
Qube's Avatar
 
Join Date: Aug 2006
Location: England
Posts: 218
Pretty awesome Kroah - keep it up - You are becoming the master of game reverse engineering Working out the inner workings of old games can be fun and rewarding, and expands the mind!

I remember a year or so ago I cooked up some crazy hacked up map viewer app and got it to finally show the maps from First Samurai, it's only basic, I think for that game the data was 2 bytes per tile, again a collision/event map ahead (or after) the tile map, I had to ignore every 2nd byte or something crazy, then the tile map tiles are 32x16 in size, strange one, but I digress.

If you put your mind to work, you can achieve anything! I'm thinking Gods had one of the most elaborate engines of games of that era.

Q

P.S. I wonder if Steve Tall ever reads this stuff, or even knows how his gem still gives many hours of enjoyment to people still.. 20 years later..
Qube is offline  
Old 31 August 2011, 02:03   #16
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
Quote:
Originally Posted by Qube View Post
Pretty awesome Kroah - keep it up - You are becoming the master of game reverse engineering Working out the inner workings of old games can be fun and rewarding, and expands the mind!
Yes, this is really fun and entertaining. Reverse enginneering a game is really like making a puzzle: you have some hints about the game, and the more you understand the inner working, the faster it goes and you understand the whole. Sometimes you reverse some isolated code and you hook it up to the main disassembly code like a part of a puzzle.

Quote:
Originally Posted by Qube View Post
I remember a year or so ago I cooked up some crazy hacked up map viewer app and got it to finally show the maps from First Samurai, it's only basic, I think for that game the data was 2 bytes per tile, again a collision/event map ahead (or after) the tile map, I had to ignore every 2nd byte or something crazy, then the tile map tiles are 32x16 in size, strange one, but I digress.
Interesting, i've never thought to map this game. Do you have any screenshot ?

Quote:
Originally Posted by Qube View Post
If you put your mind to work, you can achieve anything! I'm thinking Gods had one of the most elaborate engines of games of that era.
Gods has a good engine, but imho Cadaver has a better and more versatile one. Gods engine is totally oriented toward an arcade game with some basic adventure elements. Cadaver is the same with a more elaborated script engine and an incredible "3D world simulation" (weight, gravity, collision...) for its time.

Quote:
Originally Posted by Qube View Post
P.S. I wonder if Steve Tall ever reads this stuff, or even knows how his gem still gives many hours of enjoyment to people still.. 20 years later..
Too bad we don't have any news . I hope they will be flattered and won't become angry because we disassemble their code.
Kroah is offline  
Old 31 August 2011, 02:27   #17
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
New WIP version of Gods Viewer. You can grab it here (source included):
http://bringerp.free.fr/RE/Gods/wip.php5



New features:
- all worlds available (still the Atari version)
- forward & backward recursive links: you can see the links between the game elements (objects, events, doors, ...) recursively. For example, hovering a hidden key will show how it appears and where it's used.
- almost all game elements can be hovered by the mouse
- left clicking & dragging a wave event will show the screen position relative to the event. The outer white rectangle is the screen, the inner gray rectangle is the scroll limit. Because flying wave can be relative to the scroll position, this helps to see the correct ingame flying path.

Tips:
- World A = World 1&2, World B = World 3&4
- when 2 or more objects are stacked, you can left click to swap between them.

Todo:
- Intelligent enemies
- Moving blocks
- Some display options

Have fun!


Last edited by Kroah; 31 August 2011 at 11:00. Reason: todo: moving blocks
Kroah is offline  
Old 31 August 2011, 07:43   #18
Qube
Registered User
 
Qube's Avatar
 
Join Date: Aug 2006
Location: England
Posts: 218
Neat work Kroah, will test later on when I get a mo!

Have you thought about supporting the Demo game files at all? I don't know if there is anything to learn from such and it's only a partial first world map. I remember the ST demo had some minor different map tile graphics changes.

I will see if I can sort a screenshot out, it's on my old computer somewhere, time flies so to speak..

Q;
Qube is offline  
Old 31 August 2011, 16:48   #19
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,773
This might be a Very silly question and not suitable for here - But does Gods 8 way/diagonally scroll and if so how well.

for example and I havent tried but might if theres no answear you edited a blank level and and started at the top Jumped down diagonally for quite a high hight what would happen?

Most of the time you just scrolling horizontal or climbing verticaly.
Retro1234 is offline  
Old 31 August 2011, 17:12   #20
Kroah
Registered User
 
Kroah's Avatar
 
Join Date: Apr 2009
Location: France
Age: 46
Posts: 117
Quote:
Originally Posted by Boo Boo View Post
This might be a Very silly question and not suitable for here - But does Gods 8 way/diagonally scroll and if so how well.

for example and I havent tried but might if theres no answear you edited a blank level and and started at the top Jumped down diagonally for quite a high hight what would happen?

Most of the time you just scrolling horizontal or climbing verticaly.
Gods uses a 8 way scrolling. FYI, the scrolling steps are 1 pixel vertically, 4 pixels horizontally (it uses preshifted gfx). This information may be specific to the Atari version where bitplanes are interlaced).

FYI, they use the STe color hardware for the background raster effect (more than twice the number of colors vs ST). I don't see any specific STe blitter scrolling code though. The Amiga uses its copper for the raster effect (= STe) and I think they use the blitter as they did for chaos engine.

I will have more information about this when the Amiga version will be disassembled (i need this to get the hardcoded value of many variables for the viewer).
Kroah is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Speedball 2 reverse engineering & remake Kroah Retrogaming General Discussion 26 08 February 2024 15:08
Reverse engineering wiki copse Coders. General 10 02 March 2020 09:48
Captain Blood reverse engineering Kroah Retrogaming General Discussion 14 08 March 2016 21:22
Cadaver reverse engineering Kroah Retrogaming General Discussion 8 11 November 2011 09:35

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:57.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10162 seconds with 14 queries