![]() |
![]() |
#1 |
Registered User
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,344
|
64k ram pointers boundary
Is there a way to be sure to have bitplanes and other pointers inside the 64k ram boundary, to speed up pointers' set-up, with allocated or reserved memory on ocs/ecs and Aga too?
![]() |
![]() |
![]() |
#2 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,053
|
I allocate extra 64KB and then ptr = (ptr+$ffff)&(~$ffff). You can also try AllocAbs() in a loop and see if you can get it.
Also, make sure that you don't under/over-flow (e.g. blitter in decrement mode, blits the last line and then mods get "added" and you drop down to the previous 64KB bank, so the next blit will have bad upper words). |
![]() |
![]() |
#3 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,302
|
Not from the operating system, but you can allocate the bitmap yourself and fill the plane pointers, and pass the bitmap structure over to OpenScreen with a tag.
To allocate memory aligned, the usual way of doing this is first a Forbid(), then an AllocMem() of the memory block with the size increased by 64K, then round up the start address to the next 64K boundary, then FreeMem(), and then AllocAbs() of the block you need, then finally Permit(). Or, mmulib/AllocAligned(), which does quite the same. |
![]() |
![]() |
#4 |
Registered User
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,344
|
@a/b , @Thomas Richter
Thanks |
![]() |
![]() |
#5 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,053
|
That's a nice way of doing it, with AllocMem I mean, but what could work better is get exec->MaxLocMem and then loop downwards in 64KB decrements. Leaves no gaps and if you are still multitasking it can reduce segmentation.
|
![]() |
![]() |
#6 |
Registered User
Join Date: Jun 2020
Location: Druidia
Posts: 389
|
On the A500 for a game or demo it seems fragile to rely on the OS for multiple allocations.
I just allocate one big chunk that's as big as I need for the whole program and then manage that myself with a stack allocator. My allocator has calls that will align to some size or make sure to fit inside some alignment. I'm then able to allocate buffers that are within a 64k page without wasting too much space. My main point is maybe that buffers don't need to be 64k aligned for you to only update the lower 16bits. They just need to be limited to within some 64k page. Maybe there are other ways of making such an allocation that could be clearer but I found the concept of keeping "inside" an alignment was the best I came up with. |
![]() |
![]() |
#7 |
Registered User
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,344
|
Is it possible to do the same with assemblers' directives like ds.b or rs.b and like that?
|
![]() |
![]() |
#8 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,636
|
Hmm.. You could reserve a bss_c block like explained with AllocMem above, but the trouble is that it is tricky to free the unneeded part of the block yourself (assuming that you want to do that as soon as you've got your 64k aligned block).
|
![]() |
![]() |
#9 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,182
|
If you mean something like
Code:
buffer: ds.b buffersize+65336 ... dc.l (buffer+$ffff)&(~$ffff) By the way you only need to allocate twice the needed size. Either the allocation already fits or you can move the buffer start to the next 64K boundary. Slightly more complicated but could be useful in low mem situations. I.e. something like: Code:
move.l #bufferbytes,a0 move.l a0,d0 add.w #buffersize-1,d0 bcc.b .ok clr.w d0 add.l #1<<16,d0 move.l d0,a0 .ok ; buffer in a0 bufferbytes: ds.b buffersize*2 Last edited by paraj; 13 October 2022 at 18:39. |
![]() |
![]() |
#10 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,029
|
Quote:
Code:
move.l #bufferbytes,a0 move.l a0,d0 add.w #buffersize-1,d0 bcc.b .ok add.l #$10000,d0 .ok clr.w D0 move.l D0,A0 ; buffer in a0 bufferbytes: ds.b buffersize*2 Code:
move.l #Buffy+$10000,D0 clr.w D0 move.l D0,A0 ; buffer in a0 Buffy ds.b $10000+buffersize |
|
![]() |
![]() |
#11 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,182
|
I could have made a mistake (and code wasn't tested), but if understood it correctly sandruzzo wants a buffer that doesn't cross a 64K boundary (such that only updates of the l(ow) pointer registers are necessary). I.e. that the whole buffer fits inside a single 64K region (note the caveats that a/b mentioned though), but it is not required that it start at a 64K block (address $XXXX00000). If that is required, disregard my post.
Unconditionally clearing the low part of the buffer address would potentially result in an address before the allocated memory. The idea is that we have a buffer (of twice the needed size). If ((buffer + buffersize - 1) >> 16) == (buffer>>16), the ".ok" case then all bytes of the buffer are in the same 64K region (easy case). Otherwise we know that the distance to the next 64K boundary must be less than buffersize (otherwise the buffer would have fit), and we can move the start address there (and know that we have enough room, since we moved the pointer at most buffersize-1). As an example consider buffersize=4, all addresses of bufferbytes up to including $xxxxfffc are ok, when we reach $xxxxfffd through $xxxxffff we get ($xxxx0000 + (1<<16)) (which is less than the buffer end address). |
![]() |
![]() |
#12 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,029
|
Perhaps you right. I understand wrong.
|
![]() |
![]() |
#13 |
Registered User
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,344
|
It could be a nightmare to have every bitplanes' pointers inside 64k limits..
|
![]() |
![]() |
#14 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,182
|
|
![]() |
![]() |
#15 |
Registered User
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,344
|
@paraj.
That's the key: to do less copper works by optimizing memory usage |
![]() |
![]() |
#16 |
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,157
|
I did once write some custom allocation routines for this kind of thing. To avoid wasting the "offcuts", it kept a record of them and would use them for future allocations where possible.
It's written in C, so probably of limited interest here, but I can dig them out if anyone's interested. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Allocating memory within a 64K boundary | deimos | Coders. General | 5 | 30 October 2019 12:14 |
GoldenGate Bridgecard 64K Software? | ahandyman59 | support.Hardware | 7 | 05 April 2017 08:58 |
64k Amiga ECS Intro | 4pLaY | Amiga scene | 1 | 16 July 2012 09:31 |
Looking for 18pin 64k DRAM chips 90ns + | Smiley | support.Hardware | 6 | 15 April 2006 04:26 |
Two mouse pointers! | mlft | support.WinUAE | 16 | 21 December 2002 02:52 |
|
|