?login_element?

Subversion Repositories NedoOS

Rev

Rev 574 | Rev 608 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. NVVIEW_HEXEDITOR_XYTOP=0x0000
  2. NVVIEW_HEXEDITOR_HGT=24
  3. NVVIEW_HEXEDITOR_WID=80
  4. NVVIEW_HEXEDITOR_MAXX=15
  5. NVVIEW_HEXEDITOR_PAGESIZE=16*NVVIEW_HEXEDITOR_HGT
  6.  
  7. _NVVIEW_HEXEDITOR_CURSORCOLOR=0x0700;0x38
  8. _NVVIEW_HEXEDITOR_COLOR=0x0007;7
  9.  
  10. nvview_hexeditor_redrawloop
  11.         ;YIELDGETKEYLOOP
  12.         call nvview_hexeditor_prpage
  13. nvview_hexeditor_prfile_mainloop
  14. nvview_hexeditor_prfile_mainloop0
  15.         call nvhexed_calccursorxy
  16.         ld hl,_NVVIEW_HEXEDITOR_CURSORCOLOR
  17.         ld b,2
  18.         call drawfilecursor_sizeb_colorhl
  19.         call nvhexed_calctextcursorxy
  20.         ld hl,_NVVIEW_HEXEDITOR_CURSORCOLOR
  21.         ld b,1
  22.         call drawfilecursor_sizeb_colorhl
  23.         ld de,24*256+79
  24.         SETXY_
  25.        
  26.         YIELD ;halt ;если сделать просто di:rst #38, то 1.сдвинем таймер и 2.можем потерять кадровое прерывание, а если без ei, то будут глюки
  27.         GETKEY_ ;OS_GETKEYNOLANG
  28.         ld a,c ;keynolang
  29.         push hl
  30.         push bc
  31.         push de
  32.         push af
  33.         call nvhexed_calccursorxy
  34.         ld hl,_NVVIEW_HEXEDITOR_COLOR
  35.         ld b,2
  36.         call drawfilecursor_sizeb_colorhl
  37.         call nvhexed_calctextcursorxy
  38.         ld hl,_NVVIEW_HEXEDITOR_COLOR
  39.         ld b,1
  40.         call drawfilecursor_sizeb_colorhl
  41.         pop af
  42.         pop de
  43.         pop bc
  44.         pop hl
  45.        
  46.         cp NOKEY
  47.         jr nz,nvview_hexeditor_prfileq
  48.         call nvview_hexeditor_panel
  49.         jr nvview_hexeditor_prfile_mainloop0
  50. nvview_hexeditor_prfileq
  51.         cp key_redraw
  52.         jr z,nvview_hexeditor_redrawloop
  53.         cp key_esc
  54.         ret z
  55.         cp key_tab
  56.         jp z,nvview_hexeditorq
  57.         ld hl,nvview_hexeditor_prfile_mainloop
  58.         push hl
  59.          cp key_up
  60.          jp z,nvview_hexeditor_up
  61.          cp key_down
  62.          jp z,nvview_hexeditor_down
  63.          cp key_pgup
  64.          jp z,nvview_hexeditor_pgup
  65.          cp key_pgdown
  66.          jp z,nvview_hexeditor_pgdown
  67.         ;cp key_home
  68.         ;jp z,nvview_hexeditor_home
  69.         ;cp key_sspgup;ext3
  70.         ;jp z,nvview_hexeditor_home
  71.         ;cp key_end
  72.         ;jp z,nvview_hexeditor_end
  73.         ;cp key_sspgdown;ext4
  74.         ;jp z,nvview_hexeditor_end
  75.         cp key_left
  76.         jp z,nvview_hexeditor_left
  77.         cp key_right
  78.         jp z,nvview_hexeditor_right
  79.          cp key_csenter
  80.          jp z,nvview_hexeditor_save
  81.          cp key_F2
  82.          jp z,nvview_hexeditor_save
  83.         ;cp 'w'
  84.         ;jp z,nvview_wrap
  85.         cp '0'
  86.         ret c
  87.         cp '9'+1
  88.         jp c,nvview_hexeditor_symbol
  89.         cp 'a'
  90.         ret c
  91.         cp 'f'+1
  92.         jp c,nvview_hexeditor_symbol
  93.         ret
  94.  
  95. nvview_hexeditor_symbol
  96.         push af
  97.         call nvhex_calccuraddrline ;addr cur line
  98.         ld de,(hexcuraddrxy)
  99.         ld d,0
  100.         add hl,de ;addrcurline + x(e)
  101.         call ahl_to_pgaddr
  102.         pop af
  103.         ;0   a-10
  104.         cp 'a'
  105.         jr nc,nvview_hexeditor_symbol_af
  106.         ld b,-0x30
  107.         jr nvview_hexeditor_symbol_pr
  108. nvview_hexeditor_symbol_af        
  109.         ld b,-0x61+0x0a;0x56
  110. nvview_hexeditor_symbol_pr        
  111.         add a,b
  112.        
  113. nvhexed_half=$
  114.         or a ;/scf
  115.         jr c,nvhexed_symbol_right
  116.         add a,a
  117.         add a,a
  118.         add a,a
  119.         add a,a;a=XXXX0000
  120.         xor (hl)
  121.         and #f0
  122.         xor (hl)
  123.         jr nvhexed_symbol_rightq
  124. nvhexed_symbol_right
  125.         xor (hl)
  126.         and 0x0f
  127.         xor (hl)
  128. nvhexed_symbol_rightq
  129.         ld (hl),a
  130.         ld hl,nvhexed_half
  131.         ld a,(hl)
  132.         xor 0x80
  133.         ld (hl),a
  134.         call nvhex_calccuraddrline ;addr cur line
  135.         ld de,(hexcuraddrxy)
  136.         ld e,0
  137.         call nv_setxy
  138.         call nvview_hexeditor_prline
  139.         ret
  140. ;--------
  141.         ;ld a,(fcb+FCB_FSIZE)
  142.         ;dec a   ;a=????xxxx  l=XXXXzzzz
  143.         ;;xor l   ;a=????xzxz  l=XXXXzzzz
  144.         ;and #0f ;a=0000xzxz  l=XXXXzzzz
  145.         ;;xor l   ;a=XXXXxxxx  l=XXXXzzzz
  146.         ;;ld l,a
  147.         ;ld e,a
  148.        
  149. ;--------
  150.        
  151.        
  152. nvview_hexeditor_save
  153.         ;call getfcbundercursor ;->fcb
  154.         ld hl,fcb_filename
  155.         ld de,fcb2_filename
  156.         call copy_to_defcb_filename
  157.         ;call setcurpaneldir
  158.         call nv_createfcb2 ;autopush nv_closefcb2
  159.         ret nz ;error
  160.         ld de,(fcb+FCB_FSIZE)
  161.         ld hl,(fcb+FCB_FSIZE+2)
  162.         ld a,0 ;page number
  163. nvview_hexeditor_save0
  164. ;a=page number in table (0..)
  165. ;hlde=remaining size
  166.         push af
  167.         push de
  168.         push hl
  169.         call setpg32k
  170.         ld a,d
  171.         and #c0
  172.         or h
  173.         or l
  174.         jr z,$+5 ;de=size
  175.         ld de,#4000
  176.         ex de,hl ;hl=pg size
  177.         push hl ;hl=pg size
  178.         call cmd_savepage
  179.         pop bc ;bc=pg size
  180.         pop hl
  181.         pop de
  182.         ex de,hl
  183.         or a
  184.         sbc hl,bc
  185.         ex de,hl
  186.         jr nc,$+3
  187.         dec hl ;size = size-pgsize
  188.         ld a,h
  189.         or l
  190.         or d
  191.         or e
  192.         jr z,nvview_hexeditor_save_popq
  193.         pop af
  194.         inc a
  195.         jr nvview_hexeditor_save0
  196. nvview_hexeditor_save_popq
  197.         pop af
  198.         ret
  199.        
  200. nvview_hexeditor_left
  201.         ld de,(hexcuraddrxy)
  202.         ld a,e
  203.         cp 0
  204.         ret z
  205.         dec e
  206.         ld (hexcuraddrxy),de
  207.         ret
  208.        
  209. nvview_hexeditor_right
  210.         ld de,(hexcuraddrxy)
  211.         ld a,e
  212.         cp NVVIEW_HEXEDITOR_MAXX
  213.         ret z
  214.         inc e
  215.         push de
  216.         call nvhex_calccuraddrline ;ahl=lineaddr
  217.         pop de
  218.         push af
  219.         ld a,e
  220.         add a,l
  221.         ld l,a
  222.         pop af
  223.         call iseof
  224.         ret nc
  225.         ld (hexcuraddrxy),de
  226.         ret
  227.        
  228. nvhexed_calccursorxy
  229.         ld de,(hexcuraddrxy)
  230.         ld a,e
  231.         add a,a
  232.         add a,e
  233.         add a,8
  234.         ld e,a
  235.         ret
  236.        
  237. nvhexed_calctextcursorxy
  238.         ld de,(hexcuraddrxy)
  239.         ld a,e
  240.         add a,57
  241.         ld e,a
  242.         ret
  243.        
  244. nvview_hexeditor_panel
  245.         ret
  246.        
  247. nvview_hexeditor_prpage
  248.         ld hl,(hexaddrline)
  249.         ld a,(hexaddrlineHSB)
  250.         ld de,NVVIEW_HEXEDITOR_XYTOP
  251.         ld b,NVVIEW_HEXEDITOR_HGT
  252. nvview_hexeditor_prpage0
  253.         push bc
  254.         push de
  255.         push af
  256.         push hl
  257.         SETXY_
  258.         pop hl
  259.         pop af
  260.         call nvview_hexeditor_prline
  261.         pop de
  262.         pop bc
  263.         inc d
  264.         djnz nvview_hexeditor_prpage0
  265. ;nvview_hexeditor_setbottom
  266.         ;ld (hexaddrline),hl
  267.         ;ld (hexaddrlineHSB),a
  268.         ret
  269.        
  270.  
  271. nvview_hexeditor_prline
  272. ;ahl =  addr line      
  273.         ;jr $
  274.         push hl
  275.         push af
  276.        
  277.         push hl
  278.         call getmaxlinesize ;bc=max line size before eof, z=(bc==0)
  279.         ld hl,16
  280.         call minhl_bc_tobc ;bc = min(16, max line size before eof)
  281.         pop hl
  282.                  
  283.         push bc
  284.         call nvview_hexeditor_praddrline
  285.         call ahl_to_pgaddr
  286.        
  287.         push hl
  288.         ld a,':'
  289.         PRCHAR_
  290.         pop hl
  291.        
  292.         pop bc;ld b,0
  293.        
  294.         push hl
  295. nvview_hexeditor1        
  296.         ld a,b
  297.         cp 8
  298.         ld a,' '
  299.         jr nz,nvview_hexeditor0
  300.         ld a,'|'
  301. nvview_hexeditor0
  302.         push hl
  303.         push bc
  304.         PRCHAR_
  305.         pop bc
  306.         pop hl
  307.        
  308.         ld a,b
  309.         cp c
  310.         jr c,nvview_hexeditor_prhex
  311.         push bc
  312.         ld b,2
  313.         call nvview_prlinespc_b
  314.         pop bc
  315.         jr nvview_hexeditor_notprhex
  316. nvview_hexeditor_prhex        
  317.         ld a,(hl)
  318.         push bc
  319.         call nvview_hexeditor_prNN
  320.         pop bc
  321. nvview_hexeditor_notprhex
  322.         inc hl
  323.         inc b
  324.         ld a,b
  325.         cp 16
  326.         jr nz,nvview_hexeditor1        
  327.         pop hl
  328.        
  329.         ld b,2
  330.         call nvview_prlinespc_b
  331.        
  332.         ld b,0
  333. nvview_hexeditor2      
  334.         ld a,b
  335.         cp c
  336.         ld a,' '
  337.         jr nc,nvview_hexeditor2_sym  
  338. nvview_hexeditor2_prtext        
  339.         ld a,(hl)
  340.         cp 32
  341.         jr nc,nvview_hexeditor2_sym
  342.         ld a,'.'
  343. nvview_hexeditor2_sym        
  344.         push hl
  345.         push bc
  346.         PRCHAR_
  347.         pop bc
  348.         pop hl
  349.         inc hl
  350.         inc b
  351.         ld a,b
  352.         cp 16
  353.         jr nz,nvview_hexeditor2        
  354.         pop af
  355.         pop hl
  356.         ld b,0
  357.         add hl,bc
  358.         adc a,b
  359.  
  360.         ld b,7
  361.         call nvview_prlinespc_b
  362.         ret        
  363.  
  364. nvview_hexeditor_prNN
  365.         push af
  366.         push hl
  367.         call nvview_prhexbyte
  368.         pop hl
  369.         pop af
  370.         ret
  371.        
  372. nvview_hexeditor_praddrline
  373. ;ahl = addr line
  374.         push af
  375.         call nvview_hexeditor_prNN
  376.         ld a,h
  377.         call nvview_hexeditor_prNN      
  378.         ld a,l        
  379.         call nvview_hexeditor_prNN
  380.         pop af
  381.         ret
  382.        
  383. nvview_prhexbyte
  384. ;ld a,#30;a=#30 - 0,1,2..9 #41 - A,B,C,D,E,F #61 - a,b,c..
  385. ;a=XX
  386.         ;push hl
  387.         ;push af
  388.         rrca
  389.         rrca
  390.         rrca
  391.         rrca
  392.         call pronehexdigit
  393.         rlca
  394.         rlca
  395.         rlca
  396.         rlca
  397.         ;call pronehexdigit
  398.         ;pop af
  399.         ;pop hl
  400.         ;ret
  401. pronehexdigit
  402. ;a=?X
  403.         push bc
  404.         push af
  405.         and #f
  406.         cp 10
  407.         jr c,prcharbit_noletter
  408.         add a,'a'-('0'+10)
  409. prcharbit_noletter
  410.         add a,'0'
  411.         PRCHAR_
  412.         pop af
  413.         pop bc
  414.         ret
  415.  
  416. nvview_hexeditor_prevline
  417. ;ahl =addr line  
  418. ;out: ahl =addr line, nc=error      
  419.         call isbof ;cy=0
  420.         ret z
  421.         push bc
  422.         ld bc,#0010
  423.         or a
  424.         sbc hl,bc
  425.         sbc a,b
  426.         scf
  427.         pop bc
  428.         ret ;c        
  429.        
  430. nvview_hexeditor_nextline
  431.         call iseof
  432.         ret nc
  433.         push bc
  434.         ld bc,#0010
  435.         add hl,bc
  436.         adc a,b
  437.         pop bc
  438.         ret        
  439.                
  440.  
  441. nvview_hexeditor_up
  442.         call nvhex_calccuraddrline
  443.         call nvview_hexeditor_prevline
  444.         ret nc
  445.         ld de,(hexcuraddrxy)
  446.         ld a,d
  447.         or a
  448.         jp z,nvview_hexeditor_up_scroll
  449.         dec d
  450.         ld (hexcuraddrxy),de
  451.         ret
  452. nvview_hexeditor_up_scroll        
  453.         ld de,NVVIEW_HEXEDITOR_XYTOP
  454.         ld hl,256*NVVIEW_HEXEDITOR_HGT + NVVIEW_HEXEDITOR_WID
  455.         OS_SCROLLDOWN
  456.         ld de,NVVIEW_HEXEDITOR_XYTOP
  457.         SETXY_
  458.         ld hl,(hexaddrline)
  459.         ld a,(hexaddrlineHSB)
  460.         call nvview_hexeditor_prevline
  461.         ld (hexaddrline),hl
  462.         ld (hexaddrlineHSB),a
  463.        
  464.         call nvview_hexeditor_prline
  465.         ;call nvview_prline
  466.         ;call deccurline
  467.         ;ld hl,(curbottomtextaddrhex)
  468.         ;ld a,(curbottomtextHSBhex)
  469.         ;call nvview_prevline
  470.         ;jp nvview_hexeditor_setbottom
  471.         ret
  472.        
  473. nvview_hexeditor_pgdown
  474.         call nvhex_calccuraddrline
  475.         ld de,(hexcuraddrxy)
  476.         ld c,a
  477.         ld a,d
  478.         cp NVVIEW_HEXEDITOR_HGT-1
  479.         ld a,c
  480.         jp z,nvview_hexeditor_pgdown_do
  481. nvview_hexeditor_pgdown0
  482.         ld c,a
  483.         ld a,d
  484.         cp NVVIEW_HEXEDITOR_HGT-1
  485.         ld a,c
  486.         jp z,nvview_hexeditor_pgdownq
  487.         call nvhex_calcnextcorrectxy
  488.         jp c,nvview_hexeditor_pgdown0
  489. nvview_hexeditor_pgdownq
  490.         ld (hexcuraddrxy),de
  491.         ret
  492. nvview_hexeditor_pgdown_do
  493.         ld (hexaddrline),hl
  494.         ld (hexaddrlineHSB),a
  495.         push de
  496.         call nvview_hexeditor_prpage
  497.         pop de
  498.         ld hl,(hexaddrline)
  499.         ld a,(hexaddrlineHSB)
  500.         ld d,0
  501. nvview_hexeditor_pgdown_do0
  502.         ld c,a
  503.         ld a,d
  504.         cp NVVIEW_HEXEDITOR_HGT-1
  505.         ld a,c
  506.         jp z,nvview_hexeditor_pgdown_doq
  507.         call nvhex_calcnextcorrectxy
  508.         jp c,nvview_hexeditor_pgdown_do0
  509. nvview_hexeditor_pgdown_doq
  510.         ld (hexcuraddrxy),de
  511.         jp clear_keyboardbuffer
  512.  
  513. nvview_hexeditor_pgup
  514.         call nvhex_calccuraddrline
  515.         ld de,(hexcuraddrxy)
  516.         ld c,a
  517.         ld a,d
  518.         or a
  519.         ld a,c
  520.         jp nz,nvview_hexeditor_pgupq
  521.         ld b,NVVIEW_HEXEDITOR_HGT-1
  522. nvview_hexeditor_pgup0
  523.         push bc
  524.         call nvview_hexeditor_prevline
  525.         pop bc
  526.         djnz nvview_hexeditor_pgup0
  527.         ld (hexaddrline),hl
  528.         ld (hexaddrlineHSB),a
  529.         call nvview_hexeditor_prpage
  530.         jp clear_keyboardbuffer
  531. nvview_hexeditor_pgupq
  532.         ld d,0
  533.         ld (hexcuraddrxy),de
  534.         ret
  535.        
  536.        
  537.        
  538. nvview_hexeditor_down
  539.         call nvhex_calccuraddrline
  540.         ld de,(hexcuraddrxy)
  541.         call nvhex_calcnextcorrectxy
  542.         ret nc
  543.         ld c,a
  544.         ld a,d
  545.         cp NVVIEW_HEXEDITOR_HGT
  546.         ld a,c
  547.         jr z,nvview_hexeditor_down_scroll
  548.         ld (hexcuraddrxy),de
  549.         ret
  550. nvview_hexeditor_down_scroll
  551.         ;ld hl,(hexaddrline)
  552.         ;ld a,(hexaddrlineHSB)
  553.         ;ld bc,NVVIEW_HEXEDITOR_PAGESIZE
  554.         ;add hl,bc
  555.         ;adc a,0
  556.         push af
  557.         push hl
  558.         ld a,e
  559.         ld (hexcuraddrx),a
  560.         ld de,NVVIEW_HEXEDITOR_XYTOP
  561.         ld hl,256*NVVIEW_HEXEDITOR_HGT + NVVIEW_HEXEDITOR_WID
  562.         OS_SCROLLUP
  563.         ld de,NVVIEW_HEXEDITOR_XYTOP+((NVVIEW_HEXEDITOR_HGT-1)*256)
  564.         SETXY_
  565.         ld hl,(hexaddrline)
  566.         ld a,(hexaddrlineHSB)
  567.         ld bc,16
  568.         add hl,bc
  569.         ld (hexaddrline),hl
  570.         ld (hexaddrlineHSB),a
  571.         pop hl
  572.         pop af
  573.         jp nvview_hexeditor_prline
  574.        
  575. nvhex_calccuraddrline
  576. ;out: ahl = addr cur line
  577.         ld hl,(hexaddrline)
  578.         ld a,(hexaddrlineHSB)
  579.         ld de,(hexcuraddrxy)
  580.         ld e,0
  581.         srl d
  582.         rr e
  583.         srl d
  584.         rr e
  585.         srl d
  586.         rr e
  587.         srl d
  588.         rr e
  589.         add hl,de       ;hl+d*16
  590.         adc a,0
  591.         ret
  592.  
  593. nvhex_calcnextcorrectxy
  594. ;ahl=line addr, de=yx
  595. ;out:ahl=line addr, de=yx, NC=error
  596.         ld bc,16
  597.         add hl,bc
  598.         adc a,b
  599.         call iseof
  600.         jr nc,nvhex_calcnextcorrectxy_error
  601.         inc d
  602.         ld c,e
  603.         ld b,0
  604.         push hl
  605.         add hl,bc
  606.         call iseof
  607.         pop hl
  608.         ret c
  609.         push af
  610.         ld a,(fcb+FCB_FSIZE)
  611.         dec a   ;a=????xxxx  l=XXXXzzzz
  612.         ;xor l   ;a=????xzxz  l=XXXXzzzz
  613.         and #0f ;a=0000xzxz  l=XXXXzzzz
  614.         ;xor l   ;a=XXXXxxxx  l=XXXXzzzz
  615.         ;ld l,a
  616.         ld e,a
  617.         pop af
  618.         scf
  619.         ret ;c
  620. nvhex_calcnextcorrectxy_error
  621.         call nvview_hexeditor_prevline
  622.         or a
  623.         ret ;nc
  624.        
  625. hexcuraddrxy
  626. hexcuraddrx
  627.         db 0
  628. hexcuraddry
  629.         db 0
  630.  
  631. hexaddrline
  632.         dw 0
  633. hexaddrlineHSB
  634.         db 0
  635.