示例#1
0
/*
Fill boxes for fast neighborhood search.
x: time series (scaled between 0 and 1)
m, d: embedding dimension and time delay
blength: total number of points in the embedding space
eps: neighborhood size
jh: a BOX*BOX array, i.e., the boxes histogram
jpntr: the boxes pointers
*/
void fill_boxes(double *x, int m, int d, int blength, double eps, int **jh, int *jpntr) {
	int i, j, binx, biny, offset;
	int next;

	offset = (m-1)*d;
	for (i=0; i<BOX; i++)
		for (j=0; j<BOX; j++)
			jh[i][j]=0;
	for (i=0; i<blength; i++) {
		binx = BIN(x, i, eps);
		biny = BIN(x, i+offset, eps);
		jh[binx][biny] ++;
	}
	for (i=0; i<(BOX*BOX-1); i++) {
		next = i+1;
		jh[(next - (next % BOX)) / BOX ][next % BOX] += 
			jh[(i - (i % BOX) ) / BOX ][i % BOX];
	}

	for (i=0; i<blength; i++) {
		binx = BIN(x, i, eps);
		biny = BIN(x, i+offset, eps);
		jpntr[--jh[binx][biny]] = i;
	}
}
static void
write_opcodes ()
{
  int i = 0, j = 0, k;
  
  /* write out opcode table.  */
  printf ("#include \"cr16_sim.h\"\n");
  printf ("#include \"simops.h\"\n\n");
  printf ("struct simops Simops[] = {\n");
  
  for (i = NUMOPCODES-1; i >= 0; --i)
    {
      if (cr16_instruction[i].size != 0)
{
           printf ("  { \"%s\", %ld, %d, %d, %d, \"OP_%X_%X\", OP_%X_%X, ", 
                    cr16_instruction[i].mnemonic, cr16_instruction[i].size, 
                    cr16_instruction[i].match_bits, cr16_instruction[i].match,
                     cr16_instruction[i].flags, ((BIN(cr16_instruction[i].match, cr16_instruction[i].match_bits))>>(cr16_instruction[i].match_bits)),
             (32 - cr16_instruction[i].match_bits),
                     ((BIN(cr16_instruction[i].match, cr16_instruction[i].match_bits))>>(cr16_instruction[i].match_bits)), (32 - cr16_instruction[i].match_bits));
      
  j = 0;
  for (k=0;k<5;k++)
    {
      if (cr16_instruction[i].operands[k].op_type == dummy)
                break;
              else
                j++;
    }
  printf ("%d, ",j);
  
  j = 0;
  for (k=0;k<4;k++)
    {
      int optype = cr16_instruction[i].operands[k].op_type;
      int shift = cr16_instruction[i].operands[k].shift;
      if (j == 0)
        printf ("{");
      else
        printf (", ");
      printf ("{");
      printf ("%d,%d",optype, shift);
      printf ("}");
      j = 1;
   }
 if (j)
  printf ("}");
 printf ("},\n");
        }
    }
示例#3
0
文件: tsfm.cpp 项目: kerheol/zemu
bool C_TsFm::OutputByteCheckPort(Z80EX_WORD port)
{
	return (
		((port & MAKEWORD(BIN(0x11000000),BIN(0x00000010))) == MAKEWORD(BIN(0x11000000),BIN(0x00000000)))	// 0xFFFD
		||
		((port & MAKEWORD(BIN(0x11000000),BIN(0x00000010))) == MAKEWORD(BIN(0x10000000),BIN(0x00000000)))	// 0xBFFD
		||
		(!C_TrDos::trdos && ((port == 0x00FF) || (port == 0x01FF)))
	);
}
示例#4
0
/*
Find all neighbours of a specific point.
bs: Properly initialized boxSearch struct
t: theiler window
n: considered point
founds: indexes of found points
dists: euclidean distances of found points
nfounds: total number of neighbours found
*/
void find_nearests(boxSearch bs, int t, int n, int *founds, double *dists, int *nfounds) {
	int i, j, id, currx, start, end;
	int xbox, ybox;
	double tmpd;
	int md;
/**/
	double *x, eps;
	int m, d, blength;
	int **jh, *jpntr;
/**/

	x = bs.series;
	m = bs.m;
	d = bs.d;
	eps = bs.eps;
	blength = bs.blength;
	jh = bs.jh;
	jpntr = bs.jpntr;

	xbox = BIN(x,n,eps);		/*Grid position     */
	ybox = BIN(x, n+(m-1)*d, eps);  /*  of current point*/
	md = m*d;
	(*nfounds)=0;
	eps = sqr(eps);

	for(i=xbox-1; i<(xbox+2); i++) { /*Scan surrounding boxes*/
	if ((i<0)||(i>=BOX)) continue;   /*     ...              */
	for(j=ybox-1; j<(ybox+2); j++) { /*     ...             */
		if((j<0)||(j>=BOX)) continue; /*...              */
		start= jh[i][j];         /*Starting candidate index*/
		end  = ((j+1)==BOX) ? (blength-1): jh[i][j+1];/*Ending candidate index*/
		for(id=start; id<end; id++) { /*For all candidates..*/
			currx = jpntr[id];    /*current candidate*/
			if (abs(currx-n)<=t) continue; /*test for theiler window*/
			DIST2EPS(x, n, currx, md, d, eps, tmpd); /*compute real distance*/
			if (tmpd<eps) { /*If a real neighbour...*/
				dists[(*nfounds)++] = sqrt(tmpd); /*store distance*/
				founds[(*nfounds)-1]= currx; /*store point*/
			} /*end if a real neighbour*/
		} /*End for all candidates*/
	} /*End scan ...           */
	} /* ... surrounding boxes */
}
static void endMessageIntern()
{
  byte i;
  if (serialStatus & inSendQueueMsgBit) {  
    //test if inSendQueueMsgBit is set, otherwise it has been resetted by serialError
    
    // Send the message
    uartTransmit(SNAP_SYNC);
    crc = 0;
    uartTransmit(computeCRC(BIN(01010001)));   // Request ACK
    uartTransmit(computeCRC(BIN(00110000) | sendPacketLength));
    uartTransmit(computeCRC(sendPacketDestination));
    uartTransmit(computeCRC(deviceAddress));
    for(i = 0; i < sendPacketLength; i++)
      uartTransmit(computeCRC(sendPacket[i]));
    uartTransmit(crc); /// @todo crc here
    
    serialStatus &= ~inSendQueueMsgBit;  //clear 
  }
}
示例#6
0
文件: rtc.c 项目: ErisBlastar/osfree
void rtc_write(Bit8u reg, Bit8u byte)
{
  switch (reg) {
    case CMOS_SEC:
    case CMOS_MIN:
    case CMOS_HOUR:
    case CMOS_SECALRM:
    case CMOS_MINALRM:
    case CMOS_HOURALRM:
    case CMOS_DOW:
    case CMOS_DOM:
    case CMOS_MONTH:
    case CMOS_YEAR:
    case CMOS_CENTURY:
      SET_CMOS(reg, BIN(byte));
      break;

    /* b7=r/o and unused
     * b4-6=always 010 (AT standard 32.768kHz)
     * b0-3=rate [65536/2^v], default 6, min 3, 0=disable
     */
    case CMOS_STATUSA:
      h_printf("RTC: Write %hhx to A\n", byte);
      SET_CMOS(reg, byte & 0x7f);
      break;

    case CMOS_STATUSB:
      h_printf("RTC: Write %hhx to B\n", byte);
      SET_CMOS(reg, byte);
      break;

    case CMOS_STATUSC:
    case CMOS_STATUSD:
      h_printf("RTC: attempt to write %hhx to %hhx\n", byte, reg);
      break;

    default:
      SET_CMOS(reg, byte);
  }
  q_ticks_m = 0;
}
示例#7
0
static int
match_opcode (void)
{
  unsigned long mask;

  /* The instruction 'constant' opcode doewsn't exceed 32 bits.  */
  unsigned long doubleWord = words[1] + (words[0] << 16);

  /* Start searching from end of instruction table.  */
  instruction = &crx_instruction[NUMOPCODES - 2];

  /* Loop over instruction table until a full match is found.  */
  while (instruction >= crx_instruction)
    {
      mask = build_mask ();
      if ((doubleWord & mask) == BIN(instruction->match, instruction->match_bits))
	return 1;
      else
	instruction--;
    }
  return 0;
}
示例#8
0
文件: Common.cpp 项目: Speakus/plugy
const char* getTypeString (DWORD code)
{
	DWORD lang = 0;//D2GetLang();
	if ((lang == LNG_FRA) || (lang == LNG_DEU)) lang--;
	else lang = 0;
	switch (code)
	{
		case BIN('s','h','i','e') : return c_shie[0];
		case BIN('t','o','r','s') : return c_tors[0];
		case BIN('g','o','l','d') : return c_gold[0];
		case BIN('b','o','w','q') : return c_bowq[0];
		case BIN('x','b','o','q') : return c_xboq[0];
		case BIN('p','l','a','y') : return c_play[0];
		case BIN('h','e','r','b') : return c_herb[0];
		case BIN('p','o','t','i') : return c_poti[0];
		case BIN('r','i','n','g') : return c_ring[0];
		case BIN('e','l','i','x') : return c_elix[0];
		case BIN('a','m','u','l') : return c_amul[0];
		case BIN('c','h','a','r') : return c_char[0];
		case BIN('b','o','o','t') : return c_boot[0];
		case BIN('g','l','o','v') : return c_glov[0];
		case BIN('b','o','o','k') : return c_book[0];
		case BIN('b','e','l','t') : return c_belt[0];
		case BIN('g','e','m',' ') : return c_gem[0];
		case BIN('t','o','r','c') : return c_torc[0];
		case BIN('s','c','r','o') : return c_scro[0];
		case BIN('s','c','e','p') : return c_scep[0];
		case BIN('w','a','n','d') : return c_wand[0];
		case BIN('s','t','a','f') : return c_staf[0];
		case BIN('b','o','w',' ') : return c_bow[0];
		case BIN('a','x','e',' ') : return c_axe[0];
		case BIN('c','l','u','b') : return c_club[0];
		case BIN('s','w','o','r') : return c_swor[0];
		case BIN('h','a','m','m') : return c_hamm[0];
		case BIN('k','n','i','f') : return c_knif[0];
		case BIN('s','p','e','a') : return c_spea[0];
		case BIN('p','o','l','e') : return c_pole[0];
		case BIN('x','b','o','w') : return c_xbow[0];
		case BIN('m','a','c','e') : return c_mace[0];
		case BIN('h','e','l','m') : return c_helm[0];
		case BIN('t','p','o','t') : return c_tpot[0];
		case BIN('q','u','e','s') : return c_ques[0];
		case BIN('b','o','d','y') : return c_body[0];
		case BIN('k','e','y',' ') : return c_key[0];
		case BIN('t','k','n','i') : return c_tkni[0];
		case BIN('t','a','x','e') : return c_taxe[0];
		case BIN('j','a','v','e') : return c_jave[0];
		case BIN('w','e','a','p') : return c_weap[0];
		case BIN('m','e','l','e') : return c_mele[0];
		case BIN('m','i','s','s') : return c_miss[0];
		case BIN('t','h','r','o') : return c_thro[0];
		case BIN('c','o','m','b') : return c_comb[0];
		case BIN('a','r','m','o') : return c_armo[0];
		case BIN('s','h','l','d') : return c_shld[0];
		case BIN('m','i','s','c') : return c_misc[0];
		case BIN('s','o','c','k') : return c_sock[0];
		case BIN('s','e','c','o') : return c_seco[0];
		case BIN('r','o','d',' ') : return c_rod[0];
		case BIN('m','i','s','l') : return c_misl[0];
		case BIN('b','l','u','n') : return c_blun[0];
		case BIN('j','e','w','l') : return c_jewl[0];
		case BIN('c','l','a','s') : return c_clas[0];
		case BIN('a','m','a','z') : return c_amaz[0];
		case BIN('b','a','r','b') : return c_barb[0];
		case BIN('n','e','c','r') : return c_necr[0];
		case BIN('p','a','l','a') : return c_pala[0];
		case BIN('s','o','r','c') : return c_sorc[0];
		case BIN('a','s','s','n') : return c_assn[0];
		case BIN('d','r','u','i') : return c_drui[0];
		case BIN('h','2','h',' ') : return c_h2h[0];
		case BIN('h','2','h','2') : return c_h2h2[0];
		case BIN('o','r','b',' ') : return c_orb[0];
		case BIN('h','e','a','d') : return c_head[0];
		case BIN('a','s','h','d') : return c_ashd[0];
		case BIN('p','h','l','m') : return c_phlm[0];
		case BIN('p','e','l','t') : return c_pelt[0];
		case BIN('c','l','o','a') : return c_cloa[0];
		case BIN('r','u','n','e') : return c_rune[0];
		case BIN('c','i','r','c') : return c_circ[0];
		case BIN('h','p','o','t') : return c_hpot[0];
		case BIN('m','p','o','t') : return c_mpot[0];
		case BIN('r','p','o','t') : return c_rpot[0];
		case BIN('s','p','o','t') : return c_spot[0];
		case BIN('a','p','o','t') : return c_apot[0];
		case BIN('w','p','o','t') : return c_wpot[0];
		case BIN('s','c','h','a') : return c_scha[0];
		case BIN('m','c','h','a') : return c_mcha[0];
		case BIN('l','c','h','a') : return c_lcha[0];
		case BIN('a','b','o','w') : return c_abow[0];
		case BIN('a','s','p','e') : return c_aspe[0];
		case BIN('a','j','a','v') : return c_ajav[0];
		case BIN('m','b','o','q') : return c_mboq[0];
		case BIN('m','x','b','q') : return c_mxbq[0];
		case BIN('g','e','m','0') : return c_gem0[0];
		case BIN('g','e','m','1') : return c_gem1[0];
		case BIN('g','e','m','2') : return c_gem2[0];
		case BIN('g','e','m','3') : return c_gem3[0];
		case BIN('g','e','m','4') : return c_gem4[0];
		case BIN('g','e','m','a') : return c_gema[0];
		case BIN('g','e','m','d') : return c_gemd[0];
		case BIN('g','e','m','e') : return c_geme[0];
		case BIN('g','e','m','r') : return c_gemr[0];
		case BIN('g','e','m','s') : return c_gems[0];
		case BIN('g','e','m','t') : return c_gemt[0];
		case BIN('g','e','m','z') : return c_gemz[0];
		default: return NULL;
	}
}
void uartNotifyReceive()
{
  byte c; 

  
  c = RCREG;

  // If error occurred then reset by clearing CREN, but
  // attempt to continue processing anyway.
  /// @todo Should we do something else in this situation?
  if (OERR) {
    CREN = 0;
    //don't set the error: serialStatus |= serialErrorBit
    //because c and the next RCREG will be ok and maybe
    //we got a correct message
  }
  CREN = 1;

  if (serialStatus & serialErrorBit) {
    uartReceiveError();
    return;
  }
  

  switch(uartState) {

  // ----------------------------------------------------------------------- //
  case SNAP_idle:
    // In the idle state, we wait for a sync byte.  If none is
    // received, we remain in this state.
    if (c == SNAP_SYNC) {
      uartState = SNAP_haveSync;
      serialStatus &= ~msgAbortedBit; //clear
    }
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_haveSync:
    // In this state we are waiting for header definition bytes. First
    // HDB2.  We currently insist that all packets meet our expected
    // format which is 1 byte destination address, 1 byte source
    // address, and no protocol specific bytes.  The ACK/NAK bits may
    // be anything.
    in_hdb2 = c;
    if ((c & BIN(11111100)) != BIN(01010000)) {
      // Unsupported header.  Drop it an reset
      serialStatus |= serialErrorBit;  //set serialError
      serialStatus |= wrongByteErrorBit; 
      uartReceiveError();
    } else {
      // All is well
      if ((c & BIN(00000011)) == BIN(00000001))
	serialStatus |= ackRequestedBit;  //set ackRequested-Bit
      else
	serialStatus &= ~ackRequestedBit; //clear
      crc = 0;
      computeCRC(c);
      uartState = SNAP_haveHDB2;
    }
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_haveHDB2:
    // For HDB1, we insist on high bits are 0011 and low bits are the length 
    //   of the payload.
    in_hdb1 = c;
    if ((c & BIN(11110000)) != BIN(00110000)) {
      serialStatus |= serialErrorBit;  //set serialError
      serialStatus |= wrongByteErrorBit; 
      uartReceiveError();
    } else {
      packetLength = c & 0x0f;
      if (packetLength > MAX_PAYLOAD)
	packetLength = MAX_PAYLOAD;
      computeCRC(c);
      uartState = SNAP_haveHDB1;
    }
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_haveHDB1:
    // We should be reading the destination address now
    if (c != deviceAddress) {
      uartTransmit(SNAP_SYNC);
      uartTransmit(in_hdb2);
      uartTransmit(in_hdb1);
      uartTransmit(c);
      uartState = SNAP_haveDABPass;
      serialStatus &= ~ackRequestedBit; //clear
      serialStatus |= inTransmitMsgBit; 
    } else {
      computeCRC(c);
      uartState = SNAP_haveDAB;
    }
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_haveDAB:
    // We should be reading the source address now
    if (c == deviceAddress) {
      // If we receive a packet from ourselves, that means it went
      // around the ring and was never picked up, ie the device we
      // sent to is off-line or unavailable.

      /// @todo Deal with this situation
    }
    if (serialStatus & processingLockBit) {
      //we have not finished the last order, reject
      uartTransmit(SNAP_SYNC);
      crc = 0;
      uartTransmit(computeCRC(BIN(01010011))); //HDB2
      // HDB1: 0 bytes, with 8 bit CRC
      uartTransmit(computeCRC(BIN(00110000)));  //HDB1
      uartTransmit(computeCRC(sourceAddress));  // Return to sender
      uartTransmit(computeCRC(deviceAddress));  // From us
 //TODO: remove
 /*for debugging add serialStatus
 uartTransmit(computeCRC(BIN(00110001)));   //HDB1
 uartTransmit(computeCRC(sourceAddress));  // Return to sender
 uartTransmit(computeCRC(deviceAddress));  // From us
 uartTransmit(computeCRC(serialStatus));  // Return to sender
 */
      uartTransmit(crc);  // CRC
      serialStatus &= ~ackRequestedBit; //clear
      serialStatus |= msgAbortedBit; //set
      uartState = SNAP_idle;
    } else {
      sourceAddress = c;
      bufferIndex = 0;
      computeCRC(c);
      uartState = SNAP_readingData;
    }
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_readingData:
    buffer[bufferIndex] = c;
    bufferIndex++;
    computeCRC(c);

    if (bufferIndex == packetLength)
      uartState = SNAP_dataComplete;
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_dataComplete:
    // We should be receiving a CRC after data, and it
    // should match what we have already computed
    {
      byte hdb2 = BIN(01010000); // 1 byte addresses
      
      if (c == crc) {
	// All is good, so process the command.  Rather than calling the
	// appropriate function directly, we just set a flag to say
	// something is ready for processing.  Then in the main loop we
	// detect this and process the command.  This allows further
	// comms processing (such as passing other tokens around the
	// ring) while we're actioning the command.
	
	hdb2 |= BIN(10);
	serialStatus |= processingLockBit;  //set processingLockBit
	receivedSourceAddress = sourceAddress;
      } else {
	// CRC mismatch, so we will NAK the packet
	hdb2 |= BIN(11);
      }
      if (serialStatus & ackRequestedBit) {
	// Send ACK or NAK back to source
	uartTransmit(SNAP_SYNC);
	crc = 0;
	uartTransmit(computeCRC(hdb2));
	// HDB1: 0 bytes, with 8 bit CRC
	uartTransmit(computeCRC(BIN(00110000)));
	uartTransmit(computeCRC(sourceAddress));  // Return to sender
	uartTransmit(computeCRC(deviceAddress));  // From us
	uartTransmit(crc);  // CRC
	serialStatus &= ~ackRequestedBit; //clear
      }
    }
    uartState = SNAP_idle;
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_haveHDB2Pass:
    uartTransmit(c);  // We will be reading HDB1; pass it on
    packetLength = c & 0x0f;
    if (packetLength > MAX_PAYLOAD)
      packetLength = MAX_PAYLOAD;
    uartState = SNAP_haveHDB1Pass;
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_haveHDB1Pass:
    uartTransmit(c);  // We will be reading dest addr; pass it on
    uartState = SNAP_haveDABPass;
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_haveDABPass:
    uartTransmit(c);  // We will be reading source addr; pass it on

    // Increment data length by 1 so that we just copy the CRC
    // at the end as well.
    packetLength++;

    uartState = SNAP_readingDataPass;
    break;

  // ----------------------------------------------------------------------- //
  case SNAP_readingDataPass:
    uartTransmit(c);  // This is a data byte; pass it on
    if (packetLength > 1)
      packetLength--;
    else {
      uartState = SNAP_idle;
      serialStatus &= ~inTransmitMsgBit; //clear
    }
    break;

  default:
    serialStatus |= serialErrorBit;  //set serialError
    serialStatus |= wrongStateErrorBit;  
    uartReceiveError();
  }


}
示例#10
0
    L3G_CTRL_REG3    = 0x22,
    L3G_CTRL_REG4    = 0x23,
    L3G_CTRL_REG5    = 0x24,
    L3G_REFERENCE    = 0x25,
    L3G_OUT_TEMP     = 0x26,
    L3G_STATUS_REG   = 0x27,

    L3G_OUT_X_L      = 0x28,
    L3G_OUT_X_H      = 0x29,
    L3G_OUT_Y_L      = 0x2A,
    L3G_OUT_Y_H      = 0x2B,
    L3G_OUT_Z_L      = 0x2C,
    L3G_OUT_Z_H      = 0x2D,

    // Output data rate = 760Hz, Cut-Off (Bandwidth?)= 30Hz, all axes enabled
    CTRL_REG1_VALUE  = BIN(11001111),

    // continuos update, Data LSb, 2000 degrees per sec, I2C wire
    CTRL_REG4_VALUE  = BIN(00110000),
};


static const float coef = M_PI / 180.0 * (
    (CTRL_REG4_VALUE & BIN(110000)) == BIN(     0) ? 0.00875 : // �0 dps
    (CTRL_REG4_VALUE & BIN(110000)) == BIN( 10000) ? 0.01750 : // �0 dps
    (CTRL_REG4_VALUE & BIN(110000)) == BIN(100000) ? 0.070   : // �00 dps
    (CTRL_REG4_VALUE & BIN(110000)) == BIN(110000) ? 0.070   : // �00 dps
      bad_float());

static void write_to_reg(uint8_t reg, uint8_t value)
{
示例#11
0
文件: tsfm.cpp 项目: kerheol/zemu
bool C_TsFm::InputByteCheckPort(Z80EX_WORD port)
{
	return ((port & MAKEWORD(BIN(0x11000000),BIN(0x00000010))) == MAKEWORD(BIN(0x11000000),BIN(0x00000000)));	// 0xFFFD
}
示例#12
0
文件: tsfm.cpp 项目: kerheol/zemu
bool C_TsFm::OnOutputByte(Z80EX_WORD port, Z80EX_BYTE value)
{
	if (port == 0x00FF)
	{
		if (mode >= TSFM_MODE_ZXM) {
			saa1099Chip.WriteData(value);
		}
	}
	else if (port == 0x01FF)
	{
		if (mode >= TSFM_MODE_ZXM) {
			saa1099Chip.WriteAddress(value);
		}
	}
	else if ((port & MAKEWORD(BIN(0x11000000),BIN(0x00000010))) == MAKEWORD(BIN(0x11000000),BIN(0x00000000)))	// 0xFFFD
	{
		if ((mode >= TSFM_MODE_TS) && ((value & BIN(0x11110000)) == BIN(0x11110000)))
		{
			pseudoReg = value & 15;
			return true;
		}

		if (mode >= TSFM_MODE_TSFM)
		{
			if (value < 0x10) {
				ayChip[CHIP_NUM].Select(value);
			} else {
				ym2203Chip[CHIP_NUM].Select(value);
			}
		}
		else if (mode >= TSFM_MODE_TS)
		{
			ayChip[CHIP_NUM].Select(value);
		}
		else
		{
			ayChip[0].Select(value);
		}

		selectedReg = value;
	}
	else	// 0xBFFD
	{
		if (mode >= TSFM_MODE_TSFM)
		{
			if (selectedReg < 0x10) {
				ayChip[CHIP_NUM].Write(SOUND_ENABLED ? devClk : 0, value);
			} else {
				ym2203Chip[CHIP_NUM].Write(value);
			}
		}
		else if (mode >= TSFM_MODE_TS)
		{
			ayChip[CHIP_NUM].Write(SOUND_ENABLED ? devClk : 0, value);
		}
		else
		{
			ayChip[0].Write(SOUND_ENABLED ? devClk : 0, value);
		}
	}

	return true;
}
#if VMDEBUG > 0
#define DECL_SC_REG(type, r, reg) register type reg_##r

#elif __GNUC__ && __x86_64__
#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("r" reg)

#elif __GNUC__ && __i386__
#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("e" reg)

#else
#define DECL_SC_REG(type, r, reg) register type reg_##r
#endif
/* #define DECL_SC_REG(r, reg) VALUE reg_##r */

#if OPT_STACK_CACHING
static VALUE finish_insn_seq[1] = { BIN(finish_SC_ax_ax) };
#elif OPT_CALL_THREADED_CODE
static VALUE const finish_insn_seq[1] = { 0 };
#else
static VALUE finish_insn_seq[1] = { BIN(finish) };
#endif

#if !OPT_CALL_THREADED_CODE
static VALUE
vm_exec_core(rb_thread_t *th, VALUE initial)
{

#if OPT_STACK_CACHING
#if 0
#elif __GNUC__ && __x86_64__
    DECL_SC_REG(VALUE, a, "12");
示例#14
0
文件: main.c 项目: NodeUSB/c51drv
void main(void) {
    unsigned char i;
    unsigned char __code chn_year[] = {
        BIN(01000),
        BIN(01111),
        BIN(10010),
        BIN(01111),
        BIN(01010),
        BIN(11111),
        BIN(00010),
        BIN(00000)
    };
    unsigned char __code chn_month[] = {
        BIN(01111),
        BIN(01001),
        BIN(01111),
        BIN(01001),
        BIN(01111),
        BIN(01001),
        BIN(10011),
        BIN(00000)
    };
    unsigned char __code chn_day[] = {
        BIN(11111),
        BIN(10001),
        BIN(10001),
        BIN(11111),
        BIN(10001),
        BIN(10001),
        BIN(11111),
        BIN(00000)
    };
    unsigned char __code *p;

    welcome();

    lcd1602_init();

    /* lcd1602_entry_mode(1, 1); */
    LCD1602_SWITCH(1, 1, 1);
    /* lcd1602_switch(1, 1, 1); */

    LCD1602_POSITION(0, 0);

    for (i = 'A'; i <= 'Z'; i++) {
        lcd1602_putchar(i);
    }

    LCD1602_POSITION(8, 1);

    for (i = '0'; i <= '9'; i++) {
        lcd1602_putchar(i);
    }

    /* lcd1602_write_cgram(0, 'A'); */

    /* UARTCHAR(lcd1602_read_cgram(0)); */

    LCD1602_POSITION(0, 1);

    lcd1602_character(0, chn_year);
    lcd1602_character(1, chn_month);
    lcd1602_character(2, chn_day);

    for (p = "2013"; *p != 0; p++) {
        lcd1602_putchar(*p);
    }
    lcd1602_putchar(0);
    for (p = "10"; *p != 0; p++) {
        lcd1602_putchar(*p);
    }
    lcd1602_putchar(1);
    for (p = "10"; *p != 0; p++) {
        lcd1602_putchar(*p);
    }
    lcd1602_putchar(2);

    LCD1602_HOME();

    while (i = uart_getchar()) {
        lcd1602_putchar(i);
    }

    while (1);
}
示例#15
0
文件: labels.cpp 项目: kerheol/zemu
void Labels_Load(const char *fname)
{
	C_File fl;
	char buf[0x100];

	try
	{
		fl.Read(fname);
	}
	catch (C_E &e)
	{
		printf("Error loading labels from \"%s\"\n", fname);
		return;
	}

	printf("Load labels \"%s\"\n", fname);

	while (!fl.Eof())
	{
		fl.GetS(buf, sizeof(buf));
		if (strlen(buf) < 9) continue;

		if (ishex(buf[0]) && ishex(buf[1]) && buf[2]==':' &&
				ishex(buf[3]) && ishex(buf[4]) && ishex(buf[5]) &&
				ishex(buf[6]) && buf[7]==' ' && buf[8]!=' ')
		{
			int bank = (unhex(buf[0]) * 0x10 + unhex(buf[1])) & BIN(0x11000111);
			int addr = unhex(buf[3]) * 0x1000 + unhex(buf[4]) * 0x100 + unhex(buf[5]) * 0x10 + unhex(buf[6]);

			switch (bank)
			{
				case 5:
					addr += 0x4000;
					break;

				case 2:
					addr += 0x8000;
					break;

				default:
					addr += 0xC000;
					break;
			}

			char *label = (buf + 8);

			if (strlen(label) > 14)
			{
				label[11] = '.';
				label[12] = '.';
				label[13] = '.';
				label[14] = 0;
			}

			s_LabelItem item;

			item.addr = addr;
			item.label.assign(label);

			labels.push_back(item);

			if (strlen(label) >= 6)
			{
				if (label[0]=='_' && label[1]=='_' &&
						label[2]=='b' && label[3]=='p' &&
						label[4]=='_' && label[5]=='_')
				{
					printf("Set breakpoint on 0x%04X bank %02X\n", addr, bank);
					breakpoints[addr] = true;
				}
			}
		}
	}

	fl.Close();
}