Esempio n. 1
0
int main() {
	open_logfile();

	try {

		debug_printf("number of com ports: %d\n", SerialPort::countPorts());
		getchar();

		SerialPort com1(1, 9600, NONE, 8, 1);

		while (1) {
			//com1.printStatus(com1.getStatus());
			debug_printf("-------------\n");
			com1.write(0x42);
			debug_printf(".............\n");
			char d = com1.waitForData();
			if (d != 0)
				debug_printf("read from UART: %X\n", d);
		}

		GuiManager& gui = GuiManager::getInstance();
		gui.init();

		Menu m;
		m.addEntry("hallo");
		m.addEntry("welt");
		m.addEntry("asdfasdfasdf asdfasdf");
		m.addEntry("yet another one");
		m.addEntry("this");
		m.addEntry("or that");
		m.addEntry("or not?");
		m.addEntry("and the last one");

		NumericInput inp(4);
		inp.y = m.y.ref() + m.height.ref();

		gui.getScreen().addWidget(&m);
		gui.getScreen().addWidget(&inp);
		//gui.setFocusTo(m.getEntries().front());
		gui.setFocusTo(&inp);


		Label l("flub");
		l.setInt(inp.value);
		gui.getScreen().addWidget(&l);
		l.x = 200;
		l.y = 20;

		inp.focus_next_up = m.getEntries().back();
		inp.focus_next_down = m.getEntries().front();

		debug_printf("starting gui\n");
		gui.run();

		debug_printf("done, exiting\n");
		close_logfile();
		return EXIT_SUCCESS;
	} catch (Error &e) {
		// non-critical error during init -> quit anyway
		_setvideomode(_DEFAULTMODE);
		debug_printf("ERROR:\n");
		debug_printf(e.what());
		debug_printf("\naborting ...\n");
	}
	catch (CriticalError& e) {
		_setvideomode(_DEFAULTMODE);
		debug_printf("CRITICAL ERROR:\n");
		debug_printf(e.what());
		debug_printf("\naborting ...\n");
	}
	catch (std::runtime_error& e) {
		_setvideomode(_DEFAULTMODE);
		debug_printf("CRITICAL ERROR:\nUnhandled runtime exception:\n");
		debug_printf(e.what());
		debug_printf("\naborting ...\n");
	}
	catch (...) {
		_setvideomode(_DEFAULTMODE);
		debug_printf("CRITICAL ERROR:\nUnknown exception.\naborting ...\n");
	}

	debug_printf("press enter to quit\n");
	getchar();

	close_logfile();
	return EXIT_FAILURE;
}
Esempio n. 2
0
bool Decompress::handleZipEntry(std::istream& zipStream, const ZipLocalFileHeader& hdr)
{
	if (hdr.isDirectory())
	{
		// directory have 0 size, nth to read
		if (!_flattenDirs)
		{
			std::string dirName = hdr.getFileName();
			if (!ZipCommon::isValidPath(dirName))
				throw ZipException("Illegal entry name " + dirName + " containing parent directory reference");
			Poco::Path dir(_outDir, dirName);
			dir.makeDirectory();
			Poco::File aFile(dir);
			aFile.createDirectories();
		}
		return true;
	}
	try
	{
		std::string fileName = hdr.getFileName();
		if (_flattenDirs)
		{
			// remove path info
			Poco::Path p(fileName);
			p.makeFile();
			fileName = p.getFileName();
		}

		if (!ZipCommon::isValidPath(fileName))
			throw ZipException("Illegal entry name " + fileName + " containing parent directory reference");

		Poco::Path file(fileName);
		file.makeFile();
		Poco::Path dest(_outDir, file);
		dest.makeFile();
		if (dest.depth() > 0)
		{
			Poco::File aFile(dest.parent());
			aFile.createDirectories();
		}
		Poco::FileOutputStream out(dest.toString());
		ZipInputStream inp(zipStream, hdr, false);
		Poco::StreamCopier::copyStream(inp, out);
		out.close();
		Poco::File aFile(dest.toString());
		if (!aFile.exists() || !aFile.isFile())
		{
			std::pair<const ZipLocalFileHeader, const std::string> tmp = std::make_pair(hdr, "Failed to create output stream " + dest.toString());
			EError.notify(this, tmp);
			return false;
		}

		if (!inp.crcValid())
		{
			if (!_keepIncompleteFiles)
				aFile.remove();
			std::pair<const ZipLocalFileHeader, const std::string> tmp = std::make_pair(hdr, "CRC mismatch. Corrupt file: " + dest.toString());
			EError.notify(this, tmp);
			return false;
		}

		// cannot check against hdr.getUnCompressedSize if CRC and size are not set in hdr but in a ZipDataInfo
		// crc is typically enough to detect errors
		if (aFile.getSize() != hdr.getUncompressedSize() && !hdr.searchCRCAndSizesAfterData())
		{
			if (!_keepIncompleteFiles)
				aFile.remove();
			std::pair<const ZipLocalFileHeader, const std::string> tmp = std::make_pair(hdr, "Filesizes do not match. Corrupt file: " + dest.toString());
			EError.notify(this, tmp);
			return false;
		}

		std::pair<const ZipLocalFileHeader, const Poco::Path> tmp = std::make_pair(hdr, file);
		EOk.notify(this, tmp);
	}
	catch (Poco::Exception& e)
	{
		std::pair<const ZipLocalFileHeader, const std::string> tmp = std::make_pair(hdr, std::string("Exception: " + e.displayText()));
		EError.notify(this, tmp);
		return false;
	}
	catch (...)
	{
		std::pair<const ZipLocalFileHeader, const std::string> tmp = std::make_pair(hdr, std::string("Unknown Exception"));
		EError.notify(this, tmp);
		return false;
	}

	return true;
}
Esempio n. 3
0
int Recognizer::nextToken()
{
  QString text;

 Lagain:
  while (ch.isSpace ())
    inp ();
  
  if (ch.isNull ())
    return EOF_SYMBOL;

  int token = ch.unicode ();

  if (token == '"')
    {
      inp(); // skip "
      text.clear ();
      while (! ch.isNull () && ch != QLatin1Char ('"'))
        {
          if (ch == QLatin1Char ('\\'))
            {
              text += ch;
              inp();
            }
          text += ch;
          inp ();
        }

      if (ch == QLatin1Char ('"'))
        inp ();
      else
        qerr << _M_input_file << ":" << _M_line << ": Warning. Expected `\"'" << endl;

      _M_current_value = text;
      return (token = STRING_LITERAL);
    }

  else if (ch.isLetterOrNumber () || ch == QLatin1Char ('_'))
    {
      text.clear ();
      do { text += ch; inp (); }
      while (ch.isLetterOrNumber () || ch == QLatin1Char ('_') || ch == QLatin1Char ('.'));
      _M_current_value = text;
      return (token = ID);
    }

  else if (token == '%')
    {
      text.clear ();

      do { inp (); }
      while (ch.isSpace ());

      do { text += ch; inp (); }
      while (ch.isLetterOrNumber () || ch == QLatin1Char ('_') || ch == QLatin1Char ('-'));

      if (text == QLatin1String("token_prefix"))
        return (token = TOKEN_PREFIX);
      else if (text == QLatin1String("merged_output"))
        return (token = MERGED_OUTPUT);
      else if (text == QLatin1String("token"))
        return (token = TOKEN);
      else if (text == QLatin1String("start"))
        return (token = START);
      else if (text == QLatin1String("parser"))
        return (token = PARSER);
      else if (text == QLatin1String("decl"))
        return (token = DECL_FILE);
      else if (text == QLatin1String("impl"))
        return (token = IMPL_FILE);
      else if (text == QLatin1String("expect"))
        return (token = EXPECT);
      else if (text == QLatin1String("expect-rr"))
        return (token = EXPECT_RR);
      else if (text == QLatin1String("left"))
        return (token = LEFT);
      else if (text == QLatin1String("right"))
        return (token = RIGHT);
      else if (text == QLatin1String("nonassoc"))
        return (token = NONASSOC);
      else if (text == QLatin1String("prec"))
        return (token = PREC);
      else
        {
          qerr << _M_input_file << ":" << _M_line << ": Unknown keyword `" << text << "'" << endl;
          exit (EXIT_FAILURE);
          return (token = ERROR);
        }
    }

  inp ();

  if (token == '-' && ch == QLatin1Char ('-'))
    {
      do { inp (); }
      while (! ch.isNull () && ch != QLatin1Char ('\n'));
      goto Lagain;
    }

  else if (token == ':' && ch == QLatin1Char (':'))
    {
      inp ();
      if (ch != QLatin1Char ('='))
        return (token = ERROR);
      inp ();
      return (token = COLON);
    }

  else if (token == '/' && ch == QLatin1Char (':'))
    {
      _M_action_line = _M_line;

      text.clear ();
      if (! _M_no_lines)
        text += QLatin1String ("\n#line ") + QString::number (_M_action_line) + " \"" + _M_input_file + "\"\n";
      inp (); // skip ':'

      forever
        {
          while (! ch.isNull ())
            {
              token = ch.unicode ();
              inp ();

              if (token == ':' && ch == QLatin1Char ('/'))
                break;

              text += QLatin1Char (token);
            }

          if (ch != QLatin1Char ('/'))
            return (token = ERROR);

          inp ();

          if (ch.isNull () || ch.isSpace ())
            {
              _M_current_value = text;
              return (token = DECL);
            }
	  else
	    text += QLatin1String (":/");
        }
    }
Esempio n. 4
0
/* ISA PnP version. The program calling us does the work of scanning BIOS device nodes and ISA PnP device isolation,
 * then presents us with the IRQ and port number. We take the caller's word for it. If for any reason the caller
 * did not find the IRQ, it should pass irq == -1 */
int add_pnp_8250(uint16_t port,int irq) {
    unsigned char ier,dlab1,dlab2,c,fcr;
    struct info_8250 *inf;

    if (already_got_8250_port(port))
        return 0;
    if (base_8250_full())
        return 0;

    inf = &info_8250_port[base_8250_ports];
    inf->type = TYPE_8250_IS_8250;
    inf->port = port;
    inf->irq = irq;
    if (windows_mode == WINDOWS_NONE || windows_mode == WINDOWS_REAL) {
        /* in real-mode DOS we can play with the UART to our heart's content. so we play with the
         * DLAB select and interrupt enable registers to detect the UART in a manner non-destructive
         * to the hardware state. */

        /* switch registers 0+1 back to RX/TX and interrupt enable, and then test the Interrupt Enable register */
        _cli();
        outp(port+3,inp(port+3) & 0x7F);
        if (inp(port+3) == 0xFF) { _sti(); return 0; }
        ier = inp(port+1);
        outp(port+1,0);
        if (inp(port+1) == 0xFF) { _sti(); return 0; }
        outp(port+1,ier);
        if ((inp(port+1) & 0xF) != (ier & 0xF)) { _sti(); return 0; }
        /* then switch 0+1 to DLAB (divisor registers) and see if values differ from what we read the first time */
        outp(port+3,inp(port+3) | 0x80);
        dlab1 = inp(port+0);
        dlab2 = inp(port+1);
        outp(port+0,ier ^ 0xAA);
        outp(port+1,ier ^ 0x55);
        if (inp(port+1) == ier || inp(port+0) != (ier ^ 0xAA) || inp(port+1) != (ier ^ 0x55)) {
            outp(port+0,dlab1);
            outp(port+1,dlab2);
            outp(port+3,inp(port+3) & 0x7F);
            _sti();
            return 0;
        }
        outp(port+0,dlab1);
        outp(port+1,dlab2);
        outp(port+3,inp(port+3) & 0x7F);

        /* now figure out what type */
        fcr = inp(port+2);
        outp(port+2,0xE7);  /* write FCR */
        c = inp(port+2);    /* read IIR */
        if (c & 0x40) { /* if FIFO */
            if (c & 0x80) {
                if (c & 0x20) inf->type = TYPE_8250_IS_16750;
                else inf->type = TYPE_8250_IS_16550A;
            }
            else {
                inf->type = TYPE_8250_IS_16550;
            }
        }
        else {
            unsigned char oscratch = inp(port+7);

            /* no FIFO. try the scratch register */
            outp(port+7,0x55);
            if (inp(port+7) == 0x55) {
                outp(port+7,0xAA);
                if (inp(port+7) == 0xAA) {
                    outp(port+7,0x00);
                    if (inp(port+7) == 0x00) {
                        inf->type = TYPE_8250_IS_16450;
                    }
                }
            }

            outp(port+7,oscratch);
        }

        outp(port+2,fcr);
        _sti();
    }
    else {
        unsigned int i;

        /* if we were to actually do our self-test in a VM, Windows would mistakingly assume we
         * were trying to use it and would allocate the port. we're just enumerating at this point.
         * play it safe and assume it works if the port is listed as one of the BIOS ports.
         * we also don't use interrupts. */
        for (i=0;i < bios_8250_ports && port != get_8250_bios_port(i);) i++;
        if (i >= bios_8250_ports) return 0;
    }

    base_8250_port[base_8250_ports++] = port;
    return 1;
}
/*
 * check if bypass connected
 */
int sm_pm_bypass_present(struct s_smc *smc)
{
	return (inp(ADDR(B0_DAS)) & DAS_BYP_ST) ? TRUE : FALSE;
}
Esempio n. 6
0
uint8_t board_buttons(void)
{
  return inp(EZ80_PB_DDR) & 7;
}
int main()
{ long long  int t,l,r,i,j,z,n,m,flag=1,sum,sum1;
t=inp();

//scanf("%llu",&t);
while(t--)
{flag=1,z=1,sum=0,sum1=0;
n=inp();m=inp();
   // scanf("%llu%llu",&n,&m);
    for(i=1;i<=n;i++)
    {a[i]=inp();
       // scanf("%llu",&a[i]);
        b[i]=0;
    }

    for(i=1;i<=m;i++)
    {
       scanf("%llu%llu",&l,&r);
       if(b[l]==0)b[l]=2;
       if(b[l]==1)b[l]=1;
       if(b[l]==2)b[l]=2;
       for(j=l+1;j<=r;j++)
       {
           b[j]=1;
       }
    }

    for(i=1;i<=n;i++)
    {

        if(b[i]==2)
        {   if((sum!=sum1))
            {
              flag=0; break; 
            }
            sum=a[i];sum1=i;
        }
        else if(b[i]==1)
        {
            sum= sum+a[i];sum1=sum1+i;
        }
         else
         {
             if((sum!=sum1)||(a[i]!=i))
             {
                 flag=0;break;
             }
             sum=0;sum1=0;
         }
       // if((b[i]==0))
        //{
         //   d[]
        //}
    }
    if(flag==0)
    {
      printf("Impossible\n") ;
    }
    else
    {
       printf("Possible\n") ;
    }
}
    return 0;
}
Esempio n. 8
0
static void config_OEM_regs(void)
{
	BYTE CRX_2A, Old_value;
	BYTE mem_Type;
	BYTE mem_MD;
	WORD i;

	lpDef_Reg_struct lpMode3_temp;
	lpDef_Reg_struct lpInit_reg;
	lpMode3_temp = &Mode3_temp[0];
	lpInit_reg = &Init_reg[0];

	printk(BIOS_DEBUG, "blade3d: config_OEM_regs()\n");

	outp(Port_GRX, 0x24);
	outp(Port_GRX + 1, 0xe0);
	//MCLK VCLK to 16 bit
	outp(Port_CRX, 0xcf);
	outp(Port_CRX + 1, inp(Port_CRX + 1) | 0x03);
	//3c5.0e
	//outp(Port_SRX, 0x3b);
	//outp(Port_SRX+1, inp(Port_SRX+1) | 0x20);
	//
	outp(Port_CRX, 0x3b);
	outp(Port_CRX + 1, inp(Port_CRX + 1) | 0x20);
	//
	outp(Port_CRX, 0x1a);
	outp(Port_CRX + 1, inp(Port_CRX + 1) & 0x08);
	//
	outp(Port_CRX, 0x2a);
	CRX_2A = inp(Port_CRX + 1);
	outp(Port_CRX + 1, CRX_2A & ~0x20);

	mem_Type = (CRX_2A & ~0x20) & 0x08;

	outp(Port_GRX, 0x0f);
	if (0x08 == mem_Type)
		outp(Port_GRX + 1, inp(Port_GRX + 1) | 0x20);
	else
		outp(Port_GRX + 1, inp(Port_GRX + 1) & ~0x20);

	outp(Port_CRX, 0x28);
	mem_MD = inp(Port_CRX + 1) & 0x07;

	set_memCLK(mem_Type, mem_MD);
	delay(100);

	if (0x08 == mem_Type) {
		outp(Port_CRX, 0x2e);
		outp(Port_CRX + 1, 0x00);
		delay(100);
		outp(Port_CRX, 0x2d);
		outp(Port_CRX + 1, 0x92);
	} else {
		outp(Port_CRX, 0x2d);
		outp(Port_CRX + 1, 0x82);
	}

	for (i = 0; i < Length_Mode3_temp; i++) {
		outp(lpMode3_temp[i].rPort, lpMode3_temp[i].rIndex);
		Old_value = inp(lpMode3_temp[i].rPort + 1);
		outp(lpMode3_temp[i].rPort + 1,
		     lpMode3_temp[i].rValue | (Old_value & lpMode3_temp[i].
					       rMask));
	}
	//screen off
	outp(Port_SRX, 0x01);
	outp(Port_SRX + 1, inp(Port_SRX + 1) | 0x20);

	for (i = 0; i < Length_Init_reg; i++) {
		outp(lpInit_reg[i].rPort, lpInit_reg[i].rIndex);
		Old_value = inp(lpInit_reg[i].rPort + 1);
		outp(lpInit_reg[i].rPort + 1,
		     lpInit_reg[i].rValue | (Old_value & lpInit_reg[i].
					     rMask));
	}
	delay(10);
	init_SGRAM();

	outp(Port_CRX, 0x1a);
	if (0x08 == inp(Port_CRX + 1)) {
		outp(Port_CRX, 0x20);
		outp(Port_CRX + 1, inp(Port_CRX + 1) | 0x04);
	}

}				//end config_OEM_reg
Esempio n. 9
0
/*------------------------------------------------------------------*
  GSERIAL.CPP
  Edited by Gong jianwei  http://www.gjwtech.com
  For asynchronous serial port communications
  适用于DOS环境下异步串口通信编程 多串口控制程序
    ATTENTION: Compile this program with Test Stack Overflow OFF.
在Turbo C++3.0中选项设置 Options/Compiler/Entry中关闭Test Stack Overflow

*------------------------------------------------------------------*/

#include "GSerial.h"

struct COMPORT_VAR
{
    char  inbuf[IBUF_LEN];		// in buffer
    char  outbuf[OBUF_LEN];		// out buffer

    unsigned int   startbuf ;
    unsigned int   endbuf  ;
    unsigned int   inhead  ;
    unsigned int   intail   ;
    unsigned int   outhead  ;
    unsigned int   outtail  ;
    unsigned int   PortBase ;
};

COMPORT_VAR comport1,comport2;




//////////////////////////////////GSerial////////
GSerial::GSerial()
{
}

GSerial::~GSerial()
{
}

//*  get status of the port  */
int GSerial::ReadStatus(void)
{
    return(inp(m_unPortBase+5));
}
Esempio n. 10
0
main()
{
    int a,b,c,x,y,rx,ry,rz,n=8,p1,p2,r,g,zpos=7500,y1,y2,rya,ypos,yposa;
    int ya,yy,boingm=6,boingd=7;
    int jello=0,jelloa=0,bigjello=0,bigjelloa=0;
    int xscale=120,yscale=120,zscale=120,bscale=0;
    int oxp=0,oyp=0,ozp=0;
    int oxb=0,oyb=0,ozb=0;
    int bscaleflag=0;
    int	repec;
    int pdy;
    int lasta=-1;
    char    *ps,*pd,*pp;
    unsigned int u;

    dis_partstart();

    while(!dis_exit() && dis_musplus()<-19) ;
    dis_setmframe(0);

    zoomer2();

    _asm mov dx,3c4h
    _asm mov ax,0f02h
    _asm out dx,ax
    memset(vram,0,65535);
    _asm
    {
        mov ax,13h
        int 010h
    }
    testasm();

    for(a=0;a<100;a++)
    {
        fcrow[a]=fc+768+16+a*320;
    }
    for(a=0;a<16;a++)
    {
        fcrow2[a]=fc+768+16+a*320+100*320;
    }
    
    outp(0x3c8,0);
    for(a=0;a<768;a++) outp(0x3c9,0);
    outp(0x3c8,0);
    for(a=0;a<16*3;a++) outp(0x3c9,fc[a+16]);
    yy=0; ya=0;
    while(!dis_exit())
    {
        ya++; yy+=ya;
        if(yy>48*16)
        {
            yy-=ya;
            ya=-ya*2/3;
            if(ya>-4 && ya<4) break;
        }
        y=yy/16;
        y1=130+y/2;
        y2=130+y*3/2;
        if(y2!=y1) b=25600/(y2-y1);
        pd=vram+(y1-4)*320; pdy=y1;
        for(ry=y1-4;ry<y1;ry++,pd+=320)
        {
            if(ry>199) continue;
            memset(pd,0,320);
        }
        for(c=0,ry=y1;ry<y2;ry++,pd+=320,c+=b)
        {
            if(ry>199) continue;
            memcpy(pd,fcrow[c/256],320);
        }
        for(c=0;c<16;c++,pd+=320,ry++)
        {
            if(ry>199) continue;
            if(c>7) memset(pd,0,320);
            else memcpy(pd,fcrow2[c],320);
        }
        waitb();
    }
    
    while(!dis_exit() && dis_getmframe()<300);
    dis_waitb();

    //initnewgroup();
    for(a=0;a<16;a++)
    {
        ps=fc+0x10+a*3;
        pd=backpal+a*3;
        pd[0]=ps[0];
        pd[1]=ps[1];
        pd[2]=ps[2];
    }
    pp=tmppal;
    for(a=0;a<256;a++)
    {
        if(a<16) b=a;
        else
        {
            b=a&7;
        }
        r=backpal[b*3+0];
        g=backpal[b*3+1];
        b=backpal[b*3+2];
        if((a&8) && a>15)
        {
            r+=16;
            g+=16;
            b+=16;
        }
        if(r>63) r=63;
        if(g>63) g=63;
        if(b>63) b=63;
	*pp++=r;
	*pp++=g;
	*pp++=b;
    }
    outp(0x3c8,0);
    for(a=0;a<768;a++)
    {
        outp(0x3c9,tmppal[a]);
    }
    lightshift=9;
    rx=ry=rz=0;
    ypos=-9000; yposa=0;
    dis_waitb();
    memcpy(bgpic,vram,64000);
    
    while(!dis_exit() && dis_getmframe()<333);

    memcpy(pal,backpal,16*3);
    dis_partstart();
    dis_waitb();

    outp(0x3c7,0);
    for(a=0;a<16*3;a++) pal[a]=inp(0x3c9);
    dis_setcopper(0,copper);
    while(frame<7000 && !dis_exit())
    {
        a=dis_musplus(); if(a<0 && a>-16) break;
        
	repeat=dis_waitb();
        outp(0x3c8,0);
        for(a=0;a<16*3;a++) outp(0x3c9,pal[a]);
	
	while(repeat--)
        {
            frame++;
            rx+=32; ry+=7;
	    rx%=3*3600; ry%=3*3600; rz%=3*3600;
            
            if(frame>900)
            {
                b=frame-900;
		/*
		if(b<=256)
		{
			c=256-b;
			for(a=1;a<14*3+1;a++)
			{
				points[a]=(points1[a]*c+points9[a]*b)/256L;
			}
		}
		else if(b<=512)
		{
			b-=256;
			c=256-b;
			for(a=1;a<14*3+1;a++)
			{
				points[a]=(points9[a]*c+points8[a]*b)/256L;
			}
		}
		else if(b<=768)
		{
			b-=512;
			c=256-b;
			for(a=1;a<14*3+1;a++)
			{
				points[a]=(points8[a]*c+points7[a]*b)/256L;
			}
		}
		*/
                a=frame-900;
		b=frame-900; if(b>50) b=50;
                oxp=sin1024[(a*3)&1023]*b/10;
                oyp=sin1024[(a*5)&1023]*b/10;
                ozp=(sin1024[(a*4)&1023]/2+128)*b/16;
		if(frame>1800)
		{
			a=frame-1800+64;
			if(a>1024) a=1024;
	                oxb=(long)(-sin1024[(a*6)&1023])*(long)a/40L;
	                oyb=(long)(-sin1024[(a*7)&1023])*(long)a/40L;
	                ozb=(long)(sin1024[(a*8)&1023]+128)*(long)a/40L;
		}
		else
		{
	                oxb=-sin1024[(a*6)&1023];
	                oyb=-sin1024[(a*7)&1023];
	                ozb=sin1024[(a*8)&1023]+128;
		}
		b=1800-frame;
		if(b<0) 
		{
			if(b<-99) b=-99;
			oyp-=b*b/2;
		}
            }
            
            if(frame>800)
            {
                if(frame>1220+789)
                {
                    if(xscale>0) xscale-=1;
                    if(yscale>0) yscale-=1;
                    if(zscale>0) zscale-=1;
		    if(bscale>0) bscale-=1;
                }
                else if(frame>1400+789)
                {
                    if(bscale>0) bscale-=8;
                    if(bscale<0) bscale=0;
                }
                else
                {
                    if(bscale<180) bscale+=2;
		    else bscale=180;
                }
                if(bscale>xscale) lightshift=10;
            }
            else
            {
                if(frame<640+70)
                {
                    yposa+=31;
                    ypos+=yposa/40; 
                    if(ypos>-300)
                    {
                        ypos-=yposa/40;
                        yposa=-yposa*boingm/boingd;
                        boingm+=2; boingd++;
                        //jelloa=500;
                    }
                    if(ypos>-900 && yposa>0)
                    {
                        jello=(ypos+900)*5/3;
                        jelloa=0;
                    }
                }
                else
                {
                    if(ypos>-2800) ypos-=16;
                    else if(ypos<-2800) ypos+=16;
                }
                yscale=xscale=120+jello/30;
                zscale=120-jello/30;
                a=jello;
                jello+=jelloa;
                if((a<0 && jello>0) || (a>0 && jello<0))
                {
                    jelloa=jelloa*5/6;
                }
                a=jello/20;
                jelloa-=a;
            }

            if(frame>1280+789)
            {
	            b=1280+789+64-frame;
	            if(b<0) b=0;
	            for(a=0;a<16*3;a++) pal[a]=backpal[a]*b/64;
            }
            else if(frame>700)
            {
	            if(frame<765)
	            {
	                b=764-frame;
	                if(b<0) b=0;
	                for(a=0;a<16*3;a++) pal[a]=backpal[a]*b/64;
	            }
	            else if(frame<790)
	            {
	                y=150+(frame-765)*2;
	                memset(bgpic+y*320,0,640);
	                memset(vram+y*320,0,640);
	                if(frame>785) for(a=0;a<16;a++)
	                {
	                    r=g=b=0;
	                    if(a&1)
	                    {
	                        r+=10;
	                    }
	                    if(a&2)
	                    {
	                        r+=30;
	                    }
	                    if(a&4)
	                    {
	                        r+=20;
	                    }
	                    if(a&8)
	                    {
	                        r+=16;
	                        g+=16;
	                        b+=16;
	                    }
	                    if(r>63) r=63;
	                    if(g>63) g=63;
	                    if(b>63) b=63;
	                    backpal[a*3+0]=r;
	                    backpal[a*3+1]=g;
	                    backpal[a*3+2]=b;
	                }
	            }
	            else if(frame<795)
	            {
		    	memcpy(pal,backpal,16*3);
		    }
   	    }
	}

        cglenzinit();

        if(xscale>4)
        {
            demomode[0]=demomode[1];
            cmatrix_yxz(rx,ry,rz,matrix);
            csetmatrix(matrix,0,0,0);
            points2b[0]=0; crotlist(points2b,points);
            matrix[0]=xscale*64;
            matrix[1]=0;
            matrix[2]=0;
            matrix[3]=0;
            matrix[4]=yscale*64;
            matrix[5]=0;
            matrix[6]=0;
            matrix[7]=0;
            matrix[8]=zscale*64;
            csetmatrix(matrix,0+oxp,ypos+1500+oyp,zpos+ozp);
            points2[0]=0; crotlist(points2,points2b);
            if(frame<800) ccliplist(points2);
            points3[0]=0; cprojlist((long *)points3,points2);
            ceasypolylist(polylist,epolys,points3);
            cglenzpolylist(polylist);
        }

        if(frame>800 && bscale>4)
        {       
            demomode[0]=demomode[2];
            cmatrix_yxz(3600-rx/3,3600-ry/3,3600-rz/3,matrix);
            csetmatrix(matrix,0,0,0);
            points2b[0]=0; crotlist(points2b,pointsb);
            matrix[0]=bscale*64;
            matrix[1]=0;
            matrix[2]=0;
            matrix[3]=0;
            matrix[4]=bscale*64;
            matrix[5]=0;
            matrix[6]=0;
            matrix[7]=0;
            matrix[8]=bscale*64;
            csetmatrix(matrix,0+oxb,ypos+1500+oyb,zpos+ozb);
            points2[0]=0; crotlist(points2,points2b);
            points3[0]=0; cprojlist((long *)points3,points2);
            ceasypolylist(polylist,epolysb,points3);
            cglenzpolylist(polylist);
        }
        
        cglenzdone();
    }
    dis_setcopper(0,NULL);
    if(!dis_indemo())
    {
        _asm mov ax,3
        _asm int 10h
    }
Esempio n. 11
0
File: os_cpu.c Progetto: qinzb/WeOS
// atomic statement runtime support
inline os_atomic_t os_atomic_begin(void)
{
    os_atomic_t result = inp(SREG);
    cli();
    return result;
}
Esempio n. 12
0
void    waitb(void)
{
    while(!(inp(0x3da)&8));
    while((inp(0x3da)&8));
}
Esempio n. 13
0
unsigned __far __pascal inport( unsigned port )
{
    return( inp( port ) );
}
Esempio n. 14
0
void	zoomer2(char *pic)
{
	int	a,b,c,y;
	char *v;
	int	frame=0;
	int	zly,zy,zya;
	int	zly2,zy2;

	_asm
	{
		mov	dx,3c4h
		mov	ax,0f02h
		out	dx,ax
	}	
	outp(0x3c7,0);
	for(a=0;a<768;a++) pal1[a]=inp(0x3c9);

	zy=0; zya=0; zly=0;
	zy2=0; zly2=0;
	frame=0;
	while(!kbhit())
	{
		if(zy==260) break;
		zly=zy;
		zya++;
		zy+=zya/4;
		if(zy>260) zy=260;
		v=vram+zly*80;
		for(y=zly;y<=zy;y++)
		{
			memset(v,255,80);
			v+=80;
		}
		zly2=zy2;
		zy2=125*zy/260;
		v=vram+(399-zy2)*80;
		for(y=zly2;y<=zy2;y++)
		{
			memset(v,255,80);
			v+=80;
		}
		c=frame;
		if(c>32) c=32;
		b=32-c;
		for(a=0;a<128*3;a++)
		{
			pal2[a]=(pal1[a]*b+30*c)>>5;
		}
		frame++;
		dis_waitb();
		setpalarea(pal2,0,128);
	}
	v=vram+(194)*80;
	outp(0x3c8,0);
	outp(0x3c9,0);
	outp(0x3c9,0);
	outp(0x3c9,0);
	v=vram+(0)*80;
	for(y=0;y<=399;y++)
	{
		if(y<=274 || y>=260) memset(v,0,80);
		v+=80;
	}
}
Esempio n. 15
0
int	waitborder(void)
{
	while(inp(0x3da)&8);
	while(!(inp(0x3da)&8));
}
Esempio n. 16
0
File: xml.cpp Progetto: spolitov/lib
void read_xml(const boost::filesystem::wpath & path, boost::property_tree::wptree & out)
{
    boost::filesystem::ifstream inp(path, std::ios::binary);
    read_xml(inp, out);
}
Esempio n. 17
0
//------------------------------------------------------------------------------
int main( int argc, char * argv[] )
{
    // basic attributes of the computation
    const unsigned    geomDeg  = 1;
    const unsigned    fieldDeg = 1;
    const unsigned    dim      = 2;
    const base::Shape shape    = base::SimplexShape<dim-1>::value;

    // usage message
    if ( argc != 2 ) {
        std::cout << "Usage:  " << argv[0] << "  input.dat \n";
        return 0;
    }

    // read name of input file
    const std::string inputFile = boost::lexical_cast<std::string>( argv[1] );

    // read from input file
    std::string meshFile;
    double A, B, tolerance, pressure;
    unsigned maxIter, loadSteps;
    {    
        //Feed properties parser with the variables to be read
        base::io::PropertiesParser prop;
        prop.registerPropertiesVar( "meshFile",         meshFile );
        prop.registerPropertiesVar( "A",                A );
        prop.registerPropertiesVar( "B",                B );
        prop.registerPropertiesVar( "maxIter",          maxIter );
        prop.registerPropertiesVar( "loadSteps",        loadSteps );
        prop.registerPropertiesVar( "tolerance",        tolerance );
        prop.registerPropertiesVar( "pressure",         pressure );

        // Read variables from the input file
        std::ifstream inp( inputFile.c_str()  );
        VERIFY_MSG( inp.is_open(), "Cannot open input file" );
        prop.readValues( inp );
        inp.close( );

        // Make sure all variables have been found
        if ( not prop.isEverythingRead() ) {
            prop.writeUnread( std::cerr );
            VERIFY_MSG( false, "Could not find above variables" );
        }
    }

    // find base name from mesh file
    const std::string baseName = base::io::baseName( meshFile, ".smf" );

    //--------------------------------------------------------------------------
    // define a mesh
    typedef base::Unstructured<shape,geomDeg,dim>    Mesh;

    // create a mesh and read from input
    Mesh mesh;
    {
        std::ifstream smf( meshFile.c_str() );
        base::io::smf::readMesh( smf, mesh );
        smf.close();
    }

    // quadrature objects for volume and surface
    const unsigned kernelDegEstimate = 1; //3;
    typedef base::Quadrature<kernelDegEstimate,shape> Quadrature;
    Quadrature quadrature;
    
    // Create a field
    const unsigned    doFSize = dim;
    typedef base::fe::Basis<shape,fieldDeg>        FEBasis;
    typedef base::Field<FEBasis,doFSize>           Field;
    typedef Field::DegreeOfFreedom                 DoF;
    Field field;

    // generate DoFs from mesh
    base::dof::generate<FEBasis>( mesh, field );


    // constrain a dof
    constrainSupports( field );

    // Bind the fields together
    typedef base::asmb::FieldBinder<Mesh,Field> FieldBinder;
    FieldBinder fieldBinder( mesh, field );
    typedef FieldBinder::TupleBinder<1,1>::Type FTB;

    // material object
    typedef surf::Skalak Energy;
    Energy   energy( A, B );

    //typedef surf::NeoHookean Energy;
    //Energy   energy( A  );

    typedef surf::HyperElasticMembrane<Energy> Material;
    Material material( energy );

    // matrix kernel
    typedef solid::HyperElastic<Material,FTB::Tuple> HyperElastic;
    HyperElastic hyperElastic( material );

    // Number the degrees of freedom
    const std::size_t numDofs =
        base::dof::numberDoFsConsecutively( field.doFsBegin(), field.doFsEnd() );
    std::cout << "# Number of dofs " << numDofs << std::endl;

    // write a vtk file
    writeVTKFile( baseName, 0, mesh, field, material );

    // load increment
    const double deltaP = pressure / static_cast<double>( loadSteps );

    std::cout << "# pressure   radius \n"
              << 0.0  << "   "  << giveRadius( mesh, field ) << "\n";
    
    //--------------------------------------------------------------------------
    // Loop over load steps
    //--------------------------------------------------------------------------
    for ( unsigned step = 0; step < loadSteps; step++ ) {

        // current load
        const double p = (step+1) * deltaP;

        //----------------------------------------------------------------------
        // Nonlinear iterations
        //----------------------------------------------------------------------
        unsigned iter = 0;
        while ( iter < maxIter ) {

            //std::cout << "Iter " << iter;

            // Create a solver object
            typedef base::solver::Eigen3           Solver;
            Solver solver( numDofs );

            
            base::asmb::computeResidualForces<FTB>( quadrature, solver,
                                                    fieldBinder, hyperElastic );
            
            // Compute element stiffness matrices and assemble them
            base::asmb::stiffnessMatrixComputation<FTB>( quadrature, solver,
                                                         fieldBinder, hyperElastic,
                                                         iter > 0 );

            // internal pressure load
            base::asmb::bodyForceComputation2<FTB>( quadrature, solver, fieldBinder,
                                                    boost::bind( &internalPressure<Mesh::Element>,
                                                                 _1, _2, p ) );


            // Finalise assembly
            solver.finishAssembly();

            // norm of residual 
            const double conv1 = solver.norm();

            //std::cout << " |F| = " << conv1;

            // convergence via residual norm
            if ( conv1 < tolerance * A ) { // note the tolerance multiplier
                //std::cout << "\n";
                break;
            }

            // Solve
            solver.choleskySolve();
            
            // distribute results back to dofs
            base::dof::addToDoFsFromSolver( solver, field );

            // norm of displacement increment
            const double conv2 = solver.norm();
            //std::cout << " | DU | = " << conv2 << "\n";
            
            // convergence via increment
            if ( conv2 < tolerance ) break;

            iter++;

        }
        // Finished non-linear iterations
        //----------------------------------------------------------------------

        // warning
        if ( iter == maxIter ) {
            std::cout << "# (WW) Step " << step << " has not converged within "
                      << maxIter << " iterations \n";
        }

        // write a vtk file
        writeVTKFile( baseName, step+1, mesh, field, material );

        std::cout << p << " " << giveRadius( mesh, field ) << std::endl;

    }
    // Finished load steps
    //--------------------------------------------------------------------------

    
    return 0;
}
Esempio n. 18
0
bfs::path IphPlatform::GetInputPath(const IResource *res) const
{
	std::string inp(res->GetFilename());
	bfs::path tmp = e->GetInputPath(res->GetType());

	std::string lang(res->GetLanguage());
	if (lang != DEFAULT_LANG)
	{
		tmp /= bfs::path("l10n") / lang;
	}

	switch (res->GetType())
	{
		case RESOURCE_IMAGE:
		{
			bfs::path f = tmp / (inp + ".png");
			if (bfs::exists(f))
			{
				inp = inp + ".png";
			}
			else
			{
				Error(ERROR_FILE_NOT_FOUND, "Input: File %s.png not found at %s", res->GetFilename(), tmp.string().c_str());
			}
		}
		break;

		case RESOURCE_MASK:
		{
			bfs::path f = tmp / (inp + ".tga");
			if (bfs::exists(f))
			{
				inp = inp + ".tga";
			}
			else
			{
				Error(ERROR_FILE_NOT_FOUND, "Input: Mask file %s.tga not found at %s", tmp.string().c_str(), res->GetFilename());
			}
		}
		break;

		case RESOURCE_MUSIC:
		{
			inp = inp + PLATFORM_IPH_INPUT_MUSIC_EXT;
		}
		break;

		case RESOURCE_SOUND:
		{
			inp = inp + PLATFORM_IPH_INPUT_SOUND_EXT;
		}
		break;

		default:
			Error(ERROR_EXPORT_RESOURCE_INVALID_TYPE, "WARNING: Resource type not known for resource %s.", res->GetName());
		break;
	}

	tmp /= inp;

	return tmp;
}
Esempio n. 19
0
void PortB(void)  //  PORTB
{       port=(unsigned short)AT;
        databyte=inp(port);
        AT=(int32)databyte;
}
Esempio n. 20
0
void run(double *accum, int *cur_loc, mem_array mem) {
  int prg_counter = 0,   // mem cell location of the command being executed
    next_loc = 0,        // mem cell location of the next command to be executed
    run_flag = CONTINUE; // flag for when to stop the execution of the
                         // user's program.  Values are CONTINUE, STOP
                         // and RUN_ERR

  char cmdtrans[80];     // an English translation of the current command
  enum speed run_speed;  // the run mode

  hidemouse();

  // if they want to run
  if(get_speed(&run_speed) == CONTINUE) {
    // set up screen for running
    put_accum(accum);
    clear_monitor();
    clear_keyboard();
    clear_keys();

    /* user's program loop */
    do {
      // execute at the next location
      prg_counter = next_loc;

      // THF patch, was +2
      put_prg_counter(prg_counter + 1);
      put_instruct(mem[prg_counter]);
      bright_cell(prg_counter, mem[prg_counter]);

      // case statement for run mode
      switch(run_speed) {
        case SLOW:
          delay(SLOW_DELAY_TIME);
          break;

        case FAST:
          delay(FAST_DELAY_TIME);
      }

      /// if there is a command in the cell
      if(mem[prg_counter].entry_type == CMD) {
        // command type case statement
        switch(mem[prg_counter].cmd_type) {
          case LDC:
            run_flag = ldc(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case ADC:
            run_flag = adc(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case LDA:
            run_flag = lda(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case STA:
            run_flag = sta(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case ADD:
            run_flag = add(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case SUB:
            run_flag = sub(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case MUL:
            run_flag = mul(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case DIV:
            run_flag = div(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case INP:
            run_flag = inp(mem, cmdtrans, prg_counter, &next_loc);
            break;

          case OUT:
            run_flag = out(mem, cmdtrans, prg_counter, &next_loc);
            break;

          case BPA:
            run_flag = bpa(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case BNA:
            run_flag = bna(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case BZA:
            run_flag = bza(accum, mem, cmdtrans, prg_counter, &next_loc);
            break;

          case BRU:
            run_flag = bru(mem, cmdtrans, prg_counter, &next_loc);
            break;

          case STP:
            run_flag = stp(cmdtrans, prg_counter, &next_loc);

            if(run_speed == CYCLE) {
              display_cmdtrans(cmdtrans);
            }

            break;

          default:
            run_err_message("ERROR: Unkown command at this location.");
            run_flag = RUN_ERR;
            break;
        }
      } else {
        run_err_message("ERROR: Unkown command at this location.");
        run_flag = RUN_ERR;
      }

      // check to see if the user wants to stop
      if(kbhit()) {
        if(getch() == EscKey) {
          run_flag = STOP;
        }
      }

      if((run_speed == CYCLE) && (run_flag == CONTINUE)) {
        run_flag = display_cmdtrans(cmdtrans);
      }

      dim_cell(prg_counter, mem[prg_counter]);

    } while((run_flag == CONTINUE) && (mem[prg_counter].cmd_type != STP));

    // clear the registers when program is done
    clear_instruct();
    clear_prg_counter();
  }

  showmouse();

  if(run_flag == RUN_ERR) {
    *cur_loc = prg_counter;
  }

  display_keys();
}
Esempio n. 21
0
static void INTERRUPT FAR newkbisr(void)
{
      static int count = 0;
      int key = keyport();

      if (KBtrap_active)
      {
            if (count)
            {
                  unsigned char kbin;

                  --count;

                  if (PRTSCRNSCAN == key)
                        PrtScrnPending = True_;
IGNORE:
                  kbin = (unsigned char)inp(KEYPORT+1); /* reset keyboard  */
                  outp(KEYPORT+1, kbin|0x80);
                  outp(KEYPORT+1, kbin);
                  disable();
                  outp(CONTROLLERPORT,0x20); /* tell controller to shut up */
                  enable();
                  return;
            }
            else switch (key)
            {
            case MULTI2SCAN:
                  count = 1;
                  goto IGNORE;

            case MULTI3SCAN:
                  count = 2;
                  goto IGNORE;

            case DELSCAN:
                  if (CTRLALT == (kbstat() & CTRLALT))
                        goto IGNORE;
                  break;
                  
            case PRTSCRNSCAN:
                  PrtScrnPending = True_;
                  goto IGNORE;
                  
            case CSCAN:
            case BREAKSCAN:
                  if (CTRL == (kbstat() & CTRL))
                        goto IGNORE;
                  break;
                  
            case SYSREQSCAN:
                  goto IGNORE;
            }
      }
      else
      {
            if (count)
            {
                  --count;
                  return;
            }
      }
      oldkbisr();                         /* chain to old keyboard isr */
}
bool LanguageModelIRST::Load(const std::string &filePath, 
			     FactorType factorType, 
			     size_t nGramOrder)
{
  const char *SepString = " \t\n";
  cerr << "In LanguageModelIRST::Load: nGramOrder = " << nGramOrder << "\n";

  FactorCollection &factorCollection = FactorCollection::Instance();

  m_factorType 	 = factorType;
  m_nGramOrder	 = nGramOrder;

  // get name of LM file and, if any, of the micro-macro map file
  char *filenamesOrig = strdup(filePath.c_str());
  char *filenames = filenamesOrig;
  m_filePath = strsep(&filenames, SepString);

  // Open the input file (possibly gzipped)
  InputFileStream inp(m_filePath);

  if (filenames) {
    // case LMfile + MAPfile: create an object of lmmacro class and load both LM file and map
    cerr << "Loading LM file + MAP\n";
    m_mapFilePath = strsep(&filenames, SepString);
    if (!FileExists(m_mapFilePath)) {
      cerr << "ERROR: Map file <" << m_mapFilePath << "> does not exist\n";
			free(filenamesOrig);
      return false;
    }
    InputFileStream inpMap(m_mapFilePath);
    m_lmtb = new lmmacro(m_filePath, inp, inpMap);


  } else {
    // case (standard) LMfile only: create an object of lmtable
    cerr << "Loading LM file (no MAP)\n";
    m_lmtb  = (lmtable *)new lmtable;

  // Load the (possibly binary) model
#ifdef WIN32
    m_lmtb->load(inp); //don't use memory map
#else
    if (m_filePath.compare(m_filePath.size()-3,3,".mm")==0)
      m_lmtb->load(inp,m_filePath.c_str(),NULL,1);
    else 
      m_lmtb->load(inp,m_filePath.c_str(),NULL,0);
#endif  

  }

  m_lmtb_ng=new ngram(m_lmtb->getDict()); // ngram of words/micro tags
  m_lmtb_size=m_lmtb->maxlevel();

  // LM can be ok, just outputs warnings

  // Mauro: in the original, the following two instructions are wrongly switched:
  m_unknownId = m_lmtb->getDict()->oovcode(); // at the level of micro tags
  CreateFactors(factorCollection);

  VERBOSE(0, "IRST: m_unknownId=" << m_unknownId << std::endl);

  //install caches
  m_lmtb->init_caches(m_lmtb->maxlevel()>2?m_lmtb->maxlevel()-1:2);

  if (m_lmtb_dub >0) m_lmtb->setlogOOVpenalty(m_lmtb_dub);

  free(filenamesOrig);
  return true;
}
Esempio n. 23
0
File: FAXC.C Progetto: hollylee/EZP
static void InitComPort()
{
    unsigned char st,i;
#define NEW_RESET

    inp(PortBase);
    inp(PortBase_5);

    _disable();
    st=inp(PortBase_3);
    outp(PortBase_3,st|0x80);    /* LCR : next is baud rate */
    //outpw(PortBase_1,0);
    outpw(PortBase,6);     // 19200=115200/6  /* Baud rate low byte */
    outp(PortBase_3,st);

    outp(PortBase_3,3);    // Dlab=0, no parity, 1 stop, 8 data
    _enable();

    st=inp(PortBase_2) & 0xc0;
    if(st==0xc0)
        outp(PortBase_2,0xc7);

#ifdef NEW_RESET
    outp(PortBase_2,0);
    outp(PortBase_1,0);
    st=inp(PortBase_4) & 0xef;
    outp(PortBase_4,st|0xb);
#endif

    inp(PortBase);
#ifdef NEW_RESET
    inp(PortBase_2);
#endif
    inp(PortBase_5);
    inp(PortBase_6);

    _disable();
    st=inp(0x21) & IntDisableMask;
#ifdef NEW_RESET
    outp(PortBase_1,0x7);
#else
    outp(PortBase_1,0x3);
#endif
    outp(PortBase_4,0xb);    // MCR: DTR=1, RTS=1
    outp(0x21,st);
    _enable();

    for (i=0; i<8; i++)                  /* Edge-triggering, read the ports */
        inp(PortBase + i);          /* Port to clear                   */
}
Esempio n. 24
0
/******************************************************************************
*                                                                             *
*   BOOL SerialInit(int com, int baud)                                        *
*                                                                             *
*******************************************************************************
*
*   Initializes serial interface and enables interrupts on it. This function
*   is called from the SERIAL command, and also every time debugger pops up,
*   and a serial connector is active.
*
*   Where:
*       com is the com port to use: [1..MAX_SERIAL]
*       baud is the baud rate
*
*   If com==0, default (or previously set) port and rate will be used.
*
*   Returns:
*       TRUE - serial interface has been reset + PIC enable interrupts
*       FALSE - serial is not the default output device
*
******************************************************************************/
BOOL SerialInit(int com, int baud)
{
    BYTE PIC;                           // Current value of the PIC1 register

    // Do the reset only if the current output device is a serial terminal
    if( pOut == &outVT100 )
    {
        // If we supplied the new port and baud numbers, set them up
        if( com != 0 )
        {
            Serial.com = com;
            com = com - 1;

            Serial.port = port[com];
            Serial.irq  = irq[com];
            Serial.baud = baud;

            switch( baud )
            {
                case 0x2400:    Serial.rate = 0x30; break;
                case 0x9600:    Serial.rate = 0x0C; break;
                case 0x19200:   Serial.rate = 0x06; break;
                case 0x38400:   Serial.rate = 0x03; break;
                case 0x57600:   Serial.rate = 0x02; break;
                case 0x115200:  Serial.rate = 0x01; break;
            }
        }
        // Initialize serial port - we'd rather not have interrupts at this time
        LocalCLI();

        // + 3 Data format register:
        // [7]   Access to divisor latch
        // [6]   BRK off
        // [5:3] parity - 000 none
        // [2]   stop 0 - 1 bit
        // [1:0] 11 - 8 data bits
        outp(Serial.port + 3, 0x83);

        // Output baud rate parameter
        outp(Serial.port + 0, Serial.rate);
        outp(Serial.port + 1, 0);

        // Revert the DLATCH to 0
        outp(Serial.port + 3, 3);

#if SERIAL_POLLING
        // We still expect interrupt on receiver data in
        outp(Serial.port + 1, 0x01);

        // DTR + RTS set
        outp(Serial.port + 4, 0x08 | 0x03);
#else
        // + 1 Interrupt enable register:
        // [3] Issue interrupt on state-change of a RS-232 input line
        // [2] Issue interrupt on parity, overrun, framing error or break
        // [1] Issue interrupt when out buffer is empty (ready to send)
        // [0] Issue interrupt when byte arrives (incomming)
        outp(Serial.port + 1, 0x06);

        // + 2 Interrupt identification line:
        // [2] \   00 - change of RS232 line     01 - output buffer empty
        // [1]  \  10 - data received            11 - error or break
        // [0] 1 - no pending int.  0 - interrupt pending

        // + 4 Modem control register:
        // [3] Must be set to allow interrupts
        // [1] RTS
        // [0] DTR
        outp(Serial.port + 4, 0x08 | 0x02 | 0x01);

#endif // SERIAL_POLLING

        Serial.sent = 0;
        Serial.parity = Serial.overrun = Serial.framing = Serial.brk = 0;
        Serial.head = 0;
        Serial.tail = 0;

        // Empty the input queue
        while( inp(Serial.port + 5) & 1 )
            inp(Serial.port + 0);

        // Done with initialization of the serial port
        LocalSTI();

        // Enable the correct interrupt for the serial communication
        PIC = inp(0x21);
        PIC = PIC & ~(1 << Serial.irq);
        outp(0x21, PIC);

        return( TRUE );
    }

    return(FALSE);
}
/*
 * FDDI card reset
 */
static void card_start(struct s_smc *smc)
{
	int i ;
#ifdef	PCI
	u_char	rev_id ;
	u_short word;
#endif

	smt_stop_watchdog(smc) ;

#ifdef	PCI
	/*
	 * make sure no transfer activity is pending
	 */
	outpw(FM_A(FM_MDREG1),FM_MINIT) ;
	outp(ADDR(B0_CTRL), CTRL_HPI_SET) ;
	hwt_wait_time(smc,hwt_quick_read(smc),MS2BCLK(10)) ;
	/*
	 * now reset everything
	 */
	outp(ADDR(B0_CTRL),CTRL_RST_SET) ;	/* reset for all chips */
	i = (int) inp(ADDR(B0_CTRL)) ;		/* do dummy read */
	SK_UNUSED(i) ;				/* Make LINT happy. */
	outp(ADDR(B0_CTRL), CTRL_RST_CLR) ;

	/*
	 * Reset all bits in the PCI STATUS register
	 */
	outp(ADDR(B0_TST_CTRL), TST_CFG_WRITE_ON) ;	/* enable for writes */
	word = inpw(PCI_C(PCI_STATUS)) ;
	outpw(PCI_C(PCI_STATUS), word | PCI_ERRBITS) ;
	outp(ADDR(B0_TST_CTRL), TST_CFG_WRITE_OFF) ;	/* disable writes */

	/*
	 * Release the reset of all the State machines
	 * Release Master_Reset
	 * Release HPI_SM_Reset
	 */
	outp(ADDR(B0_CTRL), CTRL_MRST_CLR|CTRL_HPI_CLR) ;

	/*
	 * determine the adapter type
	 * Note: Do it here, because some drivers may call card_start() once
	 *	 at very first before any other initialization functions is
	 *	 executed.
	 */
	rev_id = inp(PCI_C(PCI_REV_ID)) ;
	if ((rev_id & 0xf0) == SK_ML_ID_1 || (rev_id & 0xf0) == SK_ML_ID_2) {
		smc->hw.hw_is_64bit = TRUE ;
	} else {
		smc->hw.hw_is_64bit = FALSE ;
	}

	/*
	 * Watermark initialization
	 */
	if (!smc->hw.hw_is_64bit) {
		outpd(ADDR(B4_R1_F), RX_WATERMARK) ;
		outpd(ADDR(B5_XA_F), TX_WATERMARK) ;
		outpd(ADDR(B5_XS_F), TX_WATERMARK) ;
	}

	outp(ADDR(B0_CTRL),CTRL_RST_CLR) ;	/* clear the reset chips */
	outp(ADDR(B0_LED),LED_GA_OFF|LED_MY_ON|LED_GB_OFF) ; /* ye LED on */

	/* init the timer value for the watch dog 2,5 minutes */
	outpd(ADDR(B2_WDOG_INI),0x6FC23AC0) ;

	/* initialize the ISR mask */
	smc->hw.is_imask = ISR_MASK ;
	smc->hw.hw_state = STOPPED ;
#endif
	GET_PAGE(0) ;		/* necessary for BOOT */
}
Esempio n. 26
0
/******************************************************************************
*                                                                             *
*   void SerialHandler(int IRQ)                                               *
*                                                                             *
*******************************************************************************
*
*   This handler is used when the debugger has control.
*
*   This is a low-level serial port handler. The event could be a serial
*   input character from the remote terminal or a serial mouse.
*
*   Where:
*       IRQ is 0 for COM1, COM3 or 1 for COM2, COM4
*
******************************************************************************/
void SerialHandler(int IRQ)
{
    BYTE status, data;
    static BYTE lastData;

    // If mouse has a control over the serial port, send it there

    // Queue mouse packets from the serial port:
    //
    //  D7   D6   D5   D4   D3   D2   D1   D0
    //  X    1    LB   RB   Y7   Y6   X7   X6
    //  X    0    X5   X4   X3   X2   X1   X0
    //  X    0    Y5   Y4   Y3   Y2   Y1   Y0
    //

    // Otherwise, it is a remote terminal
    // See if our serial port initiated this interrupt
    status = inp(Serial.port + 2);
    if( (status & 1)==0 )
    {
        // Pending interrupt was initiated by our serial interface
        switch( (status >> 1) & 3 )
        {
            case 0x00:      // change of RS232 line
                break;

            case 0x01:      // Output buffer empty
                // See if we have another byte to send
                if( Serial.head != Serial.tail )
                {
                    data = Serial.outBuffer[Serial.tail];
                    Serial.tail++;
                    if( Serial.tail>=MAX_SERIAL_BUFFER )
                        Serial.tail = 0;

                    outp(Serial.port + 0, data);
                    lastData = data;
                    Serial.sent++;
                }
                break;

            case 0x02:      // Data received in input buffer
                    data = inp(Serial.port);

                    // We dont support mouse yet, so assume it is a serial
                    // remote terminal sending us a character which we will
                    // accept only if serial terminal is enabled (and active)

                    if( pOut == &outVT100 )
                    {
                        VT100Input(data);
                    }

                break;

            case 0x03:      // Error or break
                    // Read status to clear pending interrupt
                    status = inp(Serial.port + 5);
                    if( status & (1<<2) ) Serial.parity++;
                    if( status & (1<<1) ) Serial.overrun++;
                    if( status & (1<<3) ) Serial.framing++;
                    if( status & (1<<4) ) Serial.brk++;

                    // Resend the data byte
                    outp(Serial.port + 0, lastData);
                break;
        }
    }

    // Or just a junk
}
Esempio n. 27
0
mainwindow::mainwindow()
{
    // Interface Construction
    ui.setupUi(this);
    pt_mth = pt_type = -1;
    evt = isreset = 1;
    pdfpath = "./PDF/";
    lstroll = "";


    dt = QDate::currentDate().toString("dd.MM.yyyy");
    ui.date->setText(dt);

    mwsdt = new sdetails();
    // Scene Construction
    setdmscene();


    // Load Modules
    btable = new bulkprint(this,ui.tab_5);
    btable->show();
    selprint = new selectiveprint(this);
    setupmenu();


    // Start the Authentication Dialog
    AuthenDialog *authendialog = new AuthenDialog(this);
    authendialog->show();

    // Printer Info
    QPrinter print;
    QPrinterInfo pinfo(print);
    ui.pinfo->setText(pinfo.printerName());//.section("",-1,-1));

    // Fetch Printing Positions
    QFile file2("./positions.dat");
    file2.open(QIODevice::ReadOnly);
    QDataStream inp(&file2);
    inp >> lt;

    //set printer
    setprinter();

    //Connections
    connect(ui.bselback,SIGNAL(pressed()),selprint,SLOT(back()));
    connect(ui.bqreset,SIGNAL(pressed()),this,SLOT(breset()));
    connect(ui.bqprint,SIGNAL(pressed()),this,SLOT(qprint()));
    connect(ui.bbulkprintall,SIGNAL(pressed()),this,SLOT(bprintall()));
    connect(ui.bbulkselprint,SIGNAL(pressed()),this,SLOT(bprintsel()));
    connect(ui.bselnext,SIGNAL(released()),selprint,SLOT(next()));
    connect(ui.babortprint,SIGNAL(released()),this,SLOT(abortprint()));
    connect(ui.bpositions,SIGNAL(released()),this,SLOT(positionsdialog()));
    connect(ui.changeButton,SIGNAL(released()),this,SLOT(changepasswd()));

    connect(ui.leqroll,SIGNAL(textChanged(const QString &)),this,SLOT(rollchanged(const QString &)));
    connect(ui.leqsname,SIGNAL(textChanged(const QString &)),this,SLOT(snamechanged(const QString &)));
    connect(ui.leqfname,SIGNAL(textChanged(const QString &)),this,SLOT(fnamechanged(const QString &)));
    connect(ui.cbcourse,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(coursechanged(const QString &)));
    connect(ui.cbbranch,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(branchchanged(const QString &)));
    connect(ui.cbyear,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(yearchanged(const QString &)));
    connect(ui.cbsem,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(semchanged(const QString &)));
    //connect(ui.cbpl,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(ptchanged(const QString &)));
    connect(ui.leqfrom,SIGNAL(textChanged(const QString &)),this,SLOT(fromchanged(const QString &)));
    connect(ui.leqto,SIGNAL(textChanged(const QString &)),this,SLOT(tochanged(const QString &)));
    connect(ui.lepurpose,SIGNAL(textChanged(const QString &)),this,SLOT(ppchanged(const QString &)));
    connect(ui.cbgen,SIGNAL(currentIndexChanged(int)),this,SLOT(genchanged(int)));
    connect(ui.modetab,SIGNAL(currentChanged(int)),this,SLOT(pmode(int)));


    connect(ui.ptcombo,SIGNAL(currentIndexChanged(QString)),ui.ltype,SLOT(setText(const QString &)));
    connect(ui.outbox,SIGNAL(currentIndexChanged(QString)),ui.lout,SLOT(setText(const QString &)));
    connect(ui.gbcno,SIGNAL(toggled(bool)),this,SLOT(cidtoggle(bool)));
    connect(ui.sbcno,SIGNAL(valueChanged (int)),this,SLOT(cidvalue(int)));
    connect(ui.actionQuit,SIGNAL(triggered()),this,SLOT(close()));
    connect(ui.actionAbout,SIGNAL(triggered()),this,SLOT(about_p()));
    connect(actionselprintall,SIGNAL(triggered()),selprint,SLOT(printall()));
    connect(actionselprintsel,SIGNAL(triggered()),selprint,SLOT(printsel()));
    connect(ui.actionPrint,SIGNAL(triggered()),this,SLOT(qprint()));
    connect(ui.actionReset,SIGNAL(triggered()),this,SLOT(reset()));

    ui.leqroll->setFocus();
    ui.lepurpose->setText("Bus Pass");
    qp1 = "select STUDENT_ID from student_admission where STUDENT_ROLLNO=";
    qp2 = "select student_name,father_name,gender from student_info where student_id=" ;
    qp3 = "select course,branch_id,current_sem,current_year from student_academic where student_id=" ;

}
Esempio n. 28
0
/*************************************************************************
	module		:[アナログ・ファンクション・チェッカー、メイン]
	function	:[アナログ・ファンクション・チェッカー、メイン]
	return		:[なし]
	common		:[]
	condition	:[]
	comment		:[]
	machine		:[V53]
	language	:[MS-C(Ver.6.0)]
	keyword		:[CHK]
	date		:[1995/02/10]
	author		:[増田]
*************************************************************************/
void	AnalogFunctionCheckerMain( void )						/* なし */
{
	UWORD	command;		/*コマンド*/
	UBYTE	machine;		/*機種(0:桐、1:椛)*/
	UBYTE	result;			/*検査結果*/
	UBYTE	result_out;		/*検査結果出力 ON/OFF*/
/*	UBYTE	lcd_work[31];	*/	/* LCD表示ワーク */

	UBYTE	data;
	UWORD	word_data;

	/** コマンド読み込み */
	command = inpw(COMMAND_PORT);	/** コマンド読み込み */
	command &= 0x00ff;
	machine = (UBYTE)(command >> 7);	/** 機種 */

	outpw(COMMAND_PORT,(UWORD)command);					/** 検査結果ステータス出力 */

	/* RTCポートチェック時は、周波数チェックを外す 1997/11/17  By T.Yamaguchi */
	if ((command != CHECK_OUT_RTC_PORT1) && (command != CHECK_OUT_RTC_PORT2)) {
		/** 周波数チェック */
		CheckClock( 0 );			/** 周波数チェック */
	}

	/** コマンド解析 */
	result = 0;						/** 検査結果=OK */
	result_out = OUT_ON;			/** 検査結果出力=ON */

	/** ブザー音消去 */
#if (PRO_KEYPANEL == PANEL_POPLAR_B) || (PRO_KEYPANEL == PANEL_POPLAR_L)
	outpw(ETC_PORT , IO_BIT_MUTE);
#endif
#if (PRO_KEYPANEL == PANEL_ANZU_L)
	IO__PADRH = 0x00ff;
#endif

	switch ( (command & 0x00ff) ) {	/** コマンド内容を調べる */
		case	CHECK_OUT_CPU_PA1:						/* ポートAデータレジスタH */
			CMN_DisableInterrupt();
			outpw(IO_PADRH_PORT, OUT_CPU_PA1);					/* A0H書き込み */
			result = OUT_CPU_PA1;
			break;
		case	CHECK_OUT_CPU_PA2:						/* ポートAデータレジスタH */
			CMN_DisableInterrupt();
			outpw(IO_PADRH_PORT, OUT_CPU_PA2);					/** 51H書き込み */
			result = OUT_CPU_PA2;
			break;
		case	CHECK_OUT_CPU_PA_UB1:					/* ポートAデータレジスタL */
			CMN_DisableInterrupt();
			outpw(IO_PADRL_PORT, OUT_CPU_PA_UB1);					/** A8H書き込み */
			result = OUT_CPU_PA_UB1;
			break;
		case	CHECK_OUT_CPU_PA_UB2:					/* ポートAデータレジスタL */
			CMN_DisableInterrupt();
			outpw(IO_PADRL_PORT, OUT_CPU_PA_UB2);					/** 55H書き込み */
			result = OUT_CPU_PA_UB2;
			break;
#if (PRO_KEYPANEL == PANEL_ANZU_L)
		case	CHECK_OUT_CPU_PA_UB1H:						/* ポートAデータレジスタL */
			CMN_DisableInterrupt();
			outpw(IO_PADRL_PORT, OUT_CPU_PA_UB1H);					/** AAH書き込み */
			result = RSLT_CPU_PA_UB1H;
			break;
		case	CHECK_OUT_CPU_PA_UB2H:						/* ポートAデータレジスタL */
			CMN_DisableInterrupt();
			outpw(IO_PADRL_PORT, OUT_CPU_PA_UB2H);					/** 51H書き込み */
			result = RSLT_CPU_PA_UB2H;
			break;
		case	CHECK_OUT_CPU_PD1H:							/* ポートDデータレジスタH */
			CMN_DisableInterrupt();
			outpw(IO_PDDRH_PORT, OUT_CPU_PD1H);					/* 40H書き込み */
			result = RSLT_CPU_PD1H;
			break;
		case	CHECK_OUT_CPU_PD2H:							/* ポートDデータレジスタH */
			CMN_DisableInterrupt();
			outpw(IO_PDDRH_PORT, OUT_CPU_PD2H);					/** 80H書き込み */
			result = RSLT_CPU_PD2H;
			break;
		case	CHECK_OUT_COM_PORT1:							/* COM・ポ−ト */
			CMN_DisableInterrupt();
			outpw(COM_PORT, OUT_COM_PORT1);					/** 28H書き込み */
			result = OUT_COM_PORT1;
			break;
		case	CHECK_OUT_COM_PORT2:							/* COM・ポ−ト */
			CMN_DisableInterrupt();
			outpw(COM_PORT, OUT_COM_PORT2);					/** 10H書き込み */
			result = OUT_COM_PORT2;
			break;
		case	CHECK_OUT_RTC_PORT1:							/* RTC・ポ−ト */
			CMN_DisableInterrupt();
			outpw(RTC_PORT, OUT_RTC_PORT1);					/** 0AH書き込み */
			result = OUT_RTC_PORT1;
			break;
		case	CHECK_OUT_RTC_PORT2:							/* RTC・ポ−ト */
			CMN_DisableInterrupt();
			outpw(RTC_PORT, OUT_RTC_PORT2);					/** 0AH書き込み */
			result = OUT_RTC_PORT2;
			break;
#endif
#if (PRO_KEYPANEL == PANEL_POPLAR_B) || (PRO_KEYPANEL == PANEL_POPLAR_L)
		case	CHECK_OUT_CPU_PE1:						/* ポートEデータレジスタH */
			CMN_DisableInterrupt();
			outpw(IO_PEDR_PORT, OUT_CPU_PE1);					/* 80H書き込み */
			result = OUT_CPU_PE1;
			break;
		case	CHECK_OUT_CPU_PE2:						/* ポートEデータレジスタH */
			CMN_DisableInterrupt();
			outpw(IO_PEDR_PORT, OUT_CPU_PE2);					/** 00H書き込み */
			result = OUT_CPU_PE2;
			break;
		case	CHECK_OUT_CPU_PE_UB1:					/* ポートEデータレジスタL */
			CMN_DisableInterrupt();
			outpw(IO_PEDR_PORT, OUT_CPU_PE_UB1);				/** 40H書き込み */
			result = RSLT_CPU_PE_UB1;
			break;
		case	CHECK_OUT_CPU_PE_UB2:					/* ポートEデータレジスタL */
			CMN_DisableInterrupt();
			outpw(IO_PEDR_PORT, OUT_CPU_PE_UB2);				/** 00H書き込み */
			result = RSLT_CPU_PE_UB2;
			break;
		case	CHECK_OUT_EXT1:							/* 外部ポート */
			CMN_DisableInterrupt();
			outpw(MODEM2_PORT, OUT_EXT1);					/* 2AH書き込み */
			result = OUT_EXT1;
			break;
		case	CHECK_OUT_EXT2:							/* 外部ポート */
			CMN_DisableInterrupt();
			outpw(MODEM2_PORT, OUT_EXT2);					/** 55H書き込み */
			result = OUT_EXT2;
			break;
		case	CHECK_OUT_EXT_UB1:						/* 外部ポート */
			CMN_DisableInterrupt();
			outpw(MODEM2_PORT, OUT_EXT_UB1);					/** 2AH書き込み */
			result = RSLT_EXT_UB1;
			break;
		case	CHECK_OUT_EXT_UB2:						/* 外部ポート */
			CMN_DisableInterrupt();
			outpw(MODEM2_PORT, OUT_EXT_UB2);					/** 55H書き込み */
			result = RSLT_EXT_UB2;
			break;
		/* I/Oリード項目 */
		case	CHECK_IN_CPU_PA:
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (inpw(IO_PADRL_PORT) & IN_CPU_PA));	/** ジャムカバーを読み、ステータスポートに出力 */
			}
			break;
		case	CHECK_IN_CPU_PA_UB:
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, ((inpw(IO_PADRL_PORT) >> 8) & IN_CPU_PA_UB));	/** ドラムステータスを読み、ステータスポートに出力 */
			}
			break;
		case	CHECK_IN_CPU_PD:
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, ((inpw(IO_PDDRH_PORT) >> 8) & IN_CPU_PD));	/** モータステータスを読み、ステータスポートに出力 */
			}
			break;
#endif
		case	CHECK_IN_CPU_PE:
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (inpw(IO_PEDR_PORT) & IN_CPU_PE));	/** ポートEデータレジスタを読み、ステータスポートに出力 */
			}
			break;
		case	CHECK_IN_CPU_PE_UB:
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, ((inpw(IO_PEDR_PORT) >> 8) & IN_CPU_PE_UB));	/** ポートEデータレジスタを読み、ステータスポートに出力 */
			}
			break;
		case	CHECK_IN_CPU_PF:
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (UWORD)(inp(IO_PFDR_PORT) & IN_CPU_PF));	/** ポートFデータレジスタを読み、ステータスポートに出力 */
			}
			break;
		case	CHECK_IN_MD9604:
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (inpw(SENSOR1_PORT) & IN_MD9604) );	/** 入力ポートCS06を読み、ステータスポートに出力 */
			}
			break;
#if 0	/* (PRO_KEYPANEL == PANEL_ANZU_L) 削除1997/11/14  By T.Yamaguchi */
//		case	CHECK_IN_MD9604H:
//			for (;;) {						/** 無限ループ */
//				outpw( COMMAND_PORT, ((inpw(SENSOR1_PORT) >> 8) & IN_MD9604H) );	/** 入力ポートCS06を読み、ステータスポートに出力 */
//			}
//			break;
#endif
#if (PRO_KEYPANEL == PANEL_POPLAR_B) || (PRO_KEYPANEL == PANEL_POPLAR_L)
		case	CHECK_IN_EXT2:		/** ディップスイッチチェックが指定された */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (inpw(SENSOR2_PORT) & IN_EXT2) );	/** 入力ポートCS06を読み、ステータスポートに出力 */
			}
			break;
#endif
#if (PRO_KEYPANEL == PANEL_POPLAR_B)
		case	CHECK_APS_SENSOR:
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (inpw(APS_SENSOR_PORT) & IO_BIT_XAPS) );	/** 入力ポートCS06を読み、ステータスポートに出力 */
			}
			break;
#endif
		case	CHECK_BUZZER_HIGH:	/* ブザー大	*/
			SCN_SetBuzzerFrequency( ACK_BUZZER_FREQ );		/** 周波数の設定 */
			SYB_MonitorSpeakerOutLevel = SYS_VOLUME_MAXIMUM;	/* ボリューム最大に設定 */
			MonitorSpeakerVolumeControl();
			SpeakerMuteOff();
			SpeakerOutBuzzer();
#if 0
//			SYS_ETC_PortStatus = (IO_BIT_SPVR1 | IO_BIT_SPVR2);		/* ボリューム最大に設定 */
//			SYS_ETC_PortStatus &= ~IO_BIT_MUTE;
//			outpw(ETC_PORT , SYS_ETC_PortStatus);
//
//			SYS_Modem2PortStatus &= ~IO_BIT_RXA_BZ;
//			outpw(MODEM2_PORT, SYS_Modem2PortStatus );
#endif
			SCN_SetBuzzer(SCN_ENABLE);						/** ブザー許可 */
			result = BUZZER_HIGH_OK;
			break;
		case	CHECK_BUZZER_LOW:
			SCN_SetBuzzerFrequency( ACK_BUZZER_FREQ );		/** 周波数の設定 */
			SYB_MonitorSpeakerOutLevel = SYS_VOLUME_MINIMUM;	/* ボリューム最小に設定 */
			MonitorSpeakerVolumeControl();
			SpeakerMuteOff();
			SpeakerOutBuzzer();
#if 0
//			SYS_ETC_PortStatus = IO_BIT_SPVR1;		/* ボリューム最小に設定 */
//			SYS_ETC_PortStatus &= ~IO_BIT_MUTE;
//			outpw(ETC_PORT , SYS_ETC_PortStatus);
//
//			SYS_Modem2PortStatus &= ~IO_BIT_RXA_BZ;
//			outpw(MODEM2_PORT, SYS_Modem2PortStatus );
#endif
			SCN_SetBuzzer(SCN_ENABLE);						/** ブザー許可 */
			result = BUZZER_LOW_OK;
			break;
		case	CHECK_DRAM_WR:
			/** DRAMチェック(WR) */
			CMN_DisableInterrupt();				/** 割り込み禁止 */
			CheckMemory(CHK_WRITE,0x1000000);	/** チェック IC36 */
			result = CHECK_RAM_WRITE;			/* RAMライト完了 */
			break;
		case	CHECK_DRAM_RD:
			/** DRAMチェック(RD) */
			CMN_DisableInterrupt();				/** 割り込み禁止 */
			result = CHECK_DRAM_OK;			/** 検査結果=OK */
			if (CheckMemory(CHK_READ,0x1000000) != OK ) {	/** チェック IC36 */
				result = CHECK_ERROR;	/** IC36 NG */
			}
			break;
		case	CHECK_SRAM_WR:
			/** SRAMチェック(WR) */
			CMN_DisableInterrupt();				/** 割り込み禁止 */
			CheckMemory(CHK_WRITE,0x400000);	/** チェック IC36 */
			CheckMemory(CHK_WRITE,0x440000);	/** チェック IC36 add 1998/01/23  By T.Yamaguchi */
			result = CHECK_RAM_WRITE;			/* RAMライト完了 */
			break;
		case	CHECK_SRAM_RD:
			/** SRAMチェック(RD) */
			CMN_DisableInterrupt();				/** 割り込み禁止 */
			result = CHECK_SRAM_OK;			/** 検査結果=OK */
			if (CheckMemory(CHK_READ,0x400000) != OK ) {	/** チェック IC36 */
				result = CHECK_ERROR;	/** NG */
			}
			if (CheckMemory(CHK_READ,0x440000) != OK ) {	/** チェック IC36  add 1998/01/23  By T.Yamaguchi */
				result = CHECK_ERROR;	/** NG */
			}
			break;
		case	CHECK_MD9604:
			/* MD9604チェック(IC12) */
			/* 何処のアドレスをチェックするかよう確認すること */
			result = CheckIoWordLoop(PRINTER1_PORT ,CHECK_MD9604_OK , CHECK_ERROR );
#if 0
//			result = CheckIoLoop(PRINTER2_PORT ,CHECK_MD9604_OK , CHECK_ERROR );
//			result = CheckIoLoop(PRINTER3_PORT ,CHECK_MD9604_OK , CHECK_ERROR );
//			result = CheckIoLoop(PRINTER6_PORT ,CHECK_MD9604_OK , CHECK_ERROR );
//			result = CheckIoLoop(PRINTER7_PORT ,CHECK_MD9604_OK , CHECK_ERROR );
#endif
			break;
		case	CHECK_MD9605:
			/* MD9605チェック(IDP) */
			/** IDP301チェックが指定された */
			result = CheckIDP( machine, CHECK_IDP301_OK, CHECK_IDP301_NG );	/** IDP301チェック */
			break;
#if (PRO_KEYPANEL == PANEL_POPLAR_B)
		case	CHECK_MD9509:
			/* MD9509チェック(プリンタ) */
			/* 何処のアドレスをチェックするかよう確認すること */
			if (CheckMortor(1)) {
				result = 0xC0;		/* モーター回転中 */
			}
			result = CHECK_MD9509_OK;
			break;
#endif
		case	CHECK_EXTEND_RAM:
			/** 拡張DRAMチェック(RD) */
			result = CHECK_EXT_DRAM_OK;			/** 検査結果=OK */
			CMN_DisableInterrupt();				/** 割り込み禁止 */
			CheckMemory(CHK_WRITE,0x1200000);	/** チェック IC36 */
			if (CheckMemory(CHK_READ,0x1200000) != OK ) {	/** チェック IC36 */
				result |= CHECK_DRAM_EX12_NG;	/** IC36 NG */
			}
			CheckMemory(CHK_WRITE,0x1400000);	/** チェック IC36 */
			if (CheckMemory(CHK_READ,0x1400000) != OK ) {	/** チェック IC36 */
				result |= CHECK_DRAM_EX14_NG;	/** IC36 NG */
 			}
			CheckMemory(CHK_WRITE,0x1600000);	/** チェック IC36 */
			if (CheckMemory(CHK_READ,0x1600000) != OK ) {	/** チェック IC36 */
				result |= CHECK_DRAM_EX16_NG;	/** IC36 NG */
			}
			CheckMemory(CHK_WRITE,0x1800000);	/** チェック IC36 */
			if (CheckMemory(CHK_READ,0x1800000) != OK ) {	/** チェック IC36 */
				result |= CHECK_DRAM_EX18_NG;	/** IC36 NG */
			}
			break;
#if (PRO_CLASS1 == ENABLE)
		case	CHECK_RS232C:
			/*	??????????????????????????????????????????????????????	*/
			/* RS-232C速度19200
			** RS-232Cキャラクタービット8
			** RS-232Cパリティなし
			** RS-232Cストップビット1
			*/
			SYB_SettingStatus[5] = 0x0e;
			Class1InitVar();
			result = CHECK_ERROR;	/* チェックエラー */
			RsTestMode = 0x03;	/* 折り返しテスト */
			RsTestChar = RsTestMode;	/**	テスト用キャラクタ=?をセット	**/
			if (RsOpen('t', 'c', 60) == 1) {
				if ( RsClose('t') == 1) {		/**	テスト終了を待つ	**/
					result = CHECK_RS232C_OK;
				}
			}
#endif
			break;
		case	CHECK_OPTION:
			if (DPRD_CheckSlaveBoardEnable() == 1) {
				result = CHECK_OPTION_OK;
			}
			else {
				result = CHECK_ERROR;	/* チェックエラー */
			}
			break;
#if (PRO_KEYPANEL == PANEL_POPLAR_B) || (PRO_KEYPANEL == PANEL_POPLAR_L)
		case	CHECK_AD_PORT_F0:	/* CASET1 */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (AD__ADDRA >> 2));	/** A/DデータレジスタA */
			}
			break;
		case	CHECK_AD_PORT_F1:	/* CASET2 */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (AD__ADDRB >> 2));	/** A/DデータレジスタB */
			}
			break;
		case	CHECK_AD_PORT_F2:	/* CASET3 */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (AD__ADDRC >> 2));	/** A/DデータレジスタB */
			}
			break;
		case	CHECK_AD_PORT_F3:	/* TEMPR */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (AD__ADDRD >> 2));	/** A/DデータレジスタB */
			}
			break;
		case	CHECK_AD_PORT_F5:	/* HVR */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (AD__ADDRF >> 2));	/** A/DデータレジスタB */
			}
			break;
		case	CHECK_AD_PORT_F6:	/* THMST */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (AD__ADDRG >> 2));	/** A/DデータレジスタB */
			}
			break;
		case	CHECK_AD_PORT_F7:	/* TS */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (AD__ADDRH >> 2));	/** A/DデータレジスタB */
			}
			break;
#endif
		case	CHECK_AD_PORT_F4:	/* BAT */
			for (;;) {						/** 無限ループ */
				outpw( COMMAND_PORT, (AD__ADDRE >> 2));	/** A/DデータレジスタB */
			}
			break;
		case	CHECK_MODEM_TX:				/** モデム送信チェックが指定された */
			CheckModemTx(0);						/** モデム送信チェック */
			result = CHECK_MODEM_TX;
			break;
		case	CHECK_MODEM_RX:				/** モデム受信チェックが指定された */
			result = CheckModemRx();			/** モデム受信チェック */
			break;
/*	その他の項目	*/
		case	CHECK_DMAU:			/** DMAUチェックが指定された */
			CMN_DisableInterrupt();				/** 割り込み禁止 */
			result = CheckIoLoop(DMAU_PORT,CHECK_DMAU_OK,CHECK_DMAU_NG);/** DMAUチェック */
			break;
		case	CHECK_RXA_RXOUT:	/** RXA−RXOUTチェックが指定された*/
			result_out = OUT_OFF;				/** 検査結果出力=OFF */
			outp( ModemFilterControl, CHECK_RXA_RXOUT_BIT);	/** RXA−RXOUT*/
			break;
		case	CHECK_1100_BPF:		/** 1100BPFチェックが指定された*/
			result_out = OUT_OFF;				/** 検査結果出力=OFF */
			outp( ModemFilterControl, CHECK_1100_BPF_BIT);	/** 1100BPF*/
			break;
		case	CHECK_462_LPF:		/** 462LPFチェックが指定された*/
			result_out = OUT_OFF;				/** 検査結果出力=OFF */
			outp( ModemFilterControl, CHECK_462_LPF_BIT);	/** 462LPF*/
			break;
		case	CHECK_CODEC_SCN:	/** CODECスキャナーチェックが指定された */
			result = CheckIoWordLoop( CodecRegisterAddressTable[0][1], CHECK_CODEC_SCN_OK, CHECK_CODEC_SCN_NG );	/** CODECスキャナーチェック */
			break;
		case	CHECK_CODEC_PRN:	/** CODECプリンターチェックが指定された */
			result = CheckIoWordLoop( CodecRegisterAddressTable[1][1], CHECK_CODEC_PRN_OK, CHECK_CODEC_PRN_NG );	/** CODECプリンターチェック */
			break;
		case	CHECK_CODEC_COM:	/** CODEC通信チェックが指定された */
			result = CheckIoWordLoop( CodecRegisterAddressTable[2][1], CHECK_CODEC_COM_OK, CHECK_CODEC_COM_NG );	/** CODEC通信チェック */
			break;
		case	CHECK_SHADING:		/** 白黒判定 for ANZU_L */
			CheckShading();
/*
//			if (DIPP_ShadingExecute() == OK) {
//				result = 0xC0;			@* 終了 *@
//			}
//			else {
//				result = CHECK_ERROR;	@* チェックエラー *@
//			}
*/
			break;
		case CHECK_MOTOR:
			if (CheckMortor(1)) {
				result = 0xC0;		/* モーター回転中 */
			}
			break;
		case CHECK_MOTOR_STOP:
			CheckMortor(0);
			result = 0xC0;		/* モーターSTOP */
			break;
#if (PRO_KEYPANEL == PANEL_POPLAR_B)
		case CHECK_FBS_MOTOR:
			if (CheckMortor(3)) {
				result = 0xC0;		/* FBSモーター回転中 */
			}
			break;
		case CHECK_FBS_MOTOR_STOP:
			CheckMortor(2);
			result = 0xC0;		/* FBSモーターSTOP */
			break;
#endif
		case CHECK_TX_OUT_1080HZ:
			CheckModemTx(1);						/** モデム送信チェック */
		case CHECK_TX_OUT_5000HZ:
			CheckModemTx(2);						/** モデム送信チェック */
		default:	/* ここには来ないはず */
			break;

	}

	/** 検査結果出力 */
	if ( result_out == OUT_ON ) {		/** 検査結果出力=ONの時 */
		for (;;) {						/** 無限ループ */
			outpw(COMMAND_PORT,(UWORD)result);		/** 検査結果ステータス出力 */
		}
	}

	/** 終了処理 */
	CMN_DisableInterrupt();		/** 割り込み禁止 */
	for (;;);						/** 無限ループ */
}
Esempio n. 29
0
bool initVideoMode(word mode, byte pwidth)
{
   int dacAdjust = 0;

   if ( !(encBaseAddr = detectVideoBoard()) ) 
      return mtxFAIL;

   gain = 10000;
   if ( (inp(encBaseAddr + 2) & 0x7) > 0 ) 
      {
      switch (mode)
         {
         case NTSC_STD: 
            ptrEncReg = &ntsca_1;
            gain = 14100;
            break;
         case PAL_STD:  
            ptrEncReg = &pala_1;  
            gain = 14100;
            break;
         case NTSC_STD | VAFC:
            ptrEncReg = &ntsc_1;
            break;

         case PAL_STD | VAFC:
            ptrEncReg = &pal_1;
            break;
         }
      if ( mode & VAFC )
         {
         switch( pwidth )
            {
            case  8:
               dacAdjust = 4;
               break;

            case 16:
               dacAdjust = 2;
               break;

            case 32:
               dacAdjust = 0;
               break;
            }
         }
      else
         {
	      switch(Hw[iBoard].DacType)
            {
		      case BT482:
		      case BT485: 
               switch( pwidth )
                  {
                  case  8:
                     dacAdjust = 0;
                     break;

                  case 16:
                  case 32:
                     dacAdjust = 1;
                     break;
                  }
               break;
            
		      case VIEWPOINT: 
               dacAdjust = 5;
               break;


            case TVP3026:   
               switch( pwidth )
                  {
                  case  8:
                     dacAdjust = 18;
                     break;

                  case 16:
                     dacAdjust = 22;
                     break;

                  case 32:
                     dacAdjust = 26;
                     break;
                  }
               break;
            }

         }

      }
   else
      switch (mode)
         {
         case NTSC_STD: 
            ptrEncReg = &ntsca_0;
            break;
         case PAL_STD:  
            ptrEncReg = &pala_0;  
            break;
         case NTSC_STD | VAFC: 
            switch (pwidth)
               {
               case  8: ptrEncReg = &ntsc8_0;  break;
               case 16: ptrEncReg = &ntsc16_0; break;
               case 32: ptrEncReg = &ntsc32_0; break;
               }
            break;
         case PAL_STD | VAFC: 
            switch (pwidth)
               {
               case  8: ptrEncReg = &pal8_0;  break;
               case 16: ptrEncReg = &pal16_0; break;
               case 32: ptrEncReg = &pal32_0; break;
               }
            break;
         }


   init_denc();
   init_dac();
   init_adc();
   init_psg( dacAdjust );
   init_ctrl();
   init_luts(); 

   return mtxOK;
}
Esempio n. 30
0
/* WARNING: This code crashes DOSBox 0.74 with "PIC poll not handled" error message */
unsigned char p8259_poll(unsigned char c) {
	/* issue poll command to read and ack an interrupt */
	p8259_OCW3(c,0x0C);	/* OCW3 = POLL=1 SMM=0 RR=0 */
	return inp(p8259_irq_to_base_port(c,0));
}