Subversion Repositories Kolibri OS

Rev

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

  1. ; @RCHER system-dependent and other stuff
  2. ; Written in pure assembler by Ivushkin Andrey aka Willow
  3.  
  4. OpenFile:
  5.     mov  [outp],output
  6.     mov  esi,area
  7.     and  [Finfo.block],0
  8. if SYS eq win
  9.     invoke CreateFile, filename, GENERIC_READ, FILE_SHARE_READ, NULL, \
  10.     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL
  11.     inc  eax
  12.     test eax,eax
  13.     jz   .ex
  14.     dec  eax
  15.     mov  [hnd],eax
  16.     invoke GetFileSize,eax,NULL
  17.   .ex:
  18.     mov  ebx,eax
  19.     mov  [filesize],eax
  20. else
  21.     mcall 58,Finfo
  22.     mov  [filesize],ebx
  23. end if
  24.     ret
  25.  
  26. ResetFile:
  27.     and  [file_count],0
  28.     mov  eax,[arc_base]
  29.     xor  ebx,ebx
  30.     mov  esi,area
  31.     call FileSeek
  32.     ret
  33.  
  34.  
  35. FileSeek:
  36. ; eax - offset
  37. ; esi - current pointer (in memory!)
  38. ; ebx - translation method: 0 - beginning, 1 - current, 2 - end
  39.     push eax ecx edx
  40.     mov  edx,[Finfo.block]
  41.     imul edx,BSIZE
  42.     sub  esi,BUFPTR
  43.     add  esi,edx
  44.     cmp  ebx,1
  45.     je   .cur
  46.     jb   .begin
  47.     mov  esi,[filesize]
  48.     not  eax
  49.   .cur:
  50.     add  eax,esi
  51.   .begin:
  52.     mov  ecx,BSIZE
  53.     xor  edx,edx
  54.     div  ecx
  55.     lea  esi,[BUFPTR+edx]
  56.     mov  [Finfo.block],eax
  57. if SYS eq win
  58.     mul  ecx
  59.     invoke SetFilePointer,[hnd],eax,NULL,FILE_BEGIN
  60.     invoke ReadFile,[hnd],area,INBUF, os_work, NULL
  61. ;    add  [byte_count],area
  62. else
  63. ;    pregs
  64. ;    wait
  65.     mov  [Finfo.count],BUFSIZE*2
  66.     mcall 58,Finfo
  67. ;    mov  [byte_count],area+INBUF
  68. end if
  69.     pop  edx ecx eax
  70.     ret
  71.  
  72. macro QueryFile
  73. {
  74. local ex
  75. if SYS eq win
  76.         invoke GetOpenFileName,ofstruc
  77. else
  78.    opendialog draw_window,QFok,QFcanc,filename
  79.  QFok:
  80.    xor eax,eax
  81.    jmp ex
  82.    ret
  83.  QFcanc:
  84.    mov eax,1
  85. end if
  86.  ex:
  87. }
  88.  
  89. RunViewer:
  90.     test   [Flags],PNG_MODE
  91.     jz   .ex
  92.  if SYS eq win
  93.         mov   eax,[PNG_info.Width]
  94.         call  int2str
  95.         invoke WritePrivateProfileString,ini_sec,ini_rwidth,os_work,ini_file
  96.         mov   eax,[PNG_info.Height]
  97.         call  int2str
  98.         invoke WritePrivateProfileString,ini_sec,ini_rheight,os_work,ini_file
  99.         invoke CreateProcess,NULL,iview_cmd,NULL,NULL,TRUE,\
  100.                 NORMAL_PRIORITY_CLASS,NULL,NULL,suinfo,pinfo
  101.         invoke WaitForInputIdle,dword[pinfo],0xFFFFFFFF
  102.         invoke FindWindowEx, NULL,NULL,NULL,rawwnd_txt
  103.         invoke FindWindowEx, eax,NULL,NULL,ok_txt
  104.         invoke SendMessage,eax,BM_CLICK,NULL,NULL
  105.  else
  106.     test [Flags],THREAD_YES
  107.     jnz  .ex
  108.     mcall 51,1,thread,MEMORY
  109.     mov  [child],eax
  110.  end if
  111.   .ex: 
  112.            ret
  113.  
  114. if SYS eq win
  115. int2str:
  116. ; in: eax - number
  117. ; out: formatted string -> os_work
  118.         invoke wsprintf,os_work,fmt_str,eax
  119.         add   esp,12
  120.     ret
  121.  
  122. rawwnd_txt db 'Set RAW open parameters',0
  123. ok_txt  db 'OK',0
  124. ini_sec db 'RAW',0
  125. ini_rwidth db 'RWidth',0
  126. ini_rheight db 'RHeight',0
  127. ini_file db "C:\Program Files\IrfanView\i_view32.ini",0
  128. fmt_str db "%d",0      
  129. iview_cmd db '"C:\Program Files\IrfanView\i_view32.exe"'
  130.           db ' "D:\Ivushkin\projects\zip\output.raw"',0
  131. filt_str:
  132.         db 'Pictures (*.png)',0,'*.png',0
  133.         db 'Archives (*.zip;*.*gz)',0,'*.zip;*.*gz',0
  134.         db 'All files (*.*)',0,'*.*',0,0
  135.        
  136. suinfo STARTUPINFO
  137. pinfo  PROCESS_INFORMATION
  138. cpstruc:
  139. ofstruc:
  140.         dd  ofstruc_end-ofstruc
  141.         dd  NULL
  142.         dd  NULL
  143.         dd  filt_str
  144.         dd  NULL
  145.         dd  NULL
  146.         dd  0
  147.         dd  filename
  148.         dd  256
  149.         dd  NULL
  150.         dd  0
  151.         dd  NULL
  152.         dd  NULL
  153.         dd  NULL
  154.         dw  NULL
  155.         dw  NULL
  156.         dd  NULL
  157.         dd  NULL
  158.         dd  NULL
  159.         dd  NULL
  160.         dd  NULL
  161.         dd  NULL
  162.         dd  NULL
  163. ofstruc_end:                   
  164.  
  165.  else
  166.     mov  ebx,-1
  167.     mov  ecx,ebx
  168.     mov  edx,[PNG_info.Width]
  169.     add  edx,10
  170.     mov  esi,[PNG_info.Width]
  171.     add  esi,30
  172.     mcall 67
  173.     mcall 7,outfile,[outfile.size],10 shl 16+15
  174.  .ex:
  175.     ret
  176.  
  177. MIN_WIDTH equ 300
  178. thread:
  179.  .red:
  180.     mcall 12,1
  181.     mov  ebx,[PNG_info.Width]
  182.     cmp  ebx,MIN_WIDTH
  183.     jae  .more
  184.     mov  ebx,MIN_WIDTH
  185.   .more:
  186.     add  ebx,20
  187.     mov  ecx,[PNG_info.Height]
  188.     add  ecx,30
  189.     mcall 0,,,0x3808080
  190.     mcall 4,<5,7>,0x10f0f0f0,filename,255
  191.     mov  ecx,[PNG_info.Width]
  192.     shl  ecx,16
  193.     add  ecx,[PNG_info.Height]
  194.     mcall 7,png_image,,10 shl 16+25
  195.     mcall 12,2
  196.   .still:
  197.     mcall 10
  198.     cmp  eax,1
  199.     je   .red
  200.     cmp  eax,2
  201.     jne  .nokey
  202.     mcall 2
  203.     cmp  ah,27 ; Esc - close
  204.     je   .close
  205.     jmp  .still
  206.   .nokey:
  207.     cmp  eax,3
  208.     jne  .still
  209.   .close:
  210.     and  [child],0
  211.     mcall -1
  212.  
  213. KillViewer:
  214.     pusha
  215.     mov  edi,[child]
  216.     test edi,edi
  217.     jz   .noth
  218.     mcall 9,os_work,-1
  219.     mov  ecx,eax
  220.   .fchild:
  221.     push ecx
  222.     mcall 9,os_work
  223.     cmp  edi,[ebx+30]
  224.     jne  .lp
  225.     mov  ecx,[esp]
  226.     mcall 18,2
  227.     pop  ecx
  228.     jmp  .noth
  229.   .lp:
  230.     pop  ecx
  231.     loop .fchild
  232.   .noth:
  233.     popa
  234.     ret
  235.  
  236. macro CmdLine
  237. {
  238.     mov  esi,PARAM_PTR
  239.   .parse:
  240.     lodsb
  241.  
  242.     test al,al
  243.     jnz  .noend
  244.     or  [Flags],STAY_MODE
  245.     jmp  red
  246.   .noend:
  247.     cmp  al,' '
  248.     je   .stay
  249.     cmp  al,'/'
  250.     jne  .yespar
  251.     mov  ecx,255
  252.     dec  esi
  253.     mov  edi,filename
  254.     xor  al,al
  255.     rep  stosb
  256.     mov  ecx,255
  257.     mov  edi,filename
  258.     rep  movsb
  259.     jmp  again
  260.   .yespar:
  261.     cmp  al,'N'
  262.     jne  .nonum
  263.     call get_6ASCII_num
  264.   .fnum:
  265.     mov  [FileNum],eax
  266.     jmp  .parse
  267.   .nonum:
  268.     cmp  al,'n'
  269.     jne  .nonum2
  270.     lodsd
  271.     jmp  .fnum
  272.   .nonum2:
  273.     cmp  al,'s'
  274.     jne  .nostay
  275.   .stay:
  276.     or   [Flags],STAY_MODE
  277.     jmp  .parse
  278.   .nostay:
  279.     cmp  al,'i'
  280.     jne  .noclPID
  281.     lodsd
  282.     mov  [clientPID],eax
  283.     or   [Flags],IPC_MODE
  284.     jmp  .parse
  285.   .noclPID:
  286.     cmp  al,'R'
  287.     jne  .noraw
  288.     or   [Flags],RAW_MODE
  289.     jmp  .parse
  290.   .noraw:
  291.     cmp  al,'q'
  292.     jne  .noofs
  293.     lodsd
  294.   .fofs:  
  295.     mov  [arc_base],eax
  296.     jmp  .parse
  297.   .noofs:
  298.     cmp  al,'Q'
  299.     jne  .noofs2
  300.     call get_6ASCII_num
  301.     jmp  .fofs
  302.   .noofs2:  
  303.     jmp  .parse
  304.  
  305. get_6ASCII_num:
  306. ; in: esi - str ptr, out: eax - num
  307.     xor  edx,edx
  308.     mov  ebx,10
  309.     mov  ecx,6
  310.   .lp:
  311.     xor  eax,eax
  312.     lodsb
  313.     sub  al,'0'
  314.     imul edx,ebx
  315.     add  edx,eax
  316.     loop .lp
  317.     mov  eax,edx
  318.     ret
  319. }
  320.  
  321. StartPad:
  322.     mcall 19,editorcmd,dumpfile
  323.     ret
  324.  
  325. editorcmd db 'TINYPAD    '
  326. end if