Exemplo n.º 1
0
Arquivo: intro.c Projeto: callaa/luola
/* Draw the intro messagebox */
static void intro_draw_message (void)
{
    fill_box(screen,intr_message.x+2,intr_message.y+2,intr_message.w-4,
            intr_message.h-4,intr_message.fillcolor);

    draw_box (intr_message.x, intr_message.y, intr_message.w, intr_message.h,
              2, intr_message.framecolor);
    SDL_BlitSurface (intr_message.text, NULL, screen, &intr_message.textrect);
}
Exemplo n.º 2
0
/** @brief Init OS after load.
 *  @param NULL
 *  @return NULL
 */
void OS_Init(void)
{
	BOOTINFO* info;
	
	int32 screenWidth, screenHeight;
	uint8* bgBuf, *resVram;
	boolean re[2];
	uint32 tmpAddr;

	InitPeripheralBuffer();
	
	init_gdtidt();
	init_pic();
	io_sti();		// 恢复中断
	tim_init();
	io_out8(PIC0_IMR, 0xf8); /* PIT和PIC1和键盘设置为许可(11111000) */
	io_out8(PIC1_IMR, 0xef); /* 鼠标设置为许可(11101111) */
	
	info = (BOOTINFO*) ADR_BOOTINFO;
	screenHeight = info->screenHeight;
	screenWidth = info->screenWidth;
	
	init_palette();
	mem_init();
	fat_init();
	re[0] = mem_alloc(768 * 1024, &tmpAddr);
	resVram = (uint8*)tmpAddr;
	sheet_init(resVram);
	
	InitMouse();
	InitKeyboard();
	
	re[1] = mem_alloc(768 * 1024, &tmpAddr);
	bgBuf = (uint8*)tmpAddr;
	
	//screenWidth * screenHeight
	sheet_add(bgBuf, screenWidth, screenHeight, 0, 0, NONE_COL, &bgSheet);

	fill_box(bgSheet, DARKGRASS, 0, 0, info->screenWidth, info->screenHeight);
	if(re[0] == FALSE || re[1] == FALSE) {
		fill_box(bgSheet, RED, 0, 0, info->screenWidth, info->screenHeight);
	}
}
Exemplo n.º 3
0
/* Draw a single weapon selection bar */
static SDL_Rect draw_weapon_bar(SDL_Surface *surface,int plr) {
    SDL_Rect rect;
    Uint32 color;
    int i,plrs=0;
    switch(plr) {
        case 0: color = map_rgba(156,0,0,255); break;
        case 1: color = map_rgba(0,0,156,255); break;
        case 2: color = map_rgba(0,156,0,255); break;
        case 3: color = map_rgba(156,156,0,255); break;
        default: color = 0;
    }

    rect.x = 0; rect.w = screen->w/4-WEAPON_SEP;
    rect.h = font_height(Bigfont);

    rect.y = 0;
    for(i=0;i<4;i++) {
        if(players[i].state != INACTIVE) {
            plrs++;
            if(i<plr) rect.y += rect.h + WEAPON_SEP;
        }
    }

    rect.y += screen->h/2 - ((rect.h + WEAPON_SEP) * plrs)/2;

    fill_box(surface,rect.x,rect.y,rect.w,rect.h,color);

    putstring_direct(surface, Bigfont, rect.x + 10, rect.y,
            normal_weapon[players[plr].standardWeapon].name, font_color_white);

    rect.x = rect.w + WEAPON_SEP;
    rect.w = screen->w - rect.x;

    fill_box(surface,rect.x,rect.y,rect.w,rect.h,color);

    putstring_direct(surface, Bigfont, rect.x + 10, rect.y,
            special_weapon[players[plr].specialWeapon].name, font_color_white);

    rect.x = 0;
    rect.w = screen->w;

    return rect;
}
Exemplo n.º 4
0
        /*!
         * The following function works similarly to fill_box except that it also draws a black
         * "shadow" across the bottom of the box and down the right side of the box. This shadow
         * is one row high and two columns wide. This function assumes it will fit.
         *
         * \param row The row coordinate of the top of the box.
         * \param column The column coordinate of the left side of the box.
         * \param width The width of the box.
         * \param height The height of the box.
         */
        void fill_shadowed_box( int row, int column, int width, int height )
        {
            int index;

            // Fill the main region in the current color.
            fill_box( row, column, width, height );

            // Draw the shadow along the bottom. Assume it fits.
            set_color( B_BLACK );
            position_cursor( row + height, column + width + 1 );
            for( index = column + 2; index <= column + width + 1; index++ ) std::cout << " ";

            // Draw the shadow down the right side. Assume it fits.
            for( index = row + 1; index <= row + height; index++ ) {
                position_cursor( index, column + width );
                std::cout << "  ";
            }
        }
Exemplo n.º 5
0
/* Returns the width of the thumbnail */
static int draw_level(SDL_Surface *surface, struct LevelThumbnail *level,
        int x,int y,int visibility,int selected)
{
    int thwidth;
    SDL_Rect rect;
    Uint8 alpha;
    rect.x = x;
    rect.y = y;
    if(level->thumbnail) {
        SDL_Rect src = {0,0,level->thumbnail->w,level->thumbnail->h};
        thwidth = level->thumbnail->w;
        if(rect.x<0) {
            src.x = -rect.x;
            src.w -= src.x;
            rect.x = 0;
        }
        if(visibility > level->thumbnail->w)
            alpha = SDL_ALPHA_OPAQUE;
        else
            alpha = visibility/(double)level->thumbnail->w*SDL_ALPHA_OPAQUE;
        SDL_SetAlpha(level->thumbnail,SDL_SRCALPHA,alpha);
        SDL_BlitSurface(level->thumbnail,&src,surface,&rect);
    } else {
        rect.w = THUMBNAIL_HEIGHT;
        rect.h = THUMBNAIL_HEIGHT;
        thwidth = rect.w;
        if(visibility > THUMBNAIL_HEIGHT)
            alpha = SDL_ALPHA_OPAQUE;
        else
            alpha = visibility/(double)THUMBNAIL_HEIGHT*SDL_ALPHA_OPAQUE;
        fill_box(surface,rect.x,rect.y,rect.w,rect.h,map_rgba(0,0,0,alpha));
    }
    if(selected) {
        draw_box(rect.x-3, rect.y-3, rect.w+6, rect.h+6, 3, col_cyan);
        rect.y += rect.h + 4;
        rect.x += rect.w/2 - level->name->w/2;
        SDL_BlitSurface(level->name,NULL,surface,&rect);
    }

    return thwidth;
}
Exemplo n.º 6
0
void OS_Main(void)
{
	uint32 tmpAddr;
	WND* topWnd;
	int8 buf[10];
	TASK	*task;// *taskB, *taskC;
	WND_CONSOLE* console;
	char* wStr[64];
	
	OS_Init();
	
	fill_box(bgSheet, BLACK, 0, 0, 160, 16);
	sprintf(printBuf, "MemVol:%dMB", mem_getTotalSize() / (1024 * 1024));
	puts_str(bgSheet, printBuf, WHITE, 0, 0);

	multiTask_init();
//	console_puts(&wnd, "%s\n", "学挖掘机^_^,还到山东蓝翔!wwy");
	strcpy(wStr, "a学挖掘机到底!にほんご哪家强?");
	puts_str(bgSheet, wStr, WHITE, 32, 32);
	strcpy(wStr, "学挖掘机^_^,还到山东蓝翔!");
	puts_str(bgSheet, wStr, GREEN, 32, 48);
//	put_ascii(bgSheet, 0xD0D6, WHITE, 32, 32);
//	put_ascii(bgSheet, 'w', BLACK, 32, 48);
	sheet_draw_all();
		
	while(1){
		if(KeyboardGetChar(buf, 1)) {
			fill_box(bgSheet, BLACK, 0, 232, 100, 248);
			puts_str(bgSheet, buf, WHITE, 0, 232);
			sheet_add_redraw_region(0, 232, 100, 248);
			topWnd = wnd_get_top();
			if(topWnd != NULL) {
				PutIntoLoopArray(topWnd->keyboardBuffer, buf[0]);
			}
		}
		MouseKeyboardDeamon();
		sheet_draw_deamon();
		if(keyboardCtl.AltOn == TRUE && keyboardCtl.F4_On == TRUE) {
			console = (WND_CONSOLE*)*((int*)0xFEC);
			if(console->task->tss.ss0 != 0) {
				console_puts(console, "\nBreak(key) :\n");
				io_cli();
				console->task->tss.eax = (int) &(console->task->tss.esp0);
				console->task->tss.eip = (int) asm_end_app;
				io_sti();
				keyboardCtl.AltOn = FALSE;
				keyboardCtl.F4_On = FALSE;
			}
		}
		else if(keyboardCtl.WinOn == TRUE && keyboardCtl.F1_On == TRUE) {
			//Console Task
			mem_alloc(64 * 1024, &tmpAddr);
			tmpAddr += 64 * 1024 - 12;
			*((int*)(tmpAddr + 4)) = (int)bgSheet;
			task_alloc("Task Console", (int32)&task_console_main, tmpAddr, 0x00000202, 1, &task);
			*((int*)(tmpAddr + 8)) = (int)task;
			task->tss.cs = 2 * 8;		//目前必须为 2 × 8
			task_run(task);
				keyboardCtl.WinOn = FALSE;
				keyboardCtl.F1_On = FALSE;
		}
	}
	// 不能有 return 
}
/*
 *************************************************************************
 *
 * computeFillBoxesAndNeighborhoodSets
 *
 *************************************************************************
 */
void
PatchLevelEnhancedFillPattern::computeFillBoxesAndNeighborhoodSets(
   boost::shared_ptr<hier::BoxLevel>& fill_box_level,
   boost::shared_ptr<hier::Connector>& dst_to_fill,
   const hier::BoxLevel& dst_box_level,
   const hier::IntVector& fill_ghost_width,
   bool data_on_patch_border)
{
   NULL_USE(data_on_patch_border);
   TBOX_ASSERT_OBJDIM_EQUALITY2(dst_box_level, fill_ghost_width);

   fill_box_level.reset(new hier::BoxLevel(
         dst_box_level.getRefinementRatio(),
         dst_box_level.getGridGeometry(),
         dst_box_level.getMPI()));

   dst_to_fill.reset(new hier::Connector(dst_box_level,
         *fill_box_level,
         fill_ghost_width));

   boost::shared_ptr<const hier::BaseGridGeometry> grid_geometry(
      dst_box_level.getGridGeometry());

   const hier::BoxContainer& dst_boxes = dst_box_level.getBoxes();

   hier::LocalId last_id = dst_box_level.getLastLocalId();
   for (hier::RealBoxConstIterator ni(dst_boxes.realBegin());
        ni != dst_boxes.realEnd(); ++ni) {
      const hier::Box& dst_box = *ni;
      const hier::BoxId& dst_box_id = dst_box.getBoxId();
      hier::BoxContainer fill_boxes(
         hier::Box::grow(dst_box, fill_ghost_width));

      hier::BoxContainer constructed_fill_boxes;

      hier::Connector::NeighborhoodIterator base_box_itr =
         dst_to_fill->findLocal(dst_box_id);
      bool has_base_box = base_box_itr != dst_to_fill->end();

      for (hier::BaseGridGeometry::ConstNeighborIterator ni =
              grid_geometry->begin(dst_box.getBlockId());
           ni != grid_geometry->end(dst_box.getBlockId()); ++ni) {
         const hier::BaseGridGeometry::Neighbor& nbr = *ni;
         if (nbr.isSingularity()) {

            hier::BoxContainer encon_boxes(nbr.getTransformedDomain());
            encon_boxes.refine(dst_box_level.getRefinementRatio());
            encon_boxes.intersectBoxes(fill_boxes);
            encon_boxes.removeIntersections(constructed_fill_boxes);

            if (encon_boxes.size()) {

               if (!has_base_box) {
                  base_box_itr = dst_to_fill->makeEmptyLocalNeighborhood(
                        dst_box_id);
                  has_base_box = true;
               }
               for (hier::BoxContainer::iterator ei = encon_boxes.begin();
                    ei != encon_boxes.end(); ++ei) {

                  hier::Box fill_box(
                     *ei,
                     ++last_id,
                     dst_box.getOwnerRank());

                  TBOX_ASSERT(fill_box.getBlockId() == dst_box.getBlockId());

                  fill_box_level->addBoxWithoutUpdate(fill_box);

                  dst_to_fill->insertLocalNeighbor(
                     fill_box,
                     base_box_itr);

                  constructed_fill_boxes.pushBack(*ei);
               }
            }
         }
      }

      d_max_fill_boxes = tbox::MathUtilities<int>::Max(
            d_max_fill_boxes,
            constructed_fill_boxes.size());
   }
   fill_box_level->finalize();
}
Exemplo n.º 8
0
/*
 *************************************************************************
 *
 * computeFillBoxesAndNeighborhoodSets
 *
 *************************************************************************
 */
void
PatchLevelBorderFillPattern::computeFillBoxesAndNeighborhoodSets(
   boost::shared_ptr<hier::BoxLevel>& fill_box_level,
   boost::shared_ptr<hier::Connector>& dst_to_fill,
   const hier::BoxLevel& dst_box_level,
   const hier::IntVector& fill_ghost_width,
   bool data_on_patch_border)
{
   TBOX_ASSERT_OBJDIM_EQUALITY2(dst_box_level, fill_ghost_width);

   fill_box_level.reset(new hier::BoxLevel(
         dst_box_level.getRefinementRatio(),
         dst_box_level.getGridGeometry(),
         dst_box_level.getMPI()));

   dst_to_fill.reset(new hier::Connector(dst_box_level,
         *fill_box_level,
         fill_ghost_width));

   const hier::BoxContainer& dst_boxes = dst_box_level.getBoxes();

   const int dst_level_num = dst_box_level.getGridGeometry()->
      getEquivalentLevelNumber(dst_box_level.getRefinementRatio());

   hier::IntVector dst_to_dst_width(fill_ghost_width);
   if (data_on_patch_border) {
      dst_to_dst_width += hier::IntVector::getOne(fill_ghost_width.getDim());
   }

   const hier::Connector& dst_to_dst =
      dst_box_level.findConnector(dst_box_level,
         dst_to_dst_width,
         hier::CONNECTOR_IMPLICIT_CREATION_RULE,
         true);

   /*
    * To get the level border, grow each patch box and remove
    * the level from it.
    */
   hier::LocalId last_id = dst_box_level.getLastLocalId();
   for (hier::RealBoxConstIterator ni(dst_boxes.realBegin());
        ni != dst_boxes.realEnd(); ++ni) {
      const hier::Box& dst_box = *ni;
      hier::BoxContainer fill_boxes(
         hier::Box::grow(dst_box, fill_ghost_width));
      hier::Connector::ConstNeighborhoodIterator nabrs =
         dst_to_dst.find(dst_box.getBoxId());
      for (hier::Connector::ConstNeighborIterator na = dst_to_dst.begin(nabrs);
           na != dst_to_dst.end(nabrs); ++na) {
         if (dst_box.getBlockId() == na->getBlockId()) {
            fill_boxes.removeIntersections(*na);
         } else {
            boost::shared_ptr<const hier::BaseGridGeometry> grid_geometry(
               dst_box_level.getGridGeometry());

            const hier::BlockId& dst_block_id = dst_box.getBlockId();
            const hier::BlockId& nbr_block_id = na->getBlockId();

            TBOX_ASSERT(grid_geometry->areNeighbors(dst_block_id,
                  nbr_block_id));

            hier::Transformation::RotationIdentifier rotation =
               grid_geometry->getRotationIdentifier(dst_block_id,
                  nbr_block_id);
            hier::IntVector offset(
               grid_geometry->getOffset(dst_block_id, nbr_block_id, dst_level_num));

            hier::Transformation transformation(rotation, offset,
                                                nbr_block_id, dst_block_id);

            hier::Box nbr_box(*na);
            transformation.transform(nbr_box);

            fill_boxes.removeIntersections(nbr_box);
         }
      }

      if (!fill_boxes.empty()) {
         d_max_fill_boxes = tbox::MathUtilities<int>::Max(d_max_fill_boxes,
               fill_boxes.size());
         hier::Connector::NeighborhoodIterator base_box_itr =
            dst_to_fill->makeEmptyLocalNeighborhood(dst_box.getBoxId());
         for (hier::BoxContainer::iterator li = fill_boxes.begin();
              li != fill_boxes.end(); ++li) {
            hier::Box fill_box(*li,
                               ++last_id,
                               dst_box.getOwnerRank());
            TBOX_ASSERT(fill_box.getBlockId() == dst_box.getBlockId());
            fill_box_level->addBoxWithoutUpdate(fill_box);
            dst_to_fill->insertLocalNeighbor(fill_box, base_box_itr);
         }
      }
   }
   fill_box_level->finalize();
}
Exemplo n.º 9
0
void	do_page(const month_grid& m, bool left_half, bool right_half)
{
	s_ps->black();
	s_ps->font("Arial", 10);
//	s_ps->rectangle(X0, X0 + WIDTH, Y0, Y0 + HEIGHT);
	set_box(X0, RIGHT, Y0, TOP);
	thinline();
	show_box();

	// Line down the middle.
	vrule(X0 + WIDTH / 2);

	float	column_width = WIDTH / 8;

	// Top row: day names.
	float	top_row_height = 20;

	// Title.
	if (right_half)
	{
		// Right column; title & notes.
		float	x = X0 + WIDTH - column_width;
		vrule(x);
		s_ps->printf(x + 10, s_y1 - 20, m.m_month_name);
		s_ps->printf(x + 10, s_y1 - 40, "%d", m.m_year);
	}
	if (left_half)
	{
		// Mini-title, for double-checking book layout.
		s_ps->printf(X0 + WIDTH / 2 - 90, s_y0 + 3, "%s %d", m.m_month_name, m.m_year);
	}

	for (int i = 0; i < 7; i++)
	{
		if (left_half == false && i < 4) continue;
		if (right_half == false && i >= 4) continue;

		static const char*	day_name[7] = { "SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY" };
		float	x = X0 + column_width * i;
		set_box(x, x + column_width, TOP - top_row_height, TOP);
		s_ps->gray(0.75f);
		fill_box();
		s_ps->black();
		show_box();

		s_ps->font("Arial", 8);
		s_ps->printf(x + 5, TOP - top_row_height + 3, day_name[i]);
	}

	float	row_height = (HEIGHT - top_row_height) / ROWS;

	// Days.
	for (int row = 0; row < ROWS; row++)
	{
		for (int col = 0; col < COLS; col++)
		{
			if (left_half == false && col < 4) continue;
			if (right_half == false && col >= 4) continue;

			int	day_number = m.m_day_number[row][col];
			if (day_number == 0)
			{
				// Not a day.
				continue;
			}

			// Show this day.
			float	x = X0 + column_width * col;
			float	y = Y0 + row_height * (ROWS - 1 - row);
			set_box(x, x + column_width, y, y + row_height);
			thickline();
			show_box();

			// Show lines.
			static const int	LINES = 8;
			float	line_height = row_height / LINES;
			for (int line = 0; line < LINES; line++)
			{
				thinline();
				hrule(y + line_height * line);
			}

			// Show the day number.
			s_ps->printf(s_x1 - 11, s_y0 + 3, "%2d", day_number);
		}
	}
}