I'm working on a new game and decided to use a MMC3 with nesdoug.h for the first time.
I followed his amazing tutorial: https://nesdoug.com/2019/11/11/23-advanced-mapper-mmc3/ and it worked for me just fine.
I had to make some adjustments as in my case I have to do chr switching outside irq loop.
Basically, I'm working on 2 player fighting game and the upper half of sprite chrs is for player 1 and the lower half for player 2.
This way I can switch tiles for both players independently. This works fine and dandy - for most of the time.
Here is sample code I use for displaying consecutive metatiles for kick animation:
Code: Select all
const unsigned char *get_kick_animation() {
switch (get_animation_frame_from_timer()) {
case 0:
switch_player_sprites_to(SPRITES_00_QUADRANT_2, currentPlayer);
return get_sided_array(DudeSomersaultsBackward0SprFlipped, DudeSomersaultsBackward0Spr);
case 1:
switch_player_sprites_to(SPRITES_00_QUADRANT_2, currentPlayer);
return get_sided_array(DudeKicksSprFlipped, DudeKicksSpr);
case 2:
switch_player_sprites_to(SPRITES_01_QUADRANT_0, currentPlayer);
return get_sided_array(DudeStandsOnLeftLegSprFlipped, DudeStandsOnLeftLegSpr);
}
}
Code: Select all
void switch_player_sprites_to(unsigned char spriteFileBank, unsigned char currentPlayer) {
if (currentPlayer) {
set_chr_mode_1(spriteFileBank);
} else {
set_chr_mode_0(spriteFileBank);
}
}
The problem appears on the transition from 1 -> 2, as there I'm also switching the tileset.
There is very short 1 frame long glitch. Tileset is already correctly showing switch_player_sprites_to(SPRITES_01_QUADRANT_0, currentPlayer), but the sprites are still taken from get_sided_array(DudeKicksSprFlipped, DudeKicksSpr);. So I get tileset from state 2 ( correct ) but with the old metasprite from state 1.
I'm quite puzzled by this and checked my code couple times - the logic looks legit. I do not understand how despite switching metasprite and chr bank together in a single frame only chr switch happens and metasprite change is delayed to the next frame.
Has anyone had this problem?