Subversion Repositories Kolibri OS

Rev

Rev 7581 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
205 heavyiron 1
;
3905 leency 2
;   pipes kolibri
7773 leency 3
;   v1.42
205 heavyiron 4
;   2006 by Mario Birkner
5
;
7581 dunkaist 6
;   l.mod. 29.01.19
205 heavyiron 7
;
8
;   Compile with FASM
9
;
4697 hidnplayr 10
format binary as ""
11
 
205 heavyiron 12
bgcolor  equ  0x0074744A      ;thx
13
fgcolor  equ  0x00E7C750      ;to
14
fg2color equ  0x00E0B0A0      ;colorref
15
fg3color equ  0x007F7F55
16
btcolor  equ  0x005B6200
17
 
485 heavyiron 18
include '..\..\macros.inc'
3930 kaitz 19
include 'lang.inc'
6270 leency 20
 
205 heavyiron 21
use32
22
 
6270 leency 23
	org    0x0
24
 
25
	db     'MENUET01'              ; 8 byte id
26
	dd     0x01                    ; header version
27
	dd     START                   ; start of code
28
	dd     I_END                   ; size of image
29
	dd     0x100000                ; memory for app
30
	dd     0x7fff0                 ; esp
31
	dd     0x0 , 0x0               ; I_Param , I_Icon
205 heavyiron 32
 
4697 hidnplayr 33
START:                          ; start of execution
3905 leency 34
     jmp red
205 heavyiron 35
 
36
still:
3905 leency 37
    mcall 10            ; wait here for event
4697 hidnplayr 38
    cmp  eax,1                  ; redraw request ?
205 heavyiron 39
     je  red
4697 hidnplayr 40
    cmp  eax,2                  ; key in buffer ?
205 heavyiron 41
     je  key
4697 hidnplayr 42
    cmp  eax,3                  ; button in buffer ?
205 heavyiron 43
     je  button
44
    jmp  still
45
 
4697 hidnplayr 46
  red:                          ; redraw
205 heavyiron 47
    call draw_window
48
    call draw_board
49
    call draw_message
50
    jmp  still
51
 
4697 hidnplayr 52
  key:                          ; key
53
    mcall 2                     ; just read it and ignore
205 heavyiron 54
    jmp  still
4697 hidnplayr 55
  button:                       ; button
205 heavyiron 56
    call get_input
57
    jmp  still
58
 
59
 
60
 
61
get_input:
62
pusha
4697 hidnplayr 63
    mcall 17                    ; get id
205 heavyiron 64
 
4697 hidnplayr 65
    cmp  ah,1                   ; button id=1 ?
205 heavyiron 66
    jne  .noclose
4697 hidnplayr 67
    mcall -1                    ; close this program
205 heavyiron 68
  .noclose:
69
    cmp  ah,4
70
    jne  .moderate
71
    mov  [diffic],1
72
    jmp  .enddiffic
73
   .moderate:
74
    cmp  ah,3
75
    jne  .easy
76
    mov  [diffic],3
77
    jmp  .enddiffic
78
   .easy:
79
    cmp  ah,2
80
    jne  .board
81
    mov  [diffic],5
82
   .enddiffic:
83
    mov  [score],0
84
    mov  [speed],40
85
    mov  [level],1
86
    mov  [stat],0
87
    mov  [time],0
88
    call draw_window
89
    call scramble_board
90
    call draw_board
91
    call countdown
92
    call wassermarsch
93
    jmp  .getno
94
  .board:
95
    cmp  [stat],2
96
    jge  .getno
4697 hidnplayr 97
    shr  eax,8                  ; -> 24bit id
205 heavyiron 98
    cmp  eax,10
99
    jle  .getno
100
    cmp  eax,150
4697 hidnplayr 101
    jg   .getno
205 heavyiron 102
    sub  eax,10
103
    mov  edi,eax
104
    add   edi,map
105
    cmp   [edi], byte 1
4697 hidnplayr 106
    jg    .nogerade
205 heavyiron 107
    xor   byte [edi], 1
108
    call  draw_board
109
    jmp   .getno
110
  .nogerade:
111
    cmp   [edi], byte 6
112
    jge   .getno
113
    cmp   [edi], byte 5
114
    jne   .rota
115
    sub   byte [edi],4
116
  .rota:
117
    inc   byte [edi]
118
    call  draw_board
119
  .getno:
120
popa
121
ret
122
;//// end of event detection
4697 hidnplayr 123
get_direction:              ;Setzt Richtungs-Konstanten
124
pusha                       ;IN:
125
mov eax,[esp+28]            ;eax  -  Richtung IN
126
mov ebx,[esp+16]            ;ebx  -  Teilchen (Map-Wert)
127
cmp ebx,0                   ;OUT:
128
jne .no0                    ;eax  -  Richtung OUT
205 heavyiron 129
  cmp eax,14
130
  jne .o0
131
  jmp .setout
132
  .o0:
133
  cmp eax,-14
134
  jne .col
135
  jmp .setout
136
.no0:
137
cmp ebx,1
138
jne .no1
139
  cmp eax,1
140
  jne .o1
141
  jmp .setout
142
  .o1:
143
  cmp eax,-1
144
  jne .col
145
  jmp .setout
146
.no1:
147
cmp ebx,2
148
jne .no2
149
  cmp eax,14
150
  jne .o2
151
  sub eax,13
152
  jmp .setout
153
 .o2:
154
  cmp eax,-1
155
  jne .col
156
  sub eax,13
157
  jmp .setout
158
.no2:
159
cmp ebx,3
160
jne .no3
161
  cmp eax,-14
162
  jne .o3
163
  add eax,15
164
  jmp .setout
165
 .o3:
166
  cmp eax,-1
167
  jne .col
168
  add eax,15
169
  jmp .setout
170
.no3:
171
cmp ebx,4
172
jne .no4
173
  cmp eax,-14
174
  jne .o4
175
  add eax,13
176
  jmp .setout
177
 .o4:
178
  cmp eax,1
179
  jne .col
180
  add eax,13
181
  jmp .setout
182
.no4:
183
cmp ebx,5
184
jne .no5
185
  cmp eax,14
186
  jne .o5
187
  sub eax,15
188
  jmp .setout
189
 .o5:
190
  cmp eax,1
191
  jne .col
192
  sub eax,15
193
  jmp .setout
194
.no5:
195
cmp ebx,6
196
jne .no6
197
  jmp .setout
198
.no6:
199
cmp ebx,7
200
jne .no7
201
  mov eax,14
202
  jmp .setout
203
.no7:
204
cmp ebx,8
205
jne .no8
206
  cmp eax,14
207
  jne .col
208
  mov [stat],1
209
  jmp .setout
210
.no8:
4697 hidnplayr 211
cmp ebx,16        ; cross 2x
205 heavyiron 212
jne .col
213
  add [score],10  ; + 10 bonus points
214
  jmp .setout
215
.col:
216
xor eax,eax
217
.setout:
218
xor ebx,ebx
219
mov [esp+28],eax
220
mov [esp+16],ebx
221
popa
222
ret
223
 
224
countdown:
225
pusha
226
xor  eax,eax
227
mov  al,[diffic]
228
imul eax,10
229
mov  [time],eax
230
.udown:
231
call show_score
232
mov  ecx,10
233
.down:
234
mov  eax,5
235
mov  ebx,10
485 heavyiron 236
mcall
205 heavyiron 237
mov  eax,11
485 heavyiron 238
mcall
205 heavyiron 239
cmp  eax,1
240
jne  .nored
241
call draw_window
242
call draw_board
243
jmp  .nothing
244
.nored:
245
cmp  eax,3
246
jne  .nothing
247
call get_input
248
.nothing:
4697 hidnplayr 249
cmp  [stat],0         ;bugfix 210806
250
jnz  .exitsub         ;bugfix 210806
205 heavyiron 251
dec  ecx
252
jnz  .down
253
dec  [time]
254
jnz   .udown
4697 hidnplayr 255
.exitsub:             ;bugfix 210806
205 heavyiron 256
popa
257
ret
258
 
259
wassermarsch:
260
pusha
261
   .restart:
4697 hidnplayr 262
     mov  esi,map+16          ;start position
263
     mov  eax, 14             ;start-richtung
205 heavyiron 264
   .findway:
265
     movzx ebx, byte [esi]
266
     call  get_direction
267
     test  eax,eax
268
     jz   .collision
269
     push  eax
270
      xor   eax,eax
271
      mov   al,6
272
      sub   al,[diffic]
4697 hidnplayr 273
      add   [score],eax          ;points/item = 6 - difficulty
205 heavyiron 274
      mov   ecx,dword [speed]
275
      add   byte [esi],10
276
      .down:
7773 leency 277
      mcall 5, 2
278
      mcall 11
205 heavyiron 279
      cmp   eax,1
280
      jne   .nored
281
      call  draw_window
282
      .nored:
283
      cmp   eax,3
284
      jne   .noevnt
285
      call  get_input
286
      .noevnt:
287
      dec   ecx
288
      jnz   .down
289
     pop   eax
290
 
291
     add   esi,eax
292
     call  draw_board
293
     call  show_score
294
     jmp   .findway
295
   .collision:
296
    cmp [stat],1
297
    jne .loose
298
    call draw_message
7773 leency 299
    mcall 5, 500
205 heavyiron 300
    mov [stat],0
301
    inc [level]
4697 hidnplayr 302
    cmp [speed],6                ;waterflowdelay < 6 ?
205 heavyiron 303
    jle .skipsub
304
    sub [speed],2
305
   .skipsub:
306
    call draw_window
307
    call scramble_board
308
    call draw_board
309
    call countdown
310
    jmp  .restart
311
   .loose:
312
    mov  [stat],2
313
    call draw_message
314
popa
315
ret
316
 
317
show_score:
318
pusha
319
mov  esi,fg2color
6270 leency 320
mov  edi,bgcolor
321
or   esi,0x50000000
7773 leency 322
mcall 47, 0x20000, [time], <60,395>
205 heavyiron 323
mov  ebx,0x50000
324
mov  ecx,[score]
3930 kaitz 325
if lang eq et
6270 leency 326
add  edx,88 shl 16
3930 kaitz 327
else
6270 leency 328
add  edx,80 shl 16
3930 kaitz 329
end if
485 heavyiron 330
mcall
205 heavyiron 331
mov  ebx,0x20000
332
mov  ecx,[level]
6270 leency 333
add  edx,104 shl 16
485 heavyiron 334
mcall
205 heavyiron 335
 
336
popa
337
ret
338
 
339
 
340
 
341
scramble_board:
342
pusha
343
mov edi,map+16 ;startpunkt
344
mov eax,7      ;wieder-
4697 hidnplayr 345
stosb          ;herstellen
205 heavyiron 346
 
347
mov ebx, 0x00000007  ;modul         m max-wert
348
.loop_through:
349
mov   esi,edi
350
lodsb
351
cmp   eax, 9
352
 je   .skip
353
inc   eax
354
xor   edx, edx
4697 hidnplayr 355
div   ebx           ;modulo -> edx
205 heavyiron 356
mov   eax, edx
357
cmp   eax,6
358
jne   .skip
359
dec   [half]
360
movzx eax, byte [half]
361
jnz   .skip
362
mov   [half], byte 7
363
.skip:
364
stosb
365
cmp edi,map+125 ;endpunkt erhalten
366
jge .exit
367
jmp .loop_through
368
.exit:
369
mov  eax,8
370
stosb
371
popa
372
ret
373
 
374
 
375
gen_image:
376
pusha
4697 hidnplayr 377
    xor   ebx,ebx          ;default: kein wasser
205 heavyiron 378
    movzx eax,byte [map]   ;erstes byte der map lesen (position)
4697 hidnplayr 379
    inc   byte [map]       ;position inkrementieren
380
    add   eax,map          ;zur position die map-adresse addieren
205 heavyiron 381
    movzx  esi,byte [eax]
382
    cmp   esi,10
4697 hidnplayr 383
    jl    .nowater
384
    sub   esi,10          ;map-werte+10 sind mit wasser gefuellt
205 heavyiron 385
    mov   ebx,1
386
    cmp   esi,16
387
    jne   .nowater
388
    sub   esi,10
389
 .nowater:
4697 hidnplayr 390
   imul  esi,3072         ;mapwert * 32*32*3 = image-adresse
205 heavyiron 391
    add  esi,images
392
    mov  edi,0x10000
393
    mov  ecx,32*32*3
4697 hidnplayr 394
 .gendd:                  ;RGB-Image im Speicher generieren
205 heavyiron 395
    mov   eax,dword [esi] ;byte aus imagemap lesen
396
    shl   eax,8
397
    shr   eax,8
398
    cmp   ebx,0
4697 hidnplayr 399
    jz    .nowcolor
205 heavyiron 400
    mov   ebx,eax
7773 leency 401
    cmp   ebx,0x00B0B4B0
205 heavyiron 402
    jne   .nog1
403
    jmp   .wcolor
404
 .nog1:
7773 leency 405
    cmp   ebx,0x00A0A4A0
205 heavyiron 406
    jne   .nog2
407
    jmp   .wcolor
408
 .nog2:
7773 leency 409
    cmp   ebx,0x00909490
205 heavyiron 410
    jne   .nog3
411
    jmp   .wcolor
412
 .nog3:
7773 leency 413
    cmp   ebx,0x00808480
205 heavyiron 414
    jne   .nog4
415
    jmp   .wcolor
416
 .nog4:
7773 leency 417
    cmp   ebx,0x00707470
205 heavyiron 418
    jne   .nowcolor
419
    jmp   .wcolor
420
 .wcolor:
421
    add   eax,0x40
422
 .nowcolor:
423
    add  esi,3
424
    stosd
425
    dec  edi
426
    loop .gendd
427
popa
428
ret
429
 
430
 
431
 
432
;   *********************************************
433
;   *******  WINDOW DEFINITIONS AND DRAW ********
434
;   *********************************************
435
draw_message:
436
pusha
437
    cmp  [stat],0
4697 hidnplayr 438
        je .nomessage
6270 leency 439
    mcall 13,<146,200>,<190,40>,0
205 heavyiron 440
    add  ebx,2 shl 16 - 4
441
    add  ecx,2 shl 16 - 4
442
    mov  edx,fgcolor
485 heavyiron 443
    mcall
205 heavyiron 444
 
4697 hidnplayr 445
        cmp  [stat],3
446
        jne .stat1
7773 leency 447
 
3905 leency 448
    mov   ecx,btcolor
6270 leency 449
    or    ecx,0xB0000000
7773 leency 450
    mcall 4, <159,202>,,lbl_new_game
4697 hidnplayr 451
    jmp .nomessage
3905 leency 452
 
4697 hidnplayr 453
  .stat1:
205 heavyiron 454
    cmp   [stat],1
455
     je   .winmessage
7581 dunkaist 456
    mov   ecx,btcolor OR 0xB0000000
7773 leency 457
    mcall 4, <170,196>, , lbl_gameover
205 heavyiron 458
    add   ebx,8 shl 16 +17
6270 leency 459
    mov   edx,lbl_yscore
485 heavyiron 460
    mcall
4697 hidnplayr 461
    mov   esi,ecx       ;color
462
    mov   edx,ebx       ;pos
7581 dunkaist 463
    add   edx,90 shl 16
4697 hidnplayr 464
    mov   ebx,0x50000    ;type
465
    mov   ecx,[score]    ;inp
205 heavyiron 466
    mov   eax,47
485 heavyiron 467
    mcall
205 heavyiron 468
    jmp   .nomessage
469
   .winmessage:
470
    mov   ecx,btcolor
6270 leency 471
    or    ecx,0xB0000000
7773 leency 472
    mcall 4, <124,194>, , lbl_win
7581 dunkaist 473
    add   ebx,17
474
    add   edx,lbl_win2-lbl_win
485 heavyiron 475
    mcall
205 heavyiron 476
   .nomessage:
477
popa
478
ret
479
 
480
draw_board:
481
pusha
482
 mov  ebx,15*65536+32
483
 mov  ecx,50*65536+32
4697 hidnplayr 484
 mov  edx,15*65536+50            ;Spielfeldposition
6270 leency 485
 mov  esi,10                     ;Spielfeldgroesse Y
205 heavyiron 486
 .vloop:
4697 hidnplayr 487
  mov  edi,14                    ;Spielfeldgroesse X
205 heavyiron 488
  .hloop:
489
    call gen_image
490
    push edx
491
    mov  eax,8
492
    movsx edx, byte [map]
4697 hidnplayr 493
    add  edx,9              ;button-id = map-pos + 10;gen_image inkrements
2526 leency 494
    add  edx,0x80000000     ;first delete previous button
6270 leency 495
    mcall
3905 leency 496
    sub  edx,0x30000000     ;first delete previous button
485 heavyiron 497
    mcall
205 heavyiron 498
    pop  edx
499
    push ebx
500
    push ecx
7773 leency 501
    mcall 7, 0x10000, <32,32>
205 heavyiron 502
    pop  ecx
503
    pop  ebx
504
    add  edx,33 shl 16
505
    add  ebx,33 shl 16
506
    dec  edi
507
    jnz  .hloop
4697 hidnplayr 508
  sub  edx,14*(33 shl 16)        ;Spielfeldgroesse X
205 heavyiron 509
  sub  ebx,14*(33 shl 16)
510
  add  edx,33
511
  add  ecx,33 shl 16
512
  dec  esi
513
  jnz  .vloop
4697 hidnplayr 514
  mov  [map], byte 1             ;Map-Position zuruecksetzen
205 heavyiron 515
popa
516
ret
517
 
518
 
519
draw_window:
520
pusha
521
 
3905 leency 522
    mcall 12,1
6270 leency 523
 
524
    mov  edx,bgcolor
551 spraid 525
    or   edx,0x14000000
6270 leency 526
    mcall 0,<100,492>,<100,422>,,,lbl_title
205 heavyiron 527
 
6270 leency 528
    mcall 8,<100,72>,<28,16>,2,btcolor
529
    add   ebx,80 shl 16
205 heavyiron 530
    inc   edx
485 heavyiron 531
    mcall
6270 leency 532
    add   ebx,80 shl 16
205 heavyiron 533
    inc   edx
485 heavyiron 534
    mcall
205 heavyiron 535
 
536
    mov   eax,4
6270 leency 537
    mov   ebx,20 shl 16 +29
205 heavyiron 538
    mov   ecx,fgcolor
6270 leency 539
	or    ecx,0xB0000000
540
    mov   edx,lbl_toolbar
485 heavyiron 541
    mcall
6270 leency 542
	or    ecx,0x00000000
543
    mov   ebx,18 shl 16 +395
544
    mov   edx,lbl_score
485 heavyiron 545
    mcall
7773 leency 546
    mov   ebx,360 shl 16 +405
205 heavyiron 547
    mov   ecx,fg3color
6270 leency 548
    mov   edx,lbl_copy
485 heavyiron 549
    mcall
205 heavyiron 550
 
3905 leency 551
    mcall 12,2
205 heavyiron 552
 
553
    popa
554
    ret
555
 
6270 leency 556
;=================================================
557
; DATA - LABELS
558
;=================================================
3930 kaitz 559
if lang eq et
6270 leency 560
lbl_title    db 'Torud',0
561
lbl_gameover db 'M ä n g   L ä b i !',0
562
lbl_new_game db 'Alusta enne uut mängu',0
7581 dunkaist 563
lbl_win      db '          T u b l i !           ',0
564
lbl_win2     db '          Lähme edasi!          ',0
6270 leency 565
lbl_yscore   db 'Sinu tulemus:',0
566
lbl_toolbar  db 'Uus mäng:  Lihtne    Keskmine   Raske',0
567
lbl_score    db ' Aeg:   Tulemus:       Tase:',0
3930 kaitz 568
else
6270 leency 569
lbl_title    db 'Pipes',0
570
lbl_gameover db 'G a m e   O v e r !',0
571
lbl_new_game db 'Start a new game first',0
7581 dunkaist 572
lbl_win      db '          G r e a t !           ',0
573
lbl_win2     db "       Let's keep going!        ",0
6270 leency 574
lbl_yscore   db 'Your Score:',0
575
lbl_toolbar  db 'New Game:    Easy     Normal    Hard',0
576
lbl_score    db 'Time:    Score:       Level:',0
3930 kaitz 577
end if
6270 leency 578
 
7773 leency 579
lbl_copy     db '2006, Mario Birkner',0
580
 
6270 leency 581
;=================================================
582
; DATA - VARS
583
;=================================================
4697 hidnplayr 584
stat    db 3  ;0=gameplay 1=won 2-lost 3=stopped
585
speed   db 0
586
time    dd 0
587
diffic  db 0  ;1=hard 3=moderate 5=easy 8=dedicated to Wildwest - try it out!
588
score   dd 0
589
level   dd 1
590
half    db 1  ;reduces the random-crosses
205 heavyiron 591
 
6270 leency 592
;=================================================
593
; DATA - RES
594
;=================================================
4697 hidnplayr 595
map:       ;14*10 blocks + position
205 heavyiron 596
     db 1  ;<- act. position
597
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
598
     db 9,7,1,3,2,0,1,1,0,3,4,4,3,9
599
     db 9,5,0,2,2,1,3,0,3,1,1,6,4,9
600
     db 9,4,0,4,6,0,3,3,2,6,0,1,2,9
601
     db 9,3,0,1,2,4,6,4,5,1,2,4,1,9
602
     db 9,5,3,2,6,3,2,1,2,1,2,6,0,9
603
     db 9,4,0,2,3,0,4,1,2,3,2,3,4,9
604
     db 9,2,0,4,5,6,3,1,3,0,4,1,0,9
605
     db 9,1,0,3,5,4,2,2,4,1,6,0,8,9
606
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
607
images:
608
file 'pipes.raw'
609
I_END: