27 April 2017, 10:24 | #1 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,542
|
Splitting a game into multiple executables
Something I've been dwelling on - my current project is getting rather memory hungry and unwieldy, and there's still components to be added. On top of that the executable is currently beyond 250kb! I am currently managing memory by using banks (so I load main game assets over title screen assets when they're no longer needed) but this is getting more difficult every day.
I was dwelling on the idea of splitting it into entirely separate executables (for instance, intro/menu/main game) maybe with a lightweight master "state machine" executable controlling the flow between them. Does anyone have any tips or advice for this sort of thing? I guess the main things I was wanting to know 1. How would one open another executable in a non-multitasking way (so the current program will stop until control is passed back). 2. When control is passed back to the launching program, what needs to be done to ensure the memory consumed by the previous program is definitely freed back to the system? Thanks in advance. Last edited by earok; 27 April 2017 at 10:34. |
27 April 2017, 22:24 | #2 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 471
|
1. I believe if you use System_() your loader program halts until the called executable returns.
2. Make sure your program runs fine, everything should be freed at exit. Maybe a libflush/fontflush is needed. Generally i'm curious how your program exceeds 250k. But you can certailny split it into loader/main etc or level1/level2/level x. |
28 April 2017, 01:13 | #3 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,542
|
Thanks mate!
I'm not sure what you mean by System_()? Do you mean Execute_()? I'm honestly not sure how my executable is that large either.. I'm using a variety of third party libraries (XBone's CIA Tracker, GFont etc) as well as unrolled loops (using Macros), I guess it all adds up. |
28 April 2017, 12:31 | #4 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 828
|
@earok
If were you, first I would checked why executable is so large. With control version you can very fast find the answer. Of course I assume that you use some kind of control version. Also as I remember I did some short tests with Blitz Basic and with some short examples to checked quality of executable. After compiling I found inside unused code. |
28 April 2017, 16:38 | #5 |
Registered User
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 138
|
dos.library's LoadSeg()/CreateProc() would probably be the way to go
But, your first process remains in memory, so nothing is won, regarding memory consumption |
28 April 2017, 21:34 | #6 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 471
|
earok:
load your code into AmiBlitz3, it has a fantastic way of showing you all used commands (and #calls) and therefore all used libraries. Sometimes i am using just one single call of a lib, and replacing this by a few lines of code i can avoid linking the whole lib. |
28 April 2017, 22:23 | #7 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,351
|
Yep, good advice for avoiding unused code. Also, if you're using any resident files, there may be the possibility to use smaller .res, or just create the constants required in your main code if you're only using a few. The all.res file is convenient, but includes probably thousands of definitions you don't need. I would have hoped the compiler wouldn't include them but I'm not sure.
In the case of AB3 Includes, you could make your own stripped-down versions containing only the functions you need, which could weed out a lot of unused code. If you're using Blitz 2.1, have you got the "Create smallest code" option turned on in compiler settings? If you're using AB3, the "Create minimised executable" option in the Compiler menu does the same thing. In both cases, the compiler will make extra passes to remove more dead code from the final executable. Also, make sure the debugger is turned off when you compile an executable as if you leave it on, it includes lots of extra debugging code. As others have said, the assets of different parts of the program will remain in memory unless that task is ended before the next one runs. This is possible with a minimal overall executable that governs everything else. In this case, the Execute_ OS call, or the dos_RunCLI() function from dos.include if you're using AmiBlitz, can be used to launch another executable. |
30 April 2017, 12:45 | #8 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,782
|
I favour Amos over Blitz for now but I like this idea but the main control program would have to be light maybe Arexx or AmigaBasic - But could be anything it wouldn't have to stay running it could just load again after each section, This would definitely make Ram usage smaller but more loading - Great Idea
|
30 April 2017, 21:03 | #9 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 471
|
Using AmigaBasic for this task sound ridiculous.
A small loader using Loadseg_() would be a much better idea and it is also possible to code in Blitz. |
01 May 2017, 02:16 | #10 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,542
|
Thanks for the advice guys
Is there any examples of using LoadSeg_ with Blitz (or maybe even in general) somewhere..? I'm comfortable with using Execute_ right now but if LoadSeg would be better I'd like to check it out. |
05 May 2017, 02:48 | #11 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 471
|
There is the free loader src of Pinball Fantasies (AGA?) somewhere, possibly Aminet. But it is in E, so you would have to adapt it a bit. It's small, like "load table to mem, set some regs, jump to mem" kindof stuff. Go check it out.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Executables and initial register values | copse | Coders. General | 10 | 23 June 2022 14:39 |
run executables as df0: | jbl007 | support.WinUAE | 6 | 10 March 2015 20:39 |
Dynamic screen splitting/joining in a game: Was it possible on Amiga? Did it exist? | lilalurl | Retrogaming General Discussion | 17 | 17 December 2009 20:04 |
Splitting files | mikni | support.Apps | 4 | 19 September 2001 14:51 |
|
|