Subversion Repositories Kolibri OS

Rev

Rev 3930 | Rev 7581 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3930 Rev 4697
Line 5... Line 5...
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
Line 101... Line 103...
101
    end if
103
    end if
102
  end while
104
  end while
103
}
105
}
104
use32
106
use32
Line 105... Line 107...
105
 
107
 
Line 106... Line 108...
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
Line 113... Line 115...
113
	       dd     0x7fff0		      ; esp
115
               dd     0x7fff0                 ; esp
114
	       dd     0x0 , 0x0 	      ; I_Param , I_Icon
116
               dd     0x0 , 0x0               ; I_Param , I_Icon
Line 115... Line 117...
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 ?
Line 124... Line 126...
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
 
Line 129... Line 131...
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
 
Line 135... Line 137...
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
Line 138... Line 140...
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
Line 175... Line 177...
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
Line 201... Line 203...
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
Line 289... Line 291...
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
Line 327... Line 329...
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
Line 341... Line 343...
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
Line 385... Line 387...
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
Line 402... Line 404...
402
popa
404
popa
403
ret
405
ret
Line 404... Line 406...
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
Line 443... Line 445...
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-
Line 448... Line 450...
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
Line 475... Line 477...
475
ret
477
ret
Line 476... Line 478...
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
Line 536... Line 538...
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
Line 551... Line 553...
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
Line 561... Line 563...
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
Line 573... Line 575...
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
Line 601... Line 603...
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
Line 628... Line 630...
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
Line 642... Line 644...
642
 
644
 
643
 
645
 
Line 644... Line 646...
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
Line 653... Line 655...
653
    or   edx,0x14000000
655
    or   edx,0x14000000
Line 723... Line 725...
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
Line 737... Line 739...
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
Line 749... Line 751...
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