Subversion Repositories Kolibri OS

Rev

Rev 7421 | Rev 7604 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. format binary as ""
  2.  
  3. use32
  4. org 0x0
  5.  
  6. db 'MENUET01'
  7. dd 0x01, START, I_END, F_END, stacktop, @PARAMS, sys_path
  8.  
  9. ;-----------------------------------------------------------------------------
  10.  
  11. include '../../../config.inc'
  12. include '../../../proc32.inc'
  13. include '../../../macros.inc'
  14. include '../../../dll.inc'
  15. include '../../../KOSfuncs.inc'
  16. ;include '../../../debug.inc'
  17.  
  18. include '../../../develop/libraries/libs-dev/libio/libio.inc'
  19. include '../../../develop/libraries/libs-dev/libimg/libimg.inc'
  20.  
  21. ;include '../../../develop/libraries/box_lib/asm/trunk/opendial.mac'
  22. ;use_OpenDialog
  23. ;-----------------------------------------------------------------------------
  24.  
  25. START:
  26.     mcall   SF_SYS_MISC, SSF_HEAP_INIT
  27.  
  28.     stdcall dll.Load, @IMPORT
  29.     or  eax, eax
  30.     jnz exit
  31.  
  32.     invoke  sort.START, 1
  33.  
  34.     mov ecx, 1  ; for 15.4: 1 = tile
  35.     cmp word [@PARAMS], '\T'
  36.     jz  set_bgr
  37.     inc ecx ; for 15.4: 2 = stretch
  38.     cmp word [@PARAMS], '\S'
  39.     jz  set_bgr
  40.  
  41.     cmp byte [@PARAMS], 0
  42.     jz @f
  43.     mov esi, @PARAMS
  44.     mov edi, path
  45.     mov ecx, 4096/4
  46.     rep movsd
  47.     mov byte [edi-1], 0
  48. @@:
  49. ; OpenDialog initialisation
  50.     push    dword OpenDialog_data
  51.     call    [OpenDialog_Init]
  52.  
  53. ; initialize keyboard handling
  54.     invoke  ini_get_shortcut, inifilename, aShortcuts, aNext, -1, next_mod
  55.     mov [next_key], eax
  56.     invoke  ini_get_shortcut, inifilename, aShortcuts, aPrev, -1, prev_mod
  57.     mov [prev_key], eax
  58.     invoke  ini_get_shortcut, inifilename, aShortcuts, aSlide, -1, slide_mod
  59.     mov [slide_key], eax
  60.     invoke  ini_get_shortcut, inifilename, aShortcuts, aTglbar, -1, tglbar_mod
  61.     mov [tglbar_key], eax
  62.     mcall   SF_KEYBOARD, SSF_SET_INPUT_MODE, 1    ; set kbd mode to scancodes
  63.  
  64.     cmp byte [@PARAMS], 0
  65.     jnz params_given
  66.  
  67.     mov [OpenDialog_data.draw_window],draw_window_fake
  68.    
  69. ; OpenDialog Open
  70.     push    dword OpenDialog_data
  71.     call    [OpenDialog_Start]
  72.  
  73.     cmp [OpenDialog_data.status],1
  74.     jne exit
  75.  
  76.     mov [OpenDialog_data.draw_window],draw_window
  77.  
  78.     mov esi, path
  79.     mov edi, @PARAMS
  80.     mov ecx, 4096/4
  81.     rep movsd
  82.     mov byte [edi-1], 0
  83.     jmp params_given
  84.  
  85. set_bgr:
  86.     mcall   SF_BACKGROUND_SET, SSF_MODE_BG
  87.     mov eax, @PARAMS + 4
  88.     call    load_image
  89.     jc  exit
  90.  
  91.     call    set_as_bgr
  92.     jmp exit
  93.  
  94. params_given:
  95.  
  96.     mov esi, @PARAMS
  97.     push    esi
  98.     call    find_last_name_component
  99.  
  100.     pop eax
  101.     call    load_image
  102.     jc  exit
  103.     call    generate_header
  104.  
  105. ;-----------------------------------------------------------------------------
  106.  
  107. red:
  108.     call    draw_window
  109.  
  110. still:
  111.     mov eax, [image]
  112.     test    byte [eax + Image.Flags], Image.IsAnimated
  113.     push    SF_WAIT_EVENT
  114.     pop eax
  115.     jz  @f
  116.     mcall   SF_SYSTEM_GET, SSF_TIME_COUNT
  117.     mov edx, [cur_frame]
  118.     mov ebx, [cur_frame_time]
  119.     add ebx, [edx + Image.Delay]
  120.     sub ebx, eax
  121.     cmp ebx, [edx + Image.Delay]
  122.     ja  red_update_frame
  123.     test    ebx, ebx
  124.     jz  red_update_frame
  125.     push    SF_WAIT_EVENT_TIMEOUT
  126.     pop eax
  127.   @@:
  128.     mcall
  129.     dec eax
  130.     js  red_update_frame
  131.     jz  red
  132.     dec eax
  133.     jnz button
  134.  
  135. key:
  136.     xor esi, esi
  137. keyloop:
  138.     mcall   SF_GET_KEY
  139.     test    al, al
  140.     jnz keyloopdone
  141.     shr eax, 8
  142.     mov ecx, eax
  143.     mcall   SF_KEYBOARD, SSF_GET_CONTROL_KEYS
  144.     mov edx, next_mod
  145.     call    check_shortcut
  146.     jz  .next
  147.     add edx, prev_mod - next_mod
  148.     call    check_shortcut
  149.     jz  .prev
  150.     add edx, slide_mod - prev_mod
  151.     call    check_shortcut
  152.     jz  .slide
  153.     add edx, tglbar_mod - slide_mod
  154.     call    check_shortcut
  155.     jz  .tglbar
  156.     cmp cl, 1 ; Esc
  157.     jz  .esc
  158.     jmp keyloop
  159. .esc:
  160.     test byte [bSlideShow], 1
  161.     jnz .slide
  162.     jmp keyloop
  163. .tglbar:
  164.     mov byte [bTglbar], 1
  165.     test byte[bSlideShow], 1
  166.     jnz @f
  167.     xor [toolbar_height], 31
  168. @@:
  169.     jmp keyloop
  170. .slide:
  171.     call slide_show
  172.     jmp keyloop
  173. .prev:
  174.     dec esi
  175.     jmp keyloop
  176. .next:
  177.     inc esi
  178.     jmp keyloop
  179. keyloopdone:
  180.     test esi, esi
  181.     jnz next_or_prev_handler
  182.     test byte [bSlideShow], 2
  183.     jnz red
  184.     test byte [bTglbar], 1
  185.     jnz red
  186.     jmp still
  187. next_or_prev_handler:
  188.     call    next_or_prev_image
  189.     jmp red
  190.  
  191. red_update_frame:
  192.     mov eax, [cur_frame]
  193.     mov eax, [eax + Image.Next]
  194.     test    eax, eax
  195.     jnz @f
  196.     mov eax, [image]
  197.   @@:
  198.     mov [cur_frame], eax
  199.     mcall   SF_SYSTEM_GET, SSF_TIME_COUNT
  200.     mov [cur_frame_time], eax
  201.     mcall   SF_THREAD_INFO, procinfo, -1
  202.     call    draw_cur_frame
  203.     jmp still
  204.  
  205. button:
  206.     mcall   SF_GET_BUTTON
  207.     shr eax, 8
  208.  
  209.     ; flip horizontally
  210.     cmp eax, 'flh'
  211.     jne @f
  212.  
  213.     invoke  img.flip, [image], FLIP_HORIZONTAL
  214.     jmp redraw_image
  215.  
  216.     ; flip vertically
  217.     @@: cmp eax, 'flv'
  218.     jne @f
  219.  
  220.     invoke  img.flip, [image], FLIP_VERTICAL
  221.     jmp redraw_image
  222.  
  223.     ; flip both horizontally and vertically
  224.     @@: cmp eax, 'flb'
  225.     jne @f
  226.  
  227.     invoke  img.flip, [image], FLIP_BOTH
  228.     jmp redraw_image
  229.  
  230.     ; rotate left
  231.     @@: cmp eax, 'rtl'
  232.     jne @f
  233.  
  234.     push    ROTATE_90_CCW
  235. .rotate_common:
  236.     invoke  img.rotate, [image]
  237.     mov eax, [image]
  238.     test    eax, eax    ; clear ZF flag
  239.     call    update_image_sizes
  240.     jmp redraw_image
  241.  
  242.     ; rotate right
  243.     @@: cmp eax, 'rtr'
  244.     jne @f
  245.  
  246.     push    ROTATE_90_CW
  247.     jmp .rotate_common
  248.  
  249.     ; open new file
  250.     @@: cmp eax, 'opn'
  251.     jne @f
  252.    
  253. ; OpenDialog Open
  254.     push    dword OpenDialog_data
  255.     call    [OpenDialog_Start]
  256.    
  257.     cmp [OpenDialog_data.status],1
  258.     jne still
  259.    
  260.     mov esi, path
  261.     mov edi, @PARAMS
  262.     push    edi
  263.     mov ecx, 4096/4
  264.     rep movsd
  265.     mov byte [edi-1], 0
  266.    
  267.     pop esi
  268.     push    esi
  269.     call    find_last_name_component
  270.  
  271.     pop eax
  272.     push    [image]
  273.     call    load_image
  274.     jc  .restore_old
  275.     call    generate_header
  276.    
  277.     invoke  img.destroy
  278.     call    free_directory
  279.     jmp red
  280.    
  281.     .restore_old:
  282.     pop [image]
  283.     call    init_frame
  284.     jmp still
  285.  
  286.     ; set background
  287.     @@:
  288.     cmp eax, 'bgr'
  289.     jne @f
  290.  
  291.     call    set_as_bgr
  292.     jmp still
  293.  
  294.     @@:
  295.     cmp eax, 'sld'
  296.     jne @f
  297.  
  298.     call    slide_show
  299.     jmp red
  300.  
  301.     @@:
  302.  
  303.     or  esi, -1
  304.     cmp eax, 'bck'
  305.     jz  next_or_prev_handler
  306.     neg esi
  307.     cmp eax, 'fwd'
  308.     jz  next_or_prev_handler
  309.  
  310.     cmp eax, 1
  311.     jne still
  312.  
  313.   exit:
  314.     mcall   SF_TERMINATE_PROCESS
  315.  
  316.   redraw_image = red
  317.  
  318. load_image:
  319.     and [img_data], 0
  320.     push    eax
  321.     invoke  file.open, eax, O_READ
  322.     or  eax, eax
  323.     jz  .error_pop
  324.     mov [fh], eax
  325.     invoke  file.size
  326.     mov [img_data_len], ebx
  327.     stdcall mem.Alloc, ebx
  328.     test    eax, eax
  329.     jz  .error_close
  330.     mov [img_data], eax
  331.     invoke  file.read, [fh], eax, [img_data_len]
  332.     cmp eax, -1
  333.     jz  .error_close
  334.     cmp eax, [img_data_len]
  335.     jnz .error_close
  336.     invoke  file.close, [fh]
  337.     inc eax
  338.     jz  .error
  339.  
  340.     invoke  img.decode, [img_data], [img_data_len], 0
  341.     or  eax, eax
  342.     jz  .error
  343.     cmp [image], 0
  344.     pushf
  345.     mov [image], eax
  346.     call    img_resize_to_screen
  347.     call    init_frame
  348.     popf
  349.     call    update_image_sizes
  350.     call    free_img_data
  351.     clc
  352.     ret
  353.  
  354. .error_free:
  355.     invoke  img.destroy, [image]
  356.     jmp .error
  357.  
  358. .error_pop:
  359.     pop eax
  360.     jmp .error
  361. .error_close:
  362.     invoke  file.close, [fh]
  363. .error:
  364.     call    free_img_data
  365.     stc
  366.     ret
  367.  
  368. align 4
  369. proc img_resize_to_screen uses eax ebx ecx edx
  370.         mov ebx, [image]
  371.         cmp     [ebx+Image.Type],Image.bpp24
  372.         jne .end_f
  373.         test [ebx+Image.Flags],Image.IsAnimated
  374.         jnz .end_f
  375.         mov eax, [ebx+Image.Data]      
  376.         mov [buf_0],eax
  377.         mov eax, [ebx+Image.Width]
  378.         mov [buf_0.w],eax
  379.         mov eax, [ebx+Image.Height]
  380.         mov [buf_0.h],eax
  381.  
  382.         mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
  383.         mov edx, [image_padding]
  384.         shl edx, 1
  385.         add edx, eax
  386.         mcall SF_GET_SCREEN_SIZE
  387.         mov ecx, eax
  388.         shr ecx, 17
  389.  
  390.         mov ebx, [image]
  391.         movzx eax,ax
  392.         sub eax, edx
  393.         sub eax, [toolbar_height]
  394.         sub eax, 5-1 ;5 px = border
  395.         cmp eax, 1
  396.         jle .end0
  397.         cmp eax, [ebx+Image.Height]
  398.         jl .end1
  399.         .end0:
  400.                 xor eax,eax
  401.                 jmp .end2
  402.         .end1:
  403.                 mov [ebx+Image.Height],eax
  404.         .end2:
  405.         sub ecx, [image_padding]
  406.         shl ecx, 1
  407.         sub ecx, 10-1 ;10 px = 2 borders
  408.         cmp ecx, 1
  409.         jle .end3
  410.         cmp ecx, [ebx+Image.Width]
  411.         jl .end4
  412.         .end3:
  413.                 xor ecx,ecx
  414.                 jmp .end5
  415.         .end4:
  416.                 mov [ebx+Image.Width],ecx
  417.         .end5:
  418.         cmp eax,ecx
  419.         jne @f
  420.                 test eax,eax
  421.                 jz .end_f
  422.         @@:
  423.         stdcall [buf2d_resize], buf_0, ecx, eax, 2
  424. .end_f:
  425.         ret
  426. endp
  427.  
  428. align 4
  429. free_img_data:
  430.     mov eax, [img_data]
  431.     test    eax, eax
  432.     jz  @f
  433.     stdcall mem.Free, eax
  434. @@:
  435.     ret
  436.  
  437. update_image_sizes:
  438.     pushf
  439.     mov edx, [eax + Image.Width]
  440.     test    [eax + Image.Flags], Image.IsAnimated
  441.     jnz .not_in_row
  442.     push eax
  443. @@: cmp [eax + Image.Next], 0
  444.     jz  @f
  445.     mov eax, [eax + Image.Next]
  446.     add edx, [eax + Image.Width]
  447.     inc edx
  448.     jmp @b
  449. @@: pop eax
  450. .not_in_row:
  451.     mov [draw_width], edx
  452.     add edx, 19
  453.     cmp edx, 50 + 25*numimages
  454.     jae @f
  455.     mov edx, 50 + 25*numimages
  456. @@:
  457. ;    dec edx
  458.     mov [wnd_width], edx
  459.     mov esi, [eax + Image.Height]
  460.     test    [eax + Image.Flags], Image.IsAnimated
  461.     jnz .max_equals_first
  462.     push eax
  463. @@: cmp [eax + Image.Next], 0
  464.     jz  @f
  465.     mov eax, [eax + Image.Next]
  466.     cmp esi, [eax + Image.Height]
  467.     jae @b
  468.     mov esi, [eax + Image.Height]
  469.     jmp @b
  470. @@: pop eax
  471. .max_equals_first:
  472.     mov [draw_height], esi
  473.     add esi, [toolbar_height]
  474.     add esi, [image_padding]
  475.     add esi, [image_padding]
  476.     add esi, 5  ; window bottom frame height
  477.     dec esi
  478.     mov [wnd_height], esi
  479.     popf
  480.     jz  .no_resize
  481.     test [wnd_style], 1 SHL 25
  482.     jz .no_resize
  483.     mcall   SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
  484.     add esi, eax
  485.     mcall   SF_CHANGE_WINDOW,-1,-1
  486. .no_resize:
  487.     ret
  488.  
  489. set_as_bgr:
  490.     mov esi, [image]
  491.     mov ecx, [esi + Image.Width]
  492.     mov edx, [esi + Image.Height]
  493.     mcall   SF_BACKGROUND_SET, SSF_SIZE_BG
  494.  
  495.     mcall   SF_BACKGROUND_SET, SSF_MAP_BG
  496.     test    eax, eax
  497.     jz  @f
  498.  
  499.     push    eax
  500.     invoke  img.to_rgb2, esi, eax
  501.     pop ecx
  502.     mcall   SF_BACKGROUND_SET, SSF_UNMAP_BG
  503.  
  504. @@:
  505.     mcall   SF_BACKGROUND_SET, SSF_REDRAW_BG
  506.  
  507.         ;save to file eskin.ini
  508.         xor al,al
  509.         mov ecx,1024
  510.         mov edi,sys_path+2
  511.         repne scasb
  512.         sub edi,sys_path+3
  513.         invoke  ini_set_str, inifileeskin, amain, aprogram, sys_path+2, edi
  514.         ;add param '\S__'
  515.         cmp word[@PARAMS],'\S'
  516.         je @f
  517.         mov esi, @PARAMS+4096-8
  518.     mov edi, @PARAMS+4096-4
  519.     mov ecx, 4096/4-1
  520.         std
  521.     rep movsd
  522.         cld
  523.         mov dword[@PARAMS],'\S__'
  524.         @@:
  525.         ;
  526.         xor al,al
  527.         mov ecx,4096
  528.         mov edi,@PARAMS
  529.         repne scasb
  530.         sub edi,@PARAMS+1
  531.         invoke  ini_set_str, inifileeskin, amain, aparam, @PARAMS, edi
  532.     ret
  533.  
  534. slide_show:
  535.     or  byte [bSlideShow], 2
  536.     xor byte [bSlideShow], 1
  537.     btc dword [wnd_style], 25
  538.     jc  @f
  539.     mov eax, [toolbar_height_old]
  540.     mov [toolbar_height], eax
  541.     mov [image_padding], 5
  542.     jmp .toolbar_height_done
  543. @@:
  544.     mov eax, [toolbar_height]
  545.     mov [toolbar_height_old], eax
  546.     mov [toolbar_height], 0
  547.     mov [image_padding], 0
  548. .toolbar_height_done:
  549.     ret
  550.  
  551. ; seek to ESI image files
  552. ; esi>0 means next file, esi<0 - prev file
  553. next_or_prev_image:
  554.     push    esi
  555.     call    load_directory
  556.     pop esi
  557.     mov ebx, [directory_ptr]
  558.     test    ebx, ebx
  559.     jz  .ret
  560.     cmp dword[ebx+4], 0
  561.     jz  .ret
  562.     mov eax, [cur_file_idx]
  563.     cmp eax, -1
  564.     jnz @f
  565.     test    esi, esi
  566.     jns @f
  567.     mov eax, [ebx+4]
  568. @@:
  569.     push    [image]
  570.     add eax, esi
  571. @@:
  572.     test    eax, eax
  573.     jns @f
  574.     add eax, [ebx+4]
  575.     jmp @b
  576. @@:
  577.     cmp eax, [ebx+4]
  578.     jb  @f
  579.     sub eax, [ebx+4]
  580.     jmp @b
  581. @@:
  582.     push    eax
  583. .scanloop:
  584.     push    eax ebx esi
  585.     imul    esi, eax, 304
  586.     add esi, [directory_ptr]
  587.     add esi, 32 + 40
  588.     mov edi, curdir
  589. @@:
  590.     inc edi
  591.     cmp byte [edi-1], 0
  592.     jnz @b
  593.     mov byte [edi-1], '/'
  594. @@:
  595.     lodsb
  596.     stosb
  597.     test    al, al
  598.     jnz @b
  599.     mov eax, curdir
  600.     call    load_image
  601.     pushf
  602.     mov esi, curdir
  603.     push    esi
  604.     mov edi, @PARAMS
  605.     mov ecx, 4096/4
  606.     rep movsd
  607.     mov byte [edi-1], 0
  608.     pop esi
  609. @@:
  610.     lodsb
  611.     test    al, al
  612.     jnz @b
  613. @@:
  614.     dec esi
  615.     cmp byte [esi], '/'
  616.     jnz @b
  617.     mov byte [esi], 0
  618.     popf
  619.     pop esi ebx eax
  620.     jnc .loadedok
  621.     test    esi, esi
  622.     js  .try_prev
  623. .try_next:
  624.     inc eax
  625.     cmp eax, [ebx+4]
  626.     jb  @f
  627.     xor eax, eax
  628. @@:
  629. .try_common:
  630.     cmp eax, [esp]
  631.     jz  .notfound
  632.     jmp .scanloop
  633. .try_prev:
  634.     dec eax
  635.     jns @f
  636.     mov eax, [ebx+4]
  637.     dec eax
  638. @@:
  639.     jmp .try_common
  640. .loadedok:
  641.     mov [cur_file_idx], eax
  642.     pop eax
  643.     invoke  img.destroy
  644.     call    generate_header
  645. .ret:
  646.     ret
  647. .notfound:
  648.     pop eax
  649.     pop [image]
  650.     call    init_frame
  651.     ret
  652.  
  653. load_directory:
  654.     cmp [directory_ptr], 0
  655.     jnz .ret
  656.     mov esi, @PARAMS
  657.     mov edi, curdir
  658.     mov ecx, [last_name_component]
  659.     sub ecx, esi
  660.     dec ecx
  661.     js  @f
  662.     rep movsb
  663. @@:
  664.     mov byte [edi], 0
  665.     mcall   SF_SYS_MISC, SSF_MEM_ALLOC, 0x1000
  666.     test    eax, eax
  667.     jz  .ret
  668.     mov ebx, readdir_fileinfo
  669.     mov dword [ebx+12], (0x1000 - 32) / 304
  670.     mov dword [ebx+16], eax
  671.     mcall   SF_FILE
  672.     cmp eax, 6
  673.     jz  .dirok
  674.     test    eax, eax
  675.     jnz free_directory
  676.     mov edx, [directory_ptr]
  677.     mov ecx, [edx+8]
  678.     mov [readblocks], ecx
  679.     imul    ecx, 304
  680.     add ecx, 32
  681.     mcall   SF_SYS_MISC, SSF_MEM_REALLOC
  682.     test    eax, eax
  683.     jz  free_directory
  684.     mov [directory_ptr], eax
  685.     mcall   SF_FILE, readdir_fileinfo
  686. .dirok:
  687.     cmp ebx, 0
  688.     jle free_directory
  689.     mov eax, [directory_ptr]
  690.     add eax, 32
  691.     mov edi, eax
  692.     push    0
  693. .dirskip:
  694.     push    eax
  695.     test    byte [eax], 18h
  696.     jnz .nocopy
  697.     lea esi, [eax+40]
  698.     mov ecx, esi
  699. @@:
  700.     lodsb
  701.     test    al, al
  702.     jnz @b
  703. @@:
  704.     dec esi
  705.     cmp esi, ecx
  706.     jb  .noext
  707.     cmp byte [esi], '.'
  708.     jnz @b
  709.     inc esi
  710.     mov ecx, [esi]
  711.     cmp byte[esi+3], 0
  712.     jne .not_3
  713.     or  ecx, 0x202020
  714.     cmp ecx, 'jpg'
  715.     jz  .copy
  716.     cmp ecx, 'bmp'
  717.     jz  .copy
  718.     cmp ecx, 'gif'
  719.     jz  .copy
  720.     cmp ecx, 'png'
  721.     jz  .copy
  722.     cmp ecx, 'jpe'
  723.     jz  .copy
  724.     cmp ecx, 'ico'
  725.     jz  .copy
  726.     cmp ecx, 'cur'
  727.     jz  .copy
  728.     cmp ecx, 'tga'
  729.     jz  .copy
  730.     cmp ecx, 'pcx'
  731.     jz  .copy
  732.     cmp ecx, 'xcf'
  733.     jz  .copy
  734.     cmp ecx, 'pbm'
  735.     jz  .copy
  736.     cmp ecx, 'pgm'
  737.     jz  .copy
  738.     cmp ecx, 'pnm'
  739.     jz  .copy
  740.     cmp ecx, 'tif'
  741.     jz  .copy
  742.   .not_3:
  743.     cmp byte[esi+4], 0
  744.     jne .nocopy
  745.     or  ecx, 0x20202020
  746.     cmp ecx, 'tiff'
  747.     jz  @f
  748.     cmp ecx, 'wbmp'
  749.     jz  @f
  750.     cmp ecx, 'jpeg'
  751.     jnz .nocopy
  752. @@:
  753.     cmp byte [esi+4], 0
  754.     jnz .nocopy
  755. .copy:
  756.     mov esi, [esp]
  757.     mov ecx, 304 / 4
  758.     rep movsd
  759.     inc dword [esp+4]
  760. .nocopy:
  761. .noext:
  762.     pop eax
  763.     add eax, 304
  764.     dec ebx
  765.     jnz .dirskip
  766.     mov eax, [directory_ptr]
  767.     pop ebx
  768.     mov [eax+4], ebx
  769.     test    ebx, ebx
  770.     jz  free_directory
  771.     push    0   ; sort mode
  772.     push    ebx
  773.     add eax, 32
  774.     push    eax
  775.     call    [SortDir]
  776.     xor eax, eax
  777.     mov edi, [directory_ptr]
  778.     add edi, 32 + 40
  779. .scan:
  780.     mov esi, [last_name_component]
  781.     push    edi
  782.     invoke  strcmpi
  783.     pop edi
  784.     jz  .found
  785.     inc eax
  786.     add edi, 304
  787.     dec ebx
  788.     jnz .scan
  789.     or  eax, -1
  790. .found:
  791.     mov [cur_file_idx], eax
  792. .ret:
  793.     ret
  794.  
  795. free_directory:
  796.     mcall   SF_SYS_MISC, SSF_MEM_FREE, [directory_ptr]
  797.     and [directory_ptr], 0
  798.     ret
  799.  
  800. ; in: esi->full name (e.g. /path/to/file.png)
  801. ; out: [last_name_component]->last component (e.g. file.png)
  802. find_last_name_component:
  803.     mov ecx, esi
  804. @@:
  805.     lodsb
  806.     test    al, al
  807.     jnz @b
  808. @@:
  809.     dec esi
  810.     cmp esi, ecx
  811.     jb  @f
  812.     cmp byte [esi], '/'
  813.     jnz @b
  814. @@:
  815.     inc esi
  816.     mov [last_name_component], esi
  817.     ret
  818.  
  819. init_frame:
  820.     push    eax
  821.     mov eax, [image]
  822.     mov [cur_frame], eax
  823.     test    byte [eax + Image.Flags], Image.IsAnimated
  824.     jz  @f
  825.     push    ebx
  826.     mcall   SF_SYSTEM_GET, SSF_TIME_COUNT
  827.     pop ebx
  828.     mov [cur_frame_time], eax
  829. @@:
  830.     pop eax
  831.     ret
  832.  
  833. draw_window:
  834.     btr  word [bSlideShow], 1  ; mode changed
  835.     jc .mode_changed
  836.     test byte [bTglbar], 1
  837.     jz .mode_not_changed
  838. .mode_changed:
  839.     test [wnd_style], 1 SHL 25
  840.     jz .mode_slide
  841.     mov [bg_color], 0x00ffffff
  842.     mov eax, [image]
  843.     cmp eax, eax
  844.     call update_image_sizes
  845.     mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
  846.     mov esi, [wnd_height]
  847.     add esi, eax
  848.     test byte [bTglbar], 1
  849.     jz @f
  850.     mcall SF_CHANGE_WINDOW, -1, -1, [wnd_width],
  851.     jmp .mode_not_changed
  852. @@:
  853.     mcall SF_CHANGE_WINDOW, [wnd_x], [wnd_y], [wnd_width],
  854.     jmp .mode_not_changed
  855. .mode_slide:
  856.     mov [bg_color], 0x00000000
  857.     mov eax, [procinfo.box.left]
  858.     mov [wnd_x], eax
  859.     mov eax, [procinfo.box.top]
  860.     mov [wnd_y], eax
  861.     mcall SF_GET_SCREEN_SIZE
  862.     mov edx, eax
  863.     shr edx, 16
  864.     movzx eax, ax
  865.     mov esi, eax
  866.     mcall SF_CHANGE_WINDOW, 0, 0, ,
  867.     jmp .posok.slide_show
  868.  
  869. .mode_not_changed:
  870.     cmp [bFirstDraw], 0
  871.     jz  .posok
  872.     or  ecx, -1
  873.     mcall   SF_THREAD_INFO, procinfo
  874.  
  875.     test byte [procinfo.wnd_state], 0x04
  876.     jnz .posok
  877.  
  878.     mov edx, ecx
  879.     mov esi, ecx
  880.     cmp dword [procinfo.box.width], 50 + 25 * numimages
  881.     jae @f
  882.     mov edx, 50 + 25 * numimages
  883. @@:
  884.     cmp dword [procinfo.box.height], 70
  885.     jae @f
  886.     mov esi, 70
  887. @@:
  888.     mov eax, edx
  889.     and eax, esi
  890.     cmp eax, -1
  891.     jz  @f
  892.     mov ebx, ecx
  893.     mcall   SF_CHANGE_WINDOW
  894. @@:
  895.  
  896. .posok:
  897.     test [wnd_style], 1 SHL 25
  898.     jz .posok.slide_show
  899.     mcall   SF_REDRAW, SSF_BEGIN_DRAW
  900.     mcall   SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT
  901.     mov ebp, eax    ; save skin height
  902.     add eax, [wnd_height]
  903.     mov ebx, [wnd_x]
  904.     shl ebx, 16
  905.     add ebx, [wnd_width]
  906.     mov ecx, [wnd_y]
  907.     shl ecx, 16
  908.     add ecx, eax
  909.     mcall   SF_CREATE_WINDOW, , , [wnd_style], 0, real_header
  910.     jmp .posok.common
  911. .posok.slide_show:
  912.     mcall   SF_REDRAW, SSF_BEGIN_DRAW
  913.     mcall SF_GET_SCREEN_SIZE
  914.     mov ebx, eax
  915.     shr ebx, 16
  916.     movzx eax, ax
  917.     mov ecx, eax
  918.     mcall   SF_CREATE_WINDOW, , , [wnd_style], 0, real_header
  919. .posok.common:
  920.     mcall   SF_THREAD_INFO, procinfo, -1
  921.     mov eax, [procinfo.client_box.width]
  922.     sub eax, [image_padding]
  923.     sub eax, [image_padding]
  924.     sub eax, [draw_width]
  925.     sar eax, 1
  926.     test eax, eax
  927.     jns @f
  928.     mov eax, 0
  929. @@:
  930.     add eax, [image_padding]
  931.     mov [draw_x], eax
  932.     mov eax, [procinfo.client_box.height]
  933.     sub eax, [toolbar_height]
  934.     sub eax, [image_padding]
  935.     sub eax, [image_padding]
  936.     sub eax, [draw_height]
  937.     sar eax, 1
  938.     test eax, eax
  939.     jns @f
  940.     mov eax, 0
  941. @@:
  942.     add eax, [toolbar_height]
  943.     add eax, [image_padding]
  944.     mov [draw_y], eax
  945.     mov [bFirstDraw], 1
  946.     cmp dword [procinfo.client_box.height], 0
  947.     jle .nodraw
  948.     mov ebx, [procinfo.client_box.width]
  949.     inc ebx
  950.     mov ecx, [draw_y]
  951.     mcall   SF_DRAW_RECT, , , [bg_color]
  952.     mov ecx, [procinfo.client_box.height]
  953.     inc ecx
  954.     mov esi, [cur_frame]
  955.     mov esi, [esi + Image.Height]
  956.     add esi, [draw_y]
  957.     sub ecx, esi
  958.     jbe @f
  959.     push    esi
  960.     shl esi, 16
  961.     add ecx, esi
  962.     pop esi
  963.     mcall
  964.     xor ecx, ecx
  965. @@:
  966.     add ecx, esi
  967.     mov ebx, [draw_y]
  968.     sub ecx, ebx
  969.     shl ebx, 16
  970.     add ecx, ebx
  971.     mov ebx, [draw_x]
  972.     mcall
  973.     mov esi, [cur_frame]
  974.     mov esi, [esi + Image.Width]
  975.     add esi, ebx
  976.     mov ebx, [procinfo.client_box.width]
  977.     inc ebx
  978.     sub ebx, esi
  979.     jbe @f
  980.     shl esi, 16
  981.     add ebx, esi
  982.     mcall
  983. @@:
  984.  
  985.     test [wnd_style], 1 SHL 25
  986.     jz .slide_show_mode
  987.     mov byte [bTglbar], 0
  988.     cmp byte [toolbar_height], 0
  989.     je .decorations_done
  990.     mov ebx, [procinfo.client_box.width]
  991.     push    ebx
  992.     mcall   SF_DRAW_LINE, , <30, 30>, 0x007F7F7F
  993.     mcall   , <5 + 25 * 1, 5 + 25 * 1>, <0, 30>
  994.     mcall   , <10 + 25 * 3, 10 + 25 * 3>
  995.     mcall   , <15 + 25 * 5, 15 + 25 * 5>
  996.     pop ebx
  997.     sub ebx, 25 * 5 + 10
  998.     push    ebx
  999.     imul    ebx, 10001h
  1000.     mcall
  1001.  
  1002.     mcall   SF_DEFINE_BUTTON, <5 + 25 * 0, 20>, <5, 20>, 'opn'+40000000h
  1003.     mcall   , <10 + 25 * 1, 20>, , 'bck'+40000000h
  1004.     mcall   , <10 + 25 * 2, 20>, , 'fwd'+40000000h
  1005.     mcall   , <15 + 25 * 3, 20>, , 'bgr'+40000000h
  1006.     mcall   , <15 + 25 * 4, 20>, , 'sld'+40000000h
  1007.     pop ebx
  1008.     add ebx, 5
  1009.     shl ebx, 16
  1010.     mov bl, 20
  1011.     mcall   , , , 'flh'+40000000h
  1012.     add ebx, 25 * 65536
  1013.     mcall   , , , 'flv'+40000000h
  1014.     add ebx, 30 * 65536
  1015.     mcall   , , , 'rtr'+40000000h
  1016.     add ebx, 25 * 65536
  1017.     mcall   , , , 'rtl'+40000000h
  1018.     add ebx, 25 * 65536
  1019.     mcall   , , , 'flb'+40000000h
  1020.  
  1021.     mov ebp, (numimages-1)*20
  1022.  
  1023.     mcall   SF_PUT_IMAGE_EXT, buttons+openbtn*20, <20, 20>, <5 + 25 * 0, 5>, 8, palette
  1024.     mcall   , buttons+backbtn*20,    , <10 + 25 * 1, 5>
  1025.     mcall   , buttons+forwardbtn*20, , <10 + 25 * 2, 5>
  1026.     mcall   , buttons+bgrbtn*20,     , <15 + 25 * 3, 5>
  1027.     mcall   , buttons+slidebtn*20,   , <15 + 25 * 4, 5>
  1028.     mov edx, [procinfo.client_box.width]
  1029.     sub edx, 25 * 5 + 4
  1030.     shl edx, 16
  1031.     mov dl, 5
  1032.     mcall   , buttons+fliphorzbtn*20
  1033.     add edx, 25 * 65536
  1034.     mcall   , buttons+flipvertbtn*20
  1035.     add edx, 30 * 65536
  1036.     mcall   , buttons+rotcwbtn*20
  1037.     add edx, 25 * 65536
  1038.     mcall   , buttons+rotccwbtn*20
  1039.     add edx, 25 * 65536
  1040.     mcall   , buttons+rot180btn*20
  1041.     jmp .decorations_done
  1042.  
  1043. .slide_show_mode:
  1044.  
  1045. .decorations_done:
  1046.     call    draw_cur_frame
  1047.  
  1048. .nodraw:
  1049.     mcall   SF_REDRAW, SSF_END_DRAW
  1050.  
  1051.     ret
  1052.  
  1053. draw_cur_frame:
  1054.     push    0   ; ypos
  1055.     push    0   ; xpos
  1056.     mov eax, [procinfo.client_box.height]
  1057.     sub eax, [toolbar_height]
  1058.     sub eax, [image_padding]
  1059.     inc eax
  1060.     push    eax ; max height
  1061.     mov eax, [procinfo.client_box.width]
  1062.     sub eax, [image_padding]
  1063.     inc eax
  1064.     push    eax ; max width
  1065.     push [draw_y]
  1066.     push [draw_x]
  1067.     push    [cur_frame]
  1068.     call    [img.draw]
  1069.     mov eax, [image]
  1070.     test    [eax + Image.Flags], Image.IsAnimated
  1071.     jnz .done
  1072.     cmp [eax + Image.Next], 0
  1073.     jnz .additional_frames
  1074. .done:
  1075.     ret
  1076. .additional_frames:
  1077.     mov ebx, [procinfo.client_box.width]
  1078.     sub ebx, [image_padding]
  1079.     inc ebx
  1080.     jbe .done
  1081.     mov esi, [draw_x]
  1082. .afloop:
  1083.     sub ebx, [eax + Image.Width]
  1084.     jbe .done
  1085.     dec ebx
  1086.     jz  .done
  1087.     add esi, [eax + Image.Width]
  1088.     mov eax, [eax + Image.Next]
  1089.     push    eax
  1090.     inc esi
  1091.     push    0   ; ypos
  1092.     push    0   ; xpos
  1093.     mov ecx, [procinfo.client_box.height]
  1094.     sub ecx, [toolbar_height]
  1095.     sub ecx, [image_padding]
  1096.     inc ecx
  1097. ;    inc ebx
  1098.     push    ecx ; max height
  1099.     push    ebx ; max width
  1100.     push    [draw_y]  ; y
  1101.     push    esi ; x
  1102.     push    eax ; image
  1103.     call    [img.draw]
  1104.     pop eax
  1105.     cmp [eax + Image.Next], 0
  1106.     jnz .afloop
  1107.     ret
  1108.  
  1109.  
  1110. check_shortcut:
  1111. ; in:   cl = scancode (from sysfn 2),
  1112. ;   eax = state of modifiers (from sysfn 66.3),
  1113. ;   edx -> shortcut descriptor
  1114. ; out:  ZF set <=> fail
  1115.     cmp cl, [edx+4]
  1116.     jnz .not
  1117.     push    eax
  1118.     mov esi, [edx]
  1119.     and esi, 0xF
  1120.     and al, 3
  1121.     call    dword [check_modifier_table+esi*4]
  1122.     test    al, al
  1123.     pop eax
  1124.     jnz .not
  1125.     push    eax
  1126.     mov esi, [edx]
  1127.     shr esi, 4
  1128.     and esi, 0xF
  1129.     shr al, 2
  1130.     and al, 3
  1131.     call    dword [check_modifier_table+esi*4]
  1132.     test    al, al
  1133.     pop eax
  1134.     jnz .not
  1135.     push    eax
  1136.     mov esi, [edx]
  1137.     shr esi, 8
  1138.     and esi, 0xF
  1139.     shr al, 4
  1140.     and al, 3
  1141.     call    dword [check_modifier_table+esi*4]
  1142.     test    al, al
  1143.     pop eax
  1144. ;   jnz .not
  1145. .not:
  1146.     ret
  1147.  
  1148. check_modifier_0:
  1149.     setnz   al
  1150.     ret
  1151. check_modifier_1:
  1152.     setp    al
  1153.     ret
  1154. check_modifier_2:
  1155.     cmp al, 3
  1156.     setnz   al
  1157.     ret
  1158. check_modifier_3:
  1159.     cmp al, 1
  1160.     setnz   al
  1161.     ret
  1162. check_modifier_4:
  1163.     cmp al, 2
  1164.     setnz   al
  1165.     ret
  1166.  
  1167. ; fills real_header with window title
  1168. ; window title is generated as '<filename> - Kolibri Image Viewer'
  1169. generate_header:
  1170.     push    eax
  1171.     mov esi, [last_name_component]
  1172.     mov edi, real_header
  1173. @@:
  1174.     lodsb
  1175.     test    al, al
  1176.     jz  @f
  1177.     stosb
  1178.     cmp edi, real_header+256
  1179.     jb  @b
  1180. .overflow:
  1181.     mov dword [edi-4], '...'
  1182. .ret:
  1183.     pop eax
  1184.     ret
  1185. @@:
  1186.     mov esi, s_header
  1187. @@:
  1188.     lodsb
  1189.     stosb
  1190.     test    al, al
  1191.     jz  .ret
  1192.     cmp edi, real_header+256
  1193.     jb  @b
  1194.     jmp .overflow
  1195. ;-----------------------------------------------------------------------------
  1196.  
  1197. s_header db ' - Kolibri Image Viewer', 0
  1198. wnd_style        dd 0x73FFFFFF
  1199. wnd_x            dd 100
  1200. wnd_y            dd 100
  1201. image_padding    dd 5
  1202. toolbar_height   dd 31
  1203. bg_color         dd 0x00ffffff
  1204.  
  1205. ;-----------------------------------------------------------------------------
  1206. ;-----------------------------------------------------------------------------
  1207.  
  1208. align 4
  1209. @IMPORT:
  1210.  
  1211. library             \
  1212.     libio  , 'libio.obj'  , \
  1213.     libgfx , 'libgfx.obj' , \
  1214.     libimg , 'libimg.obj' , \
  1215.     libini , 'libini.obj' , \
  1216.     sort   , 'sort.obj'   , \
  1217.     proc_lib ,'proc_lib.obj',\
  1218.         libbuf2d, 'buf2d.obj'
  1219.  
  1220.  
  1221. import  libio             , \
  1222.     libio.init , 'lib_init'   , \
  1223.     file.size  , 'file_size'  , \
  1224.     file.open  , 'file_open'  , \
  1225.     file.read  , 'file_read'  , \
  1226.     file.close , 'file_close'
  1227.  
  1228. import  libgfx              , \
  1229.     libgfx.init   , 'lib_init'  , \
  1230.     gfx.open      , 'gfx_open'  , \
  1231.     gfx.close     , 'gfx_close' , \
  1232.     gfx.pen.color , 'gfx_pen_color' , \
  1233.     gfx.line      , 'gfx_line'
  1234.  
  1235. import  libimg             , \
  1236.     libimg.init , 'lib_init'   , \
  1237.     img.is_img  , 'img_is_img' , \
  1238.     img.to_rgb2 , 'img_to_rgb2', \
  1239.     img.decode  , 'img_decode' , \
  1240.     img.flip    , 'img_flip'   , \
  1241.     img.rotate  , 'img_rotate' , \
  1242.     img.destroy , 'img_destroy', \
  1243.     img.draw    , 'img_draw'
  1244.  
  1245. import  libini, \
  1246.     ini_get_shortcut, 'ini_get_shortcut',\
  1247.         ini_set_str, 'ini_set_str'
  1248.  
  1249. import  sort, sort.START, 'START', SortDir, 'SortDir', strcmpi, 'strcmpi'
  1250.  
  1251. import  proc_lib, \
  1252.     OpenDialog_Init, 'OpenDialog_init', \
  1253.     OpenDialog_Start,'OpenDialog_start'
  1254.  
  1255. import  libbuf2d, \
  1256.         buf2d_init, 'lib_init', \
  1257.         buf2d_resize, 'buf2d_resize'
  1258.  
  1259. align 4
  1260. buf_0: dd 0
  1261.         dw 0,0
  1262. .w: dd 0
  1263. .h: dd 0,0
  1264.         db 24 ;+20 bit in pixel
  1265.  
  1266. bFirstDraw  db  0
  1267. bSlideShow  db  0
  1268. bTglbar     db  0
  1269. ;-----------------------------------------------------------------------------
  1270.  
  1271. virtual at 0
  1272. file 'kivicons.bmp':0xA,4
  1273. load offbits dword from 0
  1274. end virtual
  1275. numimages = 10
  1276. openbtn = 0
  1277. backbtn = 1
  1278. forwardbtn = 2
  1279. bgrbtn = 3
  1280. fliphorzbtn = 4
  1281. flipvertbtn = 5
  1282. rotcwbtn = 6
  1283. rotccwbtn = 7
  1284. rot180btn = 8
  1285. slidebtn = 9
  1286.  
  1287. palette:
  1288.     file 'kivicons.bmp':0x36,offbits-0x36
  1289. buttons:
  1290.     file 'kivicons.bmp':offbits
  1291. repeat 10
  1292. y = % - 1
  1293. z = 20 - %
  1294. repeat numimages*5
  1295. load a dword from $ - numimages*20*20 + numimages*20*y + (%-1)*4
  1296. load b dword from $ - numimages*20*20 + numimages*20*z + (%-1)*4
  1297. store dword a at $ - numimages*20*20 + numimages*20*z + (%-1)*4
  1298. store dword b at $ - numimages*20*20 + numimages*20*y + (%-1)*4
  1299. end repeat
  1300. end repeat
  1301.  
  1302. inifilename db  '/sys/settings/app.ini',0
  1303. aShortcuts  db  'Kiv',0
  1304. aNext       db  'Next',0
  1305. aPrev       db  'Prev',0
  1306. aSlide      db  'SlideShow',0
  1307. aTglbar     db  'ToggleBar',0
  1308.  
  1309. inifileeskin db '/sys/settings/eskin.ini',0
  1310. amain       db 'main',0
  1311. aprogram    db 'program',0
  1312. aparam      db 'param',0
  1313.  
  1314. align 4
  1315. check_modifier_table:
  1316.     dd  check_modifier_0
  1317.     dd  check_modifier_1
  1318.     dd  check_modifier_2
  1319.     dd  check_modifier_3
  1320.     dd  check_modifier_4
  1321.  
  1322. ;---------------------------------------------------------------------
  1323. align 4
  1324. OpenDialog_data:
  1325. .type           dd 0
  1326. .procinfo       dd procinfo ;+4
  1327. .com_area_name      dd communication_area_name ;+8
  1328. .com_area       dd 0 ;+12
  1329. .opendir_pach       dd temp_dir_pach ;+16
  1330. .dir_default_pach   dd communication_area_default_pach ;+20
  1331. .start_path     dd open_dialog_path ;+24
  1332. .draw_window        dd draw_window ;+28
  1333. .status         dd 0 ;+32
  1334. .openfile_pach      dd path  ;openfile_pach ;+36
  1335. .filename_area      dd 0    ;+40
  1336. .filter_area        dd Filter
  1337. .x:
  1338. .x_size                 dw 420 ;+48 ; Window X size
  1339. .x_start                dw 10 ;+50 ; Window X position
  1340. .y:
  1341. .y_size                 dw 320 ;+52 ; Window y size
  1342. .y_start                dw 10 ;+54 ; Window Y position
  1343.  
  1344. communication_area_name:
  1345.     db 'FFFFFFFF_open_dialog',0
  1346.  
  1347. open_dialog_path:
  1348. if __nightbuild eq yes
  1349.     db '/sys/MANAGERS/opendial',0
  1350. else
  1351.     db '/sys/File Managers/opendial',0
  1352. end if
  1353. communication_area_default_pach:
  1354.     db '/rd/1',0
  1355.  
  1356. Filter:
  1357. dd Filter.end - Filter
  1358. .1:
  1359. db 'BMP',0
  1360. db 'GIF',0
  1361. db 'JPG',0
  1362. db 'JPEG',0
  1363. db 'JPE',0
  1364. db 'PNG',0
  1365. db 'ICO',0
  1366. db 'CUR',0
  1367. db 'TGA',0
  1368. db 'PCX',0
  1369. db 'XCF',0
  1370. db 'PBM',0
  1371. db 'PGM',0
  1372. db 'PNM',0
  1373. db 'TIF',0
  1374. db 'TIFF',0
  1375. db 'WBMP',0
  1376. .end:
  1377. db 0
  1378.  
  1379. draw_window_fake:
  1380.     ret
  1381. ;------------------------------------------------------------------------------
  1382. readdir_fileinfo:
  1383.     dd  1
  1384.     dd  0
  1385.     dd  0
  1386. readblocks dd   0
  1387. directory_ptr   dd  0
  1388. ;------------------------------------------------------------------------------
  1389. I_END:
  1390. curdir      rb  1024
  1391.  
  1392. align 4
  1393. img_data     dd ?
  1394. img_data_len dd ?
  1395. fh       dd ?
  1396. image        dd ?
  1397. wnd_width   dd  100
  1398. wnd_height  dd  100
  1399. draw_x      dd  ?
  1400. draw_y      dd  ?
  1401. draw_width  dd  ?
  1402. draw_height dd  ?
  1403. last_name_component dd  ?
  1404. cur_file_idx    dd  ?
  1405. cur_frame_time  dd  ?
  1406. cur_frame   dd  ?
  1407.  
  1408. next_mod    dd  ?
  1409. next_key    dd  ?
  1410. prev_mod    dd  ?
  1411. prev_key    dd  ?
  1412. slide_mod   dd  ?
  1413. slide_key   dd  ?
  1414. tglbar_mod  dd  ?
  1415. tglbar_key  dd  ?
  1416.  
  1417. toolbar_height_old   rd 1
  1418.  
  1419. procinfo    process_information
  1420. align 16
  1421. path:       rb  4096  ;1024+16
  1422. real_header rb  256
  1423. @PARAMS rb 4096  ;512
  1424. ;---------------------------------------------------------------------
  1425. sys_path rb 1024
  1426. temp_dir_pach:
  1427.         rb 4096
  1428. ;---------------------------------------------------------------------
  1429.     rb 4096
  1430. stacktop:
  1431. ;---------------------------------------------------------------------
  1432. F_END:
  1433.