[cc65] mallocing an aligned buffer

Date view Thread view Subject view

From: Shawn Jefferson (sjefferson_at_sd62.bc.ca)
Date: 2003-01-23 00:50:34


I got some help mallocing a 4k aligned buffer some time back and this works great.  I now have another problem that I wonder if someone could help me solve.

Due to limitations of the hardware in the Atari computer, the ANTIC chip can only address via DMA a 4k buffer.  With some modes you need to reload the DMA address base register (LMS) to get antic over its 4k address wall.  So the problem then becomes if I want to create an 7680 byte buffer it cannot be aligned on a 4k boundary since when ANTIC gets to the end of the 4k chunk it ends up being in the middle of the screen.  Each screen line being 40 bytes in length. 4096 / 40 = 102.4  You can see that at the 102nd line ANTIC cannot continue loading data properly since its address offset counter "rolls over" back to 0.

What I need is an algorithim that will malloc a buffer that takes these contraints into account.  I need the END of the buffer to line up with the 4k boundary, not the START. Ideally it would put 4080 bytes before the 4k boundary and 3600 bytes after, but it could really be setup in any way that makes sure a screen line ends on the 4k boundary and the next screen "chunk" doesn't cross the next 4k boundary.  I'm trying to implement something that is fairly generic and can alloc various size buffers but always deals with the 4k boundary properly.

Sheesh, did that make sense?  I hope so.

¯
Shawn Jefferson



----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-01-23 00:51:02 CET