English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. Asm / Hardware (http://eab.abime.net/forumdisplay.php?f=112)
-   -   Whats the best way to allocate bitplane memory? (http://eab.abime.net/showthread.php?t=100594)

mydma 26 January 2020 14:40

Whats the best way to allocate bitplane memory?
 
To allocate memory for a bitmap I always used to do the following

Code:

section code,code_c
    lea bitplane,a0
    etc
    etc
    rts

section plane,data_c
bitplane:
    ds.b (320*256)/8

Which seems to work ok. But the problem with that method is increased file size and loading times when testing.

So I have switched to using the allocmem library which solves this.

But now Im wondering is there a "section" I can put in assembler that would allocate the memory when the program loads automatically? This would be ideal as it saves me handling of memory allocation.

ross 26 January 2020 15:02

This:
Code:

section code,code_c
    lea bitplane,a0
    etc
    etc
    rts

section plane,bss_c
bitplane:
    ds.b (320*256)/8


mydma 26 January 2020 15:58

Great, thanks :)

roondar 26 January 2020 15:59

Yup, ross gave a good answer there.

The alternative (assuming this is something you'd start from the CLI/Workbench) would be to dynamically allocate space using the Exec function AllocMem (and free it afterwards using FreeMem).

Generally, I find the section method is easier to use and the Exec allocation method is more flexible. But your mileage might vary here - both work just fine.

ross 26 January 2020 17:32

Actually for this specific case there is another alternative:
Code:

section code,code_c
    lea bitplane(pc),a0
    ...
    rts

bitplane:
    dx.b (320*256)/8
    end

But here you can open a Pandora's box.
;)


All times are GMT +2. The time now is 01:00.

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

Page generated in 0.07295 seconds with 11 queries