Skip to content

Commit

Permalink
Menu: if bootloader is upgraded, the system reboots after flashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeal8bit committed Jan 11, 2023
1 parent 0a0a448 commit e3207f0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/menu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,28 @@ _menu_flash_ask_size:
PRINT_STR(flashing_flash_str)
pop de
pop bc
; Pop the upper 16-bit of the destination
pop hl
; If the destination is the bootloader (0), reboot after flashing
ld a, h
or l
jr z, _flash_and_reboot
; Flash the received file to the ROM(NOR Flash)
pop hl ; Pop the upper 16-bit of destination
call sys_table_flash_file_to_rom
or a
; Error is A is not 0
ret z
PRINT_STR(flash_erase_error_str)
ret
_flash_and_reboot:
; Store rst 0 (0xc7) instruction in RAM
ld a, 0xc7
push hl
ld hl, reset_instruction
ld (hl), a
; Set reset_instruction as the return address
ex (sp), hl
jp sys_table_flash_file_to_rom

_menu_flash_rom_zero:
; Put the upper 16 bit address (0) on the stack
Expand Down Expand Up @@ -842,4 +856,5 @@ arrow_end:
systems_count: DEFS 1
systems: DEFS SYS_TABLE_ENTRY_COUNT * 2
buffer: DEFS BUFFER_SIZE + 1 ; +1 for NULL byte
buffer_name: DEFS BUFFER_SIZE + 1 ; +1 for NULL byte
buffer_name: DEFS BUFFER_SIZE + 1 ; +1 for NULL byte
reset_instruction: DEFS 1

0 comments on commit e3207f0

Please sign in to comment.