Keyboard.asm 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. include_macros equ 1
  2. include_deb_mac equ 1
  3. include_flags equ 1
  4. include_scripts equ 1
  5. include_struc equ 1
  6. include_error_codes equ 1
  7. include_keyboard_codes equ 1
  8. include include.asm
  9. start32data
  10. extrn past_intro:dword
  11. end32data
  12. start32code
  13. extrn int_09_off:dword
  14. extrn halve_palette:near
  15. extrn double_palette:near
  16. check_keyboard proc
  17. call fetch_key
  18. je no_char
  19. ifdef with_screen_saver
  20. mov [sssss_count],0
  21. endif
  22. ; If pointer_pen == 42 then we have finished the credits and any key will quit to dos
  23. cmp [pointer_pen],42
  24. jne not_end_of_credits
  25. kb_game_over: program_error em_game_over
  26. not_end_of_credits: call check_cheats
  27. je no_char
  28. ;--------------------------------------------------------------------------------------------------p - pause
  29. cmp ax,'p'
  30. je pause
  31. cmp ax,'P'
  32. jne not_pause
  33. ; pause until we get another key
  34. pause: call fn_pause_fx
  35. call halve_palette
  36. pause2: call fetch_key
  37. je pause2
  38. call double_palette
  39. ifdef with_screen_saver
  40. mov [sssss_count],0
  41. endif
  42. mov [bmouse_b],0
  43. call fn_un_pause_fx
  44. jmp no_char
  45. not_pause:
  46. ;--------------------------------------------------------------------------------------------------scroll_lock
  47. cmp ax,key_scroll_lock
  48. jne not_scroll_lock
  49. btc [system_flags],sf_no_scroll
  50. jmp no_char
  51. not_scroll_lock:
  52. ;--------------------------------------------------------------------------------------------------F - toggle fx_off
  53. cmp al,'F'
  54. jne not_tog_fx
  55. call toggle_fx_kbd
  56. ; btc [system_flags],sf_fx_off
  57. ; jc no_char
  58. ;
  59. ; clear eax
  60. ; call fn_stop_fx
  61. ; mov eax,1
  62. ; call fn_stop_fx
  63. jmp no_char
  64. not_tog_fx: cmp al,'M'
  65. jne not_tog_mus
  66. call toggle_ms_kbd
  67. jmp no_char
  68. not_tog_mus:
  69. ;--------------------------------------------------------------------------------------------------escape
  70. cmp ax,27
  71. jne not_escape
  72. test [past_intro],-1
  73. je do_restart
  74. cmp [screen],85
  75. je kb_game_over
  76. ifdef no_keyboard
  77. program_error em_game_over
  78. endif
  79. jmp no_char
  80. do_restart: call force_restart
  81. jmp no_char
  82. not_escape: cmp ax,key_f5
  83. jne not_control
  84. ; can't call up control panel when choosing
  85. bt [system_flags],sf_choosing
  86. jc no_char
  87. cmp [screen],82 ;don't allow it in final rooms
  88. jc control_ok
  89. cmp [screen],85
  90. je control_ok
  91. cmp [screen],90
  92. jc no_char
  93. cmp [screen],101 ;can't save in link terminal as text gets lost
  94. jnc no_char
  95. control_ok:
  96. ifdef with_replay
  97. call switch_replay_to_record
  98. endif
  99. call control_panel
  100. jmp no_char
  101. not_control:
  102. ifdef with_replay
  103. cmp ax,key_f12 ;save mid replay
  104. jne not_save_mid_replay
  105. call control_panel
  106. jmp no_char
  107. not_save_mid_replay:
  108. cmp ax,key_f11
  109. jne not_replay_restart
  110. call force_restart
  111. jmp no_char
  112. not_replay_restart:
  113. endif
  114. ;--------------------------------------------------------------------------------------------------0-9 (speed keys)
  115. ifndef debug_42
  116. bt [system_flags],sf_speed
  117. jnc not_speed
  118. endif
  119. cmp al,'0'
  120. jc not_speed
  121. cmp al,'9'+1
  122. jnc not_speed
  123. sub al,'0'
  124. movzx eax,al
  125. call set_stabilise
  126. jmp no_char
  127. not_speed:
  128. ;--------------------------------------------------------------------------------------------------d (debug)
  129. ifdef debug_42
  130. cmp ax,key_alt_1 ;<alt> 1-0
  131. jc not_debug
  132. cmp ax,key_alt_3+1 ;<alt> 1 = debug walkgrid
  133. jnc not_debug ;<alt> 2 = debug scripts
  134. ;<alt> 3 = show walk grid
  135. sub ax,key_alt_1
  136. mov cl,al
  137. mov ebx,1
  138. shl ebx,cl
  139. xor [_debug_flag],ebx
  140. jmp no_char
  141. ;--------------------------------------------------------------------------------------------------<alt><F1-12> (debug)
  142. not_debug: cmp ax,'m'
  143. jne not_marker
  144. printf "------MARKER-----"
  145. jmp no_char
  146. not_marker: cmp ax,'t'
  147. jne not_tdebug
  148. call fn_stop_voc
  149. jmp no_char
  150. not_tdebug:
  151. endif ;debug_42
  152. ;--------------------------------------------------------------------------------------------------tab + ' ' (replay)
  153. call check_replay_key
  154. jnc no_char
  155. ;not_eq:
  156. ;--------------------------------------------------------------------------------------------------v voc control
  157. ifdef with_voc_editor
  158. bt [system_flags],sf_sblaster
  159. jnc not_voc
  160. cmp ax,'v'
  161. jne not_voc
  162. call _voc_editor__Nv
  163. jmp no_char
  164. not_voc:
  165. endif
  166. no_char: ret
  167. check_keyboard endp
  168. end32code
  169. start32data
  170. chch macro char
  171. ifnb <char>
  172. db char + 1 - 'a'
  173. else
  174. db 0
  175. endif
  176. endm
  177. no_cheats equ 9
  178. cheat_list dd version_ch
  179. dd speed_ch
  180. dd finger_ch
  181. dd jammer_ch
  182. dd dump_ch
  183. dd debug_ch
  184. dd room_access_ch
  185. dd quick_ch
  186. dd testvoice_ch
  187. cheat_pointer dd 0
  188. ; Cheat texts in alphabetical order
  189. ; NOTE first letter MUST be different for each one
  190. debug_ch db 0 dup (0)
  191. chch 'd'
  192. chch 'e'
  193. chch 'b'
  194. chch 'u'
  195. chch 'g'
  196. chch
  197. dd offset do_debug_show
  198. finger_ch db 0 dup (0)
  199. chch 'f'
  200. chch 'i'
  201. chch 'n'
  202. chch 'g'
  203. chch 'e'
  204. chch 'r'
  205. chch
  206. dd offset show_fingerprint
  207. dump_ch db 0 dup (0)
  208. chch 'g'
  209. chch 'r'
  210. chch 'a'
  211. chch 'b'
  212. chch 's'
  213. chch 'c'
  214. chch 'r'
  215. chch 'e'
  216. chch 'e'
  217. chch 'n'
  218. chch
  219. dd offset do_screen_dump
  220. jammer_ch db 0 dup (0)
  221. chch 'j'
  222. chch 'a'
  223. chch 'm'
  224. chch 'm'
  225. chch 'e'
  226. chch 'r'
  227. chch
  228. dd offset get_jammer
  229. quick_ch db 0 dup (0)
  230. chch 'q'
  231. chch 'u'
  232. chch 'i'
  233. chch 'c'
  234. chch 'k'
  235. chch 'c'
  236. chch 'h'
  237. chch 'e'
  238. chch 'a'
  239. chch 't'
  240. chch
  241. dd offset do_quick_cheat
  242. room_access_ch db 0 dup (0)
  243. chch 'r'
  244. chch 'o'
  245. chch 'o'
  246. chch 'm'
  247. chch 'a'
  248. chch 'c'
  249. chch 'c'
  250. chch 'e'
  251. chch 's'
  252. chch 's'
  253. chch
  254. dd offset access_room
  255. speed_ch db 0 dup (0)
  256. chch 's'
  257. chch 'p'
  258. chch 'e'
  259. chch 'e'
  260. chch 'd'
  261. chch
  262. dd offset take_speed
  263. testvoice_ch db 0 dup (0)
  264. chch 't'
  265. chch 'e'
  266. chch 's'
  267. chch 't'
  268. chch 'v'
  269. chch 'o'
  270. chch 'i'
  271. chch 'c'
  272. chch 'e'
  273. chch
  274. dd offset test_voices
  275. version_ch db 0 dup (0)
  276. chch 'v'
  277. chch 'e'
  278. chch 'r'
  279. chch 's'
  280. chch 'i'
  281. chch 'o'
  282. chch 'n'
  283. chch
  284. dd offset show_version
  285. version_sprite dd 0 ;pointer to version or fingerprint sprite (0 if none exists)
  286. version_compact dw 0,0,0,0,0,0,0
  287. version_x dw 130
  288. version_y dw 150
  289. dw 0
  290. version_v dw 0
  291. end32data
  292. start32code
  293. check_cheats proc
  294. ; Check for various cheat modes
  295. cmp ax,27
  296. jnc no_cheat
  297. test [cheat_pointer],-1
  298. jne in_cheat
  299. ; Look for a new cheat
  300. mov esi,offset cheat_list
  301. mov ecx,no_cheats
  302. cheat_loop: mov edi,[esi]
  303. cmp al,[edi]
  304. je start_cheat
  305. lea esi,4[esi]
  306. loop cheat_loop
  307. jmp no_cheat
  308. start_cheat: ;we have the start of a cheat
  309. inc edi
  310. mov [cheat_pointer],edi
  311. clear ax
  312. ret
  313. in_cheat: ;in the middle of a cheat
  314. mov esi,[cheat_pointer]
  315. cmp al,[esi]
  316. jne no_cheat
  317. test bpt 1[esi],-1
  318. je got_cheat
  319. inc [cheat_pointer]
  320. clear al
  321. ret
  322. got_cheat: lea esi,2[esi]
  323. call dpt[esi]
  324. no_cheat: mov [cheat_pointer],0
  325. or al,al
  326. ret
  327. check_cheats endp
  328. show_version proc
  329. ; Show the game version
  330. mov esi,offset current_version
  331. jmp show_text
  332. show_version endp
  333. show_fingerprint proc
  334. mov esi,offset finger_print
  335. jmp show_text
  336. show_fingerprint endp
  337. show_text proc
  338. test [version_sprite],-1
  339. jne trash_ver
  340. mov dl,-1
  341. mov cx,100
  342. clear ebx
  343. mov ebp,1
  344. call display_text
  345. mov [version_sprite],eax
  346. mov [version_v],0
  347. ret
  348. trash_ver: mov eax,[version_sprite]
  349. call my_free
  350. mov [version_sprite],0
  351. ret
  352. show_text endp
  353. cut_off equ 319 ;316
  354. print_version proc
  355. test [version_sprite],-1
  356. je no_sprite
  357. cmp [version_y],cut_off-1
  358. jc falling
  359. test [version_v],-1
  360. je still
  361. falling: mov ax,[version_v]
  362. add [version_y],ax
  363. add [version_v],1
  364. cmp [version_y],cut_off
  365. jc still
  366. mov ax,cut_off
  367. sub ax,[version_y]
  368. add ax,cut_off
  369. mov [version_y],ax
  370. movzx eax,ax
  371. mov ax,[version_v]
  372. shr ax,1
  373. neg ax
  374. mov [version_v],ax
  375. still: movzx eax,[version_y]
  376. movzx eax,[version_v]
  377. mov esi,offset version_compact
  378. mov edi,[version_sprite]
  379. call draw_sprite
  380. mov bl,81h
  381. call vector_to_game
  382. no_sprite: ret
  383. print_version endp
  384. take_speed proc
  385. bts [system_flags],sf_speed
  386. ret
  387. take_speed endp
  388. get_jammer proc
  389. mov [got_jammer],42
  390. mov [got_sponsor],69
  391. ret
  392. get_jammer endp
  393. do_debug_show proc
  394. xor [show_debug_vars],1
  395. ret
  396. do_debug_show endp
  397. access_room proc
  398. ; Alter flags so we have access to certain rooms
  399. clear ebx ;room number fingy
  400. push ebx
  401. no_char: call fetch_key
  402. je no_char
  403. cmp ax,13 ;return accepts
  404. je got_room
  405. pop ebx
  406. sub ax,'0'
  407. imul ebx,ebx,10
  408. add bx,ax
  409. push ebx
  410. jmp no_char
  411. got_room: pop ebx ;room to get to
  412. cmp ebx,11
  413. je get_to_computer_room
  414. cmp ebx,14
  415. je get_to_reactor_section
  416. cmp ebx,16
  417. je get_to_reactor_section
  418. cmp ebx,17
  419. je get_to_reactor_section
  420. cmp ebx,27
  421. je get_to_burke
  422. ret
  423. get_to_reactor_section:
  424. mov [foreman_friend],42 ;stop potts from stopping you
  425. mov eax,8484 ;send sync 1 to rad-suit (put in locker)
  426. mov ebx,1
  427. call fn_send_sync
  428. mov eax,id_anita_spy ;stop anita from getting to you
  429. call fn_kill_id
  430. ret
  431. get_to_burke: mov [knows_port],42
  432. ret
  433. get_to_computer_room:
  434. mov [card_status],2
  435. mov [card_fix],1
  436. ret
  437. access_room endp
  438. do_quick_cheat proc
  439. bts [system_flags],sf_allow_quick
  440. ret
  441. do_quick_cheat endp
  442. test_voices proc
  443. bt [system_flags],sf_play_vocs ;check we are able to play voices
  444. jnc no_test
  445. mov eax,50000 ;run through them all
  446. voice_loop:
  447. ;ifdef debug_42
  448. ; push eax
  449. ; call fn_printf
  450. ; pop eax
  451. ;endif
  452. push eax
  453. bts [system_flags],sf_speech_file ;enable a load fail
  454. clear edx
  455. call load_file
  456. btr [system_flags],sf_speech_file
  457. jife eax,sp_file_missing ;if eax = 0 then no file
  458. pop ebx
  459. push ebx
  460. printf "playing %d",ebx
  461. movzx ecx,(s ptr[eax]).s_tot_size
  462. push eax
  463. push ecx
  464. push 0
  465. call _play_voc_data__Npcii
  466. bts [system_flags],sf_voc_playing
  467. call wait_50hz
  468. call wait_50hz
  469. call wait_50hz
  470. call wait_50hz
  471. call wait_50hz
  472. call wait_50hz
  473. call wait_50hz
  474. call wait_50hz
  475. voc_wait: mov al,-1
  476. call voc_progress_report2
  477. call check_keyboard
  478. call debug_loop
  479. bt [system_flags],sf_voc_playing
  480. jc voc_wait
  481. zz: test [mouse_b],-1
  482. je zz
  483. call wait_mouse_not_pressed
  484. sp_file_missing: pop eax
  485. inc eax
  486. cmp eax,60000
  487. jc voice_loop
  488. no_test: ret
  489. test_voices endp
  490. end32code
  491. end
  492.