-
Notifications
You must be signed in to change notification settings - Fork 0
/
tetris.asm
executable file
·177 lines (145 loc) · 4.96 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
; 2-04-2018 Aleksey Morozov aka Alemorf
; TETRIS WAS INVENTED BY A 30-YEAR-OLD SOVIET RESEARCHER NAMED ALEXEY PAZHITNOV
; WHO CURRENTLY WORKS AT THE COMPUTER CENTRE(ACADEMY SOFT) OF THE USSR ACADEMY
; OF SCIENCES IN MOSCOW. THE ORIGINAL PROGRAMMER WAS 18-YO VADIM GERASIMOV. A
; STUDENT STUDYING COMPUTER INFORMATICS AT MOSCOW UNIVERSITY. NOW YOU CAN ENJOY
; TETRIS BECAUSE OF THE JOINT EFFORTS OF ACADEMY SOFT, MOSCOW, ANDROMEDA
; SOFTWARE LTD, LONDON, ALEMORF, SPB AND SPECTRUM HOLOBYTE, USA.
; VERSION PROGRAMMER
; ISKRA 1080 TARTU ALEKSEY MOROZOV
; IBM CGA ENG AN JIO
; RAM RESIDENT ERICK JAP
; TANDY BILLY SUTYONO
; IBM EGA ARYANTO WIDODO
; GRAPHICS DAN GUERRA
; PRODUCT MANAGER R. ANTON WIDJAJA
; PRODUCER SEAN B. BARGER
; igrab - 1406, 592
;
.i8080
.include "opcodes.inc"
; Карта памяти после загрузки
; 0100h - 8C00h Код игры
; 8С00h - 93FEh Сжатая заставка интро заехала в видеопамять
; 9000h - BFFFh (Видеопамять)
; C800h - C87Fh (Системные переменные)
; C880h - C900h (Стек)
; D000h - FFFFh (Видеопамять)
; Карта памяти после переноса
; 0003h - 00CAh Кеш игового поля (10x20), временное место хранения системных переменных (80h)
; 00CBh - 00FFh (Стек)
; 0100h - 8C00h Код игры
; 9000h - BFFFh (Видеопамять)
; С000h - C7FFh Сжатая заставка интро, изображения для игры
; C800h - C87Fh (Системные переменные)
; C880h - CFFFh Изображения для интро
; D000h - FFFFh (Видеопамять)
;----------------------------------------------------------------------------------------------------------------------
org 234
fileStart:
.db 4ch, 56h, 4fh, 56h, 2fh, 32h, 2eh, 30h, 2fh, 0d0h, "TETRIS"
.dw entry
.dw end1
.dw entry
;----------------------------------------------------------------------------------------------------------------------
entry:
; Инициализируем стек
lxi sp, 100h
; Включение цвета
out 0F8h
out 0B9h
; Вступление
call intro
; Что бы не было видно мусора с неинициализированного экрана
xra a
sta palette
; Игра
restartGame:
call tetris
; Очистить прямоугольник
lxi h, OPCODE_MVI_M
call copyImageTo
lxi h, 0FFFFh - 135 - (32 * 256)
lxi b, 18 * 256 + 30 ; width * 256 + height
lxi d, 0
call copyImage
; Выводим надпись "GAME OVER"
mvi a, 2
call setTextColor
lxi h, gameOverText
call drawText
; Ждем нажатия Enter
entry_1:
call rand
call inkey_FC12
cpi 13
jnz entry_1
;
jmp restartGame
;----------------------------------------------------------------------------------------------------------------------
gameOverText:
db 9,20,"GAME OVER",0
;----------------------------------------------------------------------------------------------------------------------
pressAnyKey:
; Ждем пока пользователь отпустит клавишу
pressAnyKey_1:
call inkey_FC12
cpi 0FFh
jnz pressAnyKey_1
pressAnyKey_2:
call rand
call inkey_FC12
cpi 0FFh
jz pressAnyKey_2
ret
;----------------------------------------------------------------------------------------------------------------------
.include "fn.inc"
.include "text.inc"
.include "tetris.inc"
.include "bios.inc"
.include "graph.inc"
.include "playfieldgraph.inc"
.include "rand.inc"
.include "unmlz.inc"
;----------------------------------------------------------------------------------------------------------------------
LEVELS_COUNT = 6
levels dw level1
db PALETTE_WHITE, PALETTE_RED, PALETTE_CYAN
dw level2
db PALETTE_WHITE, PALETTE_MAGENTA, PALETTE_CYAN
dw level3
db PALETTE_WHITE, PALETTE_RED, PALETTE_GREEN
dw level4
db PALETTE_WHITE, PALETTE_RED, PALETTE_CYAN
dw level5
db PALETTE_WHITE, PALETTE_RED, PALETTE_CYAN
dw level6
db PALETTE_RED, PALETTE_RED, PALETTE_CYAN
level1:
.include "graph/level1.inc"
level2:
.include "graph/level2.inc"
level3:
.include "graph/level3.inc"
level4:
.include "graph/level4.inc"
level5:
.include "graph/level5.inc"
level6:
.include "graph/level6.inc"
font:
.include "graph/font.inc"
;----------------------------------------------------------------------------------------------------------------------
.include "intro.inc"
plane:
.include "graph/plane.inc"
igrab:
.include "graph/igrab.inc"
packedLogo:
.include "graph/logo.inc"
plane_end:
;----------------------------------------------------------------------------------------------------------------------
end1:
make_binary_file "tetris.lvt", fileStart, end1
.end