Multiple quicksaves
Re: SDLPoP; David's open-source port of PoP
Yes. I think we're close to a good solution. A slight modification of your suggestion should work. The key (no pun intended), I think, is to keep track of the F6 and F9 key states ourselves. That is, not just if F6 or F9 are currently down, but whether or not numeric 1-9 have been pressed since they were down. In pseudocode, for quick saving:
Default state is A.
On F6 down, go to state B.
During state B if:
- numeric 1-9, quick save to selected numeric slot, AND go to state C.
- F6 release, quick save to slot 1, AND go to state A.
During state C if:
- numeric 1-9, just quick save to selected numeric slot.
- F6 release, just go to state A.
This would allow regular use of F6 to quick save (to slot 1), and F6+1-9 to quick save to specific slots. It would even allow the user to keep F6 down and save to more than one slot before releasing F6.
Default state is A.
On F6 down, go to state B.
During state B if:
- numeric 1-9, quick save to selected numeric slot, AND go to state C.
- F6 release, quick save to slot 1, AND go to state A.
During state C if:
- numeric 1-9, just quick save to selected numeric slot.
- F6 release, just go to state A.
This would allow regular use of F6 to quick save (to slot 1), and F6+1-9 to quick save to specific slots. It would even allow the user to keep F6 down and save to more than one slot before releasing F6.
Re: SDLPoP; David's open-source port of PoP
Yes, what you suggested in your pseudo code is valid and will work perfectly with saving. The problem will occur while loading. Suppose I want to load from slot 3, holding F9 and pressing 3 will create a stutter since until we press 3, the holding action of F9 key sets the game in continuous quickload loop.Norbert wrote: ↑January 10th, 2022, 3:41 pm Yes. I think we're close to a good solution. A slight modification of your suggestion should work. The key (no pun intended), I think, is to keep track of the F6 and F9 key states ourselves. That is, not just if F6 or F9 are currently down, but whether or not numeric 1-9 have been pressed since they were down. In pseudocode, for quick saving:
Default state is A.
On F6 down, go to state B.
During state B if:
- numeric 1-9, quick save to selected numeric slot, AND go to state C.
- F6 release, quick save to slot 1, AND go to state A.
During state C if:
- numeric 1-9, just quick save to selected numeric slot.
- F6 release, just go to state A.
This would allow regular use of F6 to quick save (to slot 1), and F6+1-9 to quick save to specific slots. It would even allow the user to keep F6 down and save to more than one slot before releasing F6.
Should I add a 3 second "cooldown" timer between consecutive quickloads? This will prevent the user from quickloading the game if it has been previously quickloaded within 3 seconds, but as an advantage, the game will not be stuck in quickloading loop while holding down F9 to select a num key.
What if life is a video game and Déjà Vu are just checkpoints?
Re: SDLPoP; David's open-source port of PoP
As I see it, loading would work just as well as saving.
Pseudocode, for quick loading:
Default state is A.
On F9 down, go to state B.
During state B if:
- numeric 1-9, quick load from selected numeric slot, AND go to state C.
- F9 release, quick load from slot 1, AND go to state A.
During state C if:
- numeric 1-9, just quick load from selected numeric slot.
- F9 release, just go to state A.
If you're up for implementing this but have difficulty doing so, it's probably relatively easy for David.
(Or maybe Falcury, dmitry, atrue. Personally, I don't know the SDLPoP code well enough.)
Pseudocode, for quick loading:
Default state is A.
On F9 down, go to state B.
During state B if:
- numeric 1-9, quick load from selected numeric slot, AND go to state C.
- F9 release, quick load from slot 1, AND go to state A.
During state C if:
- numeric 1-9, just quick load from selected numeric slot.
- F9 release, just go to state A.
If you're up for implementing this but have difficulty doing so, it's probably relatively easy for David.
(Or maybe Falcury, dmitry, atrue. Personally, I don't know the SDLPoP code well enough.)
Re: SDLPoP; David's open-source port of PoP
I am almost done implementing the latest solution which we discussed. The only problem is I am not able to detect simultaneous key presses. It was not difficult when the simultaneous key presses were Ctrl, Alt or Shift; since their key_modifier values were already defined by David here. Could you, or Falcury, Dmitry or others guide me in this?
I think 5 game slots should be enough considering currently single save file is working in most of the scenarios. Are 10 slots really required just because num keys are available?
What if life is a video game and Déjà Vu are just checkpoints?
Re: SDLPoP; David's open-source port of PoP
For now, I have stuck to the "Press NumKeys to select slots" version of multiple quicksaves. You can check that out here.
What if life is a video game and Déjà Vu are just checkpoints?
Re: SDLPoP; David's open-source port of PoP
And my pseudocode requires the latter, "to keep track of the F6 and F9 key states ourselves".
Re: SDLPoP; David's open-source port of PoP
Thanks David, I used this and uploaded it here. However I am facing some issues:
1. The code generates warning that array subscript is above array bounds. The code works fine with all the features when pressed "Compile and Run" but it crashes if you try to open it directly from executable.
2. The black screen blink during the "room changes", removes whatever text is getting displayed at bottom. Hence, it is a little distracting while loading and saving.
Yes, I think I may have finished implementing that. Everything is working as it should except the issues mentioned above. Practically, if you compile and run the game, no problems arise in the slot functionality.
As default, I have given user 2 seconds to press num keys with F6 or F9. By then, if no num key is pressed by the user, the game will save in the last saved/load slot. That way, the code will be almost backwards compatible. Same goes with quickload and quicksave in the menu.
What if life is a video game and Déjà Vu are just checkpoints?
Re: SDLPoP; David's open-source port of PoP
I don't get such a warning, and I don't get a crash either.
Which statement gets marked with the warning?
It's cleared by this line in load_lev_spr() and quick_load():
Code: Select all
draw_rect(&screen_rect, 0);
If he has fewer HP after quickload then his previous HP will be kept on the screen.
It would be better to display the message again where you wrote this:
Code: Select all
/* User already gets notified game is loaded before function gets called */
Re: SDLPoP; David's open-source port of PoP
I get warnings here, here, here, here and here. The warning is:
Code: Select all
[Warning] array subscript is above array bounds [-Warray-bounds]
Sure, since there were multiple quicksave texts depending on how and where it has been quicksaved (or quickloaded), I had removed text from there. I will display the messages again there.
What if life is a video game and Déjà Vu are just checkpoints?
Re: SDLPoP; David's open-source port of PoP
"key_states[SDL_KEYDOWN]" is the problem.
key_states[] should only be indexed by a scancode, but SDL_KEYDOWN is not a scancode but an event type.
Instead of this:
Code: Select all
if (key_states[SDL_SCANCODE_F6] != key_states[SDL_KEYDOWN]) {
Code: Select all
if (key_states[SDL_SCANCODE_F6] != 0) {
Code: Select all
if (key_states[SDL_SCANCODE_F6] == 1) {
Another solution (which I just tried), is to exclude the status bar from clearing the screen.
That is, replace the following line in quick_load() and load_lev_spr():
Code: Select all
draw_rect(&screen_rect, 0);
Code: Select all
clear_screen_except_status();
Code: Select all
void clear_screen_except_status() {
draw_rect(&rect_top, 0);
rect_type rect_hp_left = {
.top = rect_top.bottom,
.left = screen_rect.left,
.bottom = screen_rect.bottom,
.right = rect_bottom_text.left,
};
draw_rect(&rect_hp_left, 0);
rect_type rect_hp_right = {
.top = rect_top.bottom,
.left = rect_bottom_text.right,
.bottom = screen_rect.bottom,
.right = screen_rect.right,
};
draw_rect(&rect_hp_right, 0);
}
Re: SDLPoP; David's open-source port of PoP
The code you suggested solved the problem. I have added it to the file and I have also fixed the key_states warning as you suggested. Created a pull request.David wrote: ↑February 13th, 2022, 10:37 am "key_states[SDL_KEYDOWN]" is the problem.
key_states[] should only be indexed by a scancode, but SDL_KEYDOWN is not a scancode but an event type.
Instead of this:write this:Code: Select all
if (key_states[SDL_SCANCODE_F6] != key_states[SDL_KEYDOWN]) {
or this:Code: Select all
if (key_states[SDL_SCANCODE_F6] != 0) {
Similarly for the F9 checks.Code: Select all
if (key_states[SDL_SCANCODE_F6] == 1) {
What if life is a video game and Déjà Vu are just checkpoints?
Re: SDLPoP; David's open-source port of PoP
I have merged it.
https://github.com/NagyD/SDLPoP/pull/27 ... 6189679501
EDIT: Moved the posts into a new topic.
Re: SDLPoP; David's open-source port of PoP
Thank You David. Should this feature be implemented in the master branch SDLPoP so that it gets released in the next update or should it remain separate?David wrote: ↑March 5th, 2022, 7:32 pmI have merged it.
https://github.com/NagyD/SDLPoP/pull/27 ... 6189679501
EDIT: Moved the posts into a new topic.
What if life is a video game and Déjà Vu are just checkpoints?