Jump to content
IGNORED

Need help to align cart directory entries to physical blocks


Nop90

Recommended Posts

I'm using karri's template and his version of CC65. To optimize the speed of Starblader I reduced every sprite loaded from cart to no more than 2KB (2 blocks of the cart).

 

Is there a trick to force the rom builder to align every sprite at the start of Block, padding with 0s the unused space of the cart? This will optimize the loading speed.

 

The game is already running fine without this optimization, but I wasn't able to figure it out how it could be done and I'm curious.  

Link to comment
Share on other sites

I believe you need to define all your segments with two new keywords like this:

 

TILES: file = %O, define = yes, start = $0200, size = 2048, fill = yes, fillval = $ff;

 

This should force the linker to add $ff bytes up to the end of the block.

 

Edit: The align=256 keyword tells the linker that the RAM starting point has to be aligned. So it does not help you much in this case.

  • Like 1
Link to comment
Share on other sites

2 minutes ago, 42bs said:

fillval = $ff is important, flashing "ff" is quicker than flashing "00" ;-)

Yeah.. I just realized that in my programmer code I forgot to test for $ff. Stupid me. I just added it and the result is amazing. You can actually skip all the $ff bytes while programming.

Link to comment
Share on other sites

If someone needs to address the same thing, this is what I did:

 

first applied the padding 

 

 

    SP00: start = __MEMORY_SP__, size = __SP_SIZE__, define = yes, file = %O, fill = yes, fillval = $ff;

 

than changed the size of all the sprite files on cart  from:

 

_SP00_FILENR=_BGC_FILENR+1
entry bgCoff, bgClen, sp00off, sp00block, sp00len,__SP00_RODATA_SIZE__, __SP00_START__

 

to

 

_SP00_FILENR=_BGC_FILENR+1
entry bgCoff, bgClen, sp00off, sp00block, sp00len,__BLOCKSIZE__, __SP00_START__

 

and  last thing defined a CARTPADDING file just before the sprites

 

    CARTPADDING: start = __MEMORY_SP__, size = __SP_SIZE__, define = yes, file = %O;

 

 

_CARTPADDING_FILENR=_BGC_FILENR+1
entry bgCoff, bgClen, cpoff, cpblock, cplen,__CARTPADDING_RODATA_SIZE__, __CARTPADDING_START__

_SP00_FILENR=_CARTPADDING_FILENR+1
entry cpoff, cplen, sp00off, sp00block, sp00len,__BLOCKSIZE__, __SP00_START__

 

the content of this cart file is a sequence of $FF created with a simple c file in a dummy rodata segment 

 

// padding.c

// Dummy data
// to fill some of the cart space with $FF (that is a value faster to write ona  cart flash chip) to align the sprites data to the start of a new block
// the length of the array can be determined in 2 pass, compile the ROM, check the cart directory, calculate the padding size, change the value and compile again
const char padding[604] = {255};

 

don't know if this is the best solution, but it works and is fast

 

Edited by Nop90
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...