?login_element?

Subversion Repositories NedoOS

Rev

Rev 344 | Rev 608 | 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. ;text=#4000
  5. _COLOR=0x0007;7
  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 (fcb+FCB_FSIZE),de
  76.         ld (fcb+FCB_FSIZE+2),hl
  77.        
  78.         OS_CLOSEHANDLE
  79.        
  80.         ;ld hl,text
  81.         ;call prtext
  82. noautoload
  83.  
  84.         call textview
  85.         QUIT
  86.  
  87. ;out: hl=after terminator
  88.         if 1==1
  89. prtext
  90. ;hl=text
  91.         push hl
  92.         call strlen ;hl=length
  93.         pop de ;de=text
  94.         push de
  95.         push hl
  96.         call sendchars
  97.         pop hl
  98.         pop de
  99.         add hl,de
  100.         inc hl ;out: hl=after terminator
  101.         ret
  102.  
  103. strlen
  104. ;hl=str
  105. ;out: hl=length
  106.         ld bc,0 ;чтобы точно найти терминатор
  107.         xor a
  108.         cpir ;найдём обязательно, если длина=0, то bc=-1 и т.д.
  109.         ld hl,-1
  110.         or a
  111.         sbc hl,bc
  112.         ret
  113.         else
  114. prtext
  115. prtext0
  116.         ld a,(hl)
  117.         inc hl
  118.         or a
  119.         ret z
  120.         push hl
  121.         PRCHAR_
  122.         pop hl
  123.         jp prtext0
  124.         endif
  125.        
  126. skipword
  127. ;hl=string
  128. ;out: hl=terminator/space addr
  129. getword0
  130.         ld a,(hl)
  131.         or a
  132.         ret z
  133.         cp ' '
  134.         ret z
  135.         inc hl
  136.         jr getword0
  137.  
  138. skipspaces
  139. ;hl=string
  140. ;out: hl=after last space
  141.         ld a,(hl)
  142.         cp ' '
  143.         ret nz
  144.         inc hl
  145.         jr skipspaces
  146.  
  147. nv_setxy
  148. ;de=yx (kept)
  149. ;keeps hl
  150.         push de
  151.         push hl
  152.         push ix
  153.         SETXY_
  154.         pop ix
  155.         pop hl
  156.         pop de
  157.         ret
  158.        
  159. minhl_bc_tobc
  160.         or a
  161.         sbc hl,bc
  162.         add hl,bc
  163.         ret nc ;bc<=hl
  164.         ld b,h
  165.         ld c,l
  166.         ret
  167.  
  168.         include "prdword.asm"
  169.         include "textview.asm"
  170.         include "text_mem.asm"
  171.         include "../_sdk/stdio.asm"
  172.  
  173. ;oldtimer
  174. ;        dw 0
  175.        
  176. fcb
  177.         ds FCB_sz
  178. fcb_filename=fcb+FCB_FNAME        ;по умолчанию там длина 0
  179.        
  180. cmd_end
  181.  
  182.         display "Size ",/d,cmd_end-cmd_begin," bytes"
  183.  
  184.         savebin "texted.com",cmd_begin,cmd_end-cmd_begin
  185.        
  186.         ;LABELSLIST "../us/user.l"
  187.