##### Shinobi Library - Memory Card Function

# buInit

Initializes the memory card file system

### FORMAT

`

  Sint32 buInit( capa, drive, *work, func )
  Sint32 capa
  Sint32 drive
  void *work
  BU_INITCALLBACK func

`

### PARAMETER

  `capa` | Maximum capacity of media
  `drive` | Extension socket number
  `*work` | Work buffer
  `func` | Initialization complete callback

### RETURN

  BUD_ERR_OK | Normal end |
  BUD_ERR_INVALID_PARAM | Invalid parameter |

### DESCRIPTION

  Initializes the memory card file system.

  The following values can be designated for the argument `capa` which shows the maximum capacity of media.

  BUD_CAPACITY_128KB
  BUD_CAPACITY_256KB
  BUD_CAPACITY_512KB
  BUD_CAPACITY_1MB

  Designate the following values in the argument `drive` that shows the operand extension sockets.

  BUD_USE_DRIVE_ALL | All extension sockets
  BUD_USE_DRIVE_A1 | Extension socket 1 on board A
  BUD_USE_DRIVE_A2 | Extension socket 2 on board A
  BUD_USE_DRIVE_B1 | Extension socket 1 on board B
  BUD_USE_DRIVE_B2 | Extension socket 2 on board B
  BUD_USE_DRIVE_C1 | Extension socket 1 on board C
  BUD_USE_DRIVE_C2 | Extension socket 2 on board C
  BUD_USE_DRIVE_D1 | Extension socket 1 on board D
  BUD_USE_DRIVE_D2 | Extension socket 2 on board D

  When NULL is specified in the argument `work` that marks the work buffer,the setting for the argument `capa` is ignored and the work buffer for the memory card can be dynamically managed. When initialization is completed successfully, the specified function is called back.

  The callback function is called before returning from this function. In this case, after the BUD_OP_CONNECT callback is detected, the application allocates a buffer that is suited for the size of the memory card, and then mount processing is performed by the `buMountDisk()` function. The backup RAM can then be used in the normal manner afterwards.

  This method makes it possible to handle large size memory cards without allocating a large buffer size beforehand.

### EXAMPLE

      /* Allocating two buffers for memory cards of up to 128K */
      Uint32 work[BUM_WORK_SIZE(BUD_CAPACITY_128KB, 2) / sizeof(Uint32)];
      void init_callback(void)
      {
      	:
      }
      /* Corresponds to extension sockets 1 and 2 on board A */
      buInit(BUD_CAPACITY_128KB, BUD_USE_DRIVE_A1 | BUD_USE_DRIVE_A2, work, init_callback);

### NOTE

  The necessary amount of work space differs greatly depending on the maximum capacity and the count of the memory card being used. Do not specify an unnecessary memory card in an extension socket for an application. Not specifying unnecessary memory cards reduces the size of the work space and permits faster library operation. The following table lists guidelines for work space:

  Maximum capacity | Workspace per 1 socket | Workspace by 8 slots
  128KB | 8KB | 64KB
  256KB | 14KB | 112KB
  512KB | 28KB | 220KB
  1MB | 55KB | 440KB

  Specify files used in extension sockets as BUD_USE_DRIVE_XXX. Do not specify BUD_DRIVE_XXX constant by mistake.

### REFERENCE

  `buExit()
  buMountDisk()
  `

buInit

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999