Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2.         org     0x0
  3.  
  4.         db      'MENUET01'      ; 8 byte id
  5.         dd      38              ; required os
  6.         dd      STARTAPP        ; program start
  7.         dd      I_END           ; program image size
  8.         dd      0x100000        ; required amount of memory
  9.         dd      0x100000        ; reserved= extended header
  10.         dd      filename, 0x0   ; I_Param , I_Icon
  11.  
  12. include "aspAPI.inc"
  13.  
  14. ;Clock_Hz       equ     4608    ; Frequency of clock
  15. ;Monitor_Hz     equ     70      ; Frequency of monitor
  16. ;Clock_Scale    equ     Clock_Hz / Monitor_Hz
  17. CData           equ     0x40    ; Port number of timer 0
  18. CMode           equ     0x43    ; Port number of timer control word
  19. BufSize         equ     65528   ; Frame buffer size - Must be even
  20.  
  21. struc   MainHeaderRec
  22. {
  23.         .Padding1       dd      ?       ; size of the file
  24.         .ID             dw      ?       ; magic
  25.         .Frames         dw      ?       ; frames
  26.         .Padding2       dd      ?       ; width/height
  27.         .Padding3       dd      ?       ; depth/flags
  28.         .Speed          dw      ?       ; speed
  29.         .Reserv         dw      ?       ; always = 0
  30.         ; Only for FLC
  31.         .Created        dd      ?       ; date file attribute
  32.         .Creator        dd      ?       ; creator serial number
  33.         .Updated        dd      ?       ; date of the last change
  34.         .Updater        dd      ?       ; updater serial number
  35.         .Aspectx        dw      ?       ; scale by x
  36.         .Aspecty        dw      ?       ; scale by Y
  37.         .Padding4       db      38     dup(?)  ; Reserved. All zeroes.
  38.         .Oframe1        dd      ?       ; offset to the 1st frame
  39.         .Oframe2        dd      ?       ; offset to the 2nd frame
  40.         .Padding5       db      40     dup(?)  ; Reserved. All zeroes.
  41. }
  42.  
  43. struc   FrameHeaderRec
  44. {
  45.         .Size   dd      ?       ; size
  46.         .Padding1       dw      ?       ; magic
  47.         .Chunks dw      ?       ; chunks
  48.         .Padding2       db      8       dup(?)  ;Pad to 16 Bytes.       All zeroes.
  49. }
  50.  
  51.  
  52. ; in:           esi = pointer to the buffer
  53.  
  54. DrawFrame:
  55.         ; this is the routine that takes a frame and put it on the screen
  56.   @Fli_Loop:                                    ; main loop that goes through all the chunks in a frame
  57.     cmp  word [Chunks],0              ;are there any more chunks to draw?
  58.     je   @Exit
  59.     dec  word [Chunks]                ;decrement Chunks For the chunk to process now
  60.        
  61.         mov  ax, word [esi+4]           ; let AX have the ChunkType
  62.         add  esi, 6                  ; skip the ChunkHeader
  63.         cmp  ax, 0Bh                            ; is it a FLI_COLor chunk?
  64.         je   @Fli_Color
  65.         cmp  ax, 0Ch                            ; is it a FLI_LC chunk?
  66.         je   @Fli_Lc
  67.         cmp  ax, 0Dh                            ; is it a FLI_BLACK chunk?
  68.         je   @Fli_Black
  69.         cmp  ax, 0Fh                            ; is it a FLI_BRUN chunk?
  70.         je   @Fli_Brun
  71.         cmp  ax, 10h                            ; is it a FLI_COPY chunk?
  72.         je   @Fli_Copy
  73.         jmp  @Fli_Loop                          ; This command should not be necessary
  74.  
  75.   @Fli_Color:
  76.         mov  bx, word [esi]                     ; number of packets in this chunk (always 1?)
  77.         add  esi, 2                                     ; skip the NumberofPackets
  78. ;_________________________________________________________________________________________
  79.         mov  al, 0                                      ; start at color 0
  80.         xor  cx, cx                                     ; reset CX
  81.   @Color_Loop:
  82.         or   bx, bx                                     ; set flags
  83.         jz   @Fli_Loop                          ; Exit if no more packages
  84.         dec  bx                                         ; decrement NumberofPackages For the package to process now
  85.         mov  cl, byte [esi]                     ; first Byte in packet tells how many colors to skip
  86.         add  al, cl                                     ; add the skiped colors to the start to get the new start
  87.         mov  edi, pal
  88.         add     di,     cx
  89.  
  90.                 ;push  cx       ;----- save how many colors to skip ----->
  91.         mov  cl, byte [esi+1]           ; next Byte in packet tells how many colors to change
  92.         or   cl, cl                                     ; set the flags
  93.         jnz  @Jump_Over                         ; if NumberstoChange=0 then NumberstoChange=256
  94.         inc  ch                                         ; CH=1 and CL=0 => CX=256
  95.   @Jump_Over:
  96.         ;add  al, cl                                     ; update the color to start at
  97.         add  esi, 2                                     ; skip the NumberstoSkip and NumberstoChange Bytes
  98.         .set_next_color:
  99.              lodsb         ; B
  100.              shl     al, 2 ; Enlight the color r*4, g*4, b*4
  101.              push    ax
  102.  
  103.              lodsb         ; G
  104.              shl     al, 2 ; Enlight the color r*4, g*4, b*4
  105.              push    ax
  106.  
  107.              lodsb         ; R
  108.              shl     al, 2 ; Enlight the color r*4, g*4, b*4
  109.  
  110.              stosb         ; R
  111.              pop     ax
  112.              stosb         ; G
  113.              pop     ax
  114.              stosb         ; B
  115.              xor     al, al
  116.              stosb         ; 0
  117.           loop  .set_next_color
  118.  
  119.         jmp  @Color_Loop                        ; finish With this packet - jump back
  120.   @Fli_Lc:
  121.         mov  di, word [esi]                     ; put LinestoSkip into DI -
  122.         mov  ax, di                                     ; - to get the offset address to this line we have to multiply With 320 -
  123.         shl  ax, 8                                      ; - DI = old_DI shl 8 + old_DI shl 6 -
  124.         shl  di, 6                                      ; - it is the same as DI = old_DI*256 + old_DI*64 = old_DI*320 -
  125.         add  di, ax                                     ; - but this way is faster than a plain mul
  126.                 add  edi, dword [image]
  127.         mov  bx, word [esi+2]           ; put LinestoChange into BX
  128.         add  esi, 4                                     ; skip the LinestoSkip and LinestoChange Words
  129.         xor  cx, cx                                     ; reset cx
  130.   @Line_Loop:
  131.         or   bx, bx                                     ; set flags
  132.         jz   @Fli_Loop                          ; Exit if no more lines to change
  133.         dec  bx
  134.         mov  dl, byte [esi]                     ; put PacketsInLine into DL
  135.         inc  esi                                                ; skip the PacketsInLine Byte
  136.         push edi                                                ; save the offset address of this line
  137.   @Pack_Loop:
  138.         or   dl, dl                                     ; set flags
  139.         jz   @Next_Line                         ; Exit if no more packets in this line
  140.  
  141.         dec  dl
  142.         mov  cl, byte [esi]                     ; put BytestoSkip into CL
  143.         add  di, cx                                     ; update the offset address
  144.         mov  cl, byte [esi+1]           ; put BytesofDatatoCome into CL
  145.         or   cl, cl                                     ; set flags
  146.         jns  @Copy_Bytes                        ; no SIGN means that CL number of data is to come -
  147.                                                                 ; - else the next data should be put -CL number of times
  148.         mov  al, byte [esi+2]           ; put the Byte to be Repeated into AL
  149.         add  esi, 3                                     ; skip the packet
  150.         neg  cl                                         ; Repeat -CL times
  151.         rep  stosb
  152.         jmp  @Pack_Loop                         ; finish With this packet
  153.   @Copy_Bytes:
  154.         add  esi, 2                                     ; skip the two count Bytes at the start of the packet
  155.         rep  movsb
  156.         jmp  @Pack_Loop                         ; finish With this packet
  157.   @Next_Line:
  158.         pop  edi                                                ; restore the old offset address of the current line
  159.         add  edi, 320                           ; offset address to the next line
  160.         jmp  @Line_Loop
  161.   @Fli_Black:
  162.         mov  edi, dword [image]
  163.         mov  cx, 32000                          ; number of Words in a screen
  164.         xor  ax, ax                                     ; color 0 is to be put on the screen
  165.         rep  stosw
  166.         jmp  @Fli_Loop                          ; jump back to main loop
  167.   @Fli_Brun:
  168.         mov  edi, dword [image]
  169.         mov  bx, 200                            ; numbers of lines in a screen
  170.         xor  cx, cx
  171.   @Line_Loop2:
  172.         mov  dl, byte [esi]                     ; put PacketsInLine into DL
  173.         inc  esi                                                ; skip the PacketsInLine Byte
  174.         push edi                                                ; save the offset address of this line
  175.   @Pack_Loop2:
  176.         or   dl, dl                                     ; set flags
  177.         jz   @Next_Line2                        ; Exit if no more packets in this line
  178.         dec  dl
  179.         mov  cl, byte [esi]                     ; put BytesofDatatoCome into CL
  180.         or   cl, cl                                     ; set flags
  181.         js   @Copy_Bytes2                       ; SIGN meens that CL number of data is to come -
  182.                                                                 ; - else the next data should be put -CL number of times
  183.         mov  al, byte [esi+1]           ; put the Byte to be Repeated into AL
  184.         add  esi, 2                                     ; skip the packet
  185.         rep  stosb
  186.         jmp  @Pack_Loop2                        ; finish With this packet
  187.   @Copy_Bytes2:
  188.         inc  esi                                                ; skip the count Byte at the start of the packet
  189.         neg  cl                                         ; Repeat -CL times
  190.         rep  movsb
  191.         jmp  @Pack_Loop2                        ; finish With this packet
  192.   @Next_Line2:
  193.         pop  edi                                                ; restore the old offset address of the current line
  194.         add  edi, 320                           ; offset address to the next line
  195.         dec  bx                                         ; any more lines to draw?
  196.         jnz  @Line_Loop2
  197.         jmp  @Fli_Loop                          ; jump back to main loop
  198.   @Fli_Copy:
  199.         mov  edi, dword [image]
  200.         mov  cx, 32000                          ; number of Words in a screen
  201.         rep  movsw
  202.         jmp  @Fli_Loop                          ; jump back to main loop
  203.   @Exit:
  204.  
  205.                 mov     eax, 65
  206.                 mov     ebx, dword [image]
  207.                 mov     ecx, 320*65536+200
  208.                 mov     edx, 10*65536+100
  209.                 mov     esi, 8
  210.                 mov     edi, pal
  211.                 xor     ebp, ebp
  212.                 int     0x40
  213.        
  214.         ret     ; DrawFrame end.
  215.  
  216. TFliPlayer_Init:
  217.         mov     eax, 68         ; Init process memory
  218.         mov     ebx, 11
  219.         int     0x40
  220.         cmp     eax, BufSize   
  221.         jl      .fail  
  222.   .ok:
  223.     ;GetMem(Buffer,BufSize);
  224.         mov     eax, 68
  225.         mov     ebx, 12
  226.         mov     ecx, BufSize
  227.         int     0x40
  228.         mov     dword [Buffer], eax
  229.  
  230.                 ;GetMem(image,32000);
  231.                 mov     eax, 68
  232.                 mov     ebx, 12
  233.                 mov     ecx, 320*200*4          ;32000
  234.                 int     0x40
  235.                 mov     dword [image], eax
  236.  
  237.        
  238.     mov word [Interval],  -1    ; ClearSpeed
  239.         mov     ax,     1
  240.         ret
  241.   .fail:
  242.         xor     ax, ax
  243.         ret     ; TFliPlayer_Init end.
  244.  
  245. TFliPlayer_Done:
  246.     ;FreeMem(Buffer,BufSize);
  247.         mov     eax, 68
  248.         mov     ebx, 13
  249.         mov     ecx, dword [Buffer]
  250.         int     0x40
  251.  
  252.                 ;FreeMem(image,32000);
  253.         mov     eax, 68
  254.         mov     ebx, 13
  255.         mov     ecx, dword [image]
  256.         int     0x40
  257.  
  258.         ret     ; TFliPlayer_Done end.
  259.  
  260. ;       in:     ax = Speed
  261. ;TFliPlayer_SetSpeed:
  262. ;       mov     bl,     byte Clock_Scale
  263. ;       mul     bl
  264. ;    mov        word [Interval], ax     ;= Speed * Clock_Scale;
  265. ;       ret     ; TFliPlayer_SetSpeed end.
  266.  
  267.  
  268.  
  269. ReadHeader: ;Boolean;
  270.         ;BlockRead(FliFile,MainHeader,SizeOf(MainHeader))       ; Read header record
  271.         mov     eax, dword [filepos]
  272.         mov     dword [InfoStructure+4], eax
  273.         mov     dword [InfoStructure+12], 128
  274.         mov     dword [InfoStructure+16], MainHeader
  275.         mov     eax, 70
  276.         mov     ebx, InfoStructure
  277.        
  278.         int     0x40
  279.        
  280.         mov     eax, 128
  281.         mov     dword [filepos], eax
  282.        
  283.     mov ax, word [MainHeader.ID]
  284.         cmp     ax, 0xAF11 ; FLI ?
  285.         je      .fli
  286.  
  287.         cmp     ax, 0xAF12 ; FLC ?
  288.         je      .flc
  289.  
  290.         xor     ax,     ax      ; Not a .FLI File
  291.         ret
  292.   .fli:
  293.         mov     byte [filetype], 1
  294.         jmp     .ok
  295.   .flc:
  296.         mov     byte [filetype], 2
  297.   .ok:
  298. ;       cmp     word [Interval], -1
  299. ;       jne     @f
  300. ;       ; Read speed from header
  301. ;       mov     ax,     word [MainHeader.Speed]
  302. ;       mov     bl,     byte Clock_Scale
  303. ;       mul     bl
  304. ;    mov        word [Interval], ax     ;= Speed * Clock_Scale;
  305.         mov     ax, 1
  306. ;  @@:
  307.         ret     ; ReadHeader end.
  308.  
  309. ReadFrame:
  310.         ;BlockRead(FliFile,FrameHeader,SizeOf(FrameHeader));
  311.         mov     eax, dword [filepos]
  312.         mov     dword [InfoStructure+4], eax
  313.         mov     dword [InfoStructure+12], 16
  314.         mov     dword [InfoStructure+16], FrameHeader
  315.         mov     eax, 70
  316.         mov     ebx, InfoStructure
  317.        
  318.         int     0x40
  319.  
  320.         add     dword [filepos], 16
  321.         ;FrameSize := FrameHeader.Size - SizeOf(FrameHeader);
  322.         mov     eax, dword [FrameHeader.Size]
  323.         sub     eax, 16
  324.         mov dword [FrameSize], eax
  325.     xor ecx, ecx
  326.  
  327.         ret     ; ReadFrame end.
  328.  
  329. ProcessFrame:
  330.         ;BlockRead(FliFile,Buffer^,FrameSize);
  331.         mov     eax, dword [filepos]
  332.         mov     dword [InfoStructure+4], eax
  333.         mov     eax,    dword [FrameSize]
  334.         mov     dword [InfoStructure+12], eax
  335.         mov     eax, dword [Buffer]
  336.         mov     dword [InfoStructure+16], eax
  337.         mov     eax, 70
  338.         mov     ebx, InfoStructure
  339.        
  340.         int     0x40
  341.  
  342.         mov     eax,    dword [FrameSize]
  343.         add     dword [filepos], eax
  344.         mov     esi, dword [Buffer]
  345.         mov     dx, word [FrameHeader.Chunks]
  346.         mov     word [Chunks], dx
  347.         call DrawFrame
  348.        
  349.         ret     ; ProcessFrame end.
  350.        
  351.        
  352. ;       in:     esi = pointer to the filename
  353. TFliPlayer_Play:
  354.         mov     eax, 70
  355.         mov     ebx, InfoStructure
  356.         mov     dword [InfoStructure+12], 1
  357.         mov     dword [InfoStructure+16], FrameHeader
  358.         int     0x40
  359.         test    ax,     ax
  360.         jnz     .err
  361.  
  362.         call    ReadHeader
  363.         test    ax,     ax
  364.         jz      .err
  365.  
  366.         call    ReadFrame
  367.  
  368.         mov     eax, dword [FrameSize]
  369.         add     eax, 128+16
  370.         mov     dword [RestartPos], eax
  371.         call    ProcessFrame
  372.  
  373.  
  374.   .play_again:
  375.         mov     word [Frame], 1
  376.           .show_next_frame:
  377.                        
  378.                         call    ReadFrame
  379.                         cmp     dword [FrameSize], 0
  380.                         je      @f
  381.                         call    ProcessFrame
  382.                   @@:
  383.  
  384.                   ;REPEAT UNTIL GetClock > Timeout;
  385.                         mov     eax, 5
  386.                         mov     ebx, 2
  387.                         int     0x40
  388.                        
  389.                         push    edi            
  390.                         call    process_events
  391.                         pop     edi
  392.  
  393.                         mov     al, byte [stop]
  394.                         cmp     al, 1
  395.                         je      .end
  396.                        
  397.                         mov     ax, word [Frame]
  398.                         inc     ax
  399.                         mov     word [Frame], ax
  400.  
  401.                         cmp     ax, word [MainHeader.Frames]
  402.                         jng     .show_next_frame
  403.                 mov     eax,    dword [RestartPos]
  404.                 mov     dword [InfoStructure+4], eax
  405.                 mov     eax, 128
  406.                 mov     dword [filepos], eax
  407.  
  408.         jmp     .play_again
  409.   .end:
  410.         mov     dword [filepos], 0
  411.         xor     ax, ax
  412.   .err:
  413.  
  414.         ret     ; TFliPlayer_Play end.
  415.  
  416.  
  417. ;       in:     esi = pointer to filename
  418. AAPlay:
  419.         mov     byte [pausetime], 0
  420.         mov     byte [stop], 0
  421.         cmp     byte [playtime], 1
  422.         je      .end
  423.         call    unprint_error
  424.  
  425.         mov     byte [playtime], 1
  426.         call    TFliPlayer_Play
  427.         test    ax, ax
  428.         jz      .end
  429.         call    print_error
  430.   .end:
  431.         mov     byte [playtime], 0
  432.         ret     ; AAPlay end.
  433.  
  434.  
  435.        
  436. N_KEYCOLOR equ 0x00444444 ; Normal button color
  437. TEXTCOLOR  equ 0x80FFFFFF ; Text color
  438. BUTCAPCOLOR  equ 0x0000FF00 ; Button caption color
  439.  
  440.  
  441. unprint_error:
  442.         mov eax, 13
  443.         mov ebx, 10*65536+320
  444.         mov ecx, 50*65536+15
  445.         mov edx, 0 ; color
  446.         int 0x40
  447. ret
  448.  
  449. print_error:
  450.         ;call   unprint_error
  451.        
  452.         mov     ebx, 15*65536+54
  453.         mov     edx, error_text
  454.         mov     ecx, TEXTCOLOR - 0x0000FFFF
  455.         mov     eax, 4
  456.         int     0x40
  457.  
  458. ret
  459.  
  460. print_filename:
  461.         mov eax, 13
  462.         mov ebx, 10*65536+320
  463.         mov ecx, 30*65536+15
  464.         mov edx, 0 ; color
  465.         int 0x40
  466.  
  467.         mov     ebx, 15*65536+34
  468.         mov     edx, filename
  469.         mov     ecx, TEXTCOLOR - 0x00FF00FF
  470.         mov     eax, 4
  471.         int     0x40
  472.        
  473. ret
  474.  
  475. ;**********************************
  476. ;*  input: ecx = type of map      *
  477. ;**********************************
  478. get_keyboard_map:
  479.         mov     eax, 26
  480.         mov     ebx, 2
  481.         mov     edx, keymap
  482.         int     0x40
  483. ret
  484.  
  485. ;**********************************
  486. ;*  input: ecx = type of mode    *
  487. ;**********************************
  488. set_keyboard_mode:
  489.         mov     eax, 66
  490.         mov     ebx, 1     ; Set keyboard mode
  491.         int     0x40
  492. ret
  493.  
  494. get_control_keys_state:
  495.         mov     eax, 66
  496.         mov     ebx, 3
  497.         int     0x40
  498. ret
  499.  
  500. reload_ascii_keymap:
  501.         pusha
  502.         call    get_control_keys_state
  503.         mov     ecx, 1
  504.  
  505.         test    ax, 1                           ; Left  Shift pressed ?
  506.         jnz      @f
  507.         test    ax, 2                           ; Right Shift pressed ?
  508.         jnz      @f
  509.         test    ax, 0x40                        ; Caps  Lock  on ?
  510.         jz      .load_ascii_keymap
  511.       @@:
  512.         mov     ecx, 2
  513.       .load_ascii_keymap:
  514.         call    get_keyboard_map
  515.         popa
  516.   ret
  517.  
  518.  
  519. STARTAPP:
  520.  
  521.         call    TFliPlayer_Init
  522.         test    ax, ax
  523.         jz      close_app
  524.  
  525.         mov     ecx, 1     ; to send scancodes.
  526.         call    set_keyboard_mode
  527.         call    reload_ascii_keymap
  528.         call    draw_window
  529.         call    print_filename
  530.  
  531.         cmp  [filename], byte 0
  532.         je   .noparam
  533.         call    AAPlay
  534.   .noparam:
  535.         jmp     still
  536.  
  537.  
  538. draw_window:
  539.         start_draw_window 20,170,340,310,0x14224466,labelt
  540.         draw_button 15,70,20,20,2,N_KEYCOLOR,keyText,1,BUTCAPCOLOR              ; Play
  541.  
  542.         mov     ecx, BUTCAPCOLOR
  543.  
  544.         mov     edx, keyText
  545.         mov     ebx, 21*65536+77               ; |
  546.         call    out_symbol
  547.  
  548.         mov     edx, keyText+1
  549.         mov     ebx, 22*65536+75               ; -
  550.         call    out_symbol
  551.  
  552.         mov     ebx, 24*65536+76               ; -
  553.       @@:
  554.         call    out_symbol
  555.         inc     ebx
  556.         cmp     ebx, 24*65536+79
  557.         jl      @b
  558.                
  559.         mov     ebx, 22*65536+79               ; -
  560.         call    out_symbol
  561.  
  562.         mov     ebx, 26*65536+77               ; -
  563.         call    out_symbol
  564.                
  565.         draw_button 45,70,20,20,3,N_KEYCOLOR,keyText,1,BUTCAPCOLOR              ; Pause
  566.  
  567.         mov     ecx, BUTCAPCOLOR
  568.  
  569.         mov     edx, keyText
  570.         mov     ebx, 49*65536+77               ; |
  571.         call    out_symbol
  572.  
  573.         mov     ebx, 51*65536+77               ; |
  574.         call    out_symbol
  575.  
  576.         mov     ebx, 54*65536+77               ; |
  577.         call    out_symbol
  578.  
  579.         mov     ebx, 55*65536+77               ; |
  580.         call    out_symbol
  581.  
  582.         mov     ebx, 56*65536+77               ; |
  583.         call    out_symbol
  584.  
  585.         draw_button 75,70,20,20,4,N_KEYCOLOR,keyText,1,BUTCAPCOLOR              ; Stop
  586.  
  587.         bar     81,77,8,7,BUTCAPCOLOR
  588.  
  589.         end_draw_window
  590.         ret
  591.  
  592. process_events:
  593.         mov     eax, 11             ; Test if there is an event in the queue.
  594.         int     0x40
  595.  
  596.         cmp     eax,1                  ; redraw request ?
  597.         jnz     @f
  598.         call    red
  599.         ret
  600.       @@:              
  601.         cmp     eax,3                  ; button in buffer ?
  602.         jnz     @f
  603.         call    button
  604.         ret
  605.       @@:
  606.         cmp     eax,2                  ; key in buffer ?
  607.         jnz     @f
  608.  
  609.         call    key
  610.       @@:
  611.         ;jz      key
  612.       ;  cmp     eax, 2
  613.       ;  jnz     @f
  614.       ;
  615.       ;  cmp     byte [playtime], 0
  616.       ;  je      @f
  617.         ;int     0x40
  618.       ;@@:
  619.  
  620.         ret    
  621.        
  622. still:
  623.         call    process_events
  624.         jmp     still
  625.  
  626. red:
  627.         call    draw_window
  628.         ret     ;jmp    still
  629.  
  630. key:
  631.         mov     eax, 2
  632.         int     0x40
  633.  
  634.         test    al, al
  635.         jnz     .end
  636.  
  637.         cmp     ah, 1 ; Esc
  638.         jne     @f
  639.         jmp     close_app
  640.   @@:
  641.         cmp     ah, 28 ; Enter
  642.         jne     @f
  643.         call    AAPlay
  644.         jmp     .end
  645.   @@:
  646.         cmp     ah, 15 ; Tab
  647.         je      .end
  648.         cmp     ah, 29 ; Left Control
  649.         je      .end
  650.         cmp     ah, 42 ; Left Shift
  651.         je      .end
  652.  
  653.         cmp     ah, 14 ; BackSpace
  654.         jne     @f
  655.        
  656.         ; strlen(filename)
  657.         mov     edi, filename
  658.         xor     al, al  ; search for the end of the filename
  659.         repne   scasb
  660.         cmp     edi, filename+2
  661.         jl      .end
  662.  
  663.         cmp     edi, filename+2
  664.         jl      .end
  665.         mov     byte [edi-2], 0
  666.        
  667.         call    print_filename
  668.         jmp     .end
  669.  
  670.   @@:
  671.         cmp     ah, 57 ; Space
  672.         je      .input_symbol
  673.         cmp     ah, 2
  674.         jl      .end
  675.         cmp     ah, 54
  676.         jg      .end
  677.  
  678.   .input_symbol:
  679.         mov     byte [stop], 1
  680.         call    reload_ascii_keymap
  681.         ; strlen(filename)
  682.         mov     edi, filename
  683.         xor     al, al  ; search for the end of the filename
  684.         repne   scasb
  685.         cmp     edi, filename+52
  686.         jg      .end
  687.        
  688.         shr     ax, 8
  689.         and     eax, 0x7F
  690.         mov     al, byte [keymap+eax]   ; Read ASCII from the keymap table.
  691.         mov     byte [edi-1], al
  692.         mov     byte [edi], 0
  693.        
  694.         call    print_filename
  695.   .end:
  696.         ret
  697.        
  698. button:
  699.         mov     eax, 17             ; Get pressed button code
  700.         int     0x40
  701.  
  702.         cmp     ah, 1               ; Test x button
  703.         je      close_app
  704.  
  705.         cmp     ah, 2               ; Test "Play" button
  706.         jne     @f
  707.         call    AAPlay
  708.         jmp     .end
  709.   @@:
  710.        
  711.         cmp     ah, 3               ; Test "Pause" button
  712.         jne     @f
  713.         cmp     byte [playtime], 1
  714.         jne     @f
  715.        
  716.         not     byte [pausetime]
  717.       .pause:
  718.         call    process_events
  719.         cmp     byte [pausetime], 0
  720.         jne     .pause
  721.  
  722.   @@:
  723.         cmp     ah, 4               ; Test "Stop" button
  724.         jne     @f
  725.         mov     byte [stop], 1
  726.         jne     @f
  727.   @@:
  728.  
  729.   .end:
  730.         ret
  731. close_app:
  732.  
  733.     cmp     dword [image], 0
  734.     je      @f
  735.     call    TFliPlayer_Done
  736.   @@:
  737.     mov  eax,-1                  ; close this program
  738.     int  0x40
  739.        
  740.        
  741. ; DATA  
  742. ; Application Title
  743. labelt          db      'FLI Player v0.31',0
  744. keyText         db      '|-_'
  745.  
  746.  
  747. error_text      db      "Can't load file.",0
  748. filepos         dd      0x0
  749. filetype        db      0     ; 0 - unsupported, 1 - fli, 2 - flc
  750.  
  751. playtime        db      0
  752. pausetime       db      0
  753. stop            db      0
  754.  
  755. pal             rb      256*4
  756. image           dd      0
  757. InfoStructure: 
  758.                         dd      0x0     ; subfunction number
  759.                         dd      filepos ; position in the file in bytes
  760.                         dd      0x0     ; upper part of the position address
  761.                         dd      0x0     ; number of     bytes to read
  762.                         dd      0x0     ; pointer to the buffer to write data
  763.                         db      0
  764.                         dd      filename
  765.  
  766. keymap  rb      128
  767.                        
  768. I_END:
  769.  
  770. Buffer          dd      ?
  771. Interval        dw      ?
  772.  
  773. Chunks          dw      ?
  774.  
  775. FrameSize       dd      ?
  776. RestartPos      dd      ?
  777. Frame           dw      ?
  778.  
  779. MainHeader      MainHeaderRec
  780. FrameHeader     FrameHeaderRec
  781.  
  782. filename        db      '/hd0/2/',0
  783.                 rb      46
  784.  
  785.