"Retry API" refers to a collection of routines that Retry provides that you can call from your UberASM files if needed.
NOTE: calling these routines from files in the library folder will result in an error, at least when using the standard UberASMTool.
JSL retry_api_respawn
Call this to make the player respawn in the current level at the last checkpoint. This has the same effect as dying and hitting Retry, or dying with instant Retry enabled, but skipping everything related to death (animation, music, prompt, life loss, etc.).
N/AN/AA/X/Y 8 bitsA/X/Y 8 bitsJSL retry_api_save_game
Call this to save the game, which will also save the addresses defined in the sram_tables.asm file (including those under .global).
N/AN/AN/AA/X/Y 8 bits, DB/X/Y preservedJSL retry_api_save_global_vars
Routine to save the global variables to SRAM, meaning just the addresses found under .global in the sram_tables.asm file.
This can be useful if you need to update the global variables outside of a save file (e.g. on the title screen) or if you want to save them without saving the file specific addresses.
N/AN/AN/AA clobbered, DB/X/Y/P preserved, $02-$0B clobberedJSL retry_api_reset_cp
Call this to reset the checkpoint in the current level. Entering the level again or respawning will load the main sublevel's entrance. Note that this won't reflect to SRAM until the game is saved.
NOTE: this can be also called outside of a level if you want to reset a specific level's checkpoint. Just make sure that $13BF has the level number you want before calling this.
N/AN/AA/X/Y 8 bitsA/X/Y 8 bits, DB/X/Y preservedJSL retry_api_reset_all_cps
Call this to reset the checkpoint for every level in the game, effectively making it as if it were a fresh game. Note that this won't reflect to SRAM until the game is saved.
N/AN/AN/AA/X/Y size preserved, DB/X/Y preservedJSL retry_api_cfg_ssb
NOTE: for a more convenient way to configure the sprite status bar, check out Local Settings - Configure Sprite Status Bar. This routine is still useful if you need to unhide elements of the status bar during the level.
NOTE: this routine has no effect unless !sprite_status_bar = 1 in settings_global.asm.
Call this in UberASM level init code to configure graphics for the sprite status bar items (item box, timer, coin counter, lives counter, bonus stars counter, death counter) for a specific level. Calling this will override the default settings found in settings_global.asm and the level settings found in settings_local.asm, in case you want to hide some or all of the elements in some level or if you need to change their tile or palette. You can also call it in main if you need to unhide elements during a level.
Each item's configuration is set with a 16 bit value $PTTT. The first digit P will be the item's palette, starting from palette 8 with P = 8 and ending with palette F with P = F. TTT will determine the tile number: you can see this in Lunar Magic's "8x8 Tile Editor" if you hover over the desired tile (more specifically, the upper left 8x8 tile of the 16x16 tile you want to use). In the bottom bar you'll see "Tile 0xYYY": then, TTT = YYY - $400. For example, the Smiling Coin tile is "Tile 0x4C2", which results in TTT = $4C2 - $400 = $0C2. So, for example, to reserve that tile and use palette F, the full value will be $F0C2.
If an item's value is $0000, the item will simply not be displayed.
For the coin counter specifically, you can choose to only display coins or dragon coins. By default both will be displayed, but if you add $0200 to the value only dragon coins will be displayed, instead if you add $0400 only coins will be displayed. For example:
$81C2: palette 8, tile 0x1C2, both coins and dragon coins displayed.$83C2: palette 8, tile 0x1C2, only dragon coins displayed.$85C2: palette 8, tile 0x1C2, only coins displayed.Note that you can also just write the $PTTT value to the RAM address for a specific item yourself, this routine is just a shorthand so set all values at the same time. To see the RAM addresses names, see RAM Info.
$PTTT value is specified, in order, after the JSL (see example)N/AN/AA/X/Y size preserved, DB/X/Y preserved
JSL retry_api_cfg_ssb
dw $B080 ; Item box: palette B, tile 0x80
dw $8088 ; Timer: palette 8, tile 0x88
dw $80C2 ; Coin counter: palette 8, tile 0xC2
dw $904E ; Lives counter: palette 9, tile 0x4E
dw $90CE ; Bonus stars counter: palette 9, tile 0xCE
dw $0000 ; Death counter: hidden
... <- your code will continue here after the JSL
JSL retry_api_hide_ssb
NOTE: for a more convenient way to hide the sprite status bar, check out Local Settings - Hide Sprite Status Bar. This routine is still useful if you need to hide elements of the status bar during the level.
NOTE: this routine has no effect unless !sprite_status_bar = 1 in settings_global.asm.
Routine to hide the sprite status bar for the current level. This routine should be called in UberASM level init code, or in main if you need to hide the status bar during a level.
N/AN/AN/AA/X/Y 8 bit and clobbered, DB preservedJSL retry_api_hide_ssbRoutine to get the current Retry type, i.e. if currently the level is set to have Retry prompt, instant Retry or no Retry.
N/AA = Retry type$01: Retry prompt enabled & play the death song when the player dies$02: Retry prompt enabled & play only the death sfx when the player dies$03: instant Retry enabled & play only the death sfx when the player dies$04: instant Retry enabled & play the death song when the player dies$05: Retry disabled (vanilla death)A 8 bitsA/X/Y size preserved, DB/X/Y preservedJSL retry_api_get_retry_typeJSL retry_api_is_save_file_empty
Routine to get check if a save file is empty.
$010A|!addr (0 = save file 1, 1 = save file 2, 2 = save file 3, behavior undefined for other values)Carry set = save file emptyCarry clear = save file not emptyA 8 bitsA/X/Y 8 bit and clobbered, DB preserved
LDA #$02 ; Check save file 3
STA $010A|!addr
JSL retry_api_is_save_file_empty
BCS empty
not_empty:
...
empty:
...
JSL retry_api_get_sram_var
Routine to get the address in SRAM for a specific variable. By "variable" it's meant any of the RAM addresses that are saved to SRAM specified in the sram save table.
If not searching for a variable under .global, the variable will be searched in the currently loaded save file. If calling this before a save file is loaded (e.g. the title screen), you need to specify the save file to look into by setting the $010A|!addr address (0 = save file 1, 1 = save file 2, 2 = save file 3, behavior undefined for other values).
This could be useful to read/write values in SRAM directly, for example if you need to update some SRAM value without the game being saved, or if you need to display something on the title screen depending on the save file data.
NOTE: this will always return "variable not found" if !sram_feature = 0 or if the chosen save file is empty (for local variables).
JSL retry_api_get_sram_var dl <variable address> ... <- your code will continue here after the JSL
Carry set = variable not foundCarry clear = variable found → SRAM address stored in $00-$02. In this case the value in SRAM can be accessed indirectly with the LDA/STA [$00] and LDA/STA [$00],y instructions.N/AA/X/Y 8 bit and clobbered, DB preserved
JSL retry_api_get_sram_var
dl retry_ram_death_counter ; Variable to search for
BCS error
found:
LDY #$01
LDA #$09
STA [$00],y ; Set second death counter digit in SRAM to 9
error:
...
LDA #$01 ; $01 = search in save file 2
STA $010A|!addr
JSL retry_api_get_sram_var
dl retry_ram_death_counter ; Variable to search for
BCS empty_file
LDA [$00] ; Get first death counter digit of save file 2
...
empty_file:
...