commit 341d6befd9adc57e0a0ad27d51757fe7cb19435a
Author: jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Sat Feb 13 11:51:59 2021 -0700
Commit: jtothebell <j.to.the.bell@gmail.com>
CommitDate: Sat Feb 13 11:51:59 2021 -0700
Ignore draw state for pause menu
---
source/vm.cpp | 19 +++++++++++++++++++
source/vm.h | 1 +
2 files changed, 20 insertions(+)
diff --git a/source/vm.cpp b/source/vm.cpp
index 120283d..24e4929 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -51,6 +51,8 @@ Vm::Vm(
_cleanupDeps = true;
}
_memory = memory;
+
+ memset(_drawStateCopy, 0, sizeof(drawState_t));
if (graphics == nullptr) {
graphics = new Graphics(get_font_data(), _memory);
@@ -335,6 +337,23 @@ void Vm::LoadCart(std::string filename){
void Vm::togglePauseMenu(){
_pauseMenu = !_pauseMenu;
+
+ if (_pauseMenu){
+ //save old draw state
+ //0x5f00-0x5f3f - 64 bytes
+ memcpy(_drawStateCopy, &_memory->drawState, 64);
+
+ _graphics->pal();
+ _graphics->fillp(0);
+ _graphics->clip();
+ _graphics->camera();
+ _graphics->color();
+ }
+ else{
+ //restore old draw state
+ memcpy(&_memory->drawState, _drawStateCopy, 64);
+ }
+
}
diff --git a/source/vm.h b/source/vm.h
index 9c96dee..c72c718 100644
--- a/source/vm.h
+++ b/source/vm.h
@@ -21,6 +21,7 @@ using namespace z8;
class Vm {
Host* _host;
PicoRam* _memory;
+ uint8_t _drawStateCopy[64];
Graphics* _graphics;
Audio* _audio;