?login_element?

Subversion Repositories NedoOS

Rev

Rev 1168 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. hexeditor_XYTOP=0x0000 ;ьюцхЄ ёфтшэєЄ№ё  шч-чр ьхэ■
  2. ;hexeditor_HGT=txtscrhgt-1 ;ьюцхЄ єьхэ№°шЄ№ё  шч-чр ьхэ■
  3. hexeditor_WID=80 ;ьюцхЄ єьхэ№°шЄ№ё  шч-чр ёъЁюыысрЁр
  4. hexeditor_MAXX=15
  5. ;hexeditor_PAGESIZE=16*hexeditor_HGT
  6.  
  7.        if PRSTDIO
  8. _hexeditor_CURSORCOLOR=0x0700;0x38
  9. _hexeditor_COLOR=0x0007;7
  10.        else
  11. _hexeditor_CURSORCOLOR=0x38
  12. _hexeditor_COLOR=7
  13.        endif
  14.  
  15. hexeditor_redrawloop
  16.         ;YIELDGETKEYLOOP
  17.         call hexeditor_prpage
  18. hexeditor_mainloop
  19.         call hexeditor_calccursorxy
  20.         ld hl,_hexeditor_CURSORCOLOR
  21.         ld b,2
  22.         call drawfilecursor_sizeb_colorhl
  23.         call hexeditor_calctextcursorxy
  24.        if PRSTDIO
  25.         call nv_setxy ;keeps de,hl,ix
  26.        else
  27.         ld hl,_hexeditor_CURSORCOLOR
  28.         ld b,1
  29.         call drawfilecursor_sizeb_colorhl
  30.        endif
  31.       if 0
  32. ;hexeditor_yieldkeep
  33.         ld a,2
  34. hexeditor_yieldkeep
  35.         ld (hexeditor_wasnokey),a
  36.         YIELDKEEP
  37.         ld a,55+128 ;"or a"
  38.         ld (hexeditor_wasyield),a
  39.       endif
  40. hexeditor_mainloop_nokey
  41.       if 0
  42.       else
  43.         YIELD
  44.       endif
  45.        if PRSTDIO
  46.         GETKEY_
  47.         jr nz,hexeditor_keyq
  48.         ;GETKEY_
  49.         ;jr nz,hexeditor_keyq
  50.         ;GETKEY_
  51.         ;jr nz,hexeditor_keyq ;event бывает 3-символьный
  52.        else
  53.         GET_KEY
  54.         ld a,c ;keynolang
  55.         ;cp NOKEY
  56.          or a
  57.         jr nz,hexeditor_keyq
  58.        endif
  59.        if PRSTDIO
  60.        ld a,(stdindatacount)
  61.        or a
  62.        jr nz,hexeditor_mainloop;_nokey
  63.        endif
  64.       if 0
  65. ;если два раза подряд нет события, то рисуем панельку и делаем YIELD, иначе YIELDKEEP
  66. hexeditor_wasnokey=$+1
  67.         ld a,1
  68.         dec a
  69.         jr nz,hexeditor_yieldkeep
  70. ;рисовать панельку только при отсутствии события после YIELD
  71. hexeditor_wasyield=$
  72.         scf
  73.         jr nc,hexeditor_nopanel
  74.       endif
  75.         call hexeditor_panel
  76.        if PRSTDIO
  77.         call hexeditor_calctextcursorxy
  78.         call nv_setxy ;keeps de,hl,ix
  79.        endif
  80.       if 0
  81. hexeditor_nopanel
  82.         YIELD
  83.         ld a,55 ;"scf"
  84.         ld (hexeditor_wasyield),a
  85.       endif
  86.         jr hexeditor_mainloop_nokey
  87. hexeditor_keyq
  88.         ;push hl
  89.         ;push bc
  90.         ;push de
  91.         push af
  92.         call hexeditor_calccursorxy
  93.         ld hl,_hexeditor_COLOR
  94.         ld b,2
  95.         call drawfilecursor_sizeb_colorhl
  96.        if PRSTDIO == 0
  97.         call hexeditor_calctextcursorxy
  98.         ld hl,_hexeditor_COLOR
  99.         ld b,1
  100.         call drawfilecursor_sizeb_colorhl
  101.        endif
  102.         pop af
  103.         ;pop de
  104.         ;pop bc
  105.         ;pop hl
  106.         cp key_redraw
  107.         jr z,hexeditor_redrawloop
  108.         cp key_esc
  109.         ret z
  110.         cp key_tab
  111.         jp z,nvview_hexeditorq
  112.         ld hl,hexeditor_mainloop
  113.         push hl
  114.          cp key_up
  115.          jp z,hexeditor_up
  116.          cp key_down
  117.          jp z,hexeditor_down
  118.          cp key_pgup
  119.          jp z,hexeditor_pgup
  120.          cp key_pgdown
  121.          jp z,hexeditor_pgdown
  122.         ;cp key_home
  123.         ;jp z,hexeditor_home
  124.         ;cp key_sspgup;ext3
  125.         ;jp z,hexeditor_home
  126.         ;cp key_end
  127.         ;jp z,hexeditor_end
  128.         ;cp key_sspgdown;ext4
  129.         ;jp z,hexeditor_end
  130.         cp key_left
  131.         jp z,hexeditor_left
  132.         cp key_right
  133.         jp z,hexeditor_right
  134.          cp key_csenter
  135.          jp z,hexeditor_save
  136.          cp key_F2
  137.          jp z,hexeditor_save
  138.         cp '0'
  139.         ret c
  140.         cp '9'+1
  141.         jr c,hexeditor_symbol
  142.         cp 'a'
  143.         ret c
  144.         cp 'f'+1
  145.         ret nc ;jp c,hexeditor_symbol
  146.         ;ret
  147. hexeditor_symbol
  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'
  157.         jr nc,hexeditor_symbol_af
  158.         ld b,-0x30
  159.         jr hexeditor_symbol_pr
  160. hexeditor_symbol_af        
  161.         ld b,-0x61+0x0a;0x56
  162. hexeditor_symbol_pr        
  163.         add a,b
  164.        
  165. hexeditor_half=$
  166.         or a ;/scf
  167.         jr c,hexeditor_symbol_right
  168.         add a,a
  169.         add a,a
  170.         add a,a
  171.         add a,a;a=XXXX0000
  172.         xor (hl)
  173.         and 0xf0
  174.         xor (hl)
  175.         jr hexeditor_symbol_rightq
  176. hexeditor_symbol_right
  177.         xor (hl)
  178.         and 0x0f
  179.         xor (hl)
  180. hexeditor_symbol_rightq
  181.         ld (hl),a
  182.         ld hl,hexeditor_half
  183.         ld a,(hl)
  184.         xor 0x80
  185.         ld (hl),a
  186.         call setchanged
  187.         call nvhex_calccuraddrline ;ahl=addr cur line
  188.         ld de,(hexcuraddrxy)
  189.         ld e,0
  190.         push af
  191.         call nv_setxy ;keeps de,hl,ix
  192.         pop af ;keep ahl!!!
  193.         jp hexeditor_prline
  194.  
  195. hexeditor_save
  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
  204.         ret nz ;error
  205.         ld a,b
  206.         ld (curhandle),a
  207.         ld de,(filesize)
  208.         ld hl,(filesizeHSW)
  209.         ld a,0 ;page number
  210. hexeditor_save0
  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
  218.         and 0xc0
  219.         or h
  220.         or l
  221.         jr z,$+5 ;de=size
  222.          ld de,0x4000
  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
  234.          dec hl ;size = size-pgsize
  235.         ld a,h
  236.         or l
  237.         or d
  238.         or e
  239.         jr z,hexeditor_save_popq
  240.         pop af
  241.         inc a
  242.         jr hexeditor_save0
  243. hexeditor_save_popq
  244.         call nv_closehandle
  245.         call setunchanged
  246.         pop af
  247.         ret
  248.  
  249. hexeditor_left
  250.         ld de,(hexcuraddrxy)
  251.         ld a,e
  252.         cp 0
  253.         ret z
  254.         dec e
  255.         ld (hexcuraddrxy),de
  256.         ret
  257.  
  258. hexeditor_right
  259.         ld de,(hexcuraddrxy)
  260.         ld a,e
  261.         cp hexeditor_MAXX
  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
  276.  
  277. hexeditor_calccursorxy
  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
  285.  
  286. hexeditor_calctextcursorxy
  287.         ld de,(hexcuraddrxy)
  288.         ld a,e
  289.         add a,57
  290.         ld e,a
  291.         ret ;no ret because panel is empty
  292.  
  293. hexeditor_panel=nvview_panel
  294.         ;ret
  295.  
  296. hexeditor_prpage
  297.         ld hl,(hexaddrline)
  298.         ld a,(hexaddrlineHSB)
  299.         ld de,hexeditor_XYTOP
  300.         ;ld b,hexeditor_HGT
  301.         ld bc,(hexedhgt-1) ;b
  302. hexeditor_prpage0
  303.         push bc
  304.         push de
  305.         push af
  306.         call nv_setxy ;keeps de,hl,ix
  307.         pop af
  308.         call hexeditor_prline
  309.         pop de
  310.         pop bc
  311.         inc d
  312.         djnz hexeditor_prpage0
  313. ;hexeditor_setbottom
  314.         ;ld (hexaddrline),hl
  315.         ;ld (hexaddrlineHSB),a
  316.         ret
  317.  
  318. hexeditor_prline
  319. ;ahl =  addr line      
  320.         push af
  321.         push hl
  322.         push hl
  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
  327.         ;push bc
  328.          ld de,thexedline
  329.         call hexeditor_praddrline
  330.         call ahl_to_pgaddr
  331.          inc de      
  332.         ;pop bc ;bc = min(16, max line size before eof)
  333.  
  334.          push bc
  335.         push hl
  336.         ld a,c
  337.         or a
  338.         jr z,hexeditor_prlhex0q
  339.         ld b,a
  340. hexeditor_prlhex0
  341.          inc de
  342.         ld a,(hl)
  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
  376.  
  377.         pop hl
  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
  385.         ld a,(hl)
  386.         cp 32
  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
  408.         pop hl
  409.         pop af
  410.         ;ld b,0
  411.         add hl,bc
  412.         adc a,b
  413.         ret
  414.  
  415. hexeditor_praddrline
  416. ;ahl = addr line
  417.         push af
  418.         call hexeditor_prNN
  419.         ld a,h
  420.         call hexeditor_prNN      
  421.         ld a,l        
  422.         call hexeditor_prNN
  423.         pop af
  424.         ret
  425.  
  426. hexeditor_prNN
  427. ;#30 - 0,1,2..9 #41 - A,B,C,D,E,F #61 - a,b,c..
  428. ;a=XX
  429.         push af
  430.         rrca
  431.         rrca
  432.         rrca
  433.         rrca
  434.         or 0xf0
  435.         daa
  436.         add a,0xa0
  437.         adc a,0x40
  438.          ld (de),a
  439.          inc de
  440.         pop af
  441.         or 0xf0
  442.         daa
  443.         add a,0xa0
  444.         adc a,0x40
  445.          ld (de),a
  446.          inc de
  447.         ret
  448.  
  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
  453. ;ahl =addr line  
  454. ;out: ahl =addr line, NC=error      
  455.         call isbof ;CY=0
  456.         ret z ;NC
  457.         push bc
  458.         ld bc,0x0010
  459.         or a
  460.         sbc hl,bc
  461.         sbc a,b
  462.         scf
  463.         pop bc
  464.         ret ;CY
  465.  
  466.         if 1==0
  467. hexeditor_nextline
  468.         call iseof
  469.         ret nc
  470.         push bc
  471.         ld bc,0x0010
  472.         add hl,bc
  473.         adc a,b
  474.         pop bc
  475.         ret
  476.         endif
  477.  
  478. hexeditor_pgup
  479.         call nvhex_calccuraddrline
  480.         ld de,(hexcuraddrxy)
  481.         ld c,a
  482.         ld a,d
  483.         or a
  484.         ld a,c
  485.         jr nz,hexeditor_pgupq
  486.         ;ld b,hexeditor_HGT-1
  487.         ld bc,(hexedhgt-1) ;b
  488.         dec b
  489. hexeditor_pgup0
  490.         push bc
  491.         call hexeditor_prevline
  492.         pop bc
  493.         djnz hexeditor_pgup0
  494.         ld (hexaddrline),hl
  495.         ld (hexaddrlineHSB),a
  496.         call hexeditor_prpage
  497.         jp clear_keyboardbuffer
  498. hexeditor_pgupq
  499.         ld d,0
  500.         ld (hexcuraddrxy),de
  501.         ret
  502.  
  503. hexeditor_pgdown
  504.         call nvhex_calccuraddrline
  505.         ld de,(hexcuraddrxy)
  506.         ld c,a
  507.         ;ld a,hexeditor_HGT-1
  508.         ld a,(hexedhgt)
  509.         dec a
  510.         cp d
  511.         ld a,c
  512.         jr z,hexeditor_pgdown_do
  513. hexeditor_pgdown0
  514.         ld c,a
  515.         ;ld a,hexeditor_HGT-1
  516.         ld a,(hexedhgt)
  517.         dec a
  518.         cp d
  519.         ld a,c
  520.         jr z,hexeditor_pgdownq
  521.         call nvhex_calcnextcorrectxy
  522.         jr c,hexeditor_pgdown0
  523. hexeditor_pgdownq
  524.         ld (hexcuraddrxy),de
  525.         ret
  526. hexeditor_pgdown_do
  527.         ld (hexaddrline),hl
  528.         ld (hexaddrlineHSB),a
  529.         push de
  530.         call hexeditor_prpage
  531.         pop de
  532.         ld hl,(hexaddrline)
  533.         ld a,(hexaddrlineHSB)
  534.         ld d,0
  535. hexeditor_pgdown_do0
  536.         ld c,a
  537.         ;ld a,hexeditor_HGT-1
  538.         ld a,(hexedhgt)
  539.         dec a
  540.         cp d
  541.         ld a,c
  542.         jr z,hexeditor_pgdown_doq
  543.         call nvhex_calcnextcorrectxy
  544.         jr c,hexeditor_pgdown_do0
  545. hexeditor_pgdown_doq
  546.         ld (hexcuraddrxy),de
  547.         jp clear_keyboardbuffer
  548.  
  549. hexeditor_up
  550.         call nvhex_calccuraddrline
  551.         call hexeditor_prevline
  552.         ret nc ;bof
  553.         ld de,(hexcuraddrxy)
  554.         ld a,d
  555.         or a
  556.         jr z,hexeditor_up_scroll
  557.         dec d
  558.         ld (hexcuraddrxy),de
  559.         ret
  560. hexeditor_up_scroll        
  561.         ld de,hexeditor_XYTOP
  562.         ;ld hl,256*hexeditor_HGT + hexeditor_WID
  563.         ld hl,(hexedhgt-1) ;h
  564.         ld l,hexeditor_WID
  565.        if PRSTDIO
  566.         call scrolldown
  567.        else
  568.         OS_SCROLLDOWN
  569.        endif
  570.         ld de,hexeditor_XYTOP
  571.         call nv_setxy ;keeps de,hl,ix
  572.         ld hl,(hexaddrline)
  573.         ld a,(hexaddrlineHSB)
  574.         call hexeditor_prevline
  575.         ld (hexaddrline),hl
  576.         ld (hexaddrlineHSB),a
  577.         jp hexeditor_prline
  578.  
  579. hexeditor_down
  580.         call nvhex_calccuraddrline
  581.         ld de,(hexcuraddrxy)
  582.         call nvhex_calcnextcorrectxy
  583.         ret nc
  584.         ld c,a
  585.         ;ld a,hexeditor_HGT;-1
  586.         ld a,(hexedhgt)
  587.         ;dec a
  588.         cp d
  589.         ld a,c
  590.         jr z,hexeditor_down_scroll
  591.         ld (hexcuraddrxy),de
  592.         ret
  593. hexeditor_down_scroll
  594.         ;ld hl,(hexaddrline)
  595.         ;ld a,(hexaddrlineHSB)
  596.         ;ld bc,hexeditor_PAGESIZE
  597.         ;add hl,bc
  598.         ;adc a,0
  599.         push af
  600.         push hl
  601.         ld a,e
  602.         ld (hexcuraddrx),a
  603.         ld de,hexeditor_XYTOP
  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
  609.        if PRSTDIO
  610.         call scrollup
  611.        else
  612.         OS_SCROLLUP
  613.        endif
  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)
  621.         call nv_setxy ;keeps de,hl,ix
  622.         ld hl,(hexaddrline)
  623.         ld a,(hexaddrlineHSB)
  624.         ld bc,16
  625.         add hl,bc
  626.         adc a,b;0
  627.         ld (hexaddrline),hl
  628.         ld (hexaddrlineHSB),a
  629.         pop hl
  630.         pop af
  631.         jp hexeditor_prline
  632.  
  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
  668.         ld a,(filesize)
  669.         dec a
  670.         and 0x0f
  671.         ld e,a
  672.         pop af
  673.         scf
  674.         ret ;CY
  675. nvhex_calcnextcorrectxy_error
  676.         call hexeditor_prevline
  677.         or a
  678.         ret ;NC
  679.        
  680. hexcuraddrxy
  681. hexcuraddrx
  682.         db 0
  683. hexcuraddry
  684.         db 0
  685.  
  686. hexaddrline
  687.         dw 0
  688. hexaddrlineHSB
  689.         db 0
  690.