Subversion Repositories Kolibri OS

Rev

Rev 6270 | 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
7581 dunkaist 3
;   v1.41
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:
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
7581 dunkaist 470
    mov   ecx,btcolor OR 0xB0000000
485 heavyiron 471
    mcall
205 heavyiron 472
    add   ebx,8 shl 16 +17
6270 leency 473
    mov   edx,lbl_yscore
485 heavyiron 474
    mcall
4697 hidnplayr 475
    mov   esi,ecx       ;color
476
    mov   edx,ebx       ;pos
7581 dunkaist 477
    add   edx,90 shl 16
4697 hidnplayr 478
    mov   ebx,0x50000    ;type
479
    mov   ecx,[score]    ;inp
205 heavyiron 480
    mov   eax,47
485 heavyiron 481
    mcall
205 heavyiron 482
    jmp   .nomessage
483
   .winmessage:
484
    mov   eax,4
7581 dunkaist 485
    mov   ebx,124 shl 16 +194
6270 leency 486
    mov   edx,lbl_win
205 heavyiron 487
    mov   ecx,btcolor
6270 leency 488
    or    ecx,0xB0000000
485 heavyiron 489
    mcall
7581 dunkaist 490
    add   ebx,17
491
    add   edx,lbl_win2-lbl_win
485 heavyiron 492
    mcall
205 heavyiron 493
   .nomessage:
494
popa
495
ret
496
 
497
draw_board:
498
pusha
499
 mov  ebx,15*65536+32
500
 mov  ecx,50*65536+32
4697 hidnplayr 501
 mov  edx,15*65536+50            ;Spielfeldposition
6270 leency 502
 mov  esi,10                     ;Spielfeldgroesse Y
205 heavyiron 503
 .vloop:
4697 hidnplayr 504
  mov  edi,14                    ;Spielfeldgroesse X
205 heavyiron 505
  .hloop:
506
    call gen_image
507
    push edx
508
    mov  eax,8
509
    movsx edx, byte [map]
4697 hidnplayr 510
    add  edx,9              ;button-id = map-pos + 10;gen_image inkrements
2526 leency 511
    add  edx,0x80000000     ;first delete previous button
6270 leency 512
    mcall
3905 leency 513
    sub  edx,0x30000000     ;first delete previous button
485 heavyiron 514
    mcall
205 heavyiron 515
    pop  edx
516
    push ebx
517
    push ecx
518
    mov  eax,7
519
    mov  ebx,0x10000
520
    mov  ecx,32 shl 16 +32
485 heavyiron 521
    mcall
205 heavyiron 522
    pop  ecx
523
    pop  ebx
524
    add  edx,33 shl 16
525
    add  ebx,33 shl 16
526
    dec  edi
527
    jnz  .hloop
4697 hidnplayr 528
  sub  edx,14*(33 shl 16)        ;Spielfeldgroesse X
205 heavyiron 529
  sub  ebx,14*(33 shl 16)
530
  add  edx,33
531
  add  ecx,33 shl 16
532
  dec  esi
533
  jnz  .vloop
4697 hidnplayr 534
  mov  [map], byte 1             ;Map-Position zuruecksetzen
205 heavyiron 535
popa
536
ret
537
 
538
 
539
draw_window:
540
pusha
541
 
3905 leency 542
    mcall 12,1
6270 leency 543
 
544
    mov  edx,bgcolor
551 spraid 545
    or   edx,0x14000000
6270 leency 546
    mcall 0,<100,492>,<100,422>,,,lbl_title
205 heavyiron 547
 
6270 leency 548
    mcall 8,<100,72>,<28,16>,2,btcolor
549
    add   ebx,80 shl 16
205 heavyiron 550
    inc   edx
485 heavyiron 551
    mcall
6270 leency 552
    add   ebx,80 shl 16
205 heavyiron 553
    inc   edx
485 heavyiron 554
    mcall
205 heavyiron 555
 
556
    mov   eax,4
6270 leency 557
    mov   ebx,20 shl 16 +29
205 heavyiron 558
    mov   ecx,fgcolor
6270 leency 559
	or    ecx,0xB0000000
560
    mov   edx,lbl_toolbar
485 heavyiron 561
    mcall
6270 leency 562
	or    ecx,0x00000000
563
    mov   ebx,18 shl 16 +395
564
    mov   edx,lbl_score
485 heavyiron 565
    mcall
3905 leency 566
    mov   ebx,340 shl 16 +405
205 heavyiron 567
    mov   ecx,fg3color
6270 leency 568
    mov   edx,lbl_copy
485 heavyiron 569
    mcall
205 heavyiron 570
 
3905 leency 571
    mcall 12,2
205 heavyiron 572
 
573
    popa
574
    ret
575
 
6270 leency 576
;=================================================
577
; DATA - LABELS
578
;=================================================
3930 kaitz 579
if lang eq et
6270 leency 580
lbl_title    db 'Torud',0
581
lbl_gameover db 'M ä n g   L ä b i !',0
582
lbl_new_game db 'Alusta enne uut mängu',0
7581 dunkaist 583
lbl_win      db '          T u b l i !           ',0
584
lbl_win2     db '          Lähme edasi!          ',0
6270 leency 585
lbl_yscore   db 'Sinu tulemus:',0
586
lbl_toolbar  db 'Uus mäng:  Lihtne    Keskmine   Raske',0
7581 dunkaist 587
lbl_copy     db 'v1.41 2006,Mario Birkner',0
6270 leency 588
lbl_score    db ' Aeg:   Tulemus:       Tase:',0
3930 kaitz 589
else
6270 leency 590
lbl_title    db 'Pipes',0
591
lbl_gameover db 'G a m e   O v e r !',0
592
lbl_new_game db 'Start a new game first',0
7581 dunkaist 593
lbl_win      db '          G r e a t !           ',0
594
lbl_win2     db "       Let's keep going!        ",0
6270 leency 595
lbl_yscore   db 'Your Score:',0
596
lbl_toolbar  db 'New Game:    Easy     Normal    Hard',0
7581 dunkaist 597
lbl_copy     db 'v1.41 2006,Mario Birkner',0
6270 leency 598
lbl_score    db 'Time:    Score:       Level:',0
3930 kaitz 599
end if
6270 leency 600
 
601
;=================================================
602
; DATA - VARS
603
;=================================================
4697 hidnplayr 604
stat    db 3  ;0=gameplay 1=won 2-lost 3=stopped
605
speed   db 0
606
time    dd 0
607
diffic  db 0  ;1=hard 3=moderate 5=easy 8=dedicated to Wildwest - try it out!
608
score   dd 0
609
level   dd 1
610
half    db 1  ;reduces the random-crosses
205 heavyiron 611
 
6270 leency 612
;=================================================
613
; DATA - RES
614
;=================================================
4697 hidnplayr 615
map:       ;14*10 blocks + position
205 heavyiron 616
     db 1  ;<- act. position
617
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
618
     db 9,7,1,3,2,0,1,1,0,3,4,4,3,9
619
     db 9,5,0,2,2,1,3,0,3,1,1,6,4,9
620
     db 9,4,0,4,6,0,3,3,2,6,0,1,2,9
621
     db 9,3,0,1,2,4,6,4,5,1,2,4,1,9
622
     db 9,5,3,2,6,3,2,1,2,1,2,6,0,9
623
     db 9,4,0,2,3,0,4,1,2,3,2,3,4,9
624
     db 9,2,0,4,5,6,3,1,3,0,4,1,0,9
625
     db 9,1,0,3,5,4,2,2,4,1,6,0,8,9
626
     db 9,9,9,9,9,9,9,9,9,9,9,9,9,9
627
images:
628
file 'pipes.raw'
629
I_END: