Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/arduino-nofrendo/src/nes/nes.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ nes_t *nes_create(void)
return NULL;
}

bool nes_pausestate(void) {
return nes.pause;
}

/*
** $Log: nes.c,v $
** Revision 1.2 2001/04/27 14:37:11 neil
Expand Down
1 change: 1 addition & 0 deletions lib/arduino-nofrendo/src/nes/nes.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ extern void nes_reset(int reset_type);

extern void nes_poweroff(void);
extern void nes_togglepause(void);
extern bool nes_pausestate(void);

#endif /* _NES_H_ */

Expand Down
2 changes: 1 addition & 1 deletion src/cardputer/CardputerInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ char CardputerInput::readChar() {
if (status.del) return KEY_DEL;

return KEY_NONE;
}
}
24 changes: 24 additions & 0 deletions src/cardputer/CardputerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ void CardputerView::welcome() {
Display->printf("%s", press.c_str());
}

void CardputerView::pauseScreen() {
// some constants
const int boxW = 100;
const int boxH = 50;
const int boxX = (Display->width() - boxW) / 2;
const int boxY = (Display->height() - boxH) / 2;
const int textOffset = 25;

// do a background and a box
Display->fillScreen(BACKGROUND_COLOR);

Display->fillRoundRect(boxX, boxY, boxW, boxH, DEFAULT_ROUND_RECT, RECT_COLOR_DARK);
Display->drawRoundRect(boxX, boxY, boxW, boxH, DEFAULT_ROUND_RECT, PRIMARY_COLOR);

// kay now for sum text
std::string paused = "Paused";

Display->setTextColor(TEXT_COLOR);
Display->setTextSize(TEXT_BIG);

Display->setCursor(getCenterOffset(paused) + 1, boxY + textOffset);
Display->printf("%s", paused.c_str());
}

void CardputerView::topBar(const std::string& title, bool submenu, bool searchBar) {
uint8_t marginX = 4;
uint8_t marginY = 14;
Expand Down
1 change: 1 addition & 0 deletions src/cardputer/CardputerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CardputerView {
uint8_t getBrightness();
void welcome();
void showKeymapping();
void pauseScreen();
void topBar(const std::string& title, bool submenu, bool searchBar);
void horizontalSelection(const std::vector<std::string>& options, uint16_t selectedIndex, const std::string& description1="", const std::string& description2="", const std::vector<std::string>& icons={});
void verticalSelection(
Expand Down
11 changes: 11 additions & 0 deletions src/nes/nes_controller.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
extern "C" {
#include <nes/nes.h>
}

#include <M5Cardputer.h>

extern bool fullscreenMode;
Expand All @@ -12,6 +16,8 @@ void controller_init() {
uint32_t controller_read_input() {
uint32_t value = 0xFFFFFFFF;

if (nes_pausestate()) return value; // block input while paused

M5Cardputer.update();
Keyboard_Class::KeysState status = M5Cardputer.Keyboard.keysState();

Expand Down Expand Up @@ -100,9 +106,14 @@ uint32_t controller_read_input() {
if (M5Cardputer.Keyboard.isKeyPressed('l') || M5Cardputer.Keyboard.isKeyPressed('j')) {
value ^= (1 << 6); // A
}

if (M5Cardputer.Keyboard.isKeyPressed('k')) {
value ^= (1 << 7); // B
}

if (M5Cardputer.Keyboard.isKeyPressed(' ')) {
value ^= (1 << 10); // pause
}

return value;
}
Expand Down
18 changes: 17 additions & 1 deletion src/nes/nes_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ extern "C" {
}

#include <M5Unified.h>
#include "display/CardputerView.h"
#include "input/CardputerInput.h"


int16_t frame_scaling;
static uint16_t* s_nesLineBuf = nullptr;
Expand Down Expand Up @@ -129,6 +132,19 @@ void display_write_frame_zoom(const uint8_t *data[]) {
}

void display_write_frame(const uint8_t *data[]) {
// this might not be the best spot for this
if (nes_pausestate()) {
CardputerInput input;
CardputerView display;

display.initialize();
display.pauseScreen();

input.waitPress();
delay(100); // this is so it can't do a pause-unpause stutter
nes_togglepause();
}

if (!fullscreenMode) {
display_write_frame_square(data);
return;
Expand Down Expand Up @@ -164,4 +180,4 @@ void display_clear() {
}


}
}
4 changes: 2 additions & 2 deletions src/nes/nes_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void osd_getinput(void)
const int ev[32] = {
event_joypad1_up, event_joypad1_down, event_joypad1_left, event_joypad1_right,
event_joypad1_select,event_joypad1_start, event_joypad1_a, event_joypad1_b,
event_state_save, event_state_load, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0
event_state_save, event_state_load, event_togglepause, 0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0
};
static int oldb = 0xffff;
uint32_t b = controller_read_input();
Expand Down Expand Up @@ -287,4 +287,4 @@ void __wrap_bmp_destroy(bitmap_t **bmp)
// }
// g_rom_ptr = NULL;
// g_rom_size = 0;
// }
// }