不加载PAL0中的图像调色板 -> VDP_setPalette(PAL0, sprite_sonic.palette->data)

huangapple go评论59阅读模式
英文:

doesn't load image palette in PAL0 -> VDP_setPalette(PAL0,sprite_sonic.palette->data)

问题

决定研究一下SGDK。我想要将索尼克的精灵添加到屏幕上,但出了些问题。索尼克的精灵加载了,但没有使用他的调色板。在加载时,使用了PAL0调色板,其中默认颜色保持不变(尽管我有点改变了它们)。
这里是一个有问题的照片 -> sonic
这张照片显示索尼克是黑白的,而PAL0没有改变。
以下是代码:

#include <genesis.h>
#include "sprites.h"

Sprite* my_sprite_sonic;

int main()
{
    VDP_setBackgroundColor(40);
    VDP_setScreenWidth320();

    SPR_init();

    VDP_setPalette(PAL0, sprite_sonic.palette->data);
    
    my_sprite_sonic = SPR_addSprite(&sprite_sonic, 0, 0, TILE_ATTR(PAL0, TRUE, FALSE, FALSE));

    while(TRUE)
    {
        SPR_update();
        SYS_doVBlankProcess();
    }

    return 0;
}

如果我做错了什么,提前道歉。我是SGDK的新手。我搜索了这个问题,但找不到答案。

英文:

Decided to look into the SGDK. I wanted to add a Sonic's sprite to the screen, but something went wrong. Sonic's sprite loads but not in his palette. When loading, the PAL0 palette is used, in which the default colors remain (although I kind of changed them).
Here is a photo with a problem -> sonic.
This photo shows that Sonic is Black and White, and that PAL0 has not changed.
Here is the code:

#include &lt;genesis.h&gt;
#include &quot;sprites.h&quot;

Sprite* my_sprite_sonic;

int main()
{
    VDP_setBackgroundColor(40);
    VDP_setScreenWidth320();

    SPR_init();

    VDP_setPalette(PAL0,sprite_sonic.palette-&gt;data);
    
    my_sprite_sonic = SPR_addSprite(&amp;sprite_sonic, 0, 0, TILE_ATTR(PAL0, TRUE, FALSE, FALSE));

    while(TRUE)
    {
        SPR_update();
        SYS_doVBlankProcess();
    }

    return 0;
}

If I'm being stupid, I apologize in advance. New to SGDK. I googled the question but couldn't find anything.

答案1

得分: 0

VDP_setPalette(PAL0,sprite_sonic.palette->data); 替换为 PAL_setPalette(PAL0, sonic_sprite.palette->data, DMA);

英文:

Instead of
VDP_setPalette(PAL0,sprite_sonic.palette-&gt;data);
you need to use
PAL_setPalette(PAL0, sonic_sprite.palette-&gt;data, DMA);

huangapple
  • 本文由 发表于 2023年7月11日 06:48:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76657764.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定