Subversion Repositories NedoOS

Rev

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

Rev Author Line No. Line
1410 alone 1
hexeditor_XYTOP=0x0000 ;  - 
2
;hexeditor_HGT=txtscrhgt-1 ;  - 
3
hexeditor_WID=80 ;  - 
667 alone 4
hexeditor_MAXX=15
1410 alone 5
;hexeditor_PAGESIZE=16*hexeditor_HGT
8 dimkam 6
 
841 alone 7
       if PRSTDIO
667 alone 8
_hexeditor_CURSORCOLOR=0x0700;0x38
9
_hexeditor_COLOR=0x0007;7
841 alone 10
       else
11
_hexeditor_CURSORCOLOR=0x38
12
_hexeditor_COLOR=7
13
       endif
574 alone 14
 
667 alone 15
hexeditor_redrawloop
8 dimkam 16
        ;YIELDGETKEYLOOP
667 alone 17
        call hexeditor_prpage
18
hexeditor_mainloop
19
        call hexeditor_calccursorxy
20
        ld hl,_hexeditor_CURSORCOLOR
8 dimkam 21
        ld b,2
574 alone 22
        call drawfilecursor_sizeb_colorhl
667 alone 23
        call hexeditor_calctextcursorxy
841 alone 24
       if PRSTDIO
889 alone 25
        call nv_setxy ;keeps de,hl,ix
841 alone 26
       else
842 alone 27
        ld hl,_hexeditor_CURSORCOLOR
28
        ld b,1
29
        call drawfilecursor_sizeb_colorhl
841 alone 30
       endif
1167 alone 31
      if 0
667 alone 32
;hexeditor_yieldkeep
606 dimkam 33
        ld a,2
667 alone 34
hexeditor_yieldkeep
606 dimkam 35
        ld (hexeditor_wasnokey),a
667 alone 36
        YIELDKEEP
37
        ld a,55+128 ;"or a"
38
        ld (hexeditor_wasyield),a
1167 alone 39
      endif
667 alone 40
hexeditor_mainloop_nokey
1167 alone 41
      if 0
42
      else
43
        YIELD
44
      endif
841 alone 45
       if PRSTDIO
46
        GETKEY_
1167 alone 47
        jr nz,hexeditor_keyq
1168 alone 48
        ;GETKEY_
49
        ;jr nz,hexeditor_keyq
50
        ;GETKEY_
51
        ;jr nz,hexeditor_keyq ;event 뢠 3-ᨬ
841 alone 52
       else
53
        GET_KEY
54
        ld a,c ;keynolang
606 dimkam 55
        ;cp NOKEY
841 alone 56
         or a
1167 alone 57
        jr nz,hexeditor_keyq
841 alone 58
       endif
59
       if PRSTDIO
752 alone 60
       ld a,(stdindatacount)
61
       or a
62
       jr nz,hexeditor_mainloop;_nokey
841 alone 63
       endif
1167 alone 64
      if 0
606 dimkam 65
;᫨  ࠧ   ᮡ,  㥬    YIELD,  YIELDKEEP
66
hexeditor_wasnokey=$+1
67
        ld a,1
68
        dec a
667 alone 69
        jr nz,hexeditor_yieldkeep
70
;ᮢ  ⮫쪮  ⢨ ᮡ ᫥ YIELD
71
hexeditor_wasyield=$
72
        scf
849 alone 73
        jr nc,hexeditor_nopanel
1167 alone 74
      endif
849 alone 75
        call hexeditor_panel
76
       if PRSTDIO
77
        call hexeditor_calctextcursorxy
889 alone 78
        call nv_setxy ;keeps de,hl,ix
849 alone 79
       endif
1167 alone 80
      if 0
849 alone 81
hexeditor_nopanel
667 alone 82
        YIELD
83
        ld a,55 ;"scf"
84
        ld (hexeditor_wasyield),a
1167 alone 85
      endif
667 alone 86
        jr hexeditor_mainloop_nokey
87
hexeditor_keyq
606 dimkam 88
        ;push hl
89
        ;push bc
90
        ;push de
8 dimkam 91
        push af
667 alone 92
        call hexeditor_calccursorxy
93
        ld hl,_hexeditor_COLOR
8 dimkam 94
        ld b,2
574 alone 95
        call drawfilecursor_sizeb_colorhl
842 alone 96
       if PRSTDIO == 0
97
        call hexeditor_calctextcursorxy
98
        ld hl,_hexeditor_COLOR
99
        ld b,1
100
        call drawfilecursor_sizeb_colorhl
101
       endif
8 dimkam 102
        pop af
606 dimkam 103
        ;pop de
104
        ;pop bc
105
        ;pop hl
8 dimkam 106
        cp key_redraw
667 alone 107
        jr z,hexeditor_redrawloop
116 alone 108
        cp key_esc
8 dimkam 109
        ret z
116 alone 110
        cp key_tab
9 dimkam 111
        jp z,nvview_hexeditorq
667 alone 112
        ld hl,hexeditor_mainloop
8 dimkam 113
        push hl
116 alone 114
         cp key_up
667 alone 115
         jp z,hexeditor_up
116 alone 116
         cp key_down
667 alone 117
         jp z,hexeditor_down
116 alone 118
         cp key_pgup
667 alone 119
         jp z,hexeditor_pgup
116 alone 120
         cp key_pgdown
667 alone 121
         jp z,hexeditor_pgdown
116 alone 122
        ;cp key_home
667 alone 123
        ;jp z,hexeditor_home
116 alone 124
        ;cp key_sspgup;ext3
667 alone 125
        ;jp z,hexeditor_home
116 alone 126
        ;cp key_end
667 alone 127
        ;jp z,hexeditor_end
116 alone 128
        ;cp key_sspgdown;ext4
667 alone 129
        ;jp z,hexeditor_end
116 alone 130
        cp key_left
667 alone 131
        jp z,hexeditor_left
116 alone 132
        cp key_right
667 alone 133
        jp z,hexeditor_right
116 alone 134
         cp key_csenter
667 alone 135
         jp z,hexeditor_save
569 dimkam 136
         cp key_F2
667 alone 137
         jp z,hexeditor_save
8 dimkam 138
        cp '0'
139
        ret c
140
        cp '9'+1
667 alone 141
        jr c,hexeditor_symbol
8 dimkam 142
        cp 'a'
143
        ret c
144
        cp 'f'+1
667 alone 145
        ret nc ;jp c,hexeditor_symbol
146
        ;ret
147
hexeditor_symbol
8 dimkam 148
        push af
149
        call nvhex_calccuraddrline ;addr cur line
150
        ld de,(hexcuraddrxy)
151
        ld d,0
152
        add hl,de ;addrcurline + x(e)
153
        call ahl_to_pgaddr
154
        pop af
155
        ;0   a-10
156
        cp 'a'
667 alone 157
        jr nc,hexeditor_symbol_af
574 alone 158
        ld b,-0x30
667 alone 159
        jr hexeditor_symbol_pr
160
hexeditor_symbol_af        
574 alone 161
        ld b,-0x61+0x0a;0x56
667 alone 162
hexeditor_symbol_pr        
8 dimkam 163
        add a,b
164
 
667 alone 165
hexeditor_half=$
8 dimkam 166
        or a ;/scf
667 alone 167
        jr c,hexeditor_symbol_right
8 dimkam 168
        add a,a
169
        add a,a
170
        add a,a
171
        add a,a;a=XXXX0000
172
        xor (hl)
606 dimkam 173
        and 0xf0
8 dimkam 174
        xor (hl)
667 alone 175
        jr hexeditor_symbol_rightq
176
hexeditor_symbol_right
8 dimkam 177
        xor (hl)
574 alone 178
        and 0x0f
8 dimkam 179
        xor (hl)
667 alone 180
hexeditor_symbol_rightq
8 dimkam 181
        ld (hl),a
667 alone 182
        ld hl,hexeditor_half
8 dimkam 183
        ld a,(hl)
574 alone 184
        xor 0x80
8 dimkam 185
        ld (hl),a
849 alone 186
        call setchanged
187
        call nvhex_calccuraddrline ;ahl=addr cur line
8 dimkam 188
        ld de,(hexcuraddrxy)
189
        ld e,0
889 alone 190
        push af
191
        call nv_setxy ;keeps de,hl,ix
192
        pop af ;keep ahl!!!
667 alone 193
        jp hexeditor_prline
194
 
195
hexeditor_save
608 alone 196
        ;ld hl,fcb_filename
197
        ;ld de,fcb2_filename
198
        ;call copy_to_defcb_filename
199
        ;call nv_createfcb2 ;autopush nv_closefcb2
200
        ;ret nz ;error
201
        ld de,filenametext
202
        OS_CREATEHANDLE
203
        or a
8 dimkam 204
        ret nz ;error
608 alone 205
        ld a,b
206
        ld (curhandle),a
207
        ld de,(filesize)
208
        ld hl,(filesizeHSW)
8 dimkam 209
        ld a,0 ;page number
667 alone 210
hexeditor_save0
8 dimkam 211
;a=page number in table (0..)
212
;hlde=remaining size
213
        push af
214
        push de
215
        push hl
216
        call setpg32k
217
        ld a,d
608 alone 218
        and 0xc0
8 dimkam 219
        or h
220
        or l
221
        jr z,$+5 ;de=size
667 alone 222
         ld de,0x4000
8 dimkam 223
        ex de,hl ;hl=pg size
224
        push hl ;hl=pg size
225
        call cmd_savepage
226
        pop bc ;bc=pg size
227
        pop hl
228
        pop de
229
        ex de,hl
230
        or a
231
        sbc hl,bc
232
        ex de,hl
233
        jr nc,$+3
667 alone 234
         dec hl ;size = size-pgsize
8 dimkam 235
        ld a,h
236
        or l
237
        or d
238
        or e
667 alone 239
        jr z,hexeditor_save_popq
8 dimkam 240
        pop af
241
        inc a
667 alone 242
        jr hexeditor_save0
243
hexeditor_save_popq
608 alone 244
        call nv_closehandle
849 alone 245
        call setunchanged
8 dimkam 246
        pop af
247
        ret
667 alone 248
 
249
hexeditor_left
8 dimkam 250
        ld de,(hexcuraddrxy)
251
        ld a,e
252
        cp 0
253
        ret z
254
        dec e
255
        ld (hexcuraddrxy),de
256
        ret
667 alone 257
 
258
hexeditor_right
8 dimkam 259
        ld de,(hexcuraddrxy)
260
        ld a,e
667 alone 261
        cp hexeditor_MAXX
8 dimkam 262
        ret z
263
        inc e
264
        push de
265
        call nvhex_calccuraddrline ;ahl=lineaddr
266
        pop de
267
        push af
268
        ld a,e
269
        add a,l
270
        ld l,a
271
        pop af
272
        call iseof
273
        ret nc
274
        ld (hexcuraddrxy),de
275
        ret
667 alone 276
 
277
hexeditor_calccursorxy
8 dimkam 278
        ld de,(hexcuraddrxy)
279
        ld a,e
280
        add a,a
281
        add a,e
282
        add a,8
283
        ld e,a
284
        ret
667 alone 285
 
286
hexeditor_calctextcursorxy
230 alone 287
        ld de,(hexcuraddrxy)
288
        ld a,e
289
        add a,57
290
        ld e,a
849 alone 291
        ret ;no ret because panel is empty
667 alone 292
 
849 alone 293
hexeditor_panel=nvview_panel
294
        ;ret
667 alone 295
 
296
hexeditor_prpage
8 dimkam 297
        ld hl,(hexaddrline)
298
        ld a,(hexaddrlineHSB)
667 alone 299
        ld de,hexeditor_XYTOP
1410 alone 300
        ;ld b,hexeditor_HGT
301
        ld bc,(hexedhgt-1) ;b
667 alone 302
hexeditor_prpage0
8 dimkam 303
        push bc
304
        push de
305
        push af
889 alone 306
        call nv_setxy ;keeps de,hl,ix
8 dimkam 307
        pop af
667 alone 308
        call hexeditor_prline
8 dimkam 309
        pop de
310
        pop bc
311
        inc d
667 alone 312
        djnz hexeditor_prpage0
313
;hexeditor_setbottom
8 dimkam 314
        ;ld (hexaddrline),hl
315
        ;ld (hexaddrlineHSB),a
316
        ret
317
 
667 alone 318
hexeditor_prline
8 dimkam 319
;ahl =  addr line      
320
        push af
321
        push hl
667 alone 322
        push hl
8 dimkam 323
        call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
324
        ld hl,16
325
        call minhl_bc_tobc ;bc = min(16, max line size before eof) 
326
        pop hl
667 alone 327
        ;push bc
328
         ld de,thexedline
329
        call hexeditor_praddrline
8 dimkam 330
        call ahl_to_pgaddr
667 alone 331
         inc de      
332
        ;pop bc ;bc = min(16, max line size before eof)
333
 
334
         push bc
8 dimkam 335
        push hl
667 alone 336
        ld a,c
337
        or a
338
        jr z,hexeditor_prlhex0q
339
        ld b,a
340
hexeditor_prlhex0
341
         inc de
8 dimkam 342
        ld a,(hl)
667 alone 343
        rrca
344
        rrca
345
        rrca
346
        rrca
347
        or 0xf0
348
        daa
349
        add a,0xa0
350
        adc a,0x40
351
         ld (de),a
352
         inc de
353
        ld a,(hl)
354
        or 0xf0
355
        daa
356
        add a,0xa0
357
        adc a,0x40
358
         ld (de),a
359
         inc de
360
        inc  l
361
        djnz hexeditor_prlhex0
362
hexeditor_prlhex0q
363
        ld a,16
364
        sub c
365
        jp z,hexeditor_prlhex1q
366
        ld b,a
367
         ld a,' '
368
hexeditor_prlhex1
369
         inc de
370
         ld (de),a
371
         inc de
372
         ld (de),a
373
         inc de
374
        djnz hexeditor_prlhex1
375
hexeditor_prlhex1q
606 dimkam 376
 
8 dimkam 377
        pop hl
667 alone 378
         inc de
379
         inc de
380
        ld a,c
381
        or a
382
        jr z,hexeditor_prlsym0q
383
        ld b,a
384
hexeditor_prlsym0
8 dimkam 385
        ld a,(hl)
386
        cp 32
667 alone 387
        jr nc,$+4
388
          ld a,'.'
389
         ld (de),a
390
         inc de
391
        inc  l
392
        djnz hexeditor_prlsym0
393
hexeditor_prlsym0q
394
        ld a,16
395
        sub c
396
        jp z,hexeditor_prlsym1q
397
        ld b,a
398
         ld a,' '
399
hexeditor_prlsym1
400
         ld (de),a
401
         inc de
402
        djnz hexeditor_prlsym1
403
hexeditor_prlsym1q
404
         ld de,thexedline
405
         ld hl,80
406
         call sendchars
407
         pop bc ;bc=bytes shown in line
8 dimkam 408
        pop hl
409
        pop af
667 alone 410
        ;ld b,0
8 dimkam 411
        add hl,bc
412
        adc a,b
667 alone 413
        ret
8 dimkam 414
 
667 alone 415
hexeditor_praddrline
8 dimkam 416
;ahl = addr line
417
        push af
667 alone 418
        call hexeditor_prNN
8 dimkam 419
        ld a,h
667 alone 420
        call hexeditor_prNN      
8 dimkam 421
        ld a,l        
667 alone 422
        call hexeditor_prNN
8 dimkam 423
        pop af
424
        ret
667 alone 425
 
426
hexeditor_prNN
427
;#30 - 0,1,2..9 #41 - A,B,C,D,E,F #61 - a,b,c..
8 dimkam 428
;a=XX 
667 alone 429
        push af
8 dimkam 430
        rrca
431
        rrca
432
        rrca
433
        rrca
606 dimkam 434
        or 0xf0
435
        daa
436
        add a,0xa0
437
        adc a,0x40
667 alone 438
         ld (de),a
439
         inc de
8 dimkam 440
        pop af
667 alone 441
        or 0xf0
442
        daa
443
        add a,0xa0
444
        adc a,0x40
445
         ld (de),a
446
         inc de
8 dimkam 447
        ret
448
 
667 alone 449
thexedline
450
        db "000000: 00 00 00 00 00 00 00 00|00 00 00 00 00 00 00 00  ................       "
451
 
452
hexeditor_prevline
8 dimkam 453
;ahl =addr line  
667 alone 454
;out: ahl =addr line, NC=error      
455
        call isbof ;CY=0
456
        ret z ;NC
8 dimkam 457
        push bc
606 dimkam 458
        ld bc,0x0010
8 dimkam 459
        or a
460
        sbc hl,bc
461
        sbc a,b
462
        scf
463
        pop bc
667 alone 464
        ret ;CY
465
 
466
        if 1==0
467
hexeditor_nextline
8 dimkam 468
        call iseof
469
        ret nc
470
        push bc
606 dimkam 471
        ld bc,0x0010
8 dimkam 472
        add hl,bc
473
        adc a,b
474
        pop bc
667 alone 475
        ret
476
        endif
8 dimkam 477
 
667 alone 478
hexeditor_pgup
8 dimkam 479
        call nvhex_calccuraddrline
480
        ld de,(hexcuraddrxy)
667 alone 481
        ld c,a
8 dimkam 482
        ld a,d
483
        or a
667 alone 484
        ld a,c
485
        jr nz,hexeditor_pgupq
1410 alone 486
        ;ld b,hexeditor_HGT-1
487
        ld bc,(hexedhgt-1) ;b
488
        dec b
667 alone 489
hexeditor_pgup0
490
        push bc
491
        call hexeditor_prevline
492
        pop bc
493
        djnz hexeditor_pgup0
8 dimkam 494
        ld (hexaddrline),hl
495
        ld (hexaddrlineHSB),a
667 alone 496
        call hexeditor_prpage
497
        jp clear_keyboardbuffer
498
hexeditor_pgupq
499
        ld d,0
500
        ld (hexcuraddrxy),de
8 dimkam 501
        ret
667 alone 502
 
503
hexeditor_pgdown
8 dimkam 504
        call nvhex_calccuraddrline
505
        ld de,(hexcuraddrxy)
506
        ld c,a
1410 alone 507
        ;ld a,hexeditor_HGT-1
508
        ld a,(hexedhgt)
509
        dec a
510
        cp d
8 dimkam 511
        ld a,c
667 alone 512
        jr z,hexeditor_pgdown_do
513
hexeditor_pgdown0
8 dimkam 514
        ld c,a
1410 alone 515
        ;ld a,hexeditor_HGT-1
516
        ld a,(hexedhgt)
517
        dec a
518
        cp d
8 dimkam 519
        ld a,c
667 alone 520
        jr z,hexeditor_pgdownq
8 dimkam 521
        call nvhex_calcnextcorrectxy
667 alone 522
        jr c,hexeditor_pgdown0
523
hexeditor_pgdownq
8 dimkam 524
        ld (hexcuraddrxy),de
525
        ret
667 alone 526
hexeditor_pgdown_do
8 dimkam 527
        ld (hexaddrline),hl
528
        ld (hexaddrlineHSB),a
529
        push de
667 alone 530
        call hexeditor_prpage
8 dimkam 531
        pop de
532
        ld hl,(hexaddrline)
533
        ld a,(hexaddrlineHSB)
534
        ld d,0
667 alone 535
hexeditor_pgdown_do0
8 dimkam 536
        ld c,a
1410 alone 537
        ;ld a,hexeditor_HGT-1
538
        ld a,(hexedhgt)
539
        dec a
540
        cp d
8 dimkam 541
        ld a,c
667 alone 542
        jr z,hexeditor_pgdown_doq
8 dimkam 543
        call nvhex_calcnextcorrectxy
667 alone 544
        jr c,hexeditor_pgdown_do0
545
hexeditor_pgdown_doq
8 dimkam 546
        ld (hexcuraddrxy),de
547
        jp clear_keyboardbuffer
548
 
667 alone 549
hexeditor_up
8 dimkam 550
        call nvhex_calccuraddrline
667 alone 551
        call hexeditor_prevline
552
        ret nc ;bof
8 dimkam 553
        ld de,(hexcuraddrxy)
554
        ld a,d
555
        or a
667 alone 556
        jr z,hexeditor_up_scroll
557
        dec d
558
        ld (hexcuraddrxy),de
559
        ret
560
hexeditor_up_scroll        
561
        ld de,hexeditor_XYTOP
1410 alone 562
        ;ld hl,256*hexeditor_HGT + hexeditor_WID
563
        ld hl,(hexedhgt-1) ;h
564
        ld l,hexeditor_WID
841 alone 565
       if PRSTDIO
566
        call scrolldown
567
       else
568
        OS_SCROLLDOWN
889 alone 569
       endif
841 alone 570
        ld de,hexeditor_XYTOP
889 alone 571
        call nv_setxy ;keeps de,hl,ix
667 alone 572
        ld hl,(hexaddrline)
573
        ld a,(hexaddrlineHSB)
574
        call hexeditor_prevline
8 dimkam 575
        ld (hexaddrline),hl
576
        ld (hexaddrlineHSB),a
667 alone 577
        jp hexeditor_prline
578
 
579
hexeditor_down
8 dimkam 580
        call nvhex_calccuraddrline
581
        ld de,(hexcuraddrxy)
582
        call nvhex_calcnextcorrectxy
583
        ret nc
584
        ld c,a
1410 alone 585
        ;ld a,hexeditor_HGT;-1
586
        ld a,(hexedhgt)
587
        ;dec a
588
        cp d
8 dimkam 589
        ld a,c
667 alone 590
        jr z,hexeditor_down_scroll
8 dimkam 591
        ld (hexcuraddrxy),de
592
        ret
667 alone 593
hexeditor_down_scroll
8 dimkam 594
        ;ld hl,(hexaddrline)
595
        ;ld a,(hexaddrlineHSB)
667 alone 596
        ;ld bc,hexeditor_PAGESIZE
8 dimkam 597
        ;add hl,bc
598
        ;adc a,0
599
        push af
600
        push hl
667 alone 601
        ld a,e
8 dimkam 602
        ld (hexcuraddrx),a
667 alone 603
        ld de,hexeditor_XYTOP
1410 alone 604
        ;ld hl,256*hexeditor_HGT + hexeditor_WID
605
        ld hl,(hexedhgt-1) ;h
606
        ld l,hexeditor_WID
607
       push de
608
       push hl
841 alone 609
       if PRSTDIO
610
        call scrollup
611
       else
612
        OS_SCROLLUP
889 alone 613
       endif
1410 alone 614
        ;ld de,hexeditor_XYTOP+((hexeditor_HGT-1)*256)
615
       pop hl
616
       pop de
617
        dec h
618
        ld l,0
619
        add hl,de
620
        ex de,hl ;de=hexeditor_XYTOP+((hexeditor_HGT-1)*256)
889 alone 621
        call nv_setxy ;keeps de,hl,ix
8 dimkam 622
        ld hl,(hexaddrline)
623
        ld a,(hexaddrlineHSB)
624
        ld bc,16
625
        add hl,bc
667 alone 626
        adc a,b;0
8 dimkam 627
        ld (hexaddrline),hl
628
        ld (hexaddrlineHSB),a
629
        pop hl
630
        pop af
667 alone 631
        jp hexeditor_prline
632
 
8 dimkam 633
nvhex_calccuraddrline
634
;out: ahl = addr cur line
635
        ld hl,(hexaddrline)
636
        ld a,(hexaddrlineHSB)
637
        ld de,(hexcuraddrxy)
638
        ld e,0
639
        srl d
640
        rr e
641
        srl d
642
        rr e
643
        srl d
644
        rr e
645
        srl d
646
        rr e
647
        add hl,de       ;hl+d*16
648
        adc a,0
649
        ret
650
 
651
nvhex_calcnextcorrectxy
652
;ahl=line addr, de=yx
653
;out:ahl=line addr, de=yx, NC=error
654
        ld bc,16
655
        add hl,bc
656
        adc a,b
657
        call iseof
658
        jr nc,nvhex_calcnextcorrectxy_error
659
        inc d
660
        ld c,e
661
        ld b,0
662
        push hl
663
        add hl,bc
664
        call iseof
665
        pop hl
666
        ret c
667
        push af
608 alone 668
        ld a,(filesize)
667 alone 669
        dec a
670
        and 0x0f
8 dimkam 671
        ld e,a
672
        pop af
673
        scf
667 alone 674
        ret ;CY
8 dimkam 675
nvhex_calcnextcorrectxy_error
667 alone 676
        call hexeditor_prevline
8 dimkam 677
        or a
667 alone 678
        ret ;NC
8 dimkam 679
 
680
hexcuraddrxy
681
hexcuraddrx
682
        db 0
683
hexcuraddry
684
        db 0
685
 
686
hexaddrline
687
        dw 0
688
hexaddrlineHSB
689
        db 0