Subversion Repositories Kolibri OS

Rev

Rev 7433 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7433 Rev 7434
1
; BGIFONT.INC v1.0 beta
1
; BGIFONT.INC v1.0 beta
2
;
2
;
3
; Written in pure assembler by Ivushkin Andrey aka Willow
3
; Written in pure assembler by Ivushkin Andrey aka Willow
4
;
4
;
5
; Created: December 16, 2004
5
; Created: December 16, 2004
6
;
6
;
7
; Last changed: August 27, 2006
7
; Last changed: August 27, 2006
8
;
8
;
9
; Compile with FASM
9
; Compile with FASM
10
 
10
 
11
; BGI constants
11
; BGI constants
12
BGI_NODRAW   equ 0x10000
12
BGI_NODRAW   equ 0x10000
13
BGI_ITALIC   equ 0x20000
13
BGI_ITALIC   equ 0x20000
14
BGI_BOLD     equ 0x40000
14
BGI_BOLD     equ 0x40000
15
BGI_HALEFT   equ 0x0
15
BGI_HALEFT   equ 0x0
16
BGI_HARIGHT  equ 0x1000
16
BGI_HARIGHT  equ 0x1000
17
BGI_HACENTER equ 0x2000
17
BGI_HACENTER equ 0x2000
18
BGI_VABOTTOM equ 0x0
18
BGI_VABOTTOM equ 0x0
19
BGI_VATOP    equ 0x4000
19
BGI_VATOP    equ 0x4000
20
BGI_VACENTER equ 0x8000
20
BGI_VACENTER equ 0x8000
21
 
21
 
22
BGI_FREE     equ 0x80000000
22
BGI_FREE     equ 0x80000000
23
BGI_HAMASK   equ 0x3000
23
BGI_HAMASK   equ 0x3000
24
BGI_VAMASK   equ 0xc000
24
BGI_VAMASK   equ 0xc000
25
 
25
 
26
; Freetext structure
26
; Freetext structure
27
struc BGIfree FontName,XY,Angle,ScaleX,ScaleY,StrPtr,StrLen,Color,Align
27
struc BGIfree FontName,XY,Angle,ScaleX,ScaleY,StrPtr,StrLen,Color,Align
28
{
28
{
29
    dd FontName ;0
29
    dd FontName ;0
30
    dd XY	    ;4
30
    dd XY	    ;4
31
    dd Angle	;8
31
    dd Angle	;8
32
    dd ScaleX	;12
32
    dd ScaleX	;12
33
    dd ScaleY	;16
33
    dd ScaleY	;16
34
    dd StrPtr	;20
34
    dd StrPtr	;20
35
    dd StrLen	;24
35
    dd StrLen	;24
36
    dd Color	;28
36
    dd Color	;28
37
    dd Align	;32
37
    dd Align	;32
38
}
38
}
39
 
39
 
40
macro BGIfont_GetID
40
macro BGIfont_GetID
41
{
41
{
42
    call _BGIfont_GetID
42
    call _BGIfont_GetID
43
}
43
}
44
 
44
 
45
macro BGIfont_Prepare
45
macro BGIfont_Prepare
46
{
46
{
47
    call _BGIfont_Prepare
47
    call _BGIfont_Prepare
48
}
48
}
49
 
49
 
50
macro BGIfont_Freetext
50
macro BGIfont_Freetext
51
{
51
{
52
    call _BGIfont_Freetext
52
    call _BGIfont_Freetext
53
}
53
}
54
 
54
 
55
macro BGIfont_Outtext
55
macro BGIfont_Outtext
56
{
56
{
57
    call _BGIfont_Outtext
57
    call _BGIfont_Outtext
58
}
58
}
59
 
59
 
60
macro _FI name,_size
60
macro _FI name,_size
61
{
61
{
62
    db name
62
    db name
63
if BGI_LEVEL eq KERNEL
63
if BGI_LEVEL eq KERNEL
64
    dw _size
64
    dw _size
65
end if
65
end if
66
}
66
}
67
 
67
 
68
BGIfont_get2head:
68
BGIfont_get2head:
69
    shr  ecx,28 ; font #
69
    shr  ecx,28 ; font #
70
    sub  ecx,4
70
    sub  ecx,4
71
    jb	 .exit2	; invalid #
71
    jb	 .exit2	; invalid #
72
    mov  edi,[BGIfont_Ptr]
72
    mov  edi,[BGIfont_Ptr]
73
    inc  edi
73
    inc  edi
74
    cmp  cl,[edi-1]
74
    cmp  cl,[edi-1]
75
    jae  .exit2 ; # too large
75
    jae  .exit2 ; # too large
76
    jecxz .ex
76
    jecxz .ex
77
  .fnext:
77
  .fnext:
78
    mov  edi,[edi+16]
78
    mov  edi,[edi+16]
79
    loop .fnext
79
    loop .fnext
80
    jmp  .ex
80
    jmp  .ex
81
  .exit2:
81
  .exit2:
82
    xor  edi,edi
82
    xor  edi,edi
83
  .ex:
83
  .ex:
84
    ret
84
    ret
85
 
85
 
86
macro dps2 _str
86
macro dps2 _str
87
{
87
{
88
	if LOAD_MSG eq 1
88
	if LOAD_MSG eq 1
89
	dps _str
89
	dps _str
90
	end if
90
	end if
91
}
91
}
92
 
92
 
93
macro dph2 num,x,y
93
macro dph2 num,x,y
94
{
94
{
95
if  BGI_LEVEL eq KERNEL
95
if  BGI_LEVEL eq KERNEL
96
    pusha
96
    pusha
97
    mov  eax,0x00080100
97
    mov  eax,0x00080100
98
    mov  ebx,num
98
    mov  ebx,num
99
    mov  ecx,x shl 16+y
99
    mov  ecx,x shl 16+y
100
    mov  edx,0xFF0000
100
    mov  edx,0xFF0000
101
    call display_number
101
    call display_number
102
    popa
102
    popa
103
end if
103
end if
104
}
104
}
105
 
105
 
106
_BGIfont_GetID:
106
_BGIfont_GetID:
107
; in:  edx-font name;
107
; in:  edx-font name;
108
; out: eax-fontID, edi->BGIrec
108
; out: eax-fontID, edi->BGIrec
109
    push ecx edi
109
    push ecx edi
110
    mov  edi,[BGIfont_Ptr]
110
    mov  edi,[BGIfont_Ptr]
111
    movzx ecx,byte[edi] ; ecx-font count
111
    movzx ecx,byte[edi] ; ecx-font count
112
    mov  eax,ecx
112
    mov  eax,ecx
113
    inc  edi ; edi->FontName
113
    inc  edi ; edi->FontName
114
    jecxz .ex
114
    jecxz .ex
115
  .fnext:
115
  .fnext:
116
    cmp  edx,[edi]
116
    cmp  edx,[edi]
117
    jne  .floop
117
    jne  .floop
118
    sub  eax,ecx
118
    sub  eax,ecx
119
    add  eax,4
119
    add  eax,4
120
    shl  eax,28
120
    shl  eax,28
121
    jmp  .ex
121
    jmp  .ex
122
  .floop:
122
  .floop:
123
    mov  edi,[edi+16]
123
    mov  edi,[edi+16]
124
    loop .fnext
124
    loop .fnext
125
  .num0:
125
  .num0:
126
    xor  eax,eax
126
    xor  eax,eax
127
  .ex:
127
  .ex:
128
    pop  edi ecx
128
    pop  edi ecx
129
    ret
129
    ret
130
 
130
 
131
_BGIfont_Prepare:
131
_BGIfont_Prepare:
132
; in:  edx-font name, edi->pointer to load fonts (fonts_count)
132
; in:  edx-font name, edi->pointer to load fonts (fonts_count)
133
; out: eax-ID of new font loaded; eax=0 error
133
; out: eax-ID of new font loaded; eax=0 error
134
    cmp  [BGIfont_Ptr],0
134
    cmp  [BGIfont_Ptr],0
135
    jne  .already
135
    jne  .already
136
    mov  [BGIfont_Ptr],edi
136
    mov  [BGIfont_Ptr],edi
137
  .already:
137
  .already:
138
    pusha
138
    pusha
139
    mov  edi,[BGIfont_Ptr]
139
    mov  edi,[BGIfont_Ptr]
140
    movzx ecx,byte[edi] ; ecx-font count
140
    movzx ecx,byte[edi] ; ecx-font count
141
    mov  eax,ecx
141
    mov  eax,ecx
142
    inc  edi ; edi->FontName
142
    inc  edi ; edi->FontName
143
    jecxz .fload
143
    jecxz .fload
144
  .fnext:
144
  .fnext:
145
    cmp  edx,[edi]
145
    cmp  edx,[edi]
146
    jne  .loop
146
    jne  .loop
147
    sub  eax,ecx
147
    sub  eax,ecx
148
    inc  eax
148
    inc  eax
149
    jmp  .cr_id
149
    jmp  .cr_id
150
  .loop:
150
  .loop:
151
    mov  edi,[edi+16]
151
    mov  edi,[edi+16]
152
    loop .fnext
152
    loop .fnext
153
  .fload:
153
  .fload:
154
    mov  dword[.font],edx ; filename
154
    mov  dword[.font],edx ; filename
155
    mov  esi,edi     ; esi->FontName
155
    mov  esi,edi     ; esi->FontName
156
    mov  [.dest],edi ; ptr to load font
156
    mov  [.dest],edi ; ptr to load font
157
        mov     eax, 70
157
    ;    mov     eax, 70
158
        mov     ebx, .fontattr
158
    ;    mov     ebx, .fontattr
159
        mcall
159
    ;    mcall
160
        test    eax, eax
160
    ;    test    eax, eax
161
        ;jnz     .fail
161
    ;    ;jnz     .fail
162
        dps2    '1'
162
    ;    dps2    '1'
163
        mov     eax, [.fileattr+32]
163
    ;    mov     eax, [.fileattr+32]
164
    mov  [.fsize], litt_end-litt_file
164
    ;mov  [.fsize], litt_end-litt_file
165
    mov  ebx,.fontinfo
165
    ;mov  ebx,.fontinfo
166
    mov  eax,70
166
    ;mov  eax,70
167
    mcall	     ; ebx - file size
167
    ;mcall	     ; ebx - file size
168
    ;mov ebx, litt_end-litt_file
168
    mov ebx, litt_end-litt_file
169
    ;mov edi, litt_file
169
    mov edi, litt_file
170
	;mov  [.dest],litt_file ; ptr to load font
170
	mov  [.dest],litt_file ; ptr to load font
171
 
171
 
172
    cmp  dword[edi],0x08084b50 ; 'PK',8,8
172
    cmp  dword[edi],0x08084b50 ; 'PK',8,8
173
    jne  .fail
173
    jne  .fail
174
    dps2 '2'
174
    dps2 '2'
175
    inc  edi
175
    inc  edi
176
    mov  eax,26 ; #EOF
176
    mov  eax,26 ; #EOF
177
    mov  ecx,253
177
    mov  ecx,253
178
    cld
178
    cld
179
    repne scasb  ; skip Copyright
179
    repne scasb  ; skip Copyright
180
    test ecx,ecx
180
    test ecx,ecx
181
    jz	 .fail
181
    jz	 .fail
182
    dps2  '3'
182
    dps2  '3'
183
    cmp  edx,[edi+2] ; FontName
183
    cmp  edx,[edi+2] ; FontName
184
    jne  .fail
184
    jne  .fail
185
    dps2  '4'
185
    dps2  '4'
186
    movzx ecx,word[edi] ; HeaderSize
186
    movzx ecx,word[edi] ; HeaderSize
187
    sub  ebx,ecx  ; Filesize-Headersize
187
    sub  ebx,ecx  ; Filesize-Headersize
188
    movzx eax,word[edi+6] ; FontSize
188
    movzx eax,word[edi+6] ; FontSize
189
    cmp  eax,ebx
189
    cmp  eax,ebx
190
    jb	 .fail	  ; file truncated
190
    jb	 .fail	  ; file truncated
191
    add  ecx,[.dest]
191
    add  ecx,[.dest]
192
    dps2  '5'
192
    dps2  '5'
193
    cmp  byte[ecx],'+'	; ParPrefix
193
    cmp  byte[ecx],'+'	; ParPrefix
194
    jne  .fail
194
    jne  .fail
195
; font is valid, let's fill parameter table
195
; font is valid, let's fill parameter table
196
    dps2  '>'
196
    dps2  '>'
197
    mov  [esi],edx ; FontName
197
    mov  [esi],edx ; FontName
198
    mov  edx,eax
198
    mov  edx,eax
199
    add  eax,ecx
199
    add  eax,ecx
200
    mov  [esi+16],eax ; Font EOF
200
    mov  [esi+16],eax ; Font EOF
201
    movzx eax,word[ecx+5]
201
    movzx eax,word[ecx+5]
202
    add  eax,ecx
202
    add  eax,ecx
203
    mov  [esi+12],eax
203
    mov  [esi+12],eax
204
    lea  edi,[esi+4]  ; edi->CharsCount
204
    lea  edi,[esi+4]  ; edi->CharsCount
205
    lea  esi,[ecx+1] ; esi->ParPrefix+1
205
    lea  esi,[ecx+1] ; esi->ParPrefix+1
206
    xor  eax,eax
206
    xor  eax,eax
207
    lodsw
207
    lodsw
208
    stosb  ; CharsCount
208
    stosb  ; CharsCount
209
    inc  esi
209
    inc  esi
210
    movsb  ; FirstChar
210
    movsb  ; FirstChar
211
    add  esi,3
211
    add  esi,3
212
    lodsw
212
    lodsw
213
    stosb  ; UpperMargin
213
    stosb  ; UpperMargin
214
    movsb  ; LowerMargin
214
    movsb  ; LowerMargin
215
    add  esi,5 ; esi->offsets
215
    add  esi,5 ; esi->offsets
216
    mov  eax,[esi]
216
    mov  eax,[esi]
217
    push edi ; edi->Widths
217
    push edi ; edi->Widths
218
; prepare moving data
218
; prepare moving data
219
    add  edi,12 ; edi->offsets
219
    add  edi,12 ; edi->offsets
220
    lea  ecx,[edx-16]
220
    lea  ecx,[edx-16]
221
    rep  movsb
221
    rep  movsb
222
    pop  edi ; edi->Widths
222
    pop  edi ; edi->Widths
223
    mov  [edi+8],esi ; EOF
223
    mov  [edi+8],esi ; EOF
224
;    mov  eax,[edi]
224
;    mov  eax,[edi]
225
    movzx ecx,byte[edi-4] ; CharsCount
225
    movzx ecx,byte[edi-4] ; CharsCount
226
    lea  eax,[edi+12+ecx*2] ; eax->widths
226
    lea  eax,[edi+12+ecx*2] ; eax->widths
227
    stosd  ; edi->FirstData
227
    stosd  ; edi->FirstData
228
    add  eax,ecx
228
    add  eax,ecx
229
    stosd  ; edi->EOF
229
    stosd  ; edi->EOF
230
    mov  eax,[esp] ; eax->fonts_count
230
    mov  eax,[esp] ; eax->fonts_count
231
    inc  byte[eax] ; increase font counter
231
    inc  byte[eax] ; increase font counter
232
    movzx eax,byte[eax]
232
    movzx eax,byte[eax]
233
  .cr_id:
233
  .cr_id:
234
    add  eax,0x3   ; create unique ID
234
    add  eax,0x3   ; create unique ID
235
    shl  eax,28    ; to easy use in color(ecx)
235
    shl  eax,28    ; to easy use in color(ecx)
236
    jmp  .exit
236
    jmp  .exit
237
  .fail:
237
  .fail:
238
    xor  eax,eax
238
    xor  eax,eax
239
  .exit:
239
  .exit:
240
    mov  [esp+28],eax
240
    mov  [esp+28],eax
241
    popa
241
    popa
242
    ret
242
    ret
243
 
243
 
244
.fontinfo:
244
.fontinfo:
245
	dd 0
245
	dd 0
246
	dd 0
246
	dd 0
247
	dd 0
247
	dd 0
248
.fsize	dd 0
248
.fsize	dd 0
249
.dest	dd 0
249
.dest	dd 0
250
.fontfullname:
250
.fontfullname:
251
	db BGIFONT_PATH
251
	db BGIFONT_PATH
252
.font	db 'LITT.CHR',0
252
.font	db 'LITT.CHR',0
253
 
253
 
254
.fontattr:
254
.fontattr:
255
        dd      5
255
        dd      5
256
        dd      0
256
        dd      0
257
        dd      0
257
        dd      0
258
        dd      0
258
        dd      0
259
        dd      .fileattr
259
        dd      .fileattr
260
        db      0
260
        db      0
261
        dd      .fontfullname
261
        dd      .fontfullname
262
.fileattr rd 40/4
262
.fileattr rd 40/4
263
 
263
 
264
 
264
 
265
BGIfont_Coo:
265
BGIfont_Coo:
266
; y->word[txt.y1], x->word[txt.x1]
266
; y->word[txt.y1], x->word[txt.x1]
267
    fild [txt.y1] ;y
267
    fild [txt.y1] ;y
268
    fmul st0,st0; y*y
268
    fmul st0,st0; y*y
269
    fild [txt.x1] ;x
269
    fild [txt.x1] ;x
270
    fmul st0,st0; x*x
270
    fmul st0,st0; x*x
271
    faddp  ; x*x+y*y
271
    faddp  ; x*x+y*y
272
    fsqrt  ; sqrt, angle
272
    fsqrt  ; sqrt, angle
273
    fild [txt.y1];y
273
    fild [txt.y1];y
274
    fabs
274
    fabs
275
    fild [txt.x1] ; x
275
    fild [txt.x1] ; x
276
    fabs
276
    fabs
277
    fpatan ; arctg(y/x)
277
    fpatan ; arctg(y/x)
278
  .skip:
278
  .skip:
279
    cmp  [txt.x1],0
279
    cmp  [txt.x1],0
280
    jge  .xplus
280
    jge  .xplus
281
    fchs
281
    fchs
282
    fadd st0,st3
282
    fadd st0,st3
283
  .xplus:
283
  .xplus:
284
    cmp  [txt.y1],0
284
    cmp  [txt.y1],0
285
    jge  .yplus
285
    jge  .yplus
286
    fchs
286
    fchs
287
  .yplus:
287
  .yplus:
288
    fadd st0,st2
288
    fadd st0,st2
289
    fsincos
289
    fsincos
290
    fmul st0,st2
290
    fmul st0,st2
291
    fiadd [txt.x0]
291
    fiadd [txt.x0]
292
    fistp [txt.x1] ; x=r*cos a
292
    fistp [txt.x1] ; x=r*cos a
293
    fmulp ; y=r*sin a,angle
293
    fmulp ; y=r*sin a,angle
294
    fiadd [txt.y0]
294
    fiadd [txt.y0]
295
    fistp [txt.y1]
295
    fistp [txt.y1]
296
    ret
296
    ret
297
 
297
 
298
_BGIfont_Freetext:
298
_BGIfont_Freetext:
299
; in: ebx-BGIfree structure
299
; in: ebx-BGIfree structure
300
; out: eax-new drawing coords
300
; out: eax-new drawing coords
301
    mov  edx,[ebx]
301
    mov  edx,[ebx]
302
    call _BGIfont_GetID
302
    call _BGIfont_GetID
303
    test eax,eax
303
    test eax,eax
304
    jnz  .fexists
304
    jnz  .fexists
305
    ret
305
    ret
306
  .fexists:
306
  .fexists:
307
    pusha
307
    pusha
308
    fninit
308
    fninit
309
    fldpi
309
    fldpi
310
    fld  [pi180]
310
    fld  [pi180]
311
    fimul dword[ebx+8]
311
    fimul dword[ebx+8]
312
    fst  [BGIangle]
312
    fst  [BGIangle]
313
    mov  esi,[ebx+28]
313
    mov  esi,[ebx+28]
314
    and  esi,0xffffff
314
    and  esi,0xffffff
315
    add  esi,eax
315
    add  esi,eax
316
    mov  eax,[ebx+32]
316
    mov  eax,[ebx+32]
317
    and  [deform],0
317
    and  [deform],0
318
    test eax,BGI_ITALIC
318
    test eax,BGI_ITALIC
319
    jz	 .norm
319
    jz	 .norm
320
    mov  [deform],dword 0.4
320
    mov  [deform],dword 0.4
321
  .norm:
321
  .norm:
322
    mov  ebp,eax
322
    mov  ebp,eax
323
    or	  ebp,BGI_FREE
323
    or	  ebp,BGI_FREE
324
    mov  eax,[ebx+12]
324
    mov  eax,[ebx+12]
325
    mov  [Xscale],eax
325
    mov  [Xscale],eax
326
    mov  eax,[ebx+16]
326
    mov  eax,[ebx+16]
327
    mov  [Yscale],eax
327
    mov  [Yscale],eax
328
    mov  ecx,[ebx+20]
328
    mov  ecx,[ebx+20]
329
    mov  edx,ebp
329
    mov  edx,ebp
330
    and  edx,BGI_FREE+BGI_VAMASK+BGI_HAMASK
330
    and  edx,BGI_FREE+BGI_VAMASK+BGI_HAMASK
331
    add  edx,[ebx+24]
331
    add  edx,[ebx+24]
332
    mov  eax,[ebx+4]
332
    mov  eax,[ebx+4]
333
    mov  ebx,esi
333
    mov  ebx,esi
334
    add  ebx,0x6000000
334
    add  ebx,0x6000000
335
    mov  [esp+4],edx
335
    mov  [esp+4],edx
336
    mov  [esp+20],ecx
336
    mov  [esp+20],ecx
337
    jmp  txt
337
    jmp  txt
338
 
338
 
339
    pi180 dd 0.017453
339
    pi180 dd 0.017453
340
 
340
 
341
_BGIfont_Outtext:
341
_BGIfont_Outtext:
342
; in: ebx-[x][y], ecx-color, edx-string, esi-length
342
; in: ebx-[x][y], ecx-color, edx-string, esi-length
343
    pusha
343
    pusha
344
    mov  ebp,esi
344
    mov  ebp,esi
345
if ~ BGI_LEVEL eq KERNEL
345
if ~ BGI_LEVEL eq KERNEL
346
    mov  eax,ebx
346
    mov  eax,ebx
347
    mov  ebx,ecx
347
    mov  ebx,ecx
348
    mov  ecx,edx
348
    mov  ecx,edx
349
    mov  edx,esi
349
    mov  edx,esi
350
end if
350
end if
351
; in: eax-[x][y], ebx-color, ecx-string, edx-length
351
; in: eax-[x][y], ebx-color, ecx-string, edx-length
352
txt:
352
txt:
353
if  ~ BGI_LEVEL eq KERNEL
353
if  ~ BGI_LEVEL eq KERNEL
354
  if  BGI_WINDOW_CLIP eq 1
354
  if  BGI_WINDOW_CLIP eq 1
355
    pusha
355
    pusha
356
    mov  eax,9
356
    mov  eax,9
357
    mov  ebx,BGI_PRC_INFO
357
    mov  ebx,BGI_PRC_INFO
358
    mov  ecx,-1
358
    mov  ecx,-1
359
    mcall
359
    mcall
360
    popa
360
    popa
361
  end if
361
  end if
362
end if
362
end if
363
    mov  [.y0],ax
363
    mov  [.y0],ax
364
    shr  eax,16
364
    shr  eax,16
365
    mov  [.x0],ax
365
    mov  [.x0],ax
366
    mov  ecx,ebx ; color
366
    mov  ecx,ebx ; color
367
    and  ebx,0xfffffff
367
    and  ebx,0xfffffff
368
    mov  [.color],ebx
368
    mov  [.color],ebx
369
    call BGIfont_get2head
369
    call BGIfont_get2head
370
    test edi,edi
370
    test edi,edi
371
    jz   .exit
371
    jz   .exit
372
    mov  ecx,[esp+4]; str length
372
    mov  ecx,[esp+4]; str length
373
    mov  esi,[esp+20]; str ptr
373
    mov  esi,[esp+20]; str ptr
374
    movzx eax,byte[edi+5]
374
    movzx eax,byte[edi+5]
375
    push ecx
375
    push ecx
376
    and  ecx,0xff
376
    and  ecx,0xff
377
    jnz  .lenok
377
    jnz  .lenok
378
    add  esp,4
378
    add  esp,4
379
    jmp  .ex2
379
    jmp  .ex2
380
  .lenok:
380
  .lenok:
381
    pusha
381
    pusha
382
    push dword[txt.y0]
382
    push dword[txt.y0]
383
    and  dword[txt.y0],0
383
    and  dword[txt.y0],0
384
    xor  edx,edx
384
    xor  edx,edx
385
    mov  ebx,[edi+8]
385
    mov  ebx,[edi+8]
386
   .next:
386
   .next:
387
    call txt.BGIfont_GetChar
387
    call txt.BGIfont_GetChar
388
    movzx eax,byte[ebx+eax]
388
    movzx eax,byte[ebx+eax]
389
    add  edx,eax
389
    add  edx,eax
390
    loop .next
390
    loop .next
391
    mov  ecx,edx ; ecx - x size
391
    mov  ecx,edx ; ecx - x size
392
    movzx dx,byte[edi+6]
392
    movzx dx,byte[edi+6]
393
    mov  [BGIheight],dx
393
    mov  [BGIheight],dx
394
    mov  ebx,[esp+36]
394
    mov  ebx,[esp+36]
395
    and  ebx,BGI_HAMASK
395
    and  ebx,BGI_HAMASK
396
    cmp  ebx,BGI_HARIGHT
396
    cmp  ebx,BGI_HARIGHT
397
    je   .nova
397
    je   .nova
398
    ja   .subv
398
    ja   .subv
399
    xor  ecx,ecx
399
    xor  ecx,ecx
400
    jmp  .nova
400
    jmp  .nova
401
  .subv:
401
  .subv:
402
    shr  cx,1
402
    shr  cx,1
403
  .nova:
403
  .nova:
404
    mov  ebx,[esp+36]
404
    mov  ebx,[esp+36]
405
    and  ebx,BGI_VAMASK
405
    and  ebx,BGI_VAMASK
406
    cmp  ebx,BGI_VATOP
406
    cmp  ebx,BGI_VATOP
407
    je   .def
407
    je   .def
408
    ja   .subh
408
    ja   .subh
409
    xor  edx,edx
409
    xor  edx,edx
410
    jmp  .def
410
    jmp  .def
411
  .subh:
411
  .subh:
412
    shr  dx,1
412
    shr  dx,1
413
  .def:
413
  .def:
414
    call txt.BGIfont_Deform
414
    call txt.BGIfont_Deform
415
    pop  dword[txt.y0]
415
    pop  dword[txt.y0]
416
    popa
416
    popa
417
    pop  ebx
417
    pop  ebx
418
    mov  ax,[txt.y1]
418
    mov  ax,[txt.y1]
419
    sub  [txt.y0],ax
419
    sub  [txt.y0],ax
420
    mov  ax,[txt.x1]
420
    mov  ax,[txt.x1]
421
    sub  [txt.x0],ax
421
    sub  [txt.x0],ax
422
    xor  eax,eax
422
    xor  eax,eax
423
    cld
423
    cld
424
.mloop:
424
.mloop:
425
    push [.y0]
425
    push [.y0]
426
    pop  [.y]
426
    pop  [.y]
427
    push [.x0]
427
    push [.x0]
428
    pop  [.x]
428
    pop  [.x]
429
    call .BGIfont_GetChar
429
    call .BGIfont_GetChar
430
    push esi
430
    push esi
431
    lea  esi,[edi+20] ; offset
431
    lea  esi,[edi+20] ; offset
432
    movzx edx,word[esi+eax*2] ; ofs1
432
    movzx edx,word[esi+eax*2] ; ofs1
433
    add  edx,[edi+12]
433
    add  edx,[edi+12]
434
    inc  eax
434
    inc  eax
435
    cmp  al,[edi+4]
435
    cmp  al,[edi+4]
436
    je	 .eof
436
    je	 .eof
437
    movzx eax,word[esi+eax*2]; ofs2
437
    movzx eax,word[esi+eax*2]; ofs2
438
    add   eax,[edi+12]
438
    add   eax,[edi+12]
439
    jmp   .prc_vec
439
    jmp   .prc_vec
440
  .eof:
440
  .eof:
441
    mov  eax,[edi+16] ; ofs2=eof
441
    mov  eax,[edi+16] ; ofs2=eof
442
  .prc_vec:  ; edx-vec cmd ifs, eax-cmd limit
442
  .prc_vec:  ; edx-vec cmd ifs, eax-cmd limit
443
    mov  [.vec_end],eax
443
    mov  [.vec_end],eax
444
    push ecx
444
    push ecx
445
  .vec_loop:
445
  .vec_loop:
446
    mov  ax,word[edx]
446
    mov  ax,word[edx]
447
    push edx
447
    push edx
448
    mov  ecx,eax
448
    mov  ecx,eax
449
    and  eax,0x8080 ; op
449
    and  eax,0x8080 ; op
450
    and  ecx,0x7f ; xx
450
    and  ecx,0x7f ; xx
451
    mov  edx,[edx+1]
451
    mov  edx,[edx+1]
452
    and  edx,0x7f ; yy
452
    and  edx,0x7f ; yy
453
    cmp  edx,63
453
    cmp  edx,63
454
    jbe  .positive
454
    jbe  .positive
455
    sub  edx,128  ; yy-=128
455
    sub  edx,128  ; yy-=128
456
  .positive:
456
  .positive:
457
    cmp  ecx,63
457
    cmp  ecx,63
458
    jbe  .positive2
458
    jbe  .positive2
459
    sub  ecx,128  ; xx-=128
459
    sub  ecx,128  ; xx-=128
460
  .positive2:
460
  .positive2:
461
    call .BGIfont_Deform
461
    call .BGIfont_Deform
462
    cmp  eax,0x8080
462
    cmp  eax,0x8080
463
    jne  .noline
463
    jne  .noline
464
    test ebp,BGI_NODRAW
464
    test ebp,BGI_NODRAW
465
    jnz  .noline
465
    jnz  .noline
466
; draw vector
466
; draw vector
467
if ~ BGI_LEVEL eq KERNEL
467
if ~ BGI_LEVEL eq KERNEL
468
    push eax
468
    push eax
469
    mov  ebx,dword[.x1]
469
    mov  ebx,dword[.x1]
470
    mov  ecx,dword[.y1]
470
    mov  ecx,dword[.y1]
471
  if BGI_WINDOW_CLIP eq 1
471
  if BGI_WINDOW_CLIP eq 1
472
    movzx eax,[.x]
472
    movzx eax,[.x]
473
    cmp  eax,dword[BGI_PRC_INFO+42]
473
    cmp  eax,dword[BGI_PRC_INFO+42]
474
    ja   .nobold
474
    ja   .nobold
475
    movzx eax,[.y]
475
    movzx eax,[.y]
476
    cmp  eax,dword[BGI_PRC_INFO+46]
476
    cmp  eax,dword[BGI_PRC_INFO+46]
477
    ja  .nobold
477
    ja  .nobold
478
    xor  eax,eax
478
    xor  eax,eax
479
    cmp  ax,bx
479
    cmp  ax,bx
480
    jg   .nobold
480
    jg   .nobold
481
    cmp  ax,cx
481
    cmp  ax,cx
482
    jg   .nobold
482
    jg   .nobold
483
  end if
483
  end if
484
    mov  edx,[.color]
484
    mov  edx,[.color]
485
; \begin{diamond}[18.08.2006]
485
; \begin{diamond}[18.08.2006]
486
; starting from K0530 kernel interprets flag 0x1000000 as
486
; starting from K0530 kernel interprets flag 0x1000000 as
487
; negate existing pixels colors, disregarding passed color
487
; negate existing pixels colors, disregarding passed color
488
; we do not want this
488
; we do not want this
489
    and  edx, 0xFFFFFF
489
    and  edx, 0xFFFFFF
490
; \end{diamond}[18.08.2006]
490
; \end{diamond}[18.08.2006]
491
    mov  eax,38
491
    mov  eax,38
492
    mcall
492
    mcall
493
    test ebp,BGI_BOLD
493
    test ebp,BGI_BOLD
494
    jz	 .nobold
494
    jz	 .nobold
495
    test ebp,BGI_FREE
495
    test ebp,BGI_FREE
496
    jnz  .free5
496
    jnz  .free5
497
  .free5:
497
  .free5:
498
    add  ebx,1 shl 16+1
498
    add  ebx,1 shl 16+1
499
    mcall
499
    mcall
500
  .nobold:
500
  .nobold:
501
    pop  eax
501
    pop  eax
502
else
502
else
503
    pusha
503
    pusha
504
    mov  eax,dword[.x1]
504
    mov  eax,dword[.x1]
505
    mov  ebx,dword[.y1]
505
    mov  ebx,dword[.y1]
506
    mov  ecx,[.color]
506
    mov  ecx,[.color]
507
;    call syscall_drawline
507
;    call syscall_drawline
508
    test dword[esp+8],BGI_BOLD
508
    test dword[esp+8],BGI_BOLD
509
    jz	 .nobold
509
    jz	 .nobold
510
    add  eax,1 shl 16+1
510
    add  eax,1 shl 16+1
511
;    call syscall_drawline
511
;    call syscall_drawline
512
  .nobold:
512
  .nobold:
513
    popa
513
    popa
514
end if
514
end if
515
  .noline:
515
  .noline:
516
    pop  edx
516
    pop  edx
517
    test eax,eax
517
    test eax,eax
518
    je	 .eovecs  ; op=0
518
    je	 .eovecs  ; op=0
519
    push [.y1]
519
    push [.y1]
520
    pop  [.y]
520
    pop  [.y]
521
    push [.x1]
521
    push [.x1]
522
    pop  [.x]
522
    pop  [.x]
523
    add  edx,2
523
    add  edx,2
524
    cmp  edx,[.vec_end]
524
    cmp  edx,[.vec_end]
525
    jb	 .vec_loop
525
    jb	 .vec_loop
526
  .eovecs:
526
  .eovecs:
527
    pop  ecx esi
527
    pop  ecx esi
528
    push [.y]
528
    push [.y]
529
    pop  [.y0]
529
    pop  [.y0]
530
    push [.x]
530
    push [.x]
531
    pop  [.x0]
531
    pop  [.x0]
532
    loop .mloop1
532
    loop .mloop1
533
    jmp  .exit
533
    jmp  .exit
534
  .mloop1:
534
  .mloop1:
535
    jmp  .mloop
535
    jmp  .mloop
536
  .exit:
536
  .exit:
537
    mov  eax,dword[.y0]
537
    mov  eax,dword[.y0]
538
    mov  [esp+28],eax
538
    mov  [esp+28],eax
539
  .ex2:
539
  .ex2:
540
    popa
540
    popa
541
    ret
541
    ret
542
 
542
 
543
.BGIfont_Deform:
543
.BGIfont_Deform:
544
    test ebp,BGI_FREE
544
    test ebp,BGI_FREE
545
    jnz  .free0
545
    jnz  .free0
546
    movzx ebx,byte[.color+3] ;ebx=scale
546
    movzx ebx,byte[.color+3] ;ebx=scale
547
    imul ecx,ebx
547
    imul ecx,ebx
548
    add  ecx,2
548
    add  ecx,2
549
    shr  ecx,2
549
    shr  ecx,2
550
    imul edx,ebx
550
    imul edx,ebx
551
    add  edx,2
551
    add  edx,2
552
    shr  edx,2
552
    shr  edx,2
553
    neg  edx
553
    neg  edx
554
    mov  [.x1],cx
554
    mov  [.x1],cx
555
    mov  [.y1],dx
555
    mov  [.y1],dx
556
    jmp  .add
556
    jmp  .add
557
  .free0:
557
  .free0:
558
    mov  [.x1],cx
558
    mov  [.x1],cx
559
    mov  [.y1],dx
559
    mov  [.y1],dx
560
    fild [.y1]
560
    fild [.y1]
561
    fld  st0
561
    fld  st0
562
    fmul [Yscale]
562
    fmul [Yscale]
563
    fchs
563
    fchs
564
    fistp [.y1]
564
    fistp [.y1]
565
    fmul [deform]
565
    fmul [deform]
566
    fiadd [.x1]
566
    fiadd [.x1]
567
    fmul [Xscale]
567
    fmul [Xscale]
568
    fistp [.x1]
568
    fistp [.x1]
569
    cmp  [BGIangle],0
569
    cmp  [BGIangle],0
570
    je	 .add
570
    je	 .add
571
    call BGIfont_Coo
571
    call BGIfont_Coo
572
    jmp  .eax
572
    jmp  .eax
573
  .add:
573
  .add:
574
    mov  cx,[.x0]
574
    mov  cx,[.x0]
575
    add  [.x1],cx
575
    add  [.x1],cx
576
    mov  cx,[.y0]
576
    mov  cx,[.y0]
577
    add  [.y1],cx
577
    add  [.y1],cx
578
  .eax:
578
  .eax:
579
    ret
579
    ret
580
 
580
 
581
.BGIfont_GetChar:
581
.BGIfont_GetChar:
582
; in:  esi -> string; edi -> BGIrec
582
; in:  esi -> string; edi -> BGIrec
583
; out: esi -> next char; al - char obtained
583
; out: esi -> next char; al - char obtained
584
    lodsb  ; al - char from str
584
    lodsb  ; al - char from str
585
    sub  al,[edi+5]
585
    sub  al,[edi+5]
586
    jb	 .out
586
    jb	 .out
587
    cmp  al,[edi+4]
587
    cmp  al,[edi+4]
588
    jb	 .in
588
    jb	 .in
589
  .out:
589
  .out:
590
    xor  al,al ; al - 1st symbol available
590
    xor  al,al ; al - 1st symbol available
591
  .in:
591
  .in:
592
    ret
592
    ret
593
 
593
 
594
.y0	 dw ?
594
.y0	 dw ?
595
.x0	 dw ?
595
.x0	 dw ?
596
 
596
 
597
.x1	 dw ?
597
.x1	 dw ?
598
.x	 dw ?
598
.x	 dw ?
599
.y1	 dw ?
599
.y1	 dw ?
600
.y	 dw ?
600
.y	 dw ?
601
 
601
 
602
.color	 dd ?
602
.color	 dd ?
603
.vec_end dd ?
603
.vec_end dd ?
604
BGIfont_Ptr  dd 0
604
BGIfont_Ptr  dd 0
605
BGIheight dw ?
605
BGIheight dw ?
606
deform dd ?
606
deform dd ?
607
BGIangle dd ?
607
BGIangle dd ?
608
Xscale  dd ?
608
Xscale  dd ?
609
Yscale  dd ?
609
Yscale  dd ?