?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.  
  4.  
  5.         org PROGSTART
  6. cmd_begin
  7.         ld sp,0x4000 ;не должен опускаться ниже #3b00! иначе возможна порча OS
  8.        
  9.         ld hl,twinto866
  10. mktwinto866_0
  11.         ld e,(hl)
  12.         ld d,t866towin/256
  13.         ld a,l
  14.         ld (de),a
  15.         inc l
  16.         jr nz,mktwinto866_0
  17.  
  18.         ld hl,COMMANDLINE ;command line
  19.         call skipword
  20.         call skipspaces
  21.         ld a,(hl)
  22.         or a
  23.         jp z,noautoload
  24. ;command line = "texted <file to load>"
  25.         ld (texted_filenameaddr),hl
  26.         ex de,hl ;de=drive/path/file
  27.         OS_OPENHANDLE
  28. ;b=new file handle
  29.  
  30.         ld hl,0
  31.         ld d,h
  32.         ld e,l
  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.  
  43.         push bc
  44.        
  45.         push de
  46.         push hl
  47.         ld de,0xc000
  48.         ld hl,0x4000
  49. ;B = file handle, DE = Buffer address, HL = Number of bytes to read
  50.        push hl ;hl=bytes to read
  51.         OS_READHANDLE
  52. ;HL = Number of bytes actually read, A=error
  53.         ld b,h
  54.         ld c,l ;bc=bytes actually read
  55.        pop hl ;hl=bytes to read
  56.         or a
  57.         sbc hl,bc ;NZ = bytes to read != bytes actually read
  58.         pop hl
  59.         pop de
  60.  
  61.         ;push af ;NZ = bytes to read != bytes actually read
  62.         add hl,bc ;keep Z
  63.         jr nc,$+3
  64.         inc de
  65.         ;pop af ;NZ = bytes to read != bytes actually read
  66.  
  67.         pop bc
  68.         jr z,nvview_load0
  69. ;dehl=true file size
  70.         ld (filesize),hl
  71.         ld (filesizeHSW),de
  72.        
  73.         OS_CLOSEHANDLE
  74.        
  75.         call getsize ;ahl
  76.         ld b,a
  77.        if CONVBACK
  78.         ld d,t866towin/256
  79.        else
  80.         ld d,twinto866/256
  81.        endif
  82.         jr convloop_go
  83. convloop0
  84.         push hl
  85.         ld a,b
  86.         rl h
  87.         rla
  88.         rl h
  89.         rla
  90.         srl h
  91.         scf
  92.         rr h
  93.         push bc
  94.         ld c,a
  95.         ld b,textpages/256
  96.         ld a,(bc)
  97.         SETPG8000
  98.         pop bc
  99.         ld e,(hl)
  100.         ld a,(de)
  101.         ld (hl),a
  102.         pop hl
  103. convloop_go
  104.         ld a,h
  105.         or l
  106.         dec hl
  107.         jr nz,convloop0
  108.         ld a,b
  109.         sub 1
  110.         ld b,a
  111.         jr nc,convloop0
  112.        
  113. ;savefile
  114. texted_filenameaddr=$+1
  115.         ld de,0;defaultfilename
  116.         OS_CREATEHANDLE
  117.         or a
  118.         jr nz,nosavefile ;ret nz
  119. ;b=new file handle
  120.         push bc
  121.         ld a,b
  122.         ld (cmd_savepage_handle),a
  123.  
  124.         call getsize ;ahl
  125.         ld bc,textpages+0
  126.         ld e,a ;remaining HSW
  127.         ld d,c;0
  128. texted_save0
  129. ;a=page number in table (0..)
  130. ;hlde=remaining size
  131.         push bc ;pg
  132.         push hl ;remaining LSW
  133.         push de ;remaining HSW
  134.         ld a,h
  135.         and 0xc0
  136.         or d
  137.         or e
  138.         jr z,$+5 ;hl=remaining size
  139.         ld hl,0x4000 ;hl=maxsize (if remaining >= 0x4000)
  140.         ld a,(bc)
  141.         SETPG8000
  142.          push hl ;hl=pg size
  143. ;hl=size
  144. cmd_savepage_handle=$+1
  145.         ld b,0
  146.         ld de,0x8000
  147. ;B = file handle, DE = Buffer address, HL = Number of bytes to write
  148.         OS_WRITEHANDLE
  149. ;HL = Number of bytes actually written, A=error
  150.          pop bc ;bc=pg size
  151.         pop de ;remaining HSW
  152.         pop hl ;remaining LSW
  153.         or a
  154.         sbc hl,bc
  155.         jr nc,$+3
  156.         dec de ;size = size-pgsize
  157.         pop bc ;pg
  158.         inc c
  159.         ld a,h
  160.         or l
  161.         or d
  162.         or e
  163.         jr nz,texted_save0
  164.         pop bc ;b=handle
  165.         OS_CLOSEHANDLE
  166. nosavefile
  167. noautoload
  168.         QUIT
  169.  
  170. getsize
  171.         ld hl,(filesize)
  172.         ld a,(filesizeHSW)
  173.         ret
  174.  
  175.  
  176. skipword
  177. ;hl=string
  178. ;out: hl=terminator/space addr
  179. getword0
  180.         ld a,(hl)
  181.         or a
  182.         ret z
  183.         cp ' '
  184.         ret z
  185.         inc hl
  186.         jr getword0
  187.  
  188. skipspaces
  189. ;hl=string
  190. ;out: hl=after last space
  191.         ld a,(hl)
  192.         cp ' '
  193.         ret nz
  194.         inc hl
  195.         jr skipspaces
  196.  
  197.         include "text_mem.asm"
  198.  
  199.         display $
  200.         align 256
  201. twinto866
  202.         incbin "winto866"
  203. cmd_end
  204. t866towin
  205.         ds 256
  206.         align 256
  207. textpages
  208.         ds 256
  209. filesize
  210.         dw 0
  211. filesizeHSW
  212.         dw 0
  213.        
  214.  
  215.         display "Size ",/d,cmd_end-cmd_begin," bytes"
  216.  
  217.        if CONVBACK
  218.         savebin "866towin.com",cmd_begin,cmd_end-cmd_begin
  219.        else
  220.         savebin "winto866.com",cmd_begin,cmd_end-cmd_begin
  221.        endif
  222.  
  223.         LABELSLIST "../../us/user.l"
  224.