Subversion Repositories Kolibri OS

Rev

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

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