English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. General (http://eab.abime.net/forumdisplay.php?f=37)
-   -   Maximise free chip ram when booting from a floppy using the OS (http://eab.abime.net/showthread.php?t=86769)

alpine9000 13 April 2017 02:48

Maximise free chip ram when booting from a floppy using the OS
 
I have been down the trackloader route for games and obviously we are in full control of all ram, so I have that covered.

But lately I have been toying with the concept of an OS friendly option that boots from a floppy and still runs in low ram config amigas (Think 512 chip, 512 slow).

If I create a boot floppy that only just launches the game from the startup-sequence I noticed the amount of free chip ram is quite different depending on the ROM version. 2.04 seems to give me more free ram than 1.3 for example.

I am assuming that if someone has other peripherals attached that might also impact the free chip ram ?

Are there any tricks to freeing up this ram before I launch my game ? I notice on 2.04 it doesn't seem to create a console window, but 1.3 does.

Samurai_Crow 13 April 2017 06:03

Have you tried closing the Workbench screen at start-up?

alpine9000 13 April 2017 06:57

Quote:

Originally Posted by Samurai_Crow (Post 1152271)
Have you tried closing the Workbench screen at start-up?

Is the workbench screen started with an empty startup sequence?

Samurai_Crow 13 April 2017 07:18

On Kickstart 1.x it is. I think the original shareware Deluxe PacMan there is a utility in its startup sequence that calls CloseWorkbench() and launches a binary then calls OpenWorkbench() afterwards. It is called free16k or something like that.

alpine9000 13 April 2017 07:39

Quote:

Originally Posted by Samurai_Crow (Post 1152273)
On Kickstart 1.x it is. I think the original shareware Deluxe PacMan there is a utility in its startup sequence that calls CloseWorkbench() and launches a binary then calls OpenWorkbench() afterwards. It is called free16k or something like that.

Ah great - that's exactly the kind of thing I'm looking for

alpine9000 13 April 2017 09:54

I found this:

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

Which describes what you have said above. It mentions a commodore utility called "EndRun" that sounds like it is exactly what I am looking for.

Anyone got it ?

Edit: Found it on the developer CD

mark_k 14 April 2017 20:55

In addition to EndRun, you may be able to have code in the bootblock which disables all extra floppy drives. I think you'd just need to open disk.resource and allocate all non-zero units. That will prevent trackdisk.device and DOS from using chip memory for them. Of course you might want to carefully handle the case where the user boots the disk in DF1: not DF0:...

hitchhikr 15 April 2017 00:33

The source (to be improved):

Code:

/*
 * Frees approx 21k of chip memory
 * (Also speeds up the CLI a bit).
 * Probably not a good idea to use this on anything
 * else than a 1.x KickStarts.
 */

/*
 * Includes
 */
#include <libraries/dos.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuitionbase.h>

#include <clib/all_protos.h>

/*
 * Variables
 */
struct IntuitionBase *IntuitionBase;
struct DOSBase *DOSBase;
struct Screen *scr;
struct BitMap *bm;
struct Window *win;
ULONG orig_height;

/*
 * Program entry point
 */
int main(int argc, char *argv[])
{
    PLANEPTR pl0;
    PLANEPTR pl1;
    PLANEPTR plb;
    PLANEPTR ple;
    IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0);
    DOSBase = (struct DOSBase *) OpenLibrary("dos.library", 0);
    scr = IntuitionBase->ActiveScreen;
    win = IntuitionBase->ActiveWindow;
    orig_height = scr->Height;
    SizeWindow(win, 0, 56);
    Delay(1 * 50);
    scr->Height = 256;
    bm = &scr->BitMap;
    bm->Rows = 256;
    bm->Depth = 1;
    pl0 = bm->Planes[0];
    pl1 = bm->Planes[1];
    bm->Planes[1] = NULL;
    plb = pl0 + (640 * 256 / 8);
    ple = pl1 + (640 * orig_height / 8);
    RemakeDisplay();
    FreeMem(plb, ple - plb);
    CloseLibrary((struct Library *) DOSBase);
    CloseLibrary((struct Library *) IntuitionBase);
    return (RETURN_OK);
}

And the binary: http://franck.charlet.pagesperso-ora...emp/add21k.zip

alpine9000 15 April 2017 09:59

Quote:

Originally Posted by hitchhikr (Post 1152612)
The source (to be improved):

Code:

/*
 * Frees approx 21k of chip memory
 * (Also speeds up the CLI a bit).
 * Probably not a good idea to use this on anything
 * else than a 1.x KickStarts.
 */

/*
 * Includes
 */
#include <libraries/dos.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuitionbase.h>

#include <clib/all_protos.h>

/*
 * Variables
 */
struct IntuitionBase *IntuitionBase;
struct DOSBase *DOSBase;
struct Screen *scr;
struct BitMap *bm;
struct Window *win;
ULONG orig_height;

/*
 * Program entry point
 */
int main(int argc, char *argv[])
{
    PLANEPTR pl0;
    PLANEPTR pl1;
    PLANEPTR plb;
    PLANEPTR ple;
    IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0);
    DOSBase = (struct DOSBase *) OpenLibrary("dos.library", 0);
    scr = IntuitionBase->ActiveScreen;
    win = IntuitionBase->ActiveWindow;
    orig_height = scr->Height;
    SizeWindow(win, 0, 56);
    Delay(1 * 50);
    scr->Height = 256;
    bm = &scr->BitMap;
    bm->Rows = 256;
    bm->Depth = 1;
    pl0 = bm->Planes[0];
    pl1 = bm->Planes[1];
    bm->Planes[1] = NULL;
    plb = pl0 + (640 * 256 / 8);
    ple = pl1 + (640 * orig_height / 8);
    RemakeDisplay();
    FreeMem(plb, ple - plb);
    CloseLibrary((struct Library *) DOSBase);
    CloseLibrary((struct Library *) IntuitionBase);
    return (RETURN_OK);
}

And the binary: http://franck.charlet.pagesperso-ora...emp/add21k.zip

Thanks, I'll give this a try.

Today I tried EndRun and while it does close the cli window it doesn't result in me being able to load a larger chip segment. I'm guessing it frees some ram but it must be fragmented and not able to be allocated in one larger chunk.

hitchhikr 15 April 2017 12:33

Perhaps you could make something out of this:

http://aminet.net/package/util/cli/flush220
http://aminet.net/package/util/sys/AllocFrags
http://aminet.net/package/util/moni/memm (requires MUI)
http://aminet.net/package/dev/c/nofraglib

Apollo 27 April 2017 10:31

I remember that there was a tool (maybe for kick 1.2/1.3) reducing the number of bitplanes of the workbench screen to one and so releasing some kilobytes of valuable chipram.

something like that f.ex.
http://aminet.net/package/util/misc/add36k

Asman 02 May 2017 17:23

@hitchhikr

I checked your add21k and it didn't work under kick1.3. I have seen guru meditation #81000009.00000058.

zipper 02 May 2017 19:28

That's odd - I think it was on my Lotus 1 disk (yes, confirmed).

hitchhikr 02 May 2017 20:15

Asman: looks like a memory block freed twice.

It works here on v1.2 & v1.3 kickstarts

Maybe this one is more compatible ?

Code:

/*
 * Add21k v0.2
 * Frees approx 21k of chip memory
 * (Also speeds up the CLI and the Workbench a bit).
 * Probably not a good idea to use this on anything
 * else than a 1.x KickStart.
 */

/*
 * Includes
 */
#include <stdio.h>
#include <libraries/dos.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuitionbase.h>

#include <clib/all_protos.h>

/*
 * Variables
 */
struct IntuitionBase *IntuitionBase;
struct DOSBase *DOSBase;
struct Screen *scr;
struct BitMap *bm;
ULONG orig_height;
ULONG orig_width;

/*
 * Program entry point
 */
int main(int argc, char *argv[])
{
    PLANEPTR pl0;
    PLANEPTR pl1;

    IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0);
    DOSBase = (struct DOSBase *) OpenLibrary("dos.library", 0);
    scr = IntuitionBase->ActiveScreen;
    orig_width = scr->Width;
    orig_height = scr->Height;
    bm = &scr->BitMap;
    bm->Depth = 1;
    pl0 = bm->Planes[0];
    pl1 = bm->Planes[1];
    if(pl1 != NULL)
    {
        bm->Planes[1] = NULL;
        RemakeDisplay();
        FreeMem(pl1, (orig_width * orig_height / 8));
    }
    CloseLibrary((struct Library *) DOSBase);
    CloseLibrary((struct Library *) IntuitionBase);
    return (RETURN_OK);
}

The binary:

http://franck.charlet.pagesperso-ora...emp/add21k.zip

Asman 02 May 2017 22:35

@hitchhikr
Thanks a lot. Now it works. Frankly few minutes before you posted answer I figured out that. So I recoded it to asm version. Binary and asm version in The Zone. As I checked Avail return 20496 bytes more in column Available.
Code:

;
;add21k based on hitchhikr c source of add21k
;
;I tested it only on kickstart 1.3
;
        incdir        'includes:'
        include        'intuition/intuitionbase.i'
        include        'intuition/screens.i'
       

add21k:
        ;open intuition library
                move.l        4.w,a6
                lea        intuitionName(pc),a1
                jsr        -408(a6)        ;exec OldOpenLibrary
                move.l        d0,d7
                beq.b        .exit
               
        ;calculate one bitplane size (width * height / 8)
                move.l        d0,a0
                move.l        ib_ActiveScreen(a0),a1
       
                move.w        sc_Width(a1),d1
                move.w        sc_Height(a1),d2
                mulu        d1,d2
                lsr.l        #3,d2
               
        ;set screen bitplanes depth
                lea        sc_BitMap(a1),a2
                move.b        #1,bm_Depth(a2)
               
                move.l        a0,a6
                jsr        -384(a6)        ;intuition RemakeDisplay
               
        ;free second bitplane memory
                move.l        4.w,a6
                move.l        12(a2),a1
                move.l        d2,d0
                jsr        -210(a6)        ;exec FreeMem
               
        ;close intuition library
                move.l        d7,a1
                jsr        -414(a6)        ;exec CloseLibrary

                moveq        #0,d0
.exit                rts

intuitionName:        dc.b        'intuition.library',0


hitchhikr 03 May 2017 00:24

Another version in C (smaller and doesn't crash if executed several times).

http://franck.charlet.pagesperso-ora...emp/add21k.zip
(Source in .zip).

I tested it on 3.0 and it works well until a loadwb is issued, there it crashes.

idrougge 07 May 2017 04:10

http://eab.abime.net/showthread.php?t=72215

earok 21 April 2020 13:19

I had the exact same problem outlined in this thread, and the thread helped a lot.

My game uses system friendly OS calls to load files, and when booted from Kickstart 1.3, there just wasn't enough memory to boot the game under 512K Chip/512K Other.

I needed to use both ENDRUN and CloseWorkbench(). So far as I can tell, ENDRUN by itself closes the CLI while simultaneously opening the target application, but CloseWorkbench() actually frees the memory. CloseWorkbench() won't work if Workbench is still in use (if the CLI is opened) so it's important to use both.

40KB saved!

ross 21 April 2020 15:03

Hi earok, check this thread, is where my addchip utility was born:
http://eab.abime.net/showthread.php?t=87859

Then the Odyssey+ release:
http://eab.abime.net/showpost.php?p=...8&postcount=44
There inside a little utility that I've written that do an advanced EndRUN (multiple file launcher) and CloseWorkbench() in a single exe.
(well, it's a custom version, but I can give you the generic version)

Odyssey is a game that use OS to load files, originally in two disks and a bit picky about memory configurations.
Was very challenging pack it in one disk and make it work in every configuration.
So my utility pair was crucial.

I'm pretty confident it's impossible to have more memory on a 512+512 machine (and with the larger contiguous block) of that combination ;).

earok 21 April 2020 15:07

Quote:

Originally Posted by ross (Post 1393775)
Hi earok, check this thread, is where my addchip utility was born:
http://eab.abime.net/showthread.php?t=87859

Then the Odyssey+ release:
http://eab.abime.net/showpost.php?p=...8&postcount=44
There inside a little utility that I've written that do an advanced EndRUN (multiple file launcher) and CloseWorkbench() in a single exe.
(well, it's a custom version, but I can give you the generic version)

Odyssey is a game that use OS to load files, originally in two disks and a bit picky about memory configurations.
Was very challenging pack it in one disk and make it work in every configuration.
So my utility pair was crucial.

I'm pretty confident it's impossible to have more memory on a 512+512 machine (and with the larger contiguous block) of that combination ;).

Thanks Ross, I'll check it out! Would definitely love to get a generic version of that if I could.

Am I allowed to use your utility in my own releases, as well as being part of the (potentially, commercial in future) Scorpion Engine toolkit?


All times are GMT +2. The time now is 12:49.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.

Page generated in 0.05002 seconds with 11 queries