diff --git a/applications/plugins/tama_p1/README.md b/applications/plugins/tama_p1/README.md index 2e95d1e76..0c06eb712 100644 --- a/applications/plugins/tama_p1/README.md +++ b/applications/plugins/tama_p1/README.md @@ -11,9 +11,12 @@ Create a `tama_p1` folder in your microSD card, and put the ROM as `rom.bin`. Use a search engine to find the Tamagotchi ROM. There is a file named `a`. Rename this to `rom.bin`. -Left button is A, OK is B, and right button is C. Hold the back button to exit. -There is currently no saving, so your progress will be reset when you exit the -app. +- Left button is A. +- OK is B. +- Right button is C. +- Holding the Up button functions the same as press both A and C, which mutes the volume. +- Hold the Back button to save and exit. + Building -------- @@ -34,7 +37,7 @@ Note: you may also need to add `-Wno-unused-parameter` to `CCFLAGS` in Debugging --------- Using the serial script from [FlipperScripts](https://github.com/DroomOne/FlipperScripts/blob/main/serial_logger.py) -it is easy to add direct logging after running the appliation: +it is easy to add direct logging after running the application: `python .\serial_logger.py` `./fbt launch_app APPSRC=applications\plugins\tama_p1; python .\serial_logger.py` @@ -45,11 +48,12 @@ Implemented - Basic emulation - Input - Sound -- Saving/Loading emaulator state (stored in `/ext/tama_p1/save.bin`) +- Saving/Loading emulator state (stored in `/ext/tama_p1/save.bin`) +- Mute button combo shortcut (Up = A+C) To-do ----- -- Slots +- more than one save slot - In-game reset - Test mode? - Volume adjustment diff --git a/applications/plugins/tama_p1/tama.gif b/applications/plugins/tama_p1/tama.gif new file mode 100644 index 000000000..c41222260 Binary files /dev/null and b/applications/plugins/tama_p1/tama.gif differ diff --git a/applications/plugins/tama_p1/tama_p1.c b/applications/plugins/tama_p1/tama_p1.c index 7e627adc9..7184638d7 100644 --- a/applications/plugins/tama_p1/tama_p1.c +++ b/applications/plugins/tama_p1/tama_p1.c @@ -38,9 +38,20 @@ static void tama_p1_draw_callback(Canvas* const canvas, void* cb_ctx) { // FURI_LOG_D(TAG, "Drawing frame"); // Calculate positioning uint16_t canv_width = canvas_width(canvas); + uint16_t canv_height = canvas_height(canvas); uint16_t lcd_matrix_scaled_width = 32 * TAMA_SCREEN_SCALE_FACTOR; - uint16_t lcd_matrix_top = 0; + uint16_t lcd_matrix_scaled_height = 16 * TAMA_SCREEN_SCALE_FACTOR; + // uint16_t lcd_matrix_top = 0; + uint16_t lcd_matrix_top = (canv_height - lcd_matrix_scaled_height) / 2; uint16_t lcd_matrix_left = (canv_width - lcd_matrix_scaled_width) / 2; + + uint16_t lcd_icon_upper_top = lcd_matrix_top - TAMA_LCD_ICON_SIZE - TAMA_LCD_ICON_MARGIN; + uint16_t lcd_icon_upper_left = lcd_matrix_left; + uint16_t lcd_icon_lower_top = + lcd_matrix_top + lcd_matrix_scaled_height + TAMA_LCD_ICON_MARGIN; + uint16_t lcd_icon_lower_left = lcd_matrix_left; + uint16_t lcd_icon_spacing_horiz = + (lcd_matrix_scaled_width - (4 * TAMA_LCD_ICON_SIZE)) / 3 + TAMA_LCD_ICON_SIZE; uint16_t y = lcd_matrix_top; @@ -58,20 +69,32 @@ static void tama_p1_draw_callback(Canvas* const canvas, void* cb_ctx) { y += TAMA_SCREEN_SCALE_FACTOR; } - // Draw Icons on bottom + // Start drawing icons uint8_t lcd_icons = g_ctx->icons; - uint16_t x_ic = 0; - y = 64 - TAMA_LCD_ICON_SIZE; - for(uint8_t i = 0; i < 7; ++i) { + + // Draw top icons + y = lcd_icon_upper_top; + // y = 64 - TAMA_LCD_ICON_SIZE; + uint16_t x_ic = lcd_icon_upper_left; + for(uint8_t i = 0; i < 4; ++i) { if(lcd_icons & 1) { canvas_draw_icon(canvas, x_ic, y, icons_list[i]); } - x_ic += TAMA_LCD_ICON_SIZE + 4; + // x_ic += TAMA_LCD_ICON_SIZE + 4; + x_ic += lcd_icon_spacing_horiz; lcd_icons >>= 1; } - if (lcd_icons & 7) { - canvas_draw_icon(canvas, 128 - TAMA_LCD_ICON_SIZE, 0, icons_list[7]); + // Draw bottom icons + y = lcd_icon_lower_top; + x_ic = lcd_icon_lower_left; + for(uint8_t i = 4; i < 8; ++i) { + // canvas_draw_frame(canvas, x_ic, y, TAMA_LCD_ICON_SIZE, TAMA_LCD_ICON_SIZE); + if(lcd_icons & 1) { + canvas_draw_icon(canvas, x_ic, y, icons_list[i]); + } + x_ic += lcd_icon_spacing_horiz; + lcd_icons >>= 1; } } @@ -91,8 +114,6 @@ static void tama_p1_update_timer_callback(FuriMessageQueue* event_queue) { TamaEvent event = {.type = EventTypeTick}; furi_message_queue_put(event_queue, &event, 0); } - - static void tama_p1_load_state() { state_t *state; @@ -204,7 +225,6 @@ static void tama_p1_save_state() { // Saving state FURI_LOG_D(TAG, "Saving Gamestate"); - uint8_t buf[4]; state_t *state; uint32_t offset = 0; @@ -465,6 +485,14 @@ int32_t tama_p1_app(void* p) { tamalib_set_button(BTN_MIDDLE, tama_btn_state); } else if(event.input.key == InputKeyRight) { tamalib_set_button(BTN_RIGHT, tama_btn_state); + } else if(event.input.key == InputKeyDown && event.input.type == InputTypeShort) { + // TODO: pause or fast-forward tamagotchi + tama_p1_save_state(); + } else if(event.input.key == InputKeyUp) { // mute tamagotchi + tamalib_set_button(BTN_LEFT, tama_btn_state); + tamalib_set_button(BTN_RIGHT, tama_btn_state); + } else if(event.input.key == InputKeyBack && event.input.type == InputTypeShort) { + tama_p1_save_state(); } }