?login_element?

Subversion Repositories NedoOS

Rev

Rev 1168 | Rev 1410 | 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.         include "prdword.asm"
  195.         include "textview.asm"
  196.         include "text_mem.asm"
  197.         include "../_sdk/stdio.asm"
  198.  
  199. filesize
  200.         dw 0
  201. filesizeHSW
  202.         dw 0
  203.  
  204. defaultfilename
  205.         db "1.txt",0
  206.        
  207. cmd_end
  208.  
  209.         display "Size ",/d,cmd_end-cmd_begin," bytes"
  210.  
  211.         savebin "texted.com",cmd_begin,cmd_end-cmd_begin
  212.        
  213.         LABELSLIST "../../us/user.l"
  214.