Retry API

"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.

Index


Respawn in level

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.).


Save game

JSL 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).


Save global variables

JSL 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.


Reset level checkpoint

JSL 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.


Reset all checkpoints

JSL 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.


Configure sprite status bar

JSL 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:

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.


Hide sprite status bar

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.


Get Retry type

Routine to get the current Retry type, i.e. if currently the level is set to have Retry prompt, instant Retry or no Retry.


Is save file empty

JSL retry_api_is_save_file_empty

Routine to get check if a save file is empty.


Get SRAM variable address

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).