| 234 | } |
| 235 | |
| 236 | void UI::pauseMenu(Bus* nes) |
| 237 | { |
| 238 | // Black magic stuff |
| 239 | // Padding bytes for code alignment for better performance |
| 240 | __attribute__((used, section(".text"), aligned(64))) static const uint8_t padding[128] = { 0 }; |
| 241 | |
| 242 | paused = true; |
| 243 | int prev_select = 0; |
| 244 | int select = 0; |
| 245 | |
| 246 | screen->endWrite(); |
| 247 | |
| 248 | // Draw bars with text |
| 249 | drawBars(); |
| 250 | const char* text2 = "Pause"; |
| 251 | int text2_x = screen->width() - screen->textWidth(text2) - 12; |
| 252 | screen->fillRect(text2_x - 4, 0, screen->textWidth(text2) + 8, 16, SELECTED_BG_COLOR); |
| 253 | drawText(text2, text2_x, 4); |
| 254 | |
| 255 | constexpr int section_count[] = { 3, 2, 1 }; |
| 256 | constexpr const char* items[] = { "Resume", "Settings", "Reset", |
| 257 | "Quick Save State", "Quick Load State", "Save and Quit" }; |
| 258 | enum ItemSelect : uint8_t |
| 259 | { |
| 260 | Resume, |
| 261 | Settings, |
| 262 | Reset, |
| 263 | QuickSaveState, |
| 264 | QuickLoadState, |
| 265 | SaveAndQuit |
| 266 | }; |
| 267 | constexpr int items_y[] = { 28, 40, 52, 72, 84, 102 }; |
| 268 | constexpr int num_items = sizeof(items) / sizeof(items[0]); |
| 269 | constexpr int num_sections = sizeof(section_count) / sizeof(section_count[0]); |
| 270 | constexpr int item_height = 12; |
| 271 | constexpr int text_height = 8; |
| 272 | constexpr int text_padding = (item_height - text_height) / 2; |
| 273 | |
| 274 | // Draw pause window |
| 275 | constexpr int window_w = 124; |
| 276 | constexpr int window_h = 104; |
| 277 | int window_x = screen->width() - window_w; |
| 278 | constexpr int window_y = 16; |
| 279 | screen->fillRect(window_x, window_y, window_w, window_h, BAR_COLOR); |
| 280 | |
| 281 | // Draw section borders |
| 282 | int section_y = window_y + 8; |
| 283 | for (int s = 0; s < num_sections; s++) |
| 284 | { |
| 285 | int w = window_w - 16; |
| 286 | int h = (section_count[s] * item_height) + 8; |
| 287 | screen->drawRect(window_x + 8, section_y, w, h, TFT_BLACK); |
| 288 | screen->drawRect(window_x + 9, section_y, w, h, TFT_BLACK); |
| 289 | |
| 290 | section_y += (h - 1); |
| 291 | } |
| 292 | |
| 293 | // Draw items |
nothing calls this directly
no test coverage detected