To display figures and play sound effects.


§1. Resource Usage. We record whether pictures or sounds have been used before by storing single byte flags in the following array. (The extra 5 values allow for the fact that it can be legal to use low undeclared sound effect resource numbers in the Z-machine for short beeps, though this is deprecated in I7.)

Pictures and sounds are identified within blorb archives by resource ID numbers which count upwards from 1 in order of creation, but can mix pictures and sounds freely. (For instance, 1 might be a picture, 2 and 3 sound effects, then 4 a picture again, etc.) ID number 1 is in fact always a picture: it means the cover art, and is the I6 representation of the value "figure of cover".

Array ResourceUsageFlags -> (ICOUNT_FIGURE_NAME + ICOUNT_SOUND_NAME + 5);

§2. Figures.

[ DisplayFigure resource_ID one_time;
    if ((one_time) && (ResourceUsageFlags->resource_ID)) return;
    ResourceUsageFlags->resource_ID = true;
    print "^"; VM_Picture(resource_ID); print "^";
];

§3. Sound Effects.

[ PlaySound resource_ID one_time;
    if (resource_ID == 0) return; The "silence" non-sound effect
    if ((one_time) && (ResourceUsageFlags->resource_ID)) return;
    ResourceUsageFlags->resource_ID = true;
    VM_SoundEffect(resource_ID);
];