mvbg

VM_SHOW_SPRITES

VM_SHOW_SPRITES is a GBVM instruction used to make all sprites currently displayed on the Game Boy screen visible. It is a macro that internally calls VM_SET_SPRITE_VISIBLE with the .SPRITES_SHOW option.

Purpose: Sprites are graphical objects that move independently of the background (e.g., characters, enemies, projectiles). There are many scenarios where you might want to make all sprites visible after they were previously hidden. VM_SHOW_SPRITES is essential for:

When VM_SHOW_SPRITES is executed, the Game Boy’s hardware is instructed to resume rendering all sprites. They will then be drawn to the screen according to their individual visibility settings (e.g., if an actor was individually hidden with VM_ACTOR_SET_HIDDEN, it will remain hidden even if the global sprite layer is shown).

Syntax:

VM_SHOW_SPRITES

VM_SHOW_SPRITES takes no arguments. It performs a global operation on all sprites.

Usage Example: Showing Sprites After a Scene Transition

Imagine your game has just loaded a new scene after a fade-to-black transition. You need to make the sprites of the new scene visible to the player.

; In your script, after a new scene has been loaded and faded in:

; Assume LOAD_NEW_GAME_SCENE is a routine that loads map data and actors
; Assume VM_FADE_IN is a routine that fades the screen in

START_NEW_SCENE:
  ; Load the new scene (which might involve loading new actors and maps)
  VM_CALL LOAD_NEW_GAME_SCENE

  ; Ensure all sprites are visible globally
  VM_SHOW_SPRITES

  ; Initiate a screen fade in from black
  VM_FADE_IN 1 ; Fade in from black over 1 second

  VM_LOAD_TEXT TEXT_SCENE_READY
  VM_DISPLAY_TEXT
  VM_IDLE 60

  VM_RET

LOAD_NEW_GAME_SCENE:
  ; ... logic to load new map, actors, etc. ...
  VM_RET

TEXT_SCENE_READY:
  .TEXT "New scene loaded!"
  .TEXT_END

In this example, VM_SHOW_SPRITES is called after the new scene’s data has been loaded. This ensures that all sprites (characters, enemies, items) that are part of the new scene become visible as the screen fades in, providing a complete visual experience to the player. This is typically paired with a VM_HIDE_SPRITES call before the transition begins.

Analogy to Game Boy Development: This is akin to enabling the display of sprites by setting the appropriate bit in the Game Boy’s LCDC register. It’s a low-level hardware control that affects the entire sprite rendering pipeline, making it a powerful tool for global visual management. It’s the counterpart to VM_HIDE_SPRITES, working together to control the overall visibility of dynamic game elements.