bm_getptr

Prototypes:
Arguments:
Returns:
Description:

This function's primary purpose is to allow browsing through the list of files in the backup ram. When first used, set ptr to BRAM_STARTPTR, and the function's arguments will return the name of the first entry plus a pointer to the next entry in the backup ram. When the function's return value is 0, there are no more entries in the backup ram.

Complete Example:

#include "huc.h"

main()
{
  char namebuf[13]; /* for BRAM filenames */
  int nextptr; /* pointer to the next filename in BRAM */
  int line_cnt; /* for displaying the results */

  set_color(1, 511); /* set color 1 to pure white */
  set_font_color(1, 0); /* set the font color */
  set_font_pal(0); /* set the font palette */
  load_default_font(); /* load the default font */

  if(!bm_check()) /* check to see if BRAM is available on this system */
  {
    put_string("BACKUP RAM NOT AVAILABLE.", 0, 0); /* give an error message */
    while(1) { vsync(); } /* infinite loop (effectively stops the program) */
  }

  namebuf[12] = 0; /* the last char in the namebuffer has to be an absolute 0 */
  nextptr = BRAM_STARTPTR; /* sets up the first pointer */
  line_cnt = 2; /* first result will be displayed on character line 5 */

  while (nextptr = bm_getptr(nextptr, namebuf)) /* get the next filename */
  {
    put_string(&namebuf[2], 3, line_cnt); /* display the filename */
    put_number(namebuf[0], 1, 0, line_cnt); /* display the first value of the two-byte ID */
    put_number(namebuf[1], 1, 1, line_cnt); /* display the second value of the two-byte ID */
    put_number(bm_sizeof(namebuf), 4, 15, line_cnt); /* get the size of the file and display it */
    line_cnt++; /* increment the char line counter */
  }
}

Sample Output:



Notes:

This function was added in version 3.03.

See Also:

HuC header file | bm_check | bm_sizeof