Jump to content
IGNORED

Lynx Color Palette


Ninjabba

Recommended Posts

I'm quite new on lynx programming, but am getting a hang of it. As far as I am now, I try to have an animated sprite walking around against a background sprite. All is working fancy as long as I use the same color palette for both the sprite and the background. But I rather have different color palettes for the sprites, so when I try it like the code below, the whole screen flashes from one palette to the other. Now I have 2 questions:

 

Is it possible to use 2 completely different palettes for drawing on the same screen?

void DrawScene(void) 
{
 _SetRGB(pal_dungeon);
 DrawSprite(Dungeon);
 _SetRGB(pal_character);
 DrawSprite(Character);
}

 

Or should I pick out the color palette in such a way that the character palette is a subset of the dungeon palette? By doing this, I can use other colors for other dungeons, but the total colors on the screen will be 16.. I hope someone reads this :)

Edited by Ninjabba
Link to comment
Share on other sites

If I'm right you can just have 16 colors onscreen (well there are some tricks to increase that number, probably by swapping rapidly the palettes, but I digress)

So you must fit all your drawings in the same 16 colors palette, or multiple 8, 4, 2 colors palettes (but 16 colors max).

 

What's wrong with your code is :

Let's set the 16 colors and draw the background -> ok

Let's set another 16 colors (the background is now ugly) and draw the character.

 

Hope I didn't tell too much lies.

Link to comment
Share on other sites

I'm quite new on lynx programming, but am getting a hang of it. As far as I am now, I try to have an animated sprite walking around against a background sprite. All is working fancy as long as I use the same color palette for both the sprite and the background. But I rather have different color palettes for the sprites, so when I try it like the code below, the whole screen flashes from one palette to the other. Now I have 2 questions:

 

Is it possible to use 2 completely different palettes for drawing on the same screen?

void DrawScene(void) 
{
 _SetRGB(pal_dungeon);
 DrawSprite(Dungeon);
 _SetRGB(pal_character);
 DrawSprite(Character);
}

 

Or should I pick out the color palette in such a way that the character palette is a subset of the dungeon palette? By doing this, I can use other colors for other dungeons, but the total colors on the screen will be 16.. I hope someone reads this :)

 

This must look awful on the Lynx screen.

 

The first command _SetRGB will change the palette immediately.

 

The second command DrawSprite is hopefully drawing on a hidden draw page and not on the screen directly.

 

What this means is that the main screen will flicker every time you do a draw.

 

The correct way to do this is:

 

DrawSprite

DrawSprite

DrawSprite

wait for VBL

SetRGB

SwapBuffers

 

Now the screen is steady during all DrawSprites as they happen in background. The palette change and exchanging the draw page with the view page occur at a time when nothing happens on the screen.

 

I would create all my graphics on a giant bitmap and pick out the animated characters by sprpck. In this way you can use any colors while you design your backgrounds and characters. This also forces the same palette to all graphics on a single level. Then you can ask Gimp to convert the image to 16 bit indexed. At the conversion time you can also fine-tune the colors etc. Having the original data in RGB format makes life much easier. Don't overwrite the original design with the 16 bit indexed bitmap version.

 

Having a full color version of the design can also help in doing the box later. On the cover you can put full color versions instead of 16-color stuff.

 

If the sprites are very large like in Zaku you may need to use 3-bit, 2-bit or 1-bit sprites instead for your animations.

 

The sprpck has command line options for picking out a sprite from a bitmap.

 

-o020000

 

Offset 020 000 will start the sprite from this coordinate.

 

-S032032

 

Set size of the sprite in pixels

 

-r010004

 

Split picture into 10 by 4 tiles. This is good for animations your sprites will be named like;:

A000000

A000001

A000002

A000003

A001000

...

 

Combining these command line options makes it simple to extract the sprites out of the bitmap.

 

Keep the name of the animation as one character (like A). As the old tools you are using are very picky about the lenght of the file names.

 

--

Karri

Link to comment
Share on other sites

This must look awful on the Lynx screen.

It does look awful on the screen. I was testing if it was possible to swap palettes this way, but no its not. And I always wondered why I couldn't see those 4096 colors at the same time :D

 

I guess I'll do some clever color picking; 2 to 4 for the character sprite so I can use the remaining 12 to 14 colors for the background. That way I hope to use the full color spectrum. Thanks for quick replies!

Edited by Ninjabba
Link to comment
Share on other sites

This must look awful on the Lynx screen.

It does look awful on the screen. I was testing if it was possible to swap palettes this way, but no its not. And I always wondered why I couldn't see those 4096 colors at the same time :D

 

I guess I'll do some clever color picking; 2 to 4 for the character sprite so I can use the remaining 12 to 14 colors for the background. That way I hope to use the full color spectrum. Thanks for quick replies!

 

Why cannot you use the same colors for the character and the background? I see no point in a separate colormap for the character sprite. If you use palette indices in your character sprite you can point the colors to any color in the background image.

 

If you have only 2 bit sprite your colormap would be:

 

0x01 0x23

 

The first index has to be 0 as it means transparency.

 

The other could be anything.

 

Like

 

0x0a 0x59

 

This would use colors A, 5 and 9 from the palette for the character sprite.

 

--

Karri

Link to comment
Share on other sites

Why cannot you use the same colors for the character and the background? I see no point in a separate colormap for the character sprite. If you use palette indices in your character sprite you can point the colors to any color in the background image.

 

That's what I'm doing now. But since I do want to be able to use the full color palette of the lynx (all 4096) to create colorful backgrounds, I have multiple palettes in which each of them shares the same, say 3 the three you mentioned, colors for the character sprite and the rest is for the backgrounds.

 

So when switching backgrounds (and palettes), the character sprite keeps the same colors, but for each background I can pick out another 13 colors.

 

I was hoping however, if it would be possible to have 16 colors defined for my character sprites, and another 16 different colors for the background. But I guess its not possible.

Link to comment
Share on other sites

I was hoping however, if it would be possible to have 16 colors defined for my character sprites, and another 16 different colors for the background. But I guess its not possible.

 

You are correct. That is not possible.

 

I wish you luck on your quest for nice graphics.

 

--

Karri

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...