Advertisement
lui_

timer.asm

Aug 9th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. norom
  2.  
  3. macro org(bank, offset)
  4. org $10+((<offset>-$8000)%$2000)+($2000*<bank>)
  5. base <offset>
  6. endmacro
  7.  
  8. !dropped_count_pos = $22
  9.  
  10. counter_60hz = $11
  11. previous_60hz = $1F
  12.  
  13. dropped_frames = $0500
  14. real_frames_elapsed = $0501
  15. timer_frames = $0502
  16. timer_seconds = $0503
  17. timer_minutes = $0504
  18.  
  19. sb_score = $7F4A
  20.  
  21. ; $0300-$036B
  22. gfx_buffer_index = $0300
  23. gfx_buffer = $0301
  24.  
  25.  
  26.  
  27. ; increase 60Hz counter every frame from NMI
  28. %org(31, $F57E)
  29. JSR nmi_hijack
  30.  
  31. %org(31, $E911)
  32. nmi_hijack:
  33. INC counter_60hz
  34. JMP $FC6F
  35.  
  36. ; dont get cards hmm
  37. ; %org(31, $FD44)
  38. ; PHA
  39.  
  40. ; %org(30, $8DD8)
  41. ; JSR $96E5
  42.  
  43.  
  44. %org(30, $9701)
  45. JSR every_frame
  46.  
  47. %org(30, $9FB6)
  48. every_frame:
  49. STA $1C
  50. CLI
  51.  
  52. LDA counter_60hz
  53. SEC
  54. SBC previous_60hz
  55. TAY
  56. LDA $65
  57. ORA $66
  58. BEQ .not_level
  59. LDX $0376
  60. BNE .paused
  61. TYA
  62. CLC
  63. ADC real_frames_elapsed
  64. STA real_frames_elapsed
  65. .paused:
  66. TYA
  67. SEC
  68. SBC #$01
  69. CLC
  70. ADC dropped_frames
  71. STA dropped_frames
  72. .not_level:
  73. LDA counter_60hz
  74. STA previous_60hz
  75. RTS
  76.  
  77.  
  78. warnpc $A000
  79.  
  80.  
  81.  
  82. %org(26, $B073)
  83. coins:
  84. LDY #$00
  85. LDA $7967
  86. CMP #100
  87. BCC +
  88. SBC #100
  89. STA $7967
  90. JMP $B094
  91.  
  92. +
  93. JMP $B09F
  94.  
  95.  
  96.  
  97.  
  98. ; %org(30, $897D)
  99. ; STA $7CF2
  100. ; JSR level_transition
  101.  
  102.  
  103.  
  104. ; status bar template
  105. org $35438
  106. db $2B, $28
  107. db $0C, $EF, $EF, $EF, $EF, $EF, $EF, $AE, $AF, $FE, $EC, $F0, $F0
  108. db $2B, $45
  109. db $0F, $FE, $F0, $FE, $F0, $F0, $F0, $F0, $F0, $F0, $FE, $FE, $ED, $F0, $F0, $F0
  110. db $00
  111.  
  112.  
  113.  
  114. %org(26, $B175)
  115. score:
  116. LDA $65
  117. ORA $66
  118. BNE .level
  119. LDA #$ED
  120. STA sb_score
  121. RTS
  122.  
  123. .level:
  124. LDA $07BD
  125. BEQ .tick_timer
  126. LDA #$ED
  127. STA sb_score
  128. JMP .display_stuff
  129.  
  130. .tick_timer:
  131. LDA timer_frames
  132. CLC
  133. ADC real_frames_elapsed
  134. STA timer_frames
  135. CMP #60
  136. BCC .done
  137.  
  138. SBC #60
  139. STA timer_frames
  140. LDA timer_seconds
  141. ADC #$00
  142. STA timer_seconds
  143. CMP #60
  144. BCC .done
  145.  
  146. SBC #60
  147. STA timer_seconds
  148. LDA timer_minutes
  149. ADC #$00
  150. CMP #10
  151. BCC .no_cap
  152. LDA #59
  153. STA timer_frames
  154. LDA #59
  155. STA timer_seconds
  156. LDA #09
  157. .no_cap:
  158. STA timer_minutes
  159.  
  160. .done:
  161. LDX #$ED
  162. LDA timer_frames
  163. CMP #30
  164. BCC +
  165. LDX #$FE
  166. +
  167. STX sb_score
  168.  
  169. .display_stuff:
  170. LDA #$00
  171. STA real_frames_elapsed
  172.  
  173. LDA timer_minutes
  174. ORA #$F0
  175. STA sb_score+1
  176. LDA timer_seconds
  177. LDY #$02
  178. JSR draw_dec_to_score
  179. LDY #$04
  180. LDA timer_frames
  181. JSR draw_dec_to_score
  182.  
  183.  
  184. JMP draw_dropped_frames
  185.  
  186. draw_dec_to_score:
  187. LDX #$F0
  188. -
  189. CMP #10
  190. BCC +
  191. SBC #10
  192. INX
  193. BCS -
  194. +
  195. ORA #$F0
  196. STA sb_score+1,y
  197. TXA
  198. STA sb_score,y
  199. RTS
  200.  
  201.  
  202. warnpc $B24A
  203.  
  204. ; empty
  205. %org(26, $B520)
  206. ; draw dropped frames in hex
  207. draw_dropped_frames:
  208. LDY gfx_buffer_index
  209. LDA dropped_frames
  210. PHA
  211. LSR
  212. LSR
  213. LSR
  214. LSR
  215. CMP #$0A ; adjust tile # for A-F digits
  216. BCC +
  217. SBC #$6A
  218. +
  219. CLC
  220. ADC #$F0
  221. STA gfx_buffer+3,y
  222.  
  223. PLA
  224. AND #$0F
  225. CMP #$0A
  226. BCC +
  227. SBC #$6A
  228. +
  229. CLC
  230. ADC #$F0
  231. STA gfx_buffer+4,y
  232.  
  233. ; block terminator
  234. LDA #$00
  235. STA gfx_buffer+5,y
  236.  
  237. ; copypasta
  238. LDX #$27
  239. LDA $03EF ; vertical level
  240. BNE ++
  241. LDX #$2B
  242. LDA $070A ; level tileset
  243. CMP #16
  244. BEQ +
  245. CMP #17
  246. BNE ++
  247. +
  248. LDX #$23
  249. ++
  250. TXA
  251. ; vram hi
  252. STA gfx_buffer,y
  253. ; vram lo
  254. LDA #!dropped_count_pos
  255. STA gfx_buffer+1,y
  256. ; block size
  257. LDA #$02
  258. STA gfx_buffer+2,y
  259. ; update index
  260. LDA gfx_buffer_index
  261. CLC
  262. ADC #$05
  263. STA gfx_buffer_index
  264. RTS
  265.  
  266.  
  267.  
  268. ; level_transition:
  269. ; STA $7CF2
  270. ; STA dropped_frames
  271. ; RTS
  272.  
  273.  
  274.  
  275. warnpc $C000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement