Beispiel #1
0
HSI::operator _RGB() const
{   double r, g, b;
    if ( H > 0 && H <= 2 * M_PI / 3.0 )
    {   b = athird * ( 1 - S );
        r = athird * ( 1 + ( S * cos(H) ) / cos( M_PI / 3.0 - H ) );
        g = 1 - (r + b);
    }
    else if ( H > 2 * M_PI / 3.0 && H <= 4 * M_PI / 3.0 )
    {   double h = H - 2 * M_PI / 3.0;
        r = athird * ( 1 - S );
        g = athird * ( 1 + ( S * cos(h) ) / cos( M_PI / 3.0 - h ) );
        b = 1 - (r + g);
    }
    else
    {   double h = H - 4 * M_PI / 3.0;
        g = athird * ( 1 - S );
        b = athird * ( 1 + ( S * cos(h) ) / cos( M_PI / 3.0 - h ) );
        r = 1 - (g + b);
    }
    float sf = 3 * I * 255;
    int ri = (int)(sf*r +.5);
    int gi = (int)(sf*g +.5);
    int bi = (int)(sf*b +.5);
    if(   ri < 0   || bi < 0   || gi < 0
            || ri > 255 || bi > 255 || gi > 255 )
    {   std::cout<<"WARNING: HSI::operator RGB(): returned values out of range!!! ["\
                 << ri << " " << gi << " " << bi << "]" << std::endl;
        return ( _RGB(  ( ri < 0 ? 0 : ( ri > 255 ? 255 : ri )),
                        ( gi < 0 ? 0 : ( gi > 255 ? 255 : gi )),
                        ( bi < 0 ? 0 : ( bi > 255 ? 255 : bi )) ) );
    }
    return ( _RGB( ri, gi, bi ));
}
Beispiel #2
0
GetTriforce::GetTriforce(int tid, LinkClass& l):
    link(l),
    triforceID(tid),
    counter(0),
    counter2(0),
    x2(0)
{
    for(int i=0; i<256; i++)
        flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
}
Beispiel #3
0
XYZ::operator _RGB() const
{
    if (    X < 0 || X > 255
            || Y < 0 || Y > 255
            || Z < 0 || Z > 255 )
    {
        std::cerr<<"XYZ::operator RGB(): XYZ value [XYZ " << X << " " << Y << " " << Z << "] is not in range." << std::endl;
        return ( _RGB( (RGBType)255, (RGBType)255, (RGBType)255 ) );
    }
    else
    {
        return ( _RGB( (RGBType)X, (RGBType)Y, (RGBType)Z ) );
    }
}
Beispiel #4
0
_RGB operator*(const _RGB& c, double scale_factor)
{
    int new_R = (int)(scale_factor * c.R);
    int new_G = (int)(scale_factor * c.G);
    int new_B = (int)(scale_factor * c.B);
    if (    new_R < 0 || new_R > 255
            || new_G < 0 || new_G > 255
            || new_B < 0 || new_B > 255 )
    {
        std::cerr<<"RGB::operator*(RGB, double): result out of range." << std::endl;
        return ( _RGB( (RGBType)255, (RGBType)255, (RGBType)255 ) );
    }
    else
    {
        return ( _RGB((RGBType)new_R, (RGBType)new_G, (RGBType)new_B) );
    }
}
Beispiel #5
0
int movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user)
{
    struct fbterm_ctx *ctx = (struct fbterm_ctx *) user;

    /* Remove cursor and redraw cell */
    fbterm_rect_clear(ctx, oldpos.row, oldpos.row+1, oldpos.col, oldpos.col+1);
    VTermScreenCell cell;
    vterm_screen_get_cell(ctx->screen, oldpos, &cell);
    uint32_t fg = _RGB(cell.fg.red, cell.fg.green, cell.fg.blue);
    uint32_t bg = _RGB(cell.bg.red, cell.bg.green, cell.bg.blue);

    fbterm_putc(ctx, oldpos.row, oldpos.col, cell.chars[0], fg, bg);

    /* Set new cursor if visible */
    //if (visible)
        fbterm_set_cursor(ctx, pos.row, pos.col);
}
Beispiel #6
0
void HLStoRGB(float H, float L, float S,
              float* R, float* G, float* B)
{
    float M1, M2;
	if(S <= 0.5) M2 = S * (1 + L);
		else M2 = S * (1 - L) + L;
	M1 = 2 * S - M2;
	if (L == 0.0)
	{
		*R = S;
		*G = S;
		*B = S;
	} else {
		*R = _RGB(H + 120.0, M1, M2);
		*G = _RGB(H        , M1, M2);
		*B = _RGB(H - 120.0, M1, M2);
	}
}
Beispiel #7
0
int damage(VTermRect rect, void *user)
{
    struct fbterm_ctx *ctx = (struct fbterm_ctx *) user;
    fbterm_rect_clear(ctx, rect.start_row, rect.end_row, rect.start_col, rect.end_col);

    VTermScreenCell cell;
    VTermPos pos;

    int row, col;
    for (row = rect.start_row; row < rect.end_row; row++) {
        for (col = rect.start_col; col < rect.end_col; col++) {
            pos.col = col;
            pos.row = row;
            vterm_screen_get_cell(ctx->screen, pos, &cell);
            uint32_t fg = _RGB(cell.fg.red, cell.fg.green, cell.fg.blue);
            uint32_t bg = _RGB(cell.bg.red, cell.bg.green, cell.bg.blue);
            fbterm_putc(ctx, row, col, cell.chars[0], fg, bg);
        }
    }

    return 1;
}
Beispiel #8
0
static void __fastcall yuv2rgb_c_32 (u8 * py_1, u8 * py_2,
			  u8 * pu, u8 * pv,
			  void * _dst_1, void * _dst_2, int width)
{
    int U, V, Y;
    u32 * r, * g, * b;
    u32 * dst_1, * dst_2;

    width >>= 3;
    dst_1 = (u32 *) _dst_1;
    dst_2 = (u32 *) _dst_2;

    do {
		_RGB (u32, 0);
		DST (py_1, dst_1, 0);
		DST (py_2, dst_2, 0);

		_RGB (u32, 1);
		DST (py_2, dst_2, 1);
		DST (py_1, dst_1, 1);

		_RGB (u32, 2);
		DST (py_1, dst_1, 2);
		DST (py_2, dst_2, 2);

		_RGB (u32, 3);
		DST (py_2, dst_2, 3);
		DST (py_1, dst_1, 3);

		pu += 4;
		pv += 4;
		py_1 += 8;
		py_2 += 8;
		dst_1 += 8;
		dst_2 += 8;
    } while (--width);
}
Beispiel #9
0
void C_THISCLASS::smp_render(int this_thread, int max_threads, char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h)
{
  if (!enabled) return;

	unsigned int *f = (unsigned int *) framebuffer;
  unsigned int *of = (unsigned int *) fbout;
  unsigned int *lfo = (unsigned int *) lastframe;


  int start_l = ( this_thread * h ) / max_threads;
  int end_l;

  if (this_thread >= max_threads - 1) end_l = h;
  else end_l = ( (this_thread+1) * h ) / max_threads;  

  int outh=end_l-start_l;
  if (outh<1) return;

  int skip_pix=start_l*w;

  f += skip_pix;
  of+= skip_pix;
  lfo += skip_pix;

  int at_top=0, at_bottom=0;

  if (!this_thread) at_top=1;
  if (this_thread >= max_threads - 1) at_bottom=1;


  timingEnter(0);

  {

    if (at_top)
    // top line
    {
      int x;
    
      // left edge
	    {
        int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
        r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
        f++;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }

      // middle of line
      x=(w-2);
	    while (x--)
	    {
        int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
        r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
        r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
        f++;

        r/=2; g/=2; b/=2;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }

      // right block
	    {
        int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
        r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
        f++;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }
	  }


	  // middle block
    {
      int y=outh-at_top-at_bottom;
      while (y--)
      {
        int x;
      
        // left edge
	      {
          int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
          r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
          r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
          f++;

          r/=2; g/=2; b/=2;

          r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
          lfo++;

          if (r < 0) r=0;
          else if (r > 255) r=255;
          if (g < 0) g=0;
          else if (g > 255*256) g=255*256;
          if (b < 0) b=0;
          else if (b > 255*65536) b=255*65536;
		      *of++=_RGB(r,g,b);          
        }

        // middle of line
        x=(w-2);
#ifdef NO_MMX
	      while (x--)
	      {
          int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
          r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
          r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
          r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
          f++;

          r/=2; g/=2; b/=2;

          r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
          lfo++;

          if (r < 0) r=0;
          else if (r > 255) r=255;
          if (g < 0) g=0;
          else if (g > 255*256) g=255*256;
          if (b < 0) b=0;
          else if (b > 255*65536) b=255*65536;
		      *of++=_RGB(r,g,b);          
        }
#else
        __asm
        {
          mov esi, f
          mov edi, of
          mov edx, lfo
          mov ecx, x
          mov ebx, w
          shl ebx, 2
          shr ecx, 1
          sub esi, ebx
          align 16
mmx_water_loop1:
          movd mm0, [esi+ebx+4]

          movd mm1, [esi+ebx-4]
          punpcklbw mm0, [zero]

          movd mm2, [esi+ebx*2]
          punpcklbw mm1, [zero]

          movd mm3, [esi]
          punpcklbw mm2, [zero]

          movd mm4, [edx]
          paddw mm0, mm1

          punpcklbw mm3, [zero]
          movd mm7, [esi+ebx+8]

          punpcklbw mm4, [zero]
          paddw mm2, mm3

          movd mm6, [esi+ebx]
          paddw mm0, mm2

          psrlw mm0, 1
          punpcklbw mm7, [zero]

          movd mm2, [esi+ebx*2+4]
          psubw mm0, mm4

          movd mm3, [esi+4]
          packuswb mm0, mm0

          movd [edi], mm0
          punpcklbw mm6, [zero]

          movd mm4, [edx+4]
          punpcklbw mm2, [zero]

          paddw mm7, mm6
          punpcklbw mm3, [zero]

          punpcklbw mm4, [zero]
          paddw mm2, mm3
          
          paddw mm7, mm2
          add edx, 8

          psrlw mm7, 1
          add esi, 8

          psubw mm7, mm4

          packuswb mm7, mm7

          movd [edi+4], mm7

          add edi, 8

          dec ecx
          jnz mmx_water_loop1

          add esi, ebx
          mov f, esi
          mov of, edi
          mov lfo, edx
        };
#endif
        // right block
	      {
          int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
          r += _R(f[w]);  g += _G(f[w]);  b += _B(f[w]);
          r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
          f++;

          r/=2; g/=2; b/=2;

          r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
          lfo++;

          if (r < 0) r=0;
          else if (r > 255) r=255;
          if (g < 0) g=0;
          else if (g > 255*256) g=255*256;
          if (b < 0) b=0;
          else if (b > 255*65536) b=255*65536;
		      *of++=_RGB(r,g,b);          
        }
	    }
    }
    // bottom line
    if (at_bottom)
    {
      int x;
    
      // left edge
	    {
        int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
        r += _R(f[-w]);  g += _G(f[-w]);  b += _B(f[-w]);
        f++;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }

      // middle of line
      x=(w-2);
	    while (x--)
	    {
        int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
        r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
        r += _R(f[-w]);  g += _G(f[-w]);  b += _B(f[-w]);
        f++;

        r/=2; g/=2; b/=2;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }

      // right block
	    {
        int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
        r += _R(f[-w]);  g += _G(f[-w]);  b += _B(f[-w]);
        f++;

        r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
        lfo++;

        if (r < 0) r=0;
        else if (r > 255) r=255;
        if (g < 0) g=0;
        else if (g > 255*256) g=255*256;
        if (b < 0) b=0;
        else if (b > 255*65536) b=255*65536;
		    *of++=_RGB(r,g,b);          
      }
	  }
  }

  memcpy(lastframe+skip_pix,framebuffer+skip_pix,w*outh*sizeof(int));
  
#ifndef NO_MMX
    __asm emms;
#endif
	timingLeave(0);
}

C_RBASE *R_Water(char *desc)
{
	if (desc) { strcpy(desc,MOD_NAME); return NULL; }
	return (C_RBASE *) new C_THISCLASS();
}


static C_THISCLASS *g_this;

static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
	switch (uMsg)
	{
		case WM_INITDIALOG:
      if (g_this->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
			return 1;
    case WM_COMMAND:
      if (LOWORD(wParam) == IDC_CHECK1)
      {
        if (IsDlgButtonChecked(hwndDlg,IDC_CHECK1))
          g_this->enabled=1;
        else
          g_this->enabled=0;
      }
    return 0;
	}
	return 0;
}


HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent)
{
	g_this = this;
	return CreateDialog(hInstance,MAKEINTRESOURCE(IDD_CFG_WATER),hwndParent,g_DlgProc);
}
Beispiel #10
0
void GameOver::update()
{
    if(counter<254)
    {
        if(counter<=32)
            link.setHitTimer(32-counter);
        
        if(counter>=62 && counter<138)
        {
            switch((counter-62)%20)
            {
            case 0:
                link.dir=right;
                break;
                
            case 5:
                link.dir=up;
                break;
                
            case 10:
                link.dir=left;
                break;
                
            case 15:
                link.dir=down;
                break;
            }
            
            link.linkstep();
        }
        
        if(counter>=194 && counter<208)
        {
            if(counter==194)
                link.setAction(dying);
                
            link.extend = 0;
            link.cs = wpnsbuf[iwDeath].csets&15;
            link.tile = wpnsbuf[iwDeath].tile;
            
            if(BSZ)
                link.tile+=(counter-194)/3;
            else if(counter>=204)
                link.tile++;
        }
        
        if(counter==208)
            link.setDontDraw(true);
            
        if(get_bit(quest_rules,qr_FADE))
        {
            if(counter < 170)
            {
                if(counter<60)
                {
                    draw_screen(tmpscr);
                    //reuse our static subscreen
                    set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
                    blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
                }
                
                if(counter==60)
                {
                    red_shift();
                    create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
                    create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
                    memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
                    
                    for(int q=0; q<PAL_SIZE; q++)
                    {
                        trans_table2.data[0][q] = q;
                        trans_table2.data[q][q] = q;
                    }
                }
                
                if(counter>=60 && counter<=169)
                {
                    draw_screen(tmpscr);
                    //reuse our static subscreen
                    blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
                    red_shift();
                    
                }
                
                if(counter>=139 && counter<=169)//fade from red to black
                {
                    fade_interpolate(RAMpal,black_palette,RAMpal, (counter-138)<<1, 224, 255);
                    create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
                    create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
                    memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
                    
                    for(int q=0; q<PAL_SIZE; q++)
                    {
                        trans_table2.data[0][q] = q;
                        trans_table2.data[q][q] = q;
                    }
                    
                    refreshpal=true;
                }
            }
            else //counter>=170
            {
                if(counter==170)//make Link grayish
                {
                    fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
                    
                    for(int i=CSET(6); i < CSET(7); i++)
                    {
                        int g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
                        RAMpal[i] = _RGB(g,g,g);
                    }
                    
                    refreshpal = true;
                }
                
                //draw only link. otherwise black layers might cover him.
                rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
                link.draw(framebuf);
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
        }
        else //!qr_FADE
        {
            if(counter==58)
            {
                for(int i = 0; i < 96; i++)
                    tmpscr->cset[i] = 3;
                    
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=0; i<96; i++)
                            tmpscr2[j].cset[i] = 3;
            }
            
            if(counter==59)
            {
                for(int i = 96; i < 176; i++)
                    tmpscr->cset[i] = 3;
                    
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=96; i<176; i++)
                            tmpscr2[j].cset[i] = 3;
            }
            
            if(counter==60)
            {
                for(int i=0; i<176; i++)
                {
                    tmpscr->cset[i] = 2;
                }
                
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=0; i<176; i++)
                            tmpscr2[j].cset[i] = 2;
                            
                for(int i=1; i<16; i+=3)
                {
                    RAMpal[CSET(2)+i]   = NESpal(0x17);
                    RAMpal[CSET(2)+i+1] = NESpal(0x16);
                    RAMpal[CSET(2)+i+2] = NESpal(0x26);
                }
                
                refreshpal=true;
            }
            
            if(counter==139)
                slide_in_color(0x06);
                
            if(counter==149)
                slide_in_color(0x07);
                
            if(counter==159)
                slide_in_color(0x0F);
                
            if(counter==169)
            {
                slide_in_color(0x0F);
                slide_in_color(0x0F);
            }
            
            if(counter==170)
            {
                for(int i=1; i<16; i+=3)
                {
                    RAMpal[CSET(6)+i]   = NESpal(0x10);
                    RAMpal[CSET(6)+i+1] = NESpal(0x30);
                    RAMpal[CSET(6)+i+2] = NESpal(0x00);
                    refreshpal = true;
                }
            }
            
            if(counter < 169)
            {
                draw_screen(tmpscr);
                //reuse our static subscreen
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
            else
            {
                //draw only link. otherwise black layers might cover him.
                rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
                link.draw(framebuf);
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
        }
    }
    else if(counter<350)//draw 'GAME OVER' text
    {
        clear_bitmap(framebuf);
        blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
        textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,1,-1);
    }
    else
    {
        clear_bitmap(framebuf);
    }
    
    //SFX... put them all here
    switch(counter)
    {
    case   0:
        sfx(WAV_OUCH,pan(int(link.x)));
        break;
        
    case  60:
        sfx(WAV_SPIRAL);
        break;
        
    case 194:
        sfx(WAV_MSG);
        break;
    }
    
    //advanceframe(true);
    counter++;
    if(counter<353)
        return;
    
    finish();
    destroy_bitmap(subscrbmp);
    link.setAction(none);
    link.setDontDraw(false);
}