wbushby wrote: ↑24 Apr 2023, 13:05
Can you point me to an explanation of this code:
' Defines the amount of contiguous RAM needed for blit stripes, (in this case 15*6 + 1), min address and search direction
_blitStripeChunks_ 15, &h1FA0, &hFFFF, ascending
Marcel's original sprite routine, (that I call a blit), is only capable of blitting images of 6xn pixels, this means if you have a blit that is larger than 6 pixels wide, (lets assume divisible by 6 to make it easier to understand), then you need multiple stripes for the complete blit.
e.g. A blit of 18x24 would need 3 stripes of 6x24. It's more complex than just this, but the only other real limitation is that each of these stripes must fit in a 256 byte page, i.e. the stripe cannot cross a page boundary or exceed 256 bytes in size. So lets say you had a really tall blit of say 18*60, this would once again be split into 3 stripes of 6*60, but then these stripes would also then be split into chunks as 6*60 > 256.
The starting address, ending address and direction of allocation are chosen based on whether you developing for a 32K RAM system, 64K RAM system and how where and how big your code and data is.
e.g. On a 32K RAM system with a very simple demo that has no code, no data and no strings in the 0x08A0 to 0xFFFF offscreen segments, then your blit config line could look like this:
Code: Select all
_blitStripeChunks_ 15, &h08A0, &h7FFF, ascending
15*6 = 90, an offscreen segment has a maximum of 96 bytes, why can't we do 16? Because we need an end of stripe byte, (negative of the stripe height, see
https://github.com/kervinck/gigatron-ro ... ctions.txt "Blit sprite in screen memory").
e.g. On a 64K RAM system your blit config line could look like this:
Code: Select all
_blitStripeChunks_ 42, &h08000, &hFFFF, ascending
42*6 = 252, the extra 32k of RAM has full 256 byte pages that are free for data.
TDLR: for your example I would try something like this:
Code: Select all
_blitStripeChunks_ 34, &h08000, &hFFFF, ascending
You must also make sure that your LOAD BLIT commands happen first, before all other memory allocation, e.g. DIM's, DEF's, other types of LOAD's, etc; this way the memory manager will allocate memory for your blits first and fit all the other smaller allocations around them. If you do the LOAD BLIT's last, then memory can become too fragmented, (even though there potentially plenty of it left)
wbushby wrote: ↑24 Apr 2023, 13:05
Before I put in the above code I was getting error:
Memory::printFreeRamList() : Expected 30158 : Found 30158
Keywords::LOAD() : 'Main:125' : syntax error, use 'LOAD BLIT, <filename>, <id>, <optional flip>, <optional overlap>' : LOAD BLIT, Images/Alice1.tga, ALICE1, NoFlip
Keywords::loadBlit() : 'Main:125' : getting blit memory failed for stripe 3 : LOAD BLIT, Images/Alice1.tga, ALICE1, NoFlip
I have several BLITs of size 36 X 34 and 42 X 34 pixels
You are most likely getting this error because the LOAD BLIT commands are not the first statements in your code, they should come before any real code is executed, i.e. as discussed previously you really can't have LOAD commands in sub routines using GOSUB or PROC. So right at the top of your file directly after your pragmas is where you should do your LOAD's, I usually put them in a module file and then load that module directly after the pragmas.
P.S. If you have more than a total of 48 blits, then you need to use the _maxNumBlits_ pragma to specify how many, the blit routines use multiple LUT's and they need to be allocated correctly, e.g. PucMon does this:
Code: Select all
'use this after _runtimeStart_ to specify maximum number of blits if you have more than 48
_maxNumBlits_ 62