Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 139
1
;workarea:    <- RTF_work
1
;workarea:    <- RTF_work
2
;  listptr dd savelist    0
2
;  listptr dd savelist    0
3
;  szKeyword rb 31        4
3
;  szKeyword rb 31        4
4
;  szParameter rb 21      35
4
;  szParameter rb 21      35
5
 
5
 
6
include 'rtftype.inc'
6
include 'rtftype.inc'
7
include 'rtfactn.inc'
7
include 'rtfactn.inc'
8
 
8
 
9
read_next_block:
9
read_next_block:
10
  inc  [cur_block]
10
  inc  [cur_block]
11
read_block:
11
read_block:
12
  mov  esi,I_END
12
  mov  esi,I_END
13
  pusha
13
  pusha
14
  mov  ecx,[cur_block]
14
  mov  ecx,[cur_block]
15
  mov  ebx,fileinfo
15
  mov  ebx,fileinfo
16
  mov  eax,ecx
16
  mov  eax,ecx
17
  shl  eax,7
17
  shl  eax,16
18
  mov  [ebx+4],eax
18
  mov  [ebx+4],eax
19
;  mov  [ebx+12],esi
19
;  mov  [ebx+12],esi
20
  mcall 58
20
  mcall 70
21
if DEBUG_BLOCK eq 1
21
if DEBUG_BLOCK eq 1
22
;  dps  'B='
22
;  dps  'B='
23
;  dpd  ecx
23
;  dpd  ecx
24
;  dps  <13,10>
24
;  dps  <13,10>
25
end if
25
end if
26
  cmp  ecx,[max_block]
26
  cmp  ecx,[max_block]
27
  je   .last
27
  je   .last
28
  mov  ebx,I_END+RTFSIZE
28
  mov  ebx,I_END+RTFSIZE
29
  jmp  .add
29
  jmp  .add
30
.last:
30
.last:
31
  mov  ebx,[tail]
31
  mov  ebx,[tail]
32
;  dpd  ebx
32
;  dpd  ebx
33
.add:
33
.add:
34
;  dpd  ebx
34
;  dpd  ebx
35
  mov  [block_end],ebx
35
  mov  [block_end],ebx
36
  popa
36
  popa
37
;  dpd  esi
37
;  dpd  esi
38
;  dps  <13,10>
38
;  dps  <13,10>
39
  ret
39
  ret
40
;
40
;
41
; %%Function: ecRtfParse
41
; %%Function: ecRtfParse
42
;
42
;
43
; Step 1:
43
; Step 1:
44
; Isolate RTF keywords and send them to ecParseRtfKeyword;
44
; Isolate RTF keywords and send them to ecParseRtfKeyword;
45
; Push and pop state at the start and end of RTF groups;
45
; Push and pop state at the start and end of RTF groups;
46
; Send text to ecParseChar for further processing.
46
; Send text to ecParseChar for further processing.
47
;
47
;
48
macro CopySave _src,_dest
48
macro CopySave _src,_dest
49
{
49
{
50
    pusha
50
    pusha
51
    mov  ecx,SIZE_save
51
    mov  ecx,SIZE_save
52
    mov  esi,_src
52
    mov  esi,_src
53
    mov  edi,_dest
53
    mov  edi,_dest
54
    rep  movsb
54
    rep  movsb
55
    popa
55
    popa
56
}
56
}
57
 
57
 
58
RtfParse:
58
RtfParse:
59
 
59
 
60
 if BENCH eq 1
60
 if BENCH eq 1
61
    mcall 26,9
61
    mcall 26,9
62
    mov  [bench],eax
62
    mov  [bench],eax
63
 end if
63
 end if
64
    mov  [RetroPtr],esi
64
    mov  [RetroPtr],esi
65
    CopySave Chp,RetroSave
65
    CopySave Chp,RetroSave
66
    push dword[Free+4]
66
    push dword[Free+4]
67
    pop  dword[RetroXY]
67
    pop  dword[RetroXY]
68
    xor  eax,eax
68
    xor  eax,eax
69
    mov  [cur_block],eax
69
    mov  [cur_block],eax
70
    mov  [RetroBlock],eax
70
    mov  [RetroBlock],eax
71
    push [cGroup]
71
    push [cGroup]
72
    pop  [RetroGroup]
72
    pop  [RetroGroup]
73
    and  [mode],not RTF_BLIND
73
    and  [mode],not RTF_BLIND
74
    mov  [listptr],save_stack
74
    mov  [listptr],save_stack
75
    mov  [fileinfo.size],128
75
    mov  [fileinfo.size],128*512
76
;    test ebp,RTF_HELP
76
;    test ebp,RTF_HELP
77
    test [mode],RTF_HELP
77
    test [mode],RTF_HELP
78
    jne  .noread
78
    jne  .noread
79
    call read_block
79
    call read_block
80
  .noread:
80
  .noread:
81
    mov  [RetroPtr],esi
81
    mov  [RetroPtr],esi
82
  .nib2:
82
  .nib2:
83
    mov  [nibble],2
83
    mov  [nibble],2
84
    and  [b],al
84
    and  [b],al
85
  .getc:
85
  .getc:
86
    xor  eax,eax
86
    xor  eax,eax
87
    lods_block
87
    lods_block
88
    cmp  [cGroup],0
88
    cmp  [cGroup],0
89
    jge  .ok1
89
    jge  .ok1
90
    Return ecStackUnderflow
90
    Return ecStackUnderflow
91
  .ok1:
91
  .ok1:
92
    cmp  [ris],risBin
92
    cmp  [ris],risBin
93
    jne  .nobin
93
    jne  .nobin
94
    RetError ecParseChar
94
    RetError ecParseChar
95
  .nobin:
95
  .nobin:
96
    cmp  al,'{'
96
    cmp  al,'{'
97
    jne  .nobr1
97
    jne  .nobr1
98
    RetError ecPushRtfState
98
    RetError ecPushRtfState
99
  .nobr1:
99
  .nobr1:
100
    cmp  al,'}'
100
    cmp  al,'}'
101
    jne  .nobr2
101
    jne  .nobr2
102
    RetError ecPopRtfState
102
    RetError ecPopRtfState
103
  .nobr2:
103
  .nobr2:
104
    cmp  al,'\'
104
    cmp  al,'\'
105
    jne  .noslash
105
    jne  .noslash
106
    RetError ecParseRtfKeyword
106
    RetError ecParseRtfKeyword
107
  .noslash:
107
  .noslash:
108
    cmp  al,0xd
108
    cmp  al,0xd
109
    je   .getc
109
    je   .getc
110
    cmp  al,0xa
110
    cmp  al,0xa
111
    je   .getc
111
    je   .getc
112
  .nouc:
112
  .nouc:
113
    cmp  [ris],risNorm
113
    cmp  [ris],risNorm
114
    jne  .nonorm
114
    jne  .nonorm
115
    call ecParseChar
115
    call ecParseChar
116
    cmp  eax,ecOutOfWindow
116
    cmp  eax,ecOutOfWindow
117
    je   .__ex
117
    je   .__ex
118
    test eax,eax
118
    test eax,eax
119
    je   .getc
119
    je   .getc
120
    jmp  .__ex
120
    jmp  .__ex
121
  .nonorm:
121
  .nonorm:
122
    cmp  [ris],risHex
122
    cmp  [ris],risHex
123
    je   .noassert
123
    je   .noassert
124
    Return ecAssertion
124
    Return ecAssertion
125
  .noassert:
125
  .noassert:
126
    shl  [b],4
126
    shl  [b],4
127
    isdigit al, .nodig
127
    isdigit al, .nodig
128
    sub  al,'0'
128
    sub  al,'0'
129
    add  [b],al
129
    add  [b],al
130
    jmp  .nibble
130
    jmp  .nibble
131
  .nodig:
131
  .nodig:
132
    islower al, .nolow
132
    islower al, .nolow
133
    cmp  al,'a'
133
    cmp  al,'a'
134
    jb   .inval
134
    jb   .inval
135
    cmp  al,'f'
135
    cmp  al,'f'
136
    ja   .inval
136
    ja   .inval
137
    sub  al,'a'-10
137
    sub  al,'a'-10
138
    jmp  .nib0
138
    jmp  .nib0
139
  .inval:
139
  .inval:
140
  if INVALHEX eq 0
140
  if INVALHEX eq 0
141
    jmp  .getc
141
    jmp  .getc
142
  else
142
  else
143
;    sub  esi,I_END+1
143
;    sub  esi,I_END+1
144
;    dpd  esi
144
;    dpd  esi
145
;    movzx eax,al
145
;    movzx eax,al
146
;    dpd  eax
146
;    dpd  eax
147
;    movzx eax,[b]
147
;    movzx eax,[b]
148
;    dpd  eax
148
;    dpd  eax
149
    Return ecInvalidHex
149
    Return ecInvalidHex
150
  end if
150
  end if
151
  .nolow:
151
  .nolow:
152
    cmp  al,'A'
152
    cmp  al,'A'
153
    jb   .inval
153
    jb   .inval
154
    cmp  al,'F'
154
    cmp  al,'F'
155
    ja   .inval
155
    ja   .inval
156
    sub  al,'A'-10
156
    sub  al,'A'-10
157
  .nib0:
157
  .nib0:
158
    add  [b],al
158
    add  [b],al
159
  .nibble:
159
  .nibble:
160
    dec  [nibble]
160
    dec  [nibble]
161
    cmp  [nibble],0
161
    cmp  [nibble],0
162
    jnz  .getc
162
    jnz  .getc
163
    movzx eax,[b]
163
    movzx eax,[b]
164
    mov  [ris],risNorm
164
    mov  [ris],risNorm
165
    call ecParseChar
165
    call ecParseChar
166
    test eax,eax
166
    test eax,eax
167
    jnz  .__ex
167
    jnz  .__ex
168
;    mov  [ris],risNorm
168
;    mov  [ris],risNorm
169
    jmp  .nib2
169
    jmp  .nib2
170
  .eof:
170
  .eof:
171
    xor  eax,eax
171
    xor  eax,eax
172
    cmp  eax,[cGroup]
172
    cmp  eax,[cGroup]
173
    je   .__ex
173
    je   .__ex
174
    jg   .unbr
174
    jg   .unbr
175
    Return ecStackUnderflow
175
    Return ecStackUnderflow
176
  .unbr:
176
  .unbr:
177
    mov  eax,ecUnmatchedBrace
177
    mov  eax,ecUnmatchedBrace
178
  .__ex:
178
  .__ex:
179
    ret
179
    ret
180
nibble db 2
180
nibble db 2
181
b      db 0
181
b      db 0
182
RTF_maxlist dd ?
182
RTF_maxlist dd ?
183
;
183
;
184
; %%Function: ecParseRtfKeyword
184
; %%Function: ecParseRtfKeyword
185
;
185
;
186
; Step 2:
186
; Step 2:
187
; get a control word (and its associated value) and
187
; get a control word (and its associated value) and
188
; call ecTranslateKeyword to dispatch the control.
188
; call ecTranslateKeyword to dispatch the control.
189
;
189
;
190
 
190
 
191
ecParseRtfKeyword:
191
ecParseRtfKeyword:
192
; ch-al,bl-fParam, bh-fNeg
192
; ch-al,bl-fParam, bh-fNeg
193
    mov  [ris],risNorm
193
    mov  [ris],risNorm
194
    xor  eax,eax
194
    xor  eax,eax
195
    xor  ebx,ebx
195
    xor  ebx,ebx
196
    push edx
196
    push edx
197
    mov  [szKeyword],al
197
    mov  [szKeyword],al
198
    mov  [szParameter],al
198
    mov  [szParameter],al
199
    lods_block
199
    lods_block
200
    isalpha al,.ctrl
200
    isalpha al,.ctrl
201
    jmp  .alph
201
    jmp  .alph
202
  .ctrl:
202
  .ctrl:
203
    push esi
203
    push esi
204
    mov  esi,szKeyword
204
    mov  esi,szKeyword
205
    inc  byte[esi]
205
    inc  byte[esi]
206
    mov  [esi+1],al
206
    mov  [esi+1],al
207
    mov  eax,ebx
207
    mov  eax,ebx
208
    xor  ebx,ebx
208
    xor  ebx,ebx
209
    call ecTranslateKeyword
209
    call ecTranslateKeyword
210
    pop  esi
210
    pop  esi
211
    jmp  .__ex
211
    jmp  .__ex
212
  .alph:
212
  .alph:
213
    push edi
213
    push edi
214
    mov  edi,szKeyword+1
214
    mov  edi,szKeyword+1
215
  .loop1:
215
  .loop1:
216
    stosb
216
    stosb
217
    inc  [szKeyword]
217
    inc  [szKeyword]
218
    lods_block
218
    lods_block
219
    isalpha al,.outloop1
219
    isalpha al,.outloop1
220
    jmp  .loop1
220
    jmp  .loop1
221
  .outloop1:
221
  .outloop1:
222
    pop  edi
222
    pop  edi
223
    cmp  al,'-'
223
    cmp  al,'-'
224
    jne  .noneg
224
    jne  .noneg
225
    not  bh
225
    not  bh
226
    lods_block
226
    lods_block
227
  .noneg:
227
  .noneg:
228
    isdigit al,.nodig
228
    isdigit al,.nodig
229
    not  bl
229
    not  bl
230
    push edi
230
    push edi
231
    mov  edi,szParameter+1
231
    mov  edi,szParameter+1
232
  .loop2:
232
  .loop2:
233
    stosb
233
    stosb
234
    inc  [szParameter]
234
    inc  [szParameter]
235
    lods_block
235
    lods_block
236
    isdigit al,.outloop2
236
    isdigit al,.outloop2
237
    jmp  .loop2
237
    jmp  .loop2
238
  .outloop2:
238
  .outloop2:
239
    pop  edi
239
    pop  edi
240
    push eax esi
240
    push eax esi
241
    mov  esi,szParameter
241
    mov  esi,szParameter
242
    atoi
242
    atoi
243
    pop  esi
243
    pop  esi
244
    mov  edx,eax
244
    mov  edx,eax
245
    pop  eax
245
    pop  eax
246
    mov  [lParam],edx
246
    mov  [lParam],edx
247
    test bh,bh
247
    test bh,bh
248
    jz   .nodig
248
    jz   .nodig
249
    neg  edx
249
    neg  edx
250
  .nodig:
250
  .nodig:
251
    cmp  al,' '
251
    cmp  al,' '
252
    je   .space
252
    je   .space
253
    cmp  esi,I_END
253
    cmp  esi,I_END
254
    jne  .ok_block
254
    jne  .ok_block
255
    dec  [cur_block]
255
    dec  [cur_block]
256
    call read_block
256
    call read_block
257
    mov  esi,[block_end]
257
    mov  esi,[block_end]
258
  .ok_block:
258
  .ok_block:
259
    dec  esi
259
    dec  esi
260
  .space:
260
  .space:
261
    mov eax,ebx
261
    mov eax,ebx
262
    mov ebx,edx
262
    mov ebx,edx
263
    push esi
263
    push esi
264
    mov  esi,szKeyword
264
    mov  esi,szKeyword
265
    call ecTranslateKeyword
265
    call ecTranslateKeyword
266
    pop  esi
266
    pop  esi
267
  .__ex:
267
  .__ex:
268
    pop  edx
268
    pop  edx
269
    ret
269
    ret
270
 
270
 
271
;
271
;
272
; %%Function: ecParseChar
272
; %%Function: ecParseChar
273
;
273
;
274
; Route the character to the appropriate destination stream.
274
; Route the character to the appropriate destination stream.
275
;
275
;
276
 
276
 
277
ecParseChar:
277
ecParseChar:
278
;in: ch-al, esi->rtf
278
;in: ch-al, esi->rtf
279
   cmp  [ris],risBin
279
   cmp  [ris],risBin
280
   jne  .nobin
280
   jne  .nobin
281
   dec  [cbBin]
281
   dec  [cbBin]
282
   cmp  [cbBin],0
282
   cmp  [cbBin],0
283
   jg   .nobin
283
   jg   .nobin
284
   mov  [ris],risNorm
284
   mov  [ris],risNorm
285
 .nobin:
285
 .nobin:
286
   cmp  [rds],rdsColor
286
   cmp  [rds],rdsColor
287
   jne  .nodelim
287
   jne  .nodelim
288
   cmp  al,';'
288
   cmp  al,';'
289
   jne  .non
289
   jne  .non
290
   mov  eax,[colorptr]
290
   mov  eax,[colorptr]
291
   cmp  eax,ct_end-4
291
   cmp  eax,ct_end-4
292
   jae  .non
292
   jae  .non
293
   add  [colorptr],4
293
   add  [colorptr],4
294
   jmp  .non
294
   jmp  .non
295
 .nodelim:
295
 .nodelim:
296
   cmp  [rds],rdsSkip
296
   cmp  [rds],rdsSkip
297
   je  .non
297
   je  .non
298
   cmp  [rds],rdsNorm
298
   cmp  [rds],rdsNorm
299
   je   ecPrintChar
299
   je   ecPrintChar
300
;   ret
300
;   ret
301
 .non:
301
 .non:
302
   mov  eax,ecOK
302
   mov  eax,ecOK
303
   ret
303
   ret
304
 
304
 
305
macro PrintTrap _char
305
macro PrintTrap _char
306
{
306
{
307
local .notrap
307
local .notrap
308
    cmp  byte[esi],_char
308
    cmp  byte[esi],_char
309
    jne  .notrap
309
    jne  .notrap
310
    sub  esi,I_END
310
    sub  esi,I_END
311
    dps  'Trapped at '
311
    dps  'Trapped at '
312
    dpd  esi
312
    dpd  esi
313
    dps  <13,10>
313
    dps  <13,10>
314
    ud2
314
    ud2
315
  .notrap:
315
  .notrap:
316
}
316
}
317
;
317
;
318
; %%Function: ecPrintChar
318
; %%Function: ecPrintChar
319
;
319
;
320
; Send a character to the output file.
320
; Send a character to the output file.
321
;
321
;
322
 
322
 
323
ecPrintChar:
323
ecPrintChar:
324
; in:ch-al, esi - rtf pointer
324
; in:ch-al, esi - rtf pointer
325
;    stosb
325
;    stosb
326
;    jmp  .nowrap
326
;    jmp  .nowrap
327
    mov  ebp,[mode]
327
    mov  ebp,[mode]
328
    cmp  al,0xa
328
    cmp  al,0xa
329
    jne   .nopar
329
    jne   .nopar
330
;    and  ebp,not RTF_NO1STLINE
330
;    and  ebp,not RTF_NO1STLINE
331
    and  [mode],not RTF_NO1STLINE
331
    and  [mode],not RTF_NO1STLINE
332
    jmp  .par
332
    jmp  .par
333
  .nopar:
333
  .nopar:
334
    cmp  al,0x9
334
    cmp  al,0x9
335
    jne  .notab
335
    jne  .notab
336
    add  word[Free+6],CHARW*3
336
    add  word[Free+6],CHARW*3
337
    jmp  .chkwrap
337
    jmp  .chkwrap
338
  .notab:
338
  .notab:
339
    xor  ebx,ebx
339
    xor  ebx,ebx
340
  if ~ RENDER eq FREE
340
  if ~ RENDER eq FREE
341
    cmp  word[Free+4],TOP
341
    cmp  word[Free+4],TOP
342
    jl   .nodraw
342
    jl   .nodraw
343
  end if
343
  end if
344
    ansi2oem
344
    ansi2oem
345
    mov  [char],al
345
    mov  [char],al
346
;    PrintTrap '/'
346
;    PrintTrap '/'
347
    pusha
347
    pusha
348
    xor   eax,eax
348
    xor   eax,eax
349
;    test  [mode],RTF_BLIND
349
;    test  [mode],RTF_BLIND
350
    test  ebp,RTF_BLIND
350
    test  ebp,RTF_BLIND
351
    je   .rend
351
    je   .rend
352
;    test  [mode],RTF_COLORLESS
352
;    test  [mode],RTF_COLORLESS
353
    test  ebp,RTF_COLORLESS
353
    test  ebp,RTF_COLORLESS
354
    jz    .setcolor
354
    jz    .setcolor
355
    mov   ecx,DEFCOLOR
355
    mov   ecx,DEFCOLOR
356
    jmp   .rend
356
    jmp   .rend
357
  .setcolor:
357
  .setcolor:
358
    movzx ecx,byte[Chp+3]
358
    movzx ecx,byte[Chp+3]
359
    mov   ecx,[colortbl+ecx*4]
359
    mov   ecx,[colortbl+ecx*4]
360
  .rend:
360
  .rend:
361
  if RENDER eq FREE
361
  if RENDER eq FREE
362
    mov   ebx,Free
362
    mov   ebx,Free
363
    mov   dword[ebx+32],eax
363
    mov   dword[ebx+32],eax
364
    mov   [ebx+28],ecx
364
    mov   [ebx+28],ecx
365
;    test  [mode], RTF_BOTTOM
365
;    test  [mode], RTF_BOTTOM
366
    test  ebp, RTF_BOTTOM
366
    test  ebp, RTF_BOTTOM
367
    jne   .nodraw2
367
    jne   .nodraw2
368
    cmp  word[Free+4],TOP
368
    cmp  word[Free+4],TOP
369
    jl   .nodraw2
369
    jl   .nodraw2
370
    cmp   byte[Chp],fTrue
370
    cmp   byte[Chp],fTrue
371
    jne   .nobold
371
    jne   .nobold
372
    or    dword[ebx+32],BGI_BOLD
372
    or    dword[ebx+32],BGI_BOLD
373
  .nobold:
373
  .nobold:
374
;    test  [mode], RTF_BLIND
374
;    test  [mode], RTF_BLIND
375
    test  ebp, RTF_BLIND
375
    test  ebp, RTF_BLIND
376
    jne   .freet
376
    jne   .freet
377
  .nodraw2:
377
  .nodraw2:
378
    or    dword[ebx+32],BGI_NODRAW
378
    or    dword[ebx+32],BGI_NODRAW
379
  .freet:
379
  .freet:
380
    BGIfont_Freetext
380
    BGIfont_Freetext
381
 
381
 
382
    mov  [Free+4],eax
382
    mov  [Free+4],eax
383
    test [mode],RTF_BLIND
383
    test [mode],RTF_BLIND
384
;    jmp  .nohei
384
;    jmp  .nohei
385
    jne  .nohei
385
    jne  .nohei
386
    fild word[BGIheight]
386
    fild word[BGIheight]
387
    fmul dword[Free+12]
387
    fmul dword[Free+12]
388
;    fistp word[curheight]
388
;    fistp word[curheight]
389
    fistp word[maxheight]
389
    fistp word[maxheight]
390
;    movzx eax,[curheight]
390
;    movzx eax,[curheight]
391
;    dpd  eax
391
;    dpd  eax
392
;    cmp  ax,[maxheight]
392
;    cmp  ax,[maxheight]
393
;    jae  .nohei
393
;    jae  .nohei
394
;    mov  [maxheight],ax
394
;    mov  [maxheight],ax
395
;    dps 'M'
395
;    dps 'M'
396
;    dpd  eax
396
;    dpd  eax
397
 
397
 
398
;    dps <13,10>
398
;    dps <13,10>
399
  .nohei:
399
  .nohei:
400
  else
400
  else
401
    and   ecx,0xffffff
401
    and   ecx,0xffffff
402
    mov   ebx,[Free+4]
402
    mov   ebx,[Free+4]
403
    mov   edx,char
403
    mov   edx,char
404
    mov   esi,1
404
    mov   esi,1
405
  end if
405
  end if
406
 
406
 
407
  if RENDER eq BGI
407
  if RENDER eq BGI
408
    add   ecx,0x44000000
408
    add   ecx,0x44000000
409
    cmp   byte[Chp],fTrue
409
    cmp   byte[Chp],fTrue
410
    jne   .nobold
410
    jne   .nobold
411
    or    esi,BGI_BOLD
411
    or    esi,BGI_BOLD
412
  .nobold:
412
  .nobold:
413
    test  ebp,RTF_BLIND
413
    test  ebp,RTF_BLIND
414
;    test  [mode],RTF_BLIND
414
;    test  [mode],RTF_BLIND
415
    jne    .freet
415
    jne    .freet
416
    or    esi,BGI_NODRAW
416
    or    esi,BGI_NODRAW
417
  .freet:
417
  .freet:
418
    BGIfont_Outtext
418
    BGIfont_Outtext
419
    mov   [Free+4],eax
419
    mov   [Free+4],eax
420
  end if
420
  end if
421
 
421
 
422
  if RENDER eq PIX
422
  if RENDER eq PIX
423
;    test  [mode],RTF_TOEOF
423
;    test  [mode],RTF_TOEOF
424
;    jne   .blind
424
;    jne   .blind
425
;    test  [mode],RTF_BOTTOM
425
;    test  [mode],RTF_BOTTOM
426
    test  ebp,RTF_BOTTOM
426
    test  ebp,RTF_BOTTOM
427
    jne   .nobold
427
    jne   .nobold
428
  .blind:
428
  .blind:
429
;    test  [mode],RTF_BLIND
429
;    test  [mode],RTF_BLIND
430
    test  ebp,RTF_BLIND
430
    test  ebp,RTF_BLIND
431
    je    .nobold
431
    je    .nobold
432
    mcall 4
432
    mcall 4
433
    cmp   byte[Chp],fTrue
433
    cmp   byte[Chp],fTrue
434
    jne   .nobold
434
    jne   .nobold
435
    add   ebx,1 shl 16
435
    add   ebx,1 shl 16
436
    mcall
436
    mcall
437
  .nobold:
437
  .nobold:
438
  end if
438
  end if
439
    popa
439
    popa
440
  .nodraw:
440
  .nodraw:
441
  if  RENDER eq PIX
441
  if  RENDER eq PIX
442
    add  word[Free+6],CHARW
442
    add  word[Free+6],CHARW
443
  end if
443
  end if
444
    movsx eax,[pitch]
444
    movsx eax,[pitch]
445
    add  word[Free+6],ax
445
    add  word[Free+6],ax
446
  .chkwrap:
446
  .chkwrap:
447
    mov  eax,dword[prcinfo+42]
447
    mov  eax,dword[prcinfo+42]
448
    cmp  ax,word[Free+6]
448
    cmp  ax,word[Free+6]
449
    ja   .nowrap
449
    ja   .nowrap
450
;    or   ebp,RTF_NO1STLINE
450
;    or   ebp,RTF_NO1STLINE
451
    or   [mode],RTF_NO1STLINE
451
    or   [mode],RTF_NO1STLINE
452
  .par:
452
  .par:
453
    xor  [mode],RTF_BLIND
453
    xor  [mode],RTF_BLIND
454
;    not  [blind]
454
;    not  [blind]
455
    test [mode] ,RTF_BLIND
455
    test [mode] ,RTF_BLIND
456
    je   .makewrap
456
    je   .makewrap
457
    ; [blind]=false
457
    ; [blind]=false
458
    movzx eax,word[Free+6]
458
    movzx eax,word[Free+6]
459
    sub  ax,word[RetroXY+2]
459
    sub  ax,word[RetroXY+2]
460
    push dword[RetroXY]
460
    push dword[RetroXY]
461
    pop  dword[Free+4]
461
    pop  dword[Free+4]
462
    mov  [mark],0xff0000
462
    mov  [mark],0xff0000
463
    test [mode],RTF_ALIGNLESS
463
    test [mode],RTF_ALIGNLESS
464
    jnz  .letsdraw
464
    jnz  .letsdraw
465
    cmp  byte[Pap+12],justR
465
    cmp  byte[Pap+12],justR
466
    jb   .letsdraw
466
    jb   .letsdraw
467
    mov  [mark],0xff
467
    mov  [mark],0xff
468
    mov  ebx,dword[prcinfo+42] ; wnd width
468
    mov  ebx,dword[prcinfo+42] ; wnd width
469
    sub  ebx,eax
469
    sub  ebx,eax
470
    cmp  byte[Pap+12],justC
470
    cmp  byte[Pap+12],justC
471
    jne  .nocenter
471
    jne  .nocenter
472
    shr  ebx,1
472
    shr  ebx,1
473
    mov  [mark],0x00ff00
473
    mov  [mark],0x00ff00
474
  .nocenter:
474
  .nocenter:
475
    mov  word[Free+6],bx
475
    mov  word[Free+6],bx
476
  .letsdraw:
476
  .letsdraw:
477
;    test [mode],RTF_NO1STLINE
477
;    test [mode],RTF_NO1STLINE
478
;    jnz  .no1st
478
;    jnz  .no1st
479
;    add  word[Free+6],60
479
;    add  word[Free+6],60
480
  .no1st:
480
  .no1st:
481
  if STEPBYSTEP eq 1
481
  if STEPBYSTEP eq 1
482
;    movzx eax,[mode]
482
;    movzx eax,[mode]
483
;    dph  eax
483
;    dph  eax
484
;    test [mode],RTF_NO1STLINE
484
;    test [mode],RTF_NO1STLINE
485
;    jnz  .no1st
485
;    jnz  .no1st
486
;    mcall 4,[RetroXY],[mark],sym,1
486
;    mcall 4,[RetroXY],[mark],sym,1
487
;    dps  '1st '
487
;    dps  '1st '
488
;  .no1st:
488
;  .no1st:
489
    dps  <'false ',13,10>
489
    dps  <'false ',13,10>
490
;    dpd  eax
490
;    dpd  eax
491
;    dpd  ebx
491
;    dpd  ebx
492
  end if
492
  end if
493
  if SHOWALIGN eq 1
493
  if SHOWALIGN eq 1
494
    mcall 4,[RetroXY],[mark],sym,1
494
    mcall 4,[RetroXY],[mark],sym,1
495
  end if
495
  end if
496
  if STEPBYSTEP eq 1
496
  if STEPBYSTEP eq 1
497
    mcall 10
497
    mcall 10
498
    mcall 2
498
    mcall 2
499
  end if
499
  end if
500
    mov  eax,[RetroBlock]
500
    mov  eax,[RetroBlock]
501
    cmp  eax,[cur_block]
501
    cmp  eax,[cur_block]
502
    je   .norblock
502
    je   .norblock
503
    mov  [cur_block],eax
503
    mov  [cur_block],eax
504
    call read_block
504
    call read_block
505
  .norblock:
505
  .norblock:
506
    mov  esi,[RetroPtr]
506
    mov  esi,[RetroPtr]
507
    push [RetroGroup]
507
    push [RetroGroup]
508
    pop  [cGroup]
508
    pop  [cGroup]
509
    CopySave RetroSave,Chp
509
    CopySave RetroSave,Chp
510
    jmp  .nowrap
510
    jmp  .nowrap
511
  .makewrap:       ; second pass preparing
511
  .makewrap:       ; second pass preparing
512
    ; [blind]=true
512
    ; [blind]=true
513
  if STEPBYSTEP eq 1
513
  if STEPBYSTEP eq 1
514
    dps  'true '
514
    dps  'true '
515
    mcall 10
515
    mcall 10
516
    mcall 2
516
    mcall 2
517
  end if
517
  end if
518
    mov  word[Free+6],LMARGIN
518
    mov  word[Free+6],LMARGIN
519
  if RENDER eq FREE
519
  if RENDER eq FREE
520
    fld [line_space]
520
    fld [line_space]
521
    fimul [maxheight]
521
    fimul [maxheight]
522
    fistp [maxheight]
522
    fistp [maxheight]
523
    movzx eax,[maxheight]
523
    movzx eax,[maxheight]
524
    add  word[Free+4],ax
524
    add  word[Free+4],ax
525
;    and  [maxheight],0
525
;    and  [maxheight],0
526
;    add  word[Free+4],CHARH
526
;    add  word[Free+4],CHARH
527
  else
527
  else
528
    mov  eax,CHARH
528
    mov  eax,CHARH
529
    add  word[Free+4],ax
529
    add  word[Free+4],ax
530
  end if
530
  end if
531
    test [mode],RTF_TOEOF
531
    test [mode],RTF_TOEOF
532
    je   .nohdoc
532
    je   .nohdoc
533
    add  [HDoc],eax
533
    add  [HDoc],eax
534
    inc  [line_count]
534
    inc  [line_count]
535
  .nohdoc:
535
  .nohdoc:
536
    test [mode],RTF_BOTTOM
536
    test [mode],RTF_BOTTOM
537
    jne  .text
537
    jne  .text
538
;    dps  '1'
538
;    dps  '1'
539
    mov  ebx,dword[prcinfo+46]
539
    mov  ebx,dword[prcinfo+46]
540
    cmp  bx,word[Free+4]
540
    cmp  bx,word[Free+4]
541
    jge   .text
541
    jge   .text
542
    or   [mode],RTF_BOTTOM
542
    or   [mode],RTF_BOTTOM
543
    dps  <'btm',13,10>
543
    dps  <'btm',13,10>
544
    test [mode],RTF_TOEOF
544
    test [mode],RTF_TOEOF
545
    jne  .text
545
    jne  .text
546
    mov  eax,ecOutOfWindow
546
    mov  eax,ecOutOfWindow
547
    ret
547
    ret
548
;  end if
548
;  end if
549
  .text:
549
  .text:
550
    push dword[Free+4]
550
    push dword[Free+4]
551
    pop  dword[RetroXY]
551
    pop  dword[RetroXY]
552
    mov  word[RetroXY+2],LMARGIN
552
    mov  word[RetroXY+2],LMARGIN
553
    mov  [RetroPtr],esi
553
    mov  [RetroPtr],esi
554
    push [cur_block]
554
    push [cur_block]
555
    pop  [RetroBlock]
555
    pop  [RetroBlock]
556
    CopySave Chp,RetroSave
556
    CopySave Chp,RetroSave
557
    push [cGroup]
557
    push [cGroup]
558
    pop  [RetroGroup]
558
    pop  [RetroGroup]
559
;  if STEPBYSTEP eq 1
559
;  if STEPBYSTEP eq 1
560
;    mcall 10
560
;    mcall 10
561
;    mcall 2
561
;    mcall 2
562
;  end if
562
;  end if
563
  .nowrap:
563
  .nowrap:
564
    mov  eax,ecOK
564
    mov  eax,ecOK
565
    ret
565
    ret
566
mark dd ?
566
mark dd ?
567
sym db 0x10
567
sym db 0x10
568
line_space dd 1.6
568
line_space dd 1.6
569
;
569
;
570
; %%Function: ecPushRtfState
570
; %%Function: ecPushRtfState
571
;
571
;
572
; Save relevant info on a linked list of SAVE structures.
572
; Save relevant info on a linked list of SAVE structures.
573
;
573
;
574
 
574
 
575
ecPushRtfState:
575
ecPushRtfState:
576
    pusha
576
    pusha
577
    mov  edi,[listptr]
577
    mov  edi,[listptr]
578
    mov  eax,edi
578
    mov  eax,edi
579
    mov  ecx,SIZE_save
579
    mov  ecx,SIZE_save
580
    add  eax,ecx
580
    add  eax,ecx
581
    cmp  eax,save_limit
581
    cmp  eax,save_limit
582
    jb   .malloc
582
    jb   .malloc
583
    Return ecStackOverflow
583
    Return ecStackOverflow
584
  .malloc:
584
  .malloc:
585
    mov  esi,Chp
585
    mov  esi,Chp
586
    rep  movsb
586
    rep  movsb
587
    mov  [listptr],edi
587
    mov  [listptr],edi
588
    mov  [ris],risNorm
588
    mov  [ris],risNorm
589
    inc  [cGroup]
589
    inc  [cGroup]
590
    xor  eax,eax
590
    xor  eax,eax
591
    Epilog
591
    Epilog
592
 
592
 
593
; %%Function: ecPopRtfState
593
; %%Function: ecPopRtfState
594
;
594
;
595
; If we're ending a destination (that is, the destination is changing),
595
; If we're ending a destination (that is, the destination is changing),
596
; call ecEndGroupAction.
596
; call ecEndGroupAction.
597
; Always restore relevant info from the top of the SAVE list.
597
; Always restore relevant info from the top of the SAVE list.
598
 
598
 
599
ecPopRtfState:
599
ecPopRtfState:
600
    pusha
600
    pusha
601
    mov  esi,[listptr]
601
    mov  esi,[listptr]
602
    cmp  esi,save_stack
602
    cmp  esi,save_stack
603
    ja  .okpop
603
    ja  .okpop
604
    Return ecStackUnderflow
604
    Return ecStackUnderflow
605
  .okpop:
605
  .okpop:
606
    movzx eax,[rds]
606
    movzx eax,[rds]
607
    cmp  al,[esi-2]
607
    cmp  al,[esi-2]
608
    je   .noega
608
    je   .noega
609
    RetError ecEndGroupAction, .noega
609
    RetError ecEndGroupAction, .noega
610
  .noega:
610
  .noega:
611
    mov  ecx,SIZE_save
611
    mov  ecx,SIZE_save
612
    sub  esi,ecx
612
    sub  esi,ecx
613
    mov  [listptr],esi
613
    mov  [listptr],esi
614
    mov  edi,Chp
614
    mov  edi,Chp
615
    rep  movsb
615
    rep  movsb
616
    dec  [cGroup]
616
    dec  [cGroup]
617
    xor  eax,eax
617
    xor  eax,eax
618
    Epilog
618
    Epilog
619
 
619
 
620
ansitbl:
620
ansitbl:
621
    db 0xaa,0xba,0xbf,0xaf
621
    db 0xaa,0xba,0xbf,0xaf
622
    db 0xa7,0xa8,0xa1,0xab,0xb0,0xb2,0xb3,0xb6,0xb7,0xb8,0xb9
622
    db 0xa7,0xa8,0xa1,0xab,0xb0,0xb2,0xb3,0xb6,0xb7,0xb8,0xb9
623
    db 0xa2,0xbb,0x93,0x94,0x85
623
    db 0xa2,0xbb,0x93,0x94,0x85
624
oematbl:
624
oematbl:
625
 if RENDER eq PIX
625
 if RENDER eq PIX
626
    db 0xf2,0xf3,0xf5,0xf4
626
    db 0xf2,0xf3,0xf5,0xf4
627
 else
627
 else
628
    db 0x85,0xa5,0x69,0x49
628
    db 0x85,0xa5,0x69,0x49
629
 end if
629
 end if
630
    db 0x15,0xf0,0xf6,0x22,0x1d,0x49,0x69,0x14,0x1c,0xf1,0x23
630
    db 0x15,0xf0,0xf6,0x22,0x1d,0x49,0x69,0x14,0x1c,0xf1,0x23
631
    db 0xf7,0x22,0x22,0x22,0x16
631
    db 0xf7,0x22,0x22,0x22,0x16
632
uctbl:
632
uctbl:
633
    dw 0x451
633
    dw 0x451
634
oemutbl:
634
oemutbl:
635
    db 0xb8
635
    db 0xb8