English Amiga Board


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

 
 
Thread Tools
Old 12 October 2021, 20:51   #1
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Calling LoadSeg() from Bootblock?

Hi all,

I'm hoping you can answer what is probably a simple yes or no question for me.

Is it possible to call LoadSeg from within the Bootblock? I'm having fun trying to even open the dos.library from within the bootblock, but I just wanted to know even when I do manage to do that is it simply a case of calling LoadSeg on my executable program?

The end game here is to simply save ram and load my game straight away without the system having to open Workbench and startup sequence stuff.

Any help is really appreciated.

Cheers,
Graeme
mcgeezer is offline  
Old 12 October 2021, 21:28   #2
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Short answer: no
ross is offline  
Old 12 October 2021, 21:30   #3
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Quote:
Originally Posted by ross View Post
Short answer: no
Heheheh Cheers Ross!
mcgeezer is offline  
Old 12 October 2021, 21:37   #4
admiral
Engineer
 
Join Date: Oct 2018
Location: Shadow realm
Posts: 165
LoadSeg() is a dos.library function.

http://amigadev.elowar.com/read/ADCD.../node0279.html

However, when the bootblock runs, dos is still not initialized.

A bootblock's job is to tell the kickstart's strap module what to run next, by returning a pointer. Then strap frees the memory the bootblock uses, and jumps to that pointer (remember this, as you seem to care about available memory!).

Generally, that's a pointer to dos.library's Init routine (a fixed offset in the structure FindResident() returns).

If you were to init dos.library from your bootblock (via exec's InitResident()), dos would literally take over, so your bootblock code wouldn't run anymore, and on top of that, the bootblock would never be freed from memory.

Thus, there's two general approaches to take here:

- Load the executable you want to run by yourself, without dos.library's help. This is what you want, but you have to take care that your game's startup/exit code will not misbehave if you run it from AmigaOS, think RAM: or HDD.
- Take over the system completely from your game. This is inconvenient, as you can't use exec for allocations (because you can't free dos.library's memory). It also means AmigaOS might not be usable anymore (crash) if you attempted to use it, so you shouldn't. Now your game can't "exit" but by reboot/poweroff.

You'll find games generally use either approach.

The "without dos.library help" will mean in practice that you either write your own "trackloader", use trackdisk.device (preferable!) or use some code with a compatible license written by somebody else for comfortably loading from floppies. Some might even be able to understand standard filesystems.

You can still launch programs as tasks using exec's AddTask(), but you need to prepare them in memory yourself.

Note that if your game is self-contained in a single file, there's definitely tools out there that will prepare a floppy image for you that just loads and runs your game without ever opening dos.library.

Last edited by admiral; 12 October 2021 at 21:53. Reason: hdd
admiral is offline  
Old 12 October 2021, 21:52   #5
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Thanks admiral - that is useful info.
mcgeezer is offline  
Old 12 October 2021, 21:55   #6
admiral
Engineer
 
Join Date: Oct 2018
Location: Shadow realm
Posts: 165
Quote:
Originally Posted by mcgeezer View Post
Thanks admiral - that is useful info.
You're welcome. Just give AmigaXfer a go if you haven't yet.
admiral is offline  
Old 12 October 2021, 22:17   #7
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,957
Perhaps if your exe file will be not very complicated, you can create easy and short LoadSeg routine and place this routine in game bootblock.
Im not 100% sure, but if i remember right some old Amiga HD systems used external LoadSeg routine (supplied by Commodore) for loading HD drivers. No dos.library accesses.
Don_Adan is offline  
Old 13 October 2021, 01:28   #8
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,544
Quote:
Originally Posted by mcgeezer View Post
The end game here is to simply save ram and load my game straight away without the system having to open Workbench and startup sequence stuff.
You don't ever have to open Workbench, and startup-sequence stuff doesn't use much memory or time.

Unless you want to kick out the operating system and take over the whole machine I suggest you use it as intended. This will make your program more compatible and user-friendly.
Bruce Abbott is offline  
Old 13 October 2021, 12:15   #9
defor
Registered User
 
Join Date: Jun 2020
Location: Brno
Posts: 90
If you really want to take over the whole OS (and loose all its available functions), you may take a look at recently released Leonard's LDOS system. It allows you to load execs and data from the floppy.
defor is offline  
Old 13 October 2021, 15:20   #10
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Simply allocate memory in bootblock, then use track disk which is already active to load code, if needs be you can then use a relocate routine, and away you go.

If you wanted to absolutely have all memory available to you, every last byte, then taking over system and utilising a hardware banging sector loader is the other way forward.
Galahad/FLT is offline  
Old 13 October 2021, 16:47   #11
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Quote:
Originally Posted by Galahad/FLT View Post
Simply allocate memory in bootblock, then use track disk which is already active to load code, if needs be you can then use a relocate routine, and away you go.

If you wanted to absolutely have all memory available to you, every last byte, then taking over system and utilising a hardware banging sector loader is the other way forward.
This all then leads back to the whole WHDload saga. If I create a track loader I then eliminate hard drive users unless I use WHDload.
mcgeezer is offline  
Old 13 October 2021, 16:50   #12
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
One possibility would be to format the disk as DOS, use a trackloader (like Rob Northen) to read the executable file in memory and execute it with a minimalist loadseg/relocate routine. There are several available.

And leave your exe runnable from hard disk. Run with a give argument (ex: HD) to read files using trackloader or DOS. Include trackloader in your exe but use it only in the case you booted from floppy.

Simpler: don't use the bootblock but let the OS load your exe, but depending on an argument (same idea as above) use the OS or trackloader to load.

supercars2 has IFD directives to read from MFM track or OS for instance. This was for dev stages and was disabled in production but you can make it dynamic.
jotd is offline  
Old 13 October 2021, 16:53   #13
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by mcgeezer View Post
This all then leads back to the whole WHDload saga. If I create a track loader I then eliminate hard drive users unless I use WHDload.
Nope.

If you so wanted to, you could write a bespoke hard drive installer for your game, hiding the AmigaDOS executable on the disk.

But in all honesty, a whdload version would come any way.
Galahad/FLT is offline  
Old 13 October 2021, 20:49   #14
admiral
Engineer
 
Join Date: Oct 2018
Location: Shadow realm
Posts: 165
Quote:
Originally Posted by Galahad/FLT View Post
hiding the AmigaDOS executable on the disk.
Let's not give people data-destroying ideas :/
admiral is offline  
Old 13 October 2021, 21:23   #15
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by admiral View Post
Let's not give people data-destroying ideas :/
Well I'd hope no "cracked" version appears, but if they fuck it up, thats on them not Graeme
Galahad/FLT is offline  
Old 13 October 2021, 21:40   #16
admiral
Engineer
 
Join Date: Oct 2018
Location: Shadow realm
Posts: 165
Quote:
Originally Posted by Galahad/FLT View Post
Well I'd hope no "cracked" version appears, but if they fuck it up, thats on them not Graeme
It's never OK to bypass the filesystem the user selected as install target, and just clobber blocks somewhere.
admiral is offline  
Old 13 October 2021, 23:13   #17
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by admiral View Post
It's never OK to bypass the filesystem the user selected as install target, and just clobber blocks somewhere.
What filesystem?

Its whatever Graeme wants it to be, its not on him to guess what others would do with the disk, and he isn't obliged to worry about it either.
Galahad/FLT 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
PowerPacker LoadSeg Shell Decruncher brian_p support.Apps 9 14 April 2019 19:49
Calling it a day... killergorilla project.Killergorilla's WHD packs 57 28 March 2011 06:48
Calling All Contributors! fiath project.SPS (was CAPS) 9 28 October 2010 12:22
LoadSeg / Relocate to fixed address? a4k-oerx Coders. General 7 24 November 2008 17:35
loadseg help BippyM Coders. General 4 16 April 2007 13:35

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 13:33.

Top

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