Subversion Repositories NedoOS

Rev

Rev 975 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
447 alone 1
STRINGBUFSZ=MAXLINKSZ ;512;256
31 Alone 2
 
3
;for text
4
stringbuf1header
5
TEXT_BASE
6
TEXT_NEXT=$-TEXT_BASE
7
        ds 3 ;next
8
TEXT_PREV=$-TEXT_BASE
9
        ds 3 ;prev
10
TEXT_Y=$-TEXT_BASE
11
        ds 2 ;y
12
TEXT_X=$-TEXT_BASE
13
        ds 1 ;x
32 Alone 14
TEXT_TEXT=$-TEXT_BASE
31 Alone 15
stringbuf1
16
        ds STRINGBUFSZ
447 alone 17
        db 0 ; 砩  STRINGBUFSZ
31 Alone 18
 
19
firstpointer
20
        dw 0
21
firstpointerHSB
22
        db 0
23
 
24
;for href
25
stringbuf2header
26
HREF_BASE
27
HREF_NEXT=$-HREF_BASE
28
        ds 3 ;next
29
HREF_PREV=$-HREF_BASE
30
        ds 3 ;prev
31
HREF_Y=$-HREF_BASE
32
        ds 2 ;y
33
HREF_X=$-HREF_BASE
34
        ds 1 ;x
35
HREF_ENDY=$-HREF_BASE
344 alone 36
        ds 2 ;endy (TODO ᫮  뫮 ࠧ    騬  뫮,  ࠧ묨 ﬨ ਨ)
31 Alone 37
HREF_ENDX=$-HREF_BASE
344 alone 38
        ds 1 ;endx (TODO ᫮  뫮 ࠧ    騬  뫮,  ࠧ묨 ﬨ ਨ)
31 Alone 39
HREF_VISITED=$-HREF_BASE
40
        ds 1 ;visited
32 Alone 41
HREF_TEXT=$-HREF_BASE
31 Alone 42
stringbuf2
43
        ds STRINGBUFSZ
447 alone 44
        db 0 ; 砩  STRINGBUFSZ
31 Alone 45
 
46
first2pointer
47
        dw 0
48
first2pointerHSB
49
        db 0
50
 
344 alone 51
;᫥  ९ STRINGBUFSZ!
31 Alone 52
printtostringbuf2
53
curstringbuf2addr=$+1
54
        ld hl,stringbuf2
104 alone 55
         push de
56
         ld de,stringbuf2+STRINGBUFSZ
57
         or a
58
         sbc hl,de
59
         add hl,de
60
         pop de
61
         ret nc
31 Alone 62
        ld (hl),a
63
        inc hl
64
        ld (curstringbuf2addr),hl
65
        ret
66
 
67
linklastpointer_next_ahl_setlastpointer
68
;if (not isnull(lastpointer)) lastpointer->next=addr else firstpointer=addr
69
;lastpointer = addr
70
        push af
71
        push hl
72
        ex af,af'
73
        ld b,h
74
        ld c,l
75
        ld hl,(lastpointer)
76
        ld a,(lastpointerHSB)
77
        call isnull
78
        jr z,linklastpointer_lastnull
79
        call writeword ;bc
80
        ex af,af'
55 Alone 81
         ;cp 0xff
82
         ;jr z,$
31 Alone 83
        ld c,a
55 Alone 84
        ex af,af'
31 Alone 85
        call writebyte ;c
86
        jr linklastpointer_lastnullq
87
linklastpointer_lastnull
55 Alone 88
        ex af,af'
31 Alone 89
        ld (firstpointer),bc
90
        ld (firstpointerHSB),a
91
linklastpointer_lastnullq
92
        pop hl
93
        pop af
94
        ld (lastpointer),hl
95
        ld (lastpointerHSB),a
96
        ret
97
 
98
linklast2pointer_next_ahl_setlast2pointer
99
;if (not isnull(last2pointer)) last2pointer->next=addr else first2pointer=addr
100
;last2pointer = addr
101
        push af
102
        push hl
103
        ex af,af'
104
        ld b,h
105
        ld c,l
106
        ld hl,(last2pointer)
107
        ld a,(last2pointerHSB)
108
        call isnull
109
        jr z,linklast2pointer_lastnull
110
        call writeword ;bc
111
        ex af,af'
112
        ld c,a
55 Alone 113
        ex af,af'
31 Alone 114
        call writebyte ;c
115
        jr linklast2pointer_lastnullq
116
linklast2pointer_lastnull
55 Alone 117
        ex af,af'
31 Alone 118
        ld (first2pointer),bc
119
        ld (first2pointerHSB),a
120
linklast2pointer_lastnullq
121
        pop hl
122
        pop af
123
        ld (last2pointer),hl
124
        ld (last2pointerHSB),a
125
        ret
126
 
127
savestringbuf1
128
;add terminator
129
;find size
130
;form header
131
;reservemem & put
132
;if (not isnull(lastpointer)) link lastpointer->next = addr
133
;lastpointer = addr
134
;initialize stringbuf1
135
        ld hl,(curstringbuf1addr)
136
        xor a
137
        ld (hl),a
138
        inc hl
139
        ld de,stringbuf1header
140
        ;or a
141
        sbc hl,de ;hl=size
142
        ld b,h
143
        ld c,l
144
 
145
;form header:
146
        ld hl,-1
147
        ld a,-1
148
        ld (stringbuf1header+TEXT_NEXT),hl
149
        ld (stringbuf1header+TEXT_NEXT+2),a
150
lastpointer=$+1
151
        ld hl,-1
152
lastpointerHSB=$+1
153
        ld a,-1
154
        ld (stringbuf1header+TEXT_PREV),hl
155
        ld (stringbuf1header+TEXT_PREV+2),a
156
laststringy=$+1
157
        ld hl,0
158
        ld (stringbuf1header+TEXT_Y),hl
159
laststringx=$+1
160
        ld a,0
161
        ld (stringbuf1header+TEXT_X),a
162
 
163
;if iscentered then TEXT_X = (textfieldwidth-textlength)/2
501 alone 164
;TODO FIX:  뫪  ⮩ ப ⮦  ᤢ  X!   㦥 ࠭!!!
31 Alone 165
iscentered=$+1
166
        ld a,0
167
        or a
168
        jr z,savestringbuf1_notcentered
169
        call countlinewidth ;hl
170
        ld a,80 ;TODO textfieldwidth
171
        sub l
172
        rra
173
        ld (stringbuf1header+TEXT_X),a
174
savestringbuf1_notcentered
175
 
176
        if 1==0
177
        push bc
178
        push de
179
        push hl
180
 
181
        ld hl,(stringbuf1header+TEXT_Y)
182
        ld bc,25
183
        or a
184
        sbc hl,bc
185
        add hl,bc
186
        jr nc,notest1
187
        ld a,l
188
        add a,a
189
        add a,a
190
        add a,a
191
        ld d,a
192
        ld a,(stringbuf1header+TEXT_X)
193
        ld e,a
194
        call setxymc_stateful
195
        ld hl,stringbuf1
196
test10
197
        ld a,(hl)
198
        or a
199
        jr z,notest1
200
        inc hl
201
        push hl
202
        ;halt
203
        call prcharmc_stateful
204
        pop hl
205
        jr test10
206
 
207
notest1
208
        pop hl
209
        pop de
210
        pop bc
211
        endif
212
 
213
        ex de,hl
214
;hl=from
215
;bc=size
216
;out: ahl=addr
217
        ;jr $
218
        call reservemem_puttomem
219
        call linklastpointer_next_ahl_setlastpointer        
220
initstringbuf1
221
        xor a
222
        ld (iscentered),a
223
        ;ld (ncharsinline),a
224
        ld hl,stringbuf1
225
        ld (curstringbuf1addr),hl
32 Alone 226
        jp setfontweight
31 Alone 227
 
228
savestringbuf2
229
;add terminator
230
;find size
231
;form header
232
;reservemem & put
233
;if (not isnull(lastpointer)) lastpointer->next=addr else firstpointer=addr
234
;lastpointer = addr
235
;initialize stringbuf2
236
        ld hl,(curstringbuf2addr)
447 alone 237
         ld de,stringbuf2
238
         or a
239
         sbc hl,de
240
         add hl,de
241
         ret z ;  ࠭塞,    ࢮ 뫪 ᫥ div???
31 Alone 242
        xor a
243
        ld (hl),a
244
        inc hl
245
        ld de,stringbuf2header
246
        ;or a
247
        sbc hl,de ;hl=size
248
        push hl ;size
249
 
250
;form header:
32 Alone 251
        ld a,(prcharvirtual_stateful_x)
31 Alone 252
        ld (stringbuf2header+HREF_ENDX),a
253
        ld hl,(curprintvirtualy)
254
        ld (stringbuf2header+HREF_ENDY),hl
255
        ld a,-1
32 Alone 256
        ld h,a
257
        ld l,a
31 Alone 258
        ld (stringbuf2header+HREF_NEXT),hl
259
        ld (stringbuf2header+HREF_NEXT+2),a
260
last2pointer=$+1
261
        ld hl,-1
262
last2pointerHSB=$+1
263
        ld a,-1
264
        ld (stringbuf2header+HREF_PREV),hl
265
        ld (stringbuf2header+HREF_PREV+2),a
266
hrefyposition=$+1
267
        ld hl,0
268
        ld (stringbuf2header+HREF_Y),hl
269
hrefxposition=$+1
270
        ld a,0
271
        ld (stringbuf2header+HREF_X),a
272
        xor a
273
        ld (stringbuf2header+HREF_VISITED),a ;TODO check history
274
        ;jr $
275
 
276
        if 1==0
277
        push de
278
        push hl
279
 
280
        ld hl,(stringbuf2header+HREF_Y)
281
        ld bc,25
282
        or a
283
        sbc hl,bc
284
        add hl,bc
285
        jr nc,notest
286
        ld a,l
287
        add a,a
288
        add a,a
289
        add a,a
290
        ld d,a
291
        ld a,(stringbuf2header+HREF_X)
292
        ld e,a
293
        call setxymc_stateful
294
        ld a,'@'
295
        call prcharmc_stateful        
296
 
297
notest
298
        pop hl
299
        pop de
300
        endif
301
 
302
        ex de,hl
303
        pop bc ;size
304
;hl=from
305
;bc=size
306
;out: ahl=addr
307
        ;jr $
308
        call reservemem_puttomem
309
        call linklast2pointer_next_ahl_setlast2pointer
310
initstringbuf2
311
        ld hl,stringbuf2
312
        ld (curstringbuf2addr),hl
313
        ret
314
 
32 Alone 315
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;        
316
 
317
setdefaultfontweight
318
        xor a
319
        ld (curbold),a
320
        ld (curlink),a
68 Alone 321
        ld (curlinkimg),a
322
        ld (curmark),a
32 Alone 323
        ld (curitalic),a
324
        ld (curunderline),a
325
        ld (curstroke),a
326
        ret
327
 
328
setfontweight
329
        ld a,(printableflag)
330
        or a
331
        ret z
332
         ld a,1
333
         call prcharvirtual_stateful
334
curbold=$+1
335
        ld a,0
336
curlink=$+1
337
        or 0
68 Alone 338
curlinkimg=$+1
339
        or 0
32 Alone 340
curmark=$+1
341
        or 0
342
        inc a
343
        call prcharvirtual_stateful
344
         ld a,2
345
         call prcharvirtual_stateful
346
curitalic=$+1
347
        ld a,0
348
        inc a
349
        call prcharvirtual_stateful
350
         ld a,3
351
         call prcharvirtual_stateful
352
curstroke=$+1
353
        ld a,0
354
        inc a
355
        call prcharvirtual_stateful
356
         ld a,4
357
         call prcharvirtual_stateful
358
curunderline=$+1
359
        ld a,0
360
        inc a
361
        jp prcharvirtual_stateful
362
 
31 Alone 363
prcharvirtual_tab_stateful
364
        ld a,(prcharvirtual_stateful_x)
365
        and 7 ;0..7
366
        cpl ;-1..-8
367
        add a,9
368
        ld b,a ;8..1
369
prcharvirtual_tab_stateful0
370
        push bc
371
        ld a,' '
372
        call prcharvirtual_stateful
373
        pop bc
374
        djnz prcharvirtual_tab_stateful0
375
        ret
376
 
32 Alone 377
prcharvirtual_controlcode
378
        cp 0x09 ;tab
379
        jr z,prcharvirtual_tab_stateful
380
        cp 0x0a ;LF
975 dimkam 381
        jp z,prcharvirtual_crlf_stateful
32 Alone 382
        cp 0x0d ;CR
383
        ret z
384
        jr prcharvirtual_stateful_nocontrolcode
385
 
31 Alone 386
prcharvirtual_stateful
387
;a=code
32 Alone 388
printableflag=$+1
389
        ld l,0
390
        dec l
391
        ret nz
392
        cp 32
393
        jr c,prcharvirtual_controlcode
394
prcharvirtual_stateful_nocontrolcode
31 Alone 395
        push af
396
         cp 0x80
397
         jr c,prcharvirtual_noutf8
398
utf8flag=$+1
399
         ld l,0
400
         dec l
401
         jr nz,prcharvirtual_noutf8
402
         sub 0xd0
403
         jr z,prcharvirtual_utf8_d0
404
         cp 1
405
         jr z,prcharvirtual_utf8_d0
344 alone 406
         cp 0xe2-0xd0 ;dash = e2 80 94 ( 80 ᯮ  "" = d1 80)
32 Alone 407
         jr z,prcharvirtual_utf8_e2
408
         cp 0xc2-0xd0 ;bullet = c2 b7
409
         jr z,prcharvirtual_utf8_c2
410
         ;sub 0x80
31 Alone 411
prcharvirtual_utf8_add=$+1
412
        add a,0x00
32 Alone 413
        ;add a,0x80
414
         cp 0x01
415
         jr z,prcharvirtual_utf8_yo
416
         cp 0x20
417
         jr nc,prcharvirtual_noutf8
418
         pop af
419
         ret
420
prcharvirtual_utf8_yo
344 alone 421
         ld a,0xb8;''
31 Alone 422
        jr prcharvirtual_noutf8
32 Alone 423
prcharvirtual_utf8_c2
424
        ld a,0xb7-0xb7+0xd0
425
        ld (prcharvirtual_utf8_add),a
426
        pop af
427
        ret
428
prcharvirtual_utf8_e2
429
        ld a,'-'-0x94+0xd0
430
        ld (prcharvirtual_utf8_add),a
431
        pop af
432
        ret
31 Alone 433
prcharvirtual_utf8_d0
434
        add a,a
435
        add a,a
436
        add a,a
437
        add a,a
438
        add a,a
439
        add a,a
440
        ld (prcharvirtual_utf8_add),a
441
        pop af
442
        ret
443
prcharvirtual_noutf8
444
        ld h,twinto866/256
445
        ld l,a
446
        ld a,(hl)
975 dimkam 447
        ;call printtostringbuf1        
448
 
449
        ;᫥  ९ STRINGBUFSZ!
450
;printtostringbuf1
451
curstringbuf1addr=$+1
452
        ld hl,stringbuf1
453
        push de
454
        ld de,stringbuf1+STRINGBUFSZ
455
        or a
456
        sbc hl,de
457
        add hl,de
458
        pop de
459
        jr nc,.over_full
460
        cp ' '
461
        jr nz,.no_space
462
.last_char=$+1
463
        cp ' '
464
        jr nz,.no_space
31 Alone 465
        pop af
975 dimkam 466
        ret
467
.no_space
468
        ld (.last_char),a
469
        ld (last_crlf_flag),a
470
        ld (hl),a
471
        inc hl
472
        ld (curstringbuf1addr),hl        
473
 
474
.over_full
475
        pop af
31 Alone 476
        cp 32
477
        ret c
975 dimkam 478
        display "prcharvirtual_stateful_x ",prcharvirtual_stateful_x
31 Alone 479
prcharvirtual_stateful_x=$+1
480
        ld a,0
481
        inc a
482
        ld (prcharvirtual_stateful_x),a
483
        cp 80
484
        ret c
485
prcharvirtual_crlf_stateful
32 Alone 486
        ld a,(printableflag)
487
        or a
488
        jr z,prcharvirtual_x0
974 dimkam 489
last_crlf_flag=$+1
490
        ld a,0  ;ய⨬ ⢥ ७
491
        or a
975 dimkam 492
        jr z,prcharvirtual_x0
31 Alone 493
        call savestringbuf1
494
curprintvirtualy=$+1
495
        ld hl,0
496
        inc hl
497
        ld (laststringy),hl
498
        ld (curprintvirtualy),hl
32 Alone 499
prcharvirtual_x0
500
        xor a
501
        ld (prcharvirtual_stateful_x),a
502
        ld (laststringx),a
974 dimkam 503
        ld (last_crlf_flag),a
31 Alone 504
        ret
505
 
506
countlinewidth
507
;out:hl
508
        ld a,(prcharvirtual_stateful_x)
509
        ld hl,laststringx
510
        sub (hl)
511
        ld l,a ;number of visible chars in line        
512
        ld h,0
513
        ret