?login_element?

Subversion Repositories NedoOS

Rev

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