Subversion Repositories Kolibri OS

Rev

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

  1. ;-------------------------------------------------------------------------------
  2. ;
  3. ;    PROTECTION TEST
  4. ;
  5. ;-------------------------------------------------------------------------------
  6. ; last update:  07/03/2014
  7. ; changed by:   Marat Zakiyanov aka Mario79, aka Mario
  8. ; changes:      Optimisations and code refactoring.
  9. ;               Reducing the consumption of RAM, 4 KB instead of 64 KB.
  10. ;               Translation into Russian.
  11. ;---------------------------------------------------------------------
  12. use32
  13.         org 0x0
  14.  
  15.         db 'MENUET01'   ; 8 byte id
  16.         dd 0x01         ; header version
  17.         dd START        ; start of code
  18.         dd I_END        ; size of image
  19.         dd IM_END       ; memory for app
  20.         dd stack_top    ; esp
  21.         dd 0x0          ; I_Param
  22.         dd 0x0          ; I_Icon
  23. ;-------------------------------------------------------------------------------
  24. include '../../../macros.inc'
  25. include 'lang.inc'
  26. ;-------------------------------------------------------------------------------
  27. START:                          ; start of execution
  28. red:                            ; redraw
  29.         call    draw_window             ; at first, draw the window
  30. ;-------------------------------------------------------------------------------
  31. still:
  32.         mcall   10      ; wait here for event
  33.         cmp     eax,1   ; redraw request ?
  34.         jz      red
  35.  
  36.         cmp     eax,3   ; button in buffer ?
  37.         jz      button
  38.        
  39.         cmp     eax,2   ; key in buffer ?
  40.         jnz     still
  41. ;-------------------------------------------------------------------------------
  42. key:
  43.         mcall   2       ; just read it and ignore
  44.         jmp     still
  45. ;-------------------------------------------------------------------------------
  46. button:
  47.         mcall   17
  48.         cmp     ah,1    ; button id=1 ?
  49.         jnz     noclose
  50.  
  51.         mcall   -1      ; close this program
  52. ;-------------------------------------------------------------------------------
  53. noclose:
  54.         cmp     ah,2
  55.         jnz     notest2
  56.         cli
  57. ;-------------------------------------------------------------------------------
  58. notest2:
  59.         cmp     ah,3
  60.         jnz     notest3
  61.         sti
  62. ;-------------------------------------------------------------------------------
  63. notest3:
  64.         cmp     ah,4
  65.         jnz     notest4
  66.         mov     [0x10000],byte 1
  67. ;-------------------------------------------------------------------------------       
  68. notest4:
  69.         cmp     ah,5
  70.         jnz     notest5
  71.         jmp     dword 0x10000
  72. ;-------------------------------------------------------------------------------
  73. notest5:
  74.         cmp     ah,6
  75.         jnz     notest6
  76.         mov     esp,0
  77.         push    eax
  78. ;-------------------------------------------------------------------------------
  79. notest6:
  80.         cmp     ah,7
  81.         jnz     notest7
  82.         in      al,0x60
  83. ;-------------------------------------------------------------------------------
  84. notest7:
  85.         cmp     ah,8
  86.         jnz     still
  87.         out     0x60,al
  88.         jmp     still
  89. ;-------------------------------------------------------------------------------
  90. ;   *********************************************
  91. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  92. ;   *********************************************
  93. ;-------------------------------------------------------------------------------
  94. draw_window:
  95.         ;mcall  48,3,sys_colors,40
  96.         mcall   12,1
  97.         mcall   0,<200,292>,<200,230>,0x14FFFFFF,,tlabel
  98.         mov     eax,8                      ; function 8 : define and draw button
  99.         mov     ebx,32*65536+10     ; [x start] *65536 + [x size]
  100.         mov     ecx,75*65536+10     ; [y start] *65536 + [y size]
  101.         mov     edx,2                      ; button id
  102.         mov     esi,0x6888B8               ; button color RRGGBB
  103. .newb:
  104.         mcall
  105.         add     ecx,20*65536
  106.         inc     edx
  107.         cmp     edx,9
  108.         jb      .newb
  109.  
  110.         cld
  111.         mov     ebx,26*65536+37    ; draw info text with function 4
  112.         mov     ecx,0x000000
  113.         mov     edx,text
  114.         mov     esi,40
  115.        
  116.         mov     eax,4
  117. .newline:
  118.         mcall
  119.         add     ebx,10
  120.         add     edx,40
  121.         cmp     [edx],byte 'x'
  122.         jnz     .newline
  123.  
  124.         mcall   12,2               ; function 12:tell os about windowdraw
  125.         ret
  126. ;-------------------------------------------------------------------------------
  127. ; DATA AREA
  128. ;-------------------------------------------------------------------------------
  129. if lang eq it
  130. text:
  131.         db 'Il programma usa 0x1000 byte di memoria '
  132.         db '                                        '
  133.         db 'Open debug board for rezult information '
  134.         db '                                        '
  135.         db '     CLI                                '
  136.         db '                                        '
  137.         db '     STI                                '
  138.         db '                                        '
  139.         db '     MOV [0x10000],BYTE 1               '
  140.         db '                                        '
  141.         db '     JMP DWORD 0x10000                  '
  142.         db '                                        '
  143.         db '     MOV ESP,0 & PUSH EAX               '
  144.         db '                                        '
  145.         db '     IN  Al,0x60                        '
  146.         db '                                        '
  147.         db '     OUT 0x60,AL                        '
  148.         db 'x'
  149. else if lang eq ru
  150. text:
  151.         db 'à¨«®¦¥­¨¥ ¨á¯®«ì§ã¥â 0x1000 ¡ ©â ¯ ¬ïâ¨'
  152.         db '                                        '
  153.         db 'Žâªàëâì BOARD ¤«ï ¯à®á¬®âà  à¥§ã«ìâ â   '
  154.         db '                                        '
  155.         db '     CLI                                '
  156.         db '                                        '
  157.         db '     STI                                '
  158.         db '                                        '
  159.         db '     MOV [0x10000],BYTE 1               '
  160.         db '                                        '
  161.         db '     JMP DWORD 0x10000                  '
  162.         db '                                        '
  163.         db '     MOV ESP,0 & PUSH EAX               '
  164.         db '                                        '
  165.         db '     IN  Al,0x60                        '
  166.         db '                                        '
  167.         db '     OUT 0x60,AL                        '
  168.         db 'x'
  169. else
  170. text:
  171.         db 'Application uses 0x1000 bytes of memory '
  172.         db '                                        '
  173.         db 'Open debug board for result information '
  174.         db '                                        '
  175.         db '     CLI                                '
  176.         db '                                        '
  177.         db '     STI                                '
  178.         db '                                        '
  179.         db '     MOV [0x10000],BYTE 1               '
  180.         db '                                        '
  181.         db '     JMP DWORD 0x10000                  '
  182.         db '                                        '
  183.         db '     MOV ESP,0 & PUSH EAX               '
  184.         db '                                        '
  185.         db '     IN  Al,0x60                        '
  186.         db '                                        '
  187.         db '     OUT 0x60,AL                        '
  188.         db 'x'
  189. end if
  190. ;-------------------------------------------------------------------------------
  191. if lang eq it
  192. tlabel:
  193.         db 'Kolibri prova di protezione',0
  194. else if lang eq ru     
  195. tlabel:
  196.         db 'Kolibri ¯à®¢¥àª  § é¨âë ï¤à ',0
  197. else
  198. tlabel:
  199.         db 'Kolibri protection test',0
  200. end if
  201. ;-------------------------------------------------------------------------------
  202. I_END:
  203. ;-------------------------------------------------------------------------------
  204. align 4
  205.         rb 256
  206. stack_top:
  207. ;-------------------------------------------------------------------------------
  208. IM_END:
  209. ;-------------------------------------------------------------------------------