English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 15 February 2021, 11:56   #41
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Quote:
Originally Posted by zero View Post
It feels like this is one of the most important parts of the code, the reason why you are able to get so much on screen. The blitter can do so much if handled right, but I don't think many games came close to this level of performance.

Interesting! How are you managing allocations? A lot of games just used arrays, but of course then every object has to be fixed size.
Yes, to have optimal performance its just arrays for everything. There is no dynamic memory allocation going on at all. To handle the different data within a class of objects i use unamed unions. So i can easily 'compose' new behaviors for my objects that share something common. Of course you waste some bytes with this approach but usually your number of objects is quite small (something between 16-64 in my cases). And each struct themself is usually only a few bytes.
pink^abyss is offline  
Old 15 February 2021, 12:27   #42
zero
Registered User
 
Join Date: Jun 2016
Location: UK
Posts: 428
Quote:
Originally Posted by pink^abyss View Post
Yes, to have optimal performance its just arrays for everything. There is no dynamic memory allocation going on at all. To handle the different data within a class of objects i use unamed unions. So i can easily 'compose' new behaviors for my objects that share something common. Of course you waste some bytes with this approach but usually your number of objects is quite small (something between 16-64 in my cases). And each struct themself is usually only a few bytes.
That's how I do it too, although not in games, on embedded systems.

Usually trade memory for performance, 16 bit alignment etc... But I wonder how that works out on the Amiga? Maybe two memory reads is less efficient than one memory read and a swap. Oh, but it's C, so maybe you aren't optimizing to that level anyway.
zero is offline  
Old 15 February 2021, 14:05   #43
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Quote:
Originally Posted by zero View Post
That's how I do it too, although not in games, on embedded systems.

Usually trade memory for performance, 16 bit alignment etc... But I wonder how that works out on the Amiga? Maybe two memory reads is less efficient than one memory read and a swap. Oh, but it's C, so maybe you aren't optimizing to that level anyway.

On Amiga 500 i try to make everything optimal from the start to have enough performance in the end. So i care about memory layout, and what types i use. However, in my experience it doesn't matter much if you use C or ASM with game development if you only consider performance. GCC 10 is good in optimizing.
pink^abyss is offline  
Old 15 February 2021, 14:27   #44
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,409
I've been quite surprised with just how good GCC 10 is at optimising. I did a few minor tests in Bartman's Visual Studio Code environment and the assembly it creates is quite good.
roondar is offline  
Old 15 February 2021, 22:10   #45
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,162
so basically you didn't use the original code as you thought you could write more efficient code from scratch.

And that worked.
jotd is offline  
Old 15 February 2021, 22:58   #46
malko
Ex nihilo nihil
 
malko's Avatar
 
Join Date: Oct 2017
Location: CH
Posts: 4,856
Quote:
Originally Posted by jotd View Post
so basically you didn't use the original code as you thought you could write more efficient code from scratch.

And that worked.
considering the differences between the arcade board and the amiga, this is a logical choice
malko is offline  
Old 16 February 2021, 00:20   #47
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,162
I'm also interested by this gcc 10 version.

I've used bebbo's gcc 6 for my game (Bagman) and (no offence) I'm disappointed by the speed. Maybe it's me, maybe it's C++, but in my game nothing much is happening and I find that slow...

I've used the blitter, avoided memory copies and all, not a lot of characters, no massive blits, no scrolling, using 16 colors, and still the game is super slow... it needs a 68030 IIRC.
jotd is offline  
Old 16 February 2021, 00:35   #48
lmimmfn
Registered User
 
Join Date: May 2018
Location: Ireland
Posts: 672
Quote:
Originally Posted by pink^abyss View Post
On Amiga 500 i try to make everything optimal from the start to have enough performance in the end. So i care about memory layout, and what types i use. However, in my experience it doesn't matter much if you use C or ASM with game development if you only consider performance. GCC 10 is good in optimizing.
I might be wrong but didnt you mention vs arcade its only doing collision detection every second frame?
lmimmfn is offline  
Old 16 February 2021, 11:52   #49
Bartman
Registered User
 
Join Date: Feb 2019
Location: Munich, Germany
Posts: 63
Quote:
Originally Posted by jotd View Post
I'm also interested by this gcc 10 version.

I've used bebbo's gcc 6 for my game (Bagman) and (no offence) I'm disappointed by the speed. Maybe it's me, maybe it's C++, but in my game nothing much is happening and I find that slow...
Yeah, we found each major version update gives 10-20% extra performance
Bartman is offline  
Old 16 February 2021, 17:10   #50
zero
Registered User
 
Join Date: Jun 2016
Location: UK
Posts: 428
Surprising how good GCC is for 68k. I didn't think 68k got much love which usually means poor optimization.
zero is offline  
Old 16 February 2021, 17:40   #51
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Quote:
Originally Posted by jotd View Post
I'm also interested by this gcc 10 version.

I've used bebbo's gcc 6 for my game (Bagman) and (no offence) I'm disappointed by the speed. Maybe it's me, maybe it's C++, but in my game nothing much is happening and I find that slow...

I've used the blitter, avoided memory copies and all, not a lot of characters, no massive blits, no scrolling, using 16 colors, and still the game is super slow... it needs a 68030 IIRC.

I looked through your code on GitHub and saw you use SDL. I don't know the SDL port for Amiga but i guess this is the main issue why your game runs slow. The other parts of your code look mostly fine for Amiga 500 (at least when LTO is enabled because you have a lot of function calls). If you really want to know where the performance goes then you need to profile
pink^abyss is offline  
Old 16 February 2021, 17:40   #52
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Quote:
Originally Posted by jotd View Post
so basically you didn't use the original code as you thought you could write more efficient code from scratch.

And that worked.

Yes, the arcade code would have been be too slow on A500.
pink^abyss is offline  
Old 16 February 2021, 19:52   #53
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,162
@pink^abyss

Thanks for checking my code No the code doesn't use SDL (amiga SDL uses chunky2pixel so it's a no go from the start!)

It uses SDL interfaces, but the structures have been hacked to use the blitter. Images are loaded as planar, and SDL_UpperBlit performs... blits .

It's a port from a SDL game, and I thought that it would be easier not to remove the SDL interface. It was kind of a challenge but it worked.

Basically the assets are pngs for the SDL windows version, but a python script combines them to compute the best 16 color palette then creates custom format with header + bitplanes compatible for the blitter (and sprites, but that's not active yet). I'm pretty happy with that engine, except for the speed... Using ptreplay from phx was also very easy.

Now if you have the link for a GCC 10 for 68k compiled for windows, I'd like to rebuild with that. I'd like to avoid VSCode if possible, I already have a project under a different build system.

Profiling is always a good idea. I didn't get how it can be done on amiga though... I hope the C++ part isn't the main culprit as it would be a pain to rewrite all that in C.

So if you have some more details/links I'll happily check them. If I had to do another game, I'd probably avoid the multi-platform part that time...

found this https://github.com/BartmanAbyss/vscode-amiga-debug seems to contain everything that looks great

Last edited by jotd; 16 February 2021 at 21:06.
jotd is offline  
Old 17 February 2021, 00:05   #54
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Quote:
Originally Posted by jotd View Post
@pink^abyss

Thanks for checking my code No the code doesn't use SDL (amiga SDL uses chunky2pixel so it's a no go from the start!)

It uses SDL interfaces, but the structures have been hacked to use the blitter. Images are loaded as planar, and SDL_UpperBlit performs... blits .

It's a port from a SDL game, and I thought that it would be easier not to remove the SDL interface. It was kind of a challenge but it worked.

Basically the assets are pngs for the SDL windows version, but a python script combines them to compute the best 16 color palette then creates custom format with header + bitplanes compatible for the blitter (and sprites, but that's not active yet). I'm pretty happy with that engine, except for the speed... Using ptreplay from phx was also very easy.

Now if you have the link for a GCC 10 for 68k compiled for windows, I'd like to rebuild with that. I'd like to avoid VSCode if possible, I already have a project under a different build system.

Profiling is always a good idea. I didn't get how it can be done on amiga though... I hope the C++ part isn't the main culprit as it would be a pain to rewrite all that in C.

So if you have some more details/links I'll happily check them. If I had to do another game, I'd probably avoid the multi-platform part that time...

found this https://github.com/BartmanAbyss/vscode-amiga-debug seems to contain everything that looks great

Ah, nice, i did't realize the amiga sdl emu you did!
It seems you are running while the OS is active? This takes away a lot of performance on A500. Also the non interleaved blits add a lot of overhead. The blit routine for objects <16 pixels will become super slow when it goes into the setpixel block. If you call it just one each frame it could eat all rastertime on A500. I'm not sure about the C++ overhead from older GCC. I currently use C++ for with Bartmans GCC10 (without any dynamic memory allocations). C++ is as fast as C for me so far.
pink^abyss is offline  
Old 17 February 2021, 00:43   #55
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,409
AFAIK there was a point at which the GCC optimisations suddenly became much better on the M68K branch. Not sure if that was version 8, 9 or 10 but I remember seeing a video about Amiga demo coding in C that talked about this leap in performance.
roondar is offline  
Old 17 February 2021, 13:44   #56
Bartman
Registered User
 
Join Date: Feb 2019
Location: Munich, Germany
Posts: 63
are you referring to my seminar? https://www.twitch.tv/videos/468413972?t=02h20m09s

Excerpt from there:
VBCC->GCC 6.2 +100% ->GCC 7.0 +20% ->GCC 8.2 +20%
Bartman is offline  
Old 17 February 2021, 14:01   #57
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,409
Quote:
Originally Posted by Bartman View Post
are you referring to my seminar? https://www.twitch.tv/videos/468413972?t=02h20m09s

Excerpt from there:
VBCC->GCC 6.2 +100% ->GCC 7.0 +20% ->GCC 8.2 +20%
Yes, that's the video. Was extremely interesting, thanks for making it
roondar is offline  
Old 17 February 2021, 14:13   #58
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,162
problem is: I'm using a lot of standard library (C and C++) in my project. And the distro seems to provide bareboard includes only.
jotd is offline  
Old 17 February 2021, 15:22   #59
pink^abyss
Registered User
 
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 408
Quote:
Originally Posted by jotd View Post
problem is: I'm using a lot of standard library (C and C++) in my project. And the distro seems to provide bareboard includes only.
Yeah, there is no standard support beside barebone stuff like memcpy and such. As Bartmans solution is targeted for A500 game and demo coding it doesn't made much sense to support the standard libs.
A few days ago i switched to C++ on A500 to enjoy much less typing then i had to do with C. Also having now ranged for loops in my templated UnitHeaps saved a lot casting around and adds some extra safety at compile time.
pink^abyss is offline  
Old 17 February 2021, 15:30   #60
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,162
I now suddenly understand why your games are only made with 1 exec file.

All assets are probably "static const unsigned char bitmap[] = {0x...}" like. It makes sense, as long as the whole game data fits into memory without loading.
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
Tinyus Open Beta Released (OCS Gradius port) pink^abyss News 213 11 May 2023 01:50
Tinyus - An arcade quality Amiga OCS port of Gradius/Nemesis pink^abyss News 103 12 May 2021 04:58
Tech AMIGA magazine thinlega request.Apps 9 19 February 2021 17:26
Trackmo tech paraj Coders. Asm / Hardware 4 30 March 2017 20:57
AmigaWorld Tech Journal Shadowfire AMR news 7 26 April 2009 19:14

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 03:58.

Top

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