void DumpObject::DrawCursor(BOOL Flag) { AG_Rect rec; AG_Color col; AG_Color fg,bg; AG_Surface *s; rec.h = CHRH; rec.w = CHRW; rec.x = CHRW * CURX; rec.y = CHRH * CURY; col = fgColor; col.a = 64; if(Flag) { AG_MutexLock(&mutex); fg = fgColor; bg = bgColor; fgColor = bg; bgColor = fg; PutCharScreen(ConsoleBuf[CURY * W + CURX]); AG_FillRect(Screen, &rec, col); fgColor = fg; bgColor = bg; AG_MutexUnlock(&mutex); } }
/* * セレクト */ BOOL SelectDraw(void) { BOOL ret; AG_Color nullcolor; AG_Rect rect; AG_Widget *w; BYTE bold = bMode; int y; if (SelectCheck()) { return TRUE; } rect.h = nDrawWidth; rect.w = nDrawHeight; rect.x = 0; rect.y = 0; DrawSHUTDOWN = FALSE; /* * すべてクリア */ if(!bUseOpenGL) { if(DrawArea != NULL) { AG_ObjectLock(DrawArea); nullcolor.r = 0; nullcolor.g = 0; nullcolor.b = 0; nullcolor.a = 255; AG_FillRect(AGWIDGET(DrawArea)->drv->sRef , &rect, nullcolor); AG_ObjectUnlock(DrawArea); } } else { // OpenGLのとき } /* * すべてクリア */ bOldFullScan = bFullScan; /* * セレクト */ #if XM7_VER >= 3 switch (screen_mode) { case SCR_400LINE: ret = Select400l(); case SCR_262144: ret = Select256k(); case SCR_4096: ret = Select320(); default: ret = Select640(); } #else /* */ if (mode320) { ret = Select320(); } else { ret = Select640(); } } else {
BOOL DumpObject::InitConsole(int w, int h) { int size; AG_PixelFormat fmt; int xx; int yy; if((w <= 0) || (h <= 0)) return FALSE; AG_MutexLock(&mutex); W = w; H = h; X = 0; Y = 0; size = w * h; if(ConsoleBuf != NULL) delete [] ConsoleBuf; if(BackupConsoleBuf != NULL) delete [] ConsoleBuf; if(Screen != NULL) { Screen = NULL; AG_SurfaceFree(Screen); } ConsoleBuf = new BYTE[size]; BackupConsoleBuf = new BYTE[size]; for(yy = 0; yy < H; yy++) { for(xx = 0; xx < W; xx++) { ConsoleBuf[xx + yy * W] = 0x00000000; BackupConsoleBuf[xx + yy * W] = 0x00000000; } } SetPixelFormat(&fmt); Screen = AG_SurfaceNew(AG_SURFACE_PACKED, W * CHRW, H * CHRH, &fmt, 0); { AG_Color col; AG_Rect rec; col.r = 0; col.g = 0; col.b = 0; col.a = 255; rec.x = 0; rec.y = 0; rec.w = Screen->w; rec.h = Screen->h; AG_FillRect(Screen, &rec, col); } AG_MutexUnlock(&mutex); }
void DumpObject::PutCharScreen(BYTE c) { Uint32 ucs[2]; AG_Surface *r = NULL; if(Sym2UCS4(c, ucs) && (c != 0x20)) { if(pDbgDialogSymFont != NULL) { AG_PushTextState(); AG_TextFont(pDbgDialogSymFont); AG_TextColor(fgColor); AG_TextBGColor(bgColor); AG_TextValign(AG_TEXT_MIDDLE); r = AG_TextRenderUCS4((const Uint32 *)ucs); AG_PopTextState(); } } else if(Txt2UCS4(c, ucs) && (c != 0x20)) { if(pDbgDialogTextFont != NULL) { AG_PushTextState(); AG_TextFont(pDbgDialogTextFont); AG_TextColor(fgColor); AG_TextBGColor(bgColor); AG_TextValign(AG_TEXT_MIDDLE); r = AG_TextRenderUCS4((const Uint32 *)ucs); AG_PopTextState(); } } { // Clear Cursor position 20130122 (-_-; AG_Rect rect; rect.x = X * CHRW; rect.y = Y * CHRH; rect.w = CHRW; rect.h = CHRH; AG_FillRect(Screen, &rect, bgColor); } if(r != NULL) { if(Screen != NULL) { AG_SurfaceBlit(r, NULL, Screen, X * CHRW, Y * CHRH); } AG_SurfaceFree(r); } }
void DumpObject::ClearScreen(void) { int xx; int yy; int pos; AG_Rect rect; AG_MutexLock(&mutex); pos = 0; for(yy = 0; yy < H; yy++) { for(xx = 0; xx < W; xx++) { ConsoleBuf[pos + xx] = BackupConsoleBuf[pos + xx] = 0x00; } pos += W; } if(Screen != NULL) { rect.w = Screen->w; rect.h = Screen->h; rect.x = 0; rect.y = 0; AG_FillRect(Screen, &rect, bgColor); } AG_MutexUnlock(&mutex); }
static void RenderPalette(AG_HSVPal *pal) { AG_Surface *ds = pal->surface; float h, cur_h, cur_s, cur_v; AG_Color C; Uint32 px; /* Uint8 da; */ int x, y, i; AG_Rect rd; AG_FillRect(ds, NULL, AG_ColorRGB(0,0,0)); cur_h = (AG_GetFloat(pal, "hue")/360) * 2*AG_PI; cur_s = AG_GetFloat(pal, "saturation"); cur_v = AG_GetFloat(pal, "value"); /* Render the circle of hues. */ for (h = 0.0; h < 2*AG_PI; h += pal->circle.dh) { AG_HSV2RGB((h/(2*AG_PI)*360.0), 1.0, 1.0, &C.r, &C.g, &C.b); px = AG_MapColorRGB(ds->format, C); for (i = 0; i < pal->circle.width; i++) { x = (pal->circle.rout - i)*Cos(h); y = (pal->circle.rout - i)*Sin(h); AG_PUT_PIXEL2(ds, pal->circle.x+x, pal->circle.y+y, px); } } /* Render the triangle of saturation and value. */ for (y = 0; y < pal->triangle.h; y += 2) { float sat = (float)(pal->triangle.h - y) / (float)(pal->triangle.h); for (x = 0; x < y; x++) { AG_HSV2RGB((cur_h/(2*AG_PI))*360.0, sat, 1.0 - ((float)x/(float)pal->triangle.h), &C.r, &C.g, &C.b); px = AG_MapColorRGB(ds->format, C); AG_PUT_PIXEL2(ds, pal->triangle.x + x - y/2, pal->triangle.y + y, px); AG_PUT_PIXEL2(ds, pal->triangle.x + x - y/2, pal->triangle.y + y + 1, px); } } if (!(pal->flags & AG_HSVPAL_NOALPHA)) { /* Render the color preview. */ /* XXX overblending */ for (y = 8; y < pal->rAlpha.h+16; y+=8) { for (x = 0; x < pal->rAlpha.w; x+=16) { rd.w = 8; rd.h = 8; rd.x = pal->rAlpha.x+x; rd.y = pal->rAlpha.y+y; AG_FillRect(ds, &rd, pal->cTile); } y += 8; for (x = 8; x < pal->rAlpha.w; x+=16) { rd.w = 8; rd.h = 8; rd.x = pal->rAlpha.x+x; rd.y = pal->rAlpha.y+y; AG_FillRect(ds, &rd, pal->cTile); } } AG_HSV2RGB((cur_h/(2*AG_PI))*360.0, cur_s, cur_v, &C.r, &C.g, &C.b); /* da = MIN(1, ds->w/255); */ for (y = pal->rAlpha.y+8; y < ds->h; y++) { for (x = 0, C.a = 0; x < ds->w; x++) { AG_BLEND_RGBA2(ds, x, y, C.r, C.g, C.b, C.a, AG_ALPHA_SRC); C.a = x*255/ds->w; } } } }
void RG_FillApply(void *p, RG_Tile *t, int x, int y) { struct rg_fill_feature *fi = p; AG_Surface *su = t->su; AG_Color C; Uint8 a; switch (fi->type) { case FILL_SOLID: AG_FillRect(su, NULL, fi->f_solid.c); break; case FILL_HGRADIENT: { int x, y; AG_Color c1 = fi->f_gradient.c1; AG_Color c2 = fi->f_gradient.c2; C.a = fi->alpha; for (y = 0; y < su->h; y++) { a = (Uint8)(su->h-y)*255/su->h; C.r = (((c1.r - c2.r)*a)>>8) + c2.r; C.g = (((c1.g - c2.g)*a)>>8) + c2.g; C.b = (((c1.b - c2.b)*a)>>8) + c2.b; if (fi->alpha == 255) { for (x = 0; x < su->w; x++) { RG_PutPixel(t->su, x, y, AG_MapColorRGB(t->su->format, C)); } } else { for (x = 0; x < su->w; x++) { RG_BlendRGB(t->su, x, y, RG_PRIM_OVERLAY_ALPHA, C); } } } } break; case FILL_VGRADIENT: { int x, y; AG_Color c1 = fi->f_gradient.c1; AG_Color c2 = fi->f_gradient.c2; C.a = fi->alpha; for (y = 0; y < su->h; y++) { for (x = 0; x < su->w; x++) { a = (su->h - x)*255/su->h; C.r = (((c1.r - c2.r)*a)>>8) + c2.r; C.g = (((c1.g - c2.g)*a)>>8) + c2.g; C.b = (((c1.b - c2.b)*a)>>8) + c2.b; RG_BlendRGB(t->su, x, y, RG_PRIM_OVERLAY_ALPHA, C); } } } break; case FILL_CGRADIENT: { int i, r = MAX(su->w,su->h); int x = su->w/2; int y = su->h/2; AG_Color c1 = fi->f_gradient.c1; AG_Color c2 = fi->f_gradient.c2; C.a = fi->alpha; for (i = 0; i < r; i++) { a = (r - i)*255/r; C.r = (((c1.r - c2.r)*a)>>8) + c2.r; C.g = (((c1.g - c2.g)*a)>>8) + c2.g; C.b = (((c1.b - c2.b)*a)>>8) + c2.b; RG_ColorRGBA(t, C); RG_Circle2(t, x,y, i); } } break; default: break; } }