Subversion Repositories NedoOS

Rev

Rev 1484 | Rev 1536 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1.  
  2. getmarkedfiles
  3. ;ix = panel
  4. ;out: hl'hl = files
  5.         ld hl,0
  6.         exx
  7.         ld l,(ix+PANEL.markedfiles)
  8.         ld h,(ix+PANEL.markedfiles+1)
  9.         ret
  10.  
  11. changemark_hl
  12.         push hl
  13.         ld a,(hl)
  14.         xor 1
  15.         ld (hl),a
  16.         ld bc,FCB_FSIZE
  17.         add hl,bc
  18.         ld e,(hl)
  19.         inc hl
  20.         ld d,(hl)
  21.         inc hl
  22.         ld c,(hl)
  23.         inc hl
  24.         ld b,(hl)
  25. ;bcde = file size
  26.         ld l,(ix+PANEL.markedfiles)
  27.         ld h,(ix+PANEL.markedfiles+1)
  28.         inc hl
  29.         jr nz,changemark_hlq ;set mark
  30. ;remove mark
  31.         dec hl
  32.         dec hl
  33.         xor a
  34.         sub e
  35.         ld e,a
  36.         ld a,0
  37.         sbc a,d
  38.         ld d,a
  39.         ld a,0
  40.         sbc a,c
  41.         ld c,a
  42.         sbc a,b
  43.         sub c
  44.         ld b,a ;bcde= -bcde
  45. changemark_hlq
  46.         ld a,(ix+PANEL.markedsize)
  47.         add a,e
  48.         ld (ix+PANEL.markedsize),a
  49.         ld a,(ix+PANEL.markedsize+1)
  50.         adc a,d
  51.         ld (ix+PANEL.markedsize+1),a
  52.         ld a,(ix+PANEL.markedsize+2)
  53.         adc a,c
  54.         ld (ix+PANEL.markedsize+2),a
  55.         ld a,(ix+PANEL.markedsize+3)
  56.         adc a,b
  57.         ld (ix+PANEL.markedsize+3),a
  58.         ld (ix+PANEL.markedfiles),l
  59.         ld (ix+PANEL.markedfiles+1),h
  60.         pop hl
  61.         ret
  62.  
  63. getmarkedfilessize
  64. ;ix = panel
  65. ;out: hl'hl = files
  66.         ld l,(ix+PANEL.markedsize+2)
  67.         ld h,(ix+PANEL.markedsize+3)
  68.         exx
  69.         ld l,(ix+PANEL.markedsize)
  70.         ld h,(ix+PANEL.markedsize+1)
  71.         ret
  72.        
  73. getfiles
  74. ;ix = panel
  75. ;out: hl'hl=files (without ".", "..")
  76.         ld hl,0
  77.         exx
  78.         ld l,(ix+PANEL.filesdirs)
  79.         ld h,(ix+PANEL.filesdirs+1)
  80.         ret
  81.  
  82. countfiles
  83.         ld hl,proc_count
  84.         jp processfiles ;hl'hl=files (without ".", "..")
  85. proc_count
  86.         inc iy
  87.         ret
  88.  
  89. getfilessize
  90. ;ix = panel
  91.         ;exx
  92.         ld l,(ix+PANEL.totalsize+2)
  93.         ld h,(ix+PANEL.totalsize+3)
  94.         exx
  95.         ld l,(ix+PANEL.totalsize)
  96.         ld h,(ix+PANEL.totalsize+1)
  97.         ret ;hl'hl=size
  98.  
  99. processfiles
  100. ;ix = panel address (kept)
  101. ;hl = procedure address (uses hl=fcb, hl'iy = accumulator)
  102. ;out: hl'hl = result
  103.         ld (processfiles_proc),hl
  104.  
  105.         call nv_getpanelfiles_bc
  106.  
  107.         ld l,(ix+PANEL.pointers)
  108.         ld h,(ix+PANEL.pointers+1)
  109.         exx
  110.         ld hl,0
  111.         exx
  112.         ld iy,0
  113. processfiles0
  114.         ld a,b
  115.         or c
  116.         jr z,processfilesq
  117.         push bc
  118.         call getfilepointer_de_fromhl
  119.         push hl
  120.         push ix
  121.         ex de,hl
  122.         call isthisdotdir_hl
  123.         ;display "processfiles_proc ",$
  124. processfiles_proc=$+1
  125.         call nz,0 ;copy может переключать страницу (сейчас не переключает)
  126.         pop ix
  127.         pop hl
  128.         pop bc
  129.         dec bc
  130.         jp processfiles0
  131. processfilesq
  132.         push iy
  133.        push ix
  134.         call nv_batch ;исполнить всё, что запомнили в nv_batch_pushrecord?
  135.        pop ix
  136.         pop hl
  137.         ret
  138.  
  139. gotofilepointer_numberde
  140.         ld l,(ix+PANEL.pointers)
  141.         ld h,(ix+PANEL.pointers+1)
  142.         add hl,de
  143.         add hl,de
  144.         ret
  145.  
  146. getfilepointer_de_fromhl
  147. ;out: hl=next pointer
  148.         ld a,(ix+PANEL.poipg)
  149.         SETPGC000
  150.         ld a,(hl)
  151.         and 0xe0
  152.         ld e,a
  153.         xor (hl)
  154.         inc hl
  155.         ld d,(hl)
  156.         inc hl
  157.         ;ld a,e
  158.         ;and 31
  159.         add a,(ix+PANEL.pgadd)
  160.         PGW3strpg
  161.         ;push af
  162.         ;ld a,e
  163.         ;and 0xe0
  164.         ;ld e,a
  165.         ;pop af
  166.         ret
  167.  
  168. putfilepointer_de_tohl
  169. ;out: hl=next pointer
  170.         ld a,(ix+PANEL.poipg)
  171.         SETPGC000
  172.         ld (hl),e
  173.         inc hl
  174.         ld (hl),d
  175.         inc hl
  176.         ret
  177.  
  178. swapfilepointers_hl_de
  179. ;out: hl=next pointer
  180.         ld a,(ix+PANEL.poipg)
  181.         SETPGC000
  182.         ld a,(de)
  183.         ldi
  184.         dec hl
  185.         ld (hl),a
  186.         inc hl
  187.         ld a,(de)
  188.         ldi
  189.         dec hl
  190.         ld (hl),a
  191.         inc hl
  192.         ret
  193.  
  194. isthisdotdir_hl
  195. ;out: z="." or ".."
  196.         inc hl
  197.         ld a,(hl)
  198.         cp '.'
  199.         dec hl
  200.         ret
  201.  
  202. drawpanelfilesandsize
  203. ;ix=panel
  204.         call nv_getpanelxy_de
  205.         ;ld a,CONST_HGT_TABLE+1
  206.         ld a,(filesperpanel)
  207.         inc a
  208.         add a,d
  209.         ld d,a
  210.         inc e
  211.         inc e
  212.         call nv_setxy ;keeps de,hl,ix
  213.         ld de,_PANELDIRCOLOR;_PANELFILECOLOR
  214.         call nv_setcolor
  215.         call getmarkedfiles
  216.         ld a,h
  217.         or l
  218.         push af ;z = no marked
  219.         call z,getfiles
  220.         pop af
  221.         push af
  222.         ld de,_PANELSELECTCOLOR
  223.         call nz,nv_setcolor
  224.         ;push ix
  225.         ld de,wordfiles
  226.         call prdword_de;_withspaces
  227.         ;ld hl,wordfiles
  228.         ; ld c,0
  229.         ;call prtext
  230.         ;pop ix
  231.         pop af ;z = no marked
  232.         jr nz,drawpanelfilesandsize_markedsize
  233.         call getfilessize
  234.         jr drawpanelfilesandsize_markedsizeq
  235. drawpanelfilesandsize_markedsize
  236.         call getmarkedfilessize
  237. drawpanelfilesandsize_markedsizeq
  238.         ld de,wordbytes
  239.         call prdword_de;_withspaces
  240.         push ix
  241.         ld hl,wordfiles;bytes
  242.          ld c,0
  243.         call prtext
  244.         pop ix
  245.         ret
  246.  
  247. nv_setxy
  248. ;de=yx (kept)
  249. ;keeps de,hl,ix
  250.         push de
  251.         push hl
  252.         push ix
  253.         MYSETXY
  254.         pop ix
  255.         pop hl
  256.         pop de
  257.         ret
  258.  
  259. setpanelcolor
  260.         ld de,_PANELCOLOR
  261. nv_setcolor
  262. ;d=paper, e=ink
  263.         push hl
  264.         push ix
  265.        if PRSTDIO
  266.         SETCOLOR_
  267.        else
  268.         ;ld a,d
  269.         ;add a,a
  270.         ;add a,a
  271.         ;add a,a
  272.         ;add a,e
  273.         ;ld e,a
  274.         OS_SETCOLOR
  275.        endif
  276.         pop ix
  277.         pop hl
  278.         ret
  279.  
  280. getfcbaddrundercursor
  281.         call nv_getdirpos_hl
  282. getfcbaddrunderhl
  283.         ld ix,(curpanel)
  284.         ;ld a,(ix+PANEL.pg)
  285.         ;SETPGC000
  286.         ex de,hl
  287.         call gotofilepointer_numberde ;hl=file pointer
  288.         ;ld a,(hl)
  289.         ;inc hl
  290.         ;ld h,(hl)
  291.         ;ld l,a ;hl=FCB
  292.         call getfilepointer_de_fromhl
  293.         ex de,hl ;hl=FCB
  294.         ret
  295.  
  296. getfcbundercursor
  297.         call getfcbaddrundercursor
  298. getfcbfromhl
  299.         ld de,fcb
  300.         ld bc,FCB_sz
  301.         ldir
  302.         ret
  303.  
  304. panelprtext
  305. ;print max 37 chars (dir)
  306. ;hl = text
  307. ;keeps ix
  308.         push ix
  309. panelprtext0
  310.         ld a,(hl)
  311.         or a
  312.         jr z,panelprtextq
  313.         push bc
  314.         push hl
  315.         MYPRCHAR
  316.         pop hl
  317.         pop bc
  318.         inc c
  319.         inc hl
  320.         ld a,c
  321.         cp PANELDIRCHARS37
  322.         jp nz,panelprtext0
  323. panelprtextq
  324.         pop ix
  325.         ret
  326.  
  327. changedir_fromfcb
  328.         call setcurpaneldir
  329.         ld hl,fcb_filename
  330.         ld de,filenametext
  331.         push de
  332.         call cpmname_to_dotname
  333.         pop de
  334.         OS_CHDIR
  335.         ret
  336.  
  337.         if 1==0
  338. readfile_pages_dehl
  339.         ld a,d
  340.         SETPGC000
  341.         ld a,+(0xc000+PROGSTART)/256
  342.         call cmd_loadpage
  343.         or a
  344.         ret nz
  345.        
  346.         ld a,e
  347.         SETPGC000
  348.         ld a,0xc000/256
  349.         call cmd_loadpage
  350.         or a
  351.         ret nz
  352.        
  353.         ld a,h
  354.         SETPGC000
  355.         ld a,0xc000/256
  356.         call cmd_loadpage
  357.         or a
  358.         ret nz
  359.        
  360.         ld a,l
  361.         SETPGC000
  362.         ld a,0xc000/256
  363.         jp cmd_loadpage
  364.         endif
  365.  
  366. readfile_pages_dehl
  367.         ld a,d
  368.         SETPGC000
  369.         ld a,0xc100/256
  370.         call cmd_loadpage
  371.         ret nz
  372.         ld a,e
  373.         call cmd_loadfullpage
  374.         ret nz
  375.         ld a,h
  376.         call cmd_loadfullpage
  377.         ret nz
  378.         ld a,l
  379. cmd_loadfullpage
  380.         SETPGC000
  381.         ld a,0xc000/256
  382. cmd_loadpage
  383. ;out: a=error, bc=bytes read
  384. ;keeps hl,de
  385.         push de
  386.         push hl
  387.         ld d,a
  388.         xor a
  389.         ld l,a
  390.         ld e,a
  391.         sub d
  392.         ld h,a ;de=buffer, hl=size
  393.         call readcurhandle
  394.         ld b,h
  395.         ld c,l
  396.         pop hl
  397.         pop de
  398.         or a
  399.         ret
  400.  
  401. readcurhandle
  402. curhandle=$+1
  403.         ld b,0
  404.         OS_READHANDLE
  405.         ret
  406.  
  407. cmd_savepage
  408. ;hl=size
  409. ;out: a=error
  410.         ;push hl
  411.         ld de,0x8000
  412.         ;OS_SETDTA
  413.         ;pop hl
  414.         ;ld de,fcb2
  415.         ;OS_FWRITE_NBYTES
  416.         ld a,(curhandle)
  417.         ld b,a
  418.         OS_WRITEHANDLE
  419.         ret
  420.  
  421. setdrawtablesneeded
  422.         ld ix,leftpanel
  423.         res 0,(ix+PANEL.drawtableunneeded)
  424.         ld ix,rightpanel
  425.         res 0,(ix+PANEL.drawtableunneeded)
  426.         ret
  427.  
  428.  
  429. prtable
  430. ;de=yx
  431.         ld hl,prbeginstroka
  432.         call prtableline
  433.         push ix
  434.         ;ld b,CONST_HGT_TABLE
  435.         ld bc,(filesperpanel-1) ;b
  436. prtable0
  437.         inc d
  438.         ;ld hl,prmidstroka
  439.         ;call prtableline
  440.         push bc
  441.         push de
  442.         call nv_setxy ;keeps de,hl,ix
  443.         ld de,tmidstroka
  444.         ld hl,tmidstroka_sz
  445.         call sendchars
  446.         pop de
  447.         pop bc
  448.         djnz prtable0
  449.         pop ix
  450.         inc d
  451.         ld hl,prendstroka
  452.         jp prtableline
  453.  
  454. ;;;;;;;;;;;;;;;;;;
  455.  
  456. cmdprchar
  457.         push hl
  458.         push ix
  459.         MYPRCHAR
  460.         pop ix
  461.         pop hl
  462.         ret
  463.  
  464. nv_getpanelxy_de
  465.         ld e,(ix+PANEL.xy)
  466.         ld d,(ix+PANEL.xy+1)
  467.         ret
  468.  
  469. nv_getdirscroll_bc
  470.         ld c,(ix+PANEL.dirscroll)
  471.         ld b,(ix+PANEL.dirscroll+1)
  472.         ret
  473. nv_setdirscroll_bc
  474.         ld (ix+PANEL.dirscroll),c
  475.         ld (ix+PANEL.dirscroll+1),b
  476.         ret
  477.  
  478. nv_getpanelfiles_bc
  479.         ld c,(ix+PANEL.files)
  480.         ld b,(ix+PANEL.files+1)
  481.         ret
  482. nv_getdirpos_hl
  483.         ld l,(ix+PANEL.dirpos)
  484.         ld h,(ix+PANEL.dirpos+1)
  485.         ret
  486.  
  487. cpfiles_setdirpos
  488. ;hl=suggested dirpos (might be >= files)
  489. ;out: hl=dirpos
  490.         call nv_getpanelfiles_bc
  491.         dec bc
  492.         call minhl_bc_tobc
  493.         ld h,b
  494.         ld l,c
  495. nv_setdirpos_hl
  496.         ld (ix+PANEL.dirpos),l
  497.         ld (ix+PANEL.dirpos+1),h
  498.         ret
  499. nv_setdirpos_zero
  500.         ld hl,0
  501.         jr nv_setdirpos_hl
  502.  
  503. count_filecursor_logy
  504. ;out: a=y, de=PANEL.xy
  505.         ;call nv_getpanelxy_de
  506.         ld a,(ix+PANEL.dirpos)
  507.         sub (ix+PANEL.dirscroll)
  508.         ;add a,d;(ix+PANEL.xy+1) ;y
  509.         ret
  510.  
  511. setfilecursorxy
  512.         ;push af
  513.         ld ix,(curpanel)
  514.         call nv_getpanelxy_de
  515.         call count_filecursor_logy
  516.         add a,d
  517.         ld d,a
  518.         ;ld e,(ix+PANEL.xy)
  519.         inc d
  520.         inc e
  521.         ;pop af
  522.         ;push af
  523.         jp nv_setxy
  524.         ;pop af ;color
  525.         ;ret
  526.  
  527. prfilecursor_reprintfile
  528. ;hl=color
  529.         push hl
  530.         ;ex de,hl
  531.         ;SETCOLOR_
  532.         call setfilecursorxy
  533.         ld ix,(curpanel)
  534.         ;call getfcbaddrundercursor
  535.         ;jp prdirfile
  536.         call getfcbundercursor
  537.         ld ix,fcb
  538.         pop de
  539.         jp prdirfile_ix_decolor
  540.         ;push hl
  541.         ;pop ix
  542.         ;call prdirfile_copyfilename
  543.         ;;ld ix,(curpanel)
  544.         ;ld de,filelinebuf
  545.         ;ld hl,8+1+3
  546.         ;jp sendchars
  547.  
  548. prfilecursor
  549. ;hl=color
  550.         push hl
  551.         call setfilecursorxy
  552.         pop hl
  553.         ld b,12
  554.         call drawfilecursor_sizeb_colorhl ;hl=old color
  555.         ld ix,(curpanel)
  556.         ret
  557.  
  558. editcmd_readprompt_setendcmdx
  559.         ld ix,(curpanel)
  560.         call setpaneldir_makeprompt ;->prompt
  561.         ld hl,cmdbuf
  562.         call strlen
  563.         ld a,l
  564.         ld (curcmdx),a
  565.         ret
  566.  
  567. getanotherpanel_hl
  568. getanotherpanel_ix
  569. curpanel=$+1
  570.         ld bc,leftpanel
  571.         ld hl,0xffff&(leftpanel+rightpanel)
  572.         or a
  573.         sbc hl,bc
  574.         push hl
  575.         pop ix
  576.         ret
  577.  
  578. setanotherpaneldir
  579.         call getanotherpanel_ix
  580.         jr setpaneldir
  581.  
  582. setcurpaneldir
  583.         ld ix,(curpanel)
  584. setpaneldir
  585. ;ix=panel
  586.         push ix
  587.         pop hl
  588.         ld de,PANEL.dir
  589.         add hl,de
  590.         ex de,hl ;de=path
  591.         OS_CHDIR
  592.         ret
  593.  
  594. getcurpaneldir_hl
  595.         ld hl,(curpanel)
  596.         ld de,PANEL.dir
  597.         add hl,de
  598.         ret
  599.  
  600. drawfilecursor_sizeb_colorhl
  601. ;de=yx
  602. ;hl=color
  603. ;b=size
  604.        if PRSTDIO
  605.         push bc
  606.         push hl
  607.         call nv_setxy
  608.         pop de
  609.         SETCOLOR_
  610.         call setcolor_invisible
  611.         pop bc
  612.         ld de,tspaces
  613.         ld h,0
  614.         ld l,b
  615.         call sendchars
  616.         jp setcolor_visible
  617.        else
  618.         ;ld a,d
  619.         ;add a,a
  620.         ;add a,a
  621.         ;add a,a
  622.         ;add a,e
  623.         ;ld e,a
  624.         ;OS_SETCOLOR
  625. drawfilecursor_sizeb0
  626.         push bc
  627.         push de
  628.         push hl ;color
  629.         MYSETXY
  630.         pop de ;color
  631.         push de ;color
  632.         OS_PRATTR
  633.         pop hl ;color
  634.         pop de
  635.         pop bc
  636.         inc e ;x
  637.         djnz drawfilecursor_sizeb0
  638.         ret
  639.        endif
  640.  
  641. copy_to_fcb_filename
  642.         ld de,fcb_filename
  643. ;copy_to_defcb_filename
  644.         ld bc,11
  645.         ldir
  646.         ret
  647.  
  648. nv_closehandle
  649. ;keep de and flags!!!
  650.         push af
  651.         push de
  652.         ld a,(curhandle)
  653.         ld b,a
  654.         OS_CLOSEHANDLE
  655.         pop de
  656.         pop af
  657.         ret
  658.  
  659. tdoublehoriz
  660.         ds PANELDIRCHARS37,0xcd
  661.  
  662. prbeginstroka
  663.         db 0xc9;'г'
  664.         db 1
  665.         db 0xcd;'='
  666.         db 14;wdtcolumn1
  667.         db 0xcd;0xd1;'T'
  668.         db 1
  669.         db 0xcd;'='
  670.         db 10;wdtcolumn2
  671.         db 0xd1;'T'
  672.         db 1
  673.         db 0xcd;'='
  674.         db 12;wdtcolumn3
  675.         db 0xbb;'┐'
  676.         db 1
  677.         db 0
  678.  
  679. tmidstroka
  680.         db 0xba;'│'
  681.        if PRSTDIO
  682.         db 0x1b,"[25C"
  683.         db 0xb3;'│'
  684.         db 0x1b,"[12C"
  685.        else
  686.         ds 25,' '
  687.         db 0xb3;'│'
  688.         ds 12,' '
  689.        endif
  690.         db 0xba;'│'
  691. tmidstroka_sz=$-tmidstroka
  692.         if 1==0
  693. prmidstroka
  694.         db 0xba;'│'
  695.         db 1
  696.         db ' '
  697.         db 14;wdtcolumn1
  698.         db ' ';0xb3;'│'
  699.         db 1
  700.         db ' '
  701.         db 10;wdtcolumn2
  702.         db 0xb3;'│'
  703.         db 1
  704.         db ' '
  705.         db 12;wdtcolumn3
  706.         db 0xba;'│'
  707.         db 1
  708.         db 0
  709.         endif
  710.  
  711. prendstroka
  712.         db 0xc8;'L'
  713.         db 1
  714.         db 0xcd;;'='
  715.         db 14;wdtcolumn1
  716.         db 0xcd;0xcf;'│'
  717.         db 1
  718.         db 0xcd;'='
  719.         db 10;wdtcolumn2
  720.         db 0xcf;'│'
  721.         db 1
  722.         db 0xcd;'='
  723.         db 12;wdtcolumn3
  724.         db 0xbc;'-'
  725.         db 1
  726.         db 0
  727.        
  728. prcrlf
  729.         ld de,tcrlf
  730.         ld hl,2
  731.         jp sendchars
  732. tcrlf
  733.         db 0x0d,0x0a
  734.  
  735.         if PRSTDIO==0
  736. nv_copyscreen0to1
  737.         ;OS_GETMAINPAGES
  738.         ;push hl
  739.         ;...
  740.         ;pop hl
  741.         ;ld a,l
  742.         ;SETPGC000
  743.         ;ld a,h
  744.         ;SETPG8000
  745.         ld a,(user_scr1_low) ;ok
  746.         ld hl,(user_scr0_low) ;ok
  747.         call nv_copypg ;pg l -> pg a
  748.         ld a,(user_scr1_high) ;ok
  749.         ld hl,(user_scr0_high) ;ok
  750. nv_copypg
  751. ;pg l -> pg a
  752.         SETPGC000
  753.         ld a,l
  754.         SETPG8000
  755.         ld hl,0x8000
  756.         ld de,0xC000
  757.         ld bc,0x4000
  758.         ldir
  759.         ret
  760.  
  761. nv_copyscreen1to0
  762.         ;OS_GETMAINPAGES
  763.         ;push hl
  764.         ;...
  765.         ;pop hl
  766.         ;ld a,l
  767.         ;SETPGC000
  768.         ;ld a,h
  769.         ;SETPG8000
  770.         ld a,(user_scr0_low) ;ok
  771.         ld hl,(user_scr1_low) ;ok
  772.         call nv_copypg ;pg l -> pg a
  773.         ld a,(user_scr0_high) ;ok
  774.         ld hl,(user_scr1_high) ;ok
  775.         jr nv_copypg
  776.        
  777. sendchars
  778. ;de=buf, hl=size, c=x
  779. ;out: A=error, c=x
  780. sendchars0
  781.         push bc
  782.         push de
  783.         push hl
  784.         ld a,(de)
  785.         PRCHAR
  786.         pop hl
  787.         pop de
  788.         pop bc
  789.         inc de
  790.         inc c ;x
  791.         dec l
  792.         jr nz,sendchars0
  793.         xor a ;no error
  794.         ret
  795.        
  796. clearrestofline_crlf
  797.         ;call clearrestofline
  798.         ;ld a,0x0d
  799.         ;PRCHAR
  800.         ;ld a,0x0a
  801.         ;PRCHAR
  802.         ;ret
  803. clearrestofline
  804. ;c=x
  805. clearrestofline0
  806.         push bc
  807.         ld a,' '
  808.         PRCHAR
  809.         pop bc
  810.         inc c
  811.         ld a,c
  812.         cp 80
  813.         jr nz,clearrestofline0
  814.         ret
  815.        
  816.         endif
  817.