English Amiga Board


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

 
 
Thread Tools
Old 05 October 2023, 15:10   #1
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 140
CloseWorkBench behavior depends on Kickstart

Hello Amiga coders,

I am having a bit of difficulty with CloseWorkBench.
My goal is to call it at startup when the game is booted from its startup-sequence only: with this I aim to be freeing up as much memory as possible.

On KS 1.3, it works perfectly. It returns 1, and the chip memory is freed.
On KS 2.04, it behaves strangely: From what I understand, KS 2.04 appears to delay the opening of the workbench screen in order to prevent showing it for games booting directly from floppy.
This means CloseWorkBench returns 0. However, if I keep repeating this call for approximately 38 frames, it eventually succeeds and returns 1!
To my understanding, this means that the Workbench eventually decided to open its screen.

On KS 3.1, CloseWorkBench always returns 0, so I assume they changed the logic and the workbench never opens.

Would you have suggestion on how I could handle this the best way possible? My current code is to attempt up to 255 times to CloseWorkBench:
It works well on KS 1.3 and 2.04; but on KS 3.1, it creates an undesirable and useless pause of about 5 seconds.

Last edited by remz; 05 October 2023 at 15:11. Reason: typo
remz is offline  
Old 05 October 2023, 20:52   #2
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,306
Under 2.0 and up, the workbench will simply not open if you boot from the startup-sequence, all provided you install the default 2.0 bootblock. Thus, there is no need to close it in first place. If, however, you or some other program in the startup-sequence prints something to the console, both the console and the workbench will open and - unless you run your program in the background and the system boots to the workbench. If a (non-workbench) window is open on the workbench screen, it cannot be closed.

In general, you cannot depend on CloseWorkBench() to succeed, either if the workbench screen is locked, or some windows are open on it. Thus, you cannot really depend on it. The best you can do is to call it, continue to run your program, and in worst case print a message that there is not sufficient memory available.
Thomas Richter is offline  
Old 05 October 2023, 21:35   #3
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 140
Thank you Thomas, that is very insighful!

I didn't know about this "default 2.0 bootblock": Would this bootblock work on KS 1.2/1.3 too?

In my case I wanted to rely on CloseWorkBench because I only invoke it if the game was loaded thru its startup-sequence.
If a user installs it on a HD, then it won't be invoked. And since it is my startup I can relatively safely assume no window or other stuff should be interfering.

My startup-sequence looks like this:

c:cd data
c:run <NIL: >NIL: Hamulet.exe closeworkbench >NIL:
c:endcli >NIL:

Last edited by remz; 05 October 2023 at 21:38. Reason: typo
remz is offline  
Old 05 October 2023, 22:09   #4
Nor Bert
Norbert
 
Nor Bert's Avatar
 
Join Date: Jan 2022
Location: Poland
Posts: 133
Try using add21k, add36k or add44k programs to get more memory.

Use ENDRUN instead of RUN

More information
http://amigadev.elowar.com/read/ADCD.../node002B.html
Nor Bert is offline  
Old 05 October 2023, 22:36   #5
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,361
I remember that programs that call CloseWorkbench (1.3) when the workbench didn't open often froze/crashed whdload in kickemu mode.
jotd is offline  
Old 06 October 2023, 03:55   #6
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 140
Quote:
Originally Posted by Nor Bert View Post
Try using add21k, add36k or add44k programs to get more memory.

Use ENDRUN instead of RUN

More information
http://amigadev.elowar.com/read/ADCD.../node002B.html
Thank you Nor Bert, that was an interesting read. I've downloaded and tried ENDRUN, and although the command would be doing exactly what we'd expect, the results are not great. Here's what I discovered by trials:

add21k: useless in this scenario, since the workbench screen is either going to be closed anyway, or won't exist at all. Also, it causes a 'Recoverable Alert 0100 000f on KS2.04 and KS3.1, probably since the workbench screen doesn't exist.


The numbers are the amount of free memory once my game has finished loading and allocated all the memory it needs:
with endrun:
c:cd data
c:endrun Hamulet.exe
ks1.3=53320 ks2.04=8400 ks3.1=7008


with run/endcli/closeworkbench combo:
c:cd data
c:run <NIL: >NIL: Hamulet.exe closeworkbench >NIL:
c:endcli >NIL:
ks1.3=52320 ks2.04=19176 ks3.1=17678


For both ks2.04 and ks3.1, there is a sizeable difference of about 10KB which I am having a hard time explaining. Behaviour-wise, both methods load exactly the same way: no workbench screen is visible.
remz is offline  
Old 06 October 2023, 09:37   #7
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,306
Quote:
Originally Posted by remz View Post
I didn't know about this "default 2.0 bootblock": Would this bootblock work on KS 1.2/1.3 too?
As far as I recall, yes. It only sets a hidden flag in the expansion.library which is read by the shell code.


Quote:
Originally Posted by remz View Post
c:cd data
c:run <NIL: >NIL: Hamulet.exe closeworkbench >NIL:
c:endcli >NIL:

Please remove the "C:" there. This would prevent the shell from using built-in commands, noting that "cd", "endcli" and "run" are all shell-internal in v37 and onwards.


Otherwise, this looks acceptable. Remember that it may take a while for the shell to reach the "endcli" and thus for your code to close the workbench. You do not need any "third party" programs for that.
Thomas Richter is offline  
Old 06 October 2023, 14:32   #8
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 140
Quote:
Originally Posted by Thomas Richter View Post
Please remove the "C:" there. This would prevent the shell from using built-in commands, noting that "cd", "endcli" and "run" are all shell-internal in v37 and onwards.

Otherwise, this looks acceptable. Remember that it may take a while for the shell to reach the "endcli" and thus for your code to close the workbench. You do not need any "third party" programs for that.
Thank you for your suggestion: strangely, it appears to save even slightly more memory on ks2.04 and ks3.1:
ks1.3=52320 ks2.04=19648 ks3.1=18216
~500 bytes more memory. I would assume the built-in run commands is more efficient, but since in both cases these processes are gone by the time my game is ready, I don't fully understand where that memory is gone to. Perhaps it is an OS buffer of some sort.

I was prefixing my commands with C: because I thought that on KS1.3 and before, it would 'help' DOS look directly at the right place: Otherwise, it starts by looking in the current directory, fails to find 'cd', then look in c:.
In any case, per your suggestion, I've changed my startup-sequence to:
cd data
run <NIL: >NIL: Hamulet.exe closeworkbench >NIL:
endcli >NIL:
and it works fine on all the kickstarts I've tried, and I've adjusted my 'closeworkbench' loop to iterate up to 50 frames.
This seems to be the best combination to free the most memory possible on small configurations (512KB chip Amiga), for ks1.2, 1.3, 2.04, and 3.1.
remz 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
Kickstart 1.1 CloseWorkbench remz Coders. General 0 07 November 2022 03:21
Gotek in external housing help! New video depends on it! Starglider 2 support.Hardware 22 24 April 2019 19:54
Is this normal behavior? nobody support.WinUAE 20 28 August 2017 22:38
Blithog behavior ovale Coders. Asm / Hardware 5 12 January 2015 08:05
The Future Depends on YOU! Help develop new Amiga games! Cammy Amiga scene 22 30 September 2009 17:51

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 14:05.

Top

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