中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
作者:
标题: 建议:中文化SealDOS 上一主题 | 下一主题
AlexZhang
系统支持





积分 952
发帖 410
注册 2007-2-8
状态 离线
『楼 主』:  建议:中文化SealDOS

如题
我今天无聊研究了下SealDOS (别提Batch IDE了...我写了...只是没发布而已...这点小改进不至于更新个版本号:lol) 发现它用的ttf字体
try下 直接放进去东文宋体(宋体SimSun有版权保护 不用他 英文字体变了 中文还是乱码...)
于是乎,,,下载源码看了看...重点在以下
SCREEN.C
/******************************************************************
* SEAL 2.0                                                       *
* Copyright (c) 1999-2002 SEAL Developers. All Rights Reserved.  *
*                                                                *
* Web site: http://sealsystem.sourceforge.net/                   *
* E-mail (current maintainer): orudge@users.sourceforge.net      *
******************************************************************/

/*
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <seal.h>
#include <screen.h>

BITMAP  *screen_virtual = NULL;
BITMAP  *screen_double_buffer = NULL;

l_int    screen_width     = 0;
l_int    screen_height    = 0;
/*static*/ l_int    screen_viswidth  = 0;
/*static*/ l_int    screen_visheight = 0;
/*static*/ l_int    screen_card      = 0;
/*static*/ l_int    screen_depth     = 0;

/* jdh moved - needs to know about screen_depth -
NOTE you need to use load_bitmap directly if you ever intend saving the image (in some other format?)
because this (now, rightly or wrongly) converts it to whatever depth we have on screen
which can be destructive, particularly in 8bits, but still not good in 15 or 16 bits.
This added to ensure gifs particularly are converted to screen depth.
*/
/*static*/ 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(_fixup_loaded_bitmap((BITMAP *)bmp,Gr_pal,screen_depth));
        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" ); /* error message, if some occures */
  DEBUG_printf(" - depth: %i bits per pixel (%d colors)\n - width: %i\n - height: %i\n", depth, 1<<depth, w, h); /* error message, if some occures */
  if ( w == 0 || h == 0 || depth == 0) safe_mode=true; /* elementary precaution jdh */

  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) ) { /* not exist this resolution */
     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"); /* error message, if some occures */
     DEBUG_printf(" - depth: 8 bits per pixel (%d colors)\n - width: 640\n - height: 480\n", 1<<8); /* error message, if some occures */
     w = v_w = 640;
     h = v_h = 480;
     depth = 16;
     if ( !GrSetMode(card, w, h, v_w, v_h, depth) ) { /* not found this driver */
         DEBUG_printf("\nERROR: Your card does not support the default resolution of 640x480 in %d colours\n", 1<<8); /* error message, if some occures */
         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");
/* stops protests when run without a proper screen using the debug allegro library */
  set_color_conversion(COLORCONV_TOTAL);
  screen_virtual = create_bitmap(screen_width, screen_height);
  DEBUG_printf("   ...initializing virtual screen\n"); /* error message, if some occures */
  if ( !screen_virtual ) {
      DEBUG_printf("     - ERROR :: virtual screen is not installed\n"); /* error message, if some occures */
      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"); /* error message, if some occures */
  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
系统支持





积分 952
发帖 410
注册 2007-2-8
状态 离线
『第 2 楼』:  fonts.c


/******************************************************************
* SEAL 2.0                                                       *
* Copyright (c) 1999-2002 SEAL Developers. All Rights Reserved.  *
*                                                                *
* Web site: http://sealsystem.sourceforge.net/                   *
* E-mail (current maintainer): orudge@users.sourceforge.net      *
******************************************************************/

/*
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <seal.h>
#include <fonts.h>
#include <vfile.h>
#include <unistd.h>

////////////////////////////////////////////////////////////////////////////////
t_fonts_loaded *system_fonts = NULL;
void   *font_system = NULL;
l_text  system_font_name = "ARIAL";

/*l_text  file_getbin ( l_text filename ) {
  FILE *f = SealFileOpen(filename, "rb");
  if ( f ) {
      l_long size = filelength(fileno(f));
      l_text text = _malloc(size+1);
      if ( text ) {
         clear_type(text, size+1);
         fread(text, size, 1, f);
      };
      fclose(f);
      return text;
  };
  return NULL;
};*/

////////////////////////////////////////////////////////////////////////////////
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[a] ) {  // Will repeat the loading font for all sizes
        void *fnt = seal_load_font(file,NULL,font_sizes[a],font_sizes[a],-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[a] ); // 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 )
{
  /* did nothing - what a pity */
  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[a] ) { /
    if ( w == font_sizes[a] )
      stw = font_sizes[a];
    else if ( w > font_sizes[a-1] && w < font_sizes[a] )
      stw = font_sizes[a];
    a++;
  };
  if ( w > font_sizes[a-1] ) stw = font_sizes[a-1];*/
  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
系统支持





积分 952
发帖 410
注册 2007-2-8
状态 离线
『第 3 楼』:  sealdos.c 我不会c 所以只能这样了...


/******************************************************************
* SEAL 2.0                                                       *
* Copyright (c) 1999-2002 SEAL Developers. All Rights Reserved.  *
*                                                                *
* Web site: http://sealsystem.sourceforge.net/                   *
* E-mail (current maintainer): orudge@users.sourceforge.net      *
******************************************************************/

/*
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/* Revision History:

   DATE              CHANGE                                         VERSION
   23/09/2001        Created application                            0.1
   23/09/2001        Fixed many bugs                                0.1
   29/03/2002        Updated slightly for SEAL 2.00.11 release      0.2

   All dates are in DD/MM/YYYY format.
*/

// screen_reload
#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)
{
                                                /* function for free-ing items */
   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[MAXPATH];
   char oldpath[MAXPATH];
   char *pathloc;
   char *newfile;
   p_object o;

   if (!file)
      file = open_dialog("/", "*.exe;*.com;*.bat", get_filelist());

   if (file)
   {
      newfile = GetFile(file); // get the DOS name for it

      pathloc = strrchr(newfile, '/');
      memset(pathstr, 0, sizeof(pathstr));
      memcpy(pathstr, newfile, pathloc-newfile);  // Get the path so a chdir() can be done

      getcwd(oldpath, MAXPATH);
      put_backslash(pathstr);
      chdir(pathstr);

//      mouse_done(OBJECT(mouse));
      remove_mouse();    // remove mouse driver

// <UPDATE by Julien> //
      // ... set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); -> BAD IDEA !, there is function for it
      screen_halt();  // Set text mode and save screen ....
// </ UPDATE by Julien> //

#ifdef DEBUG_INFO
      printf("File name: %s\n", newfile);
      printf("Path:      %s\n", pathstr);
      printf("Old Path:  %s\n", oldpath);
      printf("\n");
#endif
      // Drivers have to be removed and reinstalled in case of conflicts with DOS apps

      remove_keyboard(); // remove keyboard driver
      remove_sound();    // remove sound driver

      allegro_exit();
      system(newfile);
      allegro_init();

      install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, ""); // reinstall sound driver
      install_keyboard();                                  // reinstall keyboard driver

      put_backslash(oldpath);
      chdir(oldpath);
      printf("\nPress any key to return to SEAL...");

      do {
      } while (!keypressed());

      readkey();

      screen_reload();

      install_mouse();                                     // reinstall mouse driver
//      mouse_init(mouse);


// <UPDATE by Julien> //
      // ... desktop->draw_view(desktop); -> why ? screen_reload done it ....
// </ UPDATE by Julien> //

      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
系统支持





积分 952
发帖 410
注册 2007-2-8
状态 离线
『第 4 楼』:  seal.h


/******************************************************************
* SEAL 2.0                                                       *
* Copyright (c) 1999-2002 SEAL Developers. All Rights Reserved.  *
*                                                                *
* Web site: http://sealsystem.sourceforge.net/                   *
* E-mail (current maintainer): orudge@users.sourceforge.net      *
******************************************************************/

/*
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "object.h"
#include "alltogrx.h"

#ifndef __SCREEN_H_INCLUDED__
#define __SCREEN_H_INCLUDED__

#ifdef __cplusplus
extern "C" {
#endif

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;

#ifdef __cplusplus
}
#endif

#endif


2007-12-16 14:43
查看资料  访问主页  发短消息 网志   编辑帖子  回复  引用回复
AlexZhang
系统支持





积分 952
发帖 410
注册 2007-2-8
状态 离线
『第 5 楼』:  fonts.h 我看不懂啊...懂c得来看看


...我这次做不了这个项目了...
/******************************************************************
* SEAL 2.0                                                       *
* Copyright (c) 1999-2002 SEAL Developers. All Rights Reserved.  *
*                                                                *
* Web site: http://sealsystem.sourceforge.net/                   *
* E-mail (current maintainer): orudge@users.sourceforge.net      *
******************************************************************/

/*
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "object.h"
#include "alltogrx.h"

#ifndef __SCREEN_H_INCLUDED__
#define __SCREEN_H_INCLUDED__

#ifdef __cplusplus
extern "C" {
#endif

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;

#ifdef __cplusplus
}
#endif

#endif


2007-12-16 14:46
查看资料  访问主页  发短消息 网志   编辑帖子  回复  引用回复
070
高级用户

苏醒的沉睡者


积分 659
发帖 217
注册 2003-2-15
来自 福建
状态 离线
『第 6 楼』:  

有时间看看



好久没碰Dos,手都生了,赶紧回来练练.嘿嘿
2007-12-25 09:12
查看资料  发送邮件  发短消息 网志  OICQ (181315400)  编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: