-
Notifications
You must be signed in to change notification settings - Fork 5
/
tetris.asm
executable file
·2491 lines (2416 loc) · 43.7 KB
/
tetris.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
; z80dasm 1.1.4
; command line: z80dasm -t -a -g 0xa000 -o COPIER.ASM COPIER.APP
org 0a000h
seek 00000h
defb "4952 Protocol Analyzer"
org 0a016h
seek 00016h
defw 003c4h
defw 00800h
org 0a01ah
seek 0001ah
defb "4952 Games Pack - TETRIS "
_filesize:
org 0a102h
seek 00102h
defw 00030h ; Blocks in file - 1
defb " HP4952 TETRIS 4952 "
defw 00800h
_fileflags:
defw 00000h ; Flags 0200h is copy protect
defb "4952 Games Pack - TETRIS "
;; Entry Point
org 0a147h
seek 00147h
defb 0000h
_entryaddr:
defw __init
;; Main Application
org 0a150h
seek 00150h
defw _play_game
;; ???
org 0a17eh
seek 0017eh
defw 0f958h
;; Dynamic link loader data pointer & size
org 0a180h
seek 00180h
defw 00014h ; Number of patches
defw 0a25ah ; Location of patches
__init:
di ; Disable Interrupts
call _load_dll_stub ; Call our dynamic linker
ld de,02000h ;
ld hl,0a800h ; Load menu data & stubs
ld bc,00200h ;
ldir ;
jp 02000h ; Run main menu stub
__0a196h:
ld hl,0a800h ;
ld de,02000h ; Load menu data & stubs again?
ld bc,00200h ;
ldir ;
ld hl,07621h ;
push hl ;
ld a,002h ; Patch function at 1109?
ld (0110ch),a ;
ld hl,0d966h ;
ld (0110dh),hl ;
call 01109h ;
__0a1b3h:
ld hl,0a800h ;
ld de,02000h ; Load menu data & stubs again?
ld bc,00200h ;
ldir ;
ld hl,0761ch ;
ex (sp), hl ;
ld a,002h ; Patch function at 1109?
ld (0110ch),a ;
ld hl,0d966h ;
ld (0110dh),hl ;
call 01109h ;
jp __0a1b3h ; Loop Forever
ret ; How can we ever get here?
;; This is a dynamic linker, at runtime it loads a copy of the
;; ROM vector table into RAM and fixes up all the stubbed
;; ROM references in the executable
;; Load and execute ordinal patching stub from a safe location
_load_dll_stub:
ld hl,0a210h ;
ld de,02a00h ;
ld bc,00036h ;
ldir ;
call 02a00h ;
ld ix,(0a182h) ; Load patch table from ()
ld bc,(0a180h) ; Load patch count
ld l,(ix+000h) ;
ld h,(ix+001h) ;
ld e,(hl) ; Read L Byte
inc hl ;
ld d,(hl) ; Read H Byte
ld l,(ix+002h) ; Get Patch Value
ld h,(ix+003h) ;
add hl,de ; Patch the pointer
ex de,hl ;
ld l,(ix+004h) ; Dest Address
ld h,(ix+005h) ;
ld (hl),e ; Write L Byte
inc hl ;
ld (hl),d ; Write H Byte
ld de,00006h ;
add ix,de ; Next Entry
dec bc ;
ld a,b ;
or c ;
jr nz,$-34 ; More entries?
ret ;
;; Local temp index variable
_dll_tmp:
defb 000h
;; 54 Bytes - Relocated at runtime to 02a00h and executed
org 02a00h
seek 00210h
_dll_stub:
ld a,004h ; Access Page 4
out (020h),a ;
ld hl,08000h ; Copy system ordinals from 10046 ROM
ld de,02d00h ;
ld bc,00134h ;
ldir ;
ld a,002h ; Access Page 2
out (020h),a ;
ld hl,(02d0ch) ; Generate 17 more for 02e34h = 0d9f0h...0da20h
ld bc,00003h ;
ld a,011h ; .. Source appears to be a jump table
call la246h ;
ld hl,(02e16h) ; Generate 68 more for 02e56h =
ld a,(hl) ;
inc hl ; .. (some FM going on here...)
ld h,(hl) ;
ld l,a ;
ld bc,00006h ;
ld a,044h ;
call 0a246h ;
ld bc,00002h ; Generate 30 more for 02edeh = 0eb98h..
ld a,01eh ;
call 0a246h ;
ret ;
org 0a246h
seek 00246h
la246h:
ld ix,_dll_tmp ;
ld (ix+000h),a ;
ld a,l ; do {
ld (de),a ; *DE = L
inc de ; DE++
ld a,h ;
ld (de),a ; *DE = H
inc de ; DE++
add hl,bc ; HL+=BC
dec (ix+000h) ; } while(TMP-- != 0)
jr nz,$-10 ;
ret ;
org 0a25ah
seek 0025ah
__dll_fixups:
defw 02d32h, 00000h, 0a801h
defw 02e6eh, 00000h, 0a804h
defw 02d4ah, 00000h, 0a807h
defw 02d50h, 00000h, 0a811h
defw 02d6ch, 00000h, 0a818h
defw 02d02h, 00000h, 0a81dh
defw 02d02h, 00000h, 0a82dh
defw 02e32h, 00000h, 0a830h
defw 02d02h, 00000h, 0a835h
defw 02e66h, 00003h, 0a868h
defw 02e66h, 00004h, 0a86eh
defw 02d02h, 00000h, 0a946h
defw 02eceh, 00003h, 0a1a8h
defw 02e54h, 00000h, 0a1abh
defw 02eceh, 00004h, 0a1aeh
defw 02eceh, 00000h, 0a1b1h
defw 02eceh, 00003h, 0a1c5h
defw 02e54h, 00000h, 0a1c8h
defw 02eceh, 00004h, 0a1cbh
defw 02eceh, 00000h, 0a1ceh
;; Relocated at runtime from 0a800h to 02000h
org 02000h
seek 00800h
call 01543h ; Patched to 2d32 -> 01543h
call 00fe9h ; Patched to 2e6e -> ????
call 00085h ; Patched to 2d4a -> 00085h
call l2065h ;
ld hl,_splash_screen_data ;200c 21 71 20 ! q
push hl ;
call 01cf8h ; Patched to 2d50 -> 01cf8h
pop hl ;
call l2032h ;
call 0007eh ; Patched to 2d6c -> 0007eh
ld a,006h ; Load Page 6 (Application RAM)
call 00e60h ; Patched to 2d02 -> 00e60h
ld de,0a800h ;
ld hl,02000h ; Load this section over again (dangerous)
ld bc,00200h ;
ldir ;
ld a,002h ; Load Page 2 (10046 ROM)
call 00e60h ; Patched to 2d02 -> 00e60h
jp 014d5h ; Return via call -> 02e32h -> 014d5h
l2032h:
ld a,002h ; Load Page 2 (10046 ROM)
call 00e60h ;
ld hl,_splash_screen_data ;2037 21 71 20 ! q
ld (0761dh),hl ; Screen Paint Script Location
ld hl,(0761fh) ; Copy main menu pointers
ld de,_p_main_menu_page_one ; over the first page menu
ld (0761fh),de ; pointers in our table
ld (07624h),de ;
ld bc,0000eh ;
ldir ;
ld a,(hl) ;
inc hl ;
ld h,(hl) ;
ld l,a ;
inc hl ; Skip to page two...
inc hl ;
ld de,_p_mm_reset ;
ld bc,0000ch ;
ldir ;
ld hl,_play_game ; Patch our application vector
ld (_p_mm_playgame),hl ; for button five on page two
ret ;
l2065h:
ld a,006h ; Patch 00fd4h -> our menu display function
ld (00fd4h),a ;q
ld hl,0a196h ;
ld (00fd5h),hl ;
ret ;
org 02071h
seek 00871h
_splash_screen_data:
defb 0ffh
defb 002h, 003h, 0abh
defb " ", 000h
defb 003h, 005h, 0abh
defb " ", 000h
defb 002h, 00eh, 083h
defb "TETRIS", 000h
defb 002h, 01bh, 0abh
defb " ", 000h
defb 003h, 019h, 0abh
defb " ", 000h
defb 006h, 009h, 083h
defb "for the HP 4952", 000h
defb 007h, 008h, 083h
defb "Protocol Analyzer", 000h
defb 00ah, 008h, 083h, 0abh
defb " Copyright 2018", 000h
defb 00bh, 00ah, 083h
defb "Grizzly Adams", 000h
defb 000h ;; End of Screen Data
_splash_menu_data:
defb "Re-!BERT!Remote!Mass !Play!Self~"
defb "set!Menu!&Print!Store!Game!Test|"
_p_main_menu_page_one:
defw 08336h ;; First Page Menu Data
_p_mm_autoconfig:
defw 0141ch ;; Ordinal 120h Auto Config
_p_mm_setup:
defw 0b5a8h ;; Entry Point for Setup
_p_mm_mon:
defw 0100dh ;; Entry Point for Monitor Menu
_p_mm_sim:
defw 01013h ;; Entry Point for Sim Menu
_p_mm_run:
defw 0b9ffh ;; Entry Point for Run Menu
_p_mm_exam:
defw 013cdh ;; Ordinal 12eh Examine Data
_p_mm_next1:
defw _p_main_menu_page_two ;; Next Page
_p_main_menu_page_two:
defw _splash_menu_data ;; Second Page Menu Data
_p_mm_reset:
defw 0bb1ah ;; Entry Point for Re-Set
_p_mm_bert:
defw 0b22ch ;; Entry Point for BERT Menu
_p_mm_remote:
defw 0d963h ;; Entry Point for Remote & Print
_p_mm_masstorage:
defw 00f0ch ;; Entry Point for Mass Storage
_p_mm_playgame:
defw _play_game ;; Entry Point for Application
_p_mm_selftest:
defw 0136fh ;; Ordinal 12ah Self Test
_p_mm_next2:
defw _p_main_menu_page_one ;; Next Page
_play_game:
ld a, 006h
call 00e60h ; Page in 6
ld hl,0aa00h ; Copy application to Work RAM
ld de,02160h ;
ld bc,01e9fh ; Fixme: update to size of main code
ldir ;
jp _game_main ; Run the application
;; End of menu section
;; Main Application
org 2160h
seek 0a00h
include "lib/screen.asm"
include "lib/keyb.asm"
_game_main:
call _clear_screen
ld a, 083h ; Normal Text
ld (_text_attr), a
ld a, 001h ; Line 15
ld (_cur_y), a
ld a, 001h ; Column 1 (Left)
ld (_cur_x), a
; jp 014d5h ; Return to main menu.
; TetrisJD V1.1 Build 20060507
; Par Jean-Denis Boivin (jeandenis.boivin@gmail.com)
; (c) 2006 Team-Atemis
; http://team-atemis.com
LD A, 1
LD (_cur_x), A
LD A, 1
LD (_cur_y), A
LD HL, STR_bienvenue_1
call _writestring
LD A, 1
LD (_cur_x), A
LD A, 2
LD (_cur_y), A
LD HL, STR_bienvenue_2
call _writestring
LD A, 1
LD (_cur_x), A
LD A, 3
LD (_cur_y), A
LD HL, STR_bienvenue_3
call _writestring
LD A, 1
LD (_cur_x), A
LD A, 4
LD (_cur_y), A
LD HL, STR_bienvenue_5
call _writestring
LD A, 1
LD (_cur_x), A
LD A, 5
LD (_cur_y), A
LD HL, STR_copyright_1
call _writestring
call _getkey_cooked
call _clear_screen
CALL CAL_draw_arena
CALL CAL_update_score
LD HL, INT_lvl
LD (HL), -1
LD HL, INT_speed_1
LD (HL), 25
CALL LBL_next_level
CALL CAL_random
INC HL ; +1
ADD HL, HL ; *2
LD D, H ; Save it
LD E, L
ADD HL, HL ; *4
ADD HL, HL ; *8
ADD HL, DE ; *10
LD D, H ; Save it
LD E, L
LD A, H ; Add upper & lower bytes together
ADD A, L
LD HL, INT_next_format
LD (HL), A
CALL CAL_draw_new_piece
JP LBL_game_loop
LBL_game_loop:
CALL CAL_getkey
LD A, (INT_quit)
CP 2
RET Z
LD A, (INT_speed_1)
LD E, A
LD A, (INT_wait_moin_y)
INC A
LD HL, INT_wait_moin_y
LD (HL), A
CP 150
CALL Z, CAL_inc_wait_2
LD A, (INT_wait_moin_y_2)
CP E
CALL Z, LBL_game_move_down
JP LBL_game_loop
CAL_inc_wait_2:
LD HL, INT_wait_moin_y
LD (HL), 0
LD A, (INT_wait_moin_y_2)
INC A
LD HL, INT_wait_moin_y_2
LD (HL), A
RET
CAL_getkey:
call _keyscan
call _getkey_raw
CP _key_rt
JP Z, LBL_game_move_right
CP _key_lt
JP Z, LBL_game_move_left
CP _key_up
JP Z, LBL_game_rotate
CP ' '
JP Z, LBL_game_rotate_minus
CP _key_dn
JP Z, LBL_game_move_down
CP _key_exit
JP Z, LBL_quit
CP _key_more
JP Z, LBL_pause
RET
CAL_wait_patiently:
LD E, 0
LD A, B
CP 255
RET Z
INC A
LD B, A
JP CAL_wait_patiently2
CAL_wait_patiently2:
LD A, E
CP 255
JP Z, CAL_wait_patiently
INC A
LD E, A
JP CAL_wait_patiently2
LBL_quit:
LD HL, INT_quit
LD (HL), 2
CALL CAL_dead_scrn_tetris
CALL CAL_dead_scrn_tetris2
LD B, 0
CALL CAL_wait_patiently
call _clear_screen
LD A, 1
LD (_cur_x), A
LD A, 3
LD (_cur_y), A
LD HL, STR_bienvenue_3
call _writestring
LD A, 1
LD (_cur_x), A
LD A, 4
LD (_cur_y), A
LD HL, STR_mort
call _writestring
LD A, 1
LD (_cur_x), A
LD A, 5
LD (_cur_y), A
LD HL, ARR_score
call _writestring
; JP LBL_quit_2
LBL_quit_2:
call _keyscan
call _getkey_raw
CP 00ah
JP Z, LBL_wtf
JP LBL_quit_2
LBL_wtf:
;LD HL,str1
;RST 20h
;B_CALL(_ChkFindSym)
;LD HL,str1
;RST 20h
;B_CALL(_chkFindSym)
;PUSH DE
;LD A,B
;POP DE
;INC DE
;INC DE
;LD HL,ARR_score
;LD BC,10
;LDIR
;LD A, (INT_lvl)
;B_CALL(_SetXXOP1)
;B_CALL(_StoX)
;LD A, (INT_lvl2)
;B_CALL(_SetXXOP1)
;B_CALL(_StoR)
jp 014d5h ; Return to HP main menu.
;RET
;str1:
; db StrngObj,tVarStrng,tStr1,$00
LBL_pause:
call _getkey_raw
CP _key_more
JP Z, CAL_getkey
JP LBL_pause
STR_mort:
DB ":: GAME OVER ::", 0
INT_dead_x:
DB 0
INT_dead_y:
DB 0
CAL_dead_scrn_tetris2:
RET
CAL_dead_scrn_tetris:
LD HL, INT_dead_x
LD (HL), 1
LD HL, INT_dead_y
LD (HL), 1
JP LBL_dead_scrn_tetris
LBL_dead_scrn_tetris:
LD A, (INT_dead_x)
LD HL, INT_sp_piece_relx
LD (HL), A
LD A, (INT_dead_y)
SUB 4
LD HL, INT_sp_piece_rely
LD (HL), A
LD HL, INT_piece_skin
LD (HL), 1
CALL CAL_ppiece_off
CALL CAL_ppiece_on
JP LBL_dead_scrn_tetris_addx
LBL_dead_scrn_tetris_addx:
LD A, (INT_dead_x)
INC A
LD HL, INT_dead_x
LD (HL), A
CP 12
JP Z, LBL_dead_scrn_tetris_addy
JP LBL_dead_scrn_tetris
LBL_dead_scrn_tetris_addy:
LD HL, INT_dead_x
LD (HL), 1
LD A, (INT_dead_y)
INC A
LD HL, INT_dead_y
LD (HL), A
CP 16
RET Z
JP LBL_dead_scrn_tetris
LBL_game_move_down:
LD HL, INT_wait_moin_y_2
LD (HL), 0
LD A, (INT_piece_rely)
DEC A
LD HL, INT_piece_rely
LD (HL), A
CALL CAL_update_piece
RET
LBL_game_move_right:
LD A, (INT_piece_relx)
INC A
LD HL, INT_piece_relx
LD (HL), A
CALL CAL_update_piece
RET
LBL_game_move_left:
LD A, (INT_piece_relx)
DEC A
LD HL, INT_piece_relx
LD (HL), A
CALL CAL_update_piece
RET
CAL_rot_reset:
LD A, 0
RET
CAL_rot_reset2:
LD A, 4
RET
LBL_game_rotate:
LD A, (INT_rot)
INC A
CP 4
CALL Z, CAL_rot_reset
LD HL, INT_rot
LD (HL), A
CALL CAL_update_piece
RET
LBL_game_rotate_minus:
LD A, (INT_rot)
CP 0
CALL Z, CAL_rot_reset2
DEC A
LD HL, INT_rot
LD (HL), A
CALL CAL_update_piece
RET
CAL_set_new_fr:
LD A, (INT_format)
LD E, A
LD A, (INT_rot)
ADD A, E
LD E, A
RET
CAL_set_anc_fr:
LD A, (INT_anc_format)
LD E, A
LD A, (INT_anc_rot)
ADD A, E
LD E, A
RET
CAL_next_format:
LD A, (INT_next_format)
LD E, A
RET
CAL_getformat:
LD A, (INT_anc_or_new)
CP 1
CALL Z, CAL_set_new_fr
CP 2
CALL Z, CAL_set_anc_fr
CP 3
CALL Z, CAL_next_format
LD A, E
CP 10
JP Z, LBL_draw_piece_1_0
CP 11
JP Z, LBL_draw_piece_1_0
CP 12
JP Z, LBL_draw_piece_1_0
CP 13
JP Z, LBL_draw_piece_1_0
CP 20
JP Z, LBL_draw_piece_2_0
CP 21
JP Z, LBL_draw_piece_2_1
CP 22
JP Z, LBL_draw_piece_2_2
CP 23
JP Z, LBL_draw_piece_2_3
CP 30
JP Z, LBL_draw_piece_3_0
CP 31
JP Z, LBL_draw_piece_3_1
CP 32
JP Z, LBL_draw_piece_3_0
CP 33
JP Z, LBL_draw_piece_3_1
CP 40
JP Z, LBL_draw_piece_4_0
CP 41
JP Z, LBL_draw_piece_4_1
CP 42
JP Z, LBL_draw_piece_4_0
CP 43
JP Z, LBL_draw_piece_4_1
CP 50
JP Z, LBL_draw_piece_5_0
CP 51
JP Z, LBL_draw_piece_5_1
CP 52
JP Z, LBL_draw_piece_5_0
CP 53
JP Z, LBL_draw_piece_5_1
CP 60
JP Z, LBL_draw_piece_6_0
CP 61
JP Z, LBL_draw_piece_6_1
CP 62
JP Z, LBL_draw_piece_6_2
CP 63
JP Z, LBL_draw_piece_6_3
CP 70
JP Z, LBL_draw_piece_7_0
CP 71
JP Z, LBL_draw_piece_7_1
CP 72
JP Z, LBL_draw_piece_7_2
CP 73
JP Z, LBL_draw_piece_7_3
RET
ARR_score: ; Début Score
DB 48,48,48,48,48,48,48,48,48,0
ARR_score_buf:
DB 0,0,0,0,0,0,0,0,0,0
CAL_conv_score:
LD B, 4
LD A, 0
LD C, A
LD HL, ARR_score_buf
CALL CAL_mtx_10
LD A, (INT_score_10000)
LD (HL), A
LD B, 5
LD A, 0
LD C, A
LD HL, ARR_score_buf
CALL CAL_mtx_10
LD A, (INT_score_1000)
LD (HL), A
LD B, 6
LD A, 0
LD C, A
LD HL, ARR_score_buf
CALL CAL_mtx_10
LD A, (INT_score_100)
LD (HL), A
LD B, 7
LD A, 0
LD C, A
LD HL, ARR_score_buf
CALL CAL_mtx_10
LD A, (INT_score_10)
LD (HL), A
LD B, 8
LD A, 0
LD C, A
LD HL, ARR_score_buf
CALL CAL_mtx_10
LD A, (INT_score_1)
LD (HL), A
RET
INT_score_10000:
DB 0
INT_score_1000:
DB 0
INT_score_100:
DB 0
INT_score_10:
DB 0
INT_score_1:
DB 0
INT_score_to_add:
DB 12
INT_score_to_add_buf:
DB 0
INT_score_x:
DB 0
CAL_add_score:
CALL CAL_conv_score
CALL CAL_add_score_2
CALL CAL_update_score
RET
CAL_add_score_2:
LD HL, INT_score_x
LD (HL), 8
JP LBL_add_score
LBL_add_score:
LD A, (INT_score_x)
LD B, A
LD A, 0
LD C, A
LD HL, ARR_score_buf
CALL CAL_mtx_10
LD HL, INT_score_to_add_buf
LD (HL), A
LD A, (INT_score_x)
LD B, A
LD A, 0
LD C, A
LD HL, ARR_score
CALL CAL_mtx_10
LD E, A
LD A, (INT_score_to_add_buf)
ADD A, E
CP 58
JP NC, LBL_add_score_next_unite
LD (HL), A
JP LBL_add_score_addx
LBL_add_score_next_unite:
SUB 10
LD (HL), A
LD A, (INT_score_x)
DEC A
LD B, A
LD A, 0
LD C, A
LD HL, ARR_score_buf
CALL CAL_mtx_10
INC A
LD (HL), A
JP LBL_add_score_addx
LBL_add_score_addx:
LD A, (INT_score_x)
DEC A
LD HL, INT_score_x
LD (HL), A
INC A
CP 0
RET Z
JP LBL_add_score
CAL_update_score:
LD A, 16
LD (_cur_x), A
LD A, 7
LD (_cur_y), A
LD HL, ARR_score
call _writestring
RET ; Fin Score
CAL_draw_new_piece:
LD HL, INT_piece_relx
LD (HL), 5
LD HL, INT_piece_rely
LD (HL), 15
LD A, (INT_next_format)
LD HL, INT_format
LD (HL), A
LD HL, INT_wait_moin_y
LD (HL), 0
LD HL, INT_wait_moin_y_2
LD (HL), 0
CALL CAL_random
INC HL
ADD HL, HL
LD D, H
LD E, L
ADD HL, HL
ADD HL, HL
ADD HL, DE
LD D, H
LD E, L
LD A, H
ADD A, L
LD HL, INT_next_format
LD (HL), A
LD HL, INT_rot
LD (HL), 0
LD HL, INT_anc_or_new
LD (HL), 3
CALL CAL_draw_next_piece
CALL CAL_draw_piece
RET
CAL_random:
IN A, (032h)
SRL A
SRL A
SRL A
AND 007h
LD L, A
LD H, 000h
RET
CAL_draw_piece:
LD A, (INT_piece_relx)
LD HL, INT_anc_piece_relx
LD (HL), A
LD A, (INT_piece_rely)
LD HL, INT_anc_piece_rely
LD (HL), A
LD A, (INT_format)
LD HL, INT_anc_format
LD (HL), A
LD A, (INT_rot)
LD HL, INT_anc_rot
LD (HL), A
CALL CAL_put_piece_mtx
RET
CAL_draw_next_piece: ; Début Next Piece
LD HL, INT_sp_piece_relx
LD (HL), 18
LD HL, INT_sp_piece_rely
LD (HL), 7
CALL CAL_next_piece_mtx
RET
CAL_next_piece_mtx:
CALL CAL_checkup_mtx_1
LD HL, INT_ppiece_relx
LD (HL), 0
LD HL, INT_ppiece_rely
LD (HL), 0
JP LBL_next_piece_mtx
INT_a_buf:
DB 0
LBL_next_piece_mtx:
CALL CAL_checkup_mtx_2
LD HL, INT_a_buf
LD (HL), A
CALL CAL_ppiece_off
LD A, (INT_a_buf)
CP 1
CALL Z, CAL_ppiece_on
JP LBL_next_piece_mtx_addx
LBL_next_piece_mtx_addx:
LD A, (INT_ppiece_relx)
INC A
LD HL, INT_ppiece_relx
LD (HL), A
CALL CAL_checkup_mtx_4
JP Z, LBL_next_piece_mtx_addy
JP LBL_next_piece_mtx
LBL_next_piece_mtx_addy:
LD HL, INT_ppiece_relx
LD (HL), 0
LD A, (INT_ppiece_rely)
INC A
LD HL, INT_ppiece_rely
LD (HL), A
CALL CAL_checkup_mtx_5
RET Z
JP LBL_next_piece_mtx ; Fin Next Piece
CAL_put_piece_mtx: ; Début Mettre Piece dans MTX
CALL CAL_checkup_mtx_1
JP LBL_put_piece_mtx
LBL_put_piece_mtx:
CALL CAL_checkup_mtx_2
CP 1
JP Z, LBL_put_piece_mtx_add
JP LBL_put_piece_mtx_addx
CALL_put_piece_mtx_add_bug:
INC A
LD (HL), A
RET
LBL_put_piece_mtx_add:
CALL CAL_checkup_mtx_3
CP 4
CALL NZ, CALL_put_piece_mtx_add_bug
JP LBL_put_piece_mtx_addx
LBL_put_piece_mtx_addx:
CALL CAL_checkup_mtx_4
JP Z, LBL_put_piece_mtx_addy
JP LBL_put_piece_mtx
LBL_put_piece_mtx_addy:
CALL CAL_checkup_mtx_5
RET Z
JP LBL_put_piece_mtx ; Fin Mettre Piece dans MTX
CAL_check_for_collision: ; Début Check Collision
CALL CAL_checkup_mtx_1
LD HL, INT_collision_detecte
LD (HL), 0
JP LBL_check_for_collision
LBL_check_for_collision:
CALL CAL_checkup_mtx_2
CP 1
JP Z, LBL_check_for_collision_2
JP LBL_check_for_collision_addx
LBL_check_for_collision_2:
CALL CAL_checkup_mtx_3
LD E, A
LD A, E
CP 3
JP Z, CAL_collision_detecte
JP LBL_check_for_collision_addx
LBL_check_for_collision_addx:
CALL CAL_checkup_mtx_4
JP Z, LBL_check_for_collision_addy
JP LBL_check_for_collision
LBL_check_for_collision_addy:
CALL CAL_checkup_mtx_5
RET Z