Пример #1
0
void armboard::LCD::init( void ){
         
   // avoid recursive initialisations, so clear the flag now!
   _clcd_must_init = 0;
         
   // the pins we need must be outputs
   d4.direction_set_output();
   d5.direction_set_output();
   d6.direction_set_output();
   d7.direction_set_output();
   e.direction_set_output();
   rs.direction_set_output();
         
   // give LCD time to wake up
   e.set( 0 );
   wait( 50 MS ); // was 20
         
   // interface initialisation: make sure the LCD is in 4 bit mode
   // (magical sequence, taken from the HD44780 datasheet)
   write4( 0x03 );
   wait( 5 MS );
   write4( 0x03 );
   wait( 100 US );
   write4( 0x03 );
   write4( 0x02 );     // 4 bit mode
         
   // functional initialisation
   command( 0x28 );    // 4 bit mode, 2 lines, 5x8 font
   command( 0x0C );    // display on, no cursor, no blink
   clear();            // clear display, 'cursor' home
   goto_xy( 0, 0 );    // 'cursor' home
}            
Пример #2
0
static void CreateVOBUAD(FILE *h, const struct vobgroup *va)
/* outputs a VOBU_ADMAP structure containing pointers to all VOBUs. */
  {
    int i, j, nv;
    unsigned char buf[16];
    nv = 0;
    for (i = 0; i < va->numvobs; i++)
        nv += va->vobs[i]->numvobus;
    write4(buf, nv * 4 + 3); /* end address (last byte of last entry) */
    nfwrite(buf, 4, h);
    for (j = 0; j < va->numvobs; j++)
      {
        const struct vob * const thisvob = va->vobs[j];
        for (i = 0; i < thisvob->numvobus; i++)
          {
            write4(buf, thisvob->vobu[i].sector); /* starting sector of VOBU within VOB */
            nfwrite(buf, 4, h);
          } /*for*/
      } /*for*/
    i = (-(4 + nv * 4)) & 2047;
    if (i)
      {
      /* zero out unused part of last whole sector */
        memset(buf, 0, 16);
        while (i >= 16)
          {
            nfwrite(buf, 16, h);
            i -= 16;
          } /*while*/
        if (i)
            nfwrite(buf, i, h);
      } /*if*/
  } /*CreateVOBUAD*/
void save_array(float *arr, char *s, int ndim, int *dim)
{
        register int i,size;
        FILE *f;
        
/*	if(ndim>1)
	printf("save_array WARNING: data may be lost if not contingent!\n");
*/
        size = 1;
        for( i=0; i<ndim; i++ )
                size *= dim[i];
        
        if (! (f = fopen(s,"w")))
                abort("can't open file");

        write4(f, BINARY_MATRIX);
        write4(f, (long)(ndim));
        for (i=0; i<ndim; i++ )
                write4(f, (long)(dim[i]));
        while(i++<3)
                write4(f, (long)1 );            /* SN1 compatibility */
                
        if (fwrite( arr, sizeof(float), size, f) != size)
                abort("can't write data");
        fflush(f);
        if (ferror(f))
                abort("can't flush file");
        fclose(f);
}
void save_matrix2(float **arr, char *s, int dim0, int dim1)
{
  int dim[2];
  int ndim = 2;
  int write_size;
  register int i;
  FILE *f;

  dim[0] = dim0;
  dim[1] = dim1;

  if (! (f = fopen(s,"w")))
    abort("can't open file");

  write4(f, BINARY_MATRIX);
  write4(f, (long)(ndim));
  for (i=0; i<ndim; i++ )
    write4(f, (long)(dim[i]));
  while(i++<3)
    write4(f, (long)1 );            /* SN1 compatibility */

  for(i=0;i<dim[0];i++){
    write_size = fwrite(arr[i], sizeof(float), dim[1], f);
    if (write_size != dim[1])
      abort("can't write data: column length inconsistency"); 
  }

  fflush(f);
  if (ferror(f))
    abort("can't flush file");
  fclose(f);
}
Пример #5
0
void GMD1602::command(uint8_t command) {
	lo(RS);
	lo(RW);

	write4(command);
	delayTimer.uDelay(50);
	write4(command << 4);
	delayTimer.uDelay(50);
}
Пример #6
0
void GMD1602::data(uint8_t data) {
	lo(RW);
	hi(RS);

	write4(data);
	delayTimer.uDelay(50);
	write4(data << 4);

	delayTimer.uDelay(50);
}
void save_ascii_matrix2(float **arr, char *s, int dim0, int dim1)
{
  register int i,j;
  double x;
  FILE *f;
  int dim[2];
  int ndim = 2;

  dim[0] = dim0;
  dim[1] = dim1;
        

  if (! (f = fopen(s,"w")))
    abort("can't open file");
    
  write4(f, ASCII_MATRIX);
  fprintf(f, " %d", ndim);
  for (i=0; i<ndim; i++ )
    fprintf(f, " %d", dim[i]);
  fprintf(f, "\n");
      
  for (i=0;i<dim[0];i++)
    for(j=0;j<dim[1];j++){
      x = Ftod( arr[i][j] );
      fprintf(f, "%6.4f\n",x);
    }
  fflush(f);
  if (ferror(f))
    abort("can't flush file");
  fclose(f);
}
void save_ascii_array(float *arr, char *s, int ndim, int *dim)
{
        register int i,size;
        double x;
        FILE *f;
        

        size = 1;
        for( i=0; i<ndim; i++ )
                size *= dim[i];
        
        if (! (f = fopen(s,"w")))
                abort("can't open file");
        
        write4(f, ASCII_MATRIX);
        fprintf(f, " %d", ndim);
        for (i=0; i<ndim; i++ )
                fprintf(f, " %d", dim[i]);
        fprintf(f, "\n");
        
        for (i=0;i<size;i++)
        {       
                x = Ftod( arr[i] );
                fprintf(f, "%6.4f\n",x);
        }
        fflush(f);
        if (ferror(f))
                abort("can't flush file");
        fclose(f);
}
Пример #9
0
static inline void
clear_bit(struct fsl_sdhc_softc *sc, uint32_t offset, uint32_t mask)
{
	uint32_t x = read4(sc, offset);

	write4(sc, offset, x & ~mask);
}
Пример #10
0
static void
init_controller(struct fsl_sdhc_softc *sc)
{

	/* Enable interrupts. */
#ifdef FSL_SDHC_NO_DMA
	write4(sc, SDHC_IRQSTATEN, MASK_IRQ_ALL & ~IRQ_DINT & ~IRQ_DMAE);
	write4(sc, SDHC_IRQSIGEN, MASK_IRQ_ALL & ~IRQ_DINT & ~IRQ_DMAE);
#else
	write4(sc, SDHC_IRQSTATEN, MASK_IRQ_ALL & ~IRQ_BRR & ~IRQ_BWR);
	write4(sc, SDHC_IRQSIGEN, MASK_IRQ_ALL & ~IRQ_BRR & ~IRQ_BWR);

	/* Write DMA address */
	write4(sc, SDHC_DSADDR, sc->dma_phys);

	/* Enable snooping and fix for AHB2MAG bypass. */
	write4(sc, SDHC_DCR, DCR_SNOOP | DCR_AHB2MAG_BYPASS);
#endif
	/* Set data timeout. */
	set_bit(sc, SDHC_SYSCTL, 0xe << SHIFT_DTOCV);

	/* Set water-mark levels (FIFO buffer size). */
	write4(sc, SDHC_WML, (FSL_SDHC_FIFO_BUF_WORDS << 16) |
	    FSL_SDHC_FIFO_BUF_WORDS);
}
Пример #11
0
/*
 *   Write an enumerator ID 
 */
void CTcDataStream::write_enum_id(ulong enum_id)
{
    /* if there's a fixup list, add this reference */
    if (G_keep_enumfixups)
        CTcIdFixup::add_fixup(&G_enumfixup, this, get_ofs(), enum_id);

    /* write the ID */
    write4(enum_id);
}
Пример #12
0
/*
 *   Write an offset value to the given label 
 */
void CTcCodeStream::write_ofs(CTcCodeLabel *lbl, int bias, int is_long)
{
    /* if the label is known, write it; otherwise, generate a fixup */
    if (lbl->is_known)
    {
        long diff;
        
        /* 
         *   calculate the branch offset from the current position,
         *   applying the bias to the current position 
         */
        diff = lbl->ofs - (ofs_ + bias);

        /* convert the offset to the correct format and write it out */
        if (is_long)
            write4(diff);
        else
            write2(diff);
    }
    else
    {
        CTcLabelFixup *fixup;

        /* allocate a fixup */
        fixup = alloc_fixup();

        /* set up the fixup data */
        fixup->ofs = ofs_;
        fixup->bias = bias;
        fixup->is_long = is_long;

        /* link the fixup into the label's fixup list */
        fixup->nxt = lbl->fhead;
        lbl->fhead = fixup;

        /* write a placeholder to the code stream */
        if (is_long)
            write4(0);
        else
            write2(0);
    }
}
Пример #13
0
Uint32 MessageOut::addCRC(){
	CRC32 msgCRC;
	Uint32 crc;

	msgCRC.Init();
	crc = msgCRC.GetCRC(this->myData, (this->pos));

	write4(crc);

	return crc;
}
Пример #14
0
bool set_slot_locked_and_temp (int fd)
{

  uint8_t slot_locked[4] = { 0xFF, 0xFF, 0x00, 0x00};
  uint8_t temp[4] = {0x00, 0x00, 0x00, 0x00};
  uint8_t addr = 0x16;

  uint32_t to_write = 0;

  memcpy (&to_write, slot_locked, sizeof(slot_locked));

  bool result = write4 (fd, CONFIG_ZONE, addr, to_write);
  if (result)
    {
      memcpy (&to_write, temp, sizeof(temp));
      result = write4 (fd, CONFIG_ZONE, addr + 1, to_write);
    }

  return result;

}
Пример #15
0
/*
 *   Write an object ID 
 */
void CTcDataStream::write_obj_id(ulong obj_id)
{
    /* 
     *   if there's an object ID fixup list, and this is a valid object
     *   reference (not a 'nil' reference), add this reference 
     */
    if (G_keep_objfixups && obj_id != TCTARG_INVALID_OBJ)
        CTcIdFixup::add_fixup(&G_objfixup, this, get_ofs(), obj_id);

    /* write the ID */
    write4(obj_id);
}
void save_packed_matrix2(float **arr, char *s, int dim0, int dim1)
{
  int dim[2];
  int ndim = 2;
  register int i, j;
  FILE *f;
  double x;
  unsigned char b;
 
  dim[0] = dim0;
  dim[1] = dim1;

  if (! (f = fopen(s,"w")))
    abort("can't open file");

  write4(f, PACKED_MATRIX);
  write4(f, (long)(ndim));
  for (i=0; i<ndim; i++ )
    write4(f, (long)(dim[i]));
  while(i++<3)
    write4(f, (long)1 );            /* SN1 compatibility */

  for(i=0;i<dim[0];i++)
    for(j=0;j<dim[1];j++){
                x = Ftod( arr[i][j] );                
                if (x >= 8.0)
                        b = 0x7f;
                else if (x <= -8.0)
                        b = 0x80;
                else
                        b = ( (int)(16.0 * x) & 0xff );
                        
                if (fwrite( &b, sizeof(b), 1, f) != 1)
                        abort("can't write bytes");
    }
  fflush(f);
  if (ferror(f))
    abort("can't flush file");
  fclose(f);
}
void save_packed_array(float *arr, char *s, int ndim, int *dim)
{
        register int i,size;
        double x;
        unsigned char b;
        FILE *f;
        
        size = 1;
        for( i=0; i<ndim; i++ )
                size *= dim[i];
        
        if (! (f = fopen(s,"w")))
                abort("can't open file");
        
        write4(f, PACKED_MATRIX);
        write4(f, (long)(ndim));
        for (i=0; i<ndim; i++ )
                write4(f, (long)(dim[i]));
        while(i++<3)
                write4(f, (long)1 );            /* SN1 compatibility */
        
        for (i=0; i<size; i++)
        {       
                x = Ftod( arr[i] );
                
                if (x >= 8.0)
                        b = 0x7f;
                else if (x <= -8.0)
                        b = 0x80;
                else
                        b = ( (int)(16.0 * x) & 0xff );
                        
                if (fwrite( &b, sizeof(b), 1, f) != 1)
                        abort("can't write bytes");
        }
        fflush(f);
        if (ferror(f))
                abort("can't flush file");
        fclose(f);
}
Пример #18
0
/*
 *   Write an object ID self-reference 
 */
void CTcDataStream::write_obj_id_selfref(CTcSymObj *obj_sym)
{
    /* 
     *   Add a fixup list entry to the symbol.  This type of reference
     *   must be kept with the symbol rather than in the global list,
     *   because we must apply this type of fixup each time we renumber
     *   the symbol. 
     */
    obj_sym->add_self_ref_fixup(this, get_ofs());

    /* write the ID to the stream */
    write4(obj_sym->get_obj_id());
}
Пример #19
0
static void storage_serialize(at **pp, int code)
{
   storage_t *st;
   int type, kind;
   size_t size;

   if (code != SRZ_READ) {
      st = Mptr(*pp);
      type = (int)st->type;
      kind = (int)st->kind;
      size = st->size;
   }
   // Read/write basic info
   serialize_int(&type, code);
   serialize_int(&kind, code);
   serialize_size(&size, code);

   // Create storage if needed
   if (code == SRZ_READ) {
      st = new_storage_managed((storage_type_t)type, size, NIL);
      *pp = st->backptr;
   }

   // Read/write storage data
   st = Mptr(*pp);
   if (type == ST_AT) {
      at **data = st->data;
      for (int i=0; i<size; i++)
         serialize_atstar( &data[i], code);

   } else  {
      FILE *f = serialization_file_descriptor(code);
      if (code == SRZ_WRITE) {
         extern int in_bwrite;
         in_bwrite += sizeof(int) + size * storage_sizeof[type];
         write4(f, STORAGE_NORMAL);
         storage_save(st, f);
         
      } else if (code == SRZ_READ) {
         int magic = read4(f);
         storage_load(st, f);
         if (magic == STORAGE_SWAPPED)
            swap_buffer(st->data, size, storage_sizeof[type]);
         else if (magic != STORAGE_NORMAL)
            RAISEF("Corrupted binary file",NIL);
      }
   }
}
Пример #20
0
void OutBuffer::writenl()
{
#if _WIN32
#if M_UNICODE
    write4(0x000A000D);         // newline is CR,LF on Microsoft OS's
#else
    writeword(0x0A0D);          // newline is CR,LF on Microsoft OS's
#endif
#else
#if M_UNICODE
    writeword('\n');
#else
    writeByte('\n');
#endif
#endif
}
Пример #21
0
bool set_config_zone (int fd)
{
  bool result = false;

  if (lca_is_config_locked (fd))
    return true;

  enum config_slots slots[CONFIG_SLOTS_NUM_SLOTS] = {slot0, slot2, slot4,
                                                     slot6, slot8, slot10,
                                                     slot12, slot14};

  struct slot_config ** configs = build_slot_configs();

  int x = 0;

  const uint8_t I2C_ADDR_OTP_MODE_SELECTOR_MODE [] =
    { 0xC0, 0x00, 0xAA, 0x00 };
  const uint8_t I2C_ADDR_ETC_WORD = 0x04;

  uint32_t to_send = 0;
  memcpy (&to_send, &I2C_ADDR_OTP_MODE_SELECTOR_MODE, sizeof (to_send));

  result = write4 (fd, CONFIG_ZONE, I2C_ADDR_ETC_WORD,to_send);

  for (x=0; x < CONFIG_SLOTS_NUM_SLOTS && result; x++)
    {
      int slot = 2 * x;
      result = write_slot_configs (fd, slots[x],
                                   configs[slot], configs[slot+1]);
    }

  free_slot_configs (configs);

  /* Set the Slot Locked and Temperature offset */
  if (result)
    {
      if ((result = set_slot_locked_and_temp (fd)))
        {
          LCA_LOG (DEBUG, "slot lock config passed");
          result = set_key_config (fd);
        }
    }

  return result;

}
Пример #22
0
void GMD1602::init() {
	GPIO_InitTypeDef  gpioInitStruct;

	// Enable the GPIO_LED Clock
	RCC_AHB1PeriphClockCmd(GPIOB_BASE, ENABLE);

	// Configure the GPIO pin
	gpioInitStruct.GPIO_Pin = E | RS | RW | D4 | D5 | D6 | D7;
	gpioInitStruct.GPIO_Mode = GPIO_Mode_OUT;
	gpioInitStruct.GPIO_OType = GPIO_OType_PP;
	gpioInitStruct.GPIO_PuPd = GPIO_PuPd_UP;
	gpioInitStruct.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_Init(gpio, &gpioInitStruct);


	// Wait until LCD gets ready
	delayTimer.mDelay(100);

	lo(RW);
	lo(RS);

	// Extra init for clod start ??????
	command(LCD_FUNCTIONSET | LCD_2LINE | LCD_5x8DOTS | LCD_4BITMODE);


	// Wait until LCD gets ready
	delayTimer.mDelay(40);


	write4(LCD_4BITMODE);
	delayTimer.mDelay(40);


	command(LCD_FUNCTIONSET | LCD_2LINE | LCD_5x8DOTS | LCD_4BITMODE);
	delayTimer.mDelay(100);

	command(LCD_DISPLAYCONTROL | LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF);
	delayTimer.mDelay(100);
}
Пример #23
0
bool write_slot_configs (int fd, enum config_slots slot,
                         struct slot_config *s1, struct slot_config *s2)
{

  uint8_t addr = get_slot_addr (slot);
  uint32_t to_send;
  uint8_t *p = (uint8_t *)&to_send;
  bool result = false;

  assert (NULL != s1);
  assert (NULL != s2);


  serialize_slot_config (s1, p);
  p += 2;
  serialize_slot_config (s2, p);

  result = write4 (fd, CONFIG_ZONE, addr, to_send);

  return result;


}
Пример #24
0
void TocGen(const struct workset *ws, const struct pgc *fpc, const char *fname)
  /* writes the IFO for a VMGM. */
  {
    static unsigned char buf[2048];
    int nextsector, offset, i, j, vtsstart;
    const bool forcemenus = needmenus(ws->menus);
    FILE *h;

    h = fopen(fname, "wb");

    memset(buf, 0, 2048);
    memcpy(buf, "DVDVIDEO-VMG", 12);
    buf[0x21] = 0x11; /* version number */
    buf[0x27] = 1; /* number of volumes */
    buf[0x29] = 1; /* volume number */
    buf[0x2a] = 1; /* side ID */
    write2(buf + 0x3e, ws->titlesets->numvts); /* number of title sets */
    strncpy((char *)(buf + 0x40), PACKAGE_STRING, 31); /* provider ID */
    buf[0x86] = 4; /* start address of FP_PGC = 0x400 */
    nextsector = 1;

    write4(buf + 0xc4, nextsector); /* sector pointer to TT_SRPT (table of titles) */
    nextsector += Create_TT_SRPT(0, ws->titlesets, 0);
      /* just to figure out how many sectors will be needed */

    if (jumppad || forcemenus)
      {
        write4(buf + 0xc8, nextsector); /* sector pointer to VMGM_PGCI_UT (menu PGC table) */
        nextsector += CreatePGC(0, ws, VTYPE_VMGM);
      } /*if*/

    write4(buf + 0xd0, nextsector);
      /* sector pointer to VMG_VTS_ATRT (copies of VTS audio/subpicture attrs) */
      /* I will output it immediately following IFO header */
    nextsector += (8 + ws->titlesets->numvts * 0x30c + 2047) / 2048;
      /* round up size of VMG_VTS_ATRT to whole sectors */

    if (jumppad || forcemenus)
      {
        write4(buf + 0xd8, nextsector);
          /* sector pointer to VMGM_C_ADT (menu cell address table) */
          /* I make it follow VMG_VTS_ATRT */
        nextsector += CreateCellAddressTable(0, ws->menus->vg); /* how much room it will need */

        write4(buf + 0xdc, nextsector);
          /* sector pointer to VMGM_VOBU_ADMAP (menu VOBU address map) */
        nextsector += numsectVOBUAD(ws->menus->vg);
      } /*if*/

    write4(buf + 0x1c, nextsector - 1); /* last sector of IFO */
    vtsstart = nextsector * 2; /* size of two copies of everything above including BUP */
    if (jumppad || forcemenus)
      {
        write4(buf + 0xc0, nextsector); /* start sector of menu VOB */
        vtsstart += getvoblen(ws->menus->vg);
      } /*if*/
    write4(buf + 0xc, vtsstart - 1); /* last sector of VMG set (last sector of BUP) */

    if (forcemenus)
        BuildAVInfo(buf + 256, ws->menus->vg);

  /* create FPC at 0x400 as promised */
    buf[0x407] = (getratedenom(ws->menus->vg) == 90090 ? 3 : 1) << 6;
      // only set frame rate XXX: should check titlesets if there is no VMGM menu
    buf[0x4e5] = 0xec; /* offset to command table, low byte */
    offset = 0x4f4; /* commands start here, after 8-byte header of command table */
    if (fpc)
      {
        unsigned char *pi;
        if (fpc->posti || fpc->numsources || fpc->numbuttons || fpc->entries)
          {
            fprintf(stderr,"ERR:  FPC can ONLY contain prei commands, nothing else\n");
            exit(1);
          } /*if*/
        if (ws->menus && ws->menus->numgroups)
            pi = vm_compile(buf + offset, buf + offset, ws, ws->menus->groups[0].pg, 0, fpc->prei, 2);
              // XXX: just use the first pgcgroup as a reference
        else
            pi = vm_compile(buf + offset, buf + offset, ws, 0, 0, fpc->prei, 2);
        if (!pi)
          {
            fprintf(stderr,"ERR:  in FPC\n");
            exit(1);
          } /*if*/
        offset = (pi - buf - offset) / 8; /* number of instructions */
        assert(offset <= 128);
        buf[0x4ed] = offset; /* number of pre commands, low byte */
      }
    else
      {
      /* generate default FPC */
        if (forcemenus)
          {
            buf[offset + 0] = 0x30; // jump to VMGM 1
            buf[offset + 1] = 0x06;
            buf[offset + 2] = 0x00;
            buf[offset + 3] = 0x00;
            buf[offset + 4] = 0x00;
            buf[offset + 5] = 0x42;
            buf[offset + 6] = 0x00;
            buf[offset + 7] = 0x00;
          }
        else if (ws->titlesets->numvts && ws->titlesets->vts[0].hasmenu)
          {
            buf[offset + 0] = 0x30; // jump to VTSM vts=1, ttn=1, menu=1
            buf[offset + 1] = 0x06;
            buf[offset + 2] = 0x00;
            buf[offset + 3] = 0x01;
            buf[offset + 4] = 0x01;
            buf[offset + 5] = 0x83;
            buf[offset + 6] = 0x00;
            buf[offset + 7] = 0x00;
          }
        else
          {
            buf[offset + 0] = 0x30; // jump to title 1
            buf[offset + 1] = 0x02;
            buf[offset + 2] = 0x00;
            buf[offset + 3] = 0x00;
            buf[offset + 4] = 0x00;
            buf[offset + 5] = 0x01;
            buf[offset + 6] = 0x00;
            buf[offset + 7] = 0x00;
          } /*if*/
        buf[0x4ed] = 1; /* number of pre commands, low byte */
      } /*if*/
    write2(buf + 0x4f2, 7 + buf[0x4ed] * 8); /* end address relative to command table */
    write2(buf + 0x82 /* end byte address, low word, of VMGI_MAT */, 0x4ec + read2(buf + 0x4f2));
    nfwrite(buf, 2048, h);

    Create_TT_SRPT(h, ws->titlesets, vtsstart); /* generate it for real */

    // PGC
    if (jumppad || forcemenus)
        CreatePGC(h, ws, VTYPE_VMGM);

  /* VMG_VTS_ATRT contains copies of menu and title attributes from all titlesets */
  /* output immediately following IFO header, as promised above */
    memset(buf, 0, 2048);
    j = 8 + ws->titlesets->numvts * 4;
    write2(buf, ws->titlesets->numvts); /* number of titlesets */
    write4(buf + 4, ws->titlesets->numvts * 0x30c + 8 - 1); /* end address (last byte of last VTS_ATRT) */
    for (i = 0; i < ws->titlesets->numvts; i++)
        write4(buf + 8 + i * 4, j + i * 0x308); /* offset to VTS_ATRT i */
    nfwrite(buf, j, h);
    for (i = 0; i < ws->titlesets->numvts; i++) /* output each VTS_ATRT */
      {
        write4(buf, 0x307); /* end address */
        memcpy(buf + 4, ws->titlesets->vts[i].vtscat, 4);
          /* VTS_CAT (copy of bytes 0x22 .. 0x25 of VTS IFO) */
        memcpy(buf + 8, ws->titlesets->vts[i].vtssummary, 0x300);
          /* copy of VTS attributes (bytes 0x100 onwards of VTS IFO) */
        nfwrite(buf, 0x308, h);
        j += 0x308;
      } /*for*/
    j = 2048 - (j & 2047);
    if (j < 2048)
      { /* pad to next whole sector */
        memset(buf, 0, j);
        nfwrite(buf, j, h);
      } /*if*/

    if (jumppad || forcemenus)
      {
        CreateCellAddressTable(h, ws->menus->vg); /* actually generate VMGM_C_ADT */
        CreateVOBUAD(h, ws->menus->vg); /* generate VMGM_VOBU_ADMAP */
      } /*if*/
    fflush(h);
    if (errno != 0)
      {
        fprintf(stderr, "\nERR:  Error %d -- %s -- flushing VMGM\n", errno, strerror(errno));
        exit(1);
      } /*if*/
    fclose(h);
  } /*TocGen*/
Пример #25
0
static void WriteIFO(FILE *h, const struct workset *ws)
  /* writes the IFO for a VTSM. */
  {
    static unsigned char buf[2048];
    int nextsector;
    const bool forcemenus = needmenus(ws->menus);

    // sect 0: VTS toplevel
    memset(buf, 0, 2048);
    memcpy(buf, "DVDVIDEO-VTS", 12);
    buf[33] = 0x11; /* version number */
    write4(buf + 128, 0x7ff);
    nextsector = 1;

    write4(buf + 0xC8, nextsector); // VTS_PTT_SRPT
    nextsector += Create_PTT_SRPT(0, ws->titles);

    write4(buf + 0xCC, nextsector); // VTS_PGCI
    nextsector += CreatePGC(0, ws, VTYPE_VTS);

    if (jumppad || forcemenus)
      {
        write4(buf + 0xD0,nextsector); // VTSM_PGCI
        nextsector += CreatePGC(0, ws, VTYPE_VTSM);
      } /*if*/

    write4(buf + 0xD4, nextsector); // VTS_TMAPT
    nextsector += numsectTMAPT(ws->titles);

    if (jumppad || forcemenus)
      {
        write4(buf + 0xD8, nextsector); // VTSM_C_ADT
        nextsector += CreateCellAddressTable(0, ws->menus->vg);

        write4(buf + 0xDC, nextsector); // VTSM_VOBU_ADMAP
        nextsector += numsectVOBUAD(ws->menus->vg);
      } /*if*/

    write4(buf + 0xE0, nextsector); // VTS_C_ADT
    nextsector += CreateCellAddressTable(0, ws->titles->vg);

    write4(buf + 0xE4, nextsector); // VTS_VOBU_ADMAP
    nextsector += numsectVOBUAD(ws->titles->vg);

    write4(buf + 28, nextsector - 1); /* last sector of IFO */
    if (jumppad || forcemenus)
      {
        write4(buf + 0xC0, nextsector); /* start sector of menu VOB */
        nextsector += getvoblen(ws->menus->vg);
      } /*if*/
    write4(buf + 0xC4, nextsector); /* start sector of title VOB */
    if (ws->titles->numpgcs)
        nextsector += getvoblen(ws->titles->vg);
    nextsector += read4(buf + 28); /* offset by last sector of IFO */
    write4(buf + 12, nextsector); /* gives last sector of title set (last sector of BUP) */

    if (jumppad || forcemenus)
        BuildAVInfo(buf + 256, ws->menus->vg);
    BuildAVInfo(buf + 512, ws->titles->vg);
    nfwrite(buf, 2048, h);

    // sect 1: VTS_PTT_SRPT
    Create_PTT_SRPT(h, ws->titles);
   
    // sect 2: VTS_PGCI
    CreatePGC(h, ws, VTYPE_VTS);

    if( jumppad || forcemenus )
        CreatePGC(h, ws, VTYPE_VTSM);

    // sect 3: ??? VTS_TMAPT
    CreateTMAPT(h, ws->titles);

    if (jumppad || forcemenus)
      {
        CreateCellAddressTable(h, ws->menus->vg);
        CreateVOBUAD(h, ws->menus->vg);
      } /*if*/
    CreateCellAddressTable(h, ws->titles->vg);
    CreateVOBUAD(h, ws->titles->vg);
  } /*WriteIFO*/
Пример #26
0
 inline void writeFloat(float c)             { write4((char*)&c); }
Пример #27
0
 inline void writeUInt(unsigned int c)       { write4((char*)&c); }
Пример #28
0
 inline void writeInt(int c)                 { write4((char*)&c); }
Пример #29
0
void DataFile::write4(const void * src, ULONG len){
	UI4 * s = (UI4 *)src;
	for(ULONG i=0; i<len; i++) write4(s + i);
}
Пример #30
0
void armboard::LCD::write8( unsigned char isData, unsigned char b ){
   if( _clcd_must_init ){ init(); }
   rs.set( isData );
   write4( b >> 4 );
   write4( b );
}