Debug.asm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. include_macros equ 1
  2. include_deb_mac equ 1
  3. include_flags equ 1
  4. include_error_codes equ 1
  5. include include.asm
  6. start32data
  7. ifdef debug_42
  8. show_debug_vars dd 1
  9. else
  10. show_debug_vars dd 0
  11. endif
  12. no_chars equ 11
  13. c_text_no dd 0 ;current speech number
  14. status_buffer db game_screen_width*5 dup (?)
  15. align 4
  16. status_ch_set dd 0
  17. end32data
  18. do_stat macro var,pos
  19. mov eax,var
  20. mov ebx,pos
  21. call status_int
  22. endm
  23. start32code
  24. debug_loop proc
  25. test [show_debug_vars],-1
  26. je dl_ret
  27. do_stat [game_cycle],0
  28. ifdef with_replay
  29. do_stat [db_next_cycle],7
  30. endif
  31. do_stat [screen],14
  32. do_stat [c_text_no],21
  33. do_stat [voc_progress],28
  34. ifdef debug_42
  35. do_stat [tseq_frames],40
  36. ;do_stat [replay_data_ptr],47
  37. ;do_stat [door_77_78_flag],54
  38. endif
  39. push es
  40. mov es,[screen_segment]
  41. mov esi,offset status_buffer
  42. mov edi,game_screen_width * game_screen_height
  43. mov ecx,game_screen_width*5
  44. rep movsb
  45. pop es
  46. dl_ret: ret
  47. debug_loop endp
  48. status_char proc
  49. ; print char al at position ebx
  50. test [status_ch_set],-1
  51. jne got_set
  52. push eax
  53. push ebx
  54. mov eax,60152
  55. clear edx
  56. call load_file
  57. mov [status_ch_set],eax
  58. pop ebx
  59. pop eax
  60. got_set: cmp al,' '
  61. je space
  62. sub al,'0'
  63. jmp do_ch
  64. space: mov al,10
  65. jmp do_ch
  66. do_ch: movzx eax,al
  67. imul eax,3
  68. mov esi,eax
  69. add esi,[status_ch_set]
  70. mov edi,ebx
  71. imul edi,4
  72. add edi,offset status_buffer
  73. mov edx,5
  74. clear eax
  75. line_loop: mov ecx,3
  76. rep movsb
  77. stosb
  78. add esi,no_chars*3 - 3
  79. add edi,game_screen_width-4
  80. floop edx,line_loop
  81. ret
  82. status_char endp
  83. status_int proc
  84. ; print eax at ebx
  85. cmp eax,1000000
  86. jc not_max
  87. mov eax,999999
  88. not_max: clear ebp
  89. jife eax,zero
  90. call do_char
  91. jmp all_done
  92. zero: mov al,'0'
  93. call status_char
  94. inc ebx
  95. inc ebp
  96. all_done: ;pad out to 5 wide
  97. mov al,' '
  98. call status_char
  99. inc ebp
  100. cmp ebp,5
  101. jc all_done
  102. jmp si_ret
  103. do_char: mov ecx,10
  104. clear edx
  105. idiv ecx
  106. push edx
  107. jife eax,done
  108. call do_char
  109. done: pop eax
  110. add al,'0'
  111. call status_char
  112. inc ebx
  113. inc ebp
  114. si_ret: ret
  115. status_int endp
  116. ifdef debug_42
  117. proc_start _fetch_item_section__Ni
  118. fi_sect equ 8
  119. ; fetch the address of a section item list
  120. mov eax,fi_sect[ebp]
  121. shl eax,2
  122. mov eax,[eax+offset item_list+section_0_item*4]
  123. proc_end _fetch_item_section__Ni,4
  124. flip_grid proc
  125. ; Display a ton of stuff depending on the grids
  126. bt [_debug_flag],df_grid
  127. jnc no_grid
  128. mov ebx,[screen] ;get current screen
  129. mov bl,bpt [offset grid_convert_table+ebx]
  130. cherror bl,nc,tot_no_grids,em_internal_error
  131. imul ebx,ebx,grid_size
  132. add ebx,[game_grids] ;pointer to grid start
  133. mov edx,31 ;start bit
  134. mov esi,[game_grid]
  135. mov edi,[backscreen]
  136. add edi,(GRID_H-1)*full_screen_width
  137. mov ch,GRID_Y ;screen height
  138. y_loop: push edi
  139. mov cl,GRID_X ;screen width
  140. x_loop: push ecx
  141. ;first check two walk grid bits
  142. bt [ebx],edx
  143. jnc no_grid1
  144. mov eax,0ffffffffh
  145. stosd
  146. mov eax,0ffffffh
  147. stosd
  148. sub edi,8
  149. or bpt[esi],81h
  150. no_grid1: add edi,8
  151. dec edx
  152. bt [ebx],edx
  153. jnc no_grid2
  154. mov eax,0ffffffffh
  155. stosd
  156. mov eax,0ffffffh
  157. stosd
  158. sub edi,8
  159. or bpt[esi],81h
  160. no_grid2: add edi,8
  161. dec edx
  162. jns no_new_byte
  163. add ebx,4
  164. mov edx,31
  165. no_new_byte: inc esi
  166. pop ecx
  167. floop cl,x_loop
  168. pop edi
  169. add edi,GRID_H*full_screen_width
  170. floop ch,y_loop
  171. ;--------------------------------------------------------------------------------------------------
  172. no_grid: ret
  173. flip_grid endp
  174. proc_start _mgetch__Nv
  175. waitk: call fetch_key
  176. je waitk
  177. proc_end _mgetch__Nv
  178. endif ;debug_42
  179. end32code
  180. end
  181.