?login_element?

Subversion Repositories NedoOS

Rev

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

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