Subversion Repositories NedoOS

Rev

Rev 592 | Rev 1511 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.  
  4. COLOR=7
  5. module=0x6000;0xc000
  6.        
  7.                
  8.         org PROGSTART
  9. cmd_begin
  10.         ld sp,0x4000 ;не должен опускаться ниже #3b00! иначе возможна порча OS
  11.         OS_HIDEFROMPARENT
  12.         ld e,6 ;textmode
  13.         OS_SETGFX
  14.         ;call initstdio
  15.  
  16.         OS_GETMAINPAGES ;out: dehl=номера страниц в 0000,4000,8000,c000, c=flags, b=id
  17.         ld a,e
  18.         ld (musicpage),a
  19.         ld a,b
  20.         ld (myid),a
  21.         push hl
  22.         ld e,h
  23.         OS_DELPAGE
  24.         pop hl
  25.         ld e,l
  26.         OS_DELPAGE
  27.  
  28. ;TODO найти копию себя в памяти и послать ей 0 в COMMANDLINE
  29.         ld e,1 ;no id 0
  30. cmd_proc0
  31.         push de
  32.         ld a,e
  33. myid=$+1
  34.         cp 0
  35.         jr z,cmd_proc_skip
  36.         OS_GETAPPMAINPAGES ;out: d,e,h,l=pages in 0000,4000,8000,c000, c=flags, a=error
  37.         or a
  38.         jr nz,cmd_proc_skip
  39.         ld a,d ;main page
  40.         SETPG32KHIGH
  41.         ld de,COMMANDLINE+0xc000
  42.         ld hl,ttestdata
  43.         ld bc,ttestdata_sz
  44. testdata0
  45.         ld a,(de)
  46.         or 0x20
  47.         cp (hl)
  48.         jr nz,cmd_proc_skip
  49.         inc de
  50.         cpi
  51.         jp pe,testdata0
  52.         xor a
  53.         ld (COMMANDLINE+0xc000),a ;ok ;"закройся"
  54. cmd_proc_skip
  55.         pop de
  56.         inc e
  57.         ld a,e
  58.         inc a ;no id 0xff
  59.         jr nz,cmd_proc0
  60.  
  61. ;а как заглушить музыку, если не опрашивать клаву?
  62. ;если опрашивать, то нужен терминал
  63. ;можно было бы в nv.ext прописать cmd.com start term.com player.com, но такие конструкции пока не поддержаны ни в nv, ни в term
  64. ;поэтому пока без терминала
  65.        
  66.         ld hl,wasplayer
  67.         ld de,0x4000
  68.         ld bc,szplayer
  69.         ldir
  70.        
  71.         ld hl,COMMANDLINE ;command line
  72.         call skipword
  73.         call skipspaces
  74.         ld a,(hl)
  75.         or a
  76.         jr z,noautoload
  77.         ld (filenameaddr),hl
  78. ;command line = "texted <file to load>"
  79.         ;ld (texted_filenameaddr),hl
  80.         ex de,hl ;de=drive/path/file
  81.         OS_OPENHANDLE
  82. ;b=new file handle
  83.  
  84.         ld de,module;0xc000
  85.         ld hl,0xffff&(-module);0x4000
  86. ;B = file handle, DE = Buffer address, HL = Number of bytes to read
  87.         push bc
  88.         OS_READHANDLE
  89.         pop bc
  90.  
  91. ;B = file handle
  92.         OS_CLOSEHANDLE
  93.        
  94.         ld a,(module)
  95.         cp 'V'
  96.         jr z,$+4
  97.         cp 'P' ;'P'/'V' for PT3
  98.         ld a,%00100000 ;PT3
  99.         jr z,$+4
  100.         ld a,%00000010 ;PT2
  101.         ld (SETUP),a
  102.        
  103.         ld hl,module
  104.         ld a,(hl)
  105.         cp 'T'
  106.         push af
  107.         call nz,INIT
  108.         pop af
  109.         call z,tfmini
  110.  
  111. musicpage=$+1
  112.          ld a,0
  113.          ld hl,player
  114.          OS_SETMUSIC
  115.          
  116. mainloopredraw
  117.         ld e,COLOR
  118.         OS_CLS
  119. filenameaddr=$+1
  120.         ld hl,0
  121.         call prtext
  122.         ld a,0x0d
  123.         PRCHAR
  124.         ld a,0x0a
  125.         PRCHAR
  126.        
  127. mainloop
  128.         YIELD
  129.         ;di ;TODO fix player
  130.         ;call player
  131.         ;ei
  132.         ld a,(COMMANDLINE) ;ok
  133.         or a
  134.         jr z,quit
  135.        
  136.         GET_KEY
  137.       cp key_redraw
  138.       jr z,mainloopredraw
  139.         ;or a ;cp NOKEY ;keylang==0?
  140.         ;jr nz,$+2+1+2
  141.         ;cp c ;keynolang==0?
  142.         ;jr z,_1;1b;prwindow_waitkey_nokey
  143.         cp key_esc
  144.         jr nz,mainloop
  145. quit
  146.           ld a,(musicpage)
  147.           ld hl,muter
  148.           OS_SETMUSIC
  149.           halt
  150. noautoload
  151.         QUIT
  152.  
  153. ttestdata
  154.         db "player.com"
  155. ttestdata_sz=$-ttestdata
  156.  
  157. skipword
  158. ;hl=string
  159. ;out: hl=terminator/space addr
  160. getword0
  161.         ld a,(hl)
  162.         or a
  163.         ret z
  164.         cp ' '
  165.         ret z
  166.         inc hl
  167.         jr getword0
  168.  
  169. skipspaces
  170. ;hl=string
  171. ;out: hl=after last space
  172.         ld a,(hl)
  173.         cp ' '
  174.         ret nz
  175.         inc hl
  176.         jr skipspaces
  177.  
  178. prtext
  179. ;out: hl=after terminator
  180. prtext0
  181.         ld a,(hl)
  182.         inc hl
  183.         or a
  184.         ret z
  185.         push hl
  186.         PRCHAR
  187.         pop hl
  188.         jp prtext0
  189.  
  190.        
  191. ;oldtimer
  192. ;        dw 0
  193.  
  194.         ;include "../_sdk/stdio.asm"
  195.  
  196.         ;ds 0x4000-$
  197. wasplayer
  198.         disp 0x4000
  199. player
  200. ;a = port bd77 value
  201.         di
  202.         push af
  203.         and 0xf7;0xa0;%10101000 ;320x200 mode noturbo
  204.         ld bc,0xbd77    ;shadow ports and palette remain on
  205.         out (c),a
  206.  
  207.         ld a,(module)
  208.         cp 'T'
  209.         push af
  210.         ;push de
  211.         call nz,PLAY
  212.         ;pop de
  213.         pop af
  214.         call z,tfm
  215.        
  216.         pop af
  217.         ;LD A,0xa8;%10101000 ;320x200 mode
  218.         ld bc,0xbd77    ;shadow ports and palette remain on
  219.         out (c),a
  220.         ei
  221.         ret
  222. muter        
  223.         ld a,(module)
  224.         cp 'T'
  225.         push af
  226.         call nz,MUTE
  227.         pop af
  228.         call z,tfmshut
  229.         ret
  230.  
  231.         include "ptsplay.asm"
  232.         include "tfmplay.asm"
  233.         ent
  234. szplayer=$-wasplayer
  235.        
  236. cmd_end
  237.  
  238.         display "Size ",/d,cmd_end-cmd_begin," bytes"
  239.  
  240.         savebin "player.com",cmd_begin,cmd_end-cmd_begin
  241.        
  242.         ;LABELSLIST "../us/user.l"
  243.