Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
;
2
;    EXAMPLE APPLICATION
3
;
4
;    Compile with FASM for Menuet
5
;
6
 
7
use32
8
 
9
                org     0x0
10
 
11
                db      'MENUET00'              ; 8 byte id
12
                dd      38                      ; required os
13
                dd      START                   ; program start
14
                dd      I_END                   ; program image size
15
                dd      0x8000                  ; required amount of memory
16
                dd      0x8000                  ; esp = 0x7FFF0
17
                dd      0x00000000              ; reserved=no extended header
18
 
19
include 'lang.inc'
485 heavyiron 20
include '..\..\..\macros.inc'
31 halyavin 21
 
22
begin dd 0
23
 
24
START:                          ; start of execution
25
 
26
    call open_file
27
 
28
red:
29
    call draw_window            ; at first, draw the window
30
 
31
still:
32
 
33
    mov  eax,10                 ; wait here for event
485 heavyiron 34
    mcall
31 halyavin 35
 
36
    dec  eax                    ; redraw request ?
37
    je   red
38
    dec  eax                    ; key in buffer ?
39
    je   key
40
    dec  eax                    ; button in buffer ?
41
    je   button
42
 
43
    jmp  still
44
 
45
;  red:                          ; redraw
46
;    call draw_window
47
;    jmp  still
48
 
49
  key:                          ; key
50
    mov  eax,2                  ; just read it and ignore
485 heavyiron 51
    mcall
31 halyavin 52
    jmp  still
53
 
54
  button:                       ; button
55
    mov  eax,17                 ; get id
485 heavyiron 56
    mcall
31 halyavin 57
 
58
    cmp  ah,3
59
    jne  no_up
60
    cmp  [begin],16
61
    jb   no_up
62
 
63
    add  [begin],-16
64
    jmp  red
65
  no_up:
66
 
67
    cmp  ah,4
68
    jne  no_down
69
    add  [begin],16
70
    jmp  red
71
  no_down:
72
 
73
    dec  ah                     ; button id=1 ?
74
     jne  still
485 heavyiron 75
     or   eax,-1                ; close this program
76
    mcall
31 halyavin 77
 
78
 
79
;   *********************************************
80
;   *******  WINDOW DEFINITIONS AND DRAW ********
81
;   *********************************************
82
 
83
 
84
draw_window:
85
 
86
    mov  eax,12                    ; function 12:tell os about windowdraw
87
    mov  ebx,1                     ; 1, start of draw
485 heavyiron 88
    mcall
31 halyavin 89
 
90
                                   ; DRAW WINDOW
91
    xor  eax,eax                   ; function 0 : define and draw window
92
    mov  ebx,100*65536+400         ; [x start] *65536 + [x size]
93
    mov  ecx,100*65536+270         ; [y start] *65536 + [y size]
485 heavyiron 94
    mov  edx,0x13224466            ; color of work area RRGGBB,8->c
95
    mov  edi,title                 ; WINDOW LABEL
96
    mcall
31 halyavin 97
 
485 heavyiron 98
 
31 halyavin 99
    mov  eax,8
100
    mov  ebx,280*65536+16*6
101
    mov  ecx,240*65536+14
102
    mov  edx,2
103
    mov  esi,0x5599cc
485 heavyiron 104
     mcall
31 halyavin 105
 
106
    mov  ebx,15*65536+125
107
     inc  edx
485 heavyiron 108
      mcall
31 halyavin 109
 
110
 
111
    add  ebx,127*65536
112
     inc  edx
485 heavyiron 113
     mcall
31 halyavin 114
 
115
 
116
    mov  eax,4
117
    mov  ebx,15*65536+243
118
    mov  ecx,0xffffff
119
    mov  edx,buttons
120
    mov  esi,blen-buttons
485 heavyiron 121
    mcall
31 halyavin 122
 
123
 
124
    mov  ebx,280*65536+35           ; draw info text with function 4
125
    mov  ecx,0xffffff
126
    mov  edx,text
127
    add  edx,[begin]
128
 
129
    mov  esi,16
130
     mov  edi,esi
131
   newline:
132
 
133
 push ebx                          ; hext
134
 push edx
135
push edi
136
 
137
    mov  edi,16
138
    mov  ecx,edx
139
    mov  edx,ebx
140
    add  edx,-265*65536
141
 
142
    mov  eax,47
143
    mov  ebx,0x00020101
144
    mov  esi,0xffff00
145
 
146
   newhex:
147
 
148
 ;   mov  ebx,0x00020101
149
 ;   mov  esi,0xffff00
485 heavyiron 150
    mcall
31 halyavin 151
 
152
    add  edx,16*65536
153
     inc  ecx
154
     dec  edi
155
    jne  newhex
156
 
157
;    popa
158
pop edi
159
pop edx
160
pop ebx
161
 
162
    mov  eax,4                     ; text
163
    mov  esi,16
164
    mov  ecx,0xffffff
485 heavyiron 165
    mcall
31 halyavin 166
    add  ebx,12
167
    add  edx,16
168
    dec  edi
169
    jnz  newline
170
 
171
    mov  eax,12                    ; function 12:tell os about windowdraw
172
    mov  ebx,2                     ; 2, end of draw
485 heavyiron 173
    mcall
31 halyavin 174
 
175
    ret
176
 
177
 
178
 
179
file_name  db  'EXAMPLE.ASM   '
180
      ;    db  'EXAMPLE       '
181
 
182
open_file:
183
 
184
    pusha
185
 
186
    mov  eax,6
187
    mov  ebx,file_name
188
    xor  ecx,ecx
189
    mov  edx,-1
190
    mov  esi,text
485 heavyiron 191
    mcall
31 halyavin 192
 
193
    popa
194
 
195
    ret
196
 
197
 
198
 
199
; DATA AREA
200
 
485 heavyiron 201
title  db  'HEXVIEW',0
31 halyavin 202
 
203
buttons  db  '        UP                   DOWN'
204
         db  '              EXAMPLE      '
205
blen:
206
 
207
text:
208
 
209
I_END: