?? neo.h
字號:
color_dpt = 15;
screen_wid = 640;
screen_hig = 480;
break;
case VBE800X600X32K:
color_dpt = 15;
screen_wid = 800;
screen_hig = 600;
break;
case VBE1024X768X32K:
color_dpt = 15;
screen_wid = 1024;
screen_hig = 768;
break;
case VBE1280X1024X32K:
color_dpt = 15;
screen_wid = 1280;
screen_hig = 1024;
break;
case VBE320X200X64K:
color_dpt = 16;
screen_wid = 320;
screen_hig = 200;
break;
case VBE320X240X64K:
color_dpt = 16;
screen_wid = 320;
screen_hig = 240;
break;
case VBE640X480X64K:
color_dpt = 16;
screen_wid = 640;
screen_hig = 480;
break;
case VBE800X600X64K:
color_dpt = 16;
screen_wid = 800;
screen_hig = 600;
break;
case VBE1024X768X64K:
color_dpt = 16;
screen_wid = 1024;
screen_hig = 768;
break;
case VBE1280X1024X64K:
color_dpt = 16;
screen_wid = 1280;
screen_hig = 1024;
break;
case VBE320X200X16M:
color_dpt = 24;
screen_wid = 320;
screen_hig = 200;
break;
case VBE320X240X16M:
color_dpt = 24;
screen_wid = 320;
screen_hig = 240;
break;
case VBE640X480X16M:
color_dpt = 24;
screen_wid = 640;
screen_hig = 480;
break;
case VBE800X600X16M:
color_dpt = 24;
screen_wid = 800;
screen_hig = 600;
break;
case VBE1024X768X16M:
color_dpt = 24;
screen_wid = 1024;
screen_hig = 768;
break;
case VBE1280X1024X16M:
color_dpt = 24;
screen_wid = 1280;
screen_hig = 1024;
break;
default:
return FALSE;
}
set_color_depth(color_dpt);
set_gfx_mode(get_window_mode(), screen_wid, screen_hig, 0, 0);
g_rect_left = g_rect_top = 0;
g_rect_right = g_screen_h - 1;
g_rect_bottom= g_screen_v - 1;
g_surface_ptr[0] = screen;/*create_bitmap(SCREEN_W, SCREEN_H);
clear_bitmap(g_surface_ptr[0]); */
return TRUE;
}
char screen_rect(int left, int top, int right, int bottom){
if(left>g_screen_h||top>g_screen_v||right<0||bottom<0||right<=left||bottom<=top)
{return -1;}
g_rect_left = left;
g_rect_right = right;
g_rect_top = top;
g_rect_bottom= bottom;
set_clip_rect(g_surface_ptr[g_work_surface], left, top, right, bottom);
return 0;
}
void rect_store(void){
g_temp_top = g_rect_top;
g_temp_left= g_rect_left;
g_temp_right = g_rect_right;
g_temp_bottom= g_rect_bottom;
}
void rect_restore(void){
g_rect_top = g_temp_top;
g_rect_left= g_temp_left;
g_rect_right = g_temp_right;
g_rect_bottom= g_temp_bottom;
set_clip_rect(g_surface_ptr[g_work_surface], g_rect_left, g_rect_top, g_rect_right, g_rect_bottom);
}
int surface_alloc(unsigned sur_num, int clear_flag){
unsigned num;
int i;
g_alloc_surface = sur_num >= N_MAX_SURFACE_NUM? N_MAX_SURFACE_NUM : sur_num;
for (i = 1; i <= g_alloc_surface; ++i)
{
g_surface_ptr[i] = create_bitmap(SCREEN_W, SCREEN_H);
if (clear_flag) clear_bitmap(g_surface_ptr[i]);
}
/*if (mouse_driver)
{
scare_mouse();
}
blit(screen, g_surface_ptr[0], 0, 0, 0, 0, SCREEN_W, SCREEN_H);
if (mouse_driver)
{
unscare_mouse();
}*/
return g_alloc_surface;
}
int surface_realloc(unsigned sur_num, int flag){
unsigned num;
int i;
for (i = 1; i <= g_alloc_surface; ++i)
destroy_bitmap(g_surface_ptr[i]);
return surface_alloc(sur_num, flag);
}
BITMAP *work_surface_handle(void){
return g_surface_ptr[g_work_surface];
}
int set_work_surface(unsigned sur_num){
if (g_alloc_surface)
return g_work_surface = (sur_num <= g_alloc_surface && sur_num > 0)? sur_num : 0;
else
return 0;
}
int flip_surface(unsigned sur_num){ /*跳過系統保留頁*/
if (mouse_driver)
{
scare_mouse(); /*隱藏Patch原來的光標*/
}
g_look_surface = (sur_num <= g_alloc_surface?sur_num : 0);
rect_store();
set_clip_rect(screen, 0, 0, SCREEN_W, SCREEN_H);
blit(g_surface_ptr[g_look_surface], screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
rect_restore();
if (mouse_driver)
{
unscare_mouse(); /*繪制redraw新的光標*/
}
return g_look_surface;
}
void flip(void){
static unsigned last = 0; /*跳過系統保留頁*/
g_look_surface = last != 0?1 : 0;
flip_surface(last);
}
void set_neo_color(void){
PALETTE rgb = {
0,0,0,6,6,6,10,10,10,14,14,14,18,18,18,22,22,22,26,26,26,30,30,30,34,34,34,38,38,38,42,42,42,
46,46,46,50,50,50,54,54,54,59,59,59,63,63,63,20,0,0,23,0,0,28,0,0,33,1,1,38,2,2,47,4,3,54,6,
5,63,0,0,63,0,0,63,14,11,63,18,15,63,22,19,63,22,18,63,32,28,63,37,33,63,43,39,18,5,2,21,6,3,
24,6,3,27,6,3,31,10,4,36,15,7,40,20,9,44,25,11,48,30,15,53,36,18,56,41,21,60,46,24,63,50,28,
63,55,33,63,60,39,63,62,44,12,6,0,22,15,0,32,25,0,41,34,1,48,43,1,57,50,1,59,56,1,62,62,1,62,
62,21,63,63,0,63,63,10,63,63,19,63,63,28,63,63,41,63,63,49,63,63,60,5,3,2,7,5,3,10,7,5,13,10,
7,16,13,9,18,16,11,21,19,14,24,22,16,27,25,19,29,28,21,32,31,24,35,34,28,38,37,31,41,40,36,
45,44,40,49,46,43,0,0,15,0,0,19,1,1,27,2,2,32,3,3,37,2,2,41,3,3,46,0,3,51,0,0,58,0,0,63,7,7,
63,14,14,63,21,21,63,28,28,63,38,38,63,42,42,63,7,4,14,9,5,17,11,6,20,13,8,23,15,10,26,18,12,
29,21,14,32,24,17,35,27,20,38,31,23,41,34,27,44,38,31,47,42,35,50,46,40,53,50,44,56,54,49,59,
5,9,10,7,11,13,9,14,16,11,17,19,13,20,22,16,23,25,19,26,28,22,30,32,26,33,35,30,37,39,33,40,
42,38,44,46,42,48,50,47,52,53,52,56,57,57,60,61,0,4,2,0,8,5,0,11,8,1,15,11,2,19,15,4,23,19,6,
26,22,8,30,26,11,34,29,13,38,33,17,42,37,21,46,41,26,50,45,31,54,49,36,58,52,42,62,57,23,10,
6,28,14,8,33,18,10,36,23,13,40,28,16,43,32,19,45,33,21,47,33,24,49,33,27,50,36,30,52,39,33,
54,42,37,55,45,40,57,48,43,58,51,47,60,54,50,12,4,0,16,6,0,21,8,1,24,10,2,27,12,3,30,15,6,33,
18,8,36,21,11,39,25,14,42,29,17,45,33,21,48,37,25,51,41,30,55,46,35,59,50,41,63,56,48,9,3,1,
12,5,2,15,7,3,18,9,4,22,13,7,25,16,9,28,19,12,32,23,15,35,28,18,39,32,22,42,36,27,46,41,31,
49,45,36,53,50,42,57,55,48,61,60,55,0,7,0,0,9,0,1,12,0,2,15,1,4,19,2,6,24,3,8,31,5,11,39,7,
14,45,9,0,49,0,6,49,0,11,49,0,19,49,19,26,49,22,32,49,26,28,49,31,0,6,23,0,8,27,1,10,31,3,12,
35,5,15,40,7,17,44,10,20,48,13,23,50,17,27,52,21,31,55,25,35,56,30,39,58,35,43,59,39,47,60,
44,51,61,50,55,63,9,5,3,12,7,4,15,10,6,18,13,8,22,17,11,25,20,13,28,23,16,31,27,19,34,30,22,
37,34,26,40,37,30,44,41,34,47,45,38,50,49,42,53,52,46,56,55,50, 0,0,0,32,0,0,0,32,0,32,32,
0,0,0,32,32,0,32,0,32,32,32,32,32,48,48,48,63,0,0,0,63,0,63,63,0,0,0,63,63,0,63,0,63,
63,63,63,63
};
set_palette(rgb);
}
void set_color(int index, char red,char green, char blue){
RGB p;
p.r = red;
p.g = green;
p.b = blue;
set_color(index, &p);
}
unsigned char get_red(int index){
PALETTE p;
get_palette_range(p, index, index);
return p[index].r;
}
unsigned char get_green(int index){
PALETTE p;
get_palette_range(p, index, index);
return p[index].g;
}
unsigned char get_blue(int index){
PALETTE p;
get_palette_range(p, index, index);
return p[index].b;
}
void fade_in(PALETTE p, unsigned char dest_color, int speed){
unsigned int i;
RGB black_rbg = {0,0,0};
RGB temp_rbg;
temp_rbg.r = get_red(dest_color);
temp_rbg.g = get_green(dest_color);
temp_rbg.b = get_blue(dest_color);
for (i=0; i<256; i++)
black_palette[i] = temp_rbg;
fade_in(p, speed);
for (i=0; i<256; i++)
black_palette[i] = black_rbg;
}
void fade_out(unsigned char dest_color, int speed){
unsigned int i;
RGB black_rbg = {0,0,0};
RGB temp_rbg;
temp_rbg.r = get_red(dest_color);
temp_rbg.g = get_green(dest_color);
temp_rbg.b = get_blue(dest_color);
for (i=0; i<256; i++)
black_palette[i] = temp_rbg;
fade_out(speed);
for (i=0; i<256; i++)
black_palette[i] = black_rbg;
}
char get_pal_from_bmp(char *filename, PALETTE output){
BITMAP *bmp;
bmp = load_bitmap(filename, output);
if (bmp != NULL && bitmap_color_depth(bmp) == 8)
{
destroy_bitmap(bmp);
return 0;
}
destroy_bitmap(bmp);
return -1;
}
void set_pal_with_bmp(char *filename){
PALETTE pal;
destroy_bitmap(load_bitmap(filename, pal));
set_palette(pal);
}
/*====================================Drawing primitives=================================*/
void dot(int x, int y, int color){
putpixel(g_surface_ptr[g_work_surface], x, y, color);
}
void _dot(int x,int y,int color){
_putpixel(g_surface_ptr[g_work_surface], x, y, color);
}
int get_dot(int x, int y){
return getpixel(g_surface_ptr[g_work_surface], x, y);
}
void line(int x1, int y1, int x2, int y2, unsigned color){
line(g_surface_ptr[g_work_surface], x1, y1, x2, y2, color);
}
char hline(int x, int y, int width, unsigned color){
hline(g_surface_ptr[g_work_surface], x, y, width, color);
}
void vline(int x, int y, int height,unsigned color){
vline(g_surface_ptr[g_work_surface], x, y, height, color);
}
void rect(int x0, int y0, int x1, int y1, int color){
rect(g_surface_ptr[g_work_surface], x0, y0, x1, y1, color);
}
void tri(int xa, int ya, int xb, int yb, int xc, int yc, int color){
line(xa, ya, xb, yb,color);
line(xb, yb, xc, yc,color);
line(xc, yc, xa, ya,color);
}
void rectfill(int x1, int y1, int x2, int y2, int color){
rectfill(g_surface_ptr[g_work_surface], x1, y1, x2, y2, color);
}
void ellipsefill(int center_x, int center_y, int stalk_long,int stalk_short, int fill_color){
ellipsefill(g_surface_ptr[g_work_surface], center_x, center_y, stalk_long, stalk_short, fill_color);
}
void circlefill(int c_x, int c_y, int r, unsigned color){
circlefill(g_surface_ptr[g_work_surface], c_x, c_y, r, color);
}
void circle(int c_x, int c_y, int r, unsigned color){
circle(g_surface_ptr[g_work_surface], c_x, c_y, r, color);
}
void ellipse(int x0,int y0,int a,int b,unsigned color){
ellipse(g_surface_ptr[g_work_surface], x0, y0, a, b, color);
}
void clear_to_color(int color){
clear_to_color(g_surface_ptr[g_work_surface], color);
}
void clear(void){
clear_to_color(0);
}
/*==================================Blitting and sprites=================================*/
#define CUR_SIDE 1024
enum MASK_COLOR{
TPT8 = 0X0,
TPT15 = 0X7C1F,
TPT16 = 0XF81F,
/*TPT24 = 0XFF00FFL,
TPT32 = 0XFF00FFL,*/
};
typedef struct PIC_RGB{
unsigned char blue;
unsigned char green;
unsigned char red;
unsigned char reserved;
}PIC_RGB, *PIC_RGB_ptr;
typedef struct Cursor_type{
PIC_RGB palette[16];
unsigned color64k[16];
unsigned char fir_cur_col;
unsigned char map[512];
unsigned char mask[128];
unsigned char buffer[CUR_SIDE];
}Cursor, *Cursor_ptr;
int fir_icon_color_pos(int fircol_index){
static unsigned char colorindex = /*239*/240;
/*if (!g_color_depth)
{
#ifndef NEO_sys_report_error_unused
Errinfo_t error = {"fir_icon_color_pos", ERR_VIDEO_MODE, 0};
throw_error(error);
#endif
}*/
if ((fircol_index>=0) && (fircol_index<=240))
{
colorindex = fircol_index;
return colorindex;
}
else if (fircol_index < 0)
{
return colorindex;
}
else
{
return -1;
}
}
Cursor_ptr load_icon(char *filename){
int k = 0;
int x = 0;
int y = 0;
int i, j, offset;
Cursor_ptr cursor_p = NULL;
FILE *fp;
if ((cursor_p = (Cursor_ptr)malloc( sizeof (Cursor) ))==NULL)
{
/*#ifndef NEO_sys_report_error_unused
Errinfo_t error = {"load_icon", NO_MEMORY, 0};
throw_error(error);
#endif*/exit(0);
}
if ((fp = fopen(filename, "rb")) == NULL)
{
/*#ifndef NEO_sys_report_error_unused
Errinfo_t error = {"load_icon", NO_FILE, 1};
throw_error(error);
#endif*/
return NULL;
}
cursor_p->fir_cur_col = fir_icon_color_pos(-1);
fseek(fp, 62, SEEK_SET);
fread(&cursor_p->palette, sizeof(struct PIC_RGB), 16, fp);
fread(&cursor_p->map, 512, 1, fp);
fread(&cursor_p->mask, 128, 1, fp);
fclose(fp);
memset(cursor_p->color64k, 0, 32);
for(offset=0; offset<16; ++offset)
{
set_color(cursor_p->fir_cur_col + offset, (cursor_p->palette[offset]).red>>g_dac_size_fix,
(cursor_p->palette[offset]).green>>g_dac_size_fix,
(cursor_p->palette[offset]).blue>>g_dac_size_fix );
cursor_p->color64k[offset] += ((cursor_p->palette[offset]).red>>3);
cursor_p->color64k[offset] <<= g_green_mask;
cursor_p->color64k[offset] += ((cursor_p->palette[offset]).green>>g_green_bit);
cursor_p->color64k[offset] <<= 5;
cursor_p->color64k[offset] += (cursor_p->palette[offset]).blue>>3;
}
if (g_color_depth == 8)
{
for(i=31; i>=0; --i)
{
for(j=0; j<32; j+=2)
{
cursor_p->buffer[( i<<5 )+j] = (cursor_p->map[k]>>4) + cursor_p->fir_cur_col;
cursor_p->buffer[( i<<5 )+j+1] = (cursor_p->map[k++]&0x0f) + cursor_p->fir_cur_col;
}
}
}
else if (g_color_depth == 15 || g_color_depth == 16)
{
for(i=31; i>=0; --i)
{
for(j=0; j<32; j+=2)
{
cursor_p->buffer[( i<<5 )+j] = (cursor_p->map[k]>>4);
cursor_p->buffer[( i<<5 )+j+1] = (cursor_p->map[k++]&0x0f);
}
}
}
for(i=124; i>=0; i-=4)
{
for(j=i; j<=i+3; ++j)
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -