Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 205
1
;
1
;
2
;    FIRE for MENUET  - Compile with FASM
2
;    FIRE for MENUET  - Compile with FASM
3
;
3
;
4
 
4
 
5
use32
5
use32
6
 
6
 
7
           org     0x0
7
           org     0x0
8
           db      'MENUET01'           ; 8 byte id
8
           db      'MENUET01'           ; 8 byte id
9
           dd      1                    ; header version
9
           dd      1                    ; header version
10
           dd      START                ; program start
10
           dd      START                ; program start
11
           dd      I_END                ; image size
11
           dd      I_END                ; image size
12
           dd      mem_end              ; reguired amount of memory
12
           dd      mem_end              ; reguired amount of memory
13
           dd      mem_end
13
           dd      mem_end
14
           dd      0,0                  ; no parameters, no path
14
           dd      0,0                  ; no parameters, no path
15
 
-
 
16
;include 'lang.inc'
15
 
17
include 'macros.inc'
16
include 'macros.inc'
18
 
17
 
19
START:
18
START:
20
 
19
 
21
red:
20
red:
22
 
21
 
23
; ************************************************
22
; ************************************************
24
; ********* WINDOW DEFINITIONS AND DRAW **********
23
; ********* WINDOW DEFINITIONS AND DRAW **********
25
; ************************************************
24
; ************************************************
26
 
25
 
27
draw_window:
26
draw_window:
28
 
27
 
29
    mov  eax,12                    ; tell os about redraw
28
    mov  eax,12                    ; tell os about redraw
30
    mov  ebx,1
29
    mov  ebx,1
31
    int  0x40
30
    int  0x40
32
 
31
 
33
    xor  eax,eax                   ; define and draw window
32
    xor  eax,eax                   ; define and draw window
34
    mov  ebx,100*65536+321
33
    mov  ebx,100*65536+321
35
    mov  ecx,70*65536+222
34
    mov  ecx,70*65536+222
36
    mov  edx,0x00000000
35
    mov  edx,0x00000000
37
    mov  esi,0x00000000
36
    mov  esi,0x00000000
38
    mov  edi,0x00000000
37
    mov  edi,0x00000000
39
    int  0x40
38
    int  0x40
40
 
39
 
41
    mov  al,4      ; 'FIRE FOR MENUET'
40
    mov  al,4      ; 'FIRE FOR MENUET'
42
    mov  ebx,110*65536+8
41
    mov  ebx,110*65536+8
43
    mov  ecx,dword 0x00FFFFFF
42
    mov  ecx,dword 0x00FFFFFF
44
    mov  edx,text
43
    mov  edx,text
45
    mov  esi,textlen-text
44
    mov  esi,textlen-text
46
    int  0x40
45
    int  0x40
47
 
46
 
48
    mov  al,8
47
    mov  al,8
49
    mov  ebx,(321-19)*65536+12     ; button start x & size
48
    mov  ebx,(321-19)*65536+12     ; button start x & size
50
    mov  ecx,5*65536+12            ; button start y & size
49
    mov  ecx,5*65536+12            ; button start y & size
51
    mov  edx,1                     ; button number
50
    mov  edx,1                     ; button number
52
    mov  esi,0x009a0000
51
    mov  esi,0x009a0000
53
    int  0x40
52
    int  0x40
54
 
53
 
55
    mov  ebx,ecx ;5*65536+12
54
    mov  ebx,ecx ;5*65536+12
56
    inc  edx
55
    inc  edx
57
    int  0x40
56
    int  0x40
58
 
57
 
59
    mov  ebx,18*65536+12
58
    mov  ebx,18*65536+12
60
    inc  edx
59
    inc  edx
61
    int  0x40
60
    int  0x40
62
 
61
 
63
    mov  ebx,31*65536+12
62
    mov  ebx,31*65536+12
64
    inc  edx
63
    inc  edx
65
    int  0x40
64
    int  0x40
66
 
65
 
67
    mov  al,12                    ; tell os about redraw end
66
    mov  al,12                    ; tell os about redraw end
68
    mov  ebx,2
67
    mov  ebx,2
69
    int  0x40
68
    int  0x40
70
 
69
 
71
sta:                                         ; calculate fire image
70
sta:                                         ; calculate fire image
72
 
71
 
73
    mov  esi, FireScreen+0x2300-80
72
    mov  esi, FireScreen+0x2300-80
74
    mov  ecx, 80
73
    mov  ecx, 80
75
    mov  eax, [FireSeed]
74
    mov  eax, [FireSeed]
76
 
75
 
77
  NEWLINE:
76
  NEWLINE:
78
 
77
 
79
    mul  [RandSeedConst]
78
    mul  [RandSeedConst]
80
    inc  eax
79
    inc  eax
81
    mov  [esi], dl
80
    mov  [esi], dl
82
    inc  esi
81
    inc  esi
83
    loop NEWLINE
82
    loop NEWLINE
84
 
83
 
85
    mov  [FireSeed], eax
84
    mov  [FireSeed], eax
86
 
85
 
87
    mov  ecx, 0x2300-80
86
    mov  ecx, 0x2300-80
88
    sub  esi, ecx
87
    sub  esi, ecx
89
    xor  edx, edx
88
    xor  edx, edx
90
    xor  eax, eax
89
    xor  eax, eax
91
 
90
 
92
  FIRELOOP:
91
  FIRELOOP:
93
    lodsb
92
    lodsb
94
 
93
 
95
    cmp  [type], ah
94
    cmp  [type], ah
96
    jnz  notype1
95
    jnz  notype1
97
    mov  dl, [esi + 1]
96
    mov  dl, [esi + 1]
98
    add  eax, edx
97
    add  eax, edx
99
    mov  dl, [esi]
98
    mov  dl, [esi]
100
    add  eax, edx
99
    add  eax, edx
101
    mov  dl, [esi + 80]
100
    mov  dl, [esi + 80]
102
    jmp  typedone
101
    jmp  typedone
103
  notype1:
102
  notype1:
104
 
103
 
105
;    cmp  [type],1
104
;    cmp  [type],1
106
;    jnz  notype2
105
;    jnz  notype2
107
    mov  dl, [esi - 2]
106
    mov  dl, [esi - 2]
108
;    add  eax, edx
107
;    add  eax, edx
109
;    mov  dl, [esi - 2]
108
;    mov  dl, [esi - 2]
110
;    add  eax, edx
109
;    add  eax, edx
111
    lea  eax, [eax + edx*2]
110
    lea  eax, [eax + edx*2]
112
    mov  dl, [esi + 78]
111
    mov  dl, [esi + 78]
113
;  notype2:
112
;  notype2:
114
 
113
 
115
; type 2 is never used
114
; type 2 is never used
116
;    cmp  [type],2
115
;    cmp  [type],2
117
;    jnz  notype3
116
;    jnz  notype3
118
;    mov  dl, [esi - 2]
117
;    mov  dl, [esi - 2]
119
;    add  eax, edx
118
;    add  eax, edx
120
;    mov  dl, [esi]
119
;    mov  dl, [esi]
121
;    add  eax, edx
120
;    add  eax, edx
122
;    mov  dl, [esi + 80]
121
;    mov  dl, [esi + 80]
123
;  notype3:
122
;  notype3:
124
 
123
 
125
typedone:
124
typedone:
126
    add  eax, edx
125
    add  eax, edx
127
    shr  eax, 2
126
    shr  eax, 2
128
    jz   ZERO
127
    jz   ZERO
129
    dec  eax
128
    dec  eax
130
 
129
 
131
  ZERO:
130
  ZERO:
132
 
131
 
133
    mov  [esi - 81], al
132
    mov  [esi - 81], al
134
    loop FIRELOOP
133
    loop FIRELOOP
135
 
134
 
136
    mov  al, 5              ; in this moment always high 24 bits of eax are zero!
135
    mov  al, 5              ; in this moment always high 24 bits of eax are zero!
137
    mov  ebx,[delay]
136
    mov  ebx,[delay]
138
    int  0x40
137
    int  0x40
139
 
138
 
140
    inc  [calc]
139
    inc  [calc]
141
    cmp  [calc], byte 2
140
    cmp  [calc], byte 2
142
    jnz  nodrw
141
    jnz  nodrw
143
 
142
 
144
  pdraw:
143
  pdraw:
145
 
144
 
146
    mov  byte [calc],ah ;byte 0
145
    mov  byte [calc],ah ;byte 0
147
 
146
 
148
    mov  edi,ImageData
147
    mov  edi,ImageData
149
    push edi     ; pointer for sysfunction 7, draw image
148
    push edi     ; pointer for sysfunction 7, draw image
150
    add  edi,[fcolor]
149
    add  edi,[fcolor]
151
    mov  esi,FireScreen
150
    mov  esi,FireScreen
152
    xor  edx,edx
151
    xor  edx,edx
153
 
152
 
154
  newc:
153
  newc:
155
    xor   eax, eax
154
    xor   eax, eax
156
    lodsb
155
    lodsb
157
 
156
 
158
    mov   ecx,eax
157
    mov   ecx,eax
159
    shr   eax,1
158
    shr   eax,1
160
    add   cl,al
159
    add   cl,al
161
    mov   ch,al
160
    mov   ch,al
162
 
161
 
163
    mov  [edi+0],ecx
162
    mov  [edi+0],ecx
164
    mov  [edi+3],ecx
163
    mov  [edi+3],ecx
165
    mov  [edi+6],ecx
164
    mov  [edi+6],ecx
166
    mov  [edi+9],cx
165
    mov  [edi+9],cx
167
    lea  ebx, [edi+320*3]
166
    lea  ebx, [edi+320*3]
168
    mov  [ebx+0],ecx
167
    mov  [ebx+0],ecx
169
    mov  [ebx+3],ecx
168
    mov  [ebx+3],ecx
170
    mov  [ebx+6],ecx
169
    mov  [ebx+6],ecx
171
    mov  [ebx+9],ecx
170
    mov  [ebx+9],ecx
172
 
171
 
173
    add  edi,12
172
    add  edi,12
174
    inc  edx
173
    inc  edx
175
    cmp  edx,80
174
    cmp  edx,80
176
    jnz  nnl
175
    jnz  nnl
177
    xor  edx,edx
176
    xor  edx,edx
178
    add  edi,320*3
177
    add  edi,320*3
179
  nnl:
178
  nnl:
180
    cmp  esi,FireScreen+8000; 0x2000
179
    cmp  esi,FireScreen+8000; 0x2000
181
    jnz  newc
180
    jnz  newc
182
 
181
 
183
    mov  al,7           ; display image
182
    mov  al,7           ; display image
184
                        ; high 24 bits of eax are zero!
183
                        ; high 24 bits of eax are zero!
185
    pop  ebx
184
    pop  ebx
186
    mov  ecx,4*80*65536+200
185
    mov  ecx,4*80*65536+200
187
    mov  edx,1*65536+22
186
    mov  edx,1*65536+22
188
    int  0x40
187
    int  0x40
189
 
188
 
190
  nodrw:
189
  nodrw:
191
 
190
 
192
    mov  eax,11                  ; check if os wants to talk to us
191
    mov  eax,11                  ; check if os wants to talk to us
193
    int  0x40
192
    int  0x40
194
    dec  eax
193
    dec  eax
195
    jz   red
194
    jz   red
196
    cmp  al, 3-1
195
    cmp  al, 3-1
197
    jnz  nob4
196
    jnz  nob4
198
 
197
 
199
  button:                        ; get button id
198
  button:                        ; get button id
200
    mov  al,17
199
    mov  al,17
201
    int  0x40
200
    int  0x40
202
    shr  eax, 8
201
    shr  eax, 8
203
 
202
 
204
    dec  eax
203
    dec  eax
205
    jnz  noclose
204
    jnz  noclose
206
    or   eax,-1                  ; close this program
205
    or   eax,-1                  ; close this program
207
    int  0x40
206
    int  0x40
208
  noclose:
207
  noclose:
209
 
208
 
210
    dec  eax                     ; change fire type
209
    dec  eax                     ; change fire type
211
    jnz  nob2
210
    jnz  nob2
212
    xor  [type], 1
211
    xor  [type], 1
213
   nob2:
212
   nob2:
214
 
213
 
215
    dec  eax                     ; change delay
214
    dec  eax                     ; change delay
216
    jnz  nob3
215
    jnz  nob3
217
    xor  [delay], 1
216
    xor  [delay], 1
218
  nob3:
217
  nob3:
219
 
218
 
220
    dec  eax                     ; change color
219
    dec  eax                     ; change color
221
    jnz  nob4
220
    jnz  nob4
222
    mov  eax,[fcolor]
221
    mov  eax,[fcolor]
223
    inc  eax
222
    inc  eax
224
;    cmp  al,2
223
;    cmp  al,2
225
;    jbe  fcok
224
;    jbe  fcok
226
    jnp  fcok
225
    jnp  fcok
227
    xor  eax,eax
226
    xor  eax,eax
228
  fcok:
227
  fcok:
229
    mov  [fcolor],eax
228
    mov  [fcolor],eax
230
    mov  edi,ImageData
229
    mov  edi,ImageData
231
    mov  ecx,(320*600)/4
230
    mov  ecx,(320*600)/4
232
    xor  eax,eax
231
    xor  eax,eax
233
    rep  stosd
232
    rep  stosd
234
 
233
 
235
  nob4:
234
  nob4:
236
    jmp  sta
235
    jmp  sta
237
 
236
 
238
; DATA SECTION
237
; DATA SECTION
239
RandSeedConst dd 0x8405
238
RandSeedConst dd 0x8405
240
fcolor    dd  2
239
fcolor    dd  2
241
xx        db  'x'
240
xx        db  'x'
242
type      db  0
241
type      db  0
243
calc      db  0
242
calc      db  0
244
delay     dd  0
243
delay     dd  0
245
FireSeed  dd  0x1234
244
FireSeed  dd  0x1234
246
text:     db 'FIRE FOR MENUET'
245
text:     db 'FIRE FOR MENUET'
247
textlen:
246
textlen:
248
 
247
 
249
I_END:
248
I_END:
250
 
249
 
251
FireScreen:
250
FireScreen:
252
          rb 0x2300
251
          rb 0x2300
253
ImageData:
252
ImageData:
254
          rb 320*200*3
253
          rb 320*200*3
255
 
254
 
256
; stack
255
; stack
257
          align 512
256
          align 512
258
          rb 512
257
          rb 512
259
mem_end:
258
mem_end: