English Amiga Board


Go Back   English Amiga Board > Main > Nostalgia & memories

 
 
Thread Tools
Old 01 May 2023, 12:22   #21
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,549
Quote:
Originally Posted by hooverphonique View Post
Is it even possible to reliably identify that some binary was compiled from C? I mean, you can generally tell by the structure of the disassembly if it originally was compiled from a higher level language, or written directly in asm, but how would you identify it as originating from C?
There are some general features of C vs other languages that may be visible in the machine code, eg. how parameters are passed on the stack. But each compiler also produces code that produces a unique 'fingerprint' specific to that compiler. Blitz BASIC code looks very different to SASC code, which is quite different from gcc code etc.
Bruce Abbott is offline  
Old 01 May 2023, 12:32   #22
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,147
What Bruce said. A lot of compilers have intrinsics to support C language features that are quite easy to spot once you've seen them before.
Karlos is online now  
Old 01 May 2023, 13:35   #23
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
ok.. so the answer is "no" when using the qualifiers "generally" and "reliably", but f/a 18 is probably compiled using some well-known compiler :-)
hooverphonique is offline  
Old 07 May 2023, 14:41   #24
8bitbubsy
Registered User
 
8bitbubsy's Avatar
 
Join Date: Sep 2009
Location: Norway
Posts: 1,711
Quote:
Originally Posted by Karlos View Post
I dunno, this decade you only have to identify as a nerd, and anyone contradicting you is a vicious bigot that must be cancelled.
More truthful words have never been spoken... It's a weird time we live in.
8bitbubsy is offline  
Old 08 May 2023, 01:07   #25
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,549
Quote:
Originally Posted by hooverphonique View Post
ok.. so the answer is "no" when using the qualifiers "generally" and "reliably", but f/a 18 is probably compiled using some well-known compiler :-)
F/A 18 appears to be ~1/3rd C and 2/3rds assembler. The C code looks like Lattice, which would make sense since it was the official compiler for the Amiga. To prove it I would have to compile some code with an early version of Lattice C and see what it produced.
Bruce Abbott is offline  
Old 08 May 2023, 21:29   #26
A500
Registered User
 
Join Date: Jun 2017
Location: Finland
Posts: 361
This discussion is very intriguing, like watching a detective story of sorts
A500 is offline  
Old 23 May 2023, 00:08   #27
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
I found a function in the binary that is only called when some bytes are set to 1. I don't see them being written anywhere in the code, so I guess it's a function meant for debugging.

The attached picture shows the result. The small diagonal line in the top left corner is drawn every odd frame. The three-digit number is the frame rate (but not in fps, the base seems to be 800000). The other two numbers are the x and y input of the input controller.
Attached Thumbnails
Click image for larger version

Name:	interceptor_debug.png
Views:	85
Size:	18.6 KB
ID:	79104  

Last edited by ara; 23 May 2023 at 00:53.
ara is offline  
Old 24 May 2023, 00:15   #28
Ray Norrish
Registered User
 
Ray Norrish's Avatar
 
Join Date: May 2005
Location: Cheshire, UK
Age: 56
Posts: 322
I recall when you look at code made in pure assembler in a decompiler, it looks "clean" in comparison for want of a better word. I seemed to remember encountering BCD more frequently in non-ASM compiled code.
Also, there's frequently obvious bloat in higher level compilers. I expect that the exec stub would have some kind of uniqueness, as well as what sort of mem alloc pieces there are.
I expect one of the number of ex-crackers on here would recognise code structure from their typical tracing experiences.
Ray Norrish is offline  
Old 24 May 2023, 16:45   #29
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
The compilers in the 1980s were not as much optimizing as the modern ones. For example, I don't remember to have ever seen loop unrolling in old compiled code. In addition, in code written in assembly language you can find structures that don't appear in compiled code. Typical example: code shared between several functions, like this:
Code:
function1:
     some instructions
function:
     some instructions
     rts
That said, I have to say that the parts of the Interceptor game written in assembly (most of the game core) look rather ugly (sorry dear author) and I definitely have a much harder time to annotate it with meaningful symbols and type names than I had with Starglider 2 and Carrier Command.

Do you know which game was written almost entirely in C? Populous. The code is very easy to read. I started translating it to Java and actually finished the game initialization and rendering part (see the attached picture), but at some point implementing all the game logic became too boring (so many "if"s....)
Attached Thumbnails
Click image for larger version

Name:	pop.png
Views:	65
Size:	169.6 KB
ID:	79115  
ara is offline  
Old 24 May 2023, 20:13   #30
qz3fwd
Registered User
 
Join Date: Oct 2022
Location: Shelby Township
Posts: 72
Doesn’t IDA Pro decompile nowadays? Last time I looked at it about 10+ years ago I thought it did?
qz3fwd is offline  
Old 24 May 2023, 21:13   #31
A500
Registered User
 
Join Date: Jun 2017
Location: Finland
Posts: 361
Quote:
Originally Posted by ara View Post
Do you know which game was written almost entirely in C? Populous.

Theoretically speaking, would this mean that the game could be further optimized at least to a modestly significant degree by hand-written assembler? I'm assuming here that the compiled C code from 1991 is not as efficient.
A500 is offline  
Old 24 May 2023, 23:08   #32
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
Quote:
Originally Posted by A500 View Post
Theoretically speaking, would this mean that the game could be further optimized at least to a modestly significant degree by hand-written assembler?

Here is a fragment of C code that I reverse-engineered with the help of Ghidra. It comes from a function that flattens a 9x9 patch of land for the AI player:
Code:
(player->action).id = 2;  // land lowering action
(player->action).x = x;
(player->action).y = y;
player->moveDone = 1;
Looks clean, right? Here are the actual machine instructions from the binary of the game:
Code:
movea.l   (-0xe,A5),A0
move.b    #0x2,(A0)
movea.l   (-0xe,A5),A0
move.b    d4,(0x1,A0)
movea.l   (-0xe,A5),A0
move.b    d5,(0x2,A0)
movea.l   (-0xe,A5),A0
move.w   #0x1,(0x8,A0)
There are some optimization opportunities
ara is offline  
Old 24 May 2023, 23:10   #33
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,147
Quote:
Originally Posted by ara View Post
Here is a fragment of C code that I reverse-engineered with the help of Ghidra. It comes from a function that flattens a 9x9 patch of land for the AI player:
Code:
(player->action).id = 2;  // land lowering action
(player->action).x = x;
(player->action).y = y;
player->moveDone= 1;
Looks clean, right? Here are the actual machine instructions from the binary of the game:
Code:
movea.l   (-0xe,A5),A0
move.b    #0x2,(A0)
movea.l   (-0xe,A5),A0
move.b    d4,(0x1,A0)
movea.l   (-0xe,A5),A0
move.b    d5,(0x2,A0)
movea.l   (-0xe,A5),A0
move.w   #0x1,(0x8,A0)
There are some optimization opportunities
It looks like the compiler didn't apply subexpression elimination for the pointer dereference.
Karlos is online now  
Old 24 May 2023, 23:10   #34
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,174
okay but do you really need more speed on that game? Our elders knew that compilers were crap, so they wrote critical parts in assembly already.

if so, I suppose that one could disassemble, remove the useless instructions / write more efficient code, reassemble.

But first, you'd have to profile the code to see where you'd have the best gain, else it's a lot of work for unguaranteed results.

PS: great job with the RE of Populous nevertheless. Granted, re-making those games for modern platform has little interest as those modern platforms can already emulate the real game. Unless you add features (HD, extensions...) which is another story...
jotd is offline  
Old 24 May 2023, 23:21   #35
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
Quote:
Originally Posted by jotd View Post
Granted, re-making those games for modern platform has little interest as those modern platforms can already emulate the real game
True. For me, it's just a leisure activity and a kind of archeology. It's fun to see how much game play they could squeeze into a few kbytes of code. If a remake or extended version were the goal, it would be more interesting to directly start from Populous 2.
ara is offline  
Old 25 May 2023, 08:56   #36
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,174
Another useful thing when resourcing is you can figure out how data is done and create level editors for the original engine.
jotd 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
Most advanced game by year? rothers Amiga scene 51 15 April 2022 20:47
Best Game of Year 2021 Solo Kazuki Amiga scene 13 28 February 2022 15:08
EAB Game of the year poll mcgeezer Amiga scene 20 15 December 2021 08:05
From What year to what year You can use a stock Commodore Amiga 500? The Brave Ant Nostalgia & memories 3 10 June 2014 18:34
AGTW game of the Year Dizzy project.EAB 6 23 December 2006 17:58

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 20:02.

Top

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