static libspectrum_error
pure_data_init( libspectrum_tape_pure_data_block *block,
                libspectrum_tape_pure_data_block_state *state )
{
  libspectrum_error error;

  /* We're just before the start of the data */
  state->bytes_through_block = -1; state->bits_through_byte = 7;
  /* Set up the next bit */
  error = libspectrum_tape_pure_data_next_bit( block, state );
  if( error ) return error;

  return LIBSPECTRUM_ERROR_NONE;
}
Esempio n. 2
0
static libspectrum_error
pure_data_edge( libspectrum_tape_pure_data_block *block,
                libspectrum_tape_pure_data_block_state *state,
		libspectrum_dword *tstates, int *end_of_block )
{
  int error;

  switch( state->state ) {

  case LIBSPECTRUM_TAPE_STATE_DATA1:
    /* The first edge for a bit of data */
    *tstates = state->bit_tstates;
    /* Followed by the second edge */
    state->state = LIBSPECTRUM_TAPE_STATE_DATA2;
    break;

  case LIBSPECTRUM_TAPE_STATE_DATA2:
    /* The second edge for a bit of data */
    *tstates = state->bit_tstates;
    /* Followed by the next bit of data (or the end of data) */
    error = libspectrum_tape_pure_data_next_bit( block, state );
    if( error ) return error;
    break;

  case LIBSPECTRUM_TAPE_STATE_PAUSE:
    /* The pause at the end of the block */
    *tstates = (block->pause * 69888)/20; /* FIXME: should vary with tstates
					     per frame */
    *end_of_block = 1;
    break;

  default:
    libspectrum_print_error( LIBSPECTRUM_ERROR_LOGIC,
			     "pure_data_edge: unknown state %d",
			     state->state );
    return LIBSPECTRUM_ERROR_LOGIC;

  }

  return LIBSPECTRUM_ERROR_NONE;
}