Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;   Show Mini Sample by Pavlushin Evgeni for ASCL
  3. ;   www.waptap@mail.ru
  4. ;
  5.  
  6. ;bits brushes(right mouse button)!
  7. ;resize pucture(cross buttons)!
  8. ;Open BMP MIA MHI grafic files!
  9. ;Save as MIA MHI(zip from MHC -70% size)!
  10. ;Support full files 800*600
  11. ;Open and save dialogs is work!
  12.  
  13. ; 27Ver Gif load support
  14. ; 28Ver Dialogs is work
  15.  
  16. ;******************************************************************************
  17.     use32
  18.     org    0x0
  19.     db     'MENUET01'              ; 8 byte id
  20.     dd     0x01                    ; header version
  21.     dd     START                   ; start of code
  22.     dd     IM_END                  ; size of image
  23.     dd     I_END                ; memory for app
  24.     dd     I_END               ; esp
  25.     dd     0x0 , 0x0         ; I_Param , I_Icon
  26.  
  27. ;******************************************************************************
  28. include 'lang.inc'
  29. include 'macros.inc'
  30. include 'ascl.inc'
  31. include 'ascgl.inc'
  32.  
  33.  hashtable equ MHC_END
  34.  ifile     equ MHC_END+65536*8 ;4
  35.  ofile     equ (MHC_END+65536*8)+2000000 ;1000000
  36.  
  37.  gif_hash_offset = ofile
  38.  
  39. START:                          ; start of execution
  40.     mov eax,40
  41.     mov ebx,0100111b
  42.     int 0x40
  43.  
  44. ; clear picture color White
  45.     mov ecx,1024*768*3
  46.     mov eax,0xffffffff
  47.     mov edi,image_area
  48.     cld
  49.     rep stosb
  50.  
  51.     call draw_window
  52.     call setbrush
  53.  
  54. rstill:
  55.     mov eax,37
  56.     mov ebx,1
  57.     int 0x40
  58.     mov ebx,eax
  59.     shr eax,16     ;x
  60.     and ebx,0xffff ;y
  61.     sub eax,5+6
  62.     sub ebx,22+30+6
  63.  
  64.     cmp eax,640 ;for detect out of screen
  65.     ja  still
  66.     cmp ebx,480
  67.     ja  still
  68.     mov [xt],ebx
  69.     mov [yt],eax
  70.  
  71. still:
  72.     mov eax,40
  73.     mov ebx,0100111b
  74.     int 0x40
  75.  
  76.     wtevent red,key,button
  77.  
  78.     mov ebx,2
  79.     mov eax,37
  80.     int 0x40
  81.     cmp eax,1
  82.     je  tescor ;if left button not pressed!
  83.     cmp eax,2
  84.     je  cbr ;if right button pressed!
  85.     jmp rstill
  86. ;    jmp still
  87.  
  88. cbr:
  89.     cmp dword [brush],9 ;9 brush matrix
  90.     jnae nocr
  91.     mov [brush],-1 ;0
  92. nocr:
  93.     inc [brush]
  94.     call setbrush
  95.     jmp still
  96.  
  97. ;Set brush
  98. setbrush:
  99.     mov eax,[brush]
  100.     mov ebx,4*32
  101.     mul ebx
  102.  
  103.     mov ecx,4*32
  104.     mov esi,brushtable
  105.     add esi,eax
  106.     mov edi,matrix
  107.     cld
  108.     rep movsb
  109.  
  110.     delay 10
  111.     ret
  112.  
  113. tescor:
  114.     mov eax,37
  115.     mov ebx,1
  116.     int 0x40
  117.     mov ebx,eax
  118.     shr eax,16     ;x
  119.     and ebx,0xffff ;y
  120.  
  121.     sub eax,5+6
  122.     sub ebx,22+30+6
  123.  
  124.     push eax
  125.     push ebx
  126.  
  127.     mov ecx,eax ;[yt]
  128.     mov edx,ebx  ;[xt]
  129.  
  130.     mov eax,[xt]
  131.     mov ebx,[yt]
  132.     pop [xt]
  133.     pop [yt]
  134.  
  135.     call line
  136.  
  137. ;    mov [yt],eax
  138. ;    mov [xt],ebx
  139.     call out_image
  140.  
  141.     jmp  still
  142.  
  143.   red:
  144.     call draw_window
  145.     jmp still
  146.  
  147.   key:                          ; key
  148.     int  0x40                   ; read (eax=2)
  149.     jmp  still
  150.  
  151.   button:                       ; button
  152.     mov  eax,17                 ; get id
  153.     int  0x40
  154.     cmp  ah,1                   ; button id=1 ?
  155.     jne  noclose
  156.     mov  eax,-1                 ; close this program
  157.     int  0x40
  158. noclose:
  159.     cmp  ah,10
  160.     jb   no_palbut
  161.     cmp  ah,10+32;64
  162.     ja   no_palbut
  163.     mov  ecx,0
  164.     mov  cl,ah
  165.     sub  cl,10
  166.     shl  ecx,2
  167.     mov  ebx,[colortable+ecx]
  168.     mov  [color],ebx
  169.  
  170. ;Update color boxes
  171.     drawfbox 20,32,20,15,[backcolor]
  172.     drawfbox 12,28,20,15,[color]
  173.  
  174.     jmp  still
  175. no_palbut:
  176.  
  177.     cmp  ah,6
  178.     jne  no_left
  179.  
  180.     mov  esi,0
  181.     mov  edi,0
  182.     mov  ebp,[img_ysize]
  183. x_pls:
  184.     mov  ecx,0
  185.     mov  edx,[img_xsize]
  186. x_pl:
  187.     mov  al,[image_area+edi+ecx]
  188.     mov  [image_area+esi+ecx],al
  189.     mov  al,[image_area+edi+ecx+1]
  190.     mov  [image_area+esi+ecx+1],al
  191.     mov  al,[image_area+edi+ecx+2]
  192.     mov  [image_area+esi+ecx+2],al
  193.     add  ecx,3
  194.     dec  edx
  195.     jnz  x_pl
  196.     add  edi,[img_xsize]
  197.     add  edi,[img_xsize]
  198.     add  edi,[img_xsize]
  199.     add  esi,[img_xsize]
  200.     add  esi,[img_xsize]
  201.     add  esi,[img_xsize]
  202.     sub  esi,3
  203.     dec  ebp
  204.     jns  x_pls
  205.  
  206.     dec  [img_xsize]
  207.     jmp  red
  208. no_left:
  209.  
  210.  
  211.     cmp  ah,7
  212.     jne  no_right
  213.  
  214.     mov  eax,[img_xsize]
  215.     mul  [img_ysize]
  216.     mov  ebx,3
  217.     mul  ebx
  218.     mov  edi,eax
  219.  
  220.     mov  eax,[img_xsize]
  221.     inc  eax
  222.     mul  [img_ysize]
  223.     mov  ebx,3
  224.     mul  ebx
  225.     mov  esi,eax
  226.  
  227. ;    mov  esi,0
  228. ;    mov  edi,0
  229.     mov  ebp,[img_ysize]
  230. x_mns:
  231.     mov  ecx,[img_xsize] ;0
  232.     add  ecx,[img_xsize]
  233.     add  ecx,[img_xsize]
  234.     mov  edx,[img_xsize]
  235. x_mn:
  236.     mov  al,[image_area+edi+ecx]
  237.     mov  [image_area+esi+ecx],al
  238.     mov  al,[image_area+edi+ecx+1]
  239.     mov  [image_area+esi+ecx+1],al
  240.     mov  al,[image_area+edi+ecx+2]
  241.     mov  [image_area+esi+ecx+2],al
  242.     sub  ecx,3
  243.     dec  edx
  244.     jnz  x_mn
  245.     mov  dword [image_area+esi+ecx+0],0xffffffff
  246.     sub  edi,[img_xsize]
  247.     sub  edi,[img_xsize]
  248.     sub  edi,[img_xsize]
  249.     sub  esi,[img_xsize]
  250.     sub  esi,[img_xsize]
  251.     sub  esi,[img_xsize]
  252.     sub  esi,3
  253.     dec  ebp
  254.     jns  x_mns
  255.  
  256.     inc  [img_xsize]
  257.     jmp  red
  258. no_right:
  259.  
  260.     cmp  ah,8
  261.     jne  no_up
  262.     dec  [img_ysize]
  263.     jmp  red
  264. no_up:
  265.  
  266.     cmp  ah,9
  267.     jne  no_down
  268.     inc  [img_ysize]
  269.     jmp  red
  270. no_down:
  271.  
  272. ;SAVE MIA
  273.     cmp  ah,80
  274.     jne  no_save
  275.     savedialog draw_window, mia_is_save, still, string
  276. mia_is_save:
  277.     mov  dword [fileinfo],1 ;write
  278.     mov  eax,[img_xsize]
  279.     mul  [img_ysize]
  280.     mov  edx,eax
  281.     add  edx,eax
  282.     add  edx,eax
  283.     add  edx,8
  284.     cmp  edx,1024*768*3+20000
  285.     ja   still
  286.     mov  dword [fileinfo+12],image  ;from read
  287.     mov  dword [fileinfo+8],edx ;1
  288.     mov  eax,58
  289.     mov  ebx,fileinfo
  290.     int  0x40
  291. ;    puttxt 20,4,string,40,cl_White
  292.     jmp still
  293. no_save:
  294.  
  295. ;OPEN MIA
  296.     cmp ah,81
  297.     jne no_open
  298.     opendialog draw_window, mia_is_open, still, string
  299. mia_is_open:
  300.     mov  dword [fileinfo],0 ;read
  301.     mov  dword [fileinfo+12],image  ;from read
  302.     mov  dword [fileinfo+8],1
  303.     mov  eax,58
  304.     mov  ebx,fileinfo
  305.     int  0x40
  306.     mov  eax,ebx
  307.     shr  eax,9
  308.     inc  eax
  309.     mov  dword [fileinfo+8],eax
  310.     mov  eax,58
  311.     mov  ebx,fileinfo
  312.     int  0x40
  313. ;    puttxt 20,4,string,40,cl_White
  314.     jmp red
  315. no_open:
  316.  
  317.     cmp  ah,82
  318.     jne  no_save_mhc
  319.  
  320.  
  321.     savedialog draw_window, mhi_is_save, still, string
  322. mhi_is_save:
  323.     call fill_filebufs
  324.     mov  eax,[img_xsize]
  325.     mul  [img_ysize]
  326.     mov  edx,eax
  327.     add  edx,eax
  328.     add  edx,eax
  329.     add  edx,8
  330.     mov ecx,edx
  331.     mov esi,image
  332.     mov edi,ifile
  333.     cld
  334.     rep movsb
  335.     mov eax,edx
  336.     call compress
  337.     cmp  edx,1024*768*3+20000
  338.     ja   still
  339.     mov  dword [fileinfo],1 ;write
  340.     mov  dword [fileinfo+12],ofile  ;from read
  341.     mov  dword [fileinfo+8],edx ;1
  342.     mov  eax,58
  343.     mov  ebx,fileinfo
  344.     int  0x40
  345. ;    puttxt 20,4,string,40,cl_White
  346.     jmp still
  347.  
  348. no_save_mhc:
  349.  
  350. ;OPEN MHI
  351.     cmp  ah,83
  352.     jne  no_open_mhc
  353.  
  354.     opendialog draw_window, mhi_is_open, still, string
  355. mhi_is_open:
  356.  
  357.     call fill_filebufs
  358.  
  359.     mov  dword [fileinfo],0 ;read
  360.     mov  dword [fileinfo+12],ofile  ;ofile for decompress
  361.     mov  dword [fileinfo+8],1
  362.     mov  eax,58
  363.     mov  ebx,fileinfo
  364.     int  0x40
  365.     push ebx ;push file size
  366.     mov  eax,ebx
  367.     shr  eax,9
  368.     inc  eax
  369.     mov  dword [fileinfo+8],eax
  370.     mov  eax,58
  371.     mov  ebx,fileinfo
  372.     int  0x40
  373.  
  374. ;    puttxt 20,4,string,40,cl_White
  375. ;    delay 100
  376.     pop  eax ;pop file size
  377.     call decompress
  378.  
  379.     mov ecx,edx
  380.     mov esi,ifile ;image
  381.     mov edi,image ;ifile
  382.     cld
  383.     rep movsb
  384.  
  385.     jmp  red
  386. no_open_mhc:
  387.  
  388.     cmp  ah,84
  389.     jne  no_save_bmp
  390.     jmp  still
  391. no_save_bmp:
  392.  
  393.     cmp  ah,85
  394.     jne  no_open_bmp
  395.  
  396.     opendialog draw_window, bmp_is_open, still, string
  397.  
  398. bmp_is_open:
  399.     mov  dword [fileinfo],0  ;read
  400.     mov  dword [fileinfo+12],MHC_END  ;from read
  401.  
  402.     mov  dword [fileinfo+8],1
  403.     mov  eax,58
  404.     mov  ebx,fileinfo
  405.     int  0x40
  406.     mov  eax,[MHC_END+2]
  407.     shr  eax,9
  408.     inc  eax
  409.     mov  dword [fileinfo+8],eax
  410.     mov  eax,58
  411.     mov  ebx,fileinfo
  412.     int  0x40
  413.  
  414. ;    puttxt 20,4,string,40,cl_White
  415.     bmptoimg MHC_END,image
  416.  
  417.     jmp red
  418.  
  419. no_open_bmp:
  420.  
  421.  
  422.     cmp  ah,86
  423.     jne  no_save_gif
  424.     jmp  still
  425. no_save_gif:
  426.  
  427.     cmp  ah,87
  428.     jne  no_open_gif
  429.  
  430.     opendialog draw_window, gif_is_open, still, string
  431.  
  432. gif_is_open:
  433.     mov  dword [fileinfo],0  ;read
  434.     mov  dword [fileinfo+12],MHC_END  ;from read
  435.  
  436.     mov  dword [fileinfo+8],1
  437.     mov  eax,58
  438.     mov  ebx,fileinfo
  439.     int  0x40
  440.     mov  eax,[MHC_END+2]
  441.     shr  eax,9
  442.     inc  eax
  443.     mov  dword [fileinfo+8],eax
  444.     mov  eax,58
  445.     mov  ebx,fileinfo
  446.     int  0x40
  447.  
  448.     puttxt 20,4,string,40,cl_White
  449.     giftoimg MHC_END,image
  450.  
  451.     jmp red
  452.  
  453. no_open_gif:
  454.  
  455.  
  456.  
  457.     cmp ah,100
  458.     jne nor1
  459.  
  460.     mov  eax,[img_xsize]
  461.     mul  [img_ysize]
  462.     mov  edx,eax
  463.     add  edx,eax
  464.     add  edx,eax
  465.     mov  esi,image+8
  466. norx:
  467.     mov al,byte [esi+2]
  468.     and al,01b ;10000000b
  469.     cmp al,0
  470.     jna xe
  471. ;    mov al,255
  472.     mov byte [esi],0;255
  473.     mov byte [esi+1],0;0
  474.     mov byte [esi+2],255;0
  475.     jmp xa
  476. xe:
  477.     mov byte [esi],255
  478.     mov byte [esi+1],255
  479.     mov byte [esi+2],255
  480. xa:
  481.     add esi,3
  482.     cmp esi,edx
  483.     jnae norx
  484.     jmp red
  485. nor1:
  486.  
  487.     jmp still
  488.  
  489. fileinfo:
  490.     dd 0
  491.     dd 0
  492.     dd 1
  493.     dd MHC_END
  494.     dd out_image_area ;16384
  495. string:
  496. times 256 db 0
  497. ;times 256 db 0
  498. ;times 256 db 0
  499.  
  500. ;filename db    "IMAGE   MIA"
  501. ;mhcfilename db "IMAGE   MHI"
  502.  
  503. soi dd 0
  504. pxs dd 0
  505. pys dd 0
  506.  
  507. out_image:
  508.     mov eax,[prcinfo.x_size]
  509.     sub eax,21
  510.     cmp eax,[img_xsize] ;640
  511.     jna no_x
  512.     mov eax,[img_xsize] ;640
  513. no_x:
  514.     mov [pxs],eax
  515.     mov eax,[prcinfo.y_size]
  516.     sub eax,68
  517.     cmp eax,[img_ysize] ;480
  518.     jna no_y
  519.     mov eax,[img_ysize] ;480
  520. no_y:
  521.     mov [pys],eax
  522.  
  523.     mov eax,[pxs]
  524.     cmp eax,[img_xsize] ;640
  525.     jne trans
  526.     mov eax,[pys]
  527.     cmp eax,[img_ysize] ;480
  528.     jne trans
  529.  
  530.     mov eax,7
  531.     mov ebx,image_area
  532.     mov ecx,[pxs] ;640
  533.     shl ecx,16
  534.     add ecx,[pys] ;480
  535.     mov edx,(5+6)*65536+(22+6+30) ;+30 Reserve for buttons
  536.     int 0x40
  537.     ret
  538.  
  539. trans:
  540.     mov ebp,[pys];  180
  541.     mov esi,image_area
  542.     mov edi,out_image_area
  543. loox:
  544.     mov ecx,[pxs] ;200*3
  545.     add ecx,[pxs]
  546.     add ecx,[pxs]
  547.     cld
  548.     rep movsb
  549.     mov eax,[img_xsize] ;640
  550.     sub eax,[pxs]
  551.     add esi,eax
  552.     add esi,eax
  553.     add esi,eax
  554.  
  555.     dec ebp
  556.     jnz loox
  557.  
  558.     mov eax,7
  559.     mov ebx,out_image_area
  560.     mov ecx,[pxs]
  561.     shl ecx,16
  562.     add ecx,[pys]
  563.  
  564.     mov edx,(5+6)*65536+(22+6+30) ;+30 Reserve for buttons
  565.     int 0x40
  566.     ret
  567.  
  568.  
  569. ;set put to massive
  570. puti:
  571.     mov eax,edx
  572.     mov ebx,ecx
  573.  
  574. setput:
  575.     pushad
  576.     cmp eax,[img_xsize] ;640
  577.     jae nosetput
  578.     cmp ebx,[img_ysize] ;480
  579.     jae nosetput
  580.     mov edi,ebx
  581.     mov ebx,3  ;x*3
  582.     mul ebx
  583.     mov esi,eax
  584.     mov eax,[img_xsize] ;640*3 ;Y*640*3
  585.     add eax,[img_xsize]
  586.     add eax,[img_xsize]
  587.     mov ebx,edi
  588.     mul ebx
  589.     add eax,esi
  590.  
  591.     mov ebp,[img_xsize]
  592.     shl ebp,4
  593.     add ebp,16
  594.     mov esi,ebp
  595.     add esi,ebp
  596.     add esi,ebp
  597.  
  598.     sub eax,esi   ;(16+640*16)*3
  599.  
  600.     mov esi,0
  601. mlix:
  602.     push eax
  603.  
  604.     mov edi,[matrix+esi*4]
  605. mloo:
  606.     shr edi,1
  607.     jnc nosp
  608. ;    cmp eax,640*480*3 ;for detect out of screen
  609. ;    jae  nosp
  610.     push eax
  611.     mov  eax,[img_xsize]
  612.     mul  [img_ysize]
  613.     mov  ebx,eax
  614.     add  ebx,eax
  615.     add  ebx,eax
  616.     pop  eax
  617.     cmp  eax,ebx
  618.     jae  nosp
  619.  
  620.     mov ebx,[color]
  621.     mov byte [image_area+eax],bl   ;0x00ff
  622.     shr ebx,8
  623.     mov byte [image_area+eax+1],bl ;0x33
  624.     shr ebx,8
  625.     mov byte [image_area+eax+2],bl ;0x33
  626. nosp:
  627.     add eax,3
  628.     cmp edi,0
  629.     jne mloo
  630.  
  631.     pop eax
  632.     add eax,[img_xsize]   ;640*3
  633.     add eax,[img_xsize]
  634.     add eax,[img_xsize]
  635.     inc esi
  636.     cmp esi,32
  637.     jnae mlix
  638.  
  639. nosetput:
  640.     popad
  641.     ret
  642.  
  643. matrix:
  644. times 32 dd 0
  645.  
  646. brushtable:
  647. ;standart put
  648. times 12 dd 0
  649.   dd 00000000000000000000000000000000b
  650.   dd 00000000000000000000000000000000b
  651.   dd 00000000000000000000000000000000b
  652.   dd 00000000000000000000000000000000b
  653.   dd 00000000000000010000000000000000b
  654.   dd 00000000000000000000000000000000b
  655.   dd 00000000000000000000000000000000b
  656.   dd 00000000000000000000000000000000b
  657. times 12 dd 0
  658.  
  659. ;put size 2
  660. times 12 dd 0
  661.   dd 00000000000000000000000000000000b
  662.   dd 00000000000000000000000000000000b
  663.   dd 00000000000000000000000000000000b
  664.   dd 00000000000000000000000000000000b
  665.   dd 00000000000000011000000000000000b
  666.   dd 00000000000000011000000000000000b
  667.   dd 00000000000000000000000000000000b
  668.   dd 00000000000000000000000000000000b
  669. times 12 dd 0
  670.  
  671. ;put size 3
  672. times 12 dd 0
  673.   dd 00000000000000000000000000000000b
  674.   dd 00000000000000000000000000000000b
  675.   dd 00000000000000000000000000000000b
  676.   dd 00000000000000111000000000000000b
  677.   dd 00000000000000111000000000000000b
  678.   dd 00000000000000111000000000000000b
  679.   dd 00000000000000000000000000000000b
  680.   dd 00000000000000000000000000000000b
  681. times 12 dd 0
  682.  
  683. ;put size 4
  684. times 12 dd 0
  685.   dd 00000000000000000000000000000000b
  686.   dd 00000000000000000000000000000000b
  687.   dd 00000000000000111000000000000000b
  688.   dd 00000000000001111100000000000000b
  689.   dd 00000000000001111100000000000000b
  690.   dd 00000000000001111100000000000000b
  691.   dd 00000000000000111000000000000000b
  692.   dd 00000000000000000000000000000000b
  693. times 12 dd 0
  694.  
  695.  
  696. ;put slash ld-ru
  697. times 12 dd 0
  698.   dd 00000000000000000000000000000000b
  699.   dd 00000000000000000010000000000000b
  700.   dd 00000000000000000100000000000000b
  701.   dd 00000000000000001000000000000000b
  702.   dd 00000000000000010000000000000000b
  703.   dd 00000000000000100000000000000000b
  704.   dd 00000000000001000000000000000000b
  705.   dd 00000000000010000000000000000000b
  706. times 12 dd 0
  707.  
  708. ;put slash lu-rd
  709. times 12 dd 0
  710.   dd 00000000000000000000000000000000b
  711.   dd 00000000000010000000000000000000b
  712.   dd 00000000000001000000000000000000b
  713.   dd 00000000000000100000000000000000b
  714.   dd 00000000000000010000000000000000b
  715.   dd 00000000000000001000000000000000b
  716.   dd 00000000000000000100000000000000b
  717.   dd 00000000000000000010000000000000b
  718. times 12 dd 0
  719.  
  720. ;pricel
  721. times 8 dd 0
  722.   dd 00000000000000000000000000000000b
  723.   dd 00000000000000010000000000000000b
  724.   dd 00000000000000010000000000000000b
  725.   dd 00000000000000010000000000000000b
  726.   dd 00000000000000010000000000000000b
  727.   dd 00000000000011111110000000000000b
  728.   dd 00000000000010010010000000000000b
  729.   dd 00000000000010000010000000000000b
  730.   dd 00000000111111010111111000000000b
  731.   dd 00000000000010000010000000000000b
  732.   dd 00000000000010010010000000000000b
  733.   dd 00000000000011111110000000000000b
  734.   dd 00000000000000010000000000000000b
  735.   dd 00000000000000010000000000000000b
  736.   dd 00000000000000010000000000000000b
  737.   dd 00000000000000010000000000000000b
  738. times 8 dd 0
  739.  
  740. ;krest
  741. times 12 dd 0
  742.   dd 00000000000000000000000000000000b
  743.   dd 00000000000010000010000000000000b
  744.   dd 00000000000001000100000000000000b
  745.   dd 00000000000000101000000000000000b
  746.   dd 00000000000000010000000000000000b
  747.   dd 00000000000000101000000000000000b
  748.   dd 00000000000001000100000000000000b
  749.   dd 00000000000010000010000000000000b
  750. times 12 dd 0
  751.  
  752. ;krest
  753. times 12 dd 0
  754.   dd 00000000000000000000000000000000b
  755.   dd 00000000000010000010000000000000b
  756.   dd 00000000000000000000000000000000b
  757.   dd 00000000000000000000000000000000b
  758.   dd 00000000000000000000000000000000b
  759.   dd 00000000000000000000000000000000b
  760.   dd 00000000000000000000000000000000b
  761.   dd 00000000000010000010000000000000b
  762. times 12 dd 0
  763.  
  764.  
  765. ;smile
  766. times 8 dd 0
  767.   dd 00000111110000000000000b
  768.   dd 00011000001100000000000b
  769.   dd 00100000000010000000000b
  770.   dd 01000000000001000000000b
  771.   dd 01000000000001000000000b
  772.   dd 10001100011000100000000b
  773.   dd 10001100011000100000000b
  774.   dd 10000000000000100000000b
  775.   dd 10000000000000100000000b
  776.   dd 10010000000100100000000b
  777.   dd 01001000001001000000000b
  778.   dd 01000111110001000000000b
  779.   dd 00100000000010000000000b
  780.   dd 00011000001100000000000b
  781.   dd 00000111110000000000000b
  782.   dd 00000000000000000000000000000000b
  783. times 8 dd 0
  784.  
  785. ;round
  786.   dd 00000000000111111111100000000000b
  787.   dd 00000000011000000000011000000000b
  788.   dd 00000001100000000000000110000000b
  789.   dd 00000010000000000000000001000000b
  790.   dd 00000100000000000000000000100000b
  791.   dd 00001000000000000000000000010000b
  792.   dd 00010000000000000000000000001000b
  793.   dd 00100000000000000000000000000100b
  794.   dd 00100000000000000000000000000100b
  795.   dd 01000000000000000000000000000010b
  796.   dd 01000000000000000000000000000010b
  797.   dd 10000000000000000000000000000001b
  798.   dd 10000000000000000000000000000001b
  799.   dd 10000000000000000000000000000001b
  800.   dd 10000000000000000000000000000001b
  801.   dd 10000000000000000000000000000001b
  802.   dd 10000000000000000000000000000001b
  803.   dd 10000000000000000000000000000001b
  804.   dd 10000000000000000000000000000001b
  805.   dd 10000000000000000000000000000001b
  806.   dd 10000000000000000000000000000001b
  807.   dd 01000000000000000000000000000010b
  808.   dd 01000000000000000000000000000010b
  809.   dd 00100000000000000000000000000100b
  810.   dd 00100000000000000000000000000100b
  811.   dd 00010000000000000000000000001000b
  812.   dd 00001000000000000000000000010000b
  813.   dd 00000100000000000000000000100000b
  814.   dd 00000010000000000000000001000000b
  815.   dd 00000001100000000000000110000000b
  816.   dd 00000000011000000000011000000000b
  817.   dd 00000000000111111111100000000000b
  818.  
  819.  
  820. ;Draw line procedure
  821. line:
  822.         jmp n
  823. previous_X      dw      -1
  824. previous_Y      dw      -1
  825. X_increment     dw      -1
  826. Y_increment     dw      -1
  827. n:
  828.  push ax
  829.  push bx
  830.  push cx
  831.  push dx
  832.  pop cx ;yed
  833.         pop dx ;xed
  834.         pop [previous_Y]
  835.         pop [previous_X]
  836.  
  837.         mov ax,cx
  838.         sub ax,[previous_X]
  839.         jns dx_pos
  840.         neg ax
  841.         mov [X_increment],1
  842.         jmp dx_neg
  843. dx_pos: mov [X_increment],-1
  844. dx_neg: mov bx,dx
  845.         sub bx,[previous_Y]
  846.         jns dy_pos
  847.         neg bx
  848.         mov [Y_increment],1
  849.         jmp dy_neg
  850. dy_pos: mov [Y_increment],-1
  851. dy_neg: shl ax,1
  852.         shl bx,1
  853.         pusha
  854.         call puti
  855.         popa
  856.         cmp ax,bx
  857.         jna dx_le_dy
  858.         mov di,ax
  859.         shr di,1
  860.         neg di
  861.         add di,bx
  862. cycle:
  863.         cmp cx,[previous_X]
  864.         je exit_bres
  865.         cmp di,0
  866.         jl fractlt0
  867.         add dx,[Y_increment]
  868.         sub di,ax
  869. fractlt0:
  870.         add cx,[X_increment]
  871.         add di,bx
  872.         pusha
  873.         call puti
  874.         popa
  875.         jmp cycle
  876. dx_le_dy:
  877.         mov di,bx
  878.         shr di,1
  879.         neg di
  880.         add di,ax
  881. cycle2:
  882.         cmp dx,[previous_Y]
  883.         je exit_bres
  884.         cmp di,0
  885.         jl fractlt02
  886.         add cx,[X_increment]
  887.         sub di,bx
  888. fractlt02:
  889.         add dx,[Y_increment]
  890.         add di,ax
  891.         pusha
  892.         call puti
  893.         popa
  894.         jmp cycle2
  895. exit_bres:
  896.  ret
  897.  
  898.  
  899. draw_window:
  900.     startwd
  901.     window 40,40,(586+8),(380+24),window_Skinned+0x00ffffff
  902.     label 12,8,'2D EXAMPLE: ASCL XPAINT',cl_White+font_Big
  903.  
  904. ;   Get proc info
  905.     mov eax,9
  906.     mov ebx,prcinfo
  907.     mov ecx,-1
  908.     int 0x40
  909.  
  910.     mov eax,[prcinfo.x_size]
  911.     mov ebp,[prcinfo.y_size]
  912.     sub eax,5+4
  913.     sub ebp,22+4
  914.  
  915.     drawfbox 5,22,eax,ebp,0x00e0f0f4
  916. ;    call out_image
  917.  
  918. ; draw resize buttons
  919.     mov eax,8
  920.     mov ebx,(341)*65536+9
  921.     mov ecx,(22+6+6)*65536+6
  922.     mov edx,6 ;start with 6
  923.     mov esi,0x00aaaaaa
  924.     int 0x40
  925.     inc edx
  926.     add ebx,15*65536
  927.     int 0x40
  928.     mov ebx,(340+10)*65536+6
  929.     mov ecx,(22+6-2)*65536+8
  930.     inc edx
  931.     mov esi,0x00aaaaaa
  932.     int 0x40
  933.     inc edx
  934.     add ecx,14*65536
  935.     int 0x40
  936.  
  937. ;Draw now and back color
  938.     drawfbox 20,32,20,15,[backcolor]
  939.     drawfbox 12,28,20,15,[color]
  940.  
  941.  
  942. ;Draw buttons color set
  943.     mov eax,8
  944.     mov ebx,(40+6)*65536+8
  945.     mov ecx,(22+6)*65536+8
  946.     mov edx,10 ;start with 10
  947.     mov edi,0
  948. nextbut:
  949.     mov esi,dword [colorbuttable+edi*4]
  950.     int 0x40
  951.     add ecx,(10)*65536
  952.     inc edx
  953.     inc edi
  954.     mov esi,dword [colorbuttable+edi*4]
  955.     int 0x40
  956.     sub ecx,(10)*65536
  957.     add ebx,(10)*65536
  958.     inc edx
  959.     inc edi
  960.     cmp edi,32   ;64 buttons, 2 string of 32 buttons
  961.     jnae nextbut
  962.  
  963. ;Save as not ziped image button
  964.     mov eax,8
  965.     mov ebx,(365+6)*65536+50
  966.     mov ecx,(22+6)*65536+8
  967.     mov edx,80 ;ID
  968.     mov esi,cl_Grey
  969.     int 0x40
  970.  
  971. label (365+7),(22+7),"SAVE MIA",cl_White
  972.  
  973. ;Open not zipped image button
  974.     mov eax,8
  975.     mov ebx,(365+6)*65536+50
  976.     mov ecx,(36+6)*65536+8
  977.     mov edx,81 ;ID
  978.     mov esi,cl_Grey
  979.     int 0x40
  980.  
  981. label (365+7),(36+7),"OPEN MIA",cl_White
  982.  
  983. ;Save as MHC ziped image button
  984.     mov eax,8
  985.     mov ebx,(420+6)*65536+50
  986.     mov ecx,(22+6)*65536+8
  987.     mov edx,82 ;ID
  988.     mov esi,cl_Grey
  989.     int 0x40
  990.  
  991. label (420+7),(22+7),"SAVE MHI",cl_White
  992.  
  993. ;Open MHC zipped image button
  994.     mov eax,8
  995.     mov ebx,(420+6)*65536+50
  996.     mov ecx,(36+6)*65536+8
  997.     mov edx,83 ;ID
  998.     mov esi,cl_Grey
  999.     int 0x40
  1000.  
  1001. label (420+7),(36+7),"OPEN MHI",cl_White
  1002.  
  1003. ;Save as Bitmap image button
  1004.     mov eax,8
  1005.     mov ebx,(475+6)*65536+50
  1006.     mov ecx,(22+6)*65536+8
  1007.     mov edx,84 ;ID
  1008.     mov esi,cl_Grey
  1009.     int 0x40
  1010.  
  1011. label (475+7),(22+7),"SAVE NOT",cl_White
  1012.  
  1013. ;Open Bitmap image button
  1014.     mov eax,8
  1015.     mov ebx,(475+6)*65536+50
  1016.     mov ecx,(36+6)*65536+8
  1017.     mov edx,85 ;ID
  1018.     mov esi,cl_Grey
  1019.     int 0x40
  1020.  
  1021. label (475+7),(36+7),"OPEN BMP",cl_White
  1022.  
  1023. ;Save as GIF image button
  1024.     mov eax,8
  1025.     mov ebx,(530+6)*65536+50
  1026.     mov ecx,(22+6)*65536+8
  1027.     mov edx,86 ;ID
  1028.     mov esi,cl_Grey
  1029.     int 0x40
  1030.  
  1031. label (530+7),(22+7),"SAVE NOT",cl_White
  1032.  
  1033. ;Open GIF image button
  1034.     mov eax,8
  1035.     mov ebx,(530+6)*65536+50
  1036.     mov ecx,(36+6)*65536+8
  1037.     mov edx,87 ;ID
  1038.     mov esi,cl_Grey
  1039.     int 0x40
  1040.  
  1041. label (530+7),(36+7),"OPEN GIF",cl_White
  1042.  
  1043. ;Draw filter buttons
  1044.     mov eax,8
  1045.     mov ebx,(590+6)*65536+6
  1046.     mov ecx,(22+6)*65536+6
  1047.     mov edx,100 ;start with 100
  1048.     mov edi,0
  1049. nextfbut:
  1050.     mov esi,0x00aa0000
  1051.     int 0x40
  1052.     add ecx,(8)*65536
  1053.     inc edx
  1054.     inc edi
  1055.     mov esi,0x0000aa00
  1056.     int 0x40
  1057.     add ecx,(8)*65536
  1058.     inc edx
  1059.     inc edi
  1060.     mov esi,0x000000aa
  1061.     int 0x40
  1062.     sub ecx,(8*2)*65536
  1063.     add ebx,(8)*65536
  1064.     inc edx
  1065.     inc edi
  1066.     cmp edi,8*3  ;24 buttons, 3 string of 8 buttons
  1067.     jnae nextfbut
  1068.  
  1069.  
  1070.     endwd
  1071.     call out_image
  1072.     ret
  1073.  
  1074.  
  1075. ; Get from MHC Archiver by Nikita Lesnikov
  1076. ; ======== compression/decompression engine ========
  1077.  
  1078.  compress:   ; File compression
  1079.  
  1080.  compress_filefound:
  1081.  
  1082.  jmp lzp_compress                    ; compress with order-2 LZP
  1083.  compress_dumpdata:
  1084.  
  1085.  ret
  1086.  
  1087.  decompress: ; File decompression
  1088.  
  1089.  decompress_filefound:
  1090.  
  1091.  cmp byte [ofile],0                     ; Invalid method!
  1092.  jz  right_method
  1093.  mov edx,0 ;0 size
  1094.  ret
  1095.  
  1096.  right_method:
  1097.  
  1098.  jmp lzp_decompress
  1099.  decompress_dumpdata:
  1100.  
  1101.  ret
  1102.  
  1103.  fill_filebufs:             ; Fill filebufs with garbage to simplify matching
  1104.  pusha
  1105.  cld
  1106.  mov eax,0xF7D9A03F         ; <- "magic number" :) just garbage...
  1107.  mov ecx,2000000/2 ;4
  1108.  mov edi,ifile
  1109.  rep stosd
  1110.  popa
  1111.  ret
  1112.  
  1113. ; ==== algorithms section ====
  1114.  
  1115. ; Method 0: LZP compression algorithm
  1116.  
  1117.  lzp_compress:           ; EDX - how much bytes to dump
  1118.  
  1119.  cld                     ; clear direction flag
  1120.  
  1121.  mov esi,ifile           ; init pointers
  1122.  mov edi,ofile
  1123.  
  1124.  push eax                ; write header: ID0+4bfilesize => total 5 bytes
  1125.  xor eax,eax
  1126.  stosb
  1127.  pop eax
  1128.  stosd
  1129.  
  1130.  pusha                   ; fill hash table
  1131.  mov eax,ifile
  1132.  mov edi,hashtable
  1133.  mov ecx,65536*2 ;*1
  1134.  rep stosd
  1135.  popa
  1136.  
  1137.  add eax,esi              ; calculate endpointer
  1138.  mov dword [endpointer],eax
  1139.  
  1140.  movsw                    ; copy three bytes
  1141.  movsb
  1142.  
  1143.  mov dword [controlp],edi
  1144.  inc edi
  1145.  
  1146.  mov byte [controld],0
  1147.  mov byte [controlb],0
  1148.  
  1149.  c_loop:
  1150.  cmp dword [endpointer],esi  ; check end of file
  1151.  ja  c_loop_ok
  1152.  jmp finish_c_loop
  1153.  c_loop_ok:
  1154.  
  1155.  call chash
  1156.  call compare
  1157.  jz   two_match_c
  1158.  
  1159.  lodsb
  1160.  mov byte [literal],al
  1161.  call chash
  1162.  call compare
  1163.  jz   lit_match_c
  1164.  
  1165.  mov  al,0
  1166.  call putbit
  1167.  mov  al,byte [literal]
  1168.  stosb
  1169.  movsb
  1170.  jmp  end_c_loop
  1171.  
  1172.  lit_match_c:
  1173.  mov al,1
  1174.  call putbit
  1175.  mov al,0
  1176.  call putbit
  1177.  mov al,byte [literal]
  1178.  stosb
  1179.  jmp encode_match
  1180.  
  1181.  two_match_c:
  1182.  mov al,1
  1183.  call putbit
  1184.  call putbit
  1185.  
  1186.  encode_match:
  1187.  call incpos
  1188.  call compare
  1189.  jz one_c
  1190.  mov al,0
  1191.  call putbit
  1192.  jmp end_c_loop
  1193.  one_c:
  1194.  
  1195.  call incpos
  1196.  mov  al,1
  1197.  call putbit
  1198.  
  1199.  call compare
  1200.  jnz ec1
  1201.  call incpos
  1202.  call compare
  1203.  jnz ec2
  1204.  call incpos
  1205.  call compare
  1206.  jnz ec3
  1207.  call incpos
  1208.  mov al,1
  1209.  call putbit
  1210.  call putbit
  1211.  call compare
  1212.  jnz ec4
  1213.  call incpos
  1214.  call compare
  1215.  jnz ec5
  1216.  call incpos
  1217.  call compare
  1218.  jnz ec6
  1219.  call incpos
  1220.  call compare
  1221.  jnz ec7
  1222.  call incpos
  1223.  call compare
  1224.  jnz ec8
  1225.  call incpos
  1226.  call compare
  1227.  jnz ec9
  1228.  call incpos
  1229.  call compare
  1230.  jnz ec10
  1231.  call incpos
  1232.  
  1233.  mov al,1
  1234.  call putbit
  1235.  call putbit
  1236.  call putbit
  1237.  xor  ecx,ecx
  1238.  
  1239.  match_loop_c:
  1240.  cmp  esi,dword [endpointer]
  1241.  jae   out_match_loop_c
  1242.  call compare
  1243.  jnz  out_match_loop_c
  1244.  inc  ecx
  1245.  call incpos
  1246.  jmp  match_loop_c
  1247.  out_match_loop_c:
  1248.  
  1249.  mov al,0xFF
  1250.  out_lg:
  1251.  cmp ecx,255
  1252.  jb  out_lg_out
  1253.  stosb
  1254.  sub ecx,255
  1255.  jmp out_lg
  1256.  out_lg_out:
  1257.  mov al,cl
  1258.  stosb
  1259.  jmp end_c_loop
  1260.  
  1261.  ec10:
  1262.  mov al,1
  1263.  call putbit
  1264.  call putbit
  1265.  mov al,0
  1266.  call putbit
  1267.  jmp end_c_loop
  1268.  
  1269.  ec9:
  1270.  mov al,1
  1271.  call putbit
  1272.  mov al,0
  1273.  call putbit
  1274.  mov al,1
  1275.  call putbit
  1276.  jmp end_c_loop
  1277.  
  1278.  ec8:
  1279.  mov al,1
  1280.  call putbit
  1281.  mov al,0
  1282.  call putbit
  1283.  call putbit
  1284.  jmp end_c_loop
  1285.  
  1286.  ec7:
  1287.  mov al,0
  1288.  call putbit
  1289.  mov al,1
  1290.  call putbit
  1291.  call putbit
  1292.  jmp end_c_loop
  1293.  
  1294.  ec6:
  1295.  mov al,0
  1296.  call putbit
  1297.  mov al,1
  1298.  call putbit
  1299.  mov al,0
  1300.  call putbit
  1301.  jmp end_c_loop
  1302.  
  1303.  ec5:
  1304.  mov al,0
  1305.  call putbit
  1306.  call putbit
  1307.  mov al,1
  1308.  call putbit
  1309.  jmp end_c_loop
  1310.  
  1311.  ec4:
  1312.  mov al,0
  1313.  call putbit
  1314.  call putbit
  1315.  call putbit
  1316.  jmp end_c_loop
  1317.  
  1318.  ec3:
  1319.  mov al,1
  1320.  call putbit
  1321.  mov al,0
  1322.  call putbit
  1323.  jmp end_c_loop
  1324.  
  1325.  ec2:
  1326.  mov al,0
  1327.  call putbit
  1328.  mov al,1
  1329.  call putbit
  1330.  jmp end_c_loop
  1331.  
  1332.  ec1:
  1333.  mov al,0
  1334.  call putbit
  1335.  call putbit
  1336.  
  1337.  end_c_loop:
  1338.  jmp c_loop
  1339.  
  1340.  finish_c_loop:
  1341.  
  1342.  mov eax,dword [controlp] ; store last tagbyte
  1343.  mov bl,byte [controld]
  1344.  mov [eax], byte bl
  1345.  
  1346.  sub edi,ofile ; calculate dump size
  1347.  mov edx,edi
  1348.  
  1349.  jmp compress_dumpdata
  1350.  
  1351. ; LZP decompression algorithm
  1352.  
  1353.  lzp_decompress:                        ; EDX - how much bytes to dump
  1354.  
  1355.  cld
  1356.  
  1357.  mov edi,ifile
  1358.  mov esi,ofile+1
  1359.  
  1360.  pusha                   ; fill hash table
  1361.  mov eax,ifile
  1362.  mov edi,hashtable
  1363.  mov ecx,65536*2 ;*1
  1364.  rep stosd
  1365.  popa
  1366.  
  1367.  lodsd
  1368.  
  1369.  mov ebx,edi
  1370.  add ebx,eax
  1371.  mov dword [endpointer],ebx
  1372.  
  1373.  movsw
  1374.  movsb
  1375.  
  1376.  lodsb
  1377.  mov byte [controld],al
  1378.  mov byte [controlb],0
  1379.  
  1380.  d_loop:
  1381.  cmp dword [endpointer],edi
  1382.  ja d_loop_ok
  1383.  jmp finish_d_loop
  1384.  d_loop_ok:
  1385.  
  1386.  call getbit
  1387.  cmp  al,0
  1388.  jnz  match_d
  1389.  call dhash
  1390.  movsb
  1391.  call dhash
  1392.  movsb
  1393.  jmp end_d_loop
  1394.  
  1395.  match_d:
  1396.  
  1397.  call getbit
  1398.  cmp  al,0
  1399.  jnz  no_literal_before_match
  1400.  call dhash
  1401.  movsb
  1402.  no_literal_before_match:
  1403.  
  1404.  call dhash
  1405.  mov ecx,1
  1406.  call copymatch
  1407.  
  1408.  call getbit
  1409.  cmp  al,0
  1410.  jz   end_d_loop
  1411.  mov  ecx,1
  1412.  call copymatch
  1413.  call getbit
  1414.  cmp  al,0
  1415.  jz   dc2
  1416.  mov  ecx,2
  1417.  call copymatch
  1418.  call getbit
  1419.  cmp  al,0
  1420.  jz   end_d_loop
  1421.  mov  ecx,1
  1422.  call copymatch
  1423.  call getbit
  1424.  cmp  al,0
  1425.  jz   dc4
  1426.  mov  ecx,4
  1427.  call copymatch
  1428.  call getbit
  1429.  cmp  al,0
  1430.  jz   dc5
  1431.  call getbit
  1432.  cmp  al,0
  1433.  jz   dc6
  1434.  mov  ecx,3
  1435.  call copymatch
  1436.  
  1437.  do:
  1438.  lodsb
  1439.  xor  ecx,ecx
  1440.  mov  cl,al
  1441.  call copymatch
  1442.  cmp  al,0xFF
  1443.  jnz  end_do
  1444.  jmp do
  1445.  end_do:
  1446.  jmp end_d_loop
  1447.  
  1448.  dc6:
  1449.  mov ecx,2
  1450.  call copymatch
  1451.  jmp  end_d_loop
  1452.  
  1453.  dc5:
  1454.  call getbit
  1455.  cmp  al,0
  1456.  jz   ndc5
  1457.  mov  ecx,1
  1458.  call copymatch
  1459.  ndc5:
  1460.  jmp  end_d_loop
  1461.  
  1462.  dc4:
  1463.  call getbit
  1464.  cmp  al,0
  1465.  jz   ndc4
  1466.  call getbit
  1467.  mov  ecx,3
  1468.  cmp  al,1
  1469.  jz   ndcc4
  1470.  dec  ecx
  1471.  ndcc4:
  1472.  call copymatch
  1473.  jmp  end_d_loop
  1474.  ndc4:
  1475.  call getbit
  1476.  cmp  al,0
  1477.  jz   ndccc4
  1478.  mov  ecx,1
  1479.  call copymatch
  1480.  ndccc4:
  1481.  jmp  end_d_loop
  1482.  
  1483.  dc2:
  1484.  call getbit
  1485.  cmp al,0
  1486.  jz  ndc2
  1487.  mov ecx,1
  1488.  call copymatch
  1489.  ndc2:
  1490.  
  1491.  end_d_loop:
  1492.  jmp d_loop
  1493.  finish_d_loop:
  1494.  
  1495.  mov edx, dword [ofile+1]
  1496.  
  1497.  jmp decompress_dumpdata
  1498.  
  1499. ; LZP subroutines
  1500.  
  1501.  putbit:                  ; bit -> byte tag, AL holds bit for output
  1502.  pusha
  1503.  mov cl,byte [controlb]
  1504.  shl al,cl
  1505.  mov bl,byte [controld]
  1506.  or  bl,al
  1507.  mov byte [controld],bl
  1508.  inc cl
  1509.  cmp cl,8
  1510.  jnz just_increment
  1511.  mov byte [controlb],0
  1512.  mov byte [controld],0
  1513.  push edi
  1514.  mov  edi, dword [controlp]
  1515.  mov  al,bl
  1516.  stosb
  1517.  pop  edi
  1518.  mov dword [controlp],edi
  1519.  popa
  1520.  inc edi
  1521.  ret
  1522.  just_increment:
  1523.  mov byte [controlb],cl
  1524.  popa
  1525.  ret
  1526.  
  1527.  getbit:                       ; tag byte -> bit, AL holds input
  1528.  push ecx
  1529.  mov al,byte [controld]
  1530.  mov cl,byte [controlb]
  1531.  shr al,cl
  1532.  and al,1
  1533.  inc cl
  1534.  cmp cl,8
  1535.  jnz just_increment_d
  1536.  mov byte [controlb],0
  1537.  push eax
  1538.  lodsb
  1539.  mov byte [controld],al
  1540.  pop  eax
  1541.  pop  ecx
  1542.  ret
  1543.  just_increment_d:
  1544.  mov byte [controlb],cl
  1545.  pop ecx
  1546.  ret
  1547.  
  1548.  chash:                        ; calculate hash -> mp -> fill position
  1549.  pusha
  1550.  xor  eax,eax
  1551.  mov  al, byte [esi-1]
  1552.  mov  ah, byte [esi-2]
  1553.  shl  eax,2
  1554.  add  eax,hashtable
  1555.  mov  edx,dword [eax]
  1556.  mov  dword [mp],edx
  1557.  mov  dword [eax],esi
  1558.  popa
  1559.  ret
  1560.  
  1561.  dhash:                        ; calculate hash -> mp -> fill position
  1562.  pusha
  1563.  xor  eax,eax
  1564.  mov  al, byte [edi-1]
  1565.  mov  ah, byte [edi-2]
  1566.  shl  eax,2
  1567.  add  eax,hashtable
  1568.  mov  edx,dword [eax]
  1569.  mov  dword [mp],edx
  1570.  mov  dword [eax],edi
  1571.  popa
  1572.  ret
  1573.  
  1574.  copymatch:                    ; ECX bytes from [mp] to [rp]
  1575.  push esi
  1576.  mov  esi,dword [mp]
  1577.  rep  movsb
  1578.  mov  dword [mp],esi
  1579.  pop  esi
  1580.  ret
  1581.  
  1582.  compare:                      ; compare [mp] with [cpos]
  1583.  push edi
  1584.  push esi
  1585.  mov  edi,dword [mp]
  1586.  cmpsb
  1587.  pop  esi
  1588.  pop  edi
  1589.  ret
  1590.  
  1591.  incpos:
  1592.  inc  dword [mp]
  1593.  inc  esi
  1594.  ret
  1595.  
  1596.  
  1597. ; LZP algorithm data
  1598.  
  1599.  endpointer     dd      0
  1600.  controlp       dd      0
  1601.  controlb       db      0
  1602.  controld       db      0
  1603.  mp  dd 0
  1604.  literal        db      0
  1605.  
  1606. ; the end... - Nikita Lesnikov (nlo_one)
  1607.  
  1608.  
  1609.  
  1610. ; DATA AREA
  1611. newline dd 0
  1612. xt dd 100
  1613. yt dd 100
  1614. counter dd 0
  1615. tsoi dd 0
  1616. view dd 0
  1617. brush dd 0
  1618.  
  1619. color     dd 0x00000000
  1620. backcolor dd 0xffffff
  1621.  
  1622. colortable:
  1623.       dd 0x00000000  ;black
  1624.       dd 0x00FFFFFF  ;white
  1625.       dd 0x00808080  ;dark-gray
  1626.       dd 0x00C0C0C0  ;gray
  1627.       dd 0x00000080  ;dark-blue
  1628.       dd 0x000000ff  ;blue
  1629.       dd 0x00400080  ;dark-violet
  1630.       dd 0x008000ff  ;violet
  1631.       dd 0x00800080  ;dark-pink
  1632.       dd 0x00ff00ff  ;pink
  1633.       dd 0x00800040  ;
  1634.       dd 0x00ff0080  ;
  1635.       dd 0x00800000  ;brown
  1636.       dd 0x00ff0000  ;red
  1637.       dd 0x00802000  ;
  1638.       dd 0x00ff4000  ;dark-orange
  1639.       dd 0x00804000  ;
  1640.       dd 0x00ff8000  ;orange
  1641.       dd 0x00804000  ;
  1642.       dd 0x00ff8000  ;orange
  1643.       dd 0x00808000  ;oliva
  1644.       dd 0x00ffff00  ;yellow
  1645.       dd 0x00608000  ;
  1646.       dd 0x00C0ff00  ;
  1647.       dd 0x00408000  ;green
  1648.       dd 0x0080ff00  ;lime
  1649.       dd 0x00008000  ;
  1650.       dd 0x0000ff00  ;
  1651.       dd 0x00008040  ;dark-salat
  1652.       dd 0x0000ff80  ;salat
  1653.       dd 0x00008080  ;dark-water
  1654.       dd 0x0000ffff  ;water
  1655.  
  1656. colorbuttable:
  1657.       dd 0x001e1e1e  ;black
  1658.       dd 0x00dedede  ;white
  1659.       dd 0x00808080  ;dark-gray
  1660.       dd 0x00C0C0C0  ;gray
  1661.       dd 0x001e1e80  ;dark-blue
  1662.       dd 0x001e1ede  ;blue
  1663.       dd 0x00401e80  ;dark-violet
  1664.       dd 0x00801ede  ;violet
  1665.       dd 0x00801e80  ;dark-pink
  1666.       dd 0x00de1ede  ;pink
  1667.       dd 0x00801e40  ;
  1668.       dd 0x00de1e80  ;
  1669.       dd 0x00801e1e  ;brown
  1670.       dd 0x00de1e1e  ;red
  1671.       dd 0x0080201e  ;
  1672.       dd 0x00de401e  ;dark-orange
  1673.       dd 0x0080401e  ;
  1674.       dd 0x00de801e  ;orange
  1675.       dd 0x0080401e  ;
  1676.       dd 0x00de801e  ;orange
  1677.       dd 0x0080801e  ;oliva
  1678.       dd 0x00dede1e  ;yellow
  1679.       dd 0x0060801e  ;
  1680.       dd 0x00C0de1e  ;
  1681.       dd 0x0040801e  ;green
  1682.       dd 0x0080de1e  ;lime
  1683.       dd 0x001e801e  ;
  1684.       dd 0x001ede1e  ;
  1685.       dd 0x001e8040  ;dark-salat
  1686.       dd 0x001ede80  ;salat
  1687.       dd 0x00008080  ;dark-water
  1688.       dd 0x0000dede  ;water
  1689.  
  1690.  
  1691.  
  1692. prcinfo process_information
  1693.  
  1694. ;IM_END:
  1695. image:
  1696. img_xsize dd 200
  1697. img_ysize dd 180
  1698. IM_END:
  1699. image_area:
  1700. ;rb 1024*768*3
  1701.  
  1702. out_image_area = image_area+(1024*768*3)
  1703. ;rb 640*480*3
  1704.  
  1705. MHC_END = image_area+(1024*768*3)*2
  1706. I_END = MHC_END+6000000  ;6 megs for work mhc algorythm
  1707.