-
Notifications
You must be signed in to change notification settings - Fork 0
/
asmExample.asm
2756 lines (2399 loc) · 58.8 KB
/
asmExample.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
INCLUDE Irvine32.inc
Str_remove PROTO,pStart:PTR BYTE,nChars:DWORD
main EQU start@0 ;
TIRED PROTO,
inspeed:DWORD,
exhaust:PTR BYTE
EXCITED PROTO,
plusspeed:DWORD,
happy:PTR BYTE
FFALL PROTO,
STOPspeed:DWORD,
SAD:PTR BYTE
BoxWidth = 9
BoxHeight = 9
trackWidth =100
finishWidth=20
temp = 30
.data
titleStr BYTE "Horse gambling",0
infotitle BYTE "information",0
infomsg BYTE "call the information box again,please enter 1"
BYTE 0dh,0ah,"gamble,please enter 2"
BYTE 0dh,0ah,"choose horse,please enter 3"
BYTE 0dh,0ah,"start the game,please enter 4"
BYTE 0dh,0ah,"check the achievement,please enter 5",0
achievementtitle BYTE "achievement",0
achievementmsg BYTE "first blood: first win"
BYTE 0dh,0ah,"horse god: accumulative 3 win"
BYTE 0dh,0ah,"holly shit: continuous 2 win"
BYTE 0dh,0ah,"Loser: first lose"
BYTE 0dh,0ah,"you should kill yourself: accumulative 3 lose"
BYTE 0dh,0ah,"trash: continuous 2 lose"
BYTE 0dh,0ah,"Korea fish: earn 100 dollar in a game"
BYTE 0dh,0ah,"all in: bet all you money"
BYTE 0dh,0ah,"beggar: money less than 0",0
achievement BYTE "Achievement!!!",0
achievement1 BYTE "first blood",0
achievement2 BYTE "horse god",0
achievement3 BYTE "holly shit",0
achievement4 BYTE "Loser",0
achievement5 BYTE "you should kill yourself",0
achievement6 BYTE "trash",0
achievement7 BYTE "Korea fish",0
achievement8 BYTE "all in",0
achievement9 BYTE "beggar",0
options BYTE "enter your option:",0
gamble BYTE "the money you want to gamble:",0
choosehorse BYTE "the horse you want to choose:",0
horseyouchoose BYTE "horse you choose:",0
yourmoney BYTE "yourmoney:",0
yourgamble BYTE "your gamble:",0
horse1win BYTE "horse1 win!!! ",0
horse2win BYTE "horse2 win!!! ",0
horse3win BYTE "horse3 win!!! ",0
clear BYTE 40 DUP(' '),0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
track BYTE trackWidth DUP('-')
finish BYTE '| |'
BYTE '| ___ |'
BYTE '| | |'
BYTE '| |--- |'
BYTE '| |___ |'
BYTE '| |'
BYTE '| |'
BYTE '| |\ | |'
BYTE '| | \ | |'
BYTE '| | \| |'
BYTE '| |'
BYTE '| __ |'
BYTE '| | \ |'
BYTE '| | \ |'
BYTE '| | / |'
BYTE '| |__ / |'
BYTE '| |'
BYTE '| |'
BYTE '| |',0
G BYTE' ____ '
BYTE' / '
BYTE' | ___ '
BYTE' | | '
BYTE' \____/ '
BYTE' ',0
A BYTE' __ '
BYTE' / \ '
BYTE' / \ '
BYTE' |______| '
BYTE' | | '
BYTE' | | ',0
M BYTE' _ _ '
BYTE' | \ / | '
BYTE' | \/ | '
BYTE' | | '
BYTE' | | '
BYTE' ',0
E BYTE' _____ '
BYTE' | '
BYTE' | '
BYTE' |----- '
BYTE' | '
BYTE' |_____ ',0
O BYTE' ___ '
BYTE' / \ '
BYTE' | | '
BYTE' | | '
BYTE' | | '
BYTE' \___/ ',0
V BYTE' '
BYTE' | |'
BYTE' | |'
BYTE' \ / '
BYTE' \ / '
BYTE' \_/ ',0
E2 BYTE' _____ '
BYTE' | '
BYTE' | '
BYTE' |----- '
BYTE' | '
BYTE' |_____ ',0
R BYTE' ____ '
BYTE' | \ '
BYTE' |____/ '
BYTE' |____ '
BYTE' | | '
BYTE' | | ',0
S BYTE' ___ '
BYTE' / \ '
BYTE' \___ '
BYTE' \ '
BYTE' \___/ '
BYTE' '
BYTE' ',0
T BYTE' _______ '
BYTE' | '
BYTE' | '
BYTE' | '
BYTE' | '
BYTE' | '
BYTE' ',0
fireout BYTE ' * '
BYTE ' * * * '
BYTE ' * * * * * '
BYTE ' * * * * * '
BYTE ' * * * * * '
BYTE ' * * * * * '
BYTE '* * * * * * * * * * * *'
BYTE ' * * * * * '
BYTE ' * * * * * '
BYTE ' * * * * * '
BYTE ' * * * * * '
BYTE ' * * * '
BYTE ' * ',0
firemid BYTE ' * * * '
BYTE ' * * * * * '
BYTE ' * * * * * '
BYTE '* * * * * * * *'
BYTE ' * * * * * '
BYTE ' * * * * * '
BYTE ' * * * ',0
firein BYTE ' * '
BYTE ' * * * '
BYTE '* * * *'
BYTE ' * * * '
BYTE ' * ',0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
fireblank BYTE ' ',0
fireblank1 BYTE 7 DUP(' '),0
fireblank2 BYTE 15 DUP(' '),0
fireblank3 BYTE 23 DUP(' '),0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
firework BYTE "*",0 ;煙火上升
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
boxTop BYTE ' ',' ','#','#','>' ;show mark 馬1
boxBody BYTE '#','#','#','#'
boxBottom BYTE '/','\','/','\'
boxBottom2 BYTE '/','/','/','/'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
box2Top BYTE ' ',' ','#','#','>' ;show mark 馬2
box2Body BYTE '#','#','#','#'
box2Bottom BYTE '/','\','/','\'
box2Bottom2 BYTE '/','/','/','/'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
box3Top BYTE ' ',' ','#','#','>' ;show mark 馬3
box3Body BYTE '#','#','#','#'
box3Bottom BYTE '/','\','/','\'
box3Bottom2 BYTE '/','/','/','/'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
blankTop BYTE ' ',' ',' ',' ',' ' ;show mark
blankBody BYTE ' ',' ',' ',' '
blankBottom BYTE ' ',' ',' ',' '
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
outputHandle DWORD 0
count DWORD 0
starttime DWORD ?
showtime DWORD ?
startxyPosition COORD <35,16> ;馬1起始位置
startxyPosition2 COORD <50,16> ;馬2起始位置
startxyPosition3 COORD <65,16> ;馬3起始位置
xyPosition COORD <10,5> ;馬1起始位置
xyPosition2 COORD <10,12> ;馬2起始位置
xyPosition3 COORD <10,17> ;馬3起始位置
xyPositionF COORD <105,3> ;終點線位置
xyPositionG COORD <15,3>
xyPositionA COORD <30,3>
xyPositionM COORD <55,3>
xyPositionE COORD <70,3>
xyPositionO COORD <15,13>
xyPositionV COORD <30,13>
xyPositionE2 COORD <55,13>
xyPositionR COORD <70,13>
xyPositionS COORD<20,7>
xyPositionT COORD<35,7>
xyPositionA2 COORD<50,7>
xyPositionR2 COORD<65,7>
xyPositionT2 COORD<80,7>
xyPositionfire COORD <40,25> ;煙火起始位置
xyPositionfirein COORD <37,8>
xyPositionfiremid COORD <33,7>
xyPositionfireout COORD <29,4>
xyPositionfire2 COORD <20,25>
xyPositionfire2in COORD <17,8>
xyPositionfire2mid COORD <13,7>
xyPositionfire2out COORD <9,4>
xyPositionfire3 COORD <80,25>
xyPositionfire3in COORD <77,8>
xyPositionfire3mid COORD <73,7>
xyPositionfire3out COORD <69,4>
xyPositionfire4 COORD <100,25>
xyPositionfire4in COORD <97,8>
xyPositionfire4mid COORD <93,7>
xyPositionfire4out COORD <89,4>
xyPositionfireblank COORD <40,25> ;煙火消失起始位置
xyPositionfireblankin COORD <37,8>
xyPositionfireblankmid COORD <33,7>
xyPositionfireblankout COORD <29,4>
xyPositionfireblank2 COORD <20,25>
xyPositionfireblank2in COORD <17,8>
xyPositionfireblank2mid COORD <13,7>
xyPositionfireblank2out COORD <9,4>
xyPositionfireblank3 COORD <80,25>
xyPositionfireblank3in COORD <77,8>
xyPositionfireblank3mid COORD <73,7>
xyPositionfireblank3out COORD <69,4>
xyPositionfireblank4 COORD <100,25>
xyPositionfireblank4in COORD <97,8>
xyPositionfireblank4mid COORD <93,7>
xyPositionfireblank4out COORD <89,4>
trackPosition COORD <5,3>
init DWORD 2
run SBYTE -20
run2 SBYTE -20
run3 SBYTE -20
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;判斷成就系統的變數
bwin SBYTE 0
bwin3 SBYTE 0
blose SBYTE 0
blose3 SBYTE 0
bcwin SBYTE 0
bclose SBYTE 0
allin SBYTE 0
bnomoney SBYTE 0
bkorea SBYTE 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cellsWritten DWORD ?
attributeend WORD 10 DUP(0Ch)
attributestart WORD 10 DUP(0Fh)
attributesfire WORD 23 DUP(0Ah)
attributesfire2 WORD 23 DUP(0Eh)
attributesfire3 WORD 23 DUP(0Ch)
attributesfire4 WORD 23 DUP(09h)
attributes0 WORD BoxWidth DUP(0Ah) ;color
attributes1 WORD BoxWidth DUP(0Ah)
attributes2 WORD BoxWidth DUP(0Ah)
attributes20 WORD BoxWidth DUP(0Eh) ;color2
attributes21 WORD BoxWidth DUP(0Eh)
attributes22 WORD BoxWidth DUP(0Eh)
attributes30 WORD BoxWidth DUP(0Ch) ;color3
attributes31 WORD BoxWidth DUP(0Ch)
attributes32 WORD BoxWidth DUP(0Ch)
optionnumber SDWORD ? ;選擇的數字
money SDWORD ? ;擁有的錢
gamblemoney SDWORD ? ;下注的錢
horse SDWORD ?;選擇的馬
win SDWORD ? ;勝場數
cwin SDWORD ? ;連勝場數
lose SDWORD ? ;敗場數
close SDWORD ? ;連敗場數
pause Dword 5000
duration Dword ? ;馬1移動速度
duration2 Dword ? ;馬2移動速度
duration3 Dword ? ;馬3移動速度
durationchange Dword 1500 ;事件觸發間隔 -
durationchangefast Dword 2000 ;事件觸發間隔 +
durationTmp1 Dword ?
durationTmp2 Dword ?
durationTmp3 Dword ?
speed Dword 380,360,330 ;馬的可能速度
durationf Dword 300 ;煙火速度
durationfb Dword 2000;煙火消失時間
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
H1TIRED BYTE "HORSE 1 IS TIRED",0
H2TIRED BYTE "HORSE 2 IS TIRED",0
H3TIRED BYTE "HORSE 3 IS TIRED",0
H1EXCITED BYTE "HORSE 1 IS EXCITED",0
H2EXCITED BYTE "HORSE 2 IS EXCITED",0
H3EXCITED BYTE "HORSE 3 IS EXCITED",0
H1FALL BYTE "HORSE 1 IS DEAD",0
H2FALL BYTE "HORSE 2 IS DEAD",0
H3FALL BYTE "HORSE 3 IS DEAD",0
FLAGOFFALL BYTE 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.code
main PROC
mov money,100 ;初始基金
mov gamblemoney,0 ;初始下注金額
mov win,0
mov cwin,0
mov lose,0
mov close,0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INVOKE GetStdHandle,STD_OUTPUT_HANDLE ; Get the console ouput handle
mov outputHandle, eax ; save console handle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;初始畫面
mov esi,offset S
mov ecx,6
startS:
push ecx ;;S
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributestart,
10,
xyPositionS,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle,
esi,
10,
xyPositionS,
ADDR count
inc xyPositionS.Y
add esi,10
pop ecx
Loop startS
mov esi,offset T
mov ecx,6
startT:
push ecx ;;T
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributestart,
10,
xyPositionT,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle,
esi,
10,
xyPositionT,
ADDR count
inc xyPositionT.Y
add esi,10
pop ecx
Loop startT
mov esi,offset A
mov ecx,6
startA:
push ecx ;;A
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributestart,
10,
xyPositionA2,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle,
esi,
10,
xyPositionA2,
ADDR count
inc xyPositionA2.Y
add esi,10
pop ecx
Loop startA
mov esi,offset R
mov ecx,6
startR:
push ecx ;;R
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributestart,
10,
xyPositionR2,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle,
esi,
10,
xyPositionR2,
ADDR count
inc xyPositionR2.Y
add esi,10
pop ecx
Loop startR
mov esi,offset T
mov ecx,6
startT2:
push ecx ;;T
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributestart,
10,
xyPositionT2,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle,
esi,
10,
xyPositionT2,
ADDR count
inc xyPositionT2.Y
add esi,10
pop ecx
Loop startT2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;開始裝飾馬
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes0,
5,
startxyPosition,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET boxTop, ; pointer to the top box line
5, ; size of box line
startxyPosition, ; coordinates of first char
ADDR count ; output count
inc COORD PTR startxyPosition.Y ; 座標換到下一行位置
;mov ecx, 1 ; number of lines in body
;push ecx; save counter 避免invoke 有使用到這個暫存器
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes1,
4,
startxyPosition,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET boxBody, ; pointer to the body box line
4, ; size of box line
startxyPosition, ; coordinates of first char
ADDR count ; output count
inc COORD PTR startxyPosition.Y ; 座標換到下一行位置
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes20,
5,
startxyPosition2,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box2Top, ; pointer to the top box line
5, ; size of box line
startxyPosition2, ; coordinates of first char
ADDR count ; output count
inc COORD PTR startxyPosition2.Y ; 座標換到下一行位置
;mov ecx, 1 ; number of lines in body
;push ecx; save counter 避免invoke 有使用到這個暫存器
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes21,
4,
startxyPosition2,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box2Body, ; pointer to the body box line
4, ; size of box line
startxyPosition2, ; coordinates of first char
ADDR count ; output count
inc COORD PTR startxyPosition2.Y ; 座標換到下一行位置
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes30,
5,
startxyPosition3,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box3Top, ; pointer to the top box line
5, ; size of box line
startxyPosition3, ; coordinates of first char
ADDR count ; output count
inc COORD PTR startxyPosition3.Y ; 座標換到下一行位置
;mov ecx, 1 ; number of lines in body
;push ecx; save counter 避免invoke 有使用到這個暫存器
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes31,
4,
startxyPosition3,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box3Body, ; pointer to the body box line
4, ; size of box line
startxyPosition3, ; coordinates of first char
ADDR count ; output count
inc COORD PTR startxyPosition3.Y ; 座標換到下一行位置
horserun: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;抖腳
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes1,
4,
startxyPosition,
ADDR cellsWritten
; draw bottom of the box
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET boxBottom,; pointer to the bottom box line
4, ; size of box line
startxyPosition, ; coordinates of first char
ADDR count ; output count
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes21,
4,
startxyPosition2,
ADDR cellsWritten
; draw bottom of the box
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box2Bottom,; pointer to the bottom box line
4, ; size of box line
startxyPosition2, ; coordinates of first char
ADDR count ; output count
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes31,
4,
startxyPosition3,
ADDR cellsWritten
; draw bottom of the box
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box3Bottom,; pointer to the bottom box line
4, ; size of box line
startxyPosition3, ; coordinates of first char
ADDR count ; output count
INVOKE Sleep,200
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes1,
4,
startxyPosition,
ADDR cellsWritten
; draw bottom of the box
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET boxBottom2,; pointer to the bottom box line
4, ; size of box line
startxyPosition, ; coordinates of first char
ADDR count ; output count
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes21,
4,
startxyPosition2,
ADDR cellsWritten
; draw bottom of the box
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box2Bottom2,; pointer to the bottom box line
4, ; size of box line
startxyPosition2, ; coordinates of first char
ADDR count ; output count
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes31,
4,
startxyPosition3,
ADDR cellsWritten
; draw bottom of the box
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box3Bottom2,; pointer to the bottom box line
4, ; size of box line
startxyPosition3, ; coordinates of first char
ADDR count ; output count
INVOKE Sleep,200
call ReadKey
jz horserun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
L0:
call Clrscr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INVOKE SetConsoleTitle, ADDR titleStr
INVOKE MessageBox, NULL, ADDR infomsg,
ADDR infotitle,
MB_OK
mov ebx,20000
INVOKE GetTickCount
mov starttime,eax
mov esi,offset finish
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;隨機取馬的速度
call randomize
mov eax,3
call RandomRange
shl eax,2
mov ebx,[speed+eax]
mov duration,ebx
mov durationTmp1,ebx
mov eax,3
call RandomRange
shl eax,2
mov ebx,[speed+eax]
mov duration2,ebx
mov durationTmp2,ebx
mov eax,3
call RandomRange
shl eax,2
mov ebx,[speed+eax]
mov duration3,ebx
mov durationTmp3,ebx
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;生成終點線
mov ecx,19
L98:
push ecx
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
esi, ; pointer to the top box line
12, ; size of box line
xyPositionF, ; coordinates of first char
ADDR count ; output count
inc xyPositionF.Y
add esi,12
pop ecx
Loop L98
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;生成跑道
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET track, ; pointer to the top box line
trackWidth, ; size of box line
trackPosition, ; coordinates of first char
ADDR count ; output count
add trackPosition.Y,5
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET track, ; pointer to the top box line
trackWidth, ; size of box line
trackPosition, ; coordinates of first char
ADDR count ; output count
add trackPosition.Y,5
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET track, ; pointer to the top box line
trackWidth, ; size of box line
trackPosition, ; coordinates of first char
ADDR count ; output count
add trackPosition.Y,5
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET track, ; pointer to the top box line
trackWidth, ; size of box line
trackPosition, ; coordinates of first char
ADDR count ; output count
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;馬1跑動
L3:
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes0,
5,
xyPosition,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET boxTop, ; pointer to the top box line
5, ; size of box line
xyPosition, ; coordinates of first char
ADDR count ; output count
inc COORD PTR xyPosition.Y ; 座標換到下一行位置
;mov ecx, 1 ; number of lines in body
L1: ;push ecx; save counter 避免invoke 有使用到這個暫存器
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes1,
4,
xyPosition,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET boxBody, ; pointer to the body box line
4, ; size of box line
xyPosition, ; coordinates of first char
ADDR count ; output count
inc COORD PTR xyPosition.Y ; next line
L2: INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes2,
4,
xyPosition,
ADDR cellsWritten
; draw bottom of the box
cmp run,20
jl L7
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET boxBottom,; pointer to the bottom box line
4, ; size of box line
xyPosition, ; coordinates of first char
ADDR count ; output count
jmp L6
L7:
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET boxBottom2,; pointer to the bottom box line
4, ; size of box line
xyPosition, ; coordinates of first char
ADDR count ; output count
; jmp L6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;馬2跑動
add xyPosition2.Y,-2
L23:
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes20,
5,
xyPosition2,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box2Top, ; pointer to the top box line
5, ; size of box line
xyPosition2, ; coordinates of first char
ADDR count ; output count
inc COORD PTR xyPosition2.Y ; 座標換到下一行位置
L21: ;push ecx; save counter 避免invoke 有使用到這個暫存器
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes21,
4,
xyPosition2,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box2Body, ; pointer to the body box line
4, ; size of box line
xyPosition2, ; coordinates of first char
ADDR count ; output count
inc COORD PTR xyPosition2.Y ; next line
L22: INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes22,
4,
xyPosition2,
ADDR cellsWritten
; draw bottom of the box
cmp run2,20
jl L27
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box2Bottom,; pointer to the bottom box line
4, ; size of box line
xyPosition2, ; coordinates of first char
ADDR count ; output count
jmp L6
L27:
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box2Bottom2,; pointer to the bottom box line
4, ; size of box line
xyPosition2, ; coordinates of first char
ADDR count ; output count
; jmp L6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;馬3跑動
add xyPosition3.Y,-2
L33:
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes30,
5,
xyPosition3,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box3Top, ; pointer to the top box line
5, ; size of box line
xyPosition3, ; coordinates of first char
ADDR count ; output count
inc COORD PTR xyPosition3.Y ; 座標換到下一行位置
;mov ecx, 1 ; number of lines in body
L31: ;push ecx; save counter 避免invoke 有使用到這個暫存器
INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes31,
4,
xyPosition3,
ADDR cellsWritten
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box3Body, ; pointer to the body box line
4, ; size of box line
xyPosition3, ; coordinates of first char
ADDR count ; output count
inc COORD PTR xyPosition3.Y ; next line
L32: INVOKE WriteConsoleOutputAttribute,
outputHandle,
OFFSET attributes32,
4,
xyPosition3,
ADDR cellsWritten
; draw bottom of the box
cmp run3,20
jl L37
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box3Bottom,; pointer to the bottom box line
4, ; size of box line
xyPosition3, ; coordinates of first char
ADDR count ; output count
jmp L6
L37:
INVOKE WriteConsoleOutputCharacter,
outputHandle, ; console output handle
OFFSET box3Bottom2,; pointer to the bottom box line
4, ; size of box line
xyPosition3, ; coordinates of first char
ADDR count ; output count
; jmp L6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cmp init,1
dec init
jg L99
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
L6: ;;偵測時間
INVOKE GetTickCount
sub eax,starttime
cmp eax,durationchange
ja Lspeedchange
INVOKE GetTickCount
sub eax,starttime
cmp eax,durationchangefast
ja Lspeedchangefast
cmp flagoffall,1
je Falling
jmp ENDHORSESLOW
Falling:
cmp xyPosition.X,95
jae L700
cmp xyPosition2.X,95
jae L701
cmp xyPosition3.X,95
jae L702