Subversion Repositories Kolibri OS

Rev

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

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