Ejemplo n.º 1
0
bool Mix::setOdorFlow(double fl, bool apply)
{
    for (MixtureRatio::iterator it = mix_ratio.begin(); it != mix_ratio.end(); ++it) {
      Bank *b = getBank(it->first);
      if (b && b->getFlowController()) {
        double frac = mix_total_sum ? it->second/mix_total_sum : 0;
        double flow = frac * fl;
        if (flow < b->getFlowController()->min() || flow > b->getFlowController()->max()) return false;
      } else 
        return false;
    }
    if (apply) {
      //std::list<Bank *> theBanks = typedChildren();

      // first set them all off?
      //for (std::list<Bank *>::iterator it = theBanks.begin(); it != theBanks.end(); ++it)
      //  (*it)->setEnabled(false, Bank::Soft);

      for (MixtureRatio::iterator it = mix_ratio.begin(); it != mix_ratio.end(); ++it) {
        Bank *b = getBank(it->first);
        if (b) {
          double frac = mix_total_sum ? it->second/mix_total_sum : 0;
          double flow = frac * fl;
          if (!b->setFlow(flow)) return false; // argh! what to do about errors here?!
          //b->setEnabled(true, Bank::Soft);

        }
      }
    }
  odor_flow = fl;
  return true;
}
Ejemplo n.º 2
0
void BankSelector::handleBankChange() {
	int newBank = getValue();
	if (newBank != _currentBank) {
		getBank()->deactivate();
		_currentBank = newBank;
		getBank()->activate();
		Serial.print("Switching to bank ");
		Serial.println(_currentBank);
	}
}
Ejemplo n.º 3
0
void BankSelector::reset() {
	while (_currentBank < _bankCount) {
		getBank()->reset();
		++_currentBank;
	}
	_currentBank=0;
}
Ejemplo n.º 4
0
int Model::getTempBank() {
    if (tempBank == -1) {
        return getBank();
    } else {
        return tempBank;
    }
}
Ejemplo n.º 5
0
//--------------------------------------------------------------------------
// Write_Page:
//
// Write a page to a Touch Memory at a provided location (pg).
//
// portnum    the port number of the port being used for the
//            1-Wire Network.
// SNum       the serial number for the part that the read is
//            to be done on.
// buff       location of the write data
// pg         page number to write the packet
// len        the length of the packet
//
SMALLINT Write_Page(int portnum, uchar *SNum, uchar *buff, PAGE_TYPE pg, int len) 
{
	SMALLINT  bank;
	PAGE_TYPE page;
   uchar     addpg;
   
   // check for length too long for a page
   if (len > 29)
   {
   	OWERROR(OWERROR_INVALID_PACKET_LENGTH);
   	return FALSE;
   }

   // Are program jobs possible
   // is there a job that has been opened 
   if(isJob(portnum,SNum))
   {            
      if(setJobData(portnum,SNum,pg,buff,len))
         return TRUE;
   }
   
   bank = getBank(portnum,SNum,pg,REGMEM);
   page = getPage(portnum,SNum,pg,REGMEM);

   if(!owWritePagePacket(bank,portnum,SNum,page,buff,len))
   	return FALSE;
	else
   {
		addpg = AddPage(portnum,SNum,pg,buff,len);
   }
		
	return TRUE;
}
Ejemplo n.º 6
0
void Dram::insertMSHR(Address addr, int tipo, MachineID node, bool secondMiss)
{
    int tMSHR=(tipo == 3 ||tipo == 4)? 0:1;
    assert(!isPresentMSHR(addr, tipo));
    assert(isAbleMSHR(tMSHR));

    if(DEBUG_DRAM  &&  !g_CARGA_CACHE) cout << "petici—n insertada en el MSHR " <<  tipo << " " << addr << endl;


    dramRequest request;

    request.channel=map_Address_to_DirectoryNode(addr);
    request.requestor=node;
    request.addr=addr;
    request.core=node;
    request.write= (tipo==2);
    if(DEBUG_WRITE  &&  !g_CARGA_CACHE && tipo==2) cout << "WRITE! " << addr << endl;
    request.type=tipo;
    request.MSHRTime = g_eventQueue_ptr->getTime();
    request.valid=true;
    request.bank= getBank(addr);
    if(tMSHR) request.demand=true;
    else request.demand=false;
    request.secondMiss = secondMiss;

    (tMSHR ? demandMSHR : prefMSHR).push_back(request);

}
Ejemplo n.º 7
0
void BankSelector::handle() {
	handleBankChange();
	getBank()->handle();
	if (_controller != 0) {
		handleOutput();
	}
}
Ejemplo n.º 8
0
void THaCrateMap::print(ofstream *file) const {
{
  for( int roc=0; roc<MAXROC; roc++ ) {
    if( !crdat[roc].crate_used || crdat[roc].nslot ==0 ) continue;
    *file << "==== Crate " << roc << " type " << crdat[roc].crate_type;
    if( !crdat[roc].scalerloc.IsNull() )  *file << " \"" << crdat[roc].scalerloc << "\"";
    *file << endl;
    *file << "#slot\tmodel\tclear\t  header\t  mask  \tnchan\tndata\n";
    if (isBankStructure(roc)) *file << "crate has bank structure"<<endl;
    for( int slot=0; slot<MAXSLOT; slot++ ) {
      if( !slotUsed(roc,slot) ) continue;
      *file << "  " << slot << "\t" << crdat[roc].model[slot]
	   << "\t" << crdat[roc].slot_clear[slot];
      *file << "   \t0x" << hex << crdat[roc].header[slot]
	   << "    \t0x" << hex  << crdat[roc].headmask[slot]
	   << dec << "   "
	   << "  \t" << crdat[roc].nchan[slot]
	   << "  \t" << crdat[roc].ndata[slot]
	   << endl;
      Int_t bank = getBank(roc,slot);
      if (bank >= 0) *file << "Bank number "<< bank<<endl;

    }
  }
}

}
Ejemplo n.º 9
0
void Model::bankDown() {
    if (tempBank == -1) {
        tempBank = getBank() - 1;
    } else {
        tempBank--;
    }
    if (tempBank < 0) {
        tempBank = NUM_BANKS - 1;
    }
}
Ejemplo n.º 10
0
void Model::bankUp() {
    if (tempBank == -1) {
        tempBank = getBank() + 1;
    } else {
        tempBank++;
    }
    if (tempBank > NUM_BANKS - 1) {
        tempBank = 0;
    }
}
Ejemplo n.º 11
0
/**
 * recognize
 * The magic! Given a pattern it returns the ascii that
 * it thinks is closest
 **/
unsigned char 
recognize( Pattern *p )
{
    unsigned char ascii;
    int mind, tmpd, i, nsamples;
    Pattern *np; 


    /**
     * Check for shift-symbol
     */
    if ( maxWidth( p ) < 6 )
	return '.';
    
    np = apply( preprocessor, p );
    calcSlopes( np );

    /*
     * Do the magic stuff
     */
    samples = models[ getBank() ];
    nsamples = npatterns[ getBank() ];
    unknown = np;
    ascii = samples[0]->ascii;
    mind = distance( 0 );

    for ( i = 1; i < nsamples; i++ )
    {
	tmpd = distance( i );
	if ( tmpd < mind )
	{
	    mind = tmpd;
	    ascii = samples[i]->ascii;
	}
    }
	
    /*
     * cleanup and return
     */
    deletePattern( np );
    return ascii;
}
Ejemplo n.º 12
0
bool Mix::setMixtureRatios(const MixtureRatio & m, bool apply)
{
  mix_total_sum = 0;
  for (MixtureRatio::const_iterator it = m.begin(); it != m.end(); ++it) {
    Bank *b = getBank(it->first);
    if (b) mix_total_sum += it->second;
  }
  mix_ratio = m;
  if (apply) 
    return setOdorFlow(odor_flow);
  return true;
}
Ejemplo n.º 13
0
char* generateNLFilenameForAddress(uint16 address)
{
	if (address < 0x8000)
	{
		// The NL file for the RAM addresses has the name nesrom.nes.ram.nl
		strcpy(NLfilename, mass_replace(LoadedRomFName, "|", ".").c_str());
		strcat(NLfilename, ".ram.nl");
	} else
	{
		sprintf(NLfilename, "%s.%X.nl", mass_replace(LoadedRomFName, "|", ".").c_str(), getBank(address));
	}
	return NLfilename;
}
Ejemplo n.º 14
0
//--------------------------------------------------------------------------
// ExtendedRead_Page:
//
// Read a extended page from the current Eprom Touch Memory.
// The record will be placed into a (uchar) memory location
// starting at the location pointed to by (buf).  This function will 
// read a page out of normal memory.  If the page being read is
// redirected then an error is returned
// The following return codes will be provided to the caller:
//
// portnum    the port number of the port being used for the
//            1-Wire Network.
// SNum       the serial number for the part that the read is
//            to be done on.
// buff       the buffer for the data that was read
// pg         the page that starts the read
//
// return TRUE if the read was successful.
//  
SMALLINT ExtendedRead_Page(int portnum, uchar *SNum, uchar *buff, PAGE_TYPE pg)               
{    
	SMALLINT  bank;
   PAGE_TYPE page;
	uchar     extra[20]; 
   int       len,i;
                     
	bank = getBank(portnum,SNum,pg,REGMEM);
	page = getPage(portnum,SNum,pg,REGMEM);
	
	if(!owIsWriteOnce(bank,portnum,SNum) && ((SNum[0] != 0x18) && 
      (SNum[0] != 0x33) && (SNum[0] != 0xB3)) )
	{
		OWERROR(OWERROR_NOT_WRITE_ONCE);
		return FALSE;
	}
	
   // check on the program job to see if this page is in it 
   if(isJob(portnum,SNum))
   {      
      if(getJobData(portnum,SNum,pg,&buff[1],&len))
      {
         return TRUE;
      }
   }     
  
   if(owIsWriteOnce(bank,portnum,SNum))
   {
      if(!owReadPageExtraCRC(bank,portnum,SNum,page,&buff[0],&extra[0]))
     	   return FALSE;    
   }
   else
   {
      if(!owReadPageExtra(bank,portnum,SNum,page,FALSE,&buff[0],&extra[0]))
         return FALSE;

      for(i=0;i<owGetExtraInfoLength(bank,SNum);i++)
         buff[i+32] = extra[i];

      extra[0] = 0xFF;
   }

	if(extra[0] != 0xFF)
	{
		OWERROR(OWERROR_REDIRECTED_PAGE);
		return FALSE;
	}
   	
   return TRUE;
}
Ejemplo n.º 15
0
// TODO: instead of loading from disk every time the "loadedBankNames" changes, it's better to cache loaded linkedlists in memory
void loadNameFiles()
{
	int cb;

	if (!ramBankNamesLoaded)
	{
		ramBankNamesLoaded = true;
		// load RAM names
		if (ramBankNames)
			free(ramBankNames);
		
		// Load the address descriptions for the RAM addresses
		ramBankNames = parseNameFile(generateNLFilenameForAddress(0x0000));
	}

	int nPages = 1<<(15-debuggerPageSize);

	for(int i=0;i<nPages;i++)
	{
		int pageIndexAddress = 0x8000 + (1<<debuggerPageSize)*i;

		// Find out which bank is loaded at the page index
		cb = getBank(pageIndexAddress);
		if (cb == -1) // No bank was loaded at that offset
		{
			free(pageNames[i]);
			pageNames[i] = 0;
		}
		else if (cb != pageNumbersLoaded[i])
		{
			// If the bank changed since loading the NL files the last time it's necessary
			// to load the address descriptions of the new bank.
			pageNumbersLoaded[i] = cb;

			if (pageNames[i])
				freeList(pageNames[i]);

			// Load new address definitions
			pageNames[i] = parseNameFile(generateNLFilenameForAddress(pageIndexAddress));
		}
	} //loop across pages
}
Ejemplo n.º 16
0
void MemoryControl::enqueueMemRef (MemoryNode& memRef) {
  m_msg_counter++;
  memRef.m_msg_counter = m_msg_counter;
  Time arrival_time = memRef.m_time;
  uint64 at = arrival_time;
  bool is_mem_read = memRef.m_is_mem_read;
  bool dirtyWB = memRef.m_is_dirty_wb;
  physical_address_t addr = memRef.m_addr;
  int bank = getBank(addr);
  if (m_debug) {
    printf("New memory request%7d: 0x%08llx %c arrived at %10lld  ", m_msg_counter, addr, is_mem_read? 'R':'W', at);
    printf("bank =%3x\n", bank);
  }
  g_system_ptr->getProfiler()->profileMemReq(bank);
  m_input_queue.push_back(memRef);
  if (!m_awakened) {
    g_eventQueue_ptr->scheduleEvent(this, 1);
    m_awakened = 1;
  }
}
Ejemplo n.º 17
0
int test(ihel,ihel2){

  clasHEAD_t *HEAD = getBank(&bcs_, "HEAD");
  //clasEVNT_t *EVNT = getBank(&bcs_, "EVNT");

  int dummy;

  if(HEAD){
   
    //dummy = HEAD->head[0].evtclass;
    
    HEAD->head[0].evtclass = ihel;
    //HEAD->head[0].version  = ihel2;
    //printf("evt no: %d,", j);
    //printf("evtclass: %d \n",dummy);
    
    //}

  }

  return(0);

}
Ejemplo n.º 18
0
void Mix::setOdorTable(const std::string &s, const Bank::OdorTable &ot)
{
  Bank *b = getBank(s);
  if (!b) return;
  b->setOdorTable(ot);
}
Ejemplo n.º 19
0
void MemoryControl::executeCycle () {
  // Keep track of time by counting down the busy counters:
  for (int bank=0; bank < m_total_banks; bank++) {
    if (m_bankBusyCounter[bank] > 0) m_bankBusyCounter[bank]--;
  }
  if (m_busBusyCounter_Write > 0) m_busBusyCounter_Write--;
  if (m_busBusyCounter_ReadNewRank > 0) m_busBusyCounter_ReadNewRank--;
  if (m_busBusyCounter_Basic > 0) m_busBusyCounter_Basic--;

  // Count down the tFAW shift registers:
  for (int rank=0; rank < m_total_ranks; rank++) {
    if (m_tfaw_shift[rank] & 1) m_tfaw_count[rank]--;
    m_tfaw_shift[rank] >>= 1;
  }

  // After time period expires, latch an indication that we need a refresh.
  // Disable refresh if in memFixedDelay mode.
  if (!m_memFixedDelay) m_refresh_count--;
  if (m_refresh_count == 0) {
    m_refresh_count = m_refresh_period_system;
    assert (m_need_refresh < 10);  // Are we overrunning our ability to refresh?
    m_need_refresh++;
  }

  // If this batch of requests is all done, make a new batch:
  m_ageCounter++;
  int anyOld = 0;
  for (int bank=0; bank < m_total_banks; bank++) {
    anyOld |= m_oldRequest[bank];
  }
  if (!anyOld) {
    for (int bank=0; bank < m_total_banks; bank++) {
      if (!m_bankQueues[bank].empty()) m_oldRequest[bank] = 1;
    }
    m_ageCounter = 0;
  }

  // If randomness desired, re-randomize round-robin position each cycle
  if (m_memRandomArbitrate) {
    m_roundRobin = random() % m_total_banks;
  }


  // For each channel, scan round-robin, and pick an old, ready
  // request and issue it.  Treat a refresh request as if it
  // were at the head of its bank queue.  After we issue something,
  // keep scanning the queues just to gather statistics about
  // how many are waiting.  If in memFixedDelay mode, we can issue
  // more than one request per cycle.

  int queueHeads = 0;
  int banksIssued = 0;
  for (int i = 0; i < m_total_banks; i++) {
    m_roundRobin++;
    if (m_roundRobin >= m_total_banks) m_roundRobin = 0;
    issueRefresh(m_roundRobin);
    int qs = m_bankQueues[m_roundRobin].size();
    if (qs > 1) {
      g_system_ptr->getProfiler()->profileMemBankQ(qs-1);
    }
    if (qs > 0) {
      m_idleCount = IDLECOUNT_MAX_VALUE; // we're not idle if anything is queued
      queueHeads++;
      if (queueReady(m_roundRobin)) {
        issueRequest(m_roundRobin);
        banksIssued++;
        if (m_memFixedDelay) {
          g_system_ptr->getProfiler()->profileMemWaitCycles(m_memFixedDelay);
        }
      }
    }
  }

  // memWaitCycles is a redundant catch-all for the specific counters in queueReady
  g_system_ptr->getProfiler()->profileMemWaitCycles(queueHeads - banksIssued);

  // Check input queue and move anything to bank queues if not full.
  // Since this is done here at the end of the cycle, there will always
  // be at least one cycle of latency in the bank queue.
  // We deliberately move at most one request per cycle (to simulate
  // typical hardware).  Note that if one bank queue fills up, other
  // requests can get stuck behind it here.

  if (!m_input_queue.empty()) {
    m_idleCount = IDLECOUNT_MAX_VALUE; // we're not idle if anything is pending
    MemoryNode req = m_input_queue.front();
    int bank = getBank(req.m_addr);
    if (m_bankQueues[bank].size() < m_bank_queue_size) {
      m_input_queue.pop_front();
      m_bankQueues[bank].push_back(req);
    }
    g_system_ptr->getProfiler()->profileMemInputQ(m_input_queue.size());
  }
}
Ejemplo n.º 20
0
void TAccount::printAccountStatement() {

	//Kontoauszug erstellen...

	TTime t_current;
	TDate d_current;

	cout << "Kontoauszug vom " << d_current.toString() << "; " << t_current.toString() << "\n";
	cout << "Kontonr.: " << getAccountNumber() << "; BLZ " << getBank()->getBLZ() << "\n";
	cout << "Kontoinhaber: " << getCustomer()->getName() << "\n";

	std::cout << std::left << std::setw(11) << "Datum" << std::left
			<< std::setw(17) << "| Betrag" << std::left << std::setw(33)
			<< "| Absender / Empfaenger" << std::left << std::setw(14)
			<< "| Buchungstext" << endl;

	std::cout << setfill('-') << std::left << std::setw(11) << "" << std::left
			<< std::setw(17) << "|" << std::left << std::setw(33) << "|"
			<< std::left << std::setw(14) << "|" << endl;

	std::cout << setfill(' ');

	int bookingsAvailable = -1;
	for (int i = 0; i < getBookingsCount(); i++) {

		if (getBookings()[i]->getPrinted(this) != 0) {
			bookingsAvailable = 0;
			//Kontoauszug...

			TMoney a = getBookings()[i]->getAmount();

			TMoney m = getSignValueFromBookingByAccount(this, getBookings()[i]);
			double dABS = fabs(m.getAmount());
			char negSign = negZeichen(m);

			TCustomer* sender = (getBookings()[i]->getDepitor()->getCustomer() == getCustomer()) ? getBookings()[i]->getCreditor()->getCustomer() : getBookings()[i]->getDepitor()->getCustomer();
			std::cout << std::left << std::setw(9)
					<< std::fixed << setprecision(2)
					<< getBookings()[i]->getDate().toString() << " | "
					<< std::left << std::setw(0) << negSign << std::right
					<< std::setw(9) << dABS << " " << m.getCurrency() << " | "
					<< std::left << std::setw(30)
					<< sender->getName()
					<< " | " << std::left << std::setw(14)
					<< getBookings()[i]->getMemo() << endl;

			//std::setprecision( 24 )
			//Am Ende wurde der Kontoauszug gedruckt
			//und die Buchung wird gekennzeichnet
			getBookings()[i]->setPrinted(0, this);
		}
	}


	if (bookingsAvailable == -1){
		//Keine Buchungen vorhanden
		cout << "keine neuen Buchungen vorhanden!\n";
	}

	std::cout << setfill('-') << std::left << std::setw(11) << "" << std::left
			<< std::setw(17) << "|" << std::left << std::setw(33) << "|"
			<< std::left << std::setw(14) << "|" << endl;

	cout << "aktueller Kontostand: " << getAccountAmount().toString() << "\n";

	cout << setfill(' ') << flush;
}
Ejemplo n.º 21
0
// Evaluates a condition
int evaluate(Condition* c)
{
	int f = 0;

	int value1, value2;

	if (c->lhs)
	{
		value1 = evaluate(c->lhs);
	}
	else
	{
		switch(c->type1)
		{
			case TYPE_ADDR: // This is intended to not break, and use the TYPE_NUM code
			case TYPE_NUM: value1 = c->value1; break;
			default: value1 = getValue(c->value1); break;
		}
	}

	switch(c->type1)
	{
		case TYPE_ADDR: value1 = GetMem(value1); break;
		case TYPE_PC_BANK: value1 = getBank(_PC); break;
		case TYPE_DATA_BANK: value1 = getBank(addressOfTheLastAccessedData); break;
	}

	f = value1;

	if (c->op)
	{
		if (c->rhs)
		{
			value2 = evaluate(c->rhs);
		}
		else
		{
			switch(c->type2)
			{
				case TYPE_ADDR: // This is intended to not break, and use the TYPE_NUM code
				case TYPE_NUM: value2 = c->value2; break;
				default: value2 = getValue(c->type2); break;
			}
		}

	switch(c->type2)
	{
		case TYPE_ADDR: value2 = GetMem(value2); break;
		case TYPE_PC_BANK: value2 = getBank(_PC); break;
		case TYPE_DATA_BANK: value2 = getBank(addressOfTheLastAccessedData); break;
	}

		switch (c->op)
		{
			case OP_EQ: f = value1 == value2; break;
			case OP_NE: f = value1 != value2; break;
			case OP_GE: f = value1 >= value2; break;
			case OP_LE: f = value1 <= value2; break;
			case OP_G: f = value1 > value2; break;
			case OP_L: f = value1 < value2; break;
			case OP_MULT: f = value1 * value2; break;
			case OP_DIV: f = value1 / value2; break;
			case OP_PLUS: f = value1 + value2; break;
			case OP_MINUS: f = value1 - value2; break;
			case OP_OR: f = value1 || value2; break;
			case OP_AND: f = value1 && value2; break;
		}
	}

	return f;
}
Ejemplo n.º 22
0
Program* Editor::setProgram( INT32 programNum )
{
    return getBank()->setProgram( programNum, options_.autosave_ );
}
Ejemplo n.º 23
0
INT32 Editor::getProgramNumber()             
{ 
    return getBank()->programNum_; 
}
Ejemplo n.º 24
0
void Editor::closeBank()
{
    getBank()->close( options_.autosave_ );
}
Ejemplo n.º 25
0
Program* Editor::getCurrentProgram()
{
    return getBank()->getCurrentProgram();
}
Ejemplo n.º 26
0
//----------------------------------------------------------------------
//  ExtRead, reads extended file structure files.  It is designed such
//  that if a file is contiguous then it is not reset between the reading
//  of each page packet.  The bitmap BM has a page bit cleared when a
//  page is read correctly.  The varialbe maxlen is the max number of
//  bytes that can be fit into the buffer 'buf'.  If maxlen is set to
//  -1 then the file is read but it is not copied over into buf.
//
// portnum    the port number of the port being used for the
//            1-Wire Network.
// SNum       the serial number for the part that the read is
//            to be done on.
// file       location of the file to write
// start_page the starting page for the file
// maxlen     the maximum length the file buffer can handle
// del        tell weather to delete the file or not.
// BM         the bitmap
// fl_len     the length of the file that was read
//
// return TRUE if the read was successful
//
SMALLINT ExtRead(int portnum, uchar *SNum, uchar *file, int start_page,
						 int maxlen, uchar del, uchar *BM, int *fl_len)

{
	SMALLINT  bank;
	int       done = FALSE;
	int       buff_len = 0;
	PAGE_TYPE pg;
	uchar     pgbuf[34];
	int       len = 0;
	int       i;
	int       flag;

	pg = start_page;
	
   // loop to read in pages of the extended file
   do
   {	
      if(!Read_Page(portnum,SNum,&pgbuf[0],REGMEM,&pg,&len))
      	return FALSE;
      	      
      // add page segment to buffer
      if (maxlen != -1)   // don't add to buff in maxlen is -1
      {
      	if((buff_len+len) > maxlen)
      	{
      		OWERROR(OWERROR_BUFFER_TOO_SMALL);
      		return FALSE;
      	}
      	
      	for(i=0;i<(len-1);i++)
      		file[buff_len++] = pgbuf[i];
      }
                                
      bank = getBank(portnum,SNum,pg,REGMEM);
      
      // flag to indicate that the page should be cleared in the BM
      flag = FALSE;
      // do if have a NVRAM device 
      if(owIsReadWrite(bank,portnum,SNum) && 
         owIsGeneralPurposeMemory(bank,SNum)) 
          flag = TRUE;
         
      // or non written buffered eprom page 
      if(isJob(portnum,SNum))
      {
         // see if page set to write but has not started yet
         if(isJobWritten(portnum,SNum,pg) && del)
         {
            flag = TRUE;
         }
      }
                              
      // clear bit in bitmap     
      if(flag)
      {
         if(!BitMapChange(portnum,SNum,pg,0,BM))
            return FALSE;
      }
                                                                             
      // check on continuation pointer
      if (pgbuf[len-1] == 0)
      {
      	*fl_len = buff_len;
         done = TRUE; // all done
      }
      else
         pg = pgbuf[len-1];
   } 
   while(!done);
   
   return TRUE;
}
Ejemplo n.º 27
0
//--------------------------------------------------------------------------
// Read_Page:
//
// Read a default data structure page from the current Touch Memory.
// The record will be placed shorto a (uchar) memory location
// starting at the location poshorted to by (buf).  This function will 
// read a page out of normal memory (flag = REGMEM) or a status memory
// page out of an eprom (flag = STATUSMEM).  If the page being read is
// redirected as in an eprom device then the page value passes by referece
// is changed to match the new page.
//
// portnum    the port number of the port being used for the
//            1-Wire Network.
// SNum       the serial number for the part that the read is
//            to be done on.
// flag       tells weather to read regular memory or status memory
// buff       location for data read
// page       page number to read packet from
// len        the length of the data read
//
// return TRUE if the data was read correctly
//  
SMALLINT Read_Page(int portnum, uchar *SNum, uchar *buff, uchar flag, 
                   PAGE_TYPE *pg, int *len)
{
	SMALLINT  bank;
	PAGE_TYPE page;
   int       jobopen = FALSE;
   int       cnt = 0;
	uchar     extra[3],space;
	uchar     temp_buff[32];
	uchar     rd_buf[2];
   uchar     addpg;
   int       i;	

	
   // Are program jobs possible
   // is there a job that has been opened and is this a regular memory read
   if(isJob(portnum,SNum))
      jobopen = TRUE;
            
   // loop while redirected
   for (cnt = 0; cnt <= 256; cnt++)
   {       
      // if an program job is open then check there for page
      if(jobopen && (flag != STATUSMEM))
      {
         if(getJobData(portnum,SNum,*pg,buff,len))
         {
            return TRUE;
         }
      }

      // nope so look for page in cache
      if(FindPage(portnum,SNum,pg,flag,TRUE,buff,len,&space))  
      {
         if(*len == 0x41)
         {
            *pg = buff[0];
         }
         else if(flag != STATUSMEM)
         {
     		   return TRUE;
         }
      }

      bank = getBank(portnum,SNum,*pg,flag);
		page = getPage(portnum,SNum,*pg,flag);
			
      // nope so get it from the part      
      // if the page is in the status memory then call read status
      if (flag == STATUSMEM)
      {
      	if(owIsWriteOnce(bank,portnum,SNum) && owHasExtraInfo(bank,SNum))
      	{
      		if(!owReadPageExtraCRC(bank,portnum,SNum,page,&temp_buff[0],&extra[0]))
            {
               if(extra[0] == 0xFF)
         		   return FALSE;
            }
      	}
      	else
      	{
            if(owHasPageAutoCRC(bank,SNum))
            {
          	   if(!owReadPageCRC(bank,portnum,SNum,page,&temp_buff[0]))
                  return FALSE;
            }
            else
            {
               if(!owReadPage(bank,portnum,SNum,page,FALSE,&temp_buff[0]))
  		            return FALSE;
            }
      				
         	extra[0] = 0xFF;
         }

         if(extra[0] != 0xFF)
         {
      	   rd_buf[0] = ~extra[0];
      		addpg = AddPage(portnum,SNum,*pg,&rd_buf[0],STATUSMEM);
      		*pg = (PAGE_TYPE) rd_buf[0];      
            continue;
         }
         else
         {
            *len = 8;
            for(i=0;i<*len;i++)
               buff[i] = temp_buff[i];
            addpg = AddPage(portnum,SNum,*pg,&buff[0],STATUSMEM);
//  		   	   AddPage(portnum,SNum,*pg,&buff[0],*len);
//               AddPage(portnum,SNum,*pg,&buff[0],0x41);
            return TRUE;

         }
      }
      // else call on the regular readpack function
      else 
      {          
         *len = 0;
      	if(owIsWriteOnce(bank,portnum,SNum) && owHasExtraInfo(bank,SNum))
      	{
      		if(!owReadPagePacketExtra(bank,portnum,SNum,page,FALSE,
         										&temp_buff[0],len,&extra[0]))
            {
               if(extra[0] == 0xFF)
         		   return FALSE;
            }
      	}
      	else
      	{
            if(owHasPageAutoCRC(bank,SNum))
            {
         	   if(!owReadPageCRC(bank,portnum,SNum,page,&temp_buff[0]))
                  return FALSE;
            }
            else
            {
               if(!owReadPage(bank,portnum,SNum,page,FALSE,&temp_buff[0]))
  		            return FALSE;
            }
      				
      		extra[0] = 0xFF;
         } 
            
         if(extra[0] != 0xFF)
         {
         	rd_buf[0] = ~extra[0];
      		addpg = AddPage(portnum,SNum,*pg,&rd_buf[0],REDIRMEM);
      		*pg = (PAGE_TYPE) rd_buf[0];  
            continue;
         }
         else
         {
            if(*len > 0)
            {
               if(*len > 32)
               {
                  OWERROR(OWERROR_INVALID_PACKET_LENGTH);
                  return FALSE;
               }

               for(i=0;i<(*len);i++)
                  buff[i] = temp_buff[i];
            }
            else
            {
               if(temp_buff[0] > 32)
               {
                  OWERROR(OWERROR_INVALID_PACKET_LENGTH);
                  return FALSE;
               }

     	     	   for(i=1;i<(temp_buff[0]+1);i++)
     	   		   buff[i-1] = temp_buff[i];
               *len = temp_buff[0];
            }

            addpg = AddPage(portnum,SNum,*pg,&buff[0],*len);
            return TRUE;
         }
    	}
   }         
   
   // could not find the page
   return FALSE;
}           
Ejemplo n.º 28
0
int Model::selectPatch(int num) {
    selectPatchByNum(getBank() * PPB + num);
}
Ejemplo n.º 29
0
int Model::getPresetNum(int num) {
    return getBank() * PPB + num;
}
Ejemplo n.º 30
0
/**
* Loads the necessary NL files
**/
void loadNameFiles()
{
	int cb;
	char* fn = (char*)malloc(strlen(LoadedRomFName) + 20);

	if (ramBankNames)
		free(ramBankNames);
		
	// The NL file for the RAM addresses has the name nesrom.nes.ram.nl
	strcpy(fn, LoadedRomFName);
	strcat(fn, ".ram.nl");

	// Load the address descriptions for the RAM addresses
	ramBankNames = parseNameFile(fn);
			
	free(fn);

	// Find out which bank is loaded at 0xC000
	cb = getBank(0xC000);
	
	if (cb == -1) // No bank was loaded at that offset
	{
		free(lastBankNames);
		lastBankNames = 0;
	}
	else if (cb != lastBank)
	{
		char* fn = (char*)malloc(strlen(LoadedRomFName) + 12);

		// If the bank changed since loading the NL files the last time it's necessary
		// to load the address descriptions of the new bank.
		
		lastBank = cb;

		// Get the name of the NL file
		sprintf(fn, "%s.%X.nl", LoadedRomFName, lastBank);

		if (lastBankNames)
			freeList(lastBankNames);

		// Load new address definitions
		lastBankNames = parseNameFile(fn);
				
		free(fn);
	}
	
	// Find out which bank is loaded at 0x8000
	cb = getBank(0x8000);
	
	if (cb == -1) // No bank is loaded at that offset
	{
		free(loadedBankNames);
		loadedBankNames = 0;
	}
	else if (cb != loadedBank)
	{
		char* fn = (char*)malloc(strlen(LoadedRomFName) + 12);

		// If the bank changed since loading the NL files the last time it's necessary
		// to load the address descriptions of the new bank.
		
		loadedBank = cb;
		
		// Get the name of the NL file
		sprintf(fn, "%s.%X.nl", LoadedRomFName, loadedBank);
		
		if (loadedBankNames)
			freeList(loadedBankNames);
			
		// Load new address definitions
		loadedBankNames = parseNameFile(fn);
				
		free(fn);
	}
}