1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-18 10:38:31 +02:00
VVVVVV/desktop_version/src
Misa 192b2f2dba Don't re-draw credits scroll background every frame
While I was working on my over-30-FPS patch, I found out that the tower
background in the credits scroll was being completely re-drawn every
single frame, which was a bit wasteful and expensive. It's also harder
to interpolate for my over-30-FPS patch. I'm guessing this constant
re-draw was done because the math to get the surface scroll properly
working is a bit subtle, but I've figured the precise math out!

The first changes of this patch is just removing the unconditional
`map.tdrawback = true;`, and having to set `map.scrolldir` everywhere to
get the credits scrolling in the right direction but make sure the title
screen doesn't start scrolling like a descending tower, too.

After that, the first problem is that it looks like the ACTION press to
speed up the credits scrolling doesn't speed up the background, too. No
problem, just shove a `!game.press_action` check in
`gamecompletelogic()`.

However, this introduces a mini-problem, which is that NOW when you hold
down ACTION, the background appears to be slowly getting out of sync
with the credits text by a one-pixel-per-second difference. This is
actually due to the fact that, as a result of me adding the conditional,
`map.bscroll` is no longer always unconditionally getting set to 1,
while `game.creditposition` IS always unconditionally getting
decremented by 1. And when you hold down ACTION, `game.creditposition`
gets decremented by 6.

Thus, I need to set `map.bscroll` when holding down ACTION to be 7,
which is 6 plus 1.

Then we have another problem, which is that the incoming textures desync
when you press ACTION, and when you release ACTION. They desync by
precisely 6 pixels, which should be a familiar number. I (eventually)
tracked this down to `map.bypos` being updated at the same time
`map.bscroll` is, even though `map.bypos` should be updated a frame
later AFTER updating `map.bscroll`.

So I had to change the `map.bypos` update in `gamecompleteinput()` and
`gamecompletelogic()` to be `map.bypos += map.bscroll;` and then place
it before any `map.bscroll` update, thus ensuring that `map.bscroll`
updates exactly one frame before `map.ypos` does. I had to move the
`map.bypos += map.bscroll;` to be in `gamecompleteinput()`, because
`gamecompleteinput()` comes first before `gamecompletelogic()` in the
`main.cpp` game loop, otherwise the `map.bypos` update won't be delayed
by one frame for when you press ACTION to make it go faster, and thus
cause a desync when you press ACTION.

Oh and then after that, I had to make the descending tower background
draw a THIRD row of incoming tiles, otherwise you could see some black
flickering at the bottom of the screen when you held down ACTION.

All of this took me way too long to figure out, but now the credits
scroll works perfectly while being more optimized.
2020-04-30 05:04:13 -04:00
..
BinaryBlob.cpp Fix warnings raised by GCC 8 2020-01-11 08:53:32 -05:00
BinaryBlob.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
BlockV.cpp Remove blockclass::clear(), simplify blockclass initializations 2020-04-03 23:28:47 -04:00
BlockV.h Remove blockclass::clear(), simplify blockclass initializations 2020-04-03 23:28:47 -04:00
editor.cpp Merge drawtowerbackgroundsolo() into drawtowerbackground() 2020-04-29 18:08:13 -04:00
editor.h Remove now-useless function editorclass::countstuff() 2020-04-09 19:20:31 -04:00
Ent.cpp Remove entclass::clear(), simplify entclass initializations 2020-04-03 23:28:47 -04:00
Ent.h Remove entclass::clear(), simplify entclass initializations 2020-04-03 23:28:47 -04:00
Entity.cpp Remove unused function entityclass::cblocks() 2020-04-14 22:54:16 -04:00
Entity.h Remove unused function entityclass::cblocks() 2020-04-14 22:54:16 -04:00
Enums.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
FileSystemUtils.cpp Fix deletequick() and deletetele() not deleting their files 2020-04-26 17:20:16 -04:00
FileSystemUtils.h Fix deletequick() and deletetele() not deleting their files 2020-04-26 17:20:16 -04:00
Finalclass.cpp Declare obj.flags a vector of bools instead of ints 2020-04-09 19:20:31 -04:00
Finalclass.h Remove global args from main game loadlevel() functions 2020-04-03 10:40:50 -04:00
Game.cpp Fix exiting No Death Mode being one menu too far back 2020-04-27 15:41:07 -04:00
Game.h Fix exiting No Death Mode being one menu too far back 2020-04-27 15:41:07 -04:00
GOGNetwork.c Add support for multiple Network backends, stub in GOGNetwork 2020-01-13 11:15:22 -05:00
Graphics.cpp Don't re-draw credits scroll background every frame 2020-04-30 05:04:13 -04:00
Graphics.h Merge drawtowerbackgroundsolo() into drawtowerbackground() 2020-04-29 18:08:13 -04:00
GraphicsResources.cpp Allow using help/graphics/music/game/key/map/obj everywhere 2020-01-29 07:58:23 -05:00
GraphicsResources.h Allow using help/graphics/music/game/key/map/obj everywhere 2020-01-29 07:58:23 -05:00
GraphicsUtil.cpp Fix mixed indentation in GraphicsUtil.cpp 2020-04-03 10:40:50 -04:00
GraphicsUtil.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Input.cpp Don't re-draw credits scroll background every frame 2020-04-30 05:04:13 -04:00
Input.h Remove global args from Input.cpp 2020-04-03 10:40:50 -04:00
KeyPoll.cpp Make the toggle fullscreen conditional more readable 2020-03-12 21:20:25 -04:00
KeyPoll.h Add being able to mute the music by pressing N 2020-04-19 20:51:35 -04:00
Labclass.cpp Declare obj.flags a vector of bools instead of ints 2020-04-09 19:20:31 -04:00
Labclass.h Remove global args from main game loadlevel() functions 2020-04-03 10:40:50 -04:00
Logic.cpp Don't re-draw credits scroll background every frame 2020-04-30 05:04:13 -04:00
Logic.h Merge towerlogic() into gamelogic() 2020-04-26 19:07:40 -04:00
main.cpp De-duplicate screen effects timer decrementing 2020-04-27 15:07:58 -04:00
MakeAndPlay.h Re-comment out #define MAKEANDPLAY 2020-02-09 10:42:03 -05:00
Map.cpp Fix compile failure if both MAKEANDPLAY and NO_CUSTOM_LEVELS are defined 2020-04-17 15:41:48 -04:00
Map.h Remove map.numshinytrinkets 2020-04-14 22:54:16 -04:00
Maths.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Music.cpp Remove duplicate function musicclass::stopmusic() 2020-04-03 19:19:45 -04:00
Music.h Remove duplicate function musicclass::stopmusic() 2020-04-03 19:19:45 -04:00
Network.c int32_t > int 2020-01-13 11:27:16 -05:00
Network.h Add support for multiple Network backends, stub in GOGNetwork 2020-01-13 11:15:22 -05:00
Otherlevel.cpp Declare obj.flags a vector of bools instead of ints 2020-04-09 19:20:31 -04:00
Otherlevel.h Remove global args from main game loadlevel() functions 2020-04-03 10:40:50 -04:00
preloader.cpp Only render screen effects on the title screen and in-game 2020-04-27 15:07:58 -04:00
preloader.h Remove global args from preloader.cpp 2020-04-03 10:40:50 -04:00
Render.cpp Render screen effects in maprender() 2020-04-29 19:35:00 -04:00
Render.h Merge towerrender() into gamerender() 2020-04-26 19:07:40 -04:00
Screen.cpp Remove unused variable Screen::glScreen 2020-04-03 10:40:50 -04:00
Screen.h Remove unused variable Screen::glScreen 2020-04-03 10:40:50 -04:00
Script.cpp Merge drawtowerbackgroundsolo() into drawtowerbackground() 2020-04-29 18:08:13 -04:00
Script.h Refactor scriptclass txt to not use a separate length-tracker 2020-04-03 23:28:47 -04:00
Scripts.cpp Fix mixed indentation in Scripts.cpp 2020-04-03 10:40:50 -04:00
SoundSystem.cpp add myself to the contributors file, fix formatting 2020-01-10 15:07:29 -07:00
SoundSystem.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Spacestation2.cpp Don't use obj.changeflag() to set flags 2020-04-09 19:20:31 -04:00
Spacestation2.h Remove global args from main game loadlevel() functions 2020-04-03 10:40:50 -04:00
SteamNetwork.c Fix build on DragonFlyBSD 2020-04-23 23:35:33 -04:00
TerminalScripts.cpp Remove usages of second argument of playef() script command 2020-04-03 10:40:50 -04:00
Textbox.cpp Remove textboxclass's firstcreate and clear, simplify initializations 2020-04-03 23:28:47 -04:00
Textbox.h Remove textboxclass's firstcreate and clear, simplify initializations 2020-04-03 23:28:47 -04:00
Tower.cpp Initialize level data with 0s in M&P 2020-02-08 23:54:20 -05:00
Tower.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
UtilityClass.cpp Add is_positive_num() to UtilityClass.cpp 2020-04-17 19:14:44 -04:00
UtilityClass.h Add is_positive_num() to UtilityClass.cpp 2020-04-17 19:14:44 -04:00
WarpClass.cpp Declare obj.flags a vector of bools instead of ints 2020-04-09 19:20:31 -04:00
WarpClass.h Remove global args from main game loadlevel() functions 2020-04-03 10:40:50 -04:00