English Amiga Board


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

 
 
Thread Tools
Old 26 January 2020, 14:40   #1
mydma
Registered User

 
Join Date: Aug 2019
Location: uk
Posts: 15
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.
mydma is offline  
Old 26 January 2020, 15:02   #2
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 2,800
This:
Code:
section code,code_c
    lea bitplane,a0
    etc
    etc
    rts

section plane,bss_c
bitplane: 
    ds.b (320*256)/8
ross is offline  
Old 26 January 2020, 15:58   #3
mydma
Registered User

 
Join Date: Aug 2019
Location: uk
Posts: 15
Great, thanks
mydma is offline  
Old 26 January 2020, 15:59   #4
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 2,174
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.
roondar is offline  
Old 26 January 2020, 17:32   #5
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 2,800
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.
ross 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
Allocate/deallocate memory? idrougge Coders. Blitz Basic 7 03 February 2017 10:21
SWOS 96/97 - cannot allocate ShadowRam gingerbeardman project.WHDLoad 37 11 February 2011 17:49
WHDLOAD: Can't allocate Expmem (SKIDMARKS) Nostromo support.Games 9 15 October 2010 19:49
Could not allocate 'shadow ram'? NovaCoder project.WHDLoad 4 28 August 2008 01:09
Whats your 1st memory of your/an amiga? mrbob2 Nostalgia & memories 44 28 April 2007 00:03

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 09:23.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.07581 seconds with 14 queries