?login_element?

Subversion Repositories NedoOS

Rev

Rev 608 | Rev 1191 | 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=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,COMMANDLINE ;command line
  20.         call skipword
  21.         call skipspaces
  22.         ld a,(hl)
  23.         or a
  24.         jr z,noautoload
  25. ;command line = "texted <file to load>"
  26.         ld (texted_filenameaddr),hl
  27.         ex de,hl ;de=drive/path/file
  28.         OS_OPENHANDLE
  29. ;b=new file handle
  30.  
  31.         ld hl,0
  32.         ld de,0
  33. nvview_load0
  34.         push bc
  35.         push de
  36.         push hl
  37.         call reservepage
  38.         pop hl
  39.         pop de
  40.         pop bc
  41.         ret nz ;no memory
  42.         ;ld a,#c000/256
  43.         ;call cmd_loadpage
  44.  
  45.         push bc
  46.        
  47.         push de
  48.         push hl
  49.         ld de,0xc000
  50.         ld hl,0x4000
  51. ;B = file handle, DE = Buffer address, HL = Number of bytes to read
  52.         OS_READHANDLE
  53. ;HL = Number of bytes actually read, A=error
  54.         ld b,h
  55.         ld c,l
  56.         ld hl,0x4000
  57.         or a
  58.         sbc hl,bc ;NZ = bytes to read != bytes actually read
  59.         pop hl
  60.         pop de
  61.  
  62.         push af ;NZ = bytes to read != bytes actually read
  63.         ex de,hl
  64.         add hl,bc
  65.         ex de,hl
  66.         jr nc,$+3
  67.         inc hl
  68.         pop af ;NZ = bytes to read != bytes actually read
  69.  
  70.         pop bc
  71.  
  72.         ;or a
  73.         jr z,nvview_load0
  74. ;hlde=true file size (for TRDOSFS)
  75.         ld (filesize),de
  76.         ld (filesizeHSW),hl
  77.        
  78.         OS_CLOSEHANDLE
  79.        
  80.         ;ld hl,text
  81.         ;call prtext
  82. noautoload
  83.         ld hl,(texted_filenameaddr)
  84.         ld de,tshown_filename
  85. ;copy hl->de no more than TSPACES_FILENAME_SZ bytes
  86.         ld b,TSPACES_FILENAME_SZ
  87.         call strcopy_maxb
  88.  
  89.         call textview
  90.         QUIT
  91.  
  92. strcopy_maxb
  93. ;copy hl->de no more than b bytes
  94. strcopy_maxb0
  95.         ld a,(hl)
  96.         or a
  97.         ret z
  98.         ld (de),a
  99.         inc hl
  100.         inc de
  101.         djnz strcopy_maxb0
  102.         ret
  103.  
  104. ;out: hl=after terminator
  105.         if 1==1
  106. prtext
  107. ;hl=text
  108.         push hl
  109.         call strlen ;hl=length
  110.         pop de ;de=text
  111.         push de
  112.         push hl
  113.         call sendchars
  114.         pop hl
  115.         pop de
  116.         add hl,de
  117.         inc hl ;out: hl=after terminator
  118.         ret
  119.  
  120. strlen
  121. ;hl=str
  122. ;out: hl=length
  123.         ld bc,0 ;чтобы точно найти терминатор
  124.         xor a
  125.         cpir ;найдём обязательно, если длина=0, то bc=-1 и т.д.
  126.         ld hl,-1
  127.         or a
  128.         sbc hl,bc
  129.         ret
  130.         else
  131. prtext
  132. prtext0
  133.         ld a,(hl)
  134.         inc hl
  135.         or a
  136.         ret z
  137.         push hl
  138.         PRCHAR_
  139.         pop hl
  140.         jp prtext0
  141.         endif
  142.        
  143. skipword
  144. ;hl=string
  145. ;out: hl=terminator/space addr
  146. getword0
  147.         ld a,(hl)
  148.         or a
  149.         ret z
  150.         cp ' '
  151.         ret z
  152.         inc hl
  153.         jr getword0
  154.  
  155. skipspaces
  156. ;hl=string
  157. ;out: hl=after last space
  158.         ld a,(hl)
  159.         cp ' '
  160.         ret nz
  161.         inc hl
  162.         jr skipspaces
  163.  
  164. nv_setxy
  165. ;de=yx (kept)
  166. ;keeps hl
  167.         push de
  168.         push hl
  169.         push ix
  170.         SETXY_
  171.         pop ix
  172.         pop hl
  173.         pop de
  174.         ret
  175.        
  176. minhl_bc_tobc
  177.         or a
  178.         sbc hl,bc
  179.         add hl,bc
  180.         ret nc ;bc<=hl
  181.         ld b,h
  182.         ld c,l
  183.         ret
  184.  
  185.         include "prdword.asm"
  186.         include "textview.asm"
  187.         include "text_mem.asm"
  188.         include "../_sdk/stdio.asm"
  189.  
  190. filesize
  191.         dw 0
  192. filesizeHSW
  193.         dw 0
  194.  
  195. defaultfilename
  196.         db "1.txt",0
  197.        
  198. cmd_end
  199.  
  200.         display "Size ",/d,cmd_end-cmd_begin," bytes"
  201.  
  202.         savebin "texted.com",cmd_begin,cmd_end-cmd_begin
  203.        
  204.         LABELSLIST "../../us/user.l"
  205.