Subversion Repositories Kolibri OS

Rev

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

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