#include  "sega_per.h"
#define   BUP_START_ADDR 0x60????0   /* Specifying the address to load the library */
#include  "sega_bup.h"
Uint32    BackUpRamWork[2048+30];     /* 2048=Block access table */
                                      /*   30=Backup library variable area */
main()
{
  BupConfig  conf[3];
  BupStat  sttb;
  BupDir  writetb;
  BupDate  datatb;
  Uint8  *time;
  PER_SMPC_RES_DIS();                  /* Reset button disabled  */
  BUP_Init(BUP_START_ADDR, BackUpRamWork, conf);
  if(BUP_Stat(0, &sttb)==BUP_UNFORMAT){
     BUP_Format(0);
  }
  PER_SMPC_RES_ENA();                  /* Reset button enabled  */
  BUP_Stat(0, &sttb);
  if(sttb.freeblock > 0){
     strcpy((char *)writetb.filename, "FILE_NAME01");
     strcpy((char *)writetb. comment, "テスト");  /* Write "test" in Japanese */
     writetb.language = BUP_JAPANESE;
     time = PER_GET_TIM();            /* Get date and time  */
     datetb.year = (Uint8 )( (Uint16 )(time[6]>>4) * 1000
           + (Uint16 )(time[6] & 0x0F) * 100
           + (Uint16 )(time[5]>>4)  * 10
           + (Uint16 )(time[5] & 0x0F) - 1980);
     datetb.month = time[4] & 0x0F;
     datetb.day   = (time[3]>>4)*10 + (time[3] & 0x0F);
     datetb.time  = (time[2]>>4)*10 + (time[2] & 0x0F);
     datetb.min   = (time[1]>>4)*10 + (time[1] & 0x0F);
     writetb.date = BUP_SetDate(&datetb);
     writetb.datasize = 10;
     PER_SMPC_RES_DIS();              /* Reset button disabled  */
     BUP_Write(0, &writetb, "Dummy Data");
     PER_SMPC_RES_ENA();              /* Reset button enabled  */
  }
}