updated tamagotchi (added muted button)

thanks Smileycathy1128!
This commit is contained in:
jbohack
2023-01-23 14:27:39 -05:00
parent 364943b1aa
commit 3cc4681cbc
3 changed files with 49 additions and 17 deletions

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@@ -38,10 +38,21 @@ 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;
for(uint8_t row = 0; row < 16; ++row) {
@@ -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;
}
}
@@ -92,8 +115,6 @@ static void tama_p1_update_timer_callback(FuriMessageQueue* event_queue) {
furi_message_queue_put(event_queue, &event, 0);
}
static void tama_p1_load_state() {
state_t *state;
uint8_t buf[4];
@@ -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();
}
}