bm_getptr

From ArchaicPixels: HuC and PCEAS Documentation

Jump to: navigation, search

original documentation

bm_getptr(int ptr, char *name);    [ 3.03+ ]

    Useful for browsing through the list of files in BRAM.
    Use 'BRAM_STARTPTR' for the first iteration, and it will return the name
    of this entry, and the next pointer in the list (to use for next iteration).
    When the return value is 0, there is no entry at the current location (ie.
    don't expect a name to be returned), and no subsequent entry.    


bm_getptr

Prototypes:

bm_getptr(int ptr, char* name);

Arguments:

ptr: A pointer to the start of the next file (see below)
name: Returns the name of the next file in backup ram

Returns:

Numeric true or false

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 */

  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 */
  }
}
Personal tools