thobbsinteractive / magic-carpet-2-hd

Recode Binary code of game Magic Carpet2 to C/C++ language(remake MC2 for any platform)
GNU General Public License v3.0
30 stars 4 forks source link

When the Player is hit, the framerate drops #286

Closed thobbsinteractive closed 2 months ago

thobbsinteractive commented 2 months ago

This seems to happen as the red flash is applied to the colour pallet. There are many possible causes (thread locking), but the pallet shift should not be one of them. It would be interesting to see what is taking the processing time.

thobbsinteractive commented 2 months ago

When the player is hit the pallet is adjusted using PaletteChanges_47760. This calls sub_41A90_VGA_Palette_install(...) that calls VGA_Set_Palette(...)and eventually SDL_SetPaletteColors(m_gamePalletisedSurface->format->palette, m_currentPalletColours, 0, 256); Looking at the diagnostic window, this looks fine. The code is running very fast (1ms or less).

thobbsinteractive commented 2 months ago

If could be the fade back to normal that is costing time. Calling: sub_90B27_VGA_pal_fadein_fadeout() seems to be costing 15ms

thobbsinteractive commented 2 months ago

Okay, so there is a manual delay of 10ms in fix_sub_9A0FC_wait_to_screen_beam();. Before I remove this I must be sure of its impact