![]() |
![]() |
#1 |
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; } |
![]() |
![]() |
#2 |
Zone Friend
Join Date: Apr 2005
Location: London
Posts: 1,179
|
I'm simultaneously relieved and annoyed not to be nerdy enough.
|
![]() |
![]() |
#3 |
Alien Bleed
Join Date: Aug 2022
Location: UK
Posts: 4,861
|
It reminds me of Bresenham's line drawing algorithm...
|
![]() |
![]() |
#4 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,484
|
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. |
![]() |
![]() |
#5 |
Registered User
Join Date: Sep 2022
Location: Eastbourne
Posts: 1,200
|
Sounds like your tutor from back then was ahead of his time. Does it look like particularly good code to you?
|
![]() |
![]() |
#6 |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,851
|
|
![]() |
![]() |
#7 |
Registered User
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
|
Trying my best
![]() 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. |
![]() |
![]() |
#8 |
Registered User
Join Date: Jun 2017
Location: Finland
Posts: 381
|
Hold on, was F/A18 Interceptor coded in C? Or did the author use also assembly code to make the 3D so fast?
|
![]() |
![]() |
#9 |
Alien Bleed
Join Date: Aug 2022
Location: UK
Posts: 4,861
|
Do I get any nert points for mentioning the word Bresenham at least? C'mon, I really need nerd validation just now
![]() |
![]() |
![]() |
#10 | |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,851
|
Quote:
![]() 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. |
|
![]() |
![]() |
#11 |
Alien Bleed
Join Date: Aug 2022
Location: UK
Posts: 4,861
|
No, it's Bresenham's circle algorithm. It's the name I'm panhandling for validation over.
|
![]() |
![]() |
#12 | |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,851
|
Quote:
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! |
|
![]() |
![]() |
#13 |
cheeky scoundrel
Join Date: Nov 2004
Location: Spijkenisse/Netherlands
Age: 43
Posts: 7,091
|
That's how much this decade sucks. You can't even call yourself a nerd without getting denied.
|
![]() |
![]() |
#14 | |
Alien Bleed
Join Date: Aug 2022
Location: UK
Posts: 4,861
|
Quote:
|
|
![]() |
![]() |
#15 |
Alien Bleed
Join Date: Aug 2022
Location: UK
Posts: 4,861
|
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. |
![]() |
![]() |
#16 | |
Registered User
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
|
Quote:
The piece that I showed was written in assembly, too. It's just the decompilation that shows it in C. |
|
![]() |
![]() |
#17 | |
Registered User
Join Date: Jun 2017
Location: Finland
Posts: 381
|
Quote:
Ah, okay. Thank you for the clarification! I wasn't actually aware that original assembly code can be decompiled into a higher-level language. |
|
![]() |
![]() |
#18 |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,851
|
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.
|
![]() |
![]() |
#19 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,711
|
So did you decompile it by hand or is there finally a decent decompiler available for the Amiga?
|
![]() |
![]() |
#20 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,659
|
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?
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
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 |
|
|