Subversion Repositories Kolibri OS

Rev

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

Rev 4697 Rev 6270
Line 1... Line 1...
1
;
1
;
2
;   pipes kolibri
2
;   pipes kolibri
3
;   v1.21
3
;   v1.4
4
;   2006 by Mario Birkner
4
;   2006 by Mario Birkner
5
;
5
;
6
;   l.mod. 27.08.06/15:11
6
;   l.mod. 20.02.16
7
;
7
;
8
;   Compile with FASM
8
;   Compile with FASM
9
;
9
;
10
format binary as ""
10
format binary as ""
Line 15... Line 15...
15
fg3color equ  0x007F7F55
15
fg3color equ  0x007F7F55
16
btcolor  equ  0x005B6200
16
btcolor  equ  0x005B6200
Line 17... Line 17...
17
 
17
 
18
include '..\..\macros.inc'
18
include '..\..\macros.inc'
19
include 'lang.inc'
-
 
20
; fetch the UTF-8 character in string+offs to char
-
 
21
; common part for all encodings: translate pseudographics
-
 
22
; Pseudographics for the boot screen:
-
 
23
; 0x2500 -> 0xC4, 0x2502 -> 0xB3, 0x250C -> 0xDA, 0x2510 -> 0xBF,
-
 
24
; 0x2514 -> 0xC0, 0x2518 -> 0xD9, 0x252C -> 0xC2, 0x2534 -> 0xC1, 0x2551 -> 0xBA
-
 
25
macro fetch_utf8_char string, offs, char, graph
-
 
26
{ local first_byte, b
-
 
27
  virtual at 0
-
 
28
    db string
-
 
29
    if offs >= $
-
 
30
      char = -1
-
 
31
    else
-
 
32
      ; fetch first byte
-
 
33
      load first_byte byte from offs
-
 
34
      if first_byte < 0x80
-
 
35
        char = first_byte
-
 
36
        offs = offs + 1
-
 
37
      else if first_byte < 0xC0
-
 
38
        .err Invalid UTF-8 string
-
 
39
      else if first_byte < 0xE0
-
 
40
        char = first_byte and 0x1F
-
 
41
        load b byte from offs + 1
-
 
42
        char = (char shl 6) + (b and 0x3F)
-
 
43
        offs = offs + 2
-
 
44
      else if first_byte < 0xF0
-
 
45
        char = first_byte and 0xF
-
 
46
        load b byte from offs + 1
-
 
47
        char = (char shl 6) + (b and 0x3F)
-
 
48
        load b byte from offs + 2
-
 
49
        char = (char shl 6) + (b and 0x3F)
-
 
50
        offs = offs + 3
-
 
51
      else if first_byte < 0xF8
-
 
52
        char = first_byte and 0x7
-
 
53
        load b byte from offs + 1
-
 
54
        char = (char shl 6) + (b and 0x3F)
-
 
55
        load b byte from offs + 2
-
 
56
        char = (char shl 6) + (b and 0x3F)
-
 
57
        load b byte from offs + 3
-
 
58
        char = (char shl 6) + (b and 0x3F)
-
 
59
        offs = offs + 4
-
 
60
      else
-
 
61
        .err Invalid UTF-8 string
-
 
62
      end if
-
 
63
    end if
-
 
64
  end virtual
-
 
65
  if char = 0x2500
-
 
66
    graph = 0xC4
-
 
67
  else if char = 0x2502
-
 
68
    graph = 0xB3
-
 
69
  else if char = 0x250C
-
 
70
    graph = 0xDA
-
 
71
  else if char = 0x2510
-
 
72
    graph = 0xBF
-
 
73
  else if char = 0x2514
-
 
74
    graph = 0xC0
-
 
75
  else if char = 0x2518
-
 
76
    graph = 0xD9
-
 
77
  else if char = 0x252C
-
 
78
    graph = 0xC2
-
 
79
  else if char = 0x2534
-
 
80
    graph = 0xC1
-
 
81
  else if char = 0x2551
-
 
82
    graph = 0xBA
-
 
83
  else
-
 
84
    graph = 0
-
 
85
  end if
-
 
86
}
-
 
87
; Latin-1 encoding
-
 
88
; 0x00-0xFF - trivial map
-
 
89
macro latin1 [arg]
-
 
90
{ local offs, char, graph
-
 
91
  offs = 0
-
 
92
  while 1
-
 
93
    fetch_utf8_char arg, offs, char, graph
-
 
94
    if char = -1
-
 
95
      break
-
 
96
    end if
-
 
97
    if graph
-
 
98
      db graph
-
 
99
    else if char < 0x100
-
 
100
      db char
-
 
101
    else
-
 
102
      .err Failed to convert to Latin-1
-
 
103
    end if
-
 
104
  end while
19
include 'lang.inc'
105
}
20
 
Line 106... Line 21...
106
use32
21
use32
Line 107... Line 22...
107
 
22
 
Line 404... Line 319...
404
popa
319
popa
405
ret
320
ret
Line 406... Line 321...
406
 
321
 
407
show_score:
322
show_score:
408
pusha
-
 
409
mov  eax,13                      ;clear time and score area
-
 
410
mov  ebx,50 shl 16 +15
-
 
411
mov  ecx,395 shl 16 +15
-
 
412
mov  edx,bgcolor
-
 
413
mcall
-
 
414
if lang eq et
-
 
415
add  ebx,60 shl 16 + 30
-
 
416
else
-
 
417
add  ebx,60 shl 16 + 20
-
 
418
end if
-
 
419
mcall
-
 
420
add  ebx,80 shl 16
-
 
421
mcall
323
pusha
422
mov  eax,47
324
mov  eax,47
423
mov  ebx,0x20000
325
mov  ebx,0x20000
424
mov  ecx,[time]
326
mov  ecx,[time]
425
mov  edx,50*65536+398
327
mov  edx,60*65536+395
-
 
328
mov  esi,fg2color
-
 
329
mov  edi,bgcolor
426
mov  esi,fg2color
330
or   esi,0x50000000
427
mcall
331
mcall
428
mov  ebx,0x50000
332
mov  ebx,0x50000
429
mov  ecx,[score]
333
mov  ecx,[score]
430
if lang eq et
334
if lang eq et
431
add  edx,70 shl 16
335
add  edx,88 shl 16
432
else
336
else
433
add  edx,60 shl 16
337
add  edx,80 shl 16
434
end if
338
end if
435
mcall
339
mcall
436
mov  ebx,0x20000
340
mov  ebx,0x20000
437
mov  ecx,[level]
341
mov  ecx,[level]
438
add  edx,80 shl 16
342
add  edx,104 shl 16
Line 439... Line 343...
439
mcall
343
mcall
440
 
344
 
Line 539... Line 443...
539
;   *********************************************
443
;   *********************************************
540
draw_message:
444
draw_message:
541
pusha
445
pusha
542
    cmp  [stat],0
446
    cmp  [stat],0
543
        je .nomessage
447
        je .nomessage
544
    mov  eax,13
-
 
545
    mov  ebx,146 shl 16 + 200
448
    mcall 13,<146,200>,<190,40>,0
546
    mov  ecx,190 shl 16 + 40
-
 
547
    mov  edx,0x0
-
 
548
    mcall
-
 
549
    add  ebx,2 shl 16 - 4
449
    add  ebx,2 shl 16 - 4
550
    add  ecx,2 shl 16 - 4
450
    add  ecx,2 shl 16 - 4
551
    mov  edx,fgcolor
451
    mov  edx,fgcolor
552
    mcall
452
    mcall
Line 553... Line 453...
553
 
453
 
554
        cmp  [stat],3
454
        cmp  [stat],3
555
        jne .stat1
455
        jne .stat1
556
    mov   eax,4
456
    mov   eax,4
557
    mov   ebx,174 shl 16 +206
457
    mov   ebx,159 shl 16 +202
558
    mov   edx,lbl_start_a_new_game+1
-
 
559
    movzx esi,byte [lbl_start_a_new_game]
458
    mov   edx,lbl_new_game
560
    mov   ecx,btcolor
459
    mov   ecx,btcolor
561
    add   ecx,0x10000000
460
    or    ecx,0xB0000000
562
    mcall
461
    mcall
Line 563... Line 462...
563
    jmp .nomessage
462
    jmp .nomessage
564
 
463
 
565
  .stat1:       
464
  .stat1:       
566
    cmp   [stat],1
465
    cmp   [stat],1
567
     je   .winmessage
466
     je   .winmessage
568
    mov   eax,4
467
    mov   eax,4
569
    mov   ebx,186 shl 16 +200
-
 
570
    mov   edx,lbl_gameover+1
468
    mov   ebx,170 shl 16 +196
571
    movzx esi,byte [lbl_gameover]
469
    mov   edx,lbl_gameover
572
    mov   ecx,btcolor
470
    mov   ecx,btcolor
573
    add   ecx,0x10000000
471
    or    ecx,0xB0000000
574
    mcall
472
    mcall
575
    add   ebx,8 shl 16 +17
-
 
576
    mov   edx,lbl_yscore+1
473
    add   ebx,8 shl 16 +17
577
    movzx esi,byte [lbl_yscore]
474
    mov   edx,lbl_yscore
578
    mov   ecx,btcolor
475
    mov   ecx,btcolor
579
    mcall
476
    mcall
580
    mov   esi,ecx       ;color
477
    mov   esi,ecx       ;color
Line 586... Line 483...
586
    mcall
483
    mcall
587
    jmp   .nomessage
484
    jmp   .nomessage
588
   .winmessage:
485
   .winmessage:
589
    mov   eax,4
486
    mov   eax,4
590
    mov   ebx,152 shl 16 +200
487
    mov   ebx,152 shl 16 +200
591
    mov   edx,lbl_win+1
488
    mov   edx,lbl_win
592
    movzx esi,byte [lbl_win]
-
 
593
    mov   ecx,btcolor
489
    mov   ecx,btcolor
594
    add   ecx,0x10000000
490
    or    ecx,0xB0000000
595
    mcall
491
    mcall
596
    mov   ebx,152 shl 16 +217
492
    mov   ebx,152 shl 16 +217
597
    add   edx,esi
493
    add   edx,esi
598
    mov   ecx,btcolor
494
    mov   ecx,btcolor
599
    mcall
495
    mcall
Line 646... Line 542...
646
draw_window:
542
draw_window:
647
pusha
543
pusha
Line 648... Line 544...
648
 
544
 
Line 649... Line -...
649
    mcall 12,1
-
 
650
        
-
 
651
    mov  eax,0                     ; function 0 : define and draw window
-
 
652
    mov  ebx,100*65536+492         ; [x start] *65536 + [x size]
545
    mcall 12,1
653
    mov  ecx,100*65536+420         ; [y start] *65536 + [y size]
546
 
654
    mov  edx,bgcolor               ; color of work area RRGGBB,8->color gl
547
    mov  edx,bgcolor
655
    or   edx,0x14000000
-
 
Line 656... Line -...
656
    mov  edi,title
-
 
657
    mcall
-
 
658
 
-
 
659
    mov   eax,8
-
 
660
    mov   ebx,84*65536+72
548
    or   edx,0x14000000
661
    mov   ecx,28*65536+15
-
 
662
    mov   edx,2
549
    mcall 0,<100,492>,<100,422>,,,lbl_title
663
    mov   esi,btcolor
550
 
664
    mcall
551
    mcall 8,<100,72>,<28,16>,2,btcolor
665
    add   ebx,76 shl 16
552
    add   ebx,80 shl 16
666
    inc   edx
553
    inc   edx
667
    mcall
554
    mcall
Line 668... Line 555...
668
    add   ebx,76 shl 16
555
    add   ebx,80 shl 16
669
    inc   edx
556
    inc   edx
670
    mcall
557
    mcall
671
 
558
 
672
    mov   eax,4
559
    mov   eax,4
673
    mov   ebx,26 shl 16 +32
560
    mov   ebx,20 shl 16 +29
674
    mov   ecx,fgcolor
561
    mov   ecx,fgcolor
675
    mov   edx,lbl_toolbar+1
562
	or    ecx,0xB0000000
676
    movsx esi, byte [lbl_toolbar]
563
    mov   edx,lbl_toolbar
677
    mcall
564
    mcall
678
    mov   ebx,18 shl 16 +398
565
	or    ecx,0x00000000
679
    mov   edx,lbl_score+1
566
    mov   ebx,18 shl 16 +395
680
    movsx esi, byte [lbl_score]
567
    mov   edx,lbl_score
681
    mcall
-
 
682
    mov   ebx,340 shl 16 +405
568
    mcall
Line 683... Line 569...
683
    mov   ecx,fg3color
569
    mov   ebx,340 shl 16 +405
Line 684... Line 570...
684
    mov   edx,lbl_copy+1
570
    mov   ecx,fg3color
685
    movsx esi,byte [lbl_copy]
571
    mov   edx,lbl_copy
Line 686... Line -...
686
    mcall
-
 
-
 
572
    mcall
687
 
573
 
-
 
574
    mcall 12,2
688
    mcall 12,2
575
 
689
 
576
    popa
690
    popa
-
 
691
    ret
-
 
692
 
577
    ret
693
 
-
 
694
; DATA AREA
-
 
695
if lang eq et
578
 
696
title  db  'Torud',0
-
 
697
lbl_gameover:
-
 
698
     db 19
579
;=================================================
699
     latin1 'M ä n g   L ä b i !'
580
; DATA - LABELS
700
lbl_start_a_new_game:
-
 
701
     db 21
-
 
702
     latin1 'Alusta enne uut mängu'
581
;=================================================
703
lbl_win:
-
 
704
     db 32
-
 
705
     latin1 '          T u b l i !           '
582
if lang eq et
706
     latin1 '          Lähme edasi!          '
-
 
707
lbl_yscore:
-
 
708
     db 12
583
lbl_title    db 'Torud',0
709
     latin1 'Sinu tulemus:'
-
 
710
lbl_toolbar:
-
 
711
     db 43
584
lbl_gameover db 'M ä n g   L ä b i !',0
712
     latin1 'Uus mäng:     Lihtne     Keskmine     Raske'
585
lbl_new_game db 'Alusta enne uut mängu',0
713
lbl_copy:
586
lbl_win:     db '          T u b l i !           '
714
     db 24
-
 
715
     latin1 'v1.21 2006,Mario Birkner'
-
 
716
lbl_score:
587
             db '          Lähme edasi!          ',0
717
     db 28
-
 
718
     latin1   'Aeg:    Tulemus:       Tase:'
-
 
719
else
588
lbl_yscore   db 'Sinu tulemus:',0
720
title  db   'Pipes',0
-
 
721
lbl_gameover:
-
 
722
     db 19
589
lbl_toolbar  db 'Uus mäng:  Lihtne    Keskmine   Raske',0
723
     db 'G a m e   O v e r !'
590
lbl_copy     db 'v1.21 2006,Mario Birkner',0
724
lbl_start_a_new_game:
-
 
725
     db 22
-
 
726
     db 'Start a new game first'
591
lbl_score    db ' Aeg:   Tulemus:       Tase:',0
727
lbl_win:
-
 
728
     db 32
-
 
729
     db '          G r e a t !           '
592
else
730
     db "       Let's keep going!        "
-
 
731
lbl_yscore:
-
 
732
     db 11
593
lbl_title    db 'Pipes',0
733
     db 'Your Score:'
-
 
734
lbl_toolbar:
-
 
735
     db 43
594
lbl_gameover db 'G a m e   O v e r !',0
736
     db 'New Game:     Easy       Moderate      Hard'
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
737
lbl_copy:
600
lbl_copy     db 'v1.21 2006,Mario Birkner',0
738
     db 24
601
lbl_score    db 'Time:    Score:       Level:',0
739
     db 'v1.21 2006,Mario Birkner'
602
end if
740
lbl_score:
603
 
741
     db 28
604
;=================================================
742
     db   'Time:    Score:       Level:'
605
; DATA - VARS
743
end if
606
;=================================================
Line -... Line 607...
-
 
607
stat    db 3  ;0=gameplay 1=won 2-lost 3=stopped
-
 
608
speed   db 0
-
 
609
time    dd 0
744
stat    db 3  ;0=gameplay 1=won 2-lost 3=stopped
610
diffic  db 0  ;1=hard 3=moderate 5=easy 8=dedicated to Wildwest - try it out!
745
speed   db 0
611
score   dd 0
746
time    dd 0
612
level   dd 1
747
diffic  db 0  ;1=hard 3=moderate 5=easy 8=dedicated to Wildwest - try it out!
613
half    db 1  ;reduces the random-crosses
748
score   dd 0
614