Exemple #1
0
void main()
{
   PRINTS("     |\\      _,,,---,,_\r\n\0");
   PRINTS("     /,`.-\'`\'    -.  ;-;;,_\r\n\0");
   PRINTS("    |,4-  ) )-,_..;\\ (  `\'-\'\r\n\0");
   PRINTS("   \'---\'\'(_/--\'  `-\'\\_)\r\n\0");
   PRINTS("Soft Kitty, Warm Kitty,\r\n\0");
   PRINTS("  little ball of fur.\r\n\0");
   PRINTS("    Happy Kitty, Sleepy Kitty,\r\n\0");
   PRINTS("              purr, purr, purr.\r\n\0");
   END;
}
void MD_PZone::setInitialConditions(void)
// set the global variables initial conditions for all display effects
{
	PRINTS("\nsetInitialConditions");

	if (_pText == NULL)
	return;

	_pCurChar = _pText;
	_limitOverflow = !calcTextLimits(_pText);
}
Exemple #3
0
int namei(char *filename)
{
	int len = 0;
	struct ext2_dir_entry_2 *pdir;

	pdir = (struct ext2_dir_entry_2 *)get_block(get_inode(2)->i_block[0]);
	while (len < block_size)
	{
		PRINTS(filename);
		PRINTS(pdir->name);
		PRINTD(strlen(filename));
		PRINTD(pdir->name_len);
		if (strlen(filename) == pdir->name_len)
		{
			if (strncmp(filename, pdir->name, pdir->name_len) == 0)
				return pdir->inode;
		}
		len += pdir->rec_len;
		pdir = (struct ext2_dir_entry_2 *)((int)pdir + pdir->rec_len);
	}

	return -1;
}
Exemple #4
0
void tweet(char* fName)
{
   char buffer[140];
   if(fName[0] >= 'A' && fName[0] <= 'Z')
   {
      ERROR(1);
   }
   else
   {
      PRINTS("Enter text to write to file, end with Enter key.\r\n\0");
      SCANS(buffer);
      WRITEF(fName,buffer,1);
   }
}
void MD_PZone::moveTextPointer(void)
// This method works when increment is done AFTER processing the character
// the _endOfText flag is set as a look ahead (ie, when the last character
// is still valid)
// We need to move a pointer forward or back, depending on the way we are
// travelling through the text buffer.
{
	PRINTS("\nMovePtr");

	if (SFX(SCROLL_RIGHT))
	{
		PRINTS(" --");
		_endOfText = (_pCurChar == _pText);
		_pCurChar--;
	}
	else
	{
		PRINTS(" ++");
		_pCurChar++;
		_endOfText = (*_pCurChar == '\0');
	}

	PRINT(": endOfText ", _endOfText);
}
void MD_MAX72XX::buildFontIndex(void)
{
  uint16_t	offset = 0;

  if (_fontIndex == NULL)
    return;

  PRINTS("\nBuilding font index");
  for (int16_t i=0; i<FONT_INDEX_SIZE; i++)
  {
	_fontIndex[i] = offset;
	PRINT("\nASCII '", i);
	PRINT("' offset ", _fontIndex[i]);
	offset += pgm_read_byte(_fontData+offset);
	offset++;
  }
}
uint16_t MD_PZone::getTextWidth(char *p)
// Get the width in columns for the text string passed to the function
// This is the sum of all the characters and the space between them.
{
	uint16_t	sum = 0;

	PRINTS("\ngetTextWidth");

	while (*p != '\0')
	{
		sum += findChar(*p++, ARRAY_SIZE(_cBuf), _cBuf);
		if (*p)
		sum += _charSpacing;
	}

	PRINT(": W=", sum);

	return(sum);
}
Exemple #8
0
void dir()
{
   char buffer[512];
   char fname[512];
   int index = 0;
   int i;
   int runs = 0;
   int size = 0;
   int total = 0;

   READS(buffer,2);
   while(buffer[index] != 0x0)
   {
      for (i = 0; i < 6; ++i)
      {
         fname[i] = buffer[index + i];
      }
      for (i = 6; i<32; ++i)
      {
         if (buffer[index + i] == 0x0)
         {
            break;
         }
         else
         {
            ++size;
         }
      }
      total = total + size;
      /* CHeck if filename starts with a capital */
      if(fname[0] >= 'A' && fname[0] <= 'Z')
      {
      }
      else
      {
         PRINTS("File name: \0");
         PRINTS(fname);
         PRINTS("        File size: \0");
         PRINTN(size);
         PRINTS("\r\n\0");
      }
      size = 0;
      runs = runs + 6;
      index = index + 32;
   }
   PRINTS("\r\nTotal Sectors used: \0");
   PRINTN(total);
   PRINTS("\r\nSectors free: \0");
   PRINTN(48-total);
}
uint8_t MD_PZone::getNextChar(void)
// load the next char into the char buffer
// return 0 if there are no characters
{
	uint8_t len = 0;

	PRINTS("\ngetNext ");

	if (_endOfText)
	return(0);

	len = makeChar(*_pCurChar);

	if (SFX(SCROLL_RIGHT))
	reverseBuf(_cBuf, len);

	moveTextPointer();

	return(len);
}
uint16_t MD_MAX72XX::getFontCharOffset(uint8_t c)
{
  PRINT("\nfontOffset ASCII ", c);

  if (_fontIndex != NULL)
  {
    PRINTS("' from Table");
    return(_fontIndex[c]);
  }
  else
  {
	uint16_t	offset = 0;

	for (int8_t i=0; i<c; i++)
	{
	  offset += pgm_read_byte(_fontData+offset);
	  offset++;	// skip size byte we used above
	}
    PRINT("' searched offset ", offset);

	return(offset);
  }
}
Exemple #11
0
void main()
{
   int i, a = 1, b = 1, c, n;
   PRINTS("How many terms? \0");
   SCANN(n);
   if (n < 3) n = 3;
   PRINTN(n);
   PRINTS(" terms: \0");
   PRINTN(a);
   PRINTS(" \0");
   PRINTN(b);
   PRINTS(" \0");
   for (i = 0; i < n - 2; i++)
   {
      c = a + b;
      PRINTN(c);
      PRINTS(" \0");
      a = b;
      b = c;
   }
   PRINTS("\r\n\0");
   END;
}
Exemple #12
0
int main(int argc, char** argv)
{
    int exitCode = 0;

    /*
        create a pi|engine instance and initialize it.
        Initialization step loads and prepares the resources,
        initializes the engine and sets up game window
        unless application configuration states otherwise.
    */

    application app;

    gcString s = "Test_";
    gcString s2("shit");
    gcString s3 = gcString("coca") + "cola" + "[]";
    gcString s4 = "OLD";
    s4 = ">" + s + " " + s3 + " " + s4;   //Test cocacola[] OLD
    gcString s5 = gcString::gcFromInt(600);
    gcString s6 = s + s5 + " " + s2;
    s6 += " [";
    s6 += gcString::gcFromInt(60) + "]";

    for(int i=1;i<=100;i++)
    {
        s += gcString::gcFromInt(i) +",";
    }
    s += s + s;  //selfref test

    gcArray<gcString>* a = new gcArray<gcString>;
    a->setSize(13);

    // strings test
    (*a)[0] = "2500";
    (*a)[0].setw(8,"0");
    (*a)[1] = "Pesho";
    (*a)[1].setw(20,"[abc]");
    (*a)[2] = "acbdefghijkl";
    (*a)[2].setw(4);
    (*a)[3] = "5300";
    (*a)[3].setw(10);
    (*a)[4] = "681";
    (*a)[4].setw(10,"");   //case that is not allowed
    (*a)[5] = "123";
    (*a)[5].setw(10,"-");
    (*a)[6] = "Peter";
    (*a)[6].setrw(10,"-");
    (*a)[7] = "Peter";
    (*a)[7].setrw(3);
    (*a)[8] = "*-PeterSvP1870_test[100]-*X";
    (*a)[10] = (*a)[8].digits();
    (*a)[8] = (*a)[8].letters();
    (*a)[9] = (*a)[8].toLower();

    (*a)[11] = (*a)[8][0] + (*a)[8][1];

    (*a)[12] = "Pes*o";
    (*a)[12].setchar(3,"h");


    //show them:
    for(int i=0;i<a->count();i++)
    {
        gcString output;
        output = "a[" + gcString::gcFromInt(i) + "]= " + (*a)[i] + "\n";
        std::cout << output;
    }


    std::cout
        << "s = " << s  << std::endl
        << "s2= " << s2 << std::endl
        << "s3= " << s3 << std::endl
        << "s4= " << s4 << std::endl
        << "s5= " << s5 << std::endl
        << "s6= " << s6 << std::endl
    ;




#define PRINTINT(gc_array_var) \
    for(int i=0;i<gc_array_var.count();++i) \
        std::cout << "int[" << gcString::gcFromInt(i) << "] = " << gcString::gcFromInt( gc_array_var.gcAt(i) ) << std::endl;

#define PRINTS(gc_array_var) \
    for(int i=0;i<gc_array_var.count();++i) \
        std::cout << "string[" << gcString::gcFromInt(i) << "] = " << gc_array_var.gcAt(i) << std::endl;
    /*  gcArray test */

    // INT
    {
        gcArray<int> a;
        a.setSize(5);   //must add 5 zeros
        a << 1 << 2 << 50 << 100;   //and add 1,2,50,100 finally

        std::cout << "A:\n";
        PRINTINT(a);
        std::cout << "B:\n";
        gcArray<int>* b = a.clone();
        b->removeDuplicates();
        (*b) << 75;
        b->sort();
        PRINTINT( (*b) );
    }

    // STRING
    {
        gcArray<gcString> *a = new gcArray<gcString>, *b = new gcArray<gcString>, *c = a;
        //c i s same as a?
        (*c) << "1" << "2";
        (*a) << "3" << "4";
        (*c) << "5" << "6";
        a->setSize(10);
        (*c) << "5" << "Pi-Dev";
        (*a).insertAfter(5,"7");
        (*a).insertBefore(0,"begin");
        (*a).insertAfter( (*a).count()-1, "Appended" );

        //delete b;   //These calls must be somehow inserted by gameScript optimizer directly;

        b = a->clone(); //this will effectively invalidate b! There MUST be an memory manager
        b->removeDuplicates();
        c = c->clone();  //it is internally okay ;] C is now copy of a
        c = c->getDuplicates();  //c will only need to show "" and 5 now ;]
        b->sort();

        std::cout << "A[]:\n";
        PRINTS((*a));
        std::cout << "B[]:\n";
        PRINTS((*b));
        std::cout << "C[]:\n";
        PRINTS((*c));

    }

    {
        std::cout << "POINTER TYPE sort\n";
        gcArray<int*> a;
        a << new int(4) << new int(2) << new int(100) << new int(3);
        a.sort();

        std::cout<<"Count: "<<a.count() << "\n";

        for(int i=0;i<a.count();++i)
        {
            std::cout << *(a[i]) << std::endl;
        }
    }

    {
        gcArray<std::string>* a = new gcArray<std::string>;
        (*a) << "Dimo" << "Pesho" << "Atanas";

        a->sort();

        for(int i=0;i<a->count();++i)
        {
            std::cout << (*a)[i] << std::endl;
        }
    }

    {
        //2d Array test:
        gcArray2D<int> ia;
        ia.setSize(3,5);
        ia(0,1) = 10;
        ia(1,1) = 20;
        ia(2,4) = 45;
        for(int y=0;y<ia.yCount();++y)
        {
            for(int x=0;x<ia.xCount();++x)
                std::cout << gcString::gcFromInt(ia(x,y)).setw(6,".") << " ";
            std::cout << "\n";
        }
    }

    {
        /* 3D Array test */
        gcArray3D<gcString> a;
        a.setSize(5,4,3);
        for(int x=0;x<3;++x)
            for(int y=0;y<3;++y)
                a(x,y,2) = "Stone";

        a(0,0,0) = "Cloud";
        a(1,0,0) = "Cloud";
        a(0,0,1) = "Player";
        a(1,0,1) = "Item";
        a(1,1,1) = "Item";
        a(4,3,2) = "Bound";

        for(int z=0;z<a.zCount();++z)
        {
            std::cout<<"z = "<< gcString::gcFromInt(z) << "\n";
            for(int y=0;y<a.yCount();++y)
            {
                for(int x=0;x<a.xCount();++x)std::cout<<"["<<a(x,y,z).setw(6,"-")<<"]";
                std::cout<<"\n";
            }
            std::cout<<"\n";
        }
    }


#undef PRINTS
#undef PRINTINT

    if(app.init())exitCode = app.run();
    else std::cout
            << "Initialization failed with following error:\n"
            << app.lastException->text
            << "\n";

    std::cout<<"Application closed with exit code "<<exitCode<<"!\n\n";
    return exitCode;
}
Exemple #13
0
INT main( )
{
	const DWORD N_COL_SCREEN = 	VGA_RESOLUTION_WIDTH / N_VGA_PIXEL_PER_ONCE;
	DWORD i = 0;
	DWORD j = 0;
	volatile DWORD * p_color_line = NULL;

	PRINTS( "The VGA driver started\n" );

#ifdef VGA_EMUL
	puts( "VGA emul mode\n" );

	const int DUMP_FRAME = 3;

	// initialize the driver
	if( vga_emul_init( ) == FALSE )
	{
		PRINTS( "FILE OPEN ERROR!\n" );
	}
#endif

	while( !vga_is_refreshing( ) );
	puts( "vga initial refresh\n" );

	DEADPLL( N_VGA_CLK_V_SYNC );

	while( TRUE )
	{
		// process superfield
		
		// process vsync
		IOWR_32DIRECT( IO_ADDR_VGA, 0, VGA_COLOR_V_SYNC );
		IOWR_8DIRECT( IO_ADDR_VGA, 1, VGA_CONTROL_V_SYNC_ON );
		DEADPLL( N_VGA_CLK_V_BP );
		IOWR_8DIRECT( IO_ADDR_VGA, 1, VGA_CONTROL_V_SYNC_OFF );
		PRINTS( "VSYNC PROCESSED\n" );
		
		// process back-porch line
		// during back-porch line, refresh the screen buffer
		if( vga_is_refreshing( ) )
		{
			vga_toggle_graphic_buffer( );
			puts( "vga refreshed\n" );
#ifdef	VGA_EMUL
			n_frame++;
			//			puts( "n_frame: %d\n", n_frame );
			if( n_frame == DUMP_FRAME )
			{
				puts( "start dump\n" );
			}
#endif
		}

		DEADPLL( N_VGA_CLK_H_SYNC );
		PRINTS( "BP LINE PROCESSED\n" );
		
		// draw field
		for( i = 0; i < VGA_RESOLUTION_HEIGHT; i++ )
		{
			// process hsync
			IOWR_32DIRECT( IO_ADDR_VGA, 0, VGA_COLOR_H_SYNC );
			IOWR_8DIRECT( IO_ADDR_VGA, 1, VGA_CONTROL_H_SYNC_ON );
			//p_color_line = &_screen[ _current_buffer ][ i ][ 0 ];	// access the screen memory in advance
			p_color_line = ( _screen + ( *( _current_buffer ) * VGA_RESOLUTION_HEIGHT * N_COL_SCREEN ) + ( i * N_COL_SCREEN ) );	// access the screen memory in advance
			j = N_COL_SCREEN - 1;
			DEADPLL( N_VGA_CLK_H_BP );
			IOWR_8DIRECT( IO_ADDR_VGA, 1, VGA_CONTROL_H_SYNC_OFF );
			PRINTS( "HSYNC PROCESSED\n" );
			int tmp = *p_color_line;
			int limit = ( int ) ( p_color_line + N_COL_SCREEN - 1 );
			// process back-porch pixel
			PRINTS( "BP PIXEL PROCESSED\n" );

			// draw horizontal pixels
			do
			{
#ifdef VGA_EMUL
				if( n_frame == DUMP_FRAME )
				{
					vga_emul_plot_pixel( *p_color_line );
				}
#else
				DEADPLLI( "10" );
				IOWR_32DIRECT( IO_ADDR_VGA, 0, *p_color_line );
#endif
			} while( ( int ) p_color_line++ < ( int ) limit );

			// process front-porch pixel
			DEADPLL( N_VGA_CLK_H_FP );
			IOWR_32DIRECT( IO_ADDR_VGA, 0, VGA_COLOR_H_FP );
			DEADPLL( N_VGA_CLK_H_SYNC );
			PRINTS( "FP PIXEL PROCESSED\n" );
		}

		//puts( "FRAME DRAWING END: %d\n", i );

#ifdef VGA_EMUL
		if( n_frame == DUMP_FRAME )
		{
			puts( "end dump\n" );
		}
#endif

		// process front-porch line
		IOWR_32DIRECT( IO_ADDR_VGA, 0, VGA_COLOR_V_FP );
		DEADPLL( N_VGA_CLK_V_FP - N_VGA_CLK_H_SYNC );
		DEADPLL( N_VGA_CLK_V_SYNC );
		PRINTS( "FP LINE PROCESSED\n" );
	}
	
	return 0;
}
bool MD_PZone::calcTextLimits(char *p)
// Work out left and right sides for the text to be displayed,
// depending on the text alignment. If the message will not fit
// in the current display the return false, otherwise true.
{
	bool b = true;
	uint16_t	displayWidth = ZONE_END_COL(_zoneEnd) - ZONE_START_COL(_zoneStart);
	
	_textLen = getTextWidth(p);

	PRINTS("\ncalcTextLimits");

	switch (_textAlignment)
	{
		case LEFT:
		_limitLeft = ZONE_END_COL(_zoneEnd);
		if (_textLen > displayWidth)
		{
			_limitRight = ZONE_START_COL(_zoneStart);
			b = false;
		}
		else
		{
			_limitRight = _limitLeft - _textLen;
		}
		break;

		case RIGHT:
		_limitRight = ZONE_START_COL(_zoneStart);
		if (_textLen > displayWidth)
		{
			_limitLeft = ZONE_END_COL(_zoneEnd);
			b = false;
		}
		else
		{
			_limitLeft = _limitRight + _textLen;
		}
		break;

		case CENTER:
		if (_textLen > displayWidth)
		{
			_limitLeft = ZONE_END_COL(_zoneEnd);
			_limitRight = ZONE_START_COL(_zoneStart);
			b= false;
		}
		else
		{
			_limitRight = ZONE_START_COL(_zoneStart) + (displayWidth - _textLen)/2;
			_limitLeft = _limitRight + _textLen;
		}
		break;
	}

	PRINT(" L:", _limitLeft);
	PRINT(" R:", _limitRight);
	PRINT(" O:", !b);

	return (b);
}
Exemple #15
0
void main()
{
   char x[512];
   char buffer[512];
   int size;

   while(1)
   {
      interrupt(33,0,"cxxxx][===blackdos===> \0",0,0);

      /* Takes command line input */
      SCANS(x);
      PRINTS("\r\n\0");

      if(strcmp(x,"boot\0") == 1)
      {
         BOOT;
      }
      else if(strcmp(x,"cls\0") == 1)
      {
         clr();
      }
      else if(strcmp(x,"help\0") == 1)
      {
         help();
      }
      else if(strcmp(x,"echo\0") == 1)
      {
         echo(x+5);
      }
      else if(strcmp(x,"type\0") == 1)
      {
         loadF(x+5,buffer,size);
      }
      else if(strcmp(x,"run\0") == 1)
      {
         runF(x+4);
      }
      else if(strcmp(x,"del\0") == 1)
      {
         delF(x+4);
      }
      else if(strcmp(x,"dir\0") == 1)
      {
         dir();
      }
      else if(strcmp(x,"tweet\0") == 1)
      {
         tweet(x+6);
      }
      else if(strcmp(x,"cp\0") == 1)
      {
         copy(x+3);
      }
      else
      {
         interrupt(33,0,"\r\nBad command or filename\r\n\0",0,0);
      }
      interrupt(33,0,"\r\n\0",0,0);
   }
   END;
}
Exemple #16
0
int main(int argc, char *argv[])
{
	char * filename = "fs";
	int fd = 0;
	int counter = 0;
	int gb;		// group block number

	if (argc >= 2)
		filename = argv[1];

	fd = open(filename, O_RDWR);
	if (fd < 0)
	{
		printf("open file %s failed\n", filename);
		return 0;
	}

	printf("open file %s ok\n", filename);

	p = mmap(NULL, 1024*1024, PROT_WRITE, MAP_SHARED, fd, 0);
	close(fd);	

	PRINTD(get_super_block()->s_inodes_count);
	PRINTD(get_super_block()->s_blocks_count);
	PRINTD(get_super_block()->s_log_block_size);
	PRINTD(get_super_block()->s_inode_size);
	PRINTD(get_super_block()->s_first_data_block);

	inode_size = get_super_block()->s_inode_size;
	block_size = 1024 << (get_super_block()->s_log_block_size);
	PRINTD(block_size);
	PRINTD(inode_size);

	group_block = get_super_block()->s_first_data_block + 1;

	gb = group_block;
	PRINTD(((struct ext2_group_desc *)get_block(gb))->bg_block_bitmap);
	PRINTD(((struct ext2_group_desc *)get_block(gb))->bg_inode_bitmap);
	PRINTD(((struct ext2_group_desc *)get_block(gb))->bg_inode_table);

	PRINTD(get_inode(2)->i_block[0]);

	//ls();
	//cat("test.txt");

	printf("\n");

	while (1)
	{
		char buf[64];
		char cmd[32];
		char arg[32];
		int ret = 0;

		printf("MyExt2 # ");
		//scanf("%s %s", cmd, arg);
		fgets(buf, 64, stdin);
		ret = sscanf(buf, "%s %s", cmd, arg);

		if (ret == 0)
			continue;

		PRINTS(cmd);
		PRINTS(arg);

		if (strcmp(cmd, "ls") == 0)
			ls();

		if (strcmp(cmd, "cat") == 0)
			cat(arg);

		if (strcmp(cmd, "exit") == 0)
			break;
	}

	munmap(p, 1024*1024);

	return 0;
}
Exemple #17
0
void main()
{
   int mo, day, yr, noDays, i, c;
   mo = -1;
   while (mo < 1 || mo > 12)
   {
      PRINTS("Enter desired month: \0");
      SCANN(mo);
      PRINTS("\r\n\0");
   }
   PRINTS("Enter desired year: \0");
   SCANN(yr);
   PRINTS("\r\n\0");
   if (yr < 100) yr += 2000;
   day = firstOfMonth(mo,yr);
   PRINTS("\r\n\0");
   switch(mo)
   {
      case 1:  PRINTS("January \0");   noDays = 31; break;
      case 2:  PRINTS("February \0");  noDays = 28 + isLeapYear(yr); break;
      case 3:  PRINTS("March \0");     noDays = 31; break;
      case 4:  PRINTS("April \0");     noDays = 30; break;
      case 5:  PRINTS("May \0");       noDays = 31; break;
      case 6:  PRINTS("June \0");      noDays = 30; break;
      case 7:  PRINTS("July \0");      noDays = 31; break;
      case 8:  PRINTS("August \0");    noDays = 31; break;
      case 9:  PRINTS("September \0"); noDays = 30; break;
      case 10: PRINTS("October \0");   noDays = 31; break;
      case 11: PRINTS("November \0");  noDays = 30; break;
      default: PRINTS("December \0");  noDays = 31;
   }
   PRINTN(yr);
   PRINTS("\r\n\0");
   PRINTS("Su Mo Tu We Th Fr Sa\r\n\0");
   PRINTS("====================\r\n\0");
   for (i = 1; i <= day; i++) PRINTS("   \0");
   c = day;
   for (i = 1; i <= noDays; i++)
   {
      if (i < 10) PRINTS(" \0");
      PRINTN(i);
      PRINTS(" \0");
      c = c + 1;
      if (c == 7)
      {
         c = 0; PRINTS("\r\n\0");
      }
   }
   PRINTS("\r\n\0");
   END;
}
Exemple #18
0
void help()
{
   PRINTS("\r\n\r\nHelp Manual: \r\n\r\n\0");
   PRINTS("Command:               Usage: \r\n\0");
   PRINTS("boot                   Reboot the OS.\r\n\0");
   PRINTS("cls                    Clear the screen.\r\n\0");
   PRINTS("copy <file1> <file2>   Copy file1 into file2.\r\n\0");
   PRINTS("del <file>             Delete file.\r\n\0");
   PRINTS("dir                    List disk directory.\r\n\0");
   PRINTS("echo <message>         Displays specified message.\r\n\0");
   PRINTS("help                   Displays this message.\r\n\0");
   PRINTS("run <file>             Executes specified file.\r\n\0");
   PRINTS("tweet <file>           Creates a file, and asks for text input.\r\n\0");
   PRINTS("type <file>            Displays contents of specified file.\r\n\0");
}
Exemple #19
0
void echo(char* x)
{
   PRINTS(x);
}