1

Hello,

I would like to make a fading on all my palettes. I can do this manually by creating my own palettes but it would be much better dynamics.

I know it is in 0x400000. For the first sprite, we read in 0x400020. 0x400020 is the transparent color. So we must modify 0x400021 to 0x400039 (for Sprite 1).

But I can't read each value to change to black/white. I always have 0 with 0x400020 and crash at 0x400021.

I tried with volMEMWORD, I use Datlib in C.
Should we send the color values such as 0x5148 at the address 0x400021?

Thanks for reading.

2

WORD access is even addresses only.

0x400020 isn't palette for sprite #1, sprite #1 uses whichever you want him to use for each tile.

3

Yes, I saying Sprite 1 for the example. But I know the palette number (and the number of palette for a sprite ) and the sprite list. And of course, the first 16 palettes may be used by fix layer.

I use the wiki page to find adresses : https://wiki.neogeodev.org/index.php?title=Palettes

But What do you say with "WORD access is even addresses" ? How do i do for read value (in C or ASM) ?

4

You can't read/write a word from/to an address that is odd.
avatar
Zeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo

5

Ok. I look this in the Doc of hpman.
"68000 requires even addresses when operating on word and dword (long) data. Read/write operation at an odd address for a word/long will crash the CPU."

So if i try to read odd adresses (impair like 0x400021), I have a Crash. So I'll only use 0x400020, 0x400022, 0x400024, ... Right


I try that and I have make a little nice rainbow animation with putting random value in all palettes. I use something like that : volMEMWORD(0x400200)=0x8000;
I'm more smarter now. wink Thanks you very much for all the information.

But now I need to read value for changing color. Can you explain me how to do that ? I try with fixprintf for printing my value without success naturally.
Like 0x8080, to 0x8040, to for finish 0x8000. Down every 3 last values to 0 for black color.

6

I read value with volMEMBYTE(0x400210). I have 176 in result. As byte we can read value from 0 to 255.

So I add the odd value. I have had a good masters.

volMEMBYTE(0x400210) = 255; //even
volMEMBYTE(0x400211) = 255; //odd

This give me a white palette.
The same with =0 give me black palette.

Now I need to harmonize the even and odd.

How can I lower my even and odd value ?
For example I have 128 in even and 62 in odd. I can't just reduce my values by one till 0. I have to do an operation.

7

=> wiki.neogeodev Do not worry about D, R0, G0 & B0 at the moment

it's incomplete but easier to understand, most fading-routines on neogeo works like this and uses only 12bit instead of 15 and darkbit because it's easier and also faster

try to master this:

1st step: you need 3 values 0..15 (0x00 ... 0x0F), use words(!)
RED 0x000F
GREEN 0x000F
BLUE 0x000F

2nd step: shift this values
RED 0x000F << 8 = 0x0F00
GREEN 0x000F << 4 = 0x00F0
BLUE 0x000F = 0x000F

3rd step: join values (simple add should work) into one word
RED + GREEN + BLUE => 0RGB => 0x0FFF

4th step: write this as word to get a white color

other colors:
0x0F00 = RED
0x0FF0 = YELLOW
0x00F0 = GREEN
0x0F0F = PURPLE
0x039F = LIGHT BLUE
0x000F = BLUE
0x00FF = CYAN

Got it?

=> read a word from palette => split this into 3 values (or 4 when using darkbit) => work with this => join => write

it's also possible to use bytes but in my opinion it's easier to work with words!

8

Thanks. New day, new work.

I use word now, and I can change to black.
I will do other tests to better understand the palette fading.