?? neo.h
字號:
unsigned char m = 0x80;
for(k = 0; k < 8; ++k)
{
if(cursor_p->mask[j] & m)
{
cursor_p->buffer[( y<<5 )+x] = (TPT8 + 16);
}
++x;
m >>= 1;
}
}
++y;
x = 0;
}
fir_icon_color_pos(cursor_p->fir_cur_col);
return cursor_p;
}
void blit_icon(Cursor_ptr cursor_p, int x, int y){
int i, j;
unsigned int color;
if (g_color_depth == 8)
{
for(i=0; i<32; ++i)
{
for(j=0; j<32; j+=2)
{
if ((color=cursor_p->buffer[(i<<5)+j]) != (TPT8 + 16)) dot(x + j, y + i, color);
if ((color=cursor_p->buffer[(i<<5)+j+1])!=(TPT8 + 16)) dot(x + j + 1,y + i, color);
}
}
}
else if (g_color_depth == 15 || g_color_depth == 16)
{
for(i=0; i<32; ++i)
{
for(j=0; j<32; j+=1)
{
if ((cursor_p->buffer[(i<<5)+j]) != (TPT8 + 16))
{
dot(x + j, y + i, cursor_p->color64k[cursor_p->buffer[(i<<5)+j]]);
}
}
}
}
}
void show_icon(char *curfile, int x, int y){
Cursor_ptr cur_p;
cur_p = load_icon(curfile);
blit_icon(cur_p,x,y);
free(cur_p);
}
char bitmap_color_depth(char *bmp){
PALLETE pal;
char cd;
BITMAP *b = load_bitmap(bmp, pal);
cd = bitmap_color_depth(b);
destroy_bitmap(b);
return cd;
}
char show_bmp(char *bmpfile, int x, int y)
{
PALLETE pal;
BITMAP *bmp = load_bitmap(bmpfile, pal);
if (bmp == NULL) return FALSE;
if (bitmap_color_depth(bmp) == 8) set_palette(pal);
blit(bmp, g_surface_ptr[g_work_surface], 0, 0, x, y, bmp->w, bmp->h);
destroy_bitmap(bmp);
return TRUE;
}
char _show_bmp(char *bmpfile, int x, int y)
{
PALLETE pal;
BITMAP *bmp = load_bitmap(bmpfile, pal);
if (bmp == NULL) return FALSE;
if (bitmap_color_depth(bmp) == 8) set_palette(pal);
masked_blit(bmp, g_surface_ptr[g_work_surface], 0, 0, x, y, bmp->w, bmp->h);
destroy_bitmap(bmp);
return TRUE;
}
char _show_bmp_v_flip(char *bmpfile, int x, int y)
{
PALLETE pal;
BITMAP *bmp = load_bitmap(bmpfile, pal);
if (bmp == NULL) return FALSE;
if (bitmap_color_depth(bmp) == 8) set_palette(pal);
draw_sprite_v_flip(g_surface_ptr[g_work_surface], bmp, x, y);
destroy_bitmap(bmp);
return TRUE;
}
char bmp_blit(char *bmpname, int source_x, int source_y, int dest_x, int dest_y, int width, int height){
PALLETE pal;
BITMAP *bmp = load_bitmap(bmpname, pal);
if (bmp == NULL) return FALSE;
if (bitmap_color_depth(bmp) == 8) set_palette(pal);
blit(bmp, g_surface_ptr[g_work_surface], source_x, source_y, dest_x, dest_x, width, height);
destroy_bitmap(bmp);
return TRUE;
}
char bmp_masked_blit(char *bmpname, int source_x, int source_y, int dest_x, int dest_y, int width, int height){
PALLETE pal;
BITMAP *bmp = load_bitmap(bmpname, pal);
if (bmp == NULL) return FALSE;
if (bitmap_color_depth(bmp) == 8) set_palette(pal);
masked_blit(bmp, g_surface_ptr[g_work_surface], source_x, source_y, dest_x, dest_x, width, height);
destroy_bitmap(bmp);
return TRUE;
}
BITMAP *get_image(unsigned x0, unsigned y0, unsigned x1, unsigned y1){
int w = x1 - x0;
int h = y1 - y0;
BITMAP *image = create_bitmap(w, h);
if (image == NULL || w <= 0 || h <= 0) return NULL;
blit(g_surface_ptr[g_work_surface], image, x0, y0, 0, 0, w, h);
return image;
}
void put_image(BITMAP *image, int x, int y){
blit(image, g_surface_ptr[g_work_surface], 0, 0, x, y, image->w, image->h);
}
BITMAP *_load_bmp(char *filename){
RGB *pal;
BITMAP *bmp = load_bmp(filename, pal);
if (bmp == NULL) return NULL;
return bmp;
}
char blit(BITMAP *bmp){
blit(bmp, g_surface_ptr[g_work_surface], 0, 0, 0, 0, bmp->w, bmp->h);
return TRUE;
}
void free_bmp(BITMAP *bitmap){
destroy_bitmap(bitmap);
}
char rect_save_screen(char *bmpfile, unsigned left, unsigned top, unsigned right, unsigned bottom){
BITMAP *bmp;
PALETTE pal;
get_palette(pal);
bmp = create_sub_bitmap(screen, left, top, right - left, bottom - top);
if (bmp == NULL) return FALSE;
save_bitmap(bmpfile, bmp, pal);
destroy_bitmap(bmp);
return TRUE;
}
char save_screen(char *bmpfile) {
return rect_save_screen(bmpfile, 0, 0, SCREEN_W, SCREEN_H);
}
void show_mouse(void){
show_mouse(screen);
}
void mouse_refresh(void){
//update_mouse();
//draw_mouse(TRUE, FALSE);
}
void set_dbl_click_delay(int userdelay){}
int set_mouse_icon(char *p_iconfile){
BITMAP *sprite;
PALETTE p;
if (p_iconfile)
{
sprite = load_bitmap(p_iconfile, p);
set_mouse_sprite(sprite);
//destroy_bitmap(sprite);
return TRUE;
}
else
set_mouse_sprite(NULL);
return FALSE;
}
int get_click_info(void){
return mouse_b;
}
void en_slant(char slant){
if (slant != 0)
g_slant = slant > 0?1 : -1;
else
g_slant = 0;
}
void asc_out(char c, int cx, int cy, int color){
char str[2];
str[0] = c;
str[1] = '\0';
textout_ex(g_surface_ptr[g_work_surface], font, str, cx, cy, color, g_text_bg);
}
void textout(const char *str, int sx, int sy){
int index;
for (index = 0; str[index] != 0; index++)
{
asc_out(str[index], sx + (index << 3) + g_blank, sy, g_str_color);
}
}
char put_chinese(char *string, int x, int y, int color, int blank){
FILE *hzk_p;
long fpos; /*漢字在字庫文件中的偏移*/
int i, j, k, l;
int asc_size = 0;/*用來或得當前英文字符的高*/
char hz_buf[72]; /*漢字字模緩沖區,目前能支持24X24點陣字符的存放*/
if ((hzk_p=fopen(g_hz_font,"rb+"))==NULL)/* 打開24點陣字庫文件 */
{
#ifndef NEO_sys_report_error_unused
Errinfo_t error = {"put_chinese", NO_FILE, 1};
throw_error(error);
#endif
return -1;
}
asc_size = abs(g_ilimit - text_height(font));
while (*string != '\0')
{
if((*string & 0x80) == 0)/* 判斷是否是擴展ASCII */
{
asc_out(*string, x, y + asc_size, color);
x += 8 + blank;
string++;
}
else
{
char slant = 0;
fpos = (((unsigned char)*string-0xa1 - g_start)*94 + ((unsigned char)*(string+1)-0xa1))*(long)g_hz_size;
fseek(hzk_p, fpos, SEEK_SET);
fread(hz_buf, g_hz_size, 1, hzk_p);
if (g_hz_size <= 32) /*16點陣以下的字庫*/
{
for (i = 0; i < g_ilimit; ++i)
{
slant += g_slant;
for (j = 0; j < g_jlimit; ++j)
{
for (k = 0; k < 8; ++k)
{
if (((hz_buf[(i << 1) + j] >> 7 - k)) & 1)
dot(x + (j << 3) + k + slant, y + i, color);
else if (g_text_bg >= 0)
dot(x + (j << 3) + k + slant, y + i, g_text_bg);
}
}
}
}
else /*24點陣以上的字庫*/
{
for (i = 0; i < g_ilimit; ++i)
{
for (j = 0; j < g_jlimit; ++j)
{
for (k = 1; k <= 8; ++k)
{
if ( (hz_buf[i * 3 + j] << k - 1) & 0x80 )
dot(x + i, y + (j << 3) + k - 1, color);
else if (g_text_bg >= 0)
dot(x + i, y + (j << 3) + k - 1, g_text_bg);
}
}
}
}
x += (g_ilimit + blank);
string += 2;
}
if (text_callback)
text_callback();
}
fclose(hzk_p);
return 0;
}
void set_cn_font(char cn_size, char *cn_font){
g_jlimit = 2;
g_start = 0;
g_ilimit = cn_size;
switch(cn_size)
{
case S12X12:
g_hz_size= 24;
g_hz_font= cn_font;
g_hz_width= 12;
break;
case S16X16:
g_hz_size= 32;
g_hz_font= cn_font;
g_hz_width= 16;
break;
case S24X24:
g_jlimit = 3;
g_hz_size= 72;
g_start = 15;
g_hz_width= 24;
g_hz_font= cn_font;
break;
default:
g_ilimit = S16X16;
g_hz_size= 32;
g_hz_width= 16;
g_hz_font= cn_font;
break;
}
}
void set_cn_size(char cn_size){
switch(cn_size)
{
case S12X12:
set_cn_font(S12X12, "HZK12");
break;
case S16X16:
set_cn_font(S16X16, "HZK16");
break;
case S24X24:
set_cn_font(S24X24, "HZK24S");
break;
default:
set_cn_font(S16X16, "HZK16");
break;
}
}
int neo_printf(int x, int y, char *format, ...){
char buffer[256];
va_list argptr;
int count;
char err_m;
va_start(argptr, format);
count = vsprintf(buffer, format, argptr);
va_end(argptr);
#ifndef NEO_error_unused
err_m = get_err_method();
err_method(0);
#endif
if (put_chinese(buffer, x, y, g_str_color, g_blank))
textout(buffer, x, y);
#ifndef NEO_error_unused
err_method(err_m);
#endif
return (count);
}
BITMAP *get_str_bitmap(char *string, int fc, int bc){
BITMAP *str_bitmap;
FILE *hzk_p;
long fpos; /*漢字在字庫文件中的偏移*/
int i, j, k, l, x = 0, y = 0;
int asc_size = 0;/*用來或得當前英文字符的高*/
int count;
char hz_buf[72]; /*漢字字模緩沖區,目前能支持24X24點陣字符的存放*/
if (count = strlen(string))
{
count % 2 ? count++ : 0;
str_bitmap = create_bitmap((count >> 1) * (g_hz_width) + count, g_hz_width);
if (str_bitmap)
clear(str_bitmap);
else
return NULL;
}
if ((hzk_p = fopen(g_hz_font, "rb+"))==NULL)/* 打開24點陣字庫文件 */
{
#ifndef NEO_sys_report_error_unused
Errinfo_t error = {"put_chinese", NO_FILE, 1};
throw_error(error);
#endif
return NULL;
}
asc_size = abs(g_ilimit - text_height(font));
while (*string != '\0')
{
if((*string & 0x80) == 0)/* 判斷是否是擴展ASCII */
{
char str[2];
str[0] = *string;
str[1] = '\0';
textout_ex(str_bitmap, font, str, x, 0, fc, bc);
x += 8 + 1/*+ blank*/;
string++;
}
else
{
char slant = 0;
fpos = (((unsigned char)*string-0xa1 - g_start)*94 + ((unsigned char)*(string+1)-0xa1))*(long)g_hz_size;
fseek(hzk_p, fpos, SEEK_SET);
fread(hz_buf, g_hz_size, 1, hzk_p);
if (g_hz_size <= 32) /*16點陣以下的字庫*/
{
for (i = 0; i < g_ilimit; ++i)
{
slant += g_slant;
for (j = 0; j < g_jlimit; ++j)
{
for (k = 0; k < 8; ++k)
{
if (((hz_buf[(i << 1) + j] >> 7 - k)) & 1)
putpixel(str_bitmap, x + (j << 3) + k + slant, y + i, fc);
else/* if (g_text_bg >= 0)*/
putpixel(str_bitmap, x + (j << 3) + k + slant, y + i, bc);
}
}
}
}
else /*24點陣以上的字庫*/
{
for (i = 0; i < g_ilimit; ++i)
{
for (j = 0; j < g_jlimit; ++j)
{
for (k = 1; k <= 8; ++k)
{
if ( (hz_buf[i * 3 + j] << k - 1) & 0x80 )
putpixel(str_bitmap, x + i, y + (j << 3) + k - 1, fc);
else/* if (g_text_bg >= 0)*/
putpixel(str_bitmap, x + i, y + (j << 3) + k - 1, bc);
}
}
}
}
x += (g_ilimit + 1/*+ blank*/);
string += 2;
}
}
return str_bitmap;
}
int string_out(char *str, int x, int y)
{
return put_chinese(str, x, y, g_str_color, g_blank);
}
int random (int high){ /* get a random number between low and high, inclusively */
if (high < 0) return (0); /* don't divide by zero */
return (rand() % (high + 1));
}
void neo_message(char *message, ...)
{
allegro_message(message);
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -