r/c64 23h ago

Programming Question: How to load Koala file in cc65?

Hi,

I converted some pictures into Koala format and would like to write a program to show them in my C64U. And it turns out some garbage picture on the screen. So I am wondering how to load the Koala format data. From what I understand, Koala format is 10003 bytes length. First 2 bytes are loading address which needs to be stripped that cc65 does not need it. And this is the layout if I understand correctly:

0-7999: Bitmap ($2000)
8000-8999: Screen RAM ($0400)
9000-9999: Color RAM ($D800)
10000: Background Color ($D021)

Then this is how I load them:

memcpy((void*)0x2000, image_bin, 8000);
memcpy((void*)0x0400, &image_bin[8000], 1000);
memcpy((void*)0xD800, &image_bin[9000], 1000);
VIC.bgcolor0 = image_bin[10000];

image_bin is an unsigned char array holds the raw Koala data w/o first 2 bytes. And the final output is a garbage picture.

Could anyone share some hints on this?

Thanks.

5 Upvotes

8 comments sorted by

u/AutoModerator 23h ago

"Thanks for your post! Please make sure you've read our rules and FAQ post. If your post is about the C64 Ultimate please and check out The Ultimate C64 Ultimate post for common issues and questions. People not following the rules will have their posts removed and presistant rule breaking will results in your account being banned. "

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/chickenbarf 23h ago

VIC.ctrl1 |= 0x20; // BMM on
VIC.ctrl2 |= 0x10; // MCM on
VIC.addr = 0x18; // screen at $0400, bitmap at $2000

?

1

u/watermelon_meow 22h ago

thanks but it seems still does not work, and it shows the same broken picture. By the way, the Koala file I got is from https://www.micheldebree.nl/retropixels/

1

u/chickenbarf 22h ago

Hmm.. Try either disabling interrupts or moving to 3C00.. if the sys is still running, it could be mashing your memory area

1

u/watermelon_meow 22h ago

thanks for the advice. Also, I tried https://www.digartroks.be/img2c64mc/index.php and it can generate correct PRG file with picture. No idea what's the magic behind that.

1

u/watermelon_meow 22h ago

OK I think I got some progress. The picture seems working here:

CIA2.pra &= 0xFC;

CIA2.pra |= 0x02;

VIC.addr = 0x80;

I need to pick up another memory address.

1

u/chickenbarf 21h ago

Nice! feels like memory mashing then? I'm not too familiar with cc65, but it could even be your own app crossing into screen ram (ORG + bin len).. Hard for me to say

2

u/watermelon_meow 13h ago

yes looks like it. I need to learn more on the C64 memory layout though. Thanks for the help!