Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 2227 → Rev 2232

/programs/other/font_conv/convert.com
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/programs/other/font_conv/convert.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/programs/other/font_conv/convert.c
1,30 → 1,47
/*
Copyright 2011 dunkaist <dunkaist@gmail.com>
Distributed under the terms of the GNU General Public License v3.
See http://www.gnu.org/licenses/gpl.txt for the full license text.
*/
 
 
#include <stdio.h>
 
int main()
{
const int font_height = 9;
int font_width[2] = {5,7},
char_num,i,e;
#define FONT_HEIGHT 9
#define FONT_WIDTH_MONO 5
#define FONT_WIDTH_VAR 7 /* max symbol width */
 
short int char_num, row, col;
char ch,data;
 
freopen("char.txt","rt",stdin);
freopen("CHAR.MT","wb",stdout);
 
for(char_num=256;char_num;char_num--)
int do_symbol(short int font_width)
{
fseek(stdin,8,SEEK_CUR);
for(e=font_height;e;e--)
for(row=FONT_HEIGHT; row; row--)
{
data = 0;
for(i=0;i<font_width[0];i++)
for(col=0; col<font_width; col++)
{
data |= getchar()==' '?0:1<<i;
data |= getchar()==' '? 0 : 1<<col;
}
putchar(data);
fseek(stdin,3,SEEK_CUR);
putchar(data);
}
return 0;
}
 
 
int main()
{
freopen("char.txt", "rt", stdin);
freopen("CHAR.MT", "wb", stdout);
 
for(char_num=256; char_num; char_num--)
{
fseek(stdin, 8, SEEK_CUR);
do_symbol(FONT_WIDTH_MONO);
}
 
freopen("char2.txt","rt",stdin);
freopen("CHAR2.MT","wb",stdout);
 
34,16 → 51,7
ch = getchar();
putchar(ch==' '?0x08:ch-47);
fseek(stdin,3,SEEK_CUR);
for(e=font_height;e;e--)
{
data = 0;
for(i=0;i<font_width[1];i++)
{
data |= getchar()==' '?0:1<<i;
do_symbol(FONT_WIDTH_VAR);
}
putchar(data);
fseek(stdin,3,SEEK_CUR);
return 0;
}
}
return 0;
}
/programs/other/font_conv/fontconv.asm
0,0 → 1,189
;;===================================================================
;; Copyright 2011 dunkaist <dunkaist@gmail.com>
;; Distributed under the terms of the GNU General Public License v3.
;; See http://www.gnu.org/licenses/gpl.txt for the full license text.
;;-------------------------------------------------------------------
 
CHAR1TXT_FILE_SIZE equ 20478
CHAR2TXT_FILE_SIZE equ 25598
 
CHAR1MT_FILE_SIZE equ 2304
CHAR2MT_FILE_SIZE equ 2560
 
FONT_HEIGHT equ 9
FONT_WIDTH_MONO equ 5
FONT_WIDTH_VAR equ 7
 
 
use32
org 0x0
db 'MENUET01'
dd 0x01, start, i_end, e_end, stacktop, 0x0, cur_dir
 
include '../../proc32.inc'
include '../../macros.inc'
 
 
start:
mcall 68, 11
 
cld
mov ecx, 4096
mov edi, cur_dir
xor al, al
repnz scasb
std
mov al, '/'
repnz scasb
add edi, 2
cld
mov [cur_dir_slash], edi
mov esi, _char1.txt
mov ecx, 10/2
rep movsw
 
monospace:
mcall 70, func70 ; get file info
test eax, eax
jnz quit
 
mov ecx, dword[file_info.Size]
cmp ecx, CHAR1TXT_FILE_SIZE
jl quit
mov [func70.bytes_to_read], ecx
mcall 68, 12, ; allocate memory for char.txt
test eax, eax
jz quit
mov [func70.destination], eax
 
mov [func70.func_number], 0 ; read from file
mcall 70, func70
test eax, eax
jnz freemem_quit
 
 
xor dl, dl
mov esi, [func70.destination]
mov edi, esi ; yes, that's a feature
mov bl, FONT_WIDTH_MONO
.char:
add esi, 8
call do_symbol
dec dl
jnz .char
 
mov [func70.func_number], 2 ; create/overwrite file
mov [func70.bytes_to_read], CHAR1MT_FILE_SIZE
mov edi, [cur_dir_slash]
mov esi, _char1.mt
mov ecx, 10/2
rep movsw
mcall 70, func70
test eax, eax
jnz freemem_quit
 
 
varspace:
push [func70.destination]
push file_info
pop [func70.destination]
mov [func70.func_number], 5 ; get file info
mov edi, [cur_dir_slash]
mov esi, _char2.txt
mov ecx, 10/2
rep movsw
mcall 70, func70
pop [func70.destination]
test eax, eax
jnz freemem_quit
 
mov ecx, dword[file_info.Size]
cmp ecx, CHAR2TXT_FILE_SIZE
jl freemem_quit
mov [func70.bytes_to_read], ecx
mcall 68, 20, ; realloc memory
test eax, eax
jz freemem_quit
mov [func70.destination], eax
 
mov [func70.func_number], 0 ; read from file
mcall 70, func70
test eax, eax
jnz freemem_quit
 
 
xor dl, dl
mov esi, [func70.destination]
mov edi, esi ; yes, that's a feature
mov bl, FONT_WIDTH_VAR
.char:
add esi, 6
lodsb
cmp al, ' ' ; space means default symbol width (8)
jnz @f
mov al, 8+47
@@: sub al, 47
stosb
add esi, 3
call do_symbol
dec dl
jnz .char
 
 
mov [func70.func_number], 2 ; create/overwrite file
mov [func70.bytes_to_read], CHAR2MT_FILE_SIZE
mov edi, [cur_dir_slash]
mov esi, _char2.mt
mov ecx, 10/2
rep movsw
mcall 70, func70
test eax, eax
jnz freemem_quit
 
freemem_quit:
mcall 68, 13, [func70.destination]
quit:
mcall -1
 
 
proc do_symbol
mov ch, FONT_HEIGHT
.col: xor ah, ah
xor cl, cl
.row: lodsb
cmp al, ' '
setnz al
shl al, cl
or ah, al
inc cl
cmp cl, bl
jnz .row
add esi, 3
mov al, ah
stosb
dec ch
jnz .col
ret
endp
 
_char1.txt db 'char.txt',0
_char2.txt db 'char2.txt',0
_char1.mt db 'char.mt',0
_char2.mt db 'char2.mt',0
 
func70:
.func_number dd 5 ; function number
.position dd 0 ; position in file
.reserved dd 0 ; reserved
.bytes_to_read dd 0 ; bytes to read
.destination dd file_info
.flag db 0 ; see file name later
.file_name dd cur_dir ; pointer to the name of file (ASCIIZ)
 
i_end:
file_info FILEINFO
cur_dir rb 4096
cur_dir_slash rd 1 ; we save here position of the last '/' symbol
stack_here rb 0x200
stacktop:
e_end: