|
AlexZhang
系统支持
            
积分 995
发帖 427
注册 2007-2-8
状态 离线
|
『楼 主』:
建议:中文化SealDOS
使用 LLM 解释/回答一下
如题
我今天无聊研究了下SealDOS (别提Batch IDE了...我写了...只是没发布而已...这点小改进不至于更新个版本号:lol) 发现它用的ttf字体
try下 直接放进去东文宋体(宋体SimSun有版权保护 不用他 英文字体变了 中文还是乱码...)
于是乎,,,下载源码看了看...重点在以下
SCREEN.C
BITMAP *screen_virtual = NULL;
BITMAP *screen_double_buffer = NULL;
l_int screen_width = 0;
l_int screen_height = 0;
l_int screen_viswidth = 0;
l_int screen_visheight = 0;
l_int screen_card = 0;
l_int screen_depth = 0;
PALETTE Gr_pal;
l_int save_image( char *filename, BITMAP *bmp, AL_CONST RGB *pal) {
return save_bitmap(GetFile(filename),bmp,pal);
};
GrIMAGE *gr_load_bitmap ( char *filename ) {
if( filename ) {
l_text file = GetFile(filename);
if ( file ) {
GrIMAGE * bmp=load_bitmap(file, Gr_pal);
if( bmp ) {
return bmp;
};
_free(file);
};
};
return NULL;
};
l_bool screen_reload ( void )
{
GrSetMode(screen_card, screen_viswidth, screen_visheight, screen_width, screen_height, screen_depth);
GrClearClip(screen);
if ( screen_virtual ) {
draw_sprite(screen, screen_virtual, 0, 0);
set_clip(screen, -1, -1, -1, -1);
set_clip(screen_virtual, -1, -1, -1, -1);
if ( screen_double_buffer ) set_clip(screen_double_buffer, -1, -1, -1, -1);
};
return true;
};
void screen_halt ( void )
{
if ( screen_virtual ) {
set_clip(screen, 0, 0, screen_width, screen_height);
set_clip(screen_virtual, 0, 0, screen_width, screen_height);
if ( screen_double_buffer ) set_clip(screen_double_buffer, 0, 0, screen_width, screen_height);
show_mouse(NULL);
blit(screen, screen_virtual, 0, 0, 0, 0, screen_width, screen_height);
show_mouse(screen);
};
GrSetTextMode();
};
l_bool screen_init ( void )
{
long card = 0;
long w = get_key_integer("system/graphics/width");
long h = get_key_integer("system/graphics/height");
long dbf = get_key_integer("system/graphics/double_buffer");
long v_w = 0;
long v_h = 0;
long depth = get_key_integer("system/graphics/depth");
DEBUG_printf("\n...initializing screen from registry with those parameters :\n" );
DEBUG_printf(" - depth: %i bits per pixel (%d colors)\n - width: %i\n - height: %i\n", depth, 1<<depth, w, h);
if ( w == 0 || h == 0 || depth == 0) safe_mode=true;
if ( safe_mode ) {
DEBUG_printf("\nSEAL running in safe mode\n\n");
w = 640;
h = 480;
v_w = 0;
v_h = 0;
depth = 16;
};
if ( !GrSetMode(card, w, h, v_w, v_h, depth) ) {
printf("\nERROR: Selected resolution (%dx%d @ %d bpp) is not supported!\n",w,h,depth);
DEBUG_printf("\nERROR : not supported ... try to initializing in new resolution");
DEBUG_printf(" - depth: 8 bits per pixel (%d colors)\n - width: 640\n - height: 480\n", 1<<8);
w = v_w = 640;
h = v_h = 480;
depth = 16;
if ( !GrSetMode(card, w, h, v_w, v_h, depth) ) {
DEBUG_printf("\nERROR: Your card does not support the default resolution of 640x480 in %d colours\n", 1<<8);
seal_error(ERR_NONREGULAR, "\nERROR: Your card does not support the default resolution of 640x480 in %d colours\n", 1<<8);
};
};
GrClearClip(screen);
DEBUG_printf("\nScreen is ok");
screen_viswidth = SCREEN_W;
screen_visheight = SCREEN_H;
screen_depth = get_depth(screen);
screen_card = card;
screen_width = max(SCREEN_W, min(VIRTUAL_W, v_w));
screen_height = max(SCREEN_H, min(VIRTUAL_H, v_h));
DEBUG_printf("\n..initializing the virtual screen");
set_color_conversion(COLORCONV_TOTAL);
screen_virtual = create_bitmap(screen_width, screen_height);
DEBUG_printf(" ...initializing virtual screen\n");
if ( !screen_virtual ) {
DEBUG_printf(" - ERROR :: virtual screen is not installed\n");
return false;
};
if ( dbf ) {
DEBUG_printf(" ...initializing double buffer screen\n");
screen_double_buffer = create_bitmap(screen_width, screen_height);
if ( !screen_double_buffer ) DEBUG_printf(" - ERROR :: double buffer screen is not installed (not fatal error)\n");
};
DEBUG_printf(" screen and virtual screen were succesfully installed\n");
return true;
};
void screen_done ( void )
{
if ( screen_virtual )
destroy_bitmap(screen_virtual);
screen_virtual = NULL;
if ( screen_double_buffer )
destroy_bitmap(screen_double_buffer);
screen_double_buffer = NULL;
screen_width = 0;
screen_height = 0;
GrSetTextMode();
};
|
|
2007-12-16 14:39 |
|
|
AlexZhang
系统支持
            
积分 995
发帖 427
注册 2007-2-8
状态 离线
|
『第 2 楼』:
fonts.c
使用 LLM 解释/回答一下
////////////////////////////////////////////////////////////////////////////////
t_fonts_loaded *system_fonts = NULL;
void *font_system = NULL;
l_text system_font_name = "ARIAL";
////////////////////////////////////////////////////////////////////////////////
int add_font_to_system ( void *font, char *name, int weight )
{
t_fonts_loaded *s = system_fonts;
t_fonts_loaded *n;
t_fonts_loaded *last = NULL;
int fh = 0;
if ( !font || !name ) return 0;
while ( s ) {
last = s;
if ( (fh == s->weight) && !stricmp(s->name, name) ) return 2;
s = s->next;
};
n = (t_fonts_loaded *)_malloc(sizeof(t_fonts_loaded));
if ( !n ) return 0;
memset(n, 0, sizeof(t_fonts_loaded));
if ( last ) last->next = n;
else system_fonts = n;
n->font = font;
n->weight = weight;
n->name = _strdup(name);
return 1;
};
////////////////////////////////////////////////////////////////////////////////
// Standart sizes of font
l_int font_sizes = { 8, /*9,*/ 10, /*11, 12, */ 14, 16, /* 18,*/ 20, /*22, 24, 26, 28, 36, 48, 72,*/ 0};
////////////////////////////////////////////////////////////////////////////////
// Load fonts from path
void load_supported_fonts ( l_text path ) {
struct t_ffblk f; // Delcare the struct to list directory
l_int done = 0;
l_text fi = io_realpath(path, "*.*"); // Prepare wilcard
DEBUG_printf (" - Load TTF and FNT fonts from path '%s'\n", path );
done = io_findfirst(fi, &f, FA_ARCH); // Start path listing
while ( !done ) {
l_text file = io_realpath(path, f.ff_filename); // Generate the full filename
l_text ext = get_extension(file);
l_text name = mid(f.ff_filename,0,strlen(f.ff_filename)-((ext)?strlen(ext)+1:0)); // Keep only filename without the expension
DEBUG_printf (" - Load ''%s'', named ''%s''\n",file,name);
if ( ext && !stricmp(ext,"TTF") ) { // Check if it's a ttf file
l_int a = 0;
while ( font_sizes ) { // Will repeat the loading font for all sizes
void *fnt = seal_load_font(file,NULL,font_sizes,font_sizes,-1,-1); // Load font with size N癮 in table font_sizes
if ( fnt ) // If load font succeed
add_font_to_system ( fnt, name, font_sizes ); // Add font in size in the system list (systems_fonts)
else // If load don't succeed
DEBUG_printf(" - Error :: Unable to load font\n");
a++;
};
} else if ( ext && !stricmp(ext,"FNT") ) {
FONT *f = load_font(GetFile(file));
if ( f )
add_font_to_system ( f, name, text_height(f) );
else
DEBUG_printf(" - Error :: Unable to load font\n");
} else { // If it's not a ttf file
DEBUG_printf(" - Error :: Non-TTF/FNT, not supported\n");
};
if ( name ) _free(name);
if ( file ) _free(file);
done = io_findnext(&f); // Find next file in path
};
font_system = get_font_in_size ( system_font_name, 8, 8 );
_free(fi); // Free the wilcard ("path/*.*")
};
////////////////////////////////////////////////////////////////////////////////
// Unload loaded system fonts
void unload_system_fonts ( void )
{
t_fonts_loaded *s = system_fonts;
t_fonts_loaded *last = NULL;
while ( s ) {
last = s;
_free(s->name);
s = s->next;
_free(last);
};
};
////////////////////////////////////////////////////////////////////////////////
void fonts_done ( void ) {
unload_system_fonts( );
};
////////////////////////////////////////////////////////////////////////////////
// Return the font fontname in the standart size thz most close of w
void *get_font_in_size ( char *fontname, int w, int h )
{
t_fonts_loaded *s = system_fonts;
l_int a = 1;
l_int stw = w;/*8; // Standart size
while ( font_sizes ) { /
if ( w == font_sizes )
stw = font_sizes;
else if ( w > font_sizes && w < font_sizes )
stw = font_sizes;
a++;
};
if ( w > font_sizes ) stw = font_sizes;*/
while ( s ) {
if ( s->weight == stw && fontname && s->name && !stricmp(fontname, s->name) ) {
return s->font;
};
s = s->next;
};
return get_font_in_size(system_font_name,10,10);
};
|
|
2007-12-16 14:40 |
|
|
AlexZhang
系统支持
            
积分 995
发帖 427
注册 2007-2-8
状态 离线
|
『第 3 楼』:
sealdos.c 我不会c 所以只能这样了...
使用 LLM 解释/回答一下
#include <allegro.h>
#include <seal.h>
#include <screen.h>
#include <app.h>
#include <dialogs.h>
#include <iodlg.h>
#include <mouse.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dir.h>
l_text file;
p_list get_filelist (void)
{
p_list p = list_init(malloc(sizeof(t_list)), &free_filehistory_item, 0);
if (p)
{
p->insert(p, new_filehistory_item("Executables (*.exe)", "*.exe"));
p->insert(p, new_filehistory_item("Commands (*.com)", "*.com"));
p->insert(p, new_filehistory_item("Batch Files (*.bat)", "*.bat"));
p->insert(p, new_filehistory_item("All Files (*.*)", "*.*"));
}
return p;
}
void app_init()
{
char pathstr;
char oldpath;
char *pathloc;
char *newfile;
p_object o;
if (!file)
file = open_dialog("/", "*.exe;*.com;*.bat", get_filelist());
if (file)
{
newfile = GetFile(file);
pathloc = strrchr(newfile, '/');
memset(pathstr, 0, sizeof(pathstr));
memcpy(pathstr, newfile, pathloc-newfile);
getcwd(oldpath, MAXPATH);
put_backslash(pathstr);
chdir(pathstr);
remove_mouse();
screen_halt();
#ifdef DEBUG_INFO
printf("File name: %s\n", newfile);
printf("Path: %s\n", pathstr);
printf("Old Path: %s\n", oldpath);
printf("\n");
#endif
remove_keyboard();
remove_sound();
allegro_exit();
system(newfile);
allegro_init();
install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, "");
install_keyboard();
put_backslash(oldpath);
chdir(oldpath);
printf("\nPress any key to return to SEAL...");
do {
} while (!keypressed());
readkey();
screen_reload();
install_mouse();
set_mouse_speed(mouse->speed.x, mouse->speed.y);
mouse_set_sys_cursor(CUR_ARROW);
mouse_show(mouse);
DLXUnload(ap_id);
}
}
SetInfoAppName("SealDOS");
SetInfoDesciption("SEAL 2 DOS compatibility program");
SetInfoCopyright("Copyright (c) Owen Rudge 2001-2002. All Rights Reserved.");
SetInfoManufacturer("Owen Rudge");
app_begin(void)
{
if (ap_process == AP_INIT)
{
if (ap_args)
file = ap_args;
app_init();
}
} app_end;
|
|
2007-12-16 14:42 |
|
|
AlexZhang
系统支持
            
积分 995
发帖 427
注册 2007-2-8
状态 离线
|
『第 4 楼』:
seal.h
使用 LLM 解释/回答一下
extern "C" {
extern BITMAP *screen_virtual;
extern BITMAP *screen_double_buffer;
extern l_int screen_width;
extern l_int screen_height;
extern l_int screen_viswidth;
extern l_int screen_visheight;
extern l_int screen_card;
extern l_int screen_depth;
extern l_bool screen_init ( void );
extern void screen_done ( void );
extern l_bool screen_reload ( void );
extern void screen_halt ( void );
extern PALETTE Gr_pal;
}
|
|
2007-12-16 14:43 |
|
|
AlexZhang
系统支持
            
积分 995
发帖 427
注册 2007-2-8
状态 离线
|
『第 5 楼』:
fonts.h 我看不懂啊...懂c得来看看
使用 LLM 解释/回答一下
...我这次做不了这个项目了...
extern "C" {
extern BITMAP *screen_virtual;
extern BITMAP *screen_double_buffer;
extern l_int screen_width;
extern l_int screen_height;
extern l_int screen_viswidth;
extern l_int screen_visheight;
extern l_int screen_card;
extern l_int screen_depth;
extern l_bool screen_init ( void );
extern void screen_done ( void );
extern l_bool screen_reload ( void );
extern void screen_halt ( void );
extern PALETTE Gr_pal;
}
|
|
2007-12-16 14:46 |
|
|
070
高级用户
    苏醒的沉睡者
积分 659
发帖 217
注册 2003-2-15 来自 福建
状态 离线
|
|
2007-12-25 09:12 |
|
|