?login_element?

Subversion Repositories NedoOS

Rev

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

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.  
  4. _COLOR=0x0007;7
  5. TSPACES_FILENAME_SZ=42;41
  6.  
  7.         org PROGSTART
  8. cmd_begin
  9.         ld sp,0x4000 ;не должен опускаться ниже #3b00! иначе возможна порча OS
  10.         call initstdio
  11.         ;ld e,6 ;textmode
  12.         ;OS_SETGFX
  13.  
  14.         ;YIELD ;чтобы cmd мог доделать свои дела на экране
  15.        
  16.         ;ld e,COLOR
  17.         ;OS_CLS
  18.        
  19.         ld hl,twinto866
  20. mktwinto866_0
  21.         ld e,(hl)
  22.         ld d,t866towin/256
  23.         ld a,l
  24.         ld (de),a
  25.         inc l
  26.         jr nz,mktwinto866_0
  27.  
  28.         ld hl,COMMANDLINE ;command line
  29.         call skipword
  30.         call skipspaces
  31.         ld a,(hl)
  32.         or a
  33.         jr z,noautoload
  34. ;command line = "texted <file to load>"
  35.         ld (texted_filenameaddr),hl
  36.         ex de,hl ;de=drive/path/file
  37.         OS_OPENHANDLE
  38. ;b=new file handle
  39.  
  40.         ld hl,0
  41.         ld de,0
  42. nvview_load0
  43.         push bc
  44.         push de
  45.         push hl
  46.         call reservepage
  47.         pop hl
  48.         pop de
  49.         pop bc
  50.         ret nz ;no memory
  51.         ;ld a,#c000/256
  52.         ;call cmd_loadpage
  53.  
  54.         push bc
  55.        
  56.         push de
  57.         push hl
  58.         ld de,0xc000
  59.         ld hl,0x4000
  60. ;B = file handle, DE = Buffer address, HL = Number of bytes to read
  61.         OS_READHANDLE
  62. ;HL = Number of bytes actually read, A=error
  63.         ld b,h
  64.         ld c,l
  65.         ld hl,0x4000
  66.         or a
  67.         sbc hl,bc ;NZ = bytes to read != bytes actually read
  68.         pop hl
  69.         pop de
  70.  
  71.         push af ;NZ = bytes to read != bytes actually read
  72.         ex de,hl
  73.         add hl,bc
  74.         ex de,hl
  75.         jr nc,$+3
  76.         inc hl
  77.         pop af ;NZ = bytes to read != bytes actually read
  78.  
  79.         pop bc
  80.  
  81.         ;or a
  82.         jr z,nvview_load0
  83. ;hlde=true file size (for TRDOSFS)
  84.         ld (filesize),de
  85.         ld (filesizeHSW),hl
  86.        
  87.         OS_CLOSEHANDLE
  88.        
  89.         ;ld hl,text
  90.         ;call prtext
  91. noautoload
  92.         ld hl,(texted_filenameaddr)
  93.         ld de,tshown_filename
  94. ;copy hl->de no more than TSPACES_FILENAME_SZ bytes
  95.         ld b,TSPACES_FILENAME_SZ
  96.         call strcopy_maxb
  97.  
  98.         call textview
  99.         QUIT
  100.  
  101. strcopy_maxb
  102. ;copy hl->de no more than b bytes
  103. strcopy_maxb0
  104.         ld a,(hl)
  105.         or a
  106.         ret z
  107.         ld (de),a
  108.         inc hl
  109.         inc de
  110.         djnz strcopy_maxb0
  111.         ret
  112.  
  113. ;out: hl=after terminator
  114.         if 1==1
  115. prtext
  116. ;hl=text
  117.         push hl
  118.         call strlen ;hl=length
  119.         pop de ;de=text
  120.         push de
  121.         push hl
  122.         call sendchars
  123.         pop hl
  124.         pop de
  125.         add hl,de
  126.         inc hl ;out: hl=after terminator
  127.         ret
  128.  
  129. strlen
  130. ;hl=str
  131. ;out: hl=length
  132.         ld bc,0 ;чтобы точно найти терминатор
  133.         xor a
  134.         cpir ;найдём обязательно, если длина=0, то bc=-1 и т.д.
  135.         ld hl,-1
  136.         or a
  137.         sbc hl,bc
  138.         ret
  139.         else
  140. prtext
  141. prtext0
  142.         ld a,(hl)
  143.         inc hl
  144.         or a
  145.         ret z
  146.         push hl
  147.         PRCHAR_
  148.         pop hl
  149.         jp prtext0
  150.         endif
  151.        
  152. skipword
  153. ;hl=string
  154. ;out: hl=terminator/space addr
  155. getword0
  156.         ld a,(hl)
  157.         or a
  158.         ret z
  159.         cp ' '
  160.         ret z
  161.         inc hl
  162.         jr getword0
  163.  
  164. skipspaces
  165. ;hl=string
  166. ;out: hl=after last space
  167.         ld a,(hl)
  168.         cp ' '
  169.         ret nz
  170.         inc hl
  171.         jr skipspaces
  172.  
  173. nv_setxy
  174. ;de=yx (kept)
  175. ;keeps hl
  176.         push de
  177.         push hl
  178.         push ix
  179.         SETXY_
  180.         pop ix
  181.         pop hl
  182.         pop de
  183.         ret
  184.        
  185. minhl_bc_tobc
  186.         or a
  187.         sbc hl,bc
  188.         add hl,bc
  189.         ret nc ;bc<=hl
  190.         ld b,h
  191.         ld c,l
  192.         ret
  193.  
  194. texted_build
  195.         ;OS_GETSTDINOUT ;e=stdin, d=stdout, h=stderr
  196.         ;ld a,d
  197.         ;ld (stdouthandle_wasatstart),a
  198.         ;ld a,e
  199.         ;ld (stdinhandle_wasatstart),a
  200.  
  201. ;keep current path
  202.         ld de,curpath
  203.         OS_GETPATH ;DE = Pointer to MAXPATH_sz byte buffer ;out: DE = Filled in with whole path string (WITH DRIVE! Finished by slash only if root dir), HL = Pointer to start of last item
  204. ;new app, get pages for new app, load cmd with command line from cmdbuf
  205.         call loadapp ;NZ=error ;e=id
  206. ;run cmd
  207.         push de
  208.         OS_RUNAPP
  209.         pop de
  210. ;wait for finish
  211.         WAITPID ;не должно быть, если команда была .bat!
  212.        ;ld (lastresult),hl
  213.  
  214. ;set current path
  215.         ld de,curpath
  216.         OS_CHDIR
  217.         jp setredrawflag
  218.        
  219. loadapp
  220. ;set system path
  221.         OS_SETSYSDRV
  222.         ld de,tcmd
  223.         OS_OPENHANDLE
  224.         or a
  225.          push af
  226.         ld a,b
  227.         ld (curhandle),a
  228.          pop af
  229.         ret nz ;jr nz,execcmd_error ;NC!
  230.        
  231. ;set path for newapp
  232.         ld de,curpath
  233.         OS_CHDIR
  234.        
  235.         OS_NEWAPP ;на момент создания должна быть включена текущая директория!!!
  236.         or a
  237.         ret nz ;error ;NC!
  238. ;dehl=номера страниц в 0000,4000,8000,c000 нового приложения, b=id, a=error
  239.        push bc ;b=id
  240.         ld a,d
  241.         SETPGC000
  242.         push de
  243.         push hl
  244.         ld hl,cmdbuf
  245.         ld de,0xc000+COMMANDLINE
  246.         call strcopy
  247.         pop hl
  248.         pop de
  249.         call readfile_pages_dehl
  250.         ld a,(curhandle)
  251.         ld b,a
  252.         OS_CLOSEHANDLE
  253.        pop de ;d=id
  254.         ld e,d ;e=id
  255.         xor a
  256.         ret ;Z
  257.  
  258. strcopy
  259. ;hl->de
  260. strcopy0
  261.         ld a,(hl)
  262.         ldi
  263.         or a
  264.         jr nz,strcopy0
  265.         ret
  266.  
  267. readfile_pages_dehl
  268.         ld a,d
  269.         SETPGC000
  270.         ld a,0xc100/256
  271.         call cmd_loadpage
  272.         ret nz
  273.         ld a,e
  274.         call cmd_loadfullpage
  275.         ret nz
  276.         ld a,h
  277.         call cmd_loadfullpage
  278.         ret nz
  279.         ld a,l
  280. cmd_loadfullpage
  281.         SETPGC000
  282.         ld a,0xc000/256
  283. cmd_loadpage
  284. ;out: a=error
  285. ;keeps hl,de
  286.         push de
  287.         push hl
  288.         ld d,a
  289.         xor a
  290.         ld l,a
  291.         ld e,a
  292.         sub d
  293.         ld h,a ;de=buffer, hl=size
  294. curhandle=$+1
  295.         ld b,0
  296.         OS_READHANDLE
  297.         pop hl
  298.         pop de
  299.         or a
  300.         ret
  301.  
  302. curpath
  303.         ds MAXPATH_sz
  304. tcmd
  305.         db "cmd.com",0
  306. cmdbuf
  307.         db "cmd build.bat",0
  308.  
  309.         include "prdword.asm"
  310.         include "textview.asm"
  311.         include "text_mem.asm"
  312.         include "../_sdk/stdio.asm"
  313.  
  314. filesize
  315.         dw 0
  316. filesizeHSW
  317.         dw 0
  318.  
  319. defaultfilename
  320.         db "1.txt",0
  321.        
  322. cmd_end
  323.  
  324.         display "Size ",/d,cmd_end-cmd_begin," bytes"
  325.  
  326.         savebin "texted.com",cmd_begin,cmd_end-cmd_begin
  327.        
  328.         LABELSLIST "../../us/user.l"
  329.