Intro.asm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952
  1. include_macros equ 1
  2. include_deb_mac equ 1
  3. include_struc equ 1
  4. include_flags equ 1
  5. include_keyboard_codes equ 1
  6. include include.asm
  7. ; 1a cars to small sky screen
  8. ; 1b to big sky screen
  9. ; 1c between sky screen fade up and fade off
  10. ; 1d fade off sky screen
  11. ; 1e cars to scrolling bit
  12. intro_text_width equ 128
  13. fn_a_pal equ 60080
  14. fn_1a_log equ 60081
  15. fn_1a equ 60082
  16. fn_1b equ 60083
  17. fn_1c equ 60084
  18. fn_1d equ 60085
  19. fn_1e equ 60086
  20. fn_4a equ 60087
  21. fn_4b_log equ 60088
  22. fn_4b equ 60089
  23. fn_4c_log equ 60090
  24. fn_4c equ 60091
  25. fn_5_pal equ 60092
  26. fn_5_log equ 60093
  27. fn_5 equ 60094
  28. fn_6_pal equ 60095
  29. fn_6_log equ 60096
  30. fn_6a equ 60097
  31. fn_6b equ 60098
  32. ifdef short_intro_start
  33. virgin_time_1 equ 3
  34. virgin_time_2 equ 3
  35. rev_time equ 8
  36. gibb_time equ 6
  37. else
  38. virgin_time_1 equ 3*50
  39. virgin_time_2 equ 3*50+8
  40. rev_time equ 8*50+8
  41. gibb_time equ 6*50+8
  42. endif
  43. wait_sequence macro lab
  44. wait_seq_&lab&: call check_commands
  45. ifdef debug_42
  46. call debug_loop
  47. endif
  48. ifdef no_timer
  49. call do_timer_sequence
  50. call stabilise
  51. endif
  52. call fetch_key
  53. jne key_pressed_eax
  54. test [tseq_frames],-1
  55. jne wait_seq_&lab&
  56. endm
  57. start32data
  58. public temp_pal
  59. public work_screen
  60. extrn _skip_intro:dword
  61. ifdef with_replay
  62. extrn _do_a_replay:dword
  63. endif
  64. temp_pal dd 0 ;pointer to temporary palettes
  65. seq1a_data dd 0 ;pointer to sequence data
  66. seq1b_data dd 0
  67. seq1c_data dd 0
  68. seq1d_data dd 0
  69. seq1e_data dd 0
  70. seq4a_data dd 0
  71. seq4b_data dd 0
  72. seq4c_data dd 0
  73. seq5_data dd 0
  74. seq6a_data dd 0
  75. seq6b_data dd 0
  76. vga_data dd 0
  77. diff_data dd 0
  78. work_base dd 0
  79. work_screen dd ?
  80. work_screen_end dd ?
  81. intro_text_space dd 0 ;space for storuing text messages
  82. intro_text_save dd 0 ;save screen data here
  83. vga_pointer dd ? ;working pointers
  84. diff_pointer dd ?
  85. no_frames dd ? ;no of frames in scrolling intro
  86. frame_counter dd ?
  87. command_pointer dd offset zero_commands
  88. ; Sequence commands
  89. ic_prepare_text equ 0
  90. ic_show_text equ 1
  91. ic_remove_text equ 2
  92. ic_make_sound equ 3
  93. ic_fx_volume equ 4
  94. command_routines dd offset prepare_text
  95. dd offset show_intro_text
  96. dd offset remove_text
  97. dd offset intro_fx
  98. dd offset intro_vol
  99. cockpit_commands dd 1000 ;do straight away
  100. dd ic_prepare_text
  101. dd 77
  102. dd 220
  103. dd ic_show_text ;Radar detects a jamming signal
  104. dd 20
  105. dd 160
  106. dd 105
  107. dd ic_remove_text
  108. dd 105
  109. dd ic_prepare_text
  110. dd 81
  111. dd 105
  112. dd ic_show_text ;well switch to override you fool
  113. dd 170
  114. dd 86
  115. dd 35
  116. dd ic_remove_text
  117. dd 35
  118. dd ic_prepare_text
  119. dd 477
  120. dd 35
  121. dd ic_show_text
  122. dd 30
  123. dd 160
  124. dd 3
  125. dd ic_remove_text
  126. zero_commands dd 0
  127. anim5_commands dd 31
  128. dd ic_make_sound
  129. dd 2
  130. dd 127
  131. dd 0
  132. anim4a_commands dd 136
  133. dd ic_make_sound
  134. dd 1
  135. dd 70
  136. dd 90
  137. dd ic_fx_volume
  138. dd 80
  139. dd 50
  140. dd ic_fx_volume
  141. dd 90
  142. dd 5
  143. dd ic_fx_volume
  144. dd 100
  145. dd 0
  146. anim4c_commands dd 1000
  147. dd ic_fx_volume
  148. dd 100
  149. dd 25
  150. dd ic_fx_volume
  151. dd 110
  152. dd 15
  153. dd ic_fx_volume
  154. dd 120
  155. dd 4
  156. dd ic_fx_volume
  157. dd 127
  158. dd 0
  159. anim6a_commands dd 1000
  160. dd ic_prepare_text
  161. dd 478
  162. dd 13
  163. dd ic_show_text
  164. dd 175
  165. dd 155
  166. dd 0
  167. anim6b_commands dd 131
  168. dd ic_remove_text
  169. dd 131
  170. dd ic_prepare_text
  171. dd 479
  172. dd 74
  173. dd ic_show_text
  174. dd 175
  175. dd 155
  176. dd 45
  177. dd ic_remove_text
  178. dd 45
  179. dd ic_prepare_text
  180. dd 162
  181. dd 44
  182. dd ic_show_text
  183. dd 175
  184. dd 155
  185. dd 4
  186. dd ic_remove_text
  187. dd 0
  188. end32data
  189. start32code
  190. public show_screen
  191. extrn force_restart:near
  192. extrn fade_up_esi:near
  193. extrn do_the_cd_intro:near
  194. init_virgin proc
  195. ; Bring on the virgin screen
  196. load_to 60111,[temp_pal] ;virgin palette
  197. mov esi,eax ;set virgin palette
  198. call set_palette
  199. load_to 60110,[work_screen] ;load virgin screen
  200. call show_screen ;show virgin screen
  201. mov [relative_50hz_count],0
  202. free_clr2 [work_screen]
  203. free_clr2 [temp_pal]
  204. ret
  205. init_virgin endp
  206. _intro__Nv proc
  207. ifndef cd_version_prot
  208. ifdef s1_demo
  209. jmp load_base_0
  210. endif
  211. endif
  212. ; call flush_key_buffer
  213. ifdef with_replay ;If replaying don't play intro, leave as though intro played
  214. test [_do_a_replay],-1
  215. jne load_base_0
  216. endif
  217. test [_skip_intro],-1
  218. jne load_base_0
  219. ; While virgin on screen load revolution screen
  220. load_to 60112,[work_screen]
  221. load_to 60113,[temp_pal]
  222. mov eax,0 ;load music
  223. call load_section_music
  224. ; Ensure virgin up for minimum time (should never underrun in reality)
  225. mov eax,virgin_time_1
  226. call wait_relative
  227. jc key_pressed
  228. ; mov [relative_50hz_count],0
  229. ; bt [system_flags],sf_allow_text
  230. ; jc yes_imus
  231. test [_cd_version],-1
  232. jne no_imus
  233. yes_imus: mov eax,1
  234. call fn_start_music
  235. no_imus: mov eax,virgin_time_2
  236. call wait_relative
  237. jc key_pressed
  238. call fn_fade_down ;Remove virgin
  239. ;--------------------------------------------------------------------------------------------------
  240. ; TIMING STARTS HERE
  241. mov [relative_50hz_count],0 ;keep this in 'cos it kinda works
  242. ; Fade up revolution screen
  243. call show_screen
  244. mov esi,[temp_pal]
  245. call fade_up_esi
  246. free_clr2 [temp_pal]
  247. free_clr2 [work_screen]
  248. ; While revolution is up load gibbo's screen
  249. load_to 60114,[work_screen]
  250. load_to 60115,[temp_pal]
  251. ; Do some bits and pieces
  252. mov eax,3
  253. ifdef no_timer
  254. mov eax,2
  255. endif
  256. call set_stabilise
  257. mov eax,10000 ;allocate space for text fings
  258. call my_malloc
  259. mov [intro_text_space],eax
  260. mov eax,10000
  261. call my_malloc
  262. mov [intro_text_save],eax
  263. mov eax,77 ;ensure text file is loaded
  264. call get_text
  265. ; Keep revolution up for a bit
  266. mov eax,rev_time ;revolution up for 4 seconds
  267. call wait_relative
  268. jc key_pressed ;vga data has been loaded
  269. ; mov [relative_50hz_count],0
  270. ; Load and fade up gibbo's screen
  271. call fn_fade_down
  272. call show_screen
  273. mov esi,[temp_pal]
  274. call fade_up_esi
  275. free_clr2 [temp_pal]
  276. free_clr2 [work_screen]
  277. ; CD and hard disk version seperate here
  278. test [_cd_version],-1
  279. je hard_disk_version
  280. ;--------------------------------------------------------------------------------------------------
  281. bt [system_flags],sf_sblaster ;can only do it on blaster
  282. jnc hard_disk_version
  283. ; bt [system_flags],sf_allow_text ;On foreign versions dont use cd intro
  284. ; jc hard_disk_version
  285. call do_the_cd_intro
  286. jifne ebx,key_pressed
  287. call remove_intro2
  288. jmp load_base_0
  289. ;--------------------------------------------------------------------------------------------------
  290. hard_disk_version: ;While gibbo is up load in the first sequence stuff
  291. load_to fn_a_pal,[temp_pal]
  292. load_to fn_1a_log,[work_screen]
  293. load_to fn_1a,[seq1a_data]
  294. mov eax,gibb_time ;keep gibbo up for 2 seconds
  295. call wait_relative
  296. jc key_pressed
  297. ; mov [relative_50hz_count],0
  298. ; Fade in and start the first sequence seq 1
  299. call fn_fade_down
  300. call show_screen
  301. mov esi,[temp_pal]
  302. call fade_up_esi
  303. mov esi,[seq1a_data]
  304. call start_timer_sequence ;start off sequence 1
  305. free_clr2 [work_screen]
  306. free_clr2 [temp_pal]
  307. load_to fn_1b,[seq1b_data] ;load seq 1b while 1a playing
  308. load_to fn_1c,[seq1c_data] ;load 1c while 1a playing
  309. wait_sequence 1a
  310. mov [stabilise_count],3
  311. call stabilise
  312. mov esi,[seq1b_data] ;start 1b seq 1b
  313. call anim_sequence
  314. mov esi,[seq1c_data] ;start 1c
  315. call start_timer_sequence
  316. free_clr2 [seq1a_data]
  317. free_clr2 [seq1b_data]
  318. load_to fn_1d,[seq1d_data] ;load 1d while 1c playing
  319. load_to fn_1e,[seq1e_data] ;load 1e while 1c playing
  320. wait_sequence 1c
  321. mov [stabilise_count],3
  322. call stabilise
  323. mov esi,[seq1d_data] ;start 1d
  324. call anim_sequence
  325. mov esi,[seq1e_data] ;start 1e
  326. call start_timer_sequence
  327. free_clr2 [seq1c_data]
  328. free_clr2 [seq1d_data]
  329. load_to 60100,[vga_data] ;load scrolling bit while waiting
  330. mov [vga_pointer],eax
  331. load_to 60101,[diff_data]
  332. movzx ebx,wpt[eax] ;get no frames
  333. mov [no_frames],ebx
  334. add eax,2
  335. mov [diff_pointer],eax
  336. load_to fn_4a,[seq4a_data]
  337. ; Set up the scrolling intro
  338. mov eax,game_screen_width*game_screen_height*2
  339. call my_malloc
  340. mov [work_base],eax
  341. add eax,game_screen_width*game_screen_height
  342. mov [work_screen],eax
  343. add eax,game_screen_width*game_screen_height
  344. mov [work_screen_end],eax
  345. mov edi,[work_base] ;clear work base
  346. mov ecx,game_screen_width*game_screen_height/4
  347. clear eax
  348. rep stosd
  349. wait_sequence 1e
  350. ; Put in first frame
  351. mov edi,[work_screen]
  352. push ds
  353. mov ds,[screen_segment]
  354. clear esi
  355. mov ecx,game_screen_width*game_screen_height/4
  356. rep movsd
  357. pop ds
  358. mov [frame_counter],1
  359. free_clr2 [seq1e_data]
  360. call stabilise
  361. ; Now do some more frames
  362. frame_loop: mov eax,[frame_counter]
  363. cmp eax,[no_frames]
  364. jnc intro_done
  365. call fetch_key
  366. je no_key
  367. cmp ax,27
  368. je escape_pressed_in_intro
  369. cmp ax,key_f5
  370. je f5_pressed_in_intro
  371. no_key: call stabilise
  372. mov ebx,[diff_pointer]
  373. movzx eax,bpt[ebx] ;get scrolling byte
  374. inc [diff_pointer]
  375. jife eax,no_scroll
  376. ; scroll byte is used for some commands.
  377. ; -1 fade in new palette
  378. imul eax,game_screen_width
  379. sub [work_screen],eax
  380. sub [work_screen_end],eax
  381. no_scroll: ;Non scrolling frame update
  382. call intro_frame
  383. jmp frame_loop
  384. intro_done: ;Ont to 4a, 4b, 5 and 6
  385. mov esi,[seq4a_data]
  386. call start_timer_sequence
  387. free_clr2 [vga_data]
  388. free_clr2 [diff_data]
  389. load_to fn_4b_log,[work_screen]
  390. load_to fn_4b,[seq4b_data]
  391. mov [command_pointer],offset anim4a_commands
  392. wait_sequence 4a
  393. mov [stabilise_count],3
  394. call show_screen
  395. call stabilise
  396. mov [command_pointer],offset cockpit_commands
  397. mov esi,[seq4b_data]
  398. call start_timer_sequence
  399. call check_commands
  400. call check_commands
  401. free_clr2 [work_screen]
  402. free_clr2 [seq4a_data]
  403. load_to fn_4c_log,[work_screen]
  404. load_to fn_4c,[seq4c_data]
  405. wait_sequence 4b
  406. mov [stabilise_count],3
  407. call show_screen
  408. call stabilise
  409. mov esi,[seq4c_data]
  410. call start_timer_sequence
  411. free_clr2 [work_screen]
  412. free_clr2 [seq4b_data]
  413. load_to fn_5_pal,[temp_pal]
  414. load_to fn_5_log,[work_screen]
  415. load_to fn_5,[seq5_data]
  416. mov [command_pointer],offset anim4c_commands
  417. wait_sequence 4c
  418. call fn_fade_down
  419. call show_screen
  420. mov esi,[temp_pal]
  421. call fade_up_esi
  422. mov esi,[seq5_data]
  423. call start_timer_sequence
  424. free_clr2 [work_screen]
  425. free_clr2 [seq4c_data]
  426. free_clr2 [temp_pal]
  427. load_to fn_6_pal,[temp_pal]
  428. load_to fn_6_log,[work_screen]
  429. load_to fn_6a,[seq6a_data]
  430. mov [command_pointer],offset anim5_commands
  431. wait_sequence 5
  432. call fn_fade_down
  433. call show_screen
  434. mov eax,2
  435. call fn_start_music
  436. mov esi,[temp_pal]
  437. call fade_up_esi
  438. mov esi,[seq6a_data]
  439. call start_timer_sequence
  440. free_clr2 [seq5_data]
  441. free_clr2 [temp_pal]
  442. free_clr2 [work_screen]
  443. load_to fn_6b,[seq6b_data]
  444. mov [command_pointer],offset anim6a_commands
  445. wait_sequence 6a
  446. mov esi,[seq6b_data]
  447. call start_timer_sequence
  448. free_clr2 [seq6a_data]
  449. mov [command_pointer],offset anim6b_commands
  450. wait_sequence 6b
  451. free_clr2 [seq6b_data]
  452. call remove_intro2
  453. load_base_0: mov eax,0 ;Start music 2 from section 1
  454. call fn_enter_section
  455. mov eax,2
  456. call fn_start_music
  457. call load_grids
  458. ret
  459. key_pressed_eax: mov ebx,eax
  460. key_pressed: cmp ebx,27
  461. je escape_pressed
  462. jmp f5_pressed
  463. f5_pressed_in_intro: mov [work_screen],0 ;work_screen not malloced in scrolling intro
  464. f5_pressed: mov [tseq_frames],0 ;Stop any sequences
  465. call remove_intro2
  466. call fn_restore_game ;allow a game to be restored
  467. ; call control_panel
  468. call flush_key_buffer
  469. bt [system_flags],sf_game_restored ;If a game was not restored then restart the game
  470. jnc restore_cancelled
  471. ret
  472. escape_pressed_in_intro: mov [work_screen],0 ;work_screen not malloced in scrolling intro
  473. escape_pressed: mov [tseq_frames],0 ;Stop any sequences
  474. call remove_intro2
  475. restore_cancelled: call force_restart
  476. call flush_key_buffer
  477. ret
  478. _intro__Nv endp
  479. remove_intro2 proc
  480. push eax
  481. free_if_n0 vga_data
  482. free_if_n0 diff_data
  483. free_if_n0 work_base
  484. free_if_n0 temp_pal
  485. free_if_n0 seq1a_data
  486. free_if_n0 seq1b_data
  487. free_if_n0 seq1c_data
  488. free_if_n0 seq1d_data
  489. free_if_n0 seq1e_data
  490. free_if_n0 seq4a_data
  491. free_if_n0 seq4b_data
  492. free_if_n0 seq4c_data
  493. free_if_n0 seq5_data
  494. free_if_n0 seq6a_data
  495. free_if_n0 seq6b_data
  496. free_if_n0 intro_text_space
  497. free_if_n0 intro_text_save
  498. free_if_n0 work_screen
  499. mov eax,4
  500. call set_stabilise
  501. pop eax
  502. ret
  503. remove_intro2 endp
  504. show_screen proc
  505. push es
  506. mov ax,[screen_segment]
  507. mov es,ax
  508. mov esi,[work_screen]
  509. clear edi
  510. mov ecx,game_screen_width*game_screen_height/4
  511. rep movsd
  512. pop es
  513. ret
  514. show_screen endp
  515. intro_frame proc
  516. inc [frame_counter]
  517. mov ebx,[diff_pointer]
  518. mov esi,[vga_pointer]
  519. mov edi,[work_screen]
  520. non_loop_same: movzx ecx,bpt[ebx] ;get same count
  521. inc ebx
  522. add edi,ecx
  523. cmp cl,-1 ;255 means keep going
  524. je non_loop_same
  525. non_loop_diff: movzx ecx,bpt[ebx]
  526. inc ebx
  527. rep movsb
  528. cmp bpt[ebx-1],-1
  529. je non_loop_diff
  530. cmp edi,[work_screen_end]
  531. jc non_loop_same
  532. mov [diff_pointer],ebx
  533. mov [vga_pointer],esi
  534. call show_screen
  535. ret
  536. intro_frame endp
  537. intro_fx proc
  538. ; Start an effect
  539. mov eax,8[esi]
  540. mov ecx,12[esi]
  541. push esi
  542. mov ah,5
  543. clear ch
  544. call music_command
  545. pop esi
  546. lea esi,16[esi]
  547. ret
  548. intro_fx endp
  549. intro_vol proc
  550. mov ecx,8[esi]
  551. push esi
  552. mov ah,10
  553. clear ch
  554. call music_command
  555. pop esi
  556. lea esi,12[esi]
  557. ret
  558. intro_vol endp
  559. check_commands proc
  560. ; Check for sequence commands
  561. ; esi points to command data
  562. mov esi,[command_pointer]
  563. mov eax,[esi] ;next frame marker
  564. jife eax,no_command
  565. cmp eax,[tseq_frames] ;counting down
  566. jc no_command
  567. ; Do a command
  568. mov eax,4[esi]
  569. call [offset command_routines + eax*4]
  570. mov [command_pointer],esi
  571. no_command: ret
  572. check_commands endp
  573. prepare_text proc
  574. ; Prepare a text item for printing
  575. mov eax,8[esi]
  576. push esi
  577. call get_text
  578. mov dl,-1
  579. mov cx,intro_text_width
  580. mov ebx,[intro_text_space]
  581. mov esi,offset text_buffer
  582. mov ebp,1
  583. call display_text
  584. pop esi
  585. lea esi,12[esi]
  586. ret
  587. prepare_text endp
  588. show_intro_text proc
  589. ; Show prepared text on the screen
  590. mov edx,full_screen_width ;calculate address
  591. imul edx,dpt 12[esi]
  592. add edx,8[esi]
  593. push esi
  594. ; First save the contents
  595. push edx
  596. mov esi,edx
  597. mov ebx,[intro_text_space]
  598. mov edi,[intro_text_save]
  599. movzx edx,(s ptr[ebx]).s_width
  600. movzx ebx,(s ptr[ebx]).s_height
  601. push ebx
  602. mov [edi],esi ;save address,width and height
  603. mov 4[edi],ebx
  604. mov 8[edi],edx
  605. lea edi,12[edi]
  606. push ds
  607. mov ds,[screen_segment]
  608. save_loop: push esi
  609. mov ecx,edx
  610. rep movsb
  611. pop esi
  612. lea esi,full_screen_width[esi]
  613. floop ebx,save_loop
  614. pop ds
  615. pop ebx
  616. ; Now print the text
  617. pop edi
  618. mov esi,[intro_text_space]
  619. add esi,SIZE s
  620. push es
  621. mov es,[screen_segment]
  622. draw_loop: push edi
  623. mov ecx,edx
  624. pix_loop: lodsb
  625. jife al,no_pix
  626. mov es:[edi],al
  627. no_pix: inc edi
  628. loop pix_loop
  629. pop edi
  630. lea edi,full_screen_width[edi]
  631. floop ebx,draw_loop
  632. pop es
  633. pop esi
  634. lea esi,16[esi]
  635. ret
  636. show_intro_text endp
  637. remove_text proc
  638. push esi
  639. mov esi,[intro_text_save]
  640. mov edi,[esi]
  641. mov ebx,4[esi]
  642. mov edx,8[esi]
  643. lea esi,12[esi]
  644. push es
  645. mov es,[screen_segment]
  646. remove_loop: push edi
  647. mov ecx,edx
  648. rep movsb
  649. pop edi
  650. lea edi,full_screen_width[edi]
  651. floop ebx,remove_loop
  652. pop es
  653. pop esi
  654. lea esi,8[esi]
  655. ret
  656. remove_text endp
  657. end32code
  658. end
  659.