-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMainMenu.cpp
More file actions
1265 lines (1184 loc) · 46.1 KB
/
MainMenu.cpp
File metadata and controls
1265 lines (1184 loc) · 46.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "MainMenu.h"
#include "common.h"
#include "imgui.h"
#include "imgui_impl_sdl2.h"
#include "imgui_impl_opengl3.h"
#include "imgui_memory_editor.h"
#include "OpenGLHelper.h"
#include "MemoryManager.h"
#include "A2VideoManager.h"
#include "CycleCounter.h"
#include "SoundManager.h"
#include "MockingboardManager.h"
#include "LogTextManager.h"
#include "PostProcessor.h"
#include "EventRecorder.h"
#include "SDHRManager.h"
#include "SDHRNetworking.h"
#include "extras/MemoryLoader.h"
#include "extras/ImGuiFileDialog.h"
#include <iostream>
#include <vector>
#include <unordered_map>
// In main.cpp
extern uint32_t Main_GetFPSLimit();
extern void Main_SetFPSLimit(uint32_t fps);
extern void Main_ResetFPSCalculations();
extern SDL_DisplayMode Main_GetFullScreenMode();
extern void Main_SetFullScreenMode(SDL_DisplayMode mode);
extern bool Main_IsLinuxConsole();
extern bool Main_IsFullScreen();
extern void Main_SetFullScreen(bool bIsFullscreen);
extern SwapInterval_e Main_GetVsync();
extern void Main_SetVsync(SwapInterval_e _vsync);
extern void Main_DisplaySplashScreen();
extern bool Main_GetbUsePNGForScreenshots();
extern void Main_SetbUsePNGForScreenshots(bool bUsePNG);
extern void Main_GetBGColor(float outColor[4]);
extern void Main_SetBGColor(const float newColor[4]);
extern void Main_ResetA2SS();
extern bool Main_IsFPSOverlay();
extern void Main_SetFPSOverlay(bool isFPSOverlay);
extern SDL_Window* Main_GetSDLWindow();
extern void Main_RequestAppQuit();
#define IM_MIN(A, B) (((A) < (B)) ? (A) : (B))
#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
#define IM_CLAMP(V, MN, MX) ((V) < (MN) ? (MN) : (V) > (MX) ? (MX) : (V))
class MainMenu::Gui {
public:
// A single help topic
struct HelpTopic {
std::string subject;
std::string content;
};
ImFont* fontDefault = nullptr;
ImFont* fontMedium = nullptr;
ImFont* fontLarge = nullptr;
ImFont* fontHelp = nullptr;
std::vector<SDL_DisplayMode> v_displayModes;
int iCurrentDisplayIndex = -1;
int fMouseSpeed = 1.0f;
int iFPSLimiter = 0;
int iWindowWidth=1200;
int iWindowHeight=1000;
bool bShowAboutWindow = false;
bool bShowHelpWindow = false;
int iHelpCurrentSubject = 0;
std::vector<HelpTopic> vHelpTopics;
std::unordered_map<std::string, std::string> helpVariables;
int iTextureSlotIdx = 0;
bool bShowTextureWindow = false;
bool bShowA2VideoWindow = false;
bool bShowPPWindow = false;
bool bShowSSWindow = false;
bool bShowEventRecorderWindow = false;
bool bShowLoadFileWindow = false;
bool bShowImGuiMetricsWindow = false;
bool bShowMemoryHeatMap = false;
bool bShowUSBImGuiWindow = false;
bool bShowSHRPaletteWindow = false;
bool bSampleRunKarateka = false;
MemoryEditor mem_edit_a2e;
MemoryEditor mem_edit_sdhr_upload;
Gui() {}
// Returns a glyph range that includes Latin, punctuation, bullets, arrows, etc.
const ImWchar* GetExtendedGlyphRanges()
{
static const ImWchar ranges[] = {
0x0020, 0x007F, // Basic Latin
0x0080, 0x00FF, // Latin-1 Supplement
0x0100, 0x017F, // Latin Extended-A
0x0180, 0x024F, // Latin Extended-B
0x2000, 0x206F, // General Punctuation (•, ‑, “ ”, etc.)
0x2190, 0x21FF, // Arrows
0x25A0, 0x25FF, // Geometric Shapes (■, ▲, ●, etc.)
0x2700, 0x27BF, // Dingbats (✂, ✉, ✔, etc.)
0 // terminator
};
return ranges;
}
// Simple placeholder replacer for things like ${var}
std::string ProcessContent(const std::string& in,
const std::unordered_map<std::string,std::string>& vars)
{
std::string out;
size_t pos = 0;
while (true) {
auto start = in.find("${", pos);
if (start == std::string::npos) {
out += in.substr(pos);
break;
}
out += in.substr(pos, start - pos);
auto end = in.find('}', start + 2);
if (end == std::string::npos) {
// no closing }, emit rest verbatim
out += in.substr(start);
break;
}
std::string key = in.substr(start + 2, end - (start + 2));
auto it = vars.find(key);
if (it != vars.end())
out += it->second;
else
out += "${" + key + "}"; // leave unknown token intact
pos = end + 1;
}
return out;
}
// Load topics from an INI‑style file without any trimming:
// A line `[Foo]` starts a new topic named "Foo"
// All other lines (including blank ones) go into that topic verbatim.
void LoadHelpFromIni(const std::string& filename)
{
helpVariables.clear();
vHelpTopics.clear();
std::ifstream in(filename, std::ios::binary);
if (!in.is_open()) {
std::string _errstr = "Failed to open help file: " + filename + "\n";
vHelpTopics.push_back({"Error", _errstr.c_str()});
return;
}
std::string line;
HelpTopic* currentTopic = nullptr;
bool inVariables = false;
bool firstLine = true;
while (std::getline(in, line))
{
// Optional: strip UTF-8 BOM on very first line
if (firstLine) {
firstLine = false;
if (line.size() >= 3 &&
static_cast<unsigned char>(line[0]) == 0xEF &&
static_cast<unsigned char>(line[1]) == 0xBB &&
static_cast<unsigned char>(line[2]) == 0xBF)
{
line.erase(0, 3);
}
}
// Section header?
if (!line.empty() && line.front() == '[' && line.back() == ']') {
std::string section = line.substr(1, line.size() - 2);
if (section == "Variables") {
inVariables = true;
currentTopic = nullptr;
}
else {
inVariables = false;
vHelpTopics.push_back({});
currentTopic = &vHelpTopics.back();
currentTopic->subject = section;
currentTopic->content.clear();
}
}
else if (inVariables) {
// Expect "key = value"
auto eq = line.find('=');
if (eq != std::string::npos) {
std::string key = line.substr(0, eq);
std::string val = line.substr(eq + 1);
// no trimming
helpVariables[key] = val;
}
}
else if (currentTopic) {
// Append verbatim (including blank lines)
currentTopic->content += line;
currentTopic->content += '\n';
}
// else: ignore lines before first non‑Variables section
}
if (vHelpTopics.empty()) {
vHelpTopics.push_back({"Error","Could not load any help topics!\n"});
}
}
};
MainMenu::MainMenu(SDL_GLContext gl_context, SDL_Window* window)
: gl_context_(gl_context), window_(window), pGui(new Gui()) {
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
// Setup Dear ImGui style
ImGui::StyleColorsDark();
// ImGui::StyleColorsLight();
// Setup Platform/Renderer backends
ImGui_ImplSDL2_InitForOpenGL(window_, gl_context_);
ImGui_ImplOpenGL3_Init(OpenGLHelper::GetInstance()->get_glsl_version()->c_str());
// Add the fonts
pGui->fontDefault = io.Fonts->AddFontDefault();
pGui->fontMedium = io.Fonts->AddFontFromFileTTF("./assets/ProggyTiny.ttf", 14.0f);
pGui->fontLarge = io.Fonts->AddFontFromFileTTF("./assets/BerkeliumIIHGR.ttf", 16.f);
pGui->fontHelp= io.Fonts->AddFontFromFileTTF("./assets/Monaco.ttf", 18.0f, nullptr, pGui->GetExtendedGlyphRanges());
// Never draw the cursor. Let SDL draw the cursor. In windowed mode, the cursor
// may always be drawn anyway, and having ImGUI draw it will duplicate it.
// main.cpp will handle hiding the cursor after some inactivity in fullscreen mode.
// (disabled now that the mouse can be locked to the Apple)
io.MouseDrawCursor = false;
pGui->mem_edit_a2e.Open = false;
pGui->mem_edit_a2e.HighlightFn = Memory_HighlightWriteFunction;
pGui->mem_edit_sdhr_upload.Open = false;
// --- Load help topics from INI ---
pGui->LoadHelpFromIni("assets/help.ini");
}
MainMenu::~MainMenu() {
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext();
}
bool MainMenu::HandleEvent(SDL_Event& event) {
bool eventIsHandledInImGui = false;
ImGui_ImplSDL2_ProcessEvent(&event);
ImGuiIO& io = ImGui::GetIO(); (void)io;
switch (event.type) {
case SDL_MOUSEWHEEL:
if (io.WantCaptureMouse) {
eventIsHandledInImGui = true;
// TODO: Handle mouse
}
break;
case SDL_KEYDOWN:
{
switch (event.key.keysym.sym)
{
case SDLK_F2:
pGui->bShowA2VideoWindow = !pGui->bShowA2VideoWindow;
eventIsHandledInImGui = true;
break;
case SDLK_F3:
pGui->bShowPPWindow = !pGui->bShowPPWindow;
eventIsHandledInImGui = true;
break;
case SDLK_F9:
pGui->bShowSSWindow = !pGui->bShowSSWindow;
eventIsHandledInImGui = true;
break;
default:
break;
};
}
break;
default:
break;
} // switch event.type
return eventIsHandledInImGui;
}
void MainMenu::Render() {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame(window_);
ImGui::NewFrame();
auto a2VideoManager = A2VideoManager::GetInstance();
ImFont* _menuFont;
ImFont* _itemFont;
int screen_width, screen_height;
SDL_GetWindowSize(window_, &screen_width, &screen_height);
if (screen_width < 1200)
{
_menuFont = pGui->fontDefault;
_itemFont = pGui->fontDefault;
} else {
_menuFont = pGui->fontLarge;
_itemFont = pGui->fontMedium;
}
if (ImGui::BeginMainMenuBar()) {
ImGui::PushFont(_menuFont);
if (ImGui::BeginMenu("SDD")) {
ImGui::PushFont(_itemFont);
ShowSDDMenu();
ImGui::PopFont();
ImGui::EndMenu();
}
ImGui::Spacing();
if (ImGui::BeginMenu("Motherboard")) {
ImGui::PushFont(_itemFont);
ShowMotherboardMenu();
ImGui::PopFont();
ImGui::EndMenu();
}
ImGui::Spacing();
if (ImGui::BeginMenu("Video")) {
ImGui::PushFont(_itemFont);
ShowVideoMenu();
ImGui::PopFont();
ImGui::EndMenu();
}
ImGui::Spacing();
if (ImGui::BeginMenu("Sound")) {
ImGui::PushFont(_itemFont);
ShowSoundMenu();
ImGui::PopFont();
ImGui::EndMenu();
}
ImGui::Spacing();
if (ImGui::BeginMenu("Developer")) {
ImGui::PushFont(_itemFont);
ShowDeveloperMenu();
ImGui::PopFont();
ImGui::EndMenu();
}
ImGui::PopFont();
ImGui::Text(" ");
ImGui::PushFont(pGui->fontDefault);
ImGui::Text("Screen: %dx%d (%dx%d) - ",
a2VideoManager->ScreenSize().x, a2VideoManager->ScreenSize().y,
screen_width, screen_height
);
ImGuiIO& io = ImGui::GetIO(); (void)io;
// If the frame rate is halved, io.Framerate would display twice the framerate
// because we're flipping backbuffers half as much. So we need to divide by 4
// to get the real frame rate
auto realFrameRate = (PostProcessor::GetInstance()->IsFrameRateHalved() ? io.Framerate / 2.0f : io.Framerate);
ImGui::Text("FrameID: %d, Avg %.3f ms/f (%.1f FPS)",
A2VideoManager::GetInstance()->GetVRAMReadId(),
1000.0f / realFrameRate, realFrameRate);
ImGui::PopFont();
ImGui::EndMainMenuBar();
// Show about window
if (pGui->bShowAboutWindow) {
ImGui::PushFont(_menuFont);
ImGui::Begin("About", &pGui->bShowAboutWindow, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::Text("Super Duper Display");
ImGui::Separator();
ImGui::Text("Version: %s", SDD_VERSION);
ImGui::Text("Software: Henri \"Rikkles\" Asseily");
ImGui::Text("Design & Firmware: John \"Elltwo\" Flanagan");
ImGui::Text("Appletini logo by Rikkles+Fatdog");
ImGui::Separator();
ImGui::TextWrapped("SuperDuperDisplay is a hybrid emulation frontend for Appletini, the Apple 2 Bus Card.");
ImGui::Separator();
// Retrieve OpenGL version info
const GLubyte* renderer = glGetString(GL_RENDERER);
const GLubyte* version = glGetString(GL_VERSION);
GLint major, minor;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
GLint accelerated = 0;
SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &accelerated);
ImGui::Text("Renderer: %s", renderer);
ImGui::Text("OpenGL version: %s", version);
ImGui::Text("Major version: %d", major);
ImGui::Text("Minor version: %d", minor);
ImGui::Text("Hardware Acceleration: %s", accelerated ? "Enabled" : "Disabled");
ImGui::Separator();
ImGui::TextColored(ImColor(220, 150, 0), "Press F1 to show/hide the UI");
ImGui::PopFont();
ImGui::End();
}
// Show help window
if (pGui->bShowHelpWindow) {
pGui->helpVariables["app_version"] = std::string(SDD_VERSION);
ImGui::SetNextWindowSizeConstraints(ImVec2(500, 350), ImVec2(FLT_MAX, FLT_MAX));
if (ImGui::Begin("Help", &pGui->bShowHelpWindow)) {
if (ImGui::GetWindowSize().x < 1000)
ImGui::PushFont(pGui->fontDefault);
else
ImGui::PushFont(pGui->fontHelp);
auto topics = pGui->vHelpTopics;
// Left pane: list of subjects
ImGui::BeginChild("##Subjects", ImVec2(250, 0), ImGuiChildFlags_Border | ImGuiChildFlags_ResizeX);
for (int i = 0; i < (int)topics.size(); i++)
{
if (ImGui::Selectable(topics[i].subject.c_str(), i == pGui->iHelpCurrentSubject))
pGui->iHelpCurrentSubject = i;
}
ImGui::EndChild();
ImGui::SameLine();
// Right pane: content for selected subject
// Right pane: do substitution on-the-fly
ImGui::BeginChild("##Content", ImVec2(0,0), ImGuiChildFlags_None);
{
const auto& raw = pGui->vHelpTopics[pGui->iHelpCurrentSubject].content;
std::string filled = pGui->ProcessContent(raw, pGui->helpVariables);
ImGui::TextWrapped("%s", filled.c_str());
}
ImGui::EndChild();
ImGui::PopFont();
}
ImGui::End(); // Help window
}
// Show the Apple //e memory
if (pGui->mem_edit_a2e.Open)
{
pGui->mem_edit_a2e.DrawWindow("Memory Editor: Apple 2 Memory (0000-C000 x2)", MemoryManager::GetInstance()->GetApple2MemPtr(), 2 * _A2_MEMORY_SHADOW_END);
}
if (pGui->bShowMemoryHeatMap)
{
ImGui::SetNextWindowSize(ImVec2(624,862));
if (ImGui::Begin("Memory Heat Map", &pGui->bShowMemoryHeatMap, ImGuiWindowFlags_NoResize)) {
auto drawList = ImGui::GetWindowDrawList();
ImVec2 oPos = ImGui::GetCursorScreenPos(); // origin, i.e. "layouting position" where items are submitted
ImColor yellowColor(1.0f, 1.0f, 0.0f, 1.0f);
ImColor memLinesColor(1.0f, 1.0f, 0.0f, 0.5f);
float mmultw = 1.f; // width of each pixel represneting a byte
float mmulth = 3.f; // height of each pixel representing a byte
float memDrawW = 256 * mmultw;
float memDrawH = 256 * mmulth;
// Draw the mem rectangles
float memY = 30.f; // Y top margin for mem rectangles
float labelsW = 30.f; // X left margin that will have the labels
ImVec2 mainRectMin = ImVec2(oPos.x + labelsW, oPos.y + memY);
ImVec2 mainRectMax = ImVec2(mainRectMin.x + memDrawW + 2.f, mainRectMin.y + memDrawH + 2.f);
drawList->AddRect(mainRectMin, mainRectMax, yellowColor);
ImVec2 auxRectMin = ImVec2(mainRectMax.x + labelsW, mainRectMin.y);
ImVec2 auxRectMax = ImVec2(mainRectMax.x + labelsW + memDrawW + 2.f, mainRectMax.y);
drawList->AddRect(auxRectMin, auxRectMax, yellowColor);
// Draw the mem rectangles titles
ImGui::PushFont(pGui->fontLarge);
ImVec2 mainLabelPos = ImVec2(CalcCenteredTextX("MAIN MEMORY", mainRectMin.x, mainRectMax.x), mainRectMin.y - 20.f);
drawList->AddText(mainLabelPos, yellowColor, "MAIN MEMORY");
ImVec2 auxLabelPos = ImVec2(CalcCenteredTextX("AUX MEMORY", auxRectMin.x, auxRectMax.x), auxRectMin.y - 20.f);
drawList->AddText(auxLabelPos, yellowColor, "AUX MEMORY");
ImGui::PopFont();
// Draw the heat map
auto currT = CycleCounter::GetInstance()->GetCycleTimestamp();
auto memMgr = MemoryManager::GetInstance();
for (auto j=0; j < 2; ++j) {
for (auto i=0; i < _A2_MEMORY_SHADOW_END; ++i) {
auto tdiff = currT - memMgr->GetMemWriteTimestamp(i + j*_A2_MEMORY_SHADOW_END);
if (tdiff < ((size_t)pGui->mem_edit_a2e.OptHighlightFnSeconds * 1'000'000)) {
auto writeColor = ImColor(1.f - ((float)tdiff / (pGui->mem_edit_a2e.OptHighlightFnSeconds * 1'000'000)), 0.f, 0.f, 1.f);
auto rectMin = (j == 0 ? mainRectMin : auxRectMin);
auto pMin = ImVec2(rectMin.x + 1 + (i % 0x100) * mmultw, rectMin.y + 1 + (i / 0x100) * mmulth);
auto pMax = ImVec2(pMin.x + mmultw, pMin.y + (mmulth - 1.f));
drawList->AddRectFilled(pMin, pMax, writeColor);
}
}
}
// Labels on the left and memory chunk lines
const int labelsHex[] = { 0x0, 0x400, 0x800, 0xC00, 0x2000, 0x4000, 0x6000, 0x8000, 0xA000, 0xC000, 0xD000, 0xE000 };
const size_t ctLabels = sizeof(labelsHex) / sizeof(labelsHex[0]);
char bufLabels[ctLabels];
for (size_t i = 0; i < ctLabels; ++i)
{
snprintf(bufLabels, sizeof(bufLabels), "%04X", labelsHex[i]);
float yDelta = (float)labelsHex[i] * mmulth / 0x100;
drawList->AddText(ImVec2(oPos.x, mainRectMin.y + yDelta), yellowColor, bufLabels);
drawList->AddLine(ImVec2(mainRectMin.x - 20.f, mainRectMin.y + yDelta), ImVec2(auxRectMax.x, mainRectMin.y + yDelta), memLinesColor);
}
}
ImGui::End();
}
// Show the textures starting at _TEXUNIT_IMAGE_ASSETS_START
if (pGui->bShowTextureWindow)
{
ImGui::SetNextWindowSizeConstraints(ImVec2(300, 250), ImVec2(FLT_MAX, FLT_MAX));
ImGui::Begin("Texture Viewer", &pGui->bShowTextureWindow);
ImVec2 avail_size = ImGui::GetContentRegionAvail();
ImGui::SliderInt("Texture Slot Number", &pGui->iTextureSlotIdx, 0, _SDHR_MAX_TEXTURES + 5, "slot %d", ImGuiSliderFlags_AlwaysClamp);
GLint _w, _h;
auto glhelper = OpenGLHelper::GetInstance();
if (pGui->iTextureSlotIdx < _SDHR_MAX_TEXTURES)
{
glBindTexture(GL_TEXTURE_2D, glhelper->get_texture_id_at_slot(pGui->iTextureSlotIdx));
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &_w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &_h);
ImGui::Text("Texture ID: %d (%d x %d)", (int)glhelper->get_texture_id_at_slot(pGui->iTextureSlotIdx), _w, _h);
ImGui::Image(reinterpret_cast<void*>(glhelper->get_texture_id_at_slot(pGui->iTextureSlotIdx)),
ImVec2(avail_size.x, avail_size.y - 30), ImVec2(0, 0), ImVec2(1, 1));
}
else if (pGui->iTextureSlotIdx == _SDHR_MAX_TEXTURES)
{
glBindTexture(GL_TEXTURE_2D, a2VideoManager->GetOutputTextureId());
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &_w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &_h);
ImGui::Text("Output Texture ID: %d (%d x %d)", (int)a2VideoManager->GetOutputTextureId(), _w, _h);
ImGui::Image(reinterpret_cast<void*>(a2VideoManager->GetOutputTextureId()), avail_size, ImVec2(0, 0), ImVec2(1, 1));
}
else if (pGui->iTextureSlotIdx == _SDHR_MAX_TEXTURES + 1)
{
glActiveTexture(_TEXUNIT_PP_BEZEL);
GLint target_tex_id = 0;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &target_tex_id);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, target_tex_id);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &_w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &_h);
ImGui::Text("_TEXUNIT_PP_BEZEL: %d (%d x %d)", target_tex_id, _w, _h);
ImGui::Image(reinterpret_cast<void*>(target_tex_id), avail_size, ImVec2(0, 0), ImVec2(1, 1));
}
else if (pGui->iTextureSlotIdx == _SDHR_MAX_TEXTURES + 2)
{
glActiveTexture(_TEXUNIT_PP_BEZEL_GLASS);
GLint target_tex_id = 0;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &target_tex_id);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, target_tex_id);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &_w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &_h);
ImGui::Text("_TEXUNIT_PP_BEZEL_GLASS: %d (%d x %d)", target_tex_id, _w, _h);
ImGui::Image(reinterpret_cast<void*>(target_tex_id), avail_size, ImVec2(0, 0), ImVec2(1, 1));
}
else if (pGui->iTextureSlotIdx == _SDHR_MAX_TEXTURES + 3)
{
glActiveTexture(_TEXUNIT_PP_PREVIOUS);
GLint target_tex_id = 0;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &target_tex_id);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, target_tex_id);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &_w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &_h);
ImGui::Text("_TEXUNIT_PP_PREVIOUS: %d (%d x %d)", target_tex_id, _w, _h);
ImGui::Image(reinterpret_cast<void*>(target_tex_id), avail_size, ImVec2(0, 0), ImVec2(1, 1));
}
else if (pGui->iTextureSlotIdx == _SDHR_MAX_TEXTURES + 4)
{
glActiveTexture(_TEXUNIT_POSTPROCESS);
GLint target_tex_id = 0;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &target_tex_id);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, target_tex_id);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &_w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &_h);
ImGui::Text("_TEXUNIT_POSTPROCESS: %d (%d x %d)", target_tex_id, _w, _h);
ImGui::Image(reinterpret_cast<void*>(target_tex_id), avail_size, ImVec2(0, 0), ImVec2(1, 1));
}
else if (pGui->iTextureSlotIdx == _SDHR_MAX_TEXTURES + 5)
{
glActiveTexture(_TEXUNIT_PRE_NTSC);
GLint target_tex_id = 0;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &target_tex_id);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, target_tex_id);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &_w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &_h);
ImGui::Text("_TEXUNIT_PRE_NTSC: %d (%d x %d)", target_tex_id, _w, _h);
ImGui::Image(reinterpret_cast<void*>(target_tex_id), avail_size, ImVec2(0, 0), ImVec2(1, 1));
}
glActiveTexture(GL_TEXTURE0);
ImGui::End();
}
if (pGui->bShowA2VideoWindow)
A2VideoManager::GetInstance()->DisplayImGuiWindow(&pGui->bShowA2VideoWindow);
if (pGui->bShowLoadFileWindow)
A2VideoManager::GetInstance()->DisplayImGuiLoadFileWindow(&pGui->bShowLoadFileWindow);
if (pGui->bShowPPWindow)
PostProcessor::GetInstance()->RenderImGuiWindow(&pGui->bShowPPWindow);
if (pGui->bShowEventRecorderWindow)
EventRecorder::GetInstance()->DisplayImGuiWindow(&pGui->bShowEventRecorderWindow);
if (pGui->bShowSSWindow) {
ImGui::SetNextWindowSizeConstraints(ImVec2(170, 410), ImVec2(FLT_MAX, FLT_MAX));
ImGui::Begin("Soft Switches", &pGui->bShowSSWindow);
auto memManager = MemoryManager::GetInstance();
bool ssValue0 = memManager->IsSoftSwitch(A2SS_80STORE);
if (ImGui::Checkbox("A2SS_80STORE", &ssValue0)) {
memManager->SetSoftSwitch(A2SS_80STORE, ssValue0);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue1 = memManager->IsSoftSwitch(A2SS_RAMRD);
if (ImGui::Checkbox("A2SS_RAMRD", &ssValue1)) {
memManager->SetSoftSwitch(A2SS_RAMRD, ssValue1);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue2 = memManager->IsSoftSwitch(A2SS_RAMWRT);
if (ImGui::Checkbox("A2SS_RAMWRT", &ssValue2)) {
memManager->SetSoftSwitch(A2SS_RAMWRT, ssValue2);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue3 = memManager->IsSoftSwitch(A2SS_80COL);
if (ImGui::Checkbox("A2SS_80COL", &ssValue3)) {
memManager->SetSoftSwitch(A2SS_80COL, ssValue3);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue4 = memManager->IsSoftSwitch(A2SS_ALTCHARSET);
if (ImGui::Checkbox("A2SS_ALTCHARSET", &ssValue4)) {
memManager->SetSoftSwitch(A2SS_ALTCHARSET, ssValue4);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue5 = memManager->IsSoftSwitch(A2SS_INTCXROM);
if (ImGui::Checkbox("A2SS_INTCXROM", &ssValue5)) {
memManager->SetSoftSwitch(A2SS_INTCXROM, ssValue5);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue6 = memManager->IsSoftSwitch(A2SS_SLOTC3ROM);
if (ImGui::Checkbox("A2SS_SLOTC3ROM", &ssValue6)) {
memManager->SetSoftSwitch(A2SS_SLOTC3ROM, ssValue6);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue7 = memManager->IsSoftSwitch(A2SS_TEXT);
if (ImGui::Checkbox("A2SS_TEXT", &ssValue7)) {
memManager->SetSoftSwitch(A2SS_TEXT, ssValue7);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue8 = memManager->IsSoftSwitch(A2SS_MIXED);
if (ImGui::Checkbox("A2SS_MIXED", &ssValue8)) {
memManager->SetSoftSwitch(A2SS_MIXED, ssValue8);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue9 = memManager->IsSoftSwitch(A2SS_PAGE2);
if (ImGui::Checkbox("A2SS_PAGE2", &ssValue9)) {
memManager->SetSoftSwitch(A2SS_PAGE2, ssValue9);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue10 = memManager->IsSoftSwitch(A2SS_HIRES);
if (ImGui::Checkbox("A2SS_HIRES", &ssValue10)) {
memManager->SetSoftSwitch(A2SS_HIRES, ssValue10);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue11 = memManager->IsSoftSwitch(A2SS_DHGR);
if (ImGui::Checkbox("A2SS_DHGR", &ssValue11)) {
memManager->SetSoftSwitch(A2SS_DHGR, ssValue11);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue12 = memManager->IsSoftSwitch(A2SS_DHGRMONO);
if (ImGui::Checkbox("A2SS_DHGRMONO", &ssValue12)) {
memManager->SetSoftSwitch(A2SS_DHGRMONO, ssValue12);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue13 = memManager->IsSoftSwitch(A2SS_SHR);
if (ImGui::Checkbox("A2SS_SHR", &ssValue13)) {
memManager->SetSoftSwitch(A2SS_SHR, ssValue13);
a2VideoManager->ForceBeamFullScreenRender();
}
bool ssValue14 = memManager->IsSoftSwitch(A2SS_GREYSCALE);
if (ImGui::Checkbox("A2SS_GREYSCALE", &ssValue14)) {
memManager->SetSoftSwitch(A2SS_GREYSCALE, ssValue14);
a2VideoManager->ForceBeamFullScreenRender();
}
ImGui::Separator();
if (ImGui::Button("Reset Soft Switches")) {
Main_ResetA2SS();
a2VideoManager->ForceBeamFullScreenRender();
}
ImGui::End();
}
if (pGui->bShowSHRPaletteWindow) {
const int rows = 16;
const int cols = 16;
float cellSize = 20.0f; // will change based on window size
ImGui::SetNextWindowSizeConstraints(
ImVec2(rows * cellSize + 20, cols * cellSize + 35),
ImVec2(FLT_MAX, FLT_MAX)
);
ImGui::Begin("SHR Palette Viewer", &pGui->bShowSHRPaletteWindow);
cellSize = IM_MIN(
(ImGui::GetContentRegionAvail().x) / rows,
(ImGui::GetContentRegionAvail().y) / cols
);
uint8_t* paletteData = MemoryManager::GetInstance()->GetApple2MemAuxPtr() + _A2VIDEO_SHR_PALETTE_START;
// Remove spacing between items so squares touch
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 0 });
for (int row = 0; row < rows; ++row)
{
for (int col = 0; col < cols; ++col)
{
int idx = row * cols + col;
// Read 16-bit value (low byte first, then high byte)
uint16_t value = static_cast<uint16_t>(paletteData[2 * idx]) |
(static_cast<uint16_t>(paletteData[2 * idx + 1]) << 8);
// Extract 4-bit channels: R = bits 11-8, G = bits 7-4, B = bits 3-0
float r = static_cast<float>((value >> 8) & 0xF) / 15.0f;
float g = static_cast<float>((value >> 4) & 0xF) / 15.0f;
float b = static_cast<float>( value & 0xF) / 15.0f;
// Unique ID per cell to avoid label collisions
ImGui::PushID(idx);
ImGui::ColorButton(
"##cell",
ImVec4{ r, g, b, 1.0f },
ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop,
ImVec2{ cellSize, cellSize }
);
ImGui::PopID();
ImGui::SetItemTooltip("%04X - %03.0f,%03.0f,%03.0f", value, r * 256, g * 256, b * 256);
if (col < cols - 1)
ImGui::SameLine();
}
}
ImGui::PopStyleVar();
ImGui::End();
}
A2VideoManager::GetInstance()->DisplayImGuiExtraWindows();
A2VideoManager::GetInstance()->DisplayImGUIRGBDebugWindows();
if (pGui->mem_edit_sdhr_upload.Open)
{
auto memManager = MemoryManager::GetInstance();
pGui->mem_edit_sdhr_upload.DrawWindow("Memory Editor: SDHR Upload Region", memManager->GetApple2MemPtr(), 2 * _A2_MEMORY_SHADOW_END);
}
if (pGui->bShowImGuiMetricsWindow)
ImGui::ShowMetricsWindow(&pGui->bShowImGuiMetricsWindow);
if (pGui->bShowUSBImGuiWindow)
usb_display_imgui_window(&pGui->bShowUSBImGuiWindow);
}
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}
void MainMenu::ShowSDDMenu() {
/*
// List video drivers for debugging
if (ImGui::BeginMenu("Video Drivers"))
{
auto _n = SDL_GetNumVideoDrivers();
for (size_t i = 0; i < _n; i++)
{
ImGui::Text(SDL_GetVideoDriver(i));
}
ImGui::EndMenu();
}
*/
#ifndef __APPLE__
// For OSX, don't let SDL handle fullscreen. It has the potential to crash if the user
// maximizes the window to fullscreen as well. So completely hide all fullscreen options in OSX
if (ImGui::MenuItem("Fullscreen", "Alt+Enter", Main_IsFullScreen())) {
Main_SetFullScreen(!Main_IsFullScreen());
}
if (Main_IsLinuxConsole()) {
if (ImGui::BeginMenu("Fullscreen Resolution")) {
// FIXME: Figure out the display index for full screen mode
int displayIndex = SDL_GetWindowDisplayIndex(Main_GetSDLWindow());
SDL_DisplayMode currentDisplayMode = Main_GetFullScreenMode();
if (pGui->iCurrentDisplayIndex != displayIndex)
{
// display changed, let's get its info
int numDisplayModes = SDL_GetNumDisplayModes(displayIndex);
SDL_DisplayMode _lastMode;
_lastMode.w = _lastMode.h = _lastMode.refresh_rate = 0;
pGui->v_displayModes.clear();
for (int i = 0; i < numDisplayModes; ++i) {
SDL_DisplayMode mode;
if (SDL_GetDisplayMode(displayIndex, i, &mode) != 0) {
LogStreamErr() << "SDL_GetDisplayMode failed: " << SDL_GetError();
continue;
}
// Only store the highest refresh rate modes
if (!(_lastMode.w == mode.w && _lastMode.h == mode.h && _lastMode.refresh_rate > mode.refresh_rate))
{
pGui->v_displayModes.push_back(mode);
_lastMode = mode;
}
}
}
bool foundCurrentMode = false;
bool isCurrentMode = false;
char modeDescription[200];
for (size_t i = 0; i < pGui->v_displayModes.size(); ++i)
{
auto mode = pGui->v_displayModes[i];
snprintf(modeDescription, 199, "%dx%d @ %dHz", mode.w, mode.h, mode.refresh_rate);
if (foundCurrentMode == false)
{
isCurrentMode = (
mode.w == currentDisplayMode.w &&
mode.h == currentDisplayMode.h &&
mode.refresh_rate == currentDisplayMode.refresh_rate);
isCurrentMode ? foundCurrentMode = true : foundCurrentMode = false;
}
else
isCurrentMode = false;
if (ImGui::MenuItem(modeDescription, "", isCurrentMode))
Main_SetFullScreenMode(mode);
}
if (foundCurrentMode == false)
{
// Couldn't find a mode
Main_SetFullScreenMode(pGui->v_displayModes[0]);
}
ImGui::EndMenu();
}
}
#endif
SwapInterval_e iMMVsync = Main_GetVsync();
int bMMVsync = 0;
if (iMMVsync == SWAPINTERVAL_VSYNC || iMMVsync == SWAPINTERVAL_ADAPTIVE)
bMMVsync = 1;
else if (iMMVsync == SWAPINTERVAL_APPLE2BUS)
bMMVsync = 2;
if (ImGui::RadioButton("VSYNC Monitor", &bMMVsync, 1)) {
Main_SetVsync(SWAPINTERVAL_ADAPTIVE);
iMMVsync = Main_GetVsync();
}
ImGui::SetItemTooltip("Standard monitor VSYNC, uses adaptive VSYNC when available. \nThis is the default. The Apple 2 renderer still renders at the speed of the \nApple 2 bus, but the final postprocessing is done at the monitor's VSYNC speed");
if (iMMVsync == SWAPINTERVAL_VSYNC || iMMVsync == SWAPINTERVAL_ADAPTIVE)
{
if (iMMVsync == SWAPINTERVAL_ADAPTIVE)
{
ImGui::SameLine();
ImGui::Text("(Adaptive)");
}
}
if (ImGui::RadioButton("VSYNC Appletini", &bMMVsync, 2)) {
Main_SetVsync(SWAPINTERVAL_APPLE2BUS);
}
ImGui::SetItemTooltip("Syncs to the Apple 2's bus. Everything will run at PAL \nor NTSC refresh rates, depending on your Apple 2 version");
if (ImGui::RadioButton("No VSYNC", &bMMVsync, 0)) {
Main_SetVsync(SWAPINTERVAL_NONE);
}
ImGui::SetItemTooltip("VSYNC disabled. You can choose your own postprocessing refresh speed. \nNot recommended unless you're testing your setup's maximum performance, \nor want to see what would happen if your Apple 2 were to be connected \nto a very slow refresh rate monitor");
if (bMMVsync > 0)
ImGui::BeginDisabled(true);
ImGui::SameLine();ImGui::Spacing();ImGui::SameLine();
if (ImGui::BeginMenu("FPS Limiter")) {
pGui->iFPSLimiter = Main_GetFPSLimit();
if (ImGui::RadioButton("Disabled##FPSLIMIT", &pGui->iFPSLimiter, UINT32_MAX))
Main_SetFPSLimit(UINT32_MAX);
if (ImGui::RadioButton("15 Hz##FPSLIMIT", &pGui->iFPSLimiter, 15))
Main_SetFPSLimit(15);
if (ImGui::RadioButton("20 Hz##FPSLIMIT", &pGui->iFPSLimiter, 20))
Main_SetFPSLimit(20);
if (ImGui::RadioButton("30 Hz##FPSLIMIT", &pGui->iFPSLimiter, 30))
Main_SetFPSLimit(30);
if (ImGui::RadioButton("45 Hz##FPSLIMIT", &pGui->iFPSLimiter, 45))
Main_SetFPSLimit(45);
if (ImGui::RadioButton("50 Hz##FPSLIMIT", &pGui->iFPSLimiter, 50))
Main_SetFPSLimit(50);
if (ImGui::RadioButton("60 Hz##FPSLIMIT", &pGui->iFPSLimiter, 60))
Main_SetFPSLimit(60);
if (ImGui::RadioButton("100 Hz##FPSLIMIT", &pGui->iFPSLimiter, 100))
Main_SetFPSLimit(100);
if (ImGui::RadioButton("120 Hz##FPSLIMIT", &pGui->iFPSLimiter, 120))
Main_SetFPSLimit(120);
ImGui::EndMenu();
}
if (bMMVsync)
ImGui::EndDisabled();
if (ImGui::BeginMenu("Background Color")) {
float windowBGColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; // RGBA
Main_GetBGColor(windowBGColor);
if (ImGui::ColorEdit4("##windowBGColor", windowBGColor)) {
Main_SetBGColor(windowBGColor);
}
ImGui::EndMenu();
}
ImGui::Separator();
if (ImGui::BeginMenu("Appletini")) {
ImGui::Text("%s", get_tini_name_string().c_str());
if (get_tini_last_error() == 19) // FT_TIMEOUT
ImGui::Text("%s", "No data (Apple 2 is off?)");
else
ImGui::Text("%s", get_tini_last_error_string_async().c_str());
ImGui::EndMenu();
}
ImGui::Separator();
if (ImGui::MenuItem("Reset SDD")) {
auto switch_c034 = MemoryManager::GetInstance()->switch_c034;
A2VideoManager::GetInstance()->ResetComputer();
MemoryManager::GetInstance()->switch_c034 = switch_c034;
Main_DisplaySplashScreen();
}
ImGui::Separator();
if (ImGui::BeginMenu("Samples")) {
ShowSamplesMenu();
ImGui::EndMenu();
}
ImGui::Separator();
if (ImGui::BeginMenu("HUD Log")) {
ImGui::PushItemWidth(100);
auto _ltm = LogTextManager::GetInstance();
if (ImGui::RadioButton("Top Left##LogPosition", _ltm->logPosition == TTLogPosition_e::TOP_LEFT))
_ltm->logPosition = TTLogPosition_e::TOP_LEFT;
if (ImGui::RadioButton("Bottom Left##LogPosition", _ltm->logPosition == TTLogPosition_e::BOTTOM_LEFT))
_ltm->logPosition = TTLogPosition_e::BOTTOM_LEFT;
float logDurationSec = _ltm->logDurationMS / 1000.f;
if (ImGui::DragFloat("Display Time", &logDurationSec, .1f, 0.1f, 100.f, "%.1f"))
_ltm->logDurationMS = (uint32_t)(logDurationSec * 1000);
ImGui::PopItemWidth();
ImGui::EndMenu();
}
ImGui::MenuItem("About", "", &pGui->bShowAboutWindow);
ImGui::MenuItem("Help", "", &pGui->bShowHelpWindow);
ImGui::Separator();
if (ImGui::MenuItem("Quit", "Alt+F4")) {
Main_RequestAppQuit();
}
}
void MainMenu::ShowMotherboardMenu() {
if (ImGui::BeginMenu("Region")) {
auto cycleCounter = CycleCounter::GetInstance();
int vbl_region;
vbl_region = (cycleCounter->GetVideoRegion() == VideoRegion_e::PAL ? 1 : 2);
if (ImGui::RadioButton("PAL##REGION", &vbl_region, 1))
cycleCounter->SetVideoRegion(VideoRegion_e::PAL);
ImGui::SameLine();
if (ImGui::RadioButton("NTSC##REGION", &vbl_region, 2))
cycleCounter->SetVideoRegion(VideoRegion_e::NTSC);
int vbl_slider_val = (int)cycleCounter->GetScreenCycles();
if (ImGui::InputInt("VBL Start Shift", &vbl_slider_val, 1, (CYCLES_TOTAL_PAL - CYCLES_TOTAL_NTSC) / 10))
{
cycleCounter->SetVBLStart(vbl_slider_val);
}
ImGui::SetItemTooltip("Press the '-' button to keep shifting the VBL earlier in the frame \nto realign it manually");
ImGui::Separator();
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Character ROMs")) {
A2VideoManager::GetInstance()->DisplayCharRomsImGuiChunk();
ImGui::EndMenu();
}
ImGui::MenuItem("Apple //e Memory", "", &pGui->mem_edit_a2e.Open);
ImGui::MenuItem("Apple //e Memory Heat Map", "", &pGui->bShowMemoryHeatMap);
ImGui::Separator();
bool _bMouseIsLocked = (SDL_GetRelativeMouseMode() == SDL_TRUE);
if (ImGui::Checkbox("Apple Mouse (F5)", &_bMouseIsLocked))
{
SDL_SetRelativeMouseMode(_bMouseIsLocked ? SDL_TRUE : SDL_FALSE);
}
float _ms = usb_mouse_get_sensitivity();
if (ImGui::SliderFloat("Apple Mouse Speed", &_ms, 0, 1.0))
usb_mouse_set_sensitivity(_ms);
}
void MainMenu::ShowVideoMenu() {
auto glhelper = OpenGLHelper::GetInstance();
ImGui::MenuItem("Apple 2 Video Settings", "F2", &pGui->bShowA2VideoWindow);
ImGui::MenuItem("Post Processor Settings", "F3", &pGui->bShowPPWindow);
ImGui::Separator();
if (ImGui::MenuItem("On-Screen FPS", "F8", Main_IsFPSOverlay())) {
Main_SetFPSOverlay(!Main_IsFPSOverlay());
Main_ResetFPSCalculations();
A2VideoManager::GetInstance()->ForceBeamFullScreenRender();