-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.asm
More file actions
452 lines (423 loc) · 21.8 KB
/
main.asm
File metadata and controls
452 lines (423 loc) · 21.8 KB
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
.386
.model flat, stdcall
option casemap: none
include global_dev.inc
include global_extrn.inc
.code
_ProcWinMain proc uses ebx edi esi, hWnd, uMsg, wParam, lParam
local @stPs: PAINTSTRUCT
local @hDC
local @stPos: POINT
; invoke printf, offset debug_int, playerOne.base.alive
; invoke printf, offset debug_int, playerTwo.base.alive
; invoke printf, offset debug_int, hWinMain
; invoke printf, offset debug_int, hWinMain2
mov eax, hWnd
.if eax == hWinMain
mov eax, uMsg
.if eax == WM_PAINT
invoke BeginPaint, hWnd, addr @stPs
mov @hDC, eax
mov eax, @stPs.rcPaint.right
sub eax, @stPs.rcPaint.left
mov ecx, @stPs.rcPaint.bottom
sub ecx, @stPs.rcPaint.top
invoke BitBlt, @hDC, @stPs.rcPaint.left, @stPs.rcPaint.top, eax, ecx, hDCGame, @stPs.rcPaint.left, @stPs.rcPaint.top, SRCCOPY
invoke EndPaint, hWnd, addr @stPs
.elseif eax == WM_CREATE
.elseif eax == WM_TIMER
mov eax, wParam
.if eax == ID_TIMER
mov eax, cur_interface
.if eax != in_2p_game && eax != in_2p_pause && eax != in_2p_over
invoke _draw_object, hWnd, hDCGame, addr player, addr targets, target_number
mov eax, cur_interface
.if eax == in_game
invoke _change_all_position
invoke _targets_bullet_out_of_bound
invoke _two_two_enum
.endif
.elseif eax == in_2p_game
invoke _Move_process_symbiotic, addr playerOne ;only here
invoke _Move_process_symbiotic, addr playerTwo ;only here
invoke _change_all_position_symbiotic ;only here
invoke _targets_bullet_out_of_bound_symbiotic ;only here
invoke _change_status, addr playerOne, addr playerTwo;only here
invoke _check_all_effect, addr playerOne, addr playerTwo;only here
invoke _two_two_enum_symbiotic, addr playerOne, addr targetsOne, addr target_number_one ;copy here
invoke _draw_object, hWnd, hDCGame, addr playerOne, addr targetsOne, target_number_one
;write here for 1p
.elseif eax == in_2p_pause
invoke _draw_object, hWnd, hDCGame, addr playerOne, addr targetsOne, target_number_one
.elseif eax == in_2p_over
invoke _draw_object, hWnd, hDCGame, addr playerOne, addr targetsOne, target_number_one
.endif
invoke InvalidateRect, hWnd, NULL, FALSE
.elseif eax == ID_TIMER_gene
mov eax, cur_interface
.if eax == in_game
invoke _random_object_gene, addr targets, addr target_number
.elseif eax == in_2p_game
invoke _random_object_gene_2p, addr targetsOne, addr target_number_one
.endif
.endif
.elseif eax == WM_LBUTTONUP
.elseif eax == WM_CLOSE
invoke _Quit
.elseif eax == WM_KEYDOWN
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.endif
xor eax, eax
.elseif eax == hWinMain2
mov eax, uMsg
.if eax == WM_PAINT
invoke BeginPaint, hWnd, addr @stPs
mov @hDC, eax
mov eax, @stPs.rcPaint.right
sub eax, @stPs.rcPaint.left
mov ecx, @stPs.rcPaint.bottom
sub ecx, @stPs.rcPaint.top
invoke BitBlt, @hDC, @stPs.rcPaint.left, @stPs.rcPaint.top, eax, ecx, hDCGame2, @stPs.rcPaint.left, @stPs.rcPaint.top, SRCCOPY
invoke EndPaint, hWnd, addr @stPs
.elseif eax == WM_TIMER
mov eax, wParam
.if eax == ID_TIMER2
; invoke _draw_object, hWnd, hDCGame2, addr playerTwo, addr targetsTwo, target_number_two
mov eax, cur_interface
.if eax == in_2p_game
invoke _two_two_enum_symbiotic, addr playerTwo, addr targetsTwo, addr target_number_two ;copy here
invoke _draw_object, hWnd, hDCGame2, addr playerTwo, addr targetsTwo, target_number_two
.elseif eax == in_2p_pause
invoke _draw_object, hWnd, hDCGame2, addr playerTwo, addr targetsTwo, target_number_two
.elseif eax == in_2p_choose
invoke _draw_object, hWnd, hDCGame2, addr playerTwo, addr targetsTwo, target_number_two
.elseif eax == in_2p_over
invoke _draw_object, hWnd, hDCGame2, addr playerTwo, addr targetsTwo, target_number_two
.endif
invoke InvalidateRect, hWnd, NULL, FALSE
.elseif eax == ID_TIMER_gene2
mov eax, cur_interface
.if eax == in_2p_game
invoke _random_object_gene_2p, addr targetsTwo, addr target_number_two
.endif
.endif
.elseif eax == WM_KEYDOWN
.elseif eax == WM_LBUTTONUP
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.endif
.endif
; keydown
mov eax, uMsg
.if eax == WM_KEYDOWN
mov eax, cur_interface
.if eax == in_game
mov eax, wParam
.if eax == 87
invoke _Action_jump
invoke _Jump_SOUND
.elseif eax == 65
invoke _CarMove_SOUND
invoke _Action_left
.elseif eax == 68
invoke _CarMove_SOUND
invoke _Action_right
.elseif eax == 13
invoke _shot_bullet
.endif
.elseif eax == in_2p_choose
mov eax, wParam
.if eax == 65
mov eax, playerList.choose_confirm
.if eax == 0
dec playerList.curid
mov eax, playerList.curid
.if eax == -1
add eax, player_pic_number
.endif
mov playerList.curid, eax
.endif
.elseif eax == 68
mov eax, playerList.choose_confirm
.if eax == 0
inc playerList.curid
mov eax, playerList.curid
.if eax == 4
sub eax, player_pic_number
.endif
mov playerList.curid, eax
.endif
.elseif eax == 32
mov playerList.choose_confirm, 1
.elseif eax == 37
mov eax, playerList2.choose_confirm
.if eax == 0
dec playerList2.curid
mov eax, playerList2.curid
.if eax == -1
add eax, player_pic_number
.endif
mov playerList2.curid, eax
.endif
.elseif eax == 39
mov eax, playerList2.choose_confirm
.if eax == 0
inc playerList2.curid
mov eax, playerList2.curid
.if eax == 4
sub eax, player_pic_number
.endif
mov playerList2.curid, eax
.endif
.elseif eax == 13
mov playerList2.choose_confirm, 1
.endif
.elseif eax == in_2p_game
mov eax, wParam
.if eax == 87
invoke _Jump_SOUND
invoke _Action_jump_symbiotic, addr playerOne
.elseif eax == 65
invoke _CarMove_SOUND
mov eax, playerOne.has_fever
; invoke printf, offset debug_int, playerOne.has_fever
.if eax > 0
invoke _Action_right_symbiotic, addr playerOne
.else
invoke _Action_left_symbiotic, addr playerOne
.endif
.elseif eax == 68
invoke _CarMove_SOUND
mov eax, playerOne.has_fever
.if eax > 0
invoke _Action_left_symbiotic, addr playerOne
.else
invoke _Action_right_symbiotic, addr playerOne
.endif
.elseif eax == 38
invoke _Jump_SOUND
invoke _Action_jump_symbiotic, addr playerTwo
.elseif eax == 37
invoke _CarMove_SOUND
mov eax, playerTwo.has_fever
.if eax > 0
invoke _Action_right_symbiotic, addr playerTwo
.else
invoke _Action_left_symbiotic, addr playerTwo
.endif
.elseif eax == 39
invoke _CarMove_SOUND
mov eax, playerTwo.has_fever
.if eax > 0
invoke _Action_left_symbiotic, addr playerTwo
.else
invoke _Action_right_symbiotic, addr playerTwo
.endif
; .elseif eax == 13
; invoke _shot_bullet
.endif
.endif
ret
.elseif eax == WM_LBUTTONUP
; invoke printf, offset debug_int, wParam
mov eax, cur_interface
.if eax == in_begining
mov eax, 1
.if eax == button_play.is_click
invoke _Stop_BeginBGM_SOUND
invoke _BGM_SOUND
mov cur_interface, in_game
mov button_play.is_click, 0
;播放开始游戏的BGM
.elseif eax == button_start.is_click
mov cur_interface, in_intro
mov button_start.is_click, 0
.elseif eax == button_2p_play.is_click
invoke _Stop_BeginBGM_SOUND
invoke _BGM_SOUND
invoke ShowWindow, hWinMain2, SW_SHOWNORMAL
invoke _init_2p_mode
mov cur_interface, in_2p_choose
mov button_2p_play.is_click, 0
.elseif eax == button_load.is_click
invoke _init_2p_mode
invoke _load_game, addr playerOne, addr targetsOne, addr target_number_one, addr saveFileName1
.if eax == 0
invoke _load_game, addr playerTwo, addr targetsTwo, addr target_number_two, addr saveFileName2
.if eax == 0
invoke _Stop_BeginBGM_SOUND
invoke _BGM_SOUND
invoke ShowWindow, hWinMain2, SW_SHOWNORMAL
mov cur_interface, in_2p_game
mov button_2p_play.is_click, 0
.endif
.endif
.endif
.elseif eax == in_intro
mov eax, 1
.if eax == button_back.is_click
mov cur_interface, in_begining
mov button_back.is_click, 0
.elseif eax == button_right.is_click
mov eax, intro_id
.if eax < 2
inc eax
.endif
mov intro_id, eax
mov button_right.is_click, 0
.elseif eax == button_left.is_click
mov eax, intro_id
.if eax > 0
dec eax
.endif
mov intro_id, eax
mov button_left.is_click, 0
.endif
.elseif eax == in_over || eax == in_2p_over
mov eax, 1
.if eax == button_exit.is_click
invoke _Stop_END_SOUND
invoke _Quit
mov button_exit.is_click, 0
.elseif eax == button_retry.is_click
invoke _initAll
invoke _Stop_END_SOUND
invoke ShowWindow, hWinMain2, SW_HIDE
invoke _BeginBGM_SOUND
mov cur_interface, in_begining
mov button_retry.is_click, 0
invoke _set_char_pos
.endif
.elseif eax == in_game
mov eax, 0
.if eax != button_pause.is_click
mov cur_interface, in_pause
.endif
.elseif eax == in_pause
mov eax, 1
.if eax == button_pause.is_click
mov cur_interface, in_game
mov button_pause.is_click, 0
.endif
.elseif eax == in_2p_game
invoke _check_button, addr button_pause, hWnd
.if eax == 1
mov cur_interface, in_2p_pause
.endif
.elseif eax == in_2p_pause
invoke _check_button, addr button_save, hWnd
.if eax == 1
invoke _save_game, addr playerOne, addr targetsOne, addr target_number_one, addr saveFileName1
invoke _save_game, addr playerTwo, addr targetsTwo, addr target_number_two, addr saveFileName2
invoke ShowWindow, hWinMain2, SW_HIDE
mov cur_interface, in_begining
mov button_save.is_click, 0
.endif
invoke _check_button, addr button_continue, hWnd
.if eax == 1
mov cur_interface, in_2p_game
mov button_save.is_click, 0
.endif
invoke _check_button, addr button_changeR, hWnd
.if eax == 1
mov cur_interface, in_2p_choose
mov button_save.is_click, 0
.endif
.endif
.endif
;check confirmed
mov eax, playerList.choose_confirm
mov ebx, playerList2.choose_confirm
.if eax == 1 && ebx == 1
mov cur_interface, in_2p_game
mov ebx, playerList.curid
mov eax, [playerList.DC+8*ebx]
mov playerOne.base.DC, eax
mov ebx, playerList2.curid
mov eax, [playerList2.DC+8*ebx]
mov playerTwo.base.DC, eax
mov eax, playerList.curid
mov playerOne.curid, eax
mov eax, playerList2.curid
mov playerTwo.curid, eax
mov playerList.choose_confirm, 0
mov playerList2.choose_confirm, 0
.endif
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
_ProcWinMain endp
_WinMain proc
local @stWndClass: WNDCLASSEX
local @stMsg: MSG
; ?????
invoke GetModuleHandle, NULL
mov hInstance, eax
; ????????
; invoke LoadCursor, hInstance, IDC_MOVE
; mov hCursorMove, eax
; invoke LoadCursor, hInstance, IDC_MAIN
; mov hCursorMain, eax
invoke RtlZeroMemory, addr @stWndClass, sizeof @stWndClass
invoke LoadIcon, hInstance, IDB_ICON
mov @stWndClass.hIcon, eax ; ?????????????
mov @stWndClass.hIconSm, eax
invoke LoadCursor, 0, IDC_ARROW
mov @stWndClass.hCursor, eax
mov eax, hInstance
mov @stWndClass.hInstance, eax
mov @stWndClass.cbSize, sizeof WNDCLASSEX
mov @stWndClass.style, CS_HREDRAW or CS_VREDRAW
; ??????????????????????
mov @stWndClass.lpfnWndProc, offset _ProcWinMain
mov @stWndClass.hbrBackground, COLOR_WINDOW + 1
mov @stWndClass.lpszClassName, offset szClassName
; ???????
; ???????????????????????????????
invoke RegisterClassEx, addr @stWndClass
invoke CreateWindowEx, NULL, \
offset szClassName, offset szClassName, \
WS_OVERLAPPEDWINDOW, \
0, 0, gameH, gameW, \
NULL, NULL, hInstance, NULL
mov hWinMain, eax
invoke ShowWindow, hWinMain, SW_SHOWNORMAL
invoke UpdateWindow, hWinMain
; invoke printf, offset debug_int, hWinMain
invoke CreateWindowEx, NULL, \
offset szClassName, offset szClassName, \
WS_OVERLAPPEDWINDOW, \
gameH, 0, gameH, gameW, \
NULL, NULL, hInstance, NULL
mov hWinMain2, eax
invoke _createAll
invoke _initAll
invoke SetTimer, hWinMain, ID_TIMER, 15, NULL ;flush
invoke SetTimer, hWinMain, ID_TIMER_gene, 100, NULL ;generate
invoke SetTimer, hWinMain2, ID_TIMER2, 15, NULL ;flush
invoke SetTimer, hWinMain2, ID_TIMER_gene2, 100, NULL ;generate
.while TRUE
invoke GetMessage, addr @stMsg, NULL, 0, 0
.break .if eax == 0
invoke TranslateMessage, addr @stMsg
invoke DispatchMessage, addr @stMsg
.endw
ret
_WinMain endp
start:
invoke time, 0
invoke srand, eax
invoke rand
invoke _Open_ALL_SOUND
invoke _BeginBGM_SOUND
call _WinMain
invoke _Close_ALL_SOUND
invoke ExitProcess, NULL
; invoke printf, offset debug_int, eax
; invoke _collision_test
; invoke _two_two_enum_test
; invoke _sst_test
ret
end start