main: use sprite priority
This moves pokemon sprites in front of NBG1 and other sprites behind NBG0.
This commit is contained in:
parent
3d8110ca1c
commit
e88135d4e3
23
main.cpp
23
main.cpp
@ -135,7 +135,6 @@ void render_sprite(const uint32_t ix, const enum spritesheet_t::spritesheet spri
|
||||
const screen_t& screen, const offset_t& offset,
|
||||
int32_t y_offset)
|
||||
{
|
||||
constexpr uint32_t color_address = 16;
|
||||
const uint32_t sprite_offset = facing_offset(facing) + animation_frame;
|
||||
const uint32_t base_pattern = state.draw.base_pattern.spritesheets[sprite_id];
|
||||
const uint32_t character_address = ((base_pattern + sprite_offset) * 128) / 8;
|
||||
@ -146,10 +145,8 @@ void render_sprite(const uint32_t ix, const enum spritesheet_t::spritesheet spri
|
||||
// both transparency and end codes are enabled, it seems there are only 14
|
||||
// usable colors in the 4-bit color mode.
|
||||
vdp1.vram.cmd[ix].PMOD = PMOD__ECD | PMOD__COLOR_MODE__COLOR_BANK_16;
|
||||
// It appears Kronos does not correctly calculate the color address in the
|
||||
// VDP1 debugger. Kronos will report FFFC when the actual color table address
|
||||
// in this example is 7FFE0.
|
||||
vdp1.vram.cmd[ix].COLR = color_address; // non-palettized (rgb15) color data
|
||||
vdp1.vram.cmd[ix].COLR = COLR__COLOR_BANK__4BPP__PALETTE(1)
|
||||
| COLR__COLOR_BANK__TYPE0__PR(1);
|
||||
vdp1.vram.cmd[ix].SRCA = character_address;
|
||||
vdp1.vram.cmd[ix].SIZE = SIZE__X(16) | SIZE__Y(16);
|
||||
vdp1.vram.cmd[ix].XA = (cell_offset::x * 8) + screen.x * 16 - offset.x;
|
||||
@ -170,7 +167,6 @@ uint32_t pokemon_sprite_dimension(const uint32_t size)
|
||||
void render_pokemon(const uint32_t ix, const enum pokemon_t::pokemon pokemon_id,
|
||||
const screen_cell_t& screen_cell)
|
||||
{
|
||||
constexpr uint32_t color_address = 0;
|
||||
const uint32_t base_pattern = state.draw.base_pattern.pokemon[pokemon_id].front;
|
||||
const uint32_t character_address = (base_pattern * 16) / 8;
|
||||
const uint32_t dimension = pokemon_sprite_dimension(pokemon[pokemon_id].pic.front.size);
|
||||
@ -181,10 +177,8 @@ void render_pokemon(const uint32_t ix, const enum pokemon_t::pokemon pokemon_id,
|
||||
// both transparency and end codes are enabled, it seems there are only 14
|
||||
// usable colors in the 4-bit color mode.
|
||||
vdp1.vram.cmd[ix].PMOD = PMOD__ECD | PMOD__COLOR_MODE__COLOR_BANK_16;
|
||||
// It appears Kronos does not correctly calculate the color address in the
|
||||
// VDP1 debugger. Kronos will report FFFC when the actual color table address
|
||||
// in this example is 7FFE0.
|
||||
vdp1.vram.cmd[ix].COLR = color_address; // non-palettized (rgb15) color data
|
||||
vdp1.vram.cmd[ix].COLR = COLR__COLOR_BANK__4BPP__PALETTE(0)
|
||||
| COLR__COLOR_BANK__TYPE0__PR(0);
|
||||
vdp1.vram.cmd[ix].SRCA = character_address;
|
||||
vdp1.vram.cmd[ix].SIZE = SIZE__X(dimension) | SIZE__Y(dimension);
|
||||
vdp1.vram.cmd[ix].XA = (cell_offset::x * 8) + screen_cell.x * 8;
|
||||
@ -599,8 +593,13 @@ void init_vdp1()
|
||||
|
||||
void init_vdp2()
|
||||
{
|
||||
vdp2.reg.PRISA = PRISA__S0PRIN(7); // Sprite register 0 PRIority Number
|
||||
vdp2.reg.PRINA = PRINA__N0PRIN(5)
|
||||
// sprite type
|
||||
vdp2.reg.SPCTL = SPCTL__SPTYPE(0) // 2-bit priority
|
||||
| SPCTL__SPCLMD; // enable RGB data from VDP1
|
||||
|
||||
vdp2.reg.PRISA = PRISA__S0PRIN(7) // Sprite register 0 PRIority Number
|
||||
| PRISA__S1PRIN(5); // Sprite register 1 PRIority Number
|
||||
vdp2.reg.PRINA = PRINA__N0PRIN(4)
|
||||
| PRINA__N1PRIN(6);
|
||||
|
||||
// DISP: Please make sure to change this bit from 0 to 1 during V blank.
|
||||
|
Loading…
x
Reference in New Issue
Block a user