📄 .#palette.c.1.24
字号:
UINT32 *ta; UINT8 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<6)); ct = coltab[bank]; do{ yy = (*ta++) >> 8; yr = (yy&0x0000F8)>>3; yg = (yy&0x00F800)>>11; yb = (yy&0xF80000)>>19; yy = (yr<<10) | (yg<<5) | (yb<<0); GET_PEN_FOR_COLOUR_8( yr << 1, yg << 1, yb << 1, res ); *ct++ = res; }while(--cols);}void map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_15(UINT32 bank, UINT32 cols){ UINT8 yr,yg,yb; UINT32 yy; UINT32 *ta; UINT16 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<6)); ct = (UINT16 *) coltab[bank]; do{ yy = (*ta++) >> 8; yr = (yy&0x0000F8)>>3; yg = (yy&0x00F800)>>11; yb = (yy&0xF80000)>>19; yy = (yr<<10) | (yg<<5) | (yb<<0); GET_PEN_FOR_COLOUR_15( yr << 1, yg << 1, yb << 1, res ); *ct++ = res; }while(--cols);}void map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_16(UINT32 bank, UINT32 cols){ UINT8 yr,yg,yb; UINT32 yy; UINT32 *ta; UINT16 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<6)); ct = (UINT16 *) coltab[bank]; do{ yy = (*ta++) >> 8; yr = (yy&0x0000F8)>>3; yg = (yy&0x00F800)>>11; yb = (yy&0xF80000)>>19; yy = (yr<<10) | (yg<<5) | (yb<<0); GET_PEN_FOR_COLOUR_16( yr << 1, yg << 1, yb << 1, res ); *ct++ = res; }while(--cols);}void map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_24(UINT32 bank, UINT32 cols){ UINT8 yr,yg,yb; UINT32 yy; UINT32 *ta; UINT32 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<6)); ct = (UINT32 *) coltab[bank]; do{ yy = (*ta++) >> 8; yr = (yy&0x0000F8)>>3; yg = (yy&0x00F800)>>11; yb = (yy&0xF80000)>>19; yy = (yr<<10) | (yg<<5) | (yb<<0); GET_PEN_FOR_COLOUR_24( yr << 1, yg << 1, yb << 1, res ); *ct++ = res; }while(--cols);}void map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_32(UINT32 bank, UINT32 cols){ UINT8 yr,yg,yb; UINT32 yy; UINT32 *ta; UINT32 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<6)); ct = (UINT32 *) coltab[bank]; do{ yy = (*ta++) >> 8; yr = (yy&0x0000F8)>>3; yg = (yy&0x00F800)>>11; yb = (yy&0xF80000)>>19; yy = (yr<<10) | (yg<<5) | (yb<<0); GET_PEN_FOR_COLOUR_32( yr << 1, yg << 1, yb << 1, res ); *ct++ = res; }while(--cols);}struct COLOUR_MAPPER col_map_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb ={ "24bit xxxx xxxx rrrr rrrr gggg gggg bbbb bbbb [M68020]", map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_8, map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_15, map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_16, map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_24, map_24bit_xxxx_xxxx_rrrr_rrrr_gggg_gggg_bbbb_bbbb_32,};/******************************************************************************//* 24-bit xRGB (12-bit mapping) byteswapped starscream format *//******************************************************************************/void Map_24bit_xRGB_bswap(int bank, int cols){ UINT8 yr,yg,yb; UINT16 yy; UINT8 *ta; UINT8 *ct,res; bank_status[bank] = cols; ta = (RAM_PAL+(bank<<6)); ct = coltab[bank]; do{ yr = (*(ta+0)) >>4; yg = (*(ta+3)) >>4; yb = (*(ta+2)) >>4; ta += 4; yy=((yr<<8)|(yg<<4)|(yb)); GET_PEN_FOR_COLOUR_8( yr<<2, yg<<2, yb<<2, res ); *ct++ = res; }while(--cols);}/******************************************************************************//* 21-bit xRGB (12-bit mapping) 680x0 format (Cleopatra's Fortune) *//******************************************************************************/// Map_21bit_xRGB#define BUILD_MAPPER2(NAME, TYPE, PEN_FUNC) \void NAME(UINT32 bank, UINT32 cols) \{ \ UINT8 yr,yg,yb; \ UINT16 yy; \ UINT8 *ta; \ TYPE *ct,res; \ \ bank_status[bank] = cols; \ ta = (RAM_PAL+(bank<<6)); \ ct = (TYPE *)coltab[bank]; \ do{ \ yr = ((*(ta+1)) >>3)&0x0F; \ yg = ((*(ta+2)) >>3)&0x0F; \ yb = ((*(ta+3)) >>3)&0x0F; \ ta += 4; \ yy=((yr<<8)|(yg<<4)|(yb)); \ \ PEN_FUNC( \ yr<<2, \ yg<<2, \ yb<<2, \ res \ ); \ \ *ct++ = res; \ \ }while(--cols); \}BUILD_MAPPER2(Map_21bit_xRGB_8,UINT8,GET_PEN_FOR_COLOUR_8)BUILD_MAPPER2(Map_21bit_xRGB_15,UINT16,GET_PEN_FOR_COLOUR_15)BUILD_MAPPER2(Map_21bit_xRGB_16,UINT16,GET_PEN_FOR_COLOUR_16)BUILD_MAPPER2(Map_21bit_xRGB_24,UINT32,GET_PEN_FOR_COLOUR_24)BUILD_MAPPER2(Map_21bit_xRGB_32,UINT32,GET_PEN_FOR_COLOUR_32)struct COLOUR_MAPPER col_map_21bit_xRGB ={ "21bit_xRGB", Map_21bit_xRGB_8, Map_21bit_xRGB_15, Map_21bit_xRGB_16, Map_21bit_xRGB_24, Map_21bit_xRGB_32,};/******************************************************************************//* 12-bit xxxxRGBx (12-bit mapping) 680x0 format (Arabian Magic) *//******************************************************************************///Map_12bit_RGBxxxxx#define BUILD_MAPPER(NAME, TYPE, PEN_FUNC) \void NAME(UINT32 bank, UINT32 cols) \{ \ UINT16 yy; \ UINT8 *ta; \ TYPE *ct,res; \ \ bank_status[bank] = cols; \ ta = (RAM_PAL+(bank<<6)+2); \ ct = (TYPE *)coltab[bank]; \ do{ \ yy = ReadWord68k(ta)>>4; \ ta += 4; \ \ PEN_FUNC( \ (yy&0x0F00)>>6, \ (yy&0x00F0)>>2, \ (yy&0x000F)<<2, \ res \ ); \ \ *ct++ = res; \ \ }while(--cols); \}BUILD_MAPPER(Map_12bit_RGBxxxxx_8,UINT8,GET_PEN_FOR_COLOUR_8)BUILD_MAPPER(Map_12bit_RGBxxxxx_15,UINT16,GET_PEN_FOR_COLOUR_15)BUILD_MAPPER(Map_12bit_RGBxxxxx_16,UINT16,GET_PEN_FOR_COLOUR_16)BUILD_MAPPER(Map_12bit_RGBxxxxx_24,UINT32,GET_PEN_FOR_COLOUR_24)BUILD_MAPPER(Map_12bit_RGBxxxxx_32,UINT32,GET_PEN_FOR_COLOUR_32)struct COLOUR_MAPPER col_map_12bit_rgbxxxx ={ "12bit rgbxxx", Map_12bit_RGBxxxxx_8, Map_12bit_RGBxxxxx_15, Map_12bit_RGBxxxxx_16, Map_12bit_RGBxxxxx_24, Map_12bit_RGBxxxxx_32,};/******************************************************************************//* 15bit rrrr rggg ggbb bbbx xxxx xxxx xxxx xxxx *//******************************************************************************/void map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_8(UINT32 bank, UINT32 cols){ UINT16 yy; UINT32 *ta; UINT8 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<10)); ct = coltab[bank]; do{ yy = (*ta++) >> 1; GET_PEN_FOR_COLOUR_8( (yy&0x001F)<<1, (yy&0x03E0)>>4, (yy&0x7C00)>>9, res ); *ct++ = res; }while(--cols);}void map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_15(UINT32 bank, UINT32 cols){ UINT16 yy; UINT32 *ta; UINT16 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<10)); ct = (UINT16 *) coltab[bank]; do{ yy = (*ta++) >> 1; GET_PEN_FOR_COLOUR_15( (yy&0x001F)<<1, (yy&0x03E0)>>4, (yy&0x7C00)>>9, res ); *ct++ = res; }while(--cols);}void map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_16(UINT32 bank, UINT32 cols){ UINT16 yy; UINT32 *ta; UINT16 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<10)); ct = (UINT16 *) coltab[bank]; do{ yy = (*ta++) >> 1; GET_PEN_FOR_COLOUR_16( (yy&0x001F)<<1, (yy&0x03E0)>>4, (yy&0x7C00)>>9, res ); *ct++ = res; }while(--cols);}void map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_24(UINT32 bank, UINT32 cols){ UINT16 yy; UINT32 *ta; UINT32 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<10)); ct = (UINT32 *) coltab[bank]; do{ yy = (*ta++) >> 1; GET_PEN_FOR_COLOUR_24( (yy&0x001F)<<1, (yy&0x03E0)>>4, (yy&0x7C00)>>9, res ); *ct++ = res; }while(--cols);}void map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_32(UINT32 bank, UINT32 cols){ UINT16 yy; UINT32 *ta; UINT32 *ct,res; bank_status[bank] = cols; ta = (UINT32 *) (RAM_PAL+(bank<<10)); ct = (UINT32 *) coltab[bank]; do{ yy = (*ta++) >> 1; GET_PEN_FOR_COLOUR_32( (yy&0x001F)<<1, (yy&0x03E0)>>4, (yy&0x7C00)>>9, res ); *ct++ = res; }while(--cols);}struct COLOUR_MAPPER col_map_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx ={ "15bit bbbb bggg ggrr rrrx xxxx xxxx xxxx xxxx", map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_8, map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_15, map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_16, map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_24, map_15bit_bbbb_bggg_ggrr_rrrx_xxxx_xxxx_xxxx_xxxx_32,};/******************************************************************************//* 15bit xggg ggrr rrrb bbbb *//******************************************************************************/void map_15bit_xggg_ggrr_rrrb_bbbb_8(UINT32 bank, UINT32 cols){ UINT16 yy; UINT16 *ta; UINT8 *ct,res; bank_status[bank] = cols; ta = (UINT16 *) colour_ram_src[bank]; ct = coltab[bank]; do{ yy = (*ta++) & 0x7FFF; GET_PEN_FOR_COLOUR_8( (yy&0x03E0)>>4, (yy&0x7C00)>>9, (yy&0x001F)<<1, res ); *ct++ = res; }while(--cols);}void map_15bit_xggg_ggrr_rrrb_bbbb_15(UINT32 bank, UINT32 cols){ UINT16 yy; UINT16 *ta; UINT16 *ct,res; bank_status[bank] = cols; ta = (UINT16 *) colour_ram_src[bank]; ct = (UINT16 *) coltab[bank]; do{ yy = (*ta++) & 0x7FFF; GET_PEN_FOR_COLOUR_15( (yy&0x03E0)>>4, (yy&0x7C00)>>9, (yy&0x001F)<<1, res ); *ct++ = res; }while(--cols);}void map_15bit_xggg_ggrr_rrrb_bbbb_16(UINT32 bank, UINT32 cols){ UINT16 yy; UINT16 *ta; UINT16 *ct,res; bank_status[bank] = cols; ta = (UINT16 *) colour_ram_src[bank]; ct = (UINT16 *) coltab[bank]; do{ yy = (*ta++) & 0x7FFF; GET_PEN_FOR_COLOUR_16( (yy&0x03E0)>>4, (yy&0x7C00)>>9, (yy&0x001F)<<1, res ); *ct++ = res; }while(--cols);}void map_15bit_xggg_ggrr_rrrb_bbbb_24(UINT32 bank, UINT32 cols){ UINT16 yy; UINT16 *ta; UINT32 *ct,res; bank_status[bank] = cols; ta = (UINT16 *) colour_ram_src[bank]; ct = (UINT32 *) coltab[bank]; do{ yy = (*ta++) & 0x7FFF; GET_PEN_FOR_COLOUR_24( (yy&0x03E0)>>4, (yy&0x7C00)>>9, (yy&0x001F)<<1, res ); *ct++ = res; }while(--cols);}void map_15bit_xggg_ggrr_rrrb_bbbb_32(UINT32 bank, UINT32 cols){ UINT16 yy; UINT16 *ta; UINT32 *ct,res; bank_status[bank] = cols; ta = (UINT16 *) colour_ram_src[bank]; ct = (UINT32 *) coltab[bank]; do{ yy = (*ta++) & 0x7FFF; GET_PEN_FOR_COLOUR_32( (yy&0x03E0)>>4, (yy&0x7C00)>>9, (yy&0x001F)<<1, res ); *ct++ = res; }while(--cols);}struct COLOUR_MAPPER col_map_xggg_ggrr_rrrb_bbbb ={ "15bit xggg ggrr rrrb bbbb", map_15bit_xggg_ggrr_rrrb_bbbb_8, map_15bit_xggg_ggrr_rrrb_bbbb_15, map_15bit_xggg_ggrr_rrrb_bbbb_16, map_15bit_xggg_ggrr_rrrb_bbbb_24, map_15bit_xggg_ggrr_rrrb_bbbb_32,};/******************************************************************************//* *//* CLOSEST MATCHING COLOUR ROUTINE *//* *//******************************************************************************/static UINT32 col_diff[128*3]; static void closest_colour_init(void){ int i; for(i=1; i<64; i++){ int k = i * i; col_diff[0 +i] = col_diff[0 +128-i] = k * (59 * 59); col_diff[128+i] = col_diff[128+128-i] = k * (30 * 30); col_diff[256+i] = col_diff[256+128-i] = k * (11 * 11); }}/*Find the best fitting colour in the range res_pens - 254*/static UINT8 closest_colour(int r, int g, int b){ int i, coldiff, lowest, bestfit; RGB *rgb; bestfit = 0; lowest = INT_MAX; i = res_pens; rgb = &pal[i]; do{ coldiff = (col_diff + 0) [ (rgb->g - g) & 0x7F ]; if (coldiff < lowest) { coldiff += (col_diff + 128) [ (rgb->r - r) & 0x7F ]; if (coldiff < lowest) { coldiff += (col_diff + 256) [ (rgb->b - b) & 0x7F ]; if (coldiff < lowest) { bestfit = i; if (coldiff == 0) return bestfit; lowest = coldiff; } } } i++; rgb++; }while(i<255); return bestfit;}// Set changed colours. Since this is a slow thing on the pc,// I must try to reduce it to be called when only needed.extern int fbcon_enabled;void update_screen_palette(PALETTE palette){#ifdef RDTSC_PROFILE if(raine_cfg.show_fps_mode>2){ ProfileStop(PRO_BLIT); ProfileStart(PRO_PAL); }#endif // In non 8 bpp modes it is pointless to update the palette as it is not required // or usable. if( internal_bpp(display_cfg.bpp) == 8 ){#ifdef RAINE_UNIX if(display_cfg.fast_set_pal && !x_display && !fbcon_enabled) fast_palette_update(palette,pal_screen,display_cfg.vsync); else // User has a lame gfx card/vesa driver set_palette_range(palette,0,255,display_cfg.vsync);#else#ifdef RAINE_DOS if(display_cfg.fast_set_pal) fast_palette_update(palette,pal_screen,display_cfg.vsync); else // User has a lame gfx card/vesa driver set_palette_range(palette,0,255,display_cfg.vsync);#else set_palette_range(palette,0,255,display_cfg.vsync);#endif // RAINE_DOS#endif // RAINE_UNIX }#ifdef RDTSC_PROFILE if(raine_cfg.show_fps_mode>2){ ProfileStop(PRO_PAL); ProfileStart(PRO_BLIT); }#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -