English Amiga Board


Go Back   English Amiga Board > Main > Nostalgia & memories

 
 
Thread Tools
Old 28 April 2023, 20:07   #1
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
When you look at the code of a 35 year old game...

... and you recognize, with a big grin on your face, an algorithm from a course you once had at university.

From F/A-18 Interceptor:
Code:
    _x = 0;
    d = _y * -2 + 3;
    if (0 < _y) {
      do {
        *xcoords = -_x;
        xcoords[1] = _x;
        *ycoords = -_y;
        ycoords[1] = _y;
        if (d < 0) {
          d = d + _x * 4 + 6;
        }
        else {
          d += (_x - _y) * 4 + 10;
          _y += -1;
          xcoords = xcoords + 2;
        }
        ycoords = ycoords + -2;
        _x += 1;
      } while (_x < _y);
     }
    if (_x == _y) {
      *xcoords = -_x;
      xcoords[1] = _x;
    }
Ten fake internet points for the nerd who recognizes it, too.
ara is offline  
Old 28 April 2023, 21:47   #2
rare_j
Zone Friend
 
rare_j's Avatar
 
Join Date: Apr 2005
Location: London
Posts: 1,176
I'm simultaneously relieved and annoyed not to be nerdy enough.
rare_j is offline  
Old 28 April 2023, 21:57   #3
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,169
It reminds me of Bresenham's line drawing algorithm...
Karlos is online now  
Old 28 April 2023, 22:23   #4
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,233
That is not a line drawer. This is a circle drawer (or parts of it). There are similar algorithms to draw any conic section. That is, rotated ellipses, parabola and hyperbola. It all goes down to the fact that a conic section is the zero set of a quadratic function, and an edge-tracer of a quadratic function only requires linear operations (thus, no multiplications and no divisions).

To give you some reference, DPaint uses a similar algorithm for drawing slanted ellipses (not the above Bresenham, but the above conic section), unfortunately not as a very good implementation.
Thomas Richter is offline  
Old 28 April 2023, 23:12   #5
Megalomaniac
Registered User
 
Join Date: Sep 2022
Location: Eastbourne
Posts: 1,019
Sounds like your tutor from back then was ahead of his time. Does it look like particularly good code to you?
Megalomaniac is offline  
Old 28 April 2023, 23:33   #6
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,588
Quote:
Originally Posted by ara View Post
When you look at the code... From F/A-18 Interceptor:
You decompiled the machine code?
Bruce Abbott is offline  
Old 29 April 2023, 00:01   #7
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
Quote:
Originally Posted by Bruce Abbott View Post
You decompiled the machine code?
Trying my best Quite a challenge, but it's progressing (very slowly). Do you know whether anybody has published the source code or is willing to share it?

And yes, it's the Bresenham's circle drawing algorithm. Straight from the textbook: https://www.geeksforgeeks.org/bresen...ing-algorithm/

The game uses it to draw the sun and the head of the pilot.
ara is offline  
Old 29 April 2023, 09:42   #8
A500
Registered User
 
Join Date: Jun 2017
Location: Finland
Posts: 362
Hold on, was F/A18 Interceptor coded in C? Or did the author use also assembly code to make the 3D so fast?
A500 is offline  
Old 29 April 2023, 10:02   #9
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,169
Do I get any nert points for mentioning the word Bresenham at least? C'mon, I really need nerd validation just now
Karlos is online now  
Old 29 April 2023, 12:50   #10
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,588
Quote:
Originally Posted by Karlos View Post
Do I get any nert points for mentioning the word Bresenham at least? C'mon, I really need nerd validation just now
No. One glance should have told you this wasn't Bresenham's line algorithm.

I first learned about Bresenham back in 1980 when I was creating a 6800 based computer from scratch. I wanted to draw lines in the 'hires' 256x192 screen of the MC6847 video display generator, and the simplicity of this algorithm blew me away! I had almost no computing knowledge and very few resources, not even a assembler - just the machine code monitor that I wrote from scratch and a copy of the 6800 Software Gourmet Guide and Cookbook by Robert Findley.
Bruce Abbott is offline  
Old 29 April 2023, 13:06   #11
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,169
No, it's Bresenham's circle algorithm. It's the name I'm panhandling for validation over.
Karlos is online now  
Old 29 April 2023, 20:43   #12
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,588
Quote:
Originally Posted by Karlos View Post
No, it's Bresenham's circle algorithm. It's the name I'm panhandling for validation over.
No, that's not how it works. To be a nerd you have to be "a person who is extremely enthusiastic and knowledgeable about a particular subject, especially one of specialist or niche interest". Just dropping names doesn't count. Trying to get nerd points for something you are clearly wrong about does the opposite. It may seem a little harsh, but that's just the way it works in nerd land.

Note that if you keep going on about it you risk being called a 'lamer'. To avoid this I suggest posting some other obscure technical detail that only a true nerd would know. Alternatively you could claim an acceptable excuse such as that you typed circle but the autocorrect changed it to line, or the cat jumped on the keyboard. That happens to me all the time, and I don't even have a cat!
Bruce Abbott is offline  
Old 29 April 2023, 21:05   #13
gimbal
cheeky scoundrel
 
gimbal's Avatar
 
Join Date: Nov 2004
Location: Spijkenisse/Netherlands
Age: 42
Posts: 6,919
That's how much this decade sucks. You can't even call yourself a nerd without getting denied.
gimbal is offline  
Old 29 April 2023, 21:24   #14
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,169
Quote:
Alternatively you could claim an acceptable excuse such as that you typed circle but the autocorrect changed it to line, or the cat jumped on the keyboard.
I mean that totally did happen, except it was thumbs and my android phone's increasingly ludicrous idea of what it thinks I want to say...
Karlos is online now  
Old 29 April 2023, 21:45   #15
Karlos
Alien Bleed
 
Karlos's Avatar
 
Join Date: Aug 2022
Location: UK
Posts: 4,169
Quote:
Originally Posted by gimbal View Post
That's how much this decade sucks. You can't even call yourself a nerd without getting denied.
I dunno, this decade you only have to identify as a nerd, and anyone contradicting you is a vicious bigot that must be cancelled.

Last edited by Karlos; 29 April 2023 at 23:26.
Karlos is online now  
Old 29 April 2023, 22:24   #16
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
Quote:
Originally Posted by A500 View Post
Hold on, was F/A18 Interceptor coded in C? Or did the author use also assembly code to make the 3D so fast?
Most of it was written in assembly code as far as I can tell. Only the high-level stuff (initialization of the screen, music, etc.) was written in C.

The piece that I showed was written in assembly, too. It's just the decompilation that shows it in C.
ara is offline  
Old 30 April 2023, 14:56   #17
A500
Registered User
 
Join Date: Jun 2017
Location: Finland
Posts: 362
Quote:
Originally Posted by ara View Post
Most of it was written in assembly code as far as I can tell. Only the high-level stuff (initialization of the screen, music, etc.) was written in C.

The piece that I showed was written in assembly, too. It's just the decompilation that shows it in C.

Ah, okay. Thank you for the clarification! I wasn't actually aware that original assembly code can be decompiled into a higher-level language.
A500 is offline  
Old 30 April 2023, 22:49   #18
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,588
Quote:
Originally Posted by A500 View Post
Ah, okay. Thank you for the clarification! I wasn't actually aware that original assembly code can be decompiled into a higher-level language.
Depends on what the original source code was. If it was written directly in assembler (not extracted from C compiler output) then technically you would be translating it to C, not decompiling it.
Bruce Abbott is offline  
Old 01 May 2023, 10:15   #19
Minuous
Coder/webmaster/gamer
 
Minuous's Avatar
 
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,642
So did you decompile it by hand or is there finally a decent decompiler available for the Amiga?
Minuous is offline  
Old 01 May 2023, 10:23   #20
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
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?
hooverphonique 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 11:52.

Top

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