English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 13 June 2013, 00:50   #1
Herpes
... aka Amix73
 
Herpes's Avatar
 
Join Date: Jan 2009
Location: Austria
Posts: 87
Question "special" chip-mem allocation 68K-ASM

Hi there everybody!

I want to allocate memory to us it as bit plane memory. That usually not a problem but I have certain requirements which must be satisfied.
I wonder if there is an elegant solution ...

* I want to keep it as legal as possible - so I need to allocate the memory with AllocAbs or AllocMem.
* I need a mem-block much less than 64K - lets say 24K.
* I do not want to cross 64K boundaries - therefore the the memory should be positioned in the chip area - just to be safe on most Amigas - below $80000. So typically I would like to have my memblock either before or after a 64K boundary.

Do I need to try to iteratively AllocAbs from e.g. ($20000+-MyBlocksize) up to ($80000-MyBlocksize) until I get a valid block? or is there a better way?


Thanks for your help!
Herpes is offline  
Old 13 June 2013, 07:17   #2
britelite
Registered User
 
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 818
I'm guessing allocating a larger block than the 24k needed is not an option?
britelite is offline  
Old 13 June 2013, 07:43   #3
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Alloc a bit more memory than you need and align it then. For example, if you want to have your memory aligned to a 64k boundary you would alloc YOURMEMSIZE+65536 bytes and after allocating you'd do this:

; d0.l: allocated memory
add.l #65536,d0
and.l #$3ff0000,d0 ; align to 64k boundary

Another option (if you're going to use AllocAbs() anyway), save the memory block you're going to destroy in a temporary buffer and then just use it. At the end you need to restore it of course.

Last edited by StingRay; 13 June 2013 at 08:19. Reason: forgot a line of code
StingRay is offline  
Old 13 June 2013, 08:20   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
Ugly but working method which does not waste memory (Enforcer uses this method to get MMU page aligned memory which means it can't be too bad):

AllocMem(65536 + memory size you need) normally.
Forbid()
Free whole allocated block
AllocAbs(allocated block aligned to next 65536 byte boundary, size you need)
Permit()
Toni Wilen is offline  
Old 13 June 2013, 11:42   #5
Herpes
... aka Amix73
 
Herpes's Avatar
 
Join Date: Jan 2009
Location: Austria
Posts: 87
Gyus - thank you very much - these are very nice ideas - and for me still "legal enough" - I don't know which I like most
Herpes 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
New One Of "Homebrew" 68k Amiga Magazine Idea fishyfish Retrogaming General Discussion 6 16 April 2013 08:57
James Pond "Special Edition"? Stefan Lindberg Retrogaming General Discussion 15 03 March 2013 23:00
Amiga Forever 2009.1 Released - "Black Friday" Special Paul_s News 0 26 November 2009 22:32
REQ: Power Play Special issues "Die Hundert Besten Spiele" (hundred best games) rsn8887 AMR suggestions and feedback 0 01 June 2007 19:02
Special Preview release of "SDK Browser" for AmigaOS4 RELEASED Paul News 0 21 December 2004 11:34

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 16:48.

Top

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