Subversion Repositories Kolibri OS

Rev

Rev 4697 | Rev 7581 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
205 heavyiron 1
;
3905 leency 2
;   pipes kolibri
6270 leency 3
;   v1.4
205 heavyiron 4
;   2006 by Mario Birkner
5
;
6270 leency 6
;   l.mod. 20.02.16
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:
277
      mov   eax,5
278
      mov   ebx,2
485 heavyiron 279
      mcall
205 heavyiron 280
      mov   eax,11
485 heavyiron 281
      mcall
205 heavyiron 282
      cmp   eax,1
283
      jne   .nored
284
      call  draw_window
285
      .nored:
286
      cmp   eax,3
287
      jne   .noevnt
288
      call  get_input
289
      .noevnt:
290
      dec   ecx
291
      jnz   .down
292
     pop   eax
293
 
294
     add   esi,eax
295
     call  draw_board
296
     call  show_score
297
     jmp   .findway
298
   .collision:
299
    cmp [stat],1
300
    jne .loose
301
    call draw_message
302
    mov   eax,5
303
    mov   ebx,500
485 heavyiron 304
    mcall
205 heavyiron 305
    mov [stat],0
306
    inc [level]
4697 hidnplayr 307
    cmp [speed],6                ;waterflowdelay < 6 ?
205 heavyiron 308
    jle .skipsub
309
    sub [speed],2
310
   .skipsub:
311
    call draw_window
312
    call scramble_board
313
    call draw_board
314
    call countdown
315
    jmp  .restart
316
   .loose:
317
    mov  [stat],2
318
    call draw_message
319
popa
320
ret
321
 
322
show_score:
323
pusha
324
mov  eax,47
325
mov  ebx,0x20000
326
mov  ecx,[time]
6270 leency 327
mov  edx,60*65536+395
205 heavyiron 328
mov  esi,fg2color
6270 leency 329
mov  edi,bgcolor
330
or   esi,0x50000000
485 heavyiron 331
mcall
205 heavyiron 332
mov  ebx,0x50000
333
mov  ecx,[score]
3930 kaitz 334
if lang eq et
6270 leency 335
add  edx,88 shl 16
3930 kaitz 336
else
6270 leency 337
add  edx,80 shl 16
3930 kaitz 338
end if
485 heavyiron 339
mcall
205 heavyiron 340
mov  ebx,0x20000
341
mov  ecx,[level]
6270 leency 342
add  edx,104 shl 16
485 heavyiron 343
mcall
205 heavyiron 344
 
345
popa
346
ret
347
 
348
 
349
 
350
scramble_board:
351
pusha
352
mov edi,map+16 ;startpunkt
353
mov eax,7      ;wieder-
4697 hidnplayr 354
stosb          ;herstellen
205 heavyiron 355
 
356
mov ebx, 0x00000007  ;modul         m max-wert
357
.loop_through:
358
mov   esi,edi
359
lodsb
360
cmp   eax, 9
361
 je   .skip
362
inc   eax
363
xor   edx, edx
4697 hidnplayr 364
div   ebx           ;modulo -> edx
205 heavyiron 365
mov   eax, edx
366
cmp   eax,6
367
jne   .skip
368
dec   [half]
369
movzx eax, byte [half]
370
jnz   .skip
371
mov   [half], byte 7
372
.skip:
373
stosb
374
cmp edi,map+125 ;endpunkt erhalten
375
jge .exit
376
jmp .loop_through
377
.exit:
378
mov  eax,8
379
stosb
380
popa
381
ret
382
 
383
 
384
gen_image:
385
pusha
4697 hidnplayr 386
    xor   ebx,ebx          ;default: kein wasser
205 heavyiron 387
    movzx eax,byte [map]   ;erstes byte der map lesen (position)
4697 hidnplayr 388
    inc   byte [map]       ;position inkrementieren
389
    add   eax,map          ;zur position die map-adresse addieren
205 heavyiron 390
    movzx  esi,byte [eax]
391
    cmp   esi,10
4697 hidnplayr 392
    jl    .nowater
393
    sub   esi,10          ;map-werte+10 sind mit wasser gefuellt
205 heavyiron 394
    mov   ebx,1
395
    cmp   esi,16
396
    jne   .nowater
397
    sub   esi,10
398
 .nowater:
4697 hidnplayr 399
   imul  esi,3072         ;mapwert * 32*32*3 = image-adresse
205 heavyiron 400
    add  esi,images
401
    mov  edi,0x10000
402
    mov  ecx,32*32*3
4697 hidnplayr 403
 .gendd:                  ;RGB-Image im Speicher generieren
205 heavyiron 404
    mov   eax,dword [esi] ;byte aus imagemap lesen
405
    shl   eax,8
406
    shr   eax,8
407
    cmp   ebx,0
4697 hidnplayr 408
    jz    .nowcolor
205 heavyiron 409
    mov   ebx,eax
410
    cmp   ebx,0x00B0B5B0
411
    jne   .nog1
412
    jmp   .wcolor
413
 .nog1:
414
    cmp   ebx,0x00A0A5A0
415
    jne   .nog2
416
    jmp   .wcolor
417
 .nog2:
418
    cmp   ebx,0x00909590
419
    jne   .nog3
420
    jmp   .wcolor
421
 .nog3:
422
    cmp   ebx,0x00808580
423
    jne   .nog4
424
    jmp   .wcolor
425
 .nog4:
426
    cmp   ebx,0x00707570
427
    jne   .nowcolor
428
    jmp   .wcolor
429
 .wcolor:
430
    add   eax,0x40
431
 .nowcolor:
432
    add  esi,3
433
    stosd
434
    dec  edi
435
    loop .gendd
436
popa
437
ret
438
 
439
 
440
 
441
;   *********************************************
442
;   *******  WINDOW DEFINITIONS AND DRAW ********
443
;   *********************************************
444
draw_message:
445
pusha
446
    cmp  [stat],0
4697 hidnplayr 447
        je .nomessage
6270 leency 448
    mcall 13,<146,200>,<190,40>,0
205 heavyiron 449
    add  ebx,2 shl 16 - 4
450
    add  ecx,2 shl 16 - 4
451
    mov  edx,fgcolor
485 heavyiron 452
    mcall
205 heavyiron 453
 
4697 hidnplayr 454
        cmp  [stat],3
455
        jne .stat1
3905 leency 456
    mov   eax,4
6270 leency 457
    mov   ebx,159 shl 16 +202
458
    mov   edx,lbl_new_game
3905 leency 459
    mov   ecx,btcolor
6270 leency 460
    or    ecx,0xB0000000
3905 leency 461
    mcall
4697 hidnplayr 462
    jmp .nomessage
3905 leency 463
 
4697 hidnplayr 464
  .stat1:
205 heavyiron 465
    cmp   [stat],1
466
     je   .winmessage
467
    mov   eax,4
6270 leency 468
    mov   ebx,170 shl 16 +196
469
    mov   edx,lbl_gameover
205 heavyiron 470
    mov   ecx,btcolor
6270 leency 471
    or    ecx,0xB0000000
485 heavyiron 472
    mcall
205 heavyiron 473
    add   ebx,8 shl 16 +17
6270 leency 474
    mov   edx,lbl_yscore
205 heavyiron 475
    mov   ecx,btcolor
485 heavyiron 476
    mcall
4697 hidnplayr 477
    mov   esi,ecx       ;color
478
    mov   edx,ebx       ;pos
205 heavyiron 479
    add   edx,80 shl 16
4697 hidnplayr 480
    mov   ebx,0x50000    ;type
481
    mov   ecx,[score]    ;inp
205 heavyiron 482
    mov   eax,47
485 heavyiron 483
    mcall
205 heavyiron 484
    jmp   .nomessage
485
   .winmessage:
486
    mov   eax,4
487
    mov   ebx,152 shl 16 +200
6270 leency 488
    mov   edx,lbl_win
205 heavyiron 489
    mov   ecx,btcolor
6270 leency 490
    or    ecx,0xB0000000
485 heavyiron 491
    mcall
205 heavyiron 492
    mov   ebx,152 shl 16 +217
493
    add   edx,esi
494
    mov   ecx,btcolor
485 heavyiron 495
    mcall
205 heavyiron 496
   .nomessage:
497
popa
498
ret
499
 
500
draw_board:
501
pusha
502
 mov  ebx,15*65536+32
503
 mov  ecx,50*65536+32
4697 hidnplayr 504
 mov  edx,15*65536+50            ;Spielfeldposition
6270 leency 505
 mov  esi,10                     ;Spielfeldgroesse Y
205 heavyiron 506
 .vloop:
4697 hidnplayr 507
  mov  edi,14                    ;Spielfeldgroesse X
205 heavyiron 508
  .hloop:
509
    call gen_image
510
    push edx
511
    mov  eax,8
512
    movsx edx, byte [map]
4697 hidnplayr 513
    add  edx,9              ;button-id = map-pos + 10;gen_image inkrements
2526 leency 514
    add  edx,0x80000000     ;first delete previous button
6270 leency 515
    mcall
3905 leency 516
    sub  edx,0x30000000     ;first delete previous button
485 heavyiron 517
    mcall
205 heavyiron 518
    pop  edx
519
    push ebx
520
    push ecx
521
    mov  eax,7
522
    mov  ebx,0x10000
523
    mov  ecx,32 shl 16 +32
485 heavyiron 524
    mcall
205 heavyiron 525
    pop  ecx
526
    pop  ebx
527
    add  edx,33 shl 16
528
    add  ebx,33 shl 16
529
    dec  edi
530
    jnz  .hloop
4697 hidnplayr 531
  sub  edx,14*(33 shl 16)        ;Spielfeldgroesse X
205 heavyiron 532
  sub  ebx,14*(33 shl 16)
533
  add  edx,33
534
  add  ecx,33 shl 16
535
  dec  esi
536
  jnz  .vloop
4697 hidnplayr 537
  mov  [map], byte 1             ;Map-Position zuruecksetzen
205 heavyiron 538
popa
539
ret
540
 
541
 
542
draw_window:
543
pusha
544
 
3905 leency 545
    mcall 12,1
6270 leency 546
 
547
    mov  edx,bgcolor
551 spraid 548
    or   edx,0x14000000
6270 leency 549
    mcall 0,<100,492>,<100,422>,,,lbl_title
205 heavyiron 550
 
6270 leency 551
    mcall 8,<100,72>,<28,16>,2,btcolor
552
    add   ebx,80 shl 16
205 heavyiron 553
    inc   edx
485 heavyiron 554
    mcall
6270 leency 555
    add   ebx,80 shl 16
205 heavyiron 556
    inc   edx
485 heavyiron 557
    mcall
205 heavyiron 558
 
559
    mov   eax,4
6270 leency 560
    mov   ebx,20 shl 16 +29
205 heavyiron 561
    mov   ecx,fgcolor
6270 leency 562
	or    ecx,0xB0000000
563
    mov   edx,lbl_toolbar
485 heavyiron 564
    mcall
6270 leency 565
	or    ecx,0x00000000
566
    mov   ebx,18 shl 16 +395
567
    mov   edx,lbl_score
485 heavyiron 568
    mcall
3905 leency 569
    mov   ebx,340 shl 16 +405
205 heavyiron 570
    mov   ecx,fg3color
6270 leency 571
    mov   edx,lbl_copy
485 heavyiron 572
    mcall
205 heavyiron 573
 
3905 leency 574
    mcall 12,2
205 heavyiron 575
 
576
    popa
577
    ret
578
 
6270 leency 579
;=================================================
580
; DATA - LABELS
581
;=================================================
3930 kaitz 582
if lang eq et
6270 leency 583
lbl_title    db 'Torud',0
584
lbl_gameover db 'M ä n g   L ä b i !',0
585
lbl_new_game db 'Alusta enne uut mängu',0
586
lbl_win:     db '          T u b l i !           '
587
             db '          Lähme edasi!          ',0
588
lbl_yscore   db 'Sinu tulemus:',0
589
lbl_toolbar  db 'Uus mäng:  Lihtne    Keskmine   Raske',0
590
lbl_copy     db 'v1.21 2006,Mario Birkner',0
591
lbl_score    db ' Aeg:   Tulemus:       Tase:',0
3930 kaitz 592
else
6270 leency 593
lbl_title    db 'Pipes',0
594
lbl_gameover db 'G a m e   O v e r !',0
595
lbl_new_game db 'Start a new game first',0
596
lbl_win:     db '          G r e a t !           '
597
             db "       Let's keep going!        ",0
598
lbl_yscore   db 'Your Score:',0
599
lbl_toolbar  db 'New Game:    Easy     Normal    Hard',0
600
lbl_copy     db 'v1.21 2006,Mario Birkner',0
601
lbl_score    db 'Time:    Score:       Level:',0
3930 kaitz 602
end if
6270 leency 603
 
604
;=================================================
605
; DATA - VARS
606
;=================================================
4697 hidnplayr 607
stat    db 3  ;0=gameplay 1=won 2-lost 3=stopped
608
speed   db 0
609
time    dd 0
610
diffic  db 0  ;1=hard 3=moderate 5=easy 8=dedicated to Wildwest - try it out!
611
score   dd 0
612
level   dd 1
613
half    db 1  ;reduces the random-crosses
205 heavyiron 614
 
6270 leency 615
;=================================================
616
; DATA - RES
617
;=================================================
4697 hidnplayr 618
map:       ;14*10 blocks + position
205 heavyiron 619
     db 1  ;<- act. position
620
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
621
     db 9,7,1,3,2,0,1,1,0,3,4,4,3,9
622
     db 9,5,0,2,2,1,3,0,3,1,1,6,4,9
623
     db 9,4,0,4,6,0,3,3,2,6,0,1,2,9
624
     db 9,3,0,1,2,4,6,4,5,1,2,4,1,9
625
     db 9,5,3,2,6,3,2,1,2,1,2,6,0,9
626
     db 9,4,0,2,3,0,4,1,2,3,2,3,4,9
627
     db 9,2,0,4,5,6,3,1,3,0,4,1,0,9
628
     db 9,1,0,3,5,4,2,2,4,1,6,0,8,9
629
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
630
images:
631
file 'pipes.raw'
632
I_END:
633