Ejemplo n.º 1
0
void Screen::drawGlyphs(u32 x, u32 y, u8 fc, u8 bc, u16 num, u16 *text, bool *dw)
{
	for (; num--; text++, dw++) {
		drawGlyph(x, y, fc, bc, *text, *dw);
		x += *dw ? FW(2) : FW(1);
	}
}
Ejemplo n.º 2
0
static void draw_lookup_table()
{
	set_im_window(LookupTableWin, lookup_table_win);
	if (!lookup_table_win.w) return;

	draw_margin(lookup_table_win, COLOR_BG);

	unsigned i, x = lookup_table_win.x + MARGIN, y = lookup_table_win.y + MARGIN;
	for (i = 0; ; i++) {
		IBusText *text = ibus_lookup_table_get_candidate(lookup_table, i);
		if (!text) break;

		char buf[8];
		snprintf(buf, sizeof(buf), "%d.", i + 1);
		draw_text(x, y, COLOR_FG, COLOR_BG, buf, strlen(buf));
		x += FW(2);

		draw_text(x, y, i == lookup_table->cursor_pos ? COLOR_ACTIVE_CANDIDATE : COLOR_FG, COLOR_BG, text->text, strlen(text->text));
		x += FW(text_width(text->text));

		char space = ' ';
		draw_text(x, y, COLOR_FG, COLOR_BG, &space, 1);
		x += FW(1);
	}

	unsigned endx = lookup_table_win.x + lookup_table_win.w - MARGIN;
	if (x < endx) {
		Rectangle rect = { x, y, endx - x, FH(1) };
		fill_rect(rect, COLOR_BG);
	}
}
Ejemplo n.º 3
0
Screen *Screen::createInstance()
{

	if (!Font::instance() || !FW(1) || !FH(1)) {
		fprintf(stderr, "init font error!\n");
		return 0;
	}

	Screen *pScreen = 0;

	s8 shm_info[2];
	Config::instance()->getOption("shared-mem", shm_info, sizeof(shm_info));

#ifdef ENABLE_VESA
	s8 buf[16];
	Config::instance()->getOption("vesa-mode", buf, sizeof(buf));
	if (!strcmp(buf, "list")) {
		VesaDev::printModes();
		return 0;
	}

	u32 mode = 0;
	Config::instance()->getOption("vesa-mode", mode);

	if (!mode) {
		if (strlen(shm_info))
			pScreen = FbShm::initFbShm();
		else
			pScreen = FbDev::initFbDev();
	}
	if (!pScreen) pScreen = VesaDev::initVesaDev(mode);
#else
	if (strlen(shm_info))
		pScreen = FbShm::initFbShm();
	else
		pScreen = FbDev::initFbDev();
#endif

	if (!pScreen) return 0;

	if (pScreen->mRotateType == Rotate90 || pScreen->mRotateType == Rotate270) {
		u32 tmp = pScreen->mWidth;
		pScreen->mWidth = pScreen->mHeight;
		pScreen->mHeight = tmp;
	}

	if (!pScreen->mCols) pScreen->mCols = pScreen->mWidth / FW(1);
	if (!pScreen->mRows) pScreen->mRows = pScreen->mHeight / FH(1);

	if (!pScreen->mCols || !pScreen->mRows) {
		fprintf(stderr, "font size is too huge!\n");
		delete pScreen;
		return 0;
	}

	pScreen->initFillDraw();
	return pScreen;
}
Ejemplo n.º 4
0
void FZero_evil_vec_normalize()
{
	u32 r3 = GPR(3);
	float x = F(r3);
	float y = F(r3 + 4);
	float z = F(r3 + 8);
	float sq_len = x*x + y*y + z*z;
	float inv_len = 1.0f / sqrtf(sq_len);
	x *= inv_len;
	y *= inv_len;
	z *= inv_len;
	FW(r3, x);
	FW(r3 + 4, y);
	FW(r3 + 8, z);
	rPS0(1) = inv_len * sq_len;  // len
	rPS1(1) = inv_len * sq_len;  // len
	NPC = LR;

	/*
.evil_vec_something

(f6, f7, f8) <- [r3]
f1 = f6 * f6
f1 += f7 * f7
f1 += f8 * f8
f2 = mystery
f4 = f2 * f1
f3 = f2 + f2
f1 = 1/f0

f6 *= f1
f7 *= f1
f8 *= f1

8006d668: lis	r5, 0xE000
8006d684: lfs	f2, 0x01A0 (r5)
8006d69c: fmr	f0,f2
8006d6a0: fmuls	f4,f2,f1
8006d6a4: fadds	f3,f2,f2
8006d6a8: frsqrte	f1,f0,f1
8006d6ac: fadds	f3,f3,f2
8006d6b0: fmuls	f5,f1,f1
8006d6b4: fnmsubs	f5,f5,f4,f3
8006d6b8: fmuls	f1,f1,f5
8006d6bc: fmuls	f5,f1,f1
8006d6c0: fnmsubs	f5,f5,f4,f3
8006d6c4: fmuls	f1,f1,f5
8006d6c8: fmuls	f6,f6,f1
8006d6cc: stfs	f6, 0 (r3)
8006d6d0: fmuls	f7,f7,f1
8006d6d4: stfs	f7, 0x0004 (r3)
8006d6d8: fmuls	f8,f8,f1
8006d6dc: stfs	f8, 0x0008 (r3)
8006d6e0: fmuls	f1,f1,f0
8006d6e4: blr	
*/
	NPC = LR;
}
Ejemplo n.º 5
0
void Screen::eraseMargin(bool top, u16 h)
{
	if (mWidth % FW(1)) {
		fillRect(FW(mCols), top ? 0 : FH(mRows - h), mWidth % FW(1), FH(h), 0);
	}

	if (mHeight % FH(1)) {
		fillRect(0, FH(mRows), mWidth, mHeight % FH(1), 0);
	}
}
Ejemplo n.º 6
0
int main()
{
	int i,j,ca=0;
	while(1)
	{
		scanf("%d %d %d",&C,&S,&Q);
		if(C<=0||S<=0||Q<=0)
			break;

		for(i=1;i<=C;i++)
			for(j=1;j<=C;j++)
				Path[i][j]=10000;

		for(i=1;i<=S;i++)
		{
			scanf("%d %d %d",&c1,&c2,&d);
			Path[c1][c2]=d;
			Path[c2][c1]=d;
		}

		FW(); /* Floyed Warshall Alg Function*/

		if(ca>0)
			printf("\n");
		printf("Case #%d\n",++ca);
		for(i=1;i<=Q;i++)
		{
			scanf("%d %d",&q1,&q2);
			if(Path[q1][q2]==10000)
				printf("no path\n");
			else
				printf("%d\n",Path[q1][q2]);
		}
	}
}
Ejemplo n.º 7
0
static void calculate_status_win()
{
	if (!property_list) {
		status_bar_win.w = 0;
		return;
	}

	unsigned i, w = 0;
	for (i = 0; ; i++) {
		IBusProperty *prop = ibus_prop_list_get(property_list, i);
		if (!prop) break;

		w += text_width(prop->label->text);
	}

	status_bar_win.x = cursor_x;
	status_bar_win.y = get_cursor_y() + 2 * WIN_INTERVAL + GAP;
	status_bar_win.w = FW(w + property_list->properties->len) + 2 * MARGIN;
	status_bar_win.h = WIN_HEIGHT;

	if (status_bar_win.x + status_bar_win.w > SW) {
		if (status_bar_win.w > SW) status_bar_win.x = 0;
		else status_bar_win.x = SW - status_bar_win.w;
	}
}
Ejemplo n.º 8
0
static void calculate_lookup_win()
{
	if (!lookup_table) {
		lookup_table_win.w = 0;
		return;
	}

	unsigned i, w = 0;
	for (i = 0; ; i++) {
		IBusText *text = ibus_lookup_table_get_candidate(lookup_table, i);
		if (!text) break;

		w += text_width(text->text);
	}

	lookup_table_win.x = cursor_x;
	lookup_table_win.y = get_cursor_y() + WIN_INTERVAL + GAP;
	lookup_table_win.w = FW(w + 3 * lookup_table->page_size) + 2 * MARGIN;
	lookup_table_win.h = WIN_HEIGHT;

	if (lookup_table_win.x + lookup_table_win.w > SW) {
		if (lookup_table_win.w > SW) lookup_table_win.x = 0;
		else lookup_table_win.x = SW - lookup_table_win.w;
	}
}
Ejemplo n.º 9
0
Archivo: main.cpp Proyecto: vhsousa/LPA
int main ()
{
	scanf("%d",&n);
	int i,j;
	int nCon = 0;
	int con =0;
	for(i = 0; i<n; i++)
	{
		scanf("%d",&nCon);
		for(j= 0;j<nCon;j++)
		{
			scanf("%d",&con);
			adj[i][con] = 1;
						
		}
	}

	FW();

	for(i=0;i<n;i++)
	{
		if(adj[i][i]==1)
		{
			printf("%d\n",i);
		}
	}

	return 0;
}
Ejemplo n.º 10
0
// Scales the vector pointed at by r3 to the length specified by f0.
// Writes results to vector pointed at by r4.
void SMB_evil_vec_setlength()
{
	u32 r3 = GPR(3);
	u32 r4 = GPR(4);
	float x = F(r3);
	float y = F(r3 + 4);
	float z = F(r3 + 8);
	float inv_len = (float)(rPS0(0) / sqrt(x*x + y*y + z*z));
	x *= inv_len;
	y *= inv_len;
	z *= inv_len;
	FW(r4, x);
	FW(r4 + 4, y);
	FW(r4 + 8, z);
	NPC = LR;
}
Ejemplo n.º 11
0
void FZ_sqrt() {
	u32 r3 = GPR(3);
	double x = rPS0(0);
	x = sqrt(x);
	FW(r3, (float)x);
	rPS0(0) = x;
	NPC = LR;
}
Ejemplo n.º 12
0
// Normalizes the vector pointed at by r3.
void SMB_EvilNormalize()
{
	u32 r3 = GPR(3);
	float x = F(r3);
	float y = F(r3 + 4);
	float z = F(r3 + 8);
	float len = x*x + y*y + z*z;
	float inv_len;
	if (len <= 0)
		inv_len = 0;
	else 
		inv_len = 1.0f / sqrtf(len);
	x *= inv_len;
	y *= inv_len;
	z *= inv_len;
	FW(r3, x);
	FW(r3 + 4, y);
	FW(r3 + 8, z);
	NPC = LR;
}
Ejemplo n.º 13
0
static void draw_status_bar()
{
	set_im_window(StatusBarWin, status_bar_win);
	if (!status_bar_win.w) return;

	draw_margin(status_bar_win, COLOR_BG);

	unsigned i, x = status_bar_win.x + MARGIN, y = status_bar_win.y + MARGIN;
	for (i = 0; ; i++) {
		IBusProperty *prop = ibus_prop_list_get(property_list, i);
		if (!prop) break;

		draw_text(x, y, COLOR_FG, COLOR_BG, prop->label->text, strlen(prop->label->text));
		x += FW(text_width(prop->label->text));

		char space = ' ';
		draw_text(x, y, COLOR_FG, COLOR_BG, &space, 1);
		x += FW(1);
	}
}
Ejemplo n.º 14
0
void ImProxy::sendInfo()
{
	Message msg;
	msg.type = FbTermInfo;
	msg.len = sizeof(msg);
	msg.info.fontHeight = FH(1);
	msg.info.fontWidth = FW(1);
	msg.info.screenHeight = sh;
	msg.info.screenWidth = sw;

	write((s8 *)&msg, sizeof(msg));
}
Ejemplo n.º 15
0
void ImProxy::changeCursorPos(u16 col, u16 row)
{
	if (!mConnected || !mActive) return;

	Message msg;
	msg.type = CursorPosition;
	msg.len = sizeof(msg);
	msg.cursor.x = FW(col);
	msg.cursor.y = FH(row + 1);

	write((s8 *)&msg, sizeof(msg));
}
Ejemplo n.º 16
0
void ImProxy::setImWin(u32 id, Rectangle &rect)
{
	if (id >= NR_IM_WINS) return;

	if (!rect.w || !rect.h || rect.x >= sw || rect.y >= sh)
		memset(&rect, 0, sizeof(rect));

	if (rect.x + rect.w >= sw) rect.w = sw - rect.x;
	if (rect.y + rect.h >= sh) rect.h = sh - rect.y;

	bool active = (FbShellManager::instance()->activeShell() == mShell);

	if (active && intersectRectangles(mWins[id], rect) != Inside) {
		Rectangle oldrect = mWins[id];

		memset(&mWins[id], 0, sizeof(rect));
		mValidWinNum--;

		u32 endx = oldrect.x + oldrect.w, endy = oldrect.y + oldrect.h;
		u16 col = oldrect.x / FW(1);
		u16 row = oldrect.y / FH(1);
		u16 endcol = endx / FW(1);
		u16 endrow = endy / FH(1);

		mShell->expose(col, row, endcol - col + 1, endrow - row + 1);
	}

	if (!mWins[id].w && rect.w) mValidWinNum++;
	mWins[id] = rect;

	if (active) {
		Screen::instance()->enableScroll(!mValidWinNum);
	}

	for (MsgList::iterator it = mWinMsgs[id].begin(); it != mWinMsgs[id].end(); it++) {
		delete[] (s8 *)(*it);
	}

	mWinMsgs[id].clear();
}
Ejemplo n.º 17
0
void RenamedGraphMerge<T>::writeToDisk(char *& buffer_start, char *& start, char*& prev, char*& output)
{
    this->compact(buffer_start, start);
    WaitForSingleObject(gWriteFileSemaphone, INFINITE);
    {
        FileWriter FW(output);
        FW.write(buffer_start, (start - buffer_start));
        this->total_write += (start - buffer_start);
        start = buffer_start;
        prev = start;
    }
    ReleaseSemaphore(gWriteFileSemaphone, 1, NULL);
}
Ejemplo n.º 18
0
main (int argc, char *argv[]) {
  int s, nodes;
  FILE *fp1;
  vertices *D = malloc(sizeof(vertices));
  int nodecount;
  float cp;

  if (argv[1] != NULL) {
    nodecount = load(D, argv[1]);
    if (nodecount == -1 && argv[2] == NULL)
      printf("\nError loading file\n");
    else {
      FW(D, nodecount, argv[2]);
    }
  }
}
Ejemplo n.º 19
0
static void calculate_auxiliary_win()
{
	if (!auxiliary_text) {
		auxiliary_text_win.w = 0;
		return;
	}

	auxiliary_text_win.x = cursor_x;
	auxiliary_text_win.y = get_cursor_y() + GAP;
	auxiliary_text_win.w = FW(text_width(auxiliary_text->text)) + 2 * MARGIN;
	auxiliary_text_win.h = WIN_HEIGHT;

	if (auxiliary_text_win.x + auxiliary_text_win.w > SW) {
		if (auxiliary_text_win.w > SW) auxiliary_text_win.x = 0;
		else auxiliary_text_win.x = SW - auxiliary_text_win.w;
	}
}
Ejemplo n.º 20
0
void Screen::drawText(u32 x, u32 y, u8 fc, u8 bc, u16 num, u16 *text, bool *dw)
{
	u32 startx, fw = FW(1);

	u16 startnum, *starttext;
	bool *startdw, draw_space = false, draw_text = false;

	for (; num; num--, text++, dw++, x += fw) {
		if (*text == 0x20) {
			if (draw_text) {
				draw_text = false;
				drawGlyphs(startx, y, fc, bc, startnum - num, starttext, startdw);
			}

			if (!draw_space) {
				draw_space = true;
				startx = x;
			}
		} else {
			if (draw_space) {
				draw_space = false;
				fillRect(startx, y, x - startx, FH(1), bc);
			}

			if (!draw_text) {
				draw_text = true;
				starttext = text;
				startdw = dw;
				startnum = num;
				startx = x;
			}

			if (*dw) x += fw;
		}
	}

	if (draw_text) {
		drawGlyphs(startx, y, fc, bc, startnum - num, starttext, startdw);
	} else if (draw_space) {
		fillRect(startx, y, x - startx, FH(1), bc);
	}
}
Ejemplo n.º 21
0
int main(int argc, const char * argv[]) {
    Graph<int, int> g;
    for (int i = 1; i < 10 ; i++) {
        g.addVertex(i);
    }
    addE(6, 8, g, 5);
    addE(2, 3, g, 5);
    addE(5, 9, g, 2);
    addE(1, 4, g, 10);
    addE(4, 7, g, 5);
    addE(2, 1, g, 6);
    addE(2, 5, g, 10);
    addE(5, 4, g, 9);
    addE(6, 9, g, 1);
    addE(8, 7, g, 4);
    FW(g);
    
    
    
    return 0;
}
Ejemplo n.º 22
0
void Screen::drawGlyph(u32 x, u32 y, u8 fc, u8 bc, u16 code, bool dw)
{
	if (x >= mWidth || y >= mHeight) return;

	s32 w = (dw ? FW(2) : FW(1)), h = FH(1);
	if (x + w > mWidth) w = mWidth - x;
	if (y + h > mHeight) h = mHeight - y;

	Font::Glyph *glyph = (Font::Glyph *)Font::instance()->getGlyph(code);
	if (!glyph) {
		fillRect(x, y, w, h, bc);
		return;
	}

	s32 top = glyph->top;
	if (top < 0) top = 0;

	s32 left = glyph->left;
	if ((s32)x + left < 0) left = -x;

	s32 width = glyph->width;
	if (width > w - left) width = w - left;
	if ((s32)x + left + width > (s32)mWidth) width = mWidth - ((s32)x + left);
	if (width < 0) width = 0;

	s32 height = glyph->height;
	if (height > h - top) height = h - top;
	if (y + top + height > mHeight) height = mHeight - (y + top);
	if (height < 0) height = 0;

	if (top) fillRect(x, y, w, top, bc);
	if (left > 0) fillRect(x, y + top, left, height, bc);

	s32 right = width + left;
	if (w > right) fillRect((s32)x + right, y + top, w - right, height, bc);

	s32 bot = top + height;
	if (h > bot) fillRect(x, y + bot, w, h - bot, bc);

	x += left;
	y += top;
	if (x >= mWidth || y >= mHeight || !width || !height) return;

	u32 nwidth = width, nheight = height;
	rotateRect(x, y, nwidth, nheight);

	u8 *pixmap = glyph->pixmap;
	u32 wdiff = glyph->width - width, hdiff = glyph->height - height;

	if (wdiff) {
		if (mRotateType == Rotate180) pixmap += wdiff;
		else if (mRotateType == Rotate270) pixmap += wdiff * glyph->pitch;
	}

	if (hdiff) {
		if (mRotateType == Rotate90) pixmap += hdiff;
		else if (mRotateType == Rotate180) pixmap += hdiff * glyph->pitch;
	}

	adjustOffset(x, y);
	for (; nheight--; y++, pixmap += glyph->pitch) {
		if ((mScrollType == YWrap) && y > mOffsetMax) y -= mOffsetMax + 1;
		(this->*draw)(x, y, nwidth, fc, bc, pixmap);
	}
}