Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2232 dunkaist 1
;;===================================================================
2
;; Copyright 2011 dunkaist 
3
;; Distributed under the terms of the GNU General Public License v3.
4
;; See http://www.gnu.org/licenses/gpl.txt for the full license text.
5
;;-------------------------------------------------------------------
6
 
7
CHAR1TXT_FILE_SIZE	equ	20478
8
CHAR2TXT_FILE_SIZE	equ	25598
9
 
10
CHAR1MT_FILE_SIZE	equ	2304
11
CHAR2MT_FILE_SIZE	equ	2560
12
 
13
FONT_HEIGHT		equ	9
14
FONT_WIDTH_MONO		equ	5
15
FONT_WIDTH_VAR		equ	7
16
 
17
 
18
use32
19
	org	0x0
20
	db	'MENUET01'
21
	dd	0x01, start, i_end, e_end, stacktop, 0x0, cur_dir
22
 
23
include '../../proc32.inc'
24
include '../../macros.inc'
25
 
26
 
27
start:
28
	mcall	68, 11
29
 
30
	cld
31
	mov	ecx, 4096
32
	mov	edi, cur_dir
33
	xor	al, al
34
	repnz	scasb
35
	std
36
	mov	al, '/'
37
	repnz	scasb
38
	add	edi, 2
39
	cld
40
	mov	[cur_dir_slash], edi
41
	mov	esi, _char1.txt
42
	mov	ecx, 10/2
43
	rep	movsw
44
 
45
monospace:
46
	mcall	70, func70			; get file info
47
	test	eax, eax
48
	jnz	quit
49
 
50
	mov	ecx, dword[file_info.Size]
51
	cmp	ecx, CHAR1TXT_FILE_SIZE
52
	jl	quit
53
	mov	[func70.bytes_to_read], ecx
54
	mcall	68, 12, 			; allocate memory for char.txt
55
	test	eax, eax
56
	jz	quit
57
	mov	[func70.destination], eax
58
 
59
	mov	[func70.func_number], 0		; read from file
60
	mcall	70, func70
61
	test	eax, eax
62
	jnz	freemem_quit
63
 
64
 
65
	xor	dl, dl
66
	mov	esi, [func70.destination]
67
	mov	edi, esi			; yes, that's a feature
68
	mov	bl, FONT_WIDTH_MONO
69
  .char:
70
	add	esi, 8
71
	call	do_symbol
72
	dec	dl
73
	jnz	.char
74
 
75
	mov	[func70.func_number], 2		; create/overwrite file
76
	mov	[func70.bytes_to_read], CHAR1MT_FILE_SIZE
77
	mov	edi, [cur_dir_slash]
78
	mov	esi, _char1.mt
79
	mov	ecx, 10/2
80
	rep	movsw
81
	mcall	70, func70
82
	test	eax, eax
83
	jnz	freemem_quit
84
 
85
 
86
varspace:
87
	push	[func70.destination]
88
	push	file_info
89
	pop	[func70.destination]
90
	mov	[func70.func_number], 5		; get file info
91
	mov	edi, [cur_dir_slash]
92
	mov	esi, _char2.txt
93
	mov	ecx, 10/2
94
	rep	movsw
95
	mcall	70, func70
96
	pop	[func70.destination]
97
	test	eax, eax
98
	jnz	freemem_quit
99
 
100
	mov	ecx, dword[file_info.Size]
101
	cmp	ecx, CHAR2TXT_FILE_SIZE
102
	jl	freemem_quit
103
	mov	[func70.bytes_to_read], ecx
104
	mcall	68, 20, 			; realloc memory
105
	test	eax, eax
106
	jz	freemem_quit
107
	mov	[func70.destination], eax
108
 
109
	mov	[func70.func_number], 0		; read from file
110
	mcall	70, func70
111
	test	eax, eax
112
	jnz	freemem_quit
113
 
114
 
115
	xor	dl, dl
116
	mov	esi, [func70.destination]
117
	mov	edi, esi			; yes, that's a feature
118
	mov	bl, FONT_WIDTH_VAR
119
  .char:
120
	add	esi, 6
121
	lodsb
122
	cmp	al, ' '			; space means default symbol width (8)
123
	jnz	@f
124
	mov	al, 8+47
125
    @@:	sub	al, 47
126
	stosb
127
	add	esi, 3
128
	call	do_symbol
129
	dec	dl
130
	jnz	.char
131
 
132
 
133
	mov	[func70.func_number], 2		; create/overwrite file
134
	mov	[func70.bytes_to_read], CHAR2MT_FILE_SIZE
135
	mov	edi, [cur_dir_slash]
136
	mov	esi, _char2.mt
137
	mov	ecx, 10/2
138
	rep	movsw
139
	mcall	70, func70
140
	test	eax, eax
141
	jnz	freemem_quit
142
 
143
freemem_quit:
144
	mcall	68, 13, [func70.destination]
145
quit:
146
	mcall	-1
147
 
148
 
149
proc do_symbol
150
	mov	ch, FONT_HEIGHT
151
  .col:	xor	ah, ah
152
	xor	cl, cl
153
  .row:	lodsb
154
	cmp	al, ' '
155
	setnz	al
156
	shl	al, cl
157
	or	ah, al
158
	inc	cl
159
	cmp	cl, bl
160
	jnz	.row
161
	add	esi, 3
162
	mov	al, ah
163
	stosb
164
	dec	ch
165
	jnz	.col
166
	ret
167
endp
168
 
169
_char1.txt	db 'char.txt',0
170
_char2.txt	db 'char2.txt',0
171
_char1.mt	db 'char.mt',0
172
_char2.mt	db 'char2.mt',0
173
 
174
func70:
175
  .func_number		dd 5		; function number
176
  .position		dd 0		; position in file
177
  .reserved		dd 0		; reserved
178
  .bytes_to_read	dd 0		; bytes to read
179
  .destination		dd file_info
180
  .flag			db 0		; see file name later
181
  .file_name		dd cur_dir	; pointer to the name of file (ASCIIZ)
182
 
183
i_end:
184
file_info	FILEINFO
185
cur_dir		rb 4096
186
cur_dir_slash	rd 1			; we save here position of the last '/' symbol
187
stack_here	rb 0x200
188
stacktop:
189
e_end: