Subversion Repositories Kolibri OS

Rev

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

Rev 3905 Rev 3930
1
;
1
;
2
;   pipes kolibri
2
;   pipes kolibri
3
;   v1.21
3
;   v1.21
4
;   2006 by Mario Birkner
4
;   2006 by Mario Birkner
5
;
5
;
6
;   l.mod. 27.08.06/15:11
6
;   l.mod. 27.08.06/15:11
7
;
7
;
8
;   Compile with FASM
8
;   Compile with FASM
9
;
9
;
10
bgcolor  equ  0x0074744A      ;thx
10
bgcolor  equ  0x0074744A      ;thx
11
fgcolor  equ  0x00E7C750      ;to
11
fgcolor  equ  0x00E7C750      ;to
12
fg2color equ  0x00E0B0A0      ;colorref
12
fg2color equ  0x00E0B0A0      ;colorref
13
fg3color equ  0x007F7F55
13
fg3color equ  0x007F7F55
14
btcolor  equ  0x005B6200
14
btcolor  equ  0x005B6200
15
 
15
 
16
include '..\..\macros.inc'
16
include '..\..\macros.inc'
-
 
17
include 'lang.inc'
-
 
18
; fetch the UTF-8 character in string+offs to char
-
 
19
; common part for all encodings: translate pseudographics
-
 
20
; Pseudographics for the boot screen:
-
 
21
; 0x2500 -> 0xC4, 0x2502 -> 0xB3, 0x250C -> 0xDA, 0x2510 -> 0xBF,
-
 
22
; 0x2514 -> 0xC0, 0x2518 -> 0xD9, 0x252C -> 0xC2, 0x2534 -> 0xC1, 0x2551 -> 0xBA
-
 
23
macro fetch_utf8_char string, offs, char, graph
-
 
24
{ local first_byte, b
-
 
25
  virtual at 0
-
 
26
    db string
-
 
27
    if offs >= $
-
 
28
      char = -1
-
 
29
    else
-
 
30
      ; fetch first byte
-
 
31
      load first_byte byte from offs
-
 
32
      if first_byte < 0x80
-
 
33
        char = first_byte
-
 
34
        offs = offs + 1
-
 
35
      else if first_byte < 0xC0
-
 
36
        .err Invalid UTF-8 string
-
 
37
      else if first_byte < 0xE0
-
 
38
        char = first_byte and 0x1F
-
 
39
        load b byte from offs + 1
-
 
40
        char = (char shl 6) + (b and 0x3F)
-
 
41
        offs = offs + 2
-
 
42
      else if first_byte < 0xF0
-
 
43
        char = first_byte and 0xF
-
 
44
        load b byte from offs + 1
-
 
45
        char = (char shl 6) + (b and 0x3F)
-
 
46
        load b byte from offs + 2
-
 
47
        char = (char shl 6) + (b and 0x3F)
-
 
48
        offs = offs + 3
-
 
49
      else if first_byte < 0xF8
-
 
50
        char = first_byte and 0x7
-
 
51
        load b byte from offs + 1
-
 
52
        char = (char shl 6) + (b and 0x3F)
-
 
53
        load b byte from offs + 2
-
 
54
        char = (char shl 6) + (b and 0x3F)
-
 
55
        load b byte from offs + 3
-
 
56
        char = (char shl 6) + (b and 0x3F)
-
 
57
        offs = offs + 4
-
 
58
      else
-
 
59
        .err Invalid UTF-8 string
-
 
60
      end if
-
 
61
    end if
-
 
62
  end virtual
-
 
63
  if char = 0x2500
-
 
64
    graph = 0xC4
-
 
65
  else if char = 0x2502
-
 
66
    graph = 0xB3
-
 
67
  else if char = 0x250C
-
 
68
    graph = 0xDA
-
 
69
  else if char = 0x2510
-
 
70
    graph = 0xBF
-
 
71
  else if char = 0x2514
-
 
72
    graph = 0xC0
-
 
73
  else if char = 0x2518
-
 
74
    graph = 0xD9
-
 
75
  else if char = 0x252C
-
 
76
    graph = 0xC2
-
 
77
  else if char = 0x2534
-
 
78
    graph = 0xC1
-
 
79
  else if char = 0x2551
-
 
80
    graph = 0xBA
-
 
81
  else
-
 
82
    graph = 0
-
 
83
  end if
-
 
84
}
-
 
85
; Latin-1 encoding
-
 
86
; 0x00-0xFF - trivial map
-
 
87
macro latin1 [arg]
-
 
88
{ local offs, char, graph
-
 
89
  offs = 0
-
 
90
  while 1
-
 
91
    fetch_utf8_char arg, offs, char, graph
-
 
92
    if char = -1
-
 
93
      break
-
 
94
    end if
-
 
95
    if graph
-
 
96
      db graph
-
 
97
    else if char < 0x100
-
 
98
      db char
-
 
99
    else
-
 
100
      .err Failed to convert to Latin-1
-
 
101
    end if
-
 
102
  end while
17
 
103
}
18
use32
104
use32
19
 
105
 
20
	       org    0x0
106
	       org    0x0
21
 
107
 
22
	       db     'MENUET01'	      ; 8 byte id
108
	       db     'MENUET01'	      ; 8 byte id
23
	       dd     0x01		      ; header version
109
	       dd     0x01		      ; header version
24
	       dd     START		      ; start of code
110
	       dd     START		      ; start of code
25
	       dd     I_END		      ; size of image
111
	       dd     I_END		      ; size of image
26
	       dd     0x100000		      ; memory for app
112
	       dd     0x100000		      ; memory for app
27
	       dd     0x7fff0		      ; esp
113
	       dd     0x7fff0		      ; esp
28
	       dd     0x0 , 0x0 	      ; I_Param , I_Icon
114
	       dd     0x0 , 0x0 	      ; I_Param , I_Icon
29
 
115
 
30
START:				; start of execution
116
START:				; start of execution
31
     jmp red
117
     jmp red
32
 
118
 
33
still:
119
still:
34
    mcall 10            ; wait here for event
120
    mcall 10            ; wait here for event
35
    cmp  eax,1			; redraw request ?
121
    cmp  eax,1			; redraw request ?
36
     je  red
122
     je  red
37
    cmp  eax,2			; key in buffer ?
123
    cmp  eax,2			; key in buffer ?
38
     je  key
124
     je  key
39
    cmp  eax,3			; button in buffer ?
125
    cmp  eax,3			; button in buffer ?
40
     je  button
126
     je  button
41
    jmp  still
127
    jmp  still
42
 
128
 
43
  red:				; redraw
129
  red:				; redraw
44
    call draw_window
130
    call draw_window
45
    call draw_board
131
    call draw_board
46
    call draw_message
132
    call draw_message
47
    jmp  still
133
    jmp  still
48
 
134
 
49
  key:				; key
135
  key:				; key
50
    mcall 2			; just read it and ignore
136
    mcall 2			; just read it and ignore
51
    jmp  still
137
    jmp  still
52
  button:			; button
138
  button:			; button
53
    call get_input
139
    call get_input
54
    jmp  still
140
    jmp  still
55
 
141
 
56
 
142
 
57
 
143
 
58
get_input:
144
get_input:
59
pusha
145
pusha
60
    mcall 17			; get id
146
    mcall 17			; get id
61
 
147
 
62
    cmp  ah,1			; button id=1 ?
148
    cmp  ah,1			; button id=1 ?
63
    jne  .noclose
149
    jne  .noclose
64
    mcall -1			; close this program
150
    mcall -1			; close this program
65
  .noclose:
151
  .noclose:
66
    cmp  ah,4
152
    cmp  ah,4
67
    jne  .moderate
153
    jne  .moderate
68
    mov  [diffic],1
154
    mov  [diffic],1
69
    jmp  .enddiffic
155
    jmp  .enddiffic
70
   .moderate:
156
   .moderate:
71
    cmp  ah,3
157
    cmp  ah,3
72
    jne  .easy
158
    jne  .easy
73
    mov  [diffic],3
159
    mov  [diffic],3
74
    jmp  .enddiffic
160
    jmp  .enddiffic
75
   .easy:
161
   .easy:
76
    cmp  ah,2
162
    cmp  ah,2
77
    jne  .board
163
    jne  .board
78
    mov  [diffic],5
164
    mov  [diffic],5
79
   .enddiffic:
165
   .enddiffic:
80
    mov  [score],0
166
    mov  [score],0
81
    mov  [speed],40
167
    mov  [speed],40
82
    mov  [level],1
168
    mov  [level],1
83
    mov  [stat],0
169
    mov  [stat],0
84
    mov  [time],0
170
    mov  [time],0
85
    call draw_window
171
    call draw_window
86
    call scramble_board
172
    call scramble_board
87
    call draw_board
173
    call draw_board
88
    call countdown
174
    call countdown
89
    call wassermarsch
175
    call wassermarsch
90
    jmp  .getno
176
    jmp  .getno
91
  .board:
177
  .board:
92
    cmp  [stat],2
178
    cmp  [stat],2
93
    jge  .getno
179
    jge  .getno
94
    shr  eax,8			; -> 24bit id
180
    shr  eax,8			; -> 24bit id
95
    cmp  eax,10
181
    cmp  eax,10
96
    jle  .getno
182
    jle  .getno
97
    cmp  eax,150
183
    cmp  eax,150
98
    jg	 .getno
184
    jg	 .getno
99
    sub  eax,10
185
    sub  eax,10
100
    mov  edi,eax
186
    mov  edi,eax
101
    add   edi,map
187
    add   edi,map
102
    cmp   [edi], byte 1
188
    cmp   [edi], byte 1
103
    jg	  .nogerade
189
    jg	  .nogerade
104
    xor   byte [edi], 1
190
    xor   byte [edi], 1
105
    call  draw_board
191
    call  draw_board
106
    jmp   .getno
192
    jmp   .getno
107
  .nogerade:
193
  .nogerade:
108
    cmp   [edi], byte 6
194
    cmp   [edi], byte 6
109
    jge   .getno
195
    jge   .getno
110
    cmp   [edi], byte 5
196
    cmp   [edi], byte 5
111
    jne   .rota
197
    jne   .rota
112
    sub   byte [edi],4
198
    sub   byte [edi],4
113
  .rota:
199
  .rota:
114
    inc   byte [edi]
200
    inc   byte [edi]
115
    call  draw_board
201
    call  draw_board
116
  .getno:
202
  .getno:
117
popa
203
popa
118
ret
204
ret
119
;//// end of event detection
205
;//// end of event detection
120
get_direction:		    ;Setzt Richtungs-Konstanten
206
get_direction:		    ;Setzt Richtungs-Konstanten
121
pusha			    ;IN:
207
pusha			    ;IN:
122
mov eax,[esp+28]	    ;eax  -  Richtung IN
208
mov eax,[esp+28]	    ;eax  -  Richtung IN
123
mov ebx,[esp+16]	    ;ebx  -  Teilchen (Map-Wert)
209
mov ebx,[esp+16]	    ;ebx  -  Teilchen (Map-Wert)
124
cmp ebx,0		    ;OUT:
210
cmp ebx,0		    ;OUT:
125
jne .no0		    ;eax  -  Richtung OUT
211
jne .no0		    ;eax  -  Richtung OUT
126
  cmp eax,14
212
  cmp eax,14
127
  jne .o0
213
  jne .o0
128
  jmp .setout
214
  jmp .setout
129
  .o0:
215
  .o0:
130
  cmp eax,-14
216
  cmp eax,-14
131
  jne .col
217
  jne .col
132
  jmp .setout
218
  jmp .setout
133
.no0:
219
.no0:
134
cmp ebx,1
220
cmp ebx,1
135
jne .no1
221
jne .no1
136
  cmp eax,1
222
  cmp eax,1
137
  jne .o1
223
  jne .o1
138
  jmp .setout
224
  jmp .setout
139
  .o1:
225
  .o1:
140
  cmp eax,-1
226
  cmp eax,-1
141
  jne .col
227
  jne .col
142
  jmp .setout
228
  jmp .setout
143
.no1:
229
.no1:
144
cmp ebx,2
230
cmp ebx,2
145
jne .no2
231
jne .no2
146
  cmp eax,14
232
  cmp eax,14
147
  jne .o2
233
  jne .o2
148
  sub eax,13
234
  sub eax,13
149
  jmp .setout
235
  jmp .setout
150
 .o2:
236
 .o2:
151
  cmp eax,-1
237
  cmp eax,-1
152
  jne .col
238
  jne .col
153
  sub eax,13
239
  sub eax,13
154
  jmp .setout
240
  jmp .setout
155
.no2:
241
.no2:
156
cmp ebx,3
242
cmp ebx,3
157
jne .no3
243
jne .no3
158
  cmp eax,-14
244
  cmp eax,-14
159
  jne .o3
245
  jne .o3
160
  add eax,15
246
  add eax,15
161
  jmp .setout
247
  jmp .setout
162
 .o3:
248
 .o3:
163
  cmp eax,-1
249
  cmp eax,-1
164
  jne .col
250
  jne .col
165
  add eax,15
251
  add eax,15
166
  jmp .setout
252
  jmp .setout
167
.no3:
253
.no3:
168
cmp ebx,4
254
cmp ebx,4
169
jne .no4
255
jne .no4
170
  cmp eax,-14
256
  cmp eax,-14
171
  jne .o4
257
  jne .o4
172
  add eax,13
258
  add eax,13
173
  jmp .setout
259
  jmp .setout
174
 .o4:
260
 .o4:
175
  cmp eax,1
261
  cmp eax,1
176
  jne .col
262
  jne .col
177
  add eax,13
263
  add eax,13
178
  jmp .setout
264
  jmp .setout
179
.no4:
265
.no4:
180
cmp ebx,5
266
cmp ebx,5
181
jne .no5
267
jne .no5
182
  cmp eax,14
268
  cmp eax,14
183
  jne .o5
269
  jne .o5
184
  sub eax,15
270
  sub eax,15
185
  jmp .setout
271
  jmp .setout
186
 .o5:
272
 .o5:
187
  cmp eax,1
273
  cmp eax,1
188
  jne .col
274
  jne .col
189
  sub eax,15
275
  sub eax,15
190
  jmp .setout
276
  jmp .setout
191
.no5:
277
.no5:
192
cmp ebx,6
278
cmp ebx,6
193
jne .no6
279
jne .no6
194
  jmp .setout
280
  jmp .setout
195
.no6:
281
.no6:
196
cmp ebx,7
282
cmp ebx,7
197
jne .no7
283
jne .no7
198
  mov eax,14
284
  mov eax,14
199
  jmp .setout
285
  jmp .setout
200
.no7:
286
.no7:
201
cmp ebx,8
287
cmp ebx,8
202
jne .no8
288
jne .no8
203
  cmp eax,14
289
  cmp eax,14
204
  jne .col
290
  jne .col
205
  mov [stat],1
291
  mov [stat],1
206
  jmp .setout
292
  jmp .setout
207
.no8:
293
.no8:
208
cmp ebx,16	  ; cross 2x
294
cmp ebx,16	  ; cross 2x
209
jne .col
295
jne .col
210
  add [score],10  ; + 10 bonus points
296
  add [score],10  ; + 10 bonus points
211
  jmp .setout
297
  jmp .setout
212
.col:
298
.col:
213
xor eax,eax
299
xor eax,eax
214
.setout:
300
.setout:
215
xor ebx,ebx
301
xor ebx,ebx
216
mov [esp+28],eax
302
mov [esp+28],eax
217
mov [esp+16],ebx
303
mov [esp+16],ebx
218
popa
304
popa
219
ret
305
ret
220
 
306
 
221
countdown:
307
countdown:
222
pusha
308
pusha
223
xor  eax,eax
309
xor  eax,eax
224
mov  al,[diffic]
310
mov  al,[diffic]
225
imul eax,10
311
imul eax,10
226
mov  [time],eax
312
mov  [time],eax
227
.udown:
313
.udown:
228
call show_score
314
call show_score
229
mov  ecx,10
315
mov  ecx,10
230
.down:
316
.down:
231
mov  eax,5
317
mov  eax,5
232
mov  ebx,10
318
mov  ebx,10
233
mcall
319
mcall
234
mov  eax,11
320
mov  eax,11
235
mcall
321
mcall
236
cmp  eax,1
322
cmp  eax,1
237
jne  .nored
323
jne  .nored
238
call draw_window
324
call draw_window
239
call draw_board
325
call draw_board
240
jmp  .nothing
326
jmp  .nothing
241
.nored:
327
.nored:
242
cmp  eax,3
328
cmp  eax,3
243
jne  .nothing
329
jne  .nothing
244
call get_input
330
call get_input
245
.nothing:
331
.nothing:
246
cmp  [stat],0	      ;bugfix 210806
332
cmp  [stat],0	      ;bugfix 210806
247
jnz  .exitsub	      ;bugfix 210806
333
jnz  .exitsub	      ;bugfix 210806
248
dec  ecx
334
dec  ecx
249
jnz  .down
335
jnz  .down
250
dec  [time]
336
dec  [time]
251
jnz   .udown
337
jnz   .udown
252
.exitsub:	      ;bugfix 210806
338
.exitsub:	      ;bugfix 210806
253
popa
339
popa
254
ret
340
ret
255
 
341
 
256
wassermarsch:
342
wassermarsch:
257
pusha
343
pusha
258
   .restart:
344
   .restart:
259
     mov  esi,map+16	      ;start position
345
     mov  esi,map+16	      ;start position
260
     mov  eax, 14	      ;start-richtung
346
     mov  eax, 14	      ;start-richtung
261
   .findway:
347
   .findway:
262
     movzx ebx, byte [esi]
348
     movzx ebx, byte [esi]
263
     call  get_direction
349
     call  get_direction
264
     test  eax,eax
350
     test  eax,eax
265
     jz   .collision
351
     jz   .collision
266
     push  eax
352
     push  eax
267
      xor   eax,eax
353
      xor   eax,eax
268
      mov   al,6
354
      mov   al,6
269
      sub   al,[diffic]
355
      sub   al,[diffic]
270
      add   [score],eax 	 ;points/item = 6 - difficulty
356
      add   [score],eax 	 ;points/item = 6 - difficulty
271
      mov   ecx,dword [speed]
357
      mov   ecx,dword [speed]
272
      add   byte [esi],10
358
      add   byte [esi],10
273
      .down:
359
      .down:
274
      mov   eax,5
360
      mov   eax,5
275
      mov   ebx,2
361
      mov   ebx,2
276
      mcall
362
      mcall
277
      mov   eax,11
363
      mov   eax,11
278
      mcall
364
      mcall
279
      cmp   eax,1
365
      cmp   eax,1
280
      jne   .nored
366
      jne   .nored
281
      call  draw_window
367
      call  draw_window
282
      .nored:
368
      .nored:
283
      cmp   eax,3
369
      cmp   eax,3
284
      jne   .noevnt
370
      jne   .noevnt
285
      call  get_input
371
      call  get_input
286
      .noevnt:
372
      .noevnt:
287
      dec   ecx
373
      dec   ecx
288
      jnz   .down
374
      jnz   .down
289
     pop   eax
375
     pop   eax
290
 
376
 
291
     add   esi,eax
377
     add   esi,eax
292
     call  draw_board
378
     call  draw_board
293
     call  show_score
379
     call  show_score
294
     jmp   .findway
380
     jmp   .findway
295
   .collision:
381
   .collision:
296
    cmp [stat],1
382
    cmp [stat],1
297
    jne .loose
383
    jne .loose
298
    call draw_message
384
    call draw_message
299
    mov   eax,5
385
    mov   eax,5
300
    mov   ebx,500
386
    mov   ebx,500
301
    mcall
387
    mcall
302
    mov [stat],0
388
    mov [stat],0
303
    inc [level]
389
    inc [level]
304
    cmp [speed],6		 ;waterflowdelay < 6 ?
390
    cmp [speed],6		 ;waterflowdelay < 6 ?
305
    jle .skipsub
391
    jle .skipsub
306
    sub [speed],2
392
    sub [speed],2
307
   .skipsub:
393
   .skipsub:
308
    call draw_window
394
    call draw_window
309
    call scramble_board
395
    call scramble_board
310
    call draw_board
396
    call draw_board
311
    call countdown
397
    call countdown
312
    jmp  .restart
398
    jmp  .restart
313
   .loose:
399
   .loose:
314
    mov  [stat],2
400
    mov  [stat],2
315
    call draw_message
401
    call draw_message
316
popa
402
popa
317
ret
403
ret
318
 
404
 
319
show_score:
405
show_score:
320
pusha
406
pusha
321
mov  eax,13			 ;clear time and score area
407
mov  eax,13			 ;clear time and score area
322
mov  ebx,50 shl 16 +15
408
mov  ebx,50 shl 16 +15
323
mov  ecx,395 shl 16 +15
409
mov  ecx,395 shl 16 +15
324
mov  edx,bgcolor
410
mov  edx,bgcolor
325
mcall
411
mcall
-
 
412
if lang eq et
-
 
413
add  ebx,60 shl 16 + 30
-
 
414
else
326
add  ebx,60 shl 16 + 20
415
add  ebx,60 shl 16 + 20
-
 
416
end if
327
mcall
417
mcall
328
add  ebx,80 shl 16
418
add  ebx,80 shl 16
329
mcall
419
mcall
330
mov  eax,47
420
mov  eax,47
331
mov  ebx,0x20000
421
mov  ebx,0x20000
332
mov  ecx,[time]
422
mov  ecx,[time]
333
mov  edx,50*65536+398
423
mov  edx,50*65536+398
334
mov  esi,fg2color
424
mov  esi,fg2color
335
mcall
425
mcall
336
mov  ebx,0x50000
426
mov  ebx,0x50000
337
mov  ecx,[score]
427
mov  ecx,[score]
-
 
428
if lang eq et
-
 
429
add  edx,70 shl 16
-
 
430
else
338
add  edx,60 shl 16
431
add  edx,60 shl 16
-
 
432
end if
339
mcall
433
mcall
340
mov  ebx,0x20000
434
mov  ebx,0x20000
341
mov  ecx,[level]
435
mov  ecx,[level]
342
add  edx,80 shl 16
436
add  edx,80 shl 16
343
mcall
437
mcall
344
 
438
 
345
popa
439
popa
346
ret
440
ret
347
 
441
 
348
 
442
 
349
 
443
 
350
scramble_board:
444
scramble_board:
351
pusha
445
pusha
352
mov edi,map+16 ;startpunkt
446
mov edi,map+16 ;startpunkt
353
mov eax,7      ;wieder-
447
mov eax,7      ;wieder-
354
stosb	       ;herstellen
448
stosb	       ;herstellen
355
 
449
 
356
mov ebx, 0x00000007  ;modul         m max-wert
450
mov ebx, 0x00000007  ;modul         m max-wert
357
.loop_through:
451
.loop_through:
358
mov   esi,edi
452
mov   esi,edi
359
lodsb
453
lodsb
360
cmp   eax, 9
454
cmp   eax, 9
361
 je   .skip
455
 je   .skip
362
inc   eax
456
inc   eax
363
xor   edx, edx
457
xor   edx, edx
364
div   ebx	    ;modulo -> edx
458
div   ebx	    ;modulo -> edx
365
mov   eax, edx
459
mov   eax, edx
366
cmp   eax,6
460
cmp   eax,6
367
jne   .skip
461
jne   .skip
368
dec   [half]
462
dec   [half]
369
movzx eax, byte [half]
463
movzx eax, byte [half]
370
jnz   .skip
464
jnz   .skip
371
mov   [half], byte 7
465
mov   [half], byte 7
372
.skip:
466
.skip:
373
stosb
467
stosb
374
cmp edi,map+125 ;endpunkt erhalten
468
cmp edi,map+125 ;endpunkt erhalten
375
jge .exit
469
jge .exit
376
jmp .loop_through
470
jmp .loop_through
377
.exit:
471
.exit:
378
mov  eax,8
472
mov  eax,8
379
stosb
473
stosb
380
popa
474
popa
381
ret
475
ret
382
 
476
 
383
 
477
 
384
gen_image:
478
gen_image:
385
pusha
479
pusha
386
    xor   ebx,ebx	   ;default: kein wasser
480
    xor   ebx,ebx	   ;default: kein wasser
387
    movzx eax,byte [map]   ;erstes byte der map lesen (position)
481
    movzx eax,byte [map]   ;erstes byte der map lesen (position)
388
    inc   byte [map]	   ;position inkrementieren
482
    inc   byte [map]	   ;position inkrementieren
389
    add   eax,map	   ;zur position die map-adresse addieren
483
    add   eax,map	   ;zur position die map-adresse addieren
390
    movzx  esi,byte [eax]
484
    movzx  esi,byte [eax]
391
    cmp   esi,10
485
    cmp   esi,10
392
    jl	  .nowater
486
    jl	  .nowater
393
    sub   esi,10	  ;map-werte+10 sind mit wasser gefuellt
487
    sub   esi,10	  ;map-werte+10 sind mit wasser gefuellt
394
    mov   ebx,1
488
    mov   ebx,1
395
    cmp   esi,16
489
    cmp   esi,16
396
    jne   .nowater
490
    jne   .nowater
397
    sub   esi,10
491
    sub   esi,10
398
 .nowater:
492
 .nowater:
399
   imul  esi,3072	  ;mapwert * 32*32*3 = image-adresse
493
   imul  esi,3072	  ;mapwert * 32*32*3 = image-adresse
400
    add  esi,images
494
    add  esi,images
401
    mov  edi,0x10000
495
    mov  edi,0x10000
402
    mov  ecx,32*32*3
496
    mov  ecx,32*32*3
403
 .gendd:		  ;RGB-Image im Speicher generieren
497
 .gendd:		  ;RGB-Image im Speicher generieren
404
    mov   eax,dword [esi] ;byte aus imagemap lesen
498
    mov   eax,dword [esi] ;byte aus imagemap lesen
405
    shl   eax,8
499
    shl   eax,8
406
    shr   eax,8
500
    shr   eax,8
407
    cmp   ebx,0
501
    cmp   ebx,0
408
    jz	  .nowcolor
502
    jz	  .nowcolor
409
    mov   ebx,eax
503
    mov   ebx,eax
410
    cmp   ebx,0x00B0B5B0
504
    cmp   ebx,0x00B0B5B0
411
    jne   .nog1
505
    jne   .nog1
412
    jmp   .wcolor
506
    jmp   .wcolor
413
 .nog1:
507
 .nog1:
414
    cmp   ebx,0x00A0A5A0
508
    cmp   ebx,0x00A0A5A0
415
    jne   .nog2
509
    jne   .nog2
416
    jmp   .wcolor
510
    jmp   .wcolor
417
 .nog2:
511
 .nog2:
418
    cmp   ebx,0x00909590
512
    cmp   ebx,0x00909590
419
    jne   .nog3
513
    jne   .nog3
420
    jmp   .wcolor
514
    jmp   .wcolor
421
 .nog3:
515
 .nog3:
422
    cmp   ebx,0x00808580
516
    cmp   ebx,0x00808580
423
    jne   .nog4
517
    jne   .nog4
424
    jmp   .wcolor
518
    jmp   .wcolor
425
 .nog4:
519
 .nog4:
426
    cmp   ebx,0x00707570
520
    cmp   ebx,0x00707570
427
    jne   .nowcolor
521
    jne   .nowcolor
428
    jmp   .wcolor
522
    jmp   .wcolor
429
 .wcolor:
523
 .wcolor:
430
    add   eax,0x40
524
    add   eax,0x40
431
 .nowcolor:
525
 .nowcolor:
432
    add  esi,3
526
    add  esi,3
433
    stosd
527
    stosd
434
    dec  edi
528
    dec  edi
435
    loop .gendd
529
    loop .gendd
436
popa
530
popa
437
ret
531
ret
438
 
532
 
439
 
533
 
440
 
534
 
441
;   *********************************************
535
;   *********************************************
442
;   *******  WINDOW DEFINITIONS AND DRAW ********
536
;   *******  WINDOW DEFINITIONS AND DRAW ********
443
;   *********************************************
537
;   *********************************************
444
draw_message:
538
draw_message:
445
pusha
539
pusha
446
    cmp  [stat],0
540
    cmp  [stat],0
447
	je .nomessage
541
	je .nomessage
448
    mov  eax,13
542
    mov  eax,13
449
    mov  ebx,146 shl 16 + 200
543
    mov  ebx,146 shl 16 + 200
450
    mov  ecx,190 shl 16 + 40
544
    mov  ecx,190 shl 16 + 40
451
    mov  edx,0x0
545
    mov  edx,0x0
452
    mcall
546
    mcall
453
    add  ebx,2 shl 16 - 4
547
    add  ebx,2 shl 16 - 4
454
    add  ecx,2 shl 16 - 4
548
    add  ecx,2 shl 16 - 4
455
    mov  edx,fgcolor
549
    mov  edx,fgcolor
456
    mcall
550
    mcall
457
 
551
 
458
	cmp  [stat],3
552
	cmp  [stat],3
459
	jne .stat1
553
	jne .stat1
460
    mov   eax,4
554
    mov   eax,4
461
    mov   ebx,174 shl 16 +206
555
    mov   ebx,174 shl 16 +206
462
    mov   edx,lbl_start_a_new_game+1
556
    mov   edx,lbl_start_a_new_game+1
463
    movzx esi,byte [lbl_start_a_new_game]
557
    movzx esi,byte [lbl_start_a_new_game]
464
    mov   ecx,btcolor
558
    mov   ecx,btcolor
465
    add   ecx,0x10000000
559
    add   ecx,0x10000000
466
    mcall
560
    mcall
467
    jmp	.nomessage
561
    jmp	.nomessage
468
 
562
 
469
  .stat1:	
563
  .stat1:	
470
    cmp   [stat],1
564
    cmp   [stat],1
471
     je   .winmessage
565
     je   .winmessage
472
    mov   eax,4
566
    mov   eax,4
473
    mov   ebx,186 shl 16 +200
567
    mov   ebx,186 shl 16 +200
474
    mov   edx,lbl_gameover+1
568
    mov   edx,lbl_gameover+1
475
    movzx esi,byte [lbl_gameover]
569
    movzx esi,byte [lbl_gameover]
476
    mov   ecx,btcolor
570
    mov   ecx,btcolor
477
    add   ecx,0x10000000
571
    add   ecx,0x10000000
478
    mcall
572
    mcall
479
    add   ebx,8 shl 16 +17
573
    add   ebx,8 shl 16 +17
480
    mov   edx,lbl_yscore+1
574
    mov   edx,lbl_yscore+1
481
    movzx esi,byte [lbl_yscore]
575
    movzx esi,byte [lbl_yscore]
482
    mov   ecx,btcolor
576
    mov   ecx,btcolor
483
    mcall
577
    mcall
484
    mov   esi,ecx	;color
578
    mov   esi,ecx	;color
485
    mov   edx,ebx	;pos
579
    mov   edx,ebx	;pos
486
    add   edx,80 shl 16
580
    add   edx,80 shl 16
487
    mov   ebx,0x50000	 ;type
581
    mov   ebx,0x50000	 ;type
488
    mov   ecx,[score]	 ;inp
582
    mov   ecx,[score]	 ;inp
489
    mov   eax,47
583
    mov   eax,47
490
    mcall
584
    mcall
491
    jmp   .nomessage
585
    jmp   .nomessage
492
   .winmessage:
586
   .winmessage:
493
    mov   eax,4
587
    mov   eax,4
494
    mov   ebx,152 shl 16 +200
588
    mov   ebx,152 shl 16 +200
495
    mov   edx,lbl_win+1
589
    mov   edx,lbl_win+1
496
    movzx esi,byte [lbl_win]
590
    movzx esi,byte [lbl_win]
497
    mov   ecx,btcolor
591
    mov   ecx,btcolor
498
    add   ecx,0x10000000
592
    add   ecx,0x10000000
499
    mcall
593
    mcall
500
    mov   ebx,152 shl 16 +217
594
    mov   ebx,152 shl 16 +217
501
    add   edx,esi
595
    add   edx,esi
502
    mov   ecx,btcolor
596
    mov   ecx,btcolor
503
    mcall
597
    mcall
504
   .nomessage:
598
   .nomessage:
505
popa
599
popa
506
ret
600
ret
507
 
601
 
508
draw_board:
602
draw_board:
509
pusha
603
pusha
510
 mov  ebx,15*65536+32
604
 mov  ebx,15*65536+32
511
 mov  ecx,50*65536+32
605
 mov  ecx,50*65536+32
512
 mov  edx,15*65536+50		 ;Spielfeldposition
606
 mov  edx,15*65536+50		 ;Spielfeldposition
513
 mov  esi,10			  ;Spielfeldgroesse Y
607
 mov  esi,10			  ;Spielfeldgroesse Y
514
 .vloop:
608
 .vloop:
515
  mov  edi,14			 ;Spielfeldgroesse X
609
  mov  edi,14			 ;Spielfeldgroesse X
516
  .hloop:
610
  .hloop:
517
    call gen_image
611
    call gen_image
518
    push edx
612
    push edx
519
    mov  eax,8
613
    mov  eax,8
520
    movsx edx, byte [map]
614
    movsx edx, byte [map]
521
    add  edx,9		    ;button-id = map-pos + 10;gen_image inkrements
615
    add  edx,9		    ;button-id = map-pos + 10;gen_image inkrements
522
    add  edx,0x80000000     ;first delete previous button
616
    add  edx,0x80000000     ;first delete previous button
523
	mcall
617
	mcall
524
    sub  edx,0x30000000     ;first delete previous button
618
    sub  edx,0x30000000     ;first delete previous button
525
    mcall
619
    mcall
526
    pop  edx
620
    pop  edx
527
    push ebx
621
    push ebx
528
    push ecx
622
    push ecx
529
    mov  eax,7
623
    mov  eax,7
530
    mov  ebx,0x10000
624
    mov  ebx,0x10000
531
    mov  ecx,32 shl 16 +32
625
    mov  ecx,32 shl 16 +32
532
    mcall
626
    mcall
533
    pop  ecx
627
    pop  ecx
534
    pop  ebx
628
    pop  ebx
535
    add  edx,33 shl 16
629
    add  edx,33 shl 16
536
    add  ebx,33 shl 16
630
    add  ebx,33 shl 16
537
    dec  edi
631
    dec  edi
538
    jnz  .hloop
632
    jnz  .hloop
539
  sub  edx,14*(33 shl 16)	 ;Spielfeldgroesse X
633
  sub  edx,14*(33 shl 16)	 ;Spielfeldgroesse X
540
  sub  ebx,14*(33 shl 16)
634
  sub  ebx,14*(33 shl 16)
541
  add  edx,33
635
  add  edx,33
542
  add  ecx,33 shl 16
636
  add  ecx,33 shl 16
543
  dec  esi
637
  dec  esi
544
  jnz  .vloop
638
  jnz  .vloop
545
  mov  [map], byte 1		 ;Map-Position zuruecksetzen
639
  mov  [map], byte 1		 ;Map-Position zuruecksetzen
546
popa
640
popa
547
ret
641
ret
548
 
642
 
549
 
643
 
550
draw_window:
644
draw_window:
551
pusha
645
pusha
552
 
646
 
553
    mcall 12,1
647
    mcall 12,1
554
	
648
	
555
    mov  eax,0			   ; function 0 : define and draw window
649
    mov  eax,0			   ; function 0 : define and draw window
556
    mov  ebx,100*65536+492	   ; [x start] *65536 + [x size]
650
    mov  ebx,100*65536+492	   ; [x start] *65536 + [x size]
557
    mov  ecx,100*65536+420	   ; [y start] *65536 + [y size]
651
    mov  ecx,100*65536+420	   ; [y start] *65536 + [y size]
558
    mov  edx,bgcolor		   ; color of work area RRGGBB,8->color gl
652
    mov  edx,bgcolor		   ; color of work area RRGGBB,8->color gl
559
    or   edx,0x14000000
653
    or   edx,0x14000000
560
    mov  edi,title
654
    mov  edi,title
561
    mcall
655
    mcall
562
 
656
 
563
    mov   eax,8
657
    mov   eax,8
564
    mov   ebx,84*65536+72
658
    mov   ebx,84*65536+72
565
    mov   ecx,28*65536+15
659
    mov   ecx,28*65536+15
566
    mov   edx,2
660
    mov   edx,2
567
    mov   esi,btcolor
661
    mov   esi,btcolor
568
    mcall
662
    mcall
569
    add   ebx,76 shl 16
663
    add   ebx,76 shl 16
570
    inc   edx
664
    inc   edx
571
    mcall
665
    mcall
572
    add   ebx,76 shl 16
666
    add   ebx,76 shl 16
573
    inc   edx
667
    inc   edx
574
    mcall
668
    mcall
575
 
669
 
576
    mov   eax,4
670
    mov   eax,4
577
    mov   ebx,26 shl 16 +32
671
    mov   ebx,26 shl 16 +32
578
    mov   ecx,fgcolor
672
    mov   ecx,fgcolor
579
    mov   edx,lbl_toolbar+1
673
    mov   edx,lbl_toolbar+1
580
    movsx esi, byte [lbl_toolbar]
674
    movsx esi, byte [lbl_toolbar]
581
    mcall
675
    mcall
582
    mov   ebx,18 shl 16 +398
676
    mov   ebx,18 shl 16 +398
583
    mov   edx,lbl_score+1
677
    mov   edx,lbl_score+1
584
    movsx esi, byte [lbl_score]
678
    movsx esi, byte [lbl_score]
585
    mcall
679
    mcall
586
    mov   ebx,340 shl 16 +405
680
    mov   ebx,340 shl 16 +405
587
    mov   ecx,fg3color
681
    mov   ecx,fg3color
588
    mov   edx,lbl_copy+1
682
    mov   edx,lbl_copy+1
589
    movsx esi,byte [lbl_copy]
683
    movsx esi,byte [lbl_copy]
590
    mcall
684
    mcall
591
 
685
 
592
    mcall 12,2
686
    mcall 12,2
593
 
687
 
594
    popa
688
    popa
595
    ret
689
    ret
596
 
690
 
597
 
691
 
598
; DATA AREA
692
; DATA AREA
-
 
693
if lang eq et
-
 
694
title  db  'Torud',0
-
 
695
lbl_gameover:
-
 
696
     db 19
-
 
697
     latin1 'M ä n g   L ä b i !'
-
 
698
lbl_start_a_new_game:
-
 
699
     db 21
-
 
700
     latin1 'Alusta enne uut mängu'
599
 
701
lbl_win:
-
 
702
     db 32
-
 
703
     latin1 '          T u b l i !           '
-
 
704
     latin1 '          Lähme edasi!          '
-
 
705
lbl_yscore:
-
 
706
     db 12
-
 
707
     latin1 'Sinu tulemus:'
-
 
708
lbl_toolbar:
-
 
709
     db 43
-
 
710
     latin1 'Uus mäng:     Lihtne     Keskmine     Raske'
-
 
711
lbl_copy:
-
 
712
     db 24
-
 
713
     latin1 'v1.21 2006,Mario Birkner'
-
 
714
lbl_score:
-
 
715
     db 28
-
 
716
     latin1   'Aeg:    Tulemus:       Tase:'
600
 
717
else
601
title  db   'Pipes',0
718
title  db   'Pipes',0
602
lbl_gameover:
719
lbl_gameover:
603
     db 19
720
     db 19
604
     db 'G a m e   O v e r !'
721
     db 'G a m e   O v e r !'
605
lbl_start_a_new_game:
722
lbl_start_a_new_game:
606
     db 22
723
     db 22
607
     db 'Start a new game first'
724
     db 'Start a new game first'
608
lbl_win:
725
lbl_win:
609
     db 32
726
     db 32
610
     db '          G r e a t !           '
727
     db '          G r e a t !           '
611
     db "        Let's goin'on!          "
728
     db "        Let's goin'on!          "
612
lbl_yscore:
729
lbl_yscore:
613
     db 11
730
     db 11
614
     db 'Your Score:'
731
     db 'Your Score:'
615
lbl_toolbar:
732
lbl_toolbar:
616
     db 43
733
     db 43
617
     db 'New Game:     Easy       Moderate      Hard'
734
     db 'New Game:     Easy       Moderate      Hard'
618
lbl_copy:
735
lbl_copy:
619
     db 24
736
     db 24
620
     db 'v1.21 2006,Mario Birkner'
737
     db 'v1.21 2006,Mario Birkner'
621
lbl_score:
738
lbl_score:
622
     db 28
739
     db 28
623
     db   'Time:    Score:       Level:'
740
     db   'Time:    Score:       Level:'
-
 
741
end if
624
stat	db 3  ;0=gameplay 1=won 2-lost 3=stopped
742
stat	db 3  ;0=gameplay 1=won 2-lost 3=stopped
625
speed	db 0
743
speed	db 0
626
time	dd 0
744
time	dd 0
627
diffic	db 0  ;1=hard 3=moderate 5=easy 8=dedicated to Wildwest - try it out!
745
diffic	db 0  ;1=hard 3=moderate 5=easy 8=dedicated to Wildwest - try it out!
628
score	dd 0
746
score	dd 0
629
level	dd 1
747
level	dd 1
630
half	db 1  ;reduces the random-crosses
748
half	db 1  ;reduces the random-crosses
631
 
749
 
632
map:	   ;14*10 blocks + position
750
map:	   ;14*10 blocks + position
633
     db 1  ;<- act. position
751
     db 1  ;<- act. position
634
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
752
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
635
     db 9,7,1,3,2,0,1,1,0,3,4,4,3,9
753
     db 9,7,1,3,2,0,1,1,0,3,4,4,3,9
636
     db 9,5,0,2,2,1,3,0,3,1,1,6,4,9
754
     db 9,5,0,2,2,1,3,0,3,1,1,6,4,9
637
     db 9,4,0,4,6,0,3,3,2,6,0,1,2,9
755
     db 9,4,0,4,6,0,3,3,2,6,0,1,2,9
638
     db 9,3,0,1,2,4,6,4,5,1,2,4,1,9
756
     db 9,3,0,1,2,4,6,4,5,1,2,4,1,9
639
     db 9,5,3,2,6,3,2,1,2,1,2,6,0,9
757
     db 9,5,3,2,6,3,2,1,2,1,2,6,0,9
640
     db 9,4,0,2,3,0,4,1,2,3,2,3,4,9
758
     db 9,4,0,2,3,0,4,1,2,3,2,3,4,9
641
     db 9,2,0,4,5,6,3,1,3,0,4,1,0,9
759
     db 9,2,0,4,5,6,3,1,3,0,4,1,0,9
642
     db 9,1,0,3,5,4,2,2,4,1,6,0,8,9
760
     db 9,1,0,3,5,4,2,2,4,1,6,0,8,9
643
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
761
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
644
images:
762
images:
645
file 'pipes.raw'
763
file 'pipes.raw'
646
I_END:
764
I_END: