gbpakgetbank.c 1.22 KB
/*---------------------------------------------------------------------
        Copyright (C) 1997, Nintendo.
        
        File            gbpakgetbank.c
        Coded    by     Koji Mitsunari. Oct  2, 1997.
        Modified by     Koji Mitsunari. Apr 16, 1998.
        Comments        Get bank of 64GB-PAK
   
        $Id: 
   ---------------------------------------------------------------------*/

/**************************************************************************
 *
 *  $Revision: 1.2 $
 *  $Date: 2003/03/25 20:42:32 $
 *  $Source: 
 *
 **************************************************************************/

#include "osint.h"
#include "controller.h"

#ifndef BBPLAYER
s32
__osGbpakGetBank(OSPfs *pfs, u8 *bank)
{
  s32	ret;
  u32	temp[BLOCKSIZE/4];

  ret =  __osContRamRead(pfs->queue, pfs->channel, GB_GBBANK_ADDR, (u8 *)temp);
  if (ret == PFS_ERR_NEW_PACK) {
    ret = osGbpakInit(pfs->queue, pfs, pfs->channel);
    if (ret == 0) {
      ret =  __osContRamRead(pfs->queue, pfs->channel, GB_GBBANK_ADDR,
			     (u8 *)temp);
      if (ret == PFS_ERR_NEW_PACK) {
	ret = PFS_ERR_CONTRFAIL;
      }
    }
  }
  if ( ret == 0 ) {
    *bank = ((u8 *)temp)[0];
    pfs->banks = *bank;	/* GB BANK */
  }
  return(ret);
}
#endif