Advertisement
galaspark

demo.txt

Mar 6th, 2021
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 459.42 KB | None | 0 0
  1. .include Routines\BASE_4_5\\Game\Subroutines\TimerEndScripts.asm
  2. 09260 ;;; 00 = Loop
  3. 09260 end_loop_action:
  4. 09260
  5. 09260 60 RTS
  6. 09261 ;;; 01 = Advance
  7. 09261 advance_action:
  8. 09261 BD 9C 04 LDA Object_frame,x
  9. 09264 4A LSR
  10. 09265 4A LSR
  11. 09266 4A LSR
  12. 09267 29 07 AND #%00000111
  13. 09269 18 CLC
  14. 0926A 69 01 ADC #$01
  15. 0926C 29 07 AND #%00000111
  16. 0926E 85 08 STA tempB
  17. 09270 ;STA tempD ;; the action frame that was assigned during create macro.
  18. 09270 ;;;; object behavior tables are with the lut table.
  19. 09270 ;;;; the lut table is in bank 1C.
  20. 09270 ; SwitchBank #$1C
  21. 09270 ; ;;; Then, get the behavior for that object on that frame number.
  22. 09270 ; LDY Object_type,x
  23. 09270 ; LDA ObjectBehaviorTableLo,y
  24. 09270 ; STA pointer
  25. 09270 ; LDA ObjectBehaviorTableHi,y
  26. 09270 ; STA pointer+1
  27. 09270 ; LDY tempD
  28. 09270 ; LDA (pointer),y
  29. 09270 ; AND #%00001111
  30. 09270 ; STA tempB
  31. 09270 ; ReturnBank
  32. 09270 A5 08 LDA tempB
  33. 09272 0A ASL
  34. 09273 0A ASL
  35. 09274 0A ASL
  36. 09275 85 09 STA tempC
  37. 09277 BD 9C 04 LDA Object_frame,x
  38. 0927A 29 C7 AND #%11000111
  39. 0927C 05 09 ORA tempC
  40. 0927E 9D 9C 04 STA Object_frame,x
  41. 09281
  42. 09281 8A TXA
  43. 09282 85 07 STA tempA
  44. 09284
  45. 09284 8A 48 A5 07 85 0C A5 08.. DoObjectAction tempA, tempB
  46. 092AC ; ;arg0 = what object?
  47. 092AC ;arg1 = what step behavior?
  48. 092AC 60 RTS
  49. 092AD ;;; 02 = Repeat
  50. 092AD repeat_action:
  51. 092AD BD 9C 04 LDA Object_frame,x
  52. 092B0 4A LSR
  53. 092B1 4A LSR
  54. 092B2 4A LSR
  55. 092B3 29 07 AND #%00000111
  56. 092B5 85 08 STA tempB
  57. 092B7
  58. 092B7 8A TXA
  59. 092B8 85 07 STA tempA
  60. 092BA
  61. 092BA 8A 48 A5 07 85 0C A5 08.. DoObjectAction tempA, tempB
  62. 092E2 ; ;arg0 = what object?
  63. 092E2 ;arg1 = what step behavior?
  64. 092E2 60 RTS
  65. 092E3 ;;; 03 = Go To First
  66. 092E3 goToFirst_action:
  67. 092E3
  68. 092E3 A9 00 LDA #$00
  69. 092E5 85 08 STA tempB
  70. 092E7 ;;;; HURT END
  71. 092E7 BD 9C 04 LDA Object_frame,x
  72. 092EA 29 38 AND #%00111000
  73. 092EC C9 38 CMP #%00111000
  74. 092EE D0 16 BNE +notHurtFrame
  75. 092F0 A9 00 LDA #$00
  76. 092F2 9D 5B 04 STA Object_h_speed_hi,x
  77. 092F5 9D 4E 04 STA Object_h_speed_lo,x
  78. 092F8 9D 75 04 STA Object_v_speed_hi,x
  79. 092FB 9D 68 04 STA Object_v_speed_lo,x
  80. 092FE BD A9 04 LDA Object_direction,x
  81. 09301 29 0F AND #%00001111
  82. 09303 9D A9 04 STA Object_direction,x
  83. 09306 ;;;;;;;;;;;;;;;;;;;;
  84. 09306 +notHurtFrame
  85. 09306
  86. 09306 BD 9C 04 LDA Object_frame,x
  87. 09309 29 C7 AND #%11000111
  88. 0930B 9D 9C 04 STA Object_frame,x
  89. 0930E
  90. 0930E
  91. 0930E 8A TXA
  92. 0930F 85 07 STA tempA
  93. 09311
  94. 09311 8A 48 A5 07 85 0C A5 08.. DoObjectAction tempA, tempB
  95. 09339 ; ;arg0 = what object?
  96. 09339 ;arg1 = what step behavior?
  97. 09339 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  98. 09339 ;; turn off move towards point if current action is 7.
  99. 09339 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  100. 09339 60 RTS
  101. 0933A ;;; 04 = Go To Last
  102. 0933A goToLast_action:
  103. 0933A A9 07 LDA #$07
  104. 0933C 85 08 STA tempB
  105. 0933E
  106. 0933E
  107. 0933E BD 9C 04 LDA Object_frame,x
  108. 09341 09 38 ora #%00111000
  109. 09343 9D 9C 04 STA Object_frame,x
  110. 09346
  111. 09346 8A TXA
  112. 09347 85 07 STA tempA
  113. 09349
  114. 09349 8A 48 A5 07 85 0C A5 08.. DoObjectAction tempA, tempB
  115. 09371 ; ;arg0 = what object?
  116. 09371 ;arg1 = what step behavior?
  117. 09371 60 RTS
  118. 09372 ;;; 05 = Go To Previous
  119. 09372 goToPrev_action:
  120. 09372 BD 9C 04 LDA Object_frame,x
  121. 09375 BD 9C 04 LDA Object_frame,x
  122. 09378 4A LSR
  123. 09379 4A LSR
  124. 0937A 4A LSR
  125. 0937B 29 07 AND #%00000111
  126. 0937D 38 SEC
  127. 0937E E9 01 SBC #$01
  128. 09380 29 07 AND #%00000111
  129. 09382 85 08 STA tempB ;; the action frame that was assigned during create macro.
  130. 09384 ;;;; object behavior tables are with the lut table.
  131. 09384 ;;;; the lut table is in bank 1C.
  132. 09384 0A ASL
  133. 09385 0A ASL
  134. 09386 0A ASL
  135. 09387 85 09 STA tempC
  136. 09389 BD 9C 04 LDA Object_frame,x
  137. 0938C 29 C7 AND #%11000111
  138. 0938E 05 09 ORA tempC
  139. 09390 9D 9C 04 STA Object_frame,x
  140. 09393
  141. 09393 8A TXA
  142. 09394 85 07 STA tempA
  143. 09396
  144. 09396 8A 48 A5 07 85 0C A5 08.. DoObjectAction tempA, tempB
  145. 093BE ; ;arg0 = what object?
  146. 093BE ;arg1 = what step behavior?
  147. 093BE 60 RTS
  148. 093BF ;;; 06 = Destroy Me
  149. 093BF destroyMe_action:
  150. 093BF BD 00 04 29 3F 9D 00 04 DestroyObject
  151. 093C7 60 RTS
  152. 093C8 ;;; 07 = Go To Warp
  153. 093C8 goToWarp_action:
  154. 093C8 AD C8 06 8D A4 06 AD A3.. WarpToScreen warpToMap, warpToScreen, #$01
  155. 09407 60 RTS
  156. 09408 ;;; 08 = Show Message (1)
  157. 09408 show_message_action
  158. 09408
  159. 09408 60 RTS
  160. 09409 ;;; 09 = Go To Continue
  161. 09409 goToContinue_action:
  162. 09409 AD D5 06 LDA continueMap
  163. 0940C 8D A4 06 STA warpMap
  164. 0940F
  165. 0940F AD D2 06 LDA continueScreen
  166. 09412 8D 74 06 STA currentNametable
  167. 09415
  168. 09415 AE 6D 06 LDX player1_object
  169. 09418 9D 27 04 STA Object_screen,x
  170. 0941B
  171. 0941B A9 02 LDA #$02 ;; this is continue type warp.
  172. 0941D 8D A5 06 STA screenTransitionType ;; is of warp type
  173. 09420
  174. 09420
  175. 09420 AD AB 06 LDA gameHandler
  176. 09423 09 80 ORA #%10000000
  177. 09425 8D AB 06 STA gameHandler ;; this will set the next game loop to update the screen.
  178. 09428 8A 48 AD 6D 06 85 0C A9.. ChangeActionStep player1_object, #$00
  179. 09438 AE 6D 06 LDX player1_object
  180. 0943B A9 00 LDA #$00000000
  181. 0943D 9D A9 04 STA Object_direction,x
  182. 09440 60 RTS
  183. 09441 ;;; 10 = Restart Screen
  184. 09441 restartScreen_action:
  185. 09441 A9 02 LDA #$02
  186. 09443 8D A5 06 STA screenTransitionType
  187. 09446 AD AB 06 LDA gameHandler
  188. 09449 09 80 ORA #%10000000
  189. 0944B 8D AB 06 STA gameHandler ;; this will set the next game loop to update the screen.
  190. 0944E 8A 48 AD 6D 06 85 0C A9.. ChangeActionStep player1_object, #$00
  191. 0945E AE 6D 06 LDX player1_object
  192. 09461 A9 00 LDA #$00000000
  193. 09463 9D A9 04 STA Object_direction,x
  194. 09466 60 RTS
  195. 09467 ;;; 11 = Restart Game
  196. 09467 restartGame_action:
  197. 09467 4C 00 C0 JMP RESET
  198. 0946A 60 RTS
  199. 0946B ;;; 12 = User 0
  200. 0946B userEnd0_action:
  201. 0946B 60 RTS
  202. 0946C ;;; 13 = User 1
  203. 0946C userEnd1_action:
  204. 0946C 60 RTS
  205. 0946D
  206. 0946D
  207. 0946D EndAnimAndActions_Lo:
  208. 0946D 60 61 AD E3 3A 72 BF C8 .db #<end_loop_action, #<advance_action, #<repeat_action, #<goToFirst_action, #<goToLast_action, #<goToPrev_action, #<destroyMe_action, #<goToWarp_action
  209. 09475 08 09 41 67 6B 6C .db #<show_message_action, #<goToContinue_action, #<restartScreen_action, #<restartGame_action, #<userEnd0_action, #<userEnd1_action
  210. 0947B
  211. 0947B EndAnimAndActions_Hi:
  212. 0947B 92 92 92 92 93 93 93 93 .db #>end_loop_action, #>advance_action, #>repeat_action, #>goToFirst_action, #>goToLast_action, #>goToPrev_action, #>destroyMe_action, #>goToWarp_action
  213. 09483 94 94 94 94 94 94 .db #>show_message_action, #>goToContinue_action, #>restartScreen_action, #>restartGame_action, #>userEnd0_action, #>userEnd1_action
  214. 09489
  215. 09489
  216. 09489 .include Routines\BASE_4_5\\Game\Subroutines\doObjectAction.asm
  217. 09489 doObjectAction:
  218. 09489 8A TXA
  219. 0948A 48 PHA
  220. 0948B 98 TYA
  221. 0948C 48 PHA
  222. 0948D ;arg0 = what object?
  223. 0948D ;arg1 = what step behavior?
  224. 0948D A6 0C LDX arg0_hold
  225. 0948F ;SwitchBank #$1C
  226. 0948F
  227. 0948F
  228. 0948F BC 8F 04 LDY Object_type,x
  229. 09492 B9 D0 81 LDA ObjectBehaviorTableLo,y
  230. 09495 85 14 STA temp16
  231. 09497 B9 10 83 LDA ObjectBehaviorTableHi,y
  232. 0949A 85 15 STA temp16+1
  233. 0949C A4 0D LDY arg1_hold
  234. 0949E B1 14 LDA (temp16),y
  235. 094A0
  236. 094A0 ;;; this now holds the action type id and the action timer.
  237. 094A0 ;;; xxxxxyyy: x=action timer, y=action type, 0-7.
  238. 094A0 85 00 STA temp
  239. 094A2 29 0F AND #%00001111
  240. 094A4 85 07 STA tempA ;; use this to "do" the action.
  241. 094A6
  242. 094A6
  243. 094A6 A5 00 LDA temp
  244. 094A8 ;;; RIGHT HERE, assing the timer.
  245. 094A8 4A LSR
  246. 094A9 4A LSR
  247. 094AA 4A LSR
  248. 094AB 4A LSR
  249. 094AC D0 09 BNE notZeroForActionTimer ;;
  250. 094AE ;; set to a random number if zero
  251. 094AE 20 DD DD JSR doGetRandomNumber
  252. 094B1 29 3F AND #%00111111 ; 0-127 for a timer.
  253. 094B3 0A ASL
  254. 094B4 4C BB 94 JMP gotNewActionTimer
  255. 094B7 notZeroForActionTimer:
  256. 094B7 0A ASL
  257. 094B8 0A ASL
  258. 094B9 0A ASL
  259. 094BA 0A ASL
  260. 094BB gotNewActionTimer:
  261. 094BB 9D C3 04 STA Object_action_timer,x
  262. 094BE
  263. 094BE ;;;;;;;;;;;;;;;;;;;;;;;
  264. 094BE ;;; RESET ANIMATION TIMER
  265. 094BE ;;;;;;;;;;;;;;;;;;;;;;;;;
  266. 094BE BC 8F 04 LDY Object_type,x
  267. 094C1 B9 80 81 LDA ObjectAnimationSpeedTableLo,y
  268. 094C4 85 14 STA temp16
  269. 094C6 B9 C0 82 LDA ObjectAnimationSpeedTableHi,y
  270. 094C9 85 15 STA temp16+1
  271. 094CB
  272. 094CB BD 9C 04 LDA Object_frame,x
  273. 094CE 4A LSR
  274. 094CF 4A LSR
  275. 094D0 4A LSR
  276. 094D1 29 07 AND #%00000111
  277. 094D3 A8 TAY
  278. 094D4
  279. 094D4 B1 14 LDA (temp16),y ;; this now points to the proper spot on the anim speed table.
  280. 094D6 ;; we need to capture that number.
  281. 094D6 ;; Its high nibble is the "animation type"
  282. 094D6 29 0F AND #%00001111
  283. 094D8 ;; Now we have a value 0-16.
  284. 094D8 ;; This correlates to animation speed, but it probably shouldn't be a one-to-one comparision.
  285. 094D8 0A ASL
  286. 094D9 0A ASL
  287. 094DA 9D B6 04 STA Object_animation_timer,x
  288. 094DD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  289. 094DD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  290. 094DD
  291. 094DD BD 9C 04 LDA Object_frame,x
  292. 094E0 29 F8 AND #%11111000
  293. 094E2 9D 9C 04 STA Object_frame,x ;; reset animation frame.
  294. 094E5
  295. 094E5
  296. 094E5 A4 07 LDY tempA
  297. 094E7
  298. 094E7 B9 29 FB LDA AI_table_lo,y
  299. 094EA 85 14 STA temp16
  300. 094EC B9 39 FB LDA AI_table_hi,y
  301. 094EF 85 15 STA temp16+1
  302. 094F1
  303. 094F1 20 F7 94 JSR doObjectActionTrampoline
  304. 094F4 4C FA 94 JMP pastObjectActionTrampoline
  305. 094F7 doObjectActionTrampoline:
  306. 094F7 6C 14 00 JMP (temp16)
  307. 094FA ; ;;; make sure that the behavior ends in an RTS, and then it will
  308. 094FA ; ;;; slide right back to this part of the code.
  309. 094FA pastObjectActionTrampoline:
  310. 094FA ;;; Set this step's vulnerabilities.
  311. 094FA BC 8F 04 LDY Object_type,x
  312. 094FD B9 70 82 LDA VulnerabilityTableLo,y
  313. 09500 85 14 STA temp16
  314. 09502 B9 B0 83 LDA VulnerabilityTableHi,y
  315. 09505 85 15 STA temp16+1
  316. 09507 BD 9C 04 LDA Object_frame,x
  317. 0950A 4A LSR
  318. 0950B 4A LSR
  319. 0950C 4A LSR
  320. 0950D 29 07 AND #%00000111
  321. 0950F A8 TAY
  322. 09510 B1 14 LDA (temp16),y
  323. 09512 9D EA 04 STA Object_vulnerability,x
  324. 09515
  325. 09515
  326. 09515 ;ReturnBank
  327. 09515 68 PLA
  328. 09516 A8 TAY
  329. 09517 68 PLA
  330. 09518 AA TAX
  331. 09519 60 RTS0951A ;========================================================
  332. 0951A
  333. 0951A .include "Routines\BASE_4_5\Game\Subroutines\doCompareBoundingBoxes_multiScreen.asm"
  334. 0951A ;;;
  335. 0951A doCompareBoundingBoxes:
  336. 0951A ;;; more complicated than this
  337. 0951A ; LDA self_screen
  338. 0951A ; CMP other_screen
  339. 0951A ; BNE noBboxCollision
  340. 0951A
  341. 0951A
  342. 0951A ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Here we will check the horizontal collision.
  343. 0951A ;;; First we need to check the RIGHT SCREEN + RIGHT BBOX of self against the
  344. 0951A ;;; LEFT SCREEN + LEFT BBOX of other. If it is less, then there is no collision.
  345. 0951A
  346. 0951A AD DC 06 LDA self_screen_right
  347. 0951D CD DD 06 CMP other_screen_left
  348. 09520 F0 03 BEQ +theseAreEqual
  349. 09522 ;;; the self screen and other screen are not equal.
  350. 09522 ;;; But if the self screen is MORE than the other screen,
  351. 09522 ;;; it is still possible that this could return a collision.
  352. 09522 4C 40 95 JMP +checkOtherSide
  353. 09525
  354. 09525 +theseAreEqual
  355. 09525 ;;; we need to check the *other* side
  356. 09525 AD DB 06 LDA self_screen_left
  357. 09528 CD DE 06 CMP other_screen_right
  358. 0952B F0 0B BEQ +normalBoundsCheck
  359. 0952D ;; this means bounds are being straddled.
  360. 0952D AD 70 06 LDA bounds_right
  361. 09530 CD 60 06 CMP other_left
  362. 09533 90 39 BCC +noBboxCollision
  363. 09535 4C 5B 95 JMP +hCol
  364. 09538 +normalBoundsCheck
  365. 09538
  366. 09538 ;; the self screen and other screen are equal
  367. 09538 ;; which means now it is a matter of checking the
  368. 09538 ;; self right bbox against the left bbox.
  369. 09538 AD 70 06 LDA bounds_right
  370. 0953B CD 60 06 CMP other_left
  371. 0953E 90 2E BCC +noBboxCollision
  372. 09540
  373. 09540
  374. 09540 +continueCollisionCheck
  375. 09540 +checkOtherSide
  376. 09540 AD DB 06 LDA self_screen_left
  377. 09543 CD DE 06 CMP other_screen_right
  378. 09546 F0 03 BEQ +theseAreEqual
  379. 09548 4C 6E 95 JMP +noBboxCollision
  380. 0954B +theseAreEqual
  381. 0954B ;;; check the *other* side
  382. 0954B AD DC 06 LDA self_screen_right
  383. 0954E CD DD 06 CMP other_screen_left
  384. 09551 F0 00 BEQ +normalBoundsCheck
  385. 09553
  386. 09553 +normalBoundsCheck
  387. 09553 AD 6F 06 LDA bounds_left
  388. 09556 CD 62 06 CMP other_right
  389. 09559 B0 13 BCS +noBboxCollision
  390. 0955B
  391. 0955B +hCol
  392. 0955B
  393. 0955B AD 63 06 LDA other_bottom
  394. 0955E CD 71 06 CMP bounds_top
  395. 09561 90 0B BCC noBboxCollision
  396. 09563 AD 72 06 LDA bounds_bottom
  397. 09566 CD 61 06 CMP other_top
  398. 09569 90 03 BCC noBboxCollision
  399. 0956B ;;;;;;;;;;;;;;;;;;
  400. 0956B
  401. 0956B ;;;;;;;;;;;;;;;;;;
  402. 0956B
  403. 0956B
  404. 0956B
  405. 0956B A9 01 LDA #$01 ;; read that YES, there was a collision here. (could make this the object ID)
  406. 0956D 60 RTS
  407. 0956E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  408. 0956E noBboxCollision;; there is no collision here horizontally.
  409. 0956E A9 00 LDA #$00 ;; read that NO, there was no collision.
  410. 09570 60 RTS
  411. 09571
  412. 09571
  413. 09571 getOtherColBox:
  414. 09571 98 TYA
  415. 09572 48 PHA
  416. 09573
  417. 09573 ; LDA Object_x_hi,x
  418. 09573 ; CLC
  419. 09573 ; ADC #$10
  420. 09573 ; LDA Object_screen,x
  421. 09573 ; ADC #$00
  422. 09573 ; STA other_screen_right
  423. 09573 BC 8F 04 LDY Object_type,x
  424. 09576
  425. 09576 BD 1A 04 LDA Object_x_hi,x
  426. 09579 18 CLC
  427. 0957A 79 A0 8E ADC ObjectBboxLeft,y
  428. 0957D 8D 60 06 STA other_left
  429. 09580 BD 27 04 LDA Object_screen,x
  430. 09583 69 00 ADC #$00
  431. 09585 8D DD 06 STA other_screen_left
  432. 09588
  433. 09588 AD 60 06 LDA other_left
  434. 0958B 18 CLC
  435. 0958C 79 F0 8E ADC ObjectWidth,y
  436. 0958F 8D 62 06 STA other_right
  437. 09592 BD 27 04 LDA Object_screen,x
  438. 09595 69 00 ADC #$00
  439. 09597 8D DE 06 STA other_screen_right
  440. 0959A
  441. 0959A
  442. 0959A AD 62 06 LDA other_right
  443. 0959D
  444. 0959D 38 SEC
  445. 0959E ED 60 06 SBC other_left
  446. 095A1 4A LSR
  447. 095A2 8D 64 06 STA other_center_x
  448. 095A5
  449. 095A5 B9 40 8F LDA ObjectBboxTop,y
  450. 095A8 18 CLC
  451. 095A9 7D 41 04 ADC Object_y_hi,x
  452. 095AC 8D 61 06 STA other_top
  453. 095AF 18 CLC
  454. 095B0 79 90 8F ADC ObjectHeight,y
  455. 095B3 8D 63 06 STA other_bottom
  456. 095B6 38 SEC
  457. 095B7 ED 61 06 SBC other_top
  458. 095BA 4A LSR
  459. 095BB 8D 65 06 STA other_center_y ;; self center in the vertical direction.
  460. 095BE ; LDA Object_screen,x
  461. 095BE ; STA other_screen
  462. 095BE
  463. 095BE 68 PLA
  464. 095BF A8 TAY
  465. 095C0 60 RTS095C1
  466. 095C1 ;; do draw sprites
  467. 095C1 doDrawSprites:
  468. 095C1 .include "Routines\BASE_4_5\Game\Space Birds\Subroutines\doDrawSprites_ShooterBase -RTS Trick.asm"
  469. 095C1 ;; sprite drawing routine.
  470. 095C1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  471. 095C1 ;;; For horizontal scrolling games, extra attention has to be taken to draw
  472. 095C1 ;;; sprites off screen if they are no longer in the camera render area.
  473. 095C1
  474. 095C1 AD AB 06 LDA gameHandler
  475. 095C4 29 40 AND #%01000000
  476. 095C6 F0 03 BEQ +checkScreenFlags
  477. 095C8 4C 32 99 JMP doneDrawingThisSprite
  478. 095CB
  479. 095CB +checkScreenFlags
  480. 095CB
  481. 095CB AD 9F 06 LDA ScreenFlags00
  482. 095CE 29 80 AND #%10000000
  483. 095D0 F0 03 BEQ doDrawThisSprite
  484. 095D2 4C 32 99 JMP doneDrawingThisSprite
  485. 095D5 doDrawThisSprite:
  486. 095D5 ;;;; loaded into x is the object calling this routine.
  487. 095D5
  488. 095D5 BD 00 04 LDA Object_status,x
  489. 095D8 29 80 AND #OBJECT_IS_ACTIVE
  490. 095DA D0 03 BNE +ObjectIsActiveSoDrawIt
  491. 095DC 4C 32 99 JMP doneDrawingThisSprite
  492. 095DF
  493. 095DF +ObjectIsActiveSoDrawIt
  494. 095DF BD 1A 04 LDA Object_x_hi,x
  495. 095E2 38 SEC
  496. 095E3 ED 85 06 SBC camX
  497. 095E6 85 07 STA tempA
  498. 095E8
  499. 095E8 BD 41 04 LDA Object_y_hi,x
  500. 095EB 85 08 STA tempB
  501. 095ED
  502. 095ED BD 8F 04 LDA Object_type,x
  503. 095F0 0A ASL
  504. 095F1 AA TAX
  505. 095F2
  506. 095F2 DrawSprite_opcode_launcher:
  507. 095F2 BD 4E D9 LDA DrawSprite_opcode_table+1,x
  508. 095F5 48 PHA
  509. 095F6 BD 4D D9 LDA DrawSprite_opcode_table,x
  510. 095F9 48 PHA
  511. 095FA 60 RTS
  512. 095FB
  513. 095FB DrawPlayer1:
  514. 095FB 98 48 A4 2C A5 08 99 00.. DrawSprite tempA, tempB, #$00, #%00000000
  515. 09620 A5 07 LDA tempA
  516. 09622 18 CLC
  517. 09623 69 08 ADC #$08
  518. 09625 85 01 STA temp1 ;;equals tempA plus 8
  519. 09627 98 48 A4 2C A5 08 99 00.. DrawSprite temp1, tempB, #$01, #%00000000
  520. 0964C A5 08 LDA tempB
  521. 0964E 18 CLC
  522. 0964F 69 08 ADC #$08
  523. 09651 85 02 STA temp2 ;; equals tempB plus 8
  524. 09653 98 48 A4 2C A5 02 99 00.. DrawSprite tempA, temp2, #$10, #%00000000
  525. 09678 98 48 A4 2C A5 02 99 00.. DrawSprite temp1, temp2, #$11, #%00000000
  526. 0969D 60 RTS
  527. 0969E
  528. 0969E DrawPlayer2:
  529. 0969E
  530. 0969E 98 48 A4 2C A5 08 99 00.. DrawSprite tempA, tempB, #$00, #%00000001
  531. 096C3 A5 07 LDA tempA
  532. 096C5 18 CLC
  533. 096C6 69 08 ADC #$08
  534. 096C8 85 01 STA temp1 ;;equals tempA plus 8
  535. 096CA 98 48 A4 2C A5 08 99 00.. DrawSprite temp1, tempB, #$01, #%00000001
  536. 096EF A5 08 LDA tempB
  537. 096F1 18 CLC
  538. 096F2 69 08 ADC #$08
  539. 096F4 85 02 STA temp2 ;; equals tempB plus 8
  540. 096F6 98 48 A4 2C A5 02 99 00.. DrawSprite tempA, temp2, #$10, #%00000001
  541. 0971B 98 48 A4 2C A5 02 99 00.. DrawSprite temp1, temp2, #$11, #%00000001
  542. 09740 60 RTS
  543. 09741
  544. 09741
  545. 09741 DrawMonsterBullet:
  546. 09741 A5 18 LDA vBlankTimer
  547. 09743 29 04 AND #%00000100
  548. 09745 F0 28 BEQ +isEvenFrame
  549. 09747 ;; is Odd Frame
  550. 09747 98 48 A4 2C A5 08 99 00.. DrawSprite tempA, tempB, #$21, #%00000010
  551. 0976C 4C 32 99 JMP doneDrawingThisSprite
  552. 0976F +isEvenFrame
  553. 0976F ;; Draw Alien Weapon, Game Object 2
  554. 0976F 98 48 A4 2C A5 08 99 00.. DrawSprite tempA, tempB, #$20, #%00000010
  555. 09794 60 rts
  556. 09795
  557. 09795 DrawMissile1:
  558. 09795 98 48 A4 2C A5 08 99 00.. DrawSprite tempA, tempB, #$02, #%00000000
  559. 097BA 60 rts
  560. 097BB
  561. 097BB DrawMissile2:
  562. 097BB 98 48 A4 2C A5 08 99 00.. DrawSprite tempA, tempB, #$02, #%00000001
  563. 097E0 60 RTS
  564. 097E1
  565. 097E1 DrawObject5:
  566. 097E1 60 rts
  567. 097E2 DrawObject6:
  568. 097E2 60 rts
  569. 097E3 DrawObject7:
  570. 097E3 60 rts
  571. 097E4 DrawObject8:
  572. 097E4 60 rts
  573. 097E5 DrawObject9:
  574. 097E5 60 rts
  575. 097E6 DrawObjectA:
  576. 097E6 60 rts
  577. 097E7 DrawObjectB:
  578. 097E7 60 rts
  579. 097E8 DrawObjectC:
  580. 097E8 60 rts
  581. 097E9 DrawObjectD:
  582. 097E9 60 rts
  583. 097EA DrawObjectE:
  584. 097EA 60 rts
  585. 097EB DrawObjectF:
  586. 097EB 60 rts
  587. 097EC DrawAlien:
  588. 097EC 98 48 A4 2C A5 08 99 00.. DrawSprite tempA, tempB, #$80, #%00000010
  589. 09811 A5 07 LDA tempA
  590. 09813 18 CLC
  591. 09814 69 08 ADC #$08
  592. 09816 85 01 STA temp1 ;;equals tempA plus 8
  593. 09818 98 48 A4 2C A5 08 99 00.. DrawSprite temp1, tempB, #$81, #%00000010
  594. 0983D A5 08 LDA tempB
  595. 0983F 18 CLC
  596. 09840 69 08 ADC #$08
  597. 09842 85 02 STA temp2 ;; equals tempB plus 8
  598. 09844 98 48 A4 2C A5 02 99 00.. DrawSprite tempA, temp2, #$90, #%00000010
  599. 09869 98 48 A4 2C A5 02 99 00.. DrawSprite temp1, temp2, #$91, #%00000010
  600. 0988E 60 rts
  601. 0988F DrawAlienShooter:
  602. 0988F 98 48 A4 2C A5 08 99 00.. DrawSprite tempA, tempB, #$80, #%00000011
  603. 098B4 A5 07 LDA tempA
  604. 098B6 18 CLC
  605. 098B7 69 08 ADC #$08
  606. 098B9 85 01 STA temp1 ;;equals tempA plus 8
  607. 098BB 98 48 A4 2C A5 08 99 00.. DrawSprite temp1, tempB, #$81, #%00000011
  608. 098E0 A5 08 LDA tempB
  609. 098E2 18 CLC
  610. 098E3 69 08 ADC #$08
  611. 098E5 85 02 STA temp2 ;; equals tempB plus 8
  612. 098E7 98 48 A4 2C A5 02 99 00.. DrawSprite tempA, temp2, #$90, #%00000011
  613. 0990C 98 48 A4 2C A5 02 99 00.. DrawSprite temp1, temp2, #$91, #%00000011
  614. 09931 60 rts
  615. 09932
  616. 09932
  617. 09932 doneDrawingThisSprite:
  618. 09932 60 rts
  619. 09933
  620. 09933 09933 60 rts
  621. 09934
  622. 09934 doUpdateSpriteTimer:
  623. 09934 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  624. 09934 ;blank09934 60 RTS
  625. 09935
  626. 09935 doUpdateActionTimer:
  627. 09935 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  628. 09935 ;blank09935 60 RTS
  629. 09936 doObjectCollisions_bank1C:
  630. 09936 .include "Routines\BASE_4_5\Game\Subroutines\doObjectCollisionState.asm"
  631. 09936 ;do object collision state09936 .include "Routines\BASE_4_5\Game\MOD_shooter\Subroutines\doHandleObjectCollisions_shooter2.asm"
  632. 09936
  633. 09936 BD 00 04 LDA Object_status,x
  634. 09939 29 80 AND #%10000000
  635. 0993B D0 03 BNE +doCheckSelfForObjectCollision
  636. 0993D ;; object is inactive.
  637. 0993D 4C C7 9A JMP +skipObjectCollisionCheck
  638. 09940 +doCheckSelfForObjectCollision:
  639. 09940 ;;STEP 2: Check for hurt state.
  640. 09940 ;;; In this module, monsters will use action step 7 for their hurt state.
  641. 09940 8A TXA
  642. 09941 8D B1 06 STA selfObject
  643. 09944 85 00 STA temp
  644. 09946 A6 00 BD 9C 04 4A 4A 4A.. GetActionStep temp
  645. 09950 C9 07 CMP #$07
  646. 09952 D0 03 BNE +notHurt
  647. 09954 4C C7 9A JMP +skipObjectCollisionCheck
  648. 09957 +notHurt
  649. 09957 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  650. 09957 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  651. 09957 ;;STEP 3: Set up bounds for self collision.
  652. 09957 8A TXA
  653. 09958 48 PHA
  654. 09959 BC 8F 04 LDY Object_type,x
  655. 0995C B9 20 91 LDA ObjectFlags,y
  656. 0995F 85 07 STA tempA ;; temp A now holds the current object flags.
  657. 09961 ;; collision box is still held over from the physics routine.
  658. 09961
  659. 09961 AD 7A 06 LDA xHold_screen
  660. 09964 ;ADC #$00
  661. 09964 8D DB 06 STA self_screen_left
  662. 09967
  663. 09967 ; LDA Object_x_hi,x
  664. 09967 ; CLC
  665. 09967 ; ADC #$10
  666. 09967 ; LDA self_screen_left
  667. 09967 ; ADC #$00
  668. 09967 ; STA self_screen_right
  669. 09967
  670. 09967 AD 79 06 LDA xHold_hi
  671. 0996A 18 CLC
  672. 0996B 6D 59 06 ADC self_left
  673. 0996E BD 27 04 LDA Object_screen,x
  674. 09971 69 00 ADC #$00
  675. 09973 8D DB 06 STA self_screen_left
  676. 09976
  677. 09976 AD 79 06 LDA xHold_hi
  678. 09979 18 CLC
  679. 0997A 6D 5B 06 ADC self_right
  680. 0997D BD 27 04 LDA Object_screen,x
  681. 09980 69 00 ADC #$00
  682. 09982 8D DC 06 STA self_screen_right
  683. 09985
  684. 09985 ; LDA Object_x_hi,x
  685. 09985 ; CLC
  686. 09985 ; ADC #$10
  687. 09985 ; LDA self_screen_left
  688. 09985 ; ADC #$00
  689. 09985 ; STA self_screen_right
  690. 09985
  691. 09985 AD 79 06 LDA xHold_hi;Object_x_hi,x
  692. 09988 18 CLC
  693. 09989 6D 59 06 ADC self_left
  694. 0998C 8D 6F 06 STA bounds_left
  695. 0998F
  696. 0998F AD 79 06 LDA xHold_hi
  697. 09992 18 CLC
  698. 09993 6D 5B 06 ADC self_right
  699. 09996 8D 70 06 STA bounds_right
  700. 09999
  701. 09999 AD 7C 06 LDA yHold_hi;Object_y_hi,x
  702. 0999C 18 CLC
  703. 0999D 6D 5A 06 ADC self_top
  704. 099A0 8D 71 06 STA bounds_top
  705. 099A3 AD 7C 06 LDA yHold_hi;Object_y_hi,x
  706. 099A6 18 CLC
  707. 099A7 6D 5C 06 ADC self_bottom
  708. 099AA 8D 72 06 STA bounds_bottom
  709. 099AD
  710. 099AD
  711. 099AD
  712. 099AD 98 TYA
  713. 099AE 48 PHA
  714. 099AF ;;; we probably want this to live inside bank 1C
  715. 099AF ;;; so that we can access flag data easily with no RAM.
  716. 099AF ;;;; Right now, in this module, it is there by default.
  717. 099AF ;;;; If it is not, we will have to bankswap to 1c here.
  718. 099AF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  719. 099AF ;;; Check the type of object.
  720. 099AF ;;; If it is a weapon, it will check against monsters only.
  721. 099AF BD D0 04 LDA Object_flags,x
  722. 099B2 29 04 AND #%00000100
  723. 099B4 D0 03 BNE +isWeapon
  724. 099B6 4C 07 9A JMP +notPlayerWeapon
  725. 099B9 +isWeapon
  726. 099B9
  727. 099B9 A2 00 LDX #$00
  728. 099BB loop_objectCollision:
  729. 099BB EC B1 06 CPX selfObject
  730. 099BE D0 03 BNE +notSelfObject
  731. 099C0 4C FC 99 JMP +skipCollision
  732. 099C3 +notSelfObject
  733. 099C3 BD 00 04 LDA Object_status,x
  734. 099C6 29 80 AND #%10000000
  735. 099C8 D0 03 BNE +isActive
  736. 099CA 4C FC 99 JMP +skipCollision
  737. 099CD +isActive:
  738. 099CD BD D0 04 LDA Object_flags,x
  739. 099D0 29 08 AND #%00001000
  740. 099D2 D0 03 BNE isMonsterWeaponCol
  741. 099D4 4C FC 99 JMP +notAmonsterWeaponCollision
  742. 099D7 isMonsterWeaponCol:
  743. 099D7 20 71 95 JSR getOtherColBox
  744. 099DA 20 1A 95 JSR doCompareBoundingBoxes
  745. 099DD ;;; if they have collided, it is a 1
  746. 099DD ;;; if not, it is a zero.
  747. 099DD F0 1D BEQ +skipCollision
  748. 099DF
  749. 099DF 8A TXA
  750. 099E0 8D B2 06 STA otherObject
  751. 099E3 ;; There was a collision between a monster and a weapon.
  752. 099E3 ;; weapon is self.
  753. 099E3 ;; monster is other.
  754. 099E3 BD 00 04 29 3F 9D 00 04 DestroyObject
  755. 099EB ;ChangeActionStep otherObject, #$07
  756. 099EB
  757. 099EB
  758. 099EB 20 23 9B JSR doHandleHurtMonster
  759. 099EE
  760. 099EE AE B1 06 LDX selfObject
  761. 099F1 BD 00 04 29 3F 9D 00 04 DestroyObject
  762. 099F9 4C C3 9A JMP +done
  763. 099FC +skipCollision
  764. 099FC +notAmonsterWeaponCollision
  765. 099FC E8 INX
  766. 099FD E0 0D CPX #TOTAL_MAX_OBJECTS
  767. 099FF F0 03 BEQ +lastCollisionForThisObject
  768. 09A01 4C BB 99 JMP loop_objectCollision
  769. 09A04 +lastCollisionForThisObject
  770. 09A04 4C C3 9A JMP +done
  771. 09A07
  772. 09A07
  773. 09A07 +notPlayerWeapon
  774. 09A07
  775. 09A07 BD D0 04 LDA Object_flags,x
  776. 09A0A 29 02 AND #%00000010
  777. 09A0C D0 03 BNE +isPlayerForCol
  778. 09A0E ;; not player for collions
  779. 09A0E 4C C3 9A JMP +notPlayerForCollisions
  780. 09A11 +isPlayerForCol
  781. 09A11 ;;; check against monsters.
  782. 09A11 A2 00 LDX #$00
  783. 09A13 loop_objectPlayerCollisions:
  784. 09A13 EC B1 06 CPX selfObject
  785. 09A16 D0 03 BNE +notSelfObject
  786. 09A18 4C B5 9A JMP +skipCollision
  787. 09A1B +notSelfObject
  788. 09A1B BD 00 04 LDA Object_status,x
  789. 09A1E 29 80 AND #%10000000
  790. 09A20 D0 03 BNE +isActive
  791. 09A22 4C B5 9A JMP +skipCollision
  792. 09A25 +isActive
  793. 09A25 BD D0 04 LDA Object_flags,x
  794. 09A28 29 18 AND #%00011000
  795. 09A2A D0 03 BNE +isPlayerMonsterCol
  796. 09A2C 4C 4B 9A JMP +notPlayerMonsterCollision
  797. 09A2F +isPlayerMonsterCol
  798. 09A2F
  799. 09A2F 20 71 95 JSR getOtherColBox
  800. 09A32 20 1A 95 JSR doCompareBoundingBoxes
  801. 09A35 ;;; if they have collided, it is a 1
  802. 09A35 ;;; if not, it is a zero.
  803. 09A35 D0 03 BNE +dontSkipCol
  804. 09A37 4C B5 9A JMP +skipCollision
  805. 09A3A +dontSkipCol
  806. 09A3A 8A TXA
  807. 09A3B 8D B2 06 STA otherObject
  808. 09A3E ;; There was a collision between a monster and a weapon.
  809. 09A3E ;; player is self.
  810. 09A3E ;; monster is other.
  811. 09A3E ;JMP RESET
  812. 09A3E
  813. 09A3E 8A TXA
  814. 09A3F 48 PHA
  815. 09A40 AE B1 06 LDX selfObject
  816. 09A43 20 C8 9A JSR doHandleHurtPlayer
  817. 09A46 68 PLA
  818. 09A47 AA TAX
  819. 09A48
  820. 09A48 4C C3 9A JMP +done
  821. 09A4B
  822. 09A4B +notPlayerMonsterCollision:
  823. 09A4B
  824. 09A4B BD D0 04 LDA Object_flags,x
  825. 09A4E 29 20 AND #%00100000
  826. 09A50 D0 03 BNE +isPlayerPowerupCol
  827. 09A52 4C 6F 9A JMP +isNotPlayerPowerupCol
  828. 09A55 +isPlayerPowerupCol
  829. 09A55 20 71 95 JSR getOtherColBox
  830. 09A58 20 1A 95 JSR doCompareBoundingBoxes
  831. 09A5B D0 03 BNE +doCollision
  832. 09A5D 4C B5 9A JMP +skipCollision
  833. 09A60 +doCollision
  834. 09A60 8A TXA
  835. 09A61 8D B2 06 STA otherObject
  836. 09A64 ;; There was a collision between a player and a powerup.
  837. 09A64 ;; player is self.
  838. 09A64 ;; powerup is other.
  839. 09A64 BD 00 04 29 3F 9D 00 04 DestroyObject
  840. 09A6C .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  841. 09A6C ;blank09A6C 4C C3 9A JMP +done
  842. 09A6F
  843. 09A6F +isNotPlayerPowerupCol
  844. 09A6F BD D0 04 LDA Object_flags,x
  845. 09A72 29 80 AND #%10000000
  846. 09A74 D0 03 BNE +isPlayerNPCCol
  847. 09A76 4C B5 9A JMP +isNotPlayerNPCCol
  848. 09A79 +isPlayerNPCCol
  849. 09A79 20 71 95 JSR getOtherColBox
  850. 09A7C 20 1A 95 JSR doCompareBoundingBoxes
  851. 09A7F F0 34 BEQ +skipCollision
  852. 09A81 8A TXA
  853. 09A82 8D B2 06 STA otherObject
  854. 09A85 ;; There was a collision between a player and a powerup.
  855. 09A85 ;; player is self.
  856. 09A85 ;; powerup is other.
  857. 09A85 8A TXA
  858. 09A86 48 PHA
  859. 09A87 AE B1 06 LDX selfObject
  860. 09A8A AD 7F 06 LDA xPrev
  861. 09A8D 9D 1A 04 STA Object_x_hi,x
  862. 09A90 8D 79 06 STA xHold_hi
  863. 09A93
  864. 09A93 AD 80 06 LDA yPrev
  865. 09A96 9D 41 04 STA Object_y_hi,x
  866. 09A99 8D 7C 06 STA yHold_hi
  867. 09A9C
  868. 09A9C A9 00 LDA #$00
  869. 09A9E 9D 4E 04 STA Object_h_speed_lo,x
  870. 09AA1 9D 5B 04 STA Object_h_speed_hi,x
  871. 09AA4 9D 68 04 STA Object_v_speed_lo,x
  872. 09AA7 9D 75 04 STA Object_v_speed_hi,x
  873. 09AAA 9D 0D 04 STA Object_x_lo,x
  874. 09AAD 9D 34 04 STA Object_y_lo,x
  875. 09AB0 68 PLA
  876. 09AB1 AA TAX
  877. 09AB2 4C C3 9A JMP +done
  878. 09AB5
  879. 09AB5 +isNotPlayerNPCCol
  880. 09AB5
  881. 09AB5 +skipCollision
  882. 09AB5
  883. 09AB5 E8 INX
  884. 09AB6 E0 0D CPX #TOTAL_MAX_OBJECTS
  885. 09AB8 F0 03 BEQ +lastCollisionForThisObject
  886. 09ABA 4C 13 9A JMP loop_objectPlayerCollisions
  887. 09ABD +lastCollisionForThisObject
  888. 09ABD ; PLA
  889. 09ABD ; TAX
  890. 09ABD 4C C3 9A JMP +done
  891. 09AC0
  892. 09AC0
  893. 09AC0 ;; Add other object to object collision types here.
  894. 09AC0 4C C3 9A JMP +done
  895. 09AC3
  896. 09AC3
  897. 09AC3 +notPlayerForCollisions
  898. 09AC3
  899. 09AC3 +done
  900. 09AC3 68 PLA
  901. 09AC4 A8 TAY
  902. 09AC5 68 PLA
  903. 09AC6 AA TAX
  904. 09AC7 +skipObjectCollisionCheck09AC7 60 RTS
  905. 09AC8
  906. 09AC8
  907. 09AC8 ;; Game specific, common
  908. 09AC8 doHandleHurtPlayer:
  909. 09AC8 .include "Routines\BASE_4_5\Game\MOD_shooter\Common\hurtWithLives_shooter.asm"
  910. 09AC8
  911. 09AC8 ;;;;;;;;;;;;;;;;;; Presumes there is a variable called myLives defined in user variables.
  912. 09AC8 ;;;;;;;;;;;;;;;;;; You could also create your own variable for this.
  913. 09AC8
  914. 09AC8 AD AB 06 LDA gameHandler
  915. 09ACB 29 80 AND #%10000000
  916. 09ACD F0 03 BEQ +canHurtPlayer
  917. 09ACF 4C 22 9B JMP +skipHurt
  918. 09AD2 +canHurtPlayer:
  919. 09AD2
  920. 09AD2 C6 A4 DEC myLives
  921. 09AD4 A5 A4 LDA myLives
  922. 09AD6 D0 03 BNE myLivesNotZero
  923. 09AD8 4C 00 C0 JMP RESET ;; game over.
  924. 09ADB ;;;; also could warp to game over screen here instead.
  925. 09ADB myLivesNotZero:
  926. 09ADB
  927. 09ADB AD D5 06 LDA continueMap
  928. 09ADE 8D A4 06 STA warpMap
  929. 09AE1
  930. 09AE1 AD D2 06 LDA continueScreen
  931. 09AE4 8D 74 06 STA currentNametable
  932. 09AE7 29 0F AND #%00001111
  933. 09AE9 8D 86 06 STA camX_hi
  934. 09AEC
  935. 09AEC AE 6D 06 LDX player1_object
  936. 09AEF 9D 27 04 STA Object_screen,x
  937. 09AF2
  938. 09AF2 A9 02 LDA #$02 ;; this is continue type warp.
  939. 09AF4 8D A5 06 STA screenTransitionType ;; is of warp type
  940. 09AF7
  941. 09AF7
  942. 09AF7 A9 00 LDA #$00
  943. 09AF9 8D 85 06 STA camX
  944. 09AFC 8D 84 06 sta camX_lo
  945. 09AFF
  946. 09AFF
  947. 09AFF
  948. 09AFF
  949. 09AFF AD 24 06 LDA updateScreenData
  950. 09B02 29 FB AND #%11111011
  951. 09B04 8D 24 06 STA updateScreenData
  952. 09B07 AD 8C 06 LDA scrollByte
  953. 09B0A 29 3E AND #%00111110
  954. 09B0C 09 02 ORA #%00000010
  955. 09B0E 8D 8C 06 STA scrollByte
  956. 09B11 A9 00 LDA #$00
  957. 09B13 8D 8A 06 STA scrollOffsetCounter
  958. 09B16
  959. 09B16 AD AB 06 LDA gameHandler
  960. 09B19 09 80 ORA #%10000000
  961. 09B1B 8D AB 06 STA gameHandler ;; this will set the next game loop to update the screen.
  962. 09B1E
  963. 09B1E A9 05 LDA #$05
  964. 09B20 85 A8 STA bossHealth ;; resets boss health for this level.
  965. 09B22
  966. 09B22 +skipHurt09B22 60 RTS
  967. 09B23 doHandleHurtMonster:
  968. 09B23 .include "Routines\BASE_4_5\Game\MOD_shooter\Common\doHandleHurtMonster_Shooter_CountMonsters.asm"
  969. 09B23
  970. 09B23 BD 00 04 29 3F 9D 00 04 DestroyObject
  971. 09B2B A9 01 8D CB 06 AD CD 06.. PlaySound #sfx_monsterdeath
  972. 09B38 A9 08 85 07 8A 48 98 48.. CountObjects #%00001000
  973. 09B61 D0 08 BNE +notZeroCount
  974. 09B63 ;;; if there are no more monsters left, we want to disable
  975. 09B63 ;;; the edge check for scrolling.
  976. 09B63 AD 9F 06 LDA ScreenFlags00
  977. 09B66 29 EF AND #%11101111
  978. 09B68 8D 9F 06 STA ScreenFlags00
  979. 09B6B
  980. 09B6B +notZeroCount:09B6B 60 RTS
  981. 09B6C
  982. 09B6C
  983. 09B6C
  984. 09B6C
  985. 09B6C ObjectLoSpriteAddressLo:
  986. 09B6C 60 70 80 90 A0 B0 C0 D0 .db #<GameItem0_Lo, #<GameItem1_Lo, #<GameItem2_Lo, #<GameItem3_Lo, #<GameItem4_Lo, #<GameItem5_Lo, #<GameItem6_Lo, #<GameItem7_Lo
  987. 09B74 E0 F0 00 10 20 30 40 50 .db #<GameItem8_Lo, #<GameItem9_Lo,#<GameItem10_Lo,#<GameItem11_Lo,#<GameItem12_Lo,#<GameItem13_Lo,#<GameItem14_Lo,#<GameItem15_Lo
  988. 09B7C
  989. 09B7C 60 70 80 80 80 80 80 80 .db #<Object0_Lo,#<Object1_Lo,#<Object2_Lo,#<Object3_Lo,#<Object4_Lo,#<Object5_Lo,#<Object6_Lo,#<Object7_Lo
  990. 09B84 80 80 80 80 80 80 80 80 .db #<Object8_Lo,#<Object9_Lo,#<Object10_Lo,#<Object11_Lo,#<Object12_Lo,#<Object13_Lo,#<Object14_Lo,#<Object15_Lo
  991. 09B8C 80 80 80 80 80 80 80 80 .db #<Object16_Lo,#<Object17_Lo,#<Object18_Lo,#<Object19_Lo,#<Object20_Lo,#<Object21_Lo,#<Object22_Lo,#<Object23_Lo
  992. 09B94 80 80 80 80 80 80 80 80 .db #<Object24_Lo,#<Object25_Lo,#<Object26_Lo,#<Object27_Lo,#<Object28_Lo,#<Object29_Lo,#<Object30_Lo,#<Object31_Lo
  993. 09B9C 80 80 80 80 80 80 80 80 .db #<Object32_Lo,#<Object33_Lo,#<Object34_Lo,#<Object35_Lo,#<Object36_Lo,#<Object37_Lo,#<Object38_Lo,#<Object39_Lo
  994. 09BA4 80 80 80 80 80 80 80 80 .db #<Object40_Lo,#<Object41_Lo,#<Object42_Lo,#<Object43_Lo,#<Object44_Lo,#<Object45_Lo,#<Object46_Lo,#<Object47_Lo
  995. 09BAC 80 80 80 80 80 80 80 80 .db #<Object48_Lo,#<Object49_Lo,#<Object50_Lo,#<Object51_Lo,#<Object52_Lo,#<Object53_Lo,#<Object54_Lo,#<Object55_Lo
  996. 09BB4 80 80 80 80 80 80 80 80 .db #<Object56_Lo,#<Object57_Lo,#<Object58_Lo,#<Object59_Lo,#<Object60_Lo,#<Object61_Lo,#<Object62_Lo,#<Object63_Lo
  997. 09BBC
  998. 09BBC ObjectLoSpriteAddressHi:
  999. 09BBC 80 80 80 80 80 80 80 80 .db #>GameItem0_Lo, #>GameItem1_Lo, #>GameItem2_Lo, #>GameItem3_Lo, #>GameItem4_Lo, #>GameItem5_Lo, #>GameItem6_Lo, #>GameItem7_Lo
  1000. 09BC4 80 80 81 81 81 81 81 81 .db #>GameItem8_Lo, #>GameItem9_Lo,#>GameItem10_Lo,#>GameItem11_Lo,#>GameItem12_Lo,#>GameItem13_Lo,#>GameItem14_Lo,#>GameItem15_Lo
  1001. 09BCC
  1002. 09BCC 81 81 81 81 81 81 81 81 .db #>Object0_Lo,#>Object1_Lo,#>Object2_Lo,#>Object3_Lo,#>Object4_Lo,#>Object5_Lo,#>Object6_Lo,#>Object7_Lo
  1003. 09BD4 81 81 81 81 81 81 81 81 .db #>Object8_Lo,#>Object9_Lo,#>Object10_Lo,#>Object11_Lo,#>Object12_Lo,#>Object13_Lo,#>Object14_Lo,#>Object15_Lo
  1004. 09BDC 81 81 81 81 81 81 81 81 .db #>Object16_Lo,#>Object17_Lo,#>Object18_Lo,#>Object19_Lo,#>Object20_Lo,#>Object21_Lo,#>Object22_Lo,#>Object23_Lo
  1005. 09BE4 81 81 81 81 81 81 81 81 .db #>Object24_Lo,#>Object25_Lo,#>Object26_Lo,#>Object27_Lo,#>Object28_Lo,#>Object29_Lo,#>Object30_Lo,#>Object31_Lo
  1006. 09BEC 81 81 81 81 81 81 81 81 .db #>Object32_Lo,#>Object33_Lo,#>Object34_Lo,#>Object35_Lo,#>Object36_Lo,#>Object37_Lo,#>Object38_Lo,#>Object39_Lo
  1007. 09BF4 81 81 81 81 81 81 81 81 .db #>Object40_Lo,#>Object41_Lo,#>Object42_Lo,#>Object43_Lo,#>Object44_Lo,#>Object45_Lo,#>Object46_Lo,#>Object47_Lo
  1008. 09BFC 81 81 81 81 81 81 81 81 .db #>Object48_Lo,#>Object49_Lo,#>Object50_Lo,#>Object51_Lo,#>Object52_Lo,#>Object53_Lo,#>Object54_Lo,#>Object55_Lo
  1009. 09C04 81 81 81 81 81 81 81 81 .db #>Object56_Lo,#>Object57_Lo,#>Object58_Lo,#>Object59_Lo,#>Object60_Lo,#>Object61_Lo,#>Object62_Lo,#>Object63_Lo
  1010. 09C0C
  1011. 09C0C
  1012. 09C0C ObjectHiSpriteAddressLo:
  1013. 09C0C 68 78 88 98 A8 B8 C8 D8 .db #<GameItem0_Hi, #<GameItem1_Hi, #<GameItem2_Hi, #<GameItem3_Hi, #<GameItem4_Hi, #<GameItem5_Hi, #<GameItem6_Hi, #<GameItem7_Hi
  1014. 09C14 E8 F8 08 18 28 38 48 58 .db #<GameItem8_Hi, #<GameItem9_Hi,#<GameItem10_Hi,#<GameItem11_Hi,#<GameItem12_Hi,#<GameItem13_Hi,#<GameItem14_Hi,#<GameItem15_Hi
  1015. 09C1C
  1016. 09C1C 68 78 80 80 80 80 80 80 .db #<Object0_Hi,#<Object1_Hi,#<Object2_Hi,#<Object3_Hi,#<Object4_Hi,#<Object5_Hi,#<Object6_Hi,#<Object7_Hi
  1017. 09C24 80 80 80 80 80 80 80 80 .db #<Object8_Hi,#<Object9_Hi,#<Object10_Hi,#<Object11_Hi,#<Object12_Hi,#<Object13_Hi,#<Object14_Hi,#<Object15_Hi
  1018. 09C2C 80 80 80 80 80 80 80 80 .db #<Object16_Hi,#<Object17_Hi,#<Object18_Hi,#<Object19_Hi,#<Object20_Hi,#<Object21_Hi,#<Object22_Hi,#<Object23_Hi
  1019. 09C34 80 80 80 80 80 80 80 80 .db #<Object24_Hi,#<Object25_Hi,#<Object26_Hi,#<Object27_Hi,#<Object28_Hi,#<Object29_Hi,#<Object30_Hi,#<Object31_Hi
  1020. 09C3C 80 80 80 80 80 80 80 80 .db #<Object32_Hi,#<Object33_Hi,#<Object34_Hi,#<Object35_Hi,#<Object36_Hi,#<Object37_Hi,#<Object38_Hi,#<Object39_Hi
  1021. 09C44 80 80 80 80 80 80 80 80 .db #<Object40_Hi,#<Object41_Hi,#<Object42_Hi,#<Object43_Hi,#<Object44_Hi,#<Object45_Hi,#<Object46_Hi,#<Object47_Hi
  1022. 09C4C 80 80 80 80 80 80 80 80 .db #<Object48_Hi,#<Object49_Hi,#<Object50_Hi,#<Object51_Hi,#<Object52_Hi,#<Object53_Hi,#<Object54_Hi,#<Object55_Hi
  1023. 09C54 80 80 80 80 80 80 80 80 .db #<Object56_Hi,#<Object57_Hi,#<Object58_Hi,#<Object59_Hi,#<Object60_Hi,#<Object61_Hi,#<Object62_Hi,#<Object63_Hi
  1024. 09C5C
  1025. 09C5C ObjectHiSpriteAddressHi:
  1026. 09C5C 80 80 80 80 80 80 80 80 .db #>GameItem0_Hi, #>GameItem1_Hi, #>GameItem2_Hi, #>GameItem3_Hi, #>GameItem4_Hi, #>GameItem5_Hi, #>GameItem6_Hi, #>GameItem7_Hi
  1027. 09C64 80 80 81 81 81 81 81 81 .db #>GameItem8_Hi, #>GameItem9_Hi,#>GameItem10_Hi,#>GameItem11_Hi,#>GameItem12_Hi,#>GameItem13_Hi,#>GameItem14_Hi,#>GameItem15_Hi
  1028. 09C6C
  1029. 09C6C 81 81 81 81 81 81 81 81 .db #>Object0_Hi,#>Object1_Hi,#>Object2_Hi,#>Object3_Hi,#>Object4_Hi,#>Object5_Hi,#>Object6_Hi,#>Object7_Hi
  1030. 09C74 81 81 81 81 81 81 81 81 .db #>Object8_Hi,#>Object9_Hi,#>Object10_Hi,#>Object11_Hi,#>Object12_Hi,#>Object13_Hi,#>Object14_Hi,#>Object15_Hi
  1031. 09C7C 81 81 81 81 81 81 81 81 .db #>Object16_Hi,#>Object17_Hi,#>Object18_Hi,#>Object19_Hi,#>Object20_Hi,#>Object21_Hi,#>Object22_Hi,#>Object23_Hi
  1032. 09C84 81 81 81 81 81 81 81 81 .db #>Object24_Hi,#>Object25_Hi,#>Object26_Hi,#>Object27_Hi,#>Object28_Hi,#>Object29_Hi,#>Object30_Hi,#>Object31_Hi
  1033. 09C8C 81 81 81 81 81 81 81 81 .db #>Object32_Hi,#>Object33_Hi,#>Object34_Hi,#>Object35_Hi,#>Object36_Hi,#>Object37_Hi,#>Object38_Hi,#>Object39_Hi
  1034. 09C94 81 81 81 81 81 81 81 81 .db #>Object40_Hi,#>Object41_Hi,#>Object42_Hi,#>Object43_Hi,#>Object44_Hi,#>Object45_Hi,#>Object46_Hi,#>Object47_Hi
  1035. 09C9C 81 81 81 81 81 81 81 81 .db #>Object48_Hi,#>Object49_Hi,#>Object50_Hi,#>Object51_Hi,#>Object52_Hi,#>Object53_Hi,#>Object54_Hi,#>Object55_Hi
  1036. 09CA4 81 81 81 81 81 81 81 81 .db #>Object56_Hi,#>Object57_Hi,#>Object58_Hi,#>Object59_Hi,#>Object60_Hi,#>Object61_Hi,#>Object62_Hi,#>Object63_Hi
  1037. 09CAC 09CAC 00 00 00 00 00 00 00 00.. .pad $c000
  1038. 0C000
  1039. 0C000
  1040. 0C000 ;bank 30 (1d)
  1041. 0C000 .base $8000
  1042. 08000 .include "Routines\BASE_4_5\System\BankData\Bank1D.asm"
  1043. 08000 00 00 00 00 00 00 00 00.. .pad $c000
  1044. 0C000
  1045. 0C000 ;bank 31 (1e)
  1046. 0C000 .base $8000
  1047. 08000 .include "Routines\BASE_4_5\System\BankData\Bank1E.asm"
  1048. 08000
  1049. 08000
  1050. 08000
  1051. 08000
  1052. 08000 HudTiles:
  1053. 08000 00 00 00 00 00 00 00 00.. .incbin "Graphics\Backgrounds\CHR_HudTiles.chr"08400 00 00 00 00 00 00 00 00.. .pad $c000
  1054. 0C000
  1055. 0C000
  1056. 0C000 ;bank fixed, 1F
  1057. 0C000
  1058. 0C000 .org $c000 ; because c000 is the last 16kb of memory. The first 16 starts at 8000, so
  1059. 0C000 ; the swappable banks will go from 8000-bfff
  1060. 0C000 ; everything here will be in the static bank.
  1061. 0C000 ; everything moved into 8000 will be in the swappable 16k bank.0C000 ;4 The Reset
  1062. 0C000 .include "Routines\BASE_4_5\System\Reset.asm"
  1063. 0C000
  1064. 0C000 RESET:
  1065. 0C000 78 SEI ;ignore interrupts for the reset
  1066. 0C001 A9 00 LDA #$00 ; load the number 00
  1067. 0C003 8D 00 20 STA $2000 ; disables NMI
  1068. 0C006 8D 01 20 STA $2001 ; disables rendering
  1069. 0C009 8D 10 40 STA $4010 ; disables DMC IRQ
  1070. 0C00C 8D 15 40 STA $4015 ; disables APU sound
  1071. 0C00F A9 40 LDA #$40 ; Loads the number 64
  1072. 0C011 8D 17 40 STA $4017 ; disables the APU IRQ
  1073. 0C014 D8 CLD ; disables decimal mode
  1074. 0C015 A2 FF LDX #$FF
  1075. 0C017 9A TXS ; initializes the stack
  1076. 0C018
  1077. 0C018 ;5. First vblank wait
  1078. 0C018 ; what is vblank?
  1079. 0C018 ; NES draws scan lines from top to bottom. During the time it takes
  1080. 0C018 ; for the light beam to move back up to the top is a waiting period
  1081. 0C018 ; called vblank...it gives us time to update what is drawn to the screen.
  1082. 0C018 2C 02 20 bit $2002
  1083. 0C01B vBlankWait1:
  1084. 0C01B 2C 02 20 bit $2002
  1085. 0C01E 10 FB BPL vBlankWait1
  1086. 0C020
  1087. 0C020 ;6. Clear all ram
  1088. 0C020 ;LDA #$00
  1089. 0C020 A2 00 LDX #$00
  1090. 0C022 clrMemLoop:
  1091. 0C022 A9 00 LDA #$00
  1092. 0C024 95 00 STA $0000,x
  1093. 0C026 9D 00 01 STA $0100,x
  1094. 0C029 ;; skip 200, this is where the sprites are drawn
  1095. 0C029 ;; we'll set them to $FE to draw them off screen
  1096. 0C029 9D 00 03 STA $0300,x
  1097. 0C02C 9D 00 04 STA $0400,x
  1098. 0C02F 9D 00 05 STA $0500,x
  1099. 0C032 9D 00 06 STA $0600,x
  1100. 0C035 9D 00 07 STA $0700,x
  1101. 0C038 A9 FE LDA #$FE ; instead of zero, write #$FE to 0200,x
  1102. 0C03A 9D 00 02 STA $0200,x ; to place sprites off screen
  1103. 0C03D E8 INX
  1104. 0C03E D0 E2 BNE clrMemLoop
  1105. 0C040
  1106. 0C040 ;7. Second vblank
  1107. 0C040 vBlankWait2:
  1108. 0C040 2C 02 20 bit $2002
  1109. 0C043 10 FB BPL vBlankWait2
  1110. 0C045
  1111. 0C045 ;8 Enable NMI
  1112. 0C045 A9 90 LDA #%10010000 ; turn on NMI, set sprites $0000, bkg to $1000
  1113. 0C047 8D 00 20 STA $2000
  1114. 0C04A A9 1E LDA #%00011110
  1115. 0C04C 8D 01 20 STA $2001
  1116. 0C04F 85 17 STA soft2001
  1117. 0C051
  1118. 0C051 A9 00 LDA #$00
  1119. 0C053 8D 05 20 sTA $2005
  1120. 0C056 8D 05 20 STA $2005
  1121. 0C059 ;;DON'T TURN ON RENDERING UNTIL FIRST GRAPHICS ARE DRAWN.0C059 ;5 Initialization of things.
  1122. 0C059 .include "Routines\BASE_4_5\Game\Space Birds\Game\Initialization_shooter.asm"
  1123. 0C059 ;;initialization
  1124. 0C059 ;;; on a game to game basis, what data needs to be initialized will change.
  1125. 0C059 .include "ScreenData\init.ini"
  1126. 0C059 ;; INI data export. Saturday, March 6, 2021 6:48:11 PM
  1127. 0C059
  1128. 0C059 START_LEVEL = 1
  1129. 0C059 START_SCREEN_X = 1
  1130. 0C059 START_SCREEN_Y = 14
  1131. 0C059 START_ON_SCREEN = #$e1
  1132. 0C059 START_POSITION_TILE_X = 0
  1133. 0C059 START_POSITION_TILE_Y = 0
  1134. 0C059 START_POSITION_PIX_X = #$00
  1135. 0C059 START_POSITION_PIX_Y = #$00
  1136. 0C059 BOSSES_DEFEATED = #$00
  1137. 0C059 RELIC_GROUP1 = #$00
  1138. 0C059 RELIC_GROUP2 = #$00
  1139. 0C059 SONG_LEARNED = #$00
  1140. 0C059 DayNightSpeed = #$00
  1141. 0C059
  1142. 0C059 INIT_ITEM_00 = #$00
  1143. 0C059 INIT_ITEM_01 = #$00
  1144. 0C059 INIT_ITEM_02 = #$00
  1145. 0C059 INIT_ITEM_03 = #$00
  1146. 0C059 INIT_ITEM_04 = #$00
  1147. 0C059 INIT_ITEM_05 = #$00
  1148. 0C059 INIT_ITEM_06 = #$00
  1149. 0C059 INIT_ITEM_07 = #$00
  1150. 0C059
  1151. 0C059 INIT_TRIG_00 = #%00000000
  1152. 0C059 INIT_TRIG_01 = #%00000000
  1153. 0C059 INIT_TRIG_02 = #%00000000
  1154. 0C059 INIT_TRIG_03 = #%00000000
  1155. 0C059 INIT_TRIG_04 = #%00000000
  1156. 0C059 INIT_TRIG_05 = #%00000000
  1157. 0C059 INIT_TRIG_06 = #%00000000
  1158. 0C059 INIT_TRIG_07 = #%00000000
  1159. 0C059 INIT_TRIG_08 = #%00000000
  1160. 0C059 INIT_TRIG_09 = #%00000000
  1161. 0C059 INIT_TRIG_0a = #%00000000
  1162. 0C059 INIT_TRIG_0b = #%00000000
  1163. 0C059 INIT_TRIG_0c = #%00000000
  1164. 0C059 INIT_TRIG_0d = #%00000000
  1165. 0C059 INIT_TRIG_0e = #%00000000
  1166. 0C059 INIT_TRIG_0f = #%00000000
  1167. 0C059 INIT_TRIG_10 = #%00000000
  1168. 0C059 INIT_TRIG_11 = #%00000000
  1169. 0C059 INIT_TRIG_12 = #%00000000
  1170. 0C059 INIT_TRIG_13 = #%00000000
  1171. 0C059 INIT_TRIG_14 = #%00000000
  1172. 0C059 INIT_TRIG_15 = #%00000000
  1173. 0C059 INIT_TRIG_16 = #%00000000
  1174. 0C059 INIT_TRIG_17 = #%00000000
  1175. 0C059 INIT_TRIG_18 = #%00000000
  1176. 0C059 INIT_TRIG_19 = #%00000000
  1177. 0C059 INIT_TRIG_1a = #%00000000
  1178. 0C059 INIT_TRIG_1b = #%00000000
  1179. 0C059 INIT_TRIG_1c = #%00000000
  1180. 0C059 INIT_TRIG_1d = #%00000000
  1181. 0C059 INIT_TRIG_1e = #%00000000
  1182. 0C059 INIT_TRIG_1f = #%00000000
  1183. 0C059 SKIP_START_SCREEN = 1
  1184. 0C059
  1185. 0C059
  1186. 0C059 DATABANK1 = #$14
  1187. 0C059
  1188. 0C059 PRESSED_INPUTS = 5
  1189. 0C059 RELEASED_INPUTS = 8
  1190. 0C059 HELD_INPUTS = 8
  1191. 0C059
  1192. 0C059
  1193. 0C059 PAL_GO_1 = #$00
  1194. 0C059 PAL_GO_2 = #$00
  1195. 0C059
  1196. 0C059
  1197. 0C059 ;;; this contains CONSTANTS information, like the starting screen and the game object palettes.
  1198. 0C059
  1199. 0C059 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1200. 0C059 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1201. 0C059
  1202. 0C059 A9 00 LDA #$00
  1203. 0C05B 85 17 STA soft2001
  1204. 0C05D 20 FB C8 JSR doWaitFrame
  1205. 0C060 ;;; turn off rendering to load graphics.
  1206. 0C060
  1207. 0C060 A9 FF LDA #$FF
  1208. 0C062 8D CC 06 STA songToPlay ;;; this will force "none" to play.
  1209. 0C065 ;; which means that the first screen with a song that is not none
  1210. 0C065 ;; will not be seen as the "Same songToPlay value", so it will play.
  1211. 0C065 ;;; do this BEFORE screen loads.
  1212. 0C065
  1213. 0C065 A9 E1 LDA #START_ON_SCREEN
  1214. 0C067 8D D2 06 STA continueScreen
  1215. 0C06A 8D 74 06 STA currentNametable
  1216. 0C06D 8D 8D 06 STA camScreen
  1217. 0C070
  1218. 0C070 29 0F AND #%00001111
  1219. 0C072 8D 86 06 STA camX_hi
  1220. 0C075 A9 E1 LDA #START_ON_SCREEN
  1221. 0C077 4A LSR
  1222. 0C078 4A LSR
  1223. 0C079 4A LSR
  1224. 0C07A 4A LSR
  1225. 0C07B 8D 89 06 STA camY_hi
  1226. 0C07E
  1227. 0C07E A9 00 LDA #$00
  1228. 0C080 8D 85 06 STA camX
  1229. 0C083 8D 84 06 STA camX_lo
  1230. 0C086
  1231. 0C086 ; LDA #START_ON_SCREEN
  1232. 0C086 ; AND #%00000001
  1233. 0C086 ; BNE gameStartsInRightNametable
  1234. 0C086 ; ;; game starts in left nametable
  1235. 0C086 ; LDA #$20
  1236. 0C086 ; STA updateNametable
  1237. 0C086 ; LDA #$23
  1238. 0C086 ; STA updateAttributeTable
  1239. 0C086 ; JMP gotNameAndAttributeTableStart
  1240. 0C086 ; gameStartsInRightNametable:
  1241. 0C086 ; LDA #$24
  1242. 0C086 ; STA updateNametable
  1243. 0C086 ; LDA #$27
  1244. 0C086 ; STA updateAttributeTable
  1245. 0C086 ; gotNameAndAttributeTableStart:
  1246. 0C086
  1247. 0C086
  1248. 0C086 A9 01 LDA #START_LEVEL ;; right now, this is set up backwards, where 0 is underground.
  1249. 0C088 49 01 EOR #%00000001
  1250. 0C08A 8D A4 06 STA warpMap
  1251. 0C08D
  1252. 0C08D
  1253. 0C08D ;JSR doLoadScreen2 ;; loads the second screen to the second nametable.
  1254. 0C08D ;JSR doLoadScreen
  1255. 0C08D AD AB 06 LDA gameHandler
  1256. 0C090 09 80 ORA #%10000000
  1257. 0C092 8D AB 06 STA gameHandler
  1258. 0C095
  1259. 0C095 A2 00 LDX #$00
  1260. 0C097 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1261. 0C097 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1262. 0C097 20 BA F1 E0 FF D0 03 4C.. CreateObject #START_POSITION_PIX_X, #START_POSITION_PIX_Y, #$00, #$00
  1263. 0C0BE 8A TXA
  1264. 0C0BF 8D 6D 06 STA player1_object
  1265. 0C0C2 8D 81 06 STA camObject
  1266. 0C0C5 AD 74 06 LDA currentNametable
  1267. 0C0C8 9D 27 04 STA Object_screen,x
  1268. 0C0CB 8A TXA
  1269. 0C0CC 85 00 STA temp
  1270. 0C0CE 8A 48 A5 00 85 0C A9 02.. ChangeFacingDirection temp, #FACE_RIGHT
  1271. 0C0DD
  1272. 0C0DD A9 00 LDA #START_POSITION_PIX_X
  1273. 0C0DF 8D 75 06 STA newX
  1274. 0C0E2 8D D3 06 STA continueX
  1275. 0C0E5 A9 00 LDA #START_POSITION_PIX_Y
  1276. 0C0E7 8D 76 06 STA newY
  1277. 0C0EA 8D D4 06 STA continueY
  1278. 0C0ED
  1279. 0C0ED E8 INX
  1280. 0C0EE 8A TXA
  1281. 0C0EF 8D 6E 06 STA player2_object
  1282. 0C0F2 85 00 STA temp
  1283. 0C0F4 8A 48 A5 00 85 0C A9 02.. ChangeFacingDirection temp, #FACE_RIGHT
  1284. 0C103 ;LDA #%11110000
  1285. 0C103
  1286. 0C103 ;LDA #%00110000
  1287. 0C103 A2 00 LDX #$00
  1288. 0C105 A9 00 LDA #$00
  1289. 0C107 8D 92 06 STA scrollTrigger
  1290. 0C10A ;;;;; this sets up to ignore "screen edge" behavior
  1291. 0C10A ;;;;; for scrolling games.
  1292. 0C10A ;;Bit 7 = up
  1293. 0C10A ;;Bit 6 = Down
  1294. 0C10A ;;Bit 5 = left
  1295. 0C10A ;;Bit 4 = right
  1296. 0C10A
  1297. 0C10A A9 C2 LDA #%11000010
  1298. 0C10C 8D 8C 06 STA scrollByte
  1299. 0C10F
  1300. 0C10F
  1301. 0C10F 98 48 AD 20 06 8D 21 06.. SwitchBank #$1B ;; switch to the music bank
  1302. 0C11E ;; which contains the initializtion scripts.
  1303. 0C11E
  1304. 0C11E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1305. 0C11E ;;;; THIS SETS UP THE MUSIC ENGINE.
  1306. 0C11E ;;;; IF YOU USE A DIFFERENT MUSIC ENGINE
  1307. 0C11E ;;;; CHANGE THIS TO FIT YOUR NEEDS OF INITIALIZING YOUR MUSIC ENGINE.
  1308. 0C11E A9 00 lda #SOUND_REGION_NTSC ;or #SOUND_REGION_PAL, or #SOUND_REGION_DENDY
  1309. 0C120 85 50 sta sound_param_byte_0
  1310. 0C122 A9 15 lda #<(song_list)
  1311. 0C124 85 53 sta sound_param_word_0
  1312. 0C126 A9 8B lda #>(song_list)
  1313. 0C128 85 54 sta sound_param_word_0+1
  1314. 0C12A A9 27 lda #<(sfx_list)
  1315. 0C12C 85 55 sta sound_param_word_1
  1316. 0C12E A9 8B lda #>(sfx_list)
  1317. 0C130 85 56 sta sound_param_word_1+1
  1318. 0C132 A9 53 lda #<(instrument_list)
  1319. 0C134 85 57 sta sound_param_word_2
  1320. 0C136 A9 8B lda #>(instrument_list)
  1321. 0C138 85 58 sta sound_param_word_2+1
  1322. 0C13A ;lda #<dpcm_list
  1323. 0C13A ;sta sound_param_word_3
  1324. 0C13A ;lda #>dpcm_list
  1325. 0C13A ;sta sound_param_word_3+1
  1326. 0C13A 20 50 80 jsr sound_initialize
  1327. 0C13D
  1328. 0C13D
  1329. 0C13D 98 48 AC 21 06 20 83 C5.. ReturnBank
  1330. 0C147
  1331. 0C147
  1332. 0C147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1333. 0C147 ;;; Triggers
  1334. 0C147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1335. 0C147 A9 00 LDA #INIT_TRIG_00
  1336. 0C149 8D 00 06 STA screenTriggers+0
  1337. 0C14C A9 00 LDA #INIT_TRIG_01
  1338. 0C14E 8D 01 06 STA screenTriggers+1
  1339. 0C151 A9 00 LDA #INIT_TRIG_02
  1340. 0C153 8D 02 06 STA screenTriggers+2
  1341. 0C156 A9 00 LDA #INIT_TRIG_03
  1342. 0C158 8D 03 06 STA screenTriggers+3
  1343. 0C15B A9 00 LDA #INIT_TRIG_04
  1344. 0C15D 8D 04 06 STA screenTriggers+4
  1345. 0C160 A9 00 LDA #INIT_TRIG_05
  1346. 0C162 8D 05 06 STA screenTriggers+5
  1347. 0C165 A9 00 LDA #INIT_TRIG_06
  1348. 0C167 8D 06 06 STA screenTriggers+6
  1349. 0C16A A9 00 LDA #INIT_TRIG_07
  1350. 0C16C 8D 07 06 STA screenTriggers+7
  1351. 0C16F A9 00 LDA #INIT_TRIG_08
  1352. 0C171 8D 08 06 STA screenTriggers+8
  1353. 0C174 A9 00 LDA #INIT_TRIG_09
  1354. 0C176 8D 09 06 STA screenTriggers+9
  1355. 0C179 A9 00 LDA #INIT_TRIG_0a
  1356. 0C17B 8D 0A 06 STA screenTriggers+10
  1357. 0C17E A9 00 LDA #INIT_TRIG_0b
  1358. 0C180 8D 0B 06 STA screenTriggers+11
  1359. 0C183 A9 00 LDA #INIT_TRIG_0c
  1360. 0C185 8D 0C 06 STA screenTriggers+12
  1361. 0C188 A9 00 LDA #INIT_TRIG_0d
  1362. 0C18A 8D 0D 06 STA screenTriggers+13
  1363. 0C18D A9 00 LDA #INIT_TRIG_0e
  1364. 0C18F 8D 0E 06 STA screenTriggers+14
  1365. 0C192 A9 00 LDA #INIT_TRIG_0f
  1366. 0C194 8D 0F 06 STA screenTriggers+15
  1367. 0C197 A9 00 LDA #INIT_TRIG_10
  1368. 0C199 8D 10 06 STA screenTriggers+16
  1369. 0C19C A9 00 LDA #INIT_TRIG_11
  1370. 0C19E 8D 11 06 STA screenTriggers+17
  1371. 0C1A1 A9 00 LDA #INIT_TRIG_12
  1372. 0C1A3 8D 12 06 STA screenTriggers+18
  1373. 0C1A6 A9 00 LDA #INIT_TRIG_13
  1374. 0C1A8 8D 13 06 STA screenTriggers+19
  1375. 0C1AB A9 00 LDA #INIT_TRIG_14
  1376. 0C1AD 8D 14 06 STA screenTriggers+20
  1377. 0C1B0 A9 00 LDA #INIT_TRIG_15
  1378. 0C1B2 8D 15 06 STA screenTriggers+21
  1379. 0C1B5 A9 00 LDA #INIT_TRIG_16
  1380. 0C1B7 8D 16 06 STA screenTriggers+22
  1381. 0C1BA A9 00 LDA #INIT_TRIG_17
  1382. 0C1BC 8D 17 06 STA screenTriggers+23
  1383. 0C1BF A9 00 LDA #INIT_TRIG_18
  1384. 0C1C1 8D 18 06 STA screenTriggers+24
  1385. 0C1C4 A9 00 LDA #INIT_TRIG_19
  1386. 0C1C6 8D 19 06 STA screenTriggers+25
  1387. 0C1C9 A9 00 LDA #INIT_TRIG_1a
  1388. 0C1CB 8D 1A 06 STA screenTriggers+26
  1389. 0C1CE A9 00 LDA #INIT_TRIG_1b
  1390. 0C1D0 8D 1B 06 STA screenTriggers+27
  1391. 0C1D3 A9 00 LDA #INIT_TRIG_1c
  1392. 0C1D5 8D 1C 06 STA screenTriggers+28
  1393. 0C1D8 A9 00 LDA #INIT_TRIG_1d
  1394. 0C1DA 8D 1D 06 STA screenTriggers+29
  1395. 0C1DD A9 00 LDA #INIT_TRIG_1e
  1396. 0C1DF 8D 1E 06 STA screenTriggers+30
  1397. 0C1E2 A9 00 LDA #INIT_TRIG_1f
  1398. 0C1E4 8D 1F 06 STA screenTriggers+31
  1399. 0C1E7
  1400. 0C1E7
  1401. 0C1E7 ;;;;;;;;;;;;;;DELETE ME
  1402. 0C1E7 .include "GameData\InitializationScripts\hudVarInits.asm"
  1403. 0C1E7
  1404. 0C1E7 ;; UserDefined var init export. Saturday, March 6, 2021 6:48:13 PM
  1405. 0C1E7
  1406. 0C1E7 A9 03 LDA #3 ; User Defined Var 0
  1407. 0C1E9 85 A4 STA myLives
  1408. 0C1EB A9 05 LDA #5 ; User Defined Var 1
  1409. 0C1ED 85 A5 STA myAmmo
  1410. 0C1EF A9 00 LDA #0 ; User Defined Var 2
  1411. 0C1F1 85 A6 STA myKeys
  1412. 0C1F3 A9 00 LDA #0 ; User Defined Var 3
  1413. 0C1F5 85 A7 STA bulletTimer
  1414. 0C1F7 A9 05 LDA #5 ; User Defined Var 4
  1415. 0C1F9 85 A8 STA bossHealth
  1416. 0C1FB A9 00 LDA #0 ; User Defined Var 5
  1417. 0C1FD 85 A9 STA bulletTimer2
  1418. 0C1FF A9 03 LDA #3 ; User Defined Var 6
  1419. 0C201 85 AA STA player2Lives
  1420. 0C203
  1421. 0C203 A9 1E LDA #%00011110 ;;
  1422. 0C205 85 17 STA soft20010C207 4C 0E C4 JMP StartMainGameLoop
  1423. 0C20A ;6 NMI
  1424. 0C20A .include "Routines\BASE_4_5\System\NMI.asm"
  1425. 0C20A NMI:
  1426. 0C20A ;first push whatever is in the accumulator to the stack
  1427. 0C20A
  1428. 0C20A 48 PHA
  1429. 0C20B A5 16 LDA doNMI
  1430. 0C20D F0 03 BEQ dontSkipNMI
  1431. 0C20F 4C 07 C4 JMP skipWholeNMI
  1432. 0C212 dontSkipNMI:
  1433. 0C212
  1434. 0C212 A9 01 LDA #$01
  1435. 0C214 85 16 STA doNMI
  1436. 0C216 8A TXA
  1437. 0C217 48 PHA
  1438. 0C218 98 TYA
  1439. 0C219 48 PHA
  1440. 0C21A 08 PHP
  1441. 0C21B
  1442. 0C21B A5 00 LDA temp
  1443. 0C21D 48 PHA
  1444. 0C21E A5 01 LDA temp1
  1445. 0C220 48 PHA
  1446. 0C221 A5 02 LDA temp2
  1447. 0C223 48 PHA
  1448. 0C224 A5 03 LDA temp3
  1449. 0C226 48 PHA
  1450. 0C227 A5 04 LDA tempx
  1451. 0C229 48 PHA
  1452. 0C22A A5 05 LDA tempy
  1453. 0C22C 48 PHA
  1454. 0C22D A5 06 LDA tempz
  1455. 0C22F 48 PHA
  1456. 0C230
  1457. 0C230 A5 07 LDA tempA
  1458. 0C232 48 PHA
  1459. 0C233 A5 08 LDA tempB
  1460. 0C235 48 PHA
  1461. 0C236 A5 09 LDA tempC
  1462. 0C238 48 PHA
  1463. 0C239 A5 0A LDA tempD
  1464. 0C23B 48 PHA
  1465. 0C23C
  1466. 0C23C
  1467. 0C23C A5 0C LDA arg0_hold
  1468. 0C23E 48 PHA
  1469. 0C23F A5 0D LDA arg1_hold
  1470. 0C241 48 PHA
  1471. 0C242 A5 0E LDA arg2_hold
  1472. 0C244 48 PHA
  1473. 0C245 A5 0F LDA arg3_hold
  1474. 0C247 48 PHA
  1475. 0C248 A5 10 LDA arg4_hold
  1476. 0C24A 48 PHA
  1477. 0C24B A5 11 LDA arg5_hold
  1478. 0C24D 48 PHA
  1479. 0C24E A5 12 LDA arg6_hold
  1480. 0C250 48 PHA
  1481. 0C251 A5 13 LDA arg7_hold
  1482. 0C253 48 PHA
  1483. 0C254
  1484. 0C254
  1485. 0C254 A5 14 LDA temp16
  1486. 0C256 48 PHA
  1487. 0C257 A5 15 LDA temp16+1
  1488. 0C259 48 PHA
  1489. 0C25A
  1490. 0C25A A5 1B LDA pointer
  1491. 0C25C 48 PHA
  1492. 0C25D A5 1C LDA pointer+1
  1493. 0C25F 48 PHA
  1494. 0C260
  1495. 0C260 A5 1D LDA pointer2
  1496. 0C262 48 PHA
  1497. 0C263 A5 1E LDA pointer2+1
  1498. 0C265 48 PHA
  1499. 0C266
  1500. 0C266 A5 1F LDA pointer3
  1501. 0C268 48 PHA
  1502. 0C269 A5 20 LDA pointer3+1
  1503. 0C26B 48 PHA
  1504. 0C26C
  1505. 0C26C A5 33 LDA pointer6
  1506. 0C26E 48 PHA
  1507. 0C26F A5 34 LDA pointer6+1
  1508. 0C271 48 PHA
  1509. 0C272
  1510. 0C272 AD 20 06 LDA currentBank
  1511. 0C275 48 PHA
  1512. 0C276 AD 21 06 LDA prevBank
  1513. 0C279 48 PHA
  1514. 0C27A AD 22 06 LDA tempBank
  1515. 0C27D 48 PHA
  1516. 0C27E AD 23 06 LDA chrRamBank
  1517. 0C281 48 PHA
  1518. 0C282
  1519. 0C282
  1520. 0C282
  1521. 0C282 A5 1A LDA skipNMI
  1522. 0C284 F0 03 BEQ dontSkipNMI2
  1523. 0C286 4C 77 C3 JMP skipNMIstuff
  1524. 0C289 dontSkipNMI2:
  1525. 0C289
  1526. 0C289
  1527. 0C289
  1528. 0C289 A9 00 LDA #$00
  1529. 0C28B 8D 00 20 STA $2000
  1530. 0C28E A5 17 LDA soft2001
  1531. 0C290 8D 01 20 STA $2001
  1532. 0C293
  1533. 0C293 ;;;Set OAL DMA
  1534. 0C293 A9 00 LDA #$00
  1535. 0C295 8D 03 20 STA $2003
  1536. 0C298 A9 02 LDA #$02
  1537. 0C29A 8D 14 40 STA $4014
  1538. 0C29D ;; Load the Palette
  1539. 0C29D
  1540. 0C29D A5 17 LDA soft2001
  1541. 0C29F D0 03 BNE doScreenUpdates
  1542. 0C2A1 4C 56 C3 JMP skipScreenUpdates
  1543. 0C2A4 doScreenUpdates:
  1544. 0C2A4
  1545. 0C2A4 2C 02 20 bit $2002
  1546. 0C2A7 AD 24 06 LDA updateScreenData
  1547. 0C2AA 29 01 AND #%00000001
  1548. 0C2AC D0 03 BNE doPaletteUpdates
  1549. 0C2AE 4C D6 C2 JMP +
  1550. 0C2B1 doPaletteUpdates:
  1551. 0C2B1 .include "Routines\BASE_4_5\Game\DataLoadScripts\LoadBackgroundPalettes_NMI.asm"
  1552. 0C2B1 ;;Load background palettes
  1553. 0C2B1
  1554. 0C2B1 AD 02 20 LDA $2002
  1555. 0C2B4 A9 3F LDA #$3F
  1556. 0C2B6 8D 06 20 STA $2006
  1557. 0C2B9 A9 00 LDA #$00
  1558. 0C2BB 8D 06 20 STA $2006
  1559. 0C2BE A2 00 LDX #$00
  1560. 0C2C0 LoadBackgroundPal_NMI:
  1561. 0C2C0 BD 25 06 LDA bckPal,x
  1562. 0C2C3 8D 07 20 STA $2007
  1563. 0C2C6 E8 INX
  1564. 0C2C7 E0 10 CPX #$10
  1565. 0C2C9 D0 F5 BNE LoadBackgroundPal_NMI
  1566. 0C2CB
  1567. 0C2CB AD 24 06 LDA updateScreenData
  1568. 0C2CE 29 FE AND #%11111110
  1569. 0C2D0 8D 24 06 STA updateScreenData
  1570. 0C2D3
  1571. 0C2D3 ;;; this script runs in-line.0C2D3 4C 56 C3 JMP skipScreenUpdates
  1572. 0C2D6 +
  1573. 0C2D6 AD 24 06 LDA updateScreenData
  1574. 0C2D9 29 02 AND #%00000010
  1575. 0C2DB D0 03 BNE doSpritePaletteUpdates:
  1576. 0C2DD 4C 05 C3 JMP +
  1577. 0C2E0 doSpritePaletteUpdates:
  1578. 0C2E0 .include "Routines\BASE_4_5\Game\DataLoadScripts\LoadSpritePalettes_NMI.asm"
  1579. 0C2E0 ;;Load background palettes
  1580. 0C2E0
  1581. 0C2E0 AD 02 20 LDA $2002
  1582. 0C2E3 A9 3F LDA #$3F
  1583. 0C2E5 8D 06 20 STA $2006
  1584. 0C2E8 A9 10 LDA #$10
  1585. 0C2EA 8D 06 20 STA $2006
  1586. 0C2ED A2 00 LDX #$00
  1587. 0C2EF LoadSpritePal_NMI:
  1588. 0C2EF BD 35 06 LDA sprPal,x
  1589. 0C2F2 8D 07 20 STA $2007
  1590. 0C2F5 E8 INX
  1591. 0C2F6 E0 10 CPX #$10
  1592. 0C2F8 D0 F5 BNE LoadSpritePal_NMI
  1593. 0C2FA
  1594. 0C2FA AD 24 06 LDA updateScreenData
  1595. 0C2FD 29 FD AND #%11111101
  1596. 0C2FF 8D 24 06 STA updateScreenData
  1597. 0C302
  1598. 0C302 ;;; this script runs in-line.0C302 4C 56 C3 JMP skipScreenUpdates
  1599. 0C305 +
  1600. 0C305 AD 24 06 LDA updateScreenData
  1601. 0C308 29 04 AND #%00000100
  1602. 0C30A D0 03 BNE doColumnUpdate
  1603. 0C30C 4C 56 C3 JMP +
  1604. 0C30F doColumnUpdate:
  1605. 0C30F .include "Routines\BASE_4_5\Game\Subroutines\doUpdateScrollColumn.asm"
  1606. 0C30F ;;; This routine will spread over two frames.
  1607. 0C30F ;; The offset for where in the column is being drawn will be held in scrollOffsetCounter.
  1608. 0C30F ;; It will load 32 (#$20) tiles per frame, but not quite, because the screen is only
  1609. 0C30F ;; 240 px high. So there are 3 reads per tile, 12 per metatile...12x15 rows = 180.
  1610. 0C30F
  1611. 0C30F AC 8A 06 LDY scrollOffsetCounter
  1612. 0C312 A2 10 LDX #$10
  1613. 0C314 loop_LoadScrollColumn:
  1614. 0C314 B9 00 07 LDA scrollUpdateRam,y
  1615. 0C317 8D 06 20 STA $2006
  1616. 0C31A 8D FE 07 STA $07FE
  1617. 0C31D C8 INY
  1618. 0C31E
  1619. 0C31E B9 00 07 LDA scrollUpdateRam,y
  1620. 0C321 8D 06 20 STA $2006
  1621. 0C324 8D FF 07 STA $07FF
  1622. 0C327 C8 INY
  1623. 0C328
  1624. 0C328 B9 00 07 LDA scrollUpdateRam,y
  1625. 0C32B 8D 07 20 STA $2007
  1626. 0C32E C8 INY
  1627. 0C32F 98 TYA
  1628. 0C330 8D 8A 06 STA scrollOffsetCounter
  1629. 0C333 CD 8B 06 CMP maxScrollOffsetCounter ;; this should probably be variable.
  1630. 0C336 F0 06 BEQ doneUpdatingColumn
  1631. 0C338
  1632. 0C338 CA DEX
  1633. 0C339 D0 D9 BNE loop_LoadScrollColumn
  1634. 0C33B 4C 53 C3 JMP notDoneUpdatingColumn
  1635. 0C33E doneUpdatingColumn:
  1636. 0C33E AD 24 06 LDA updateScreenData
  1637. 0C341 29 FB AND #%11111011
  1638. 0C343 8D 24 06 STA updateScreenData
  1639. 0C346 AD 8C 06 LDA scrollByte
  1640. 0C349 29 FE AND #%11111110
  1641. 0C34B 8D 8C 06 STA scrollByte
  1642. 0C34E A9 00 LDA #$00
  1643. 0C350 8D 8A 06 STA scrollOffsetCounter
  1644. 0C353 notDoneUpdatingColumn:
  1645. 0C353
  1646. 0C353 0C353 4C 56 C3 JMP skipScreenUpdates
  1647. 0C356 +
  1648. 0C356
  1649. 0C356 skipScreenUpdates:
  1650. 0C356 ;; always do hud update, otherwise
  1651. 0C356 ;; it's possible that updates to tiles, attributes, or palettes
  1652. 0C356 ;; will cause a skip in hud update.
  1653. 0C356 ;.include ROOT\DataLoadScripts\LoadHudData.asm
  1654. 0C356
  1655. 0C356 AD 89 06 LDA camY_hi
  1656. 0C359 0A ASL
  1657. 0C35A 0A ASL
  1658. 0C35B 0A ASL
  1659. 0C35C 0A ASL
  1660. 0C35D 18 CLC
  1661. 0C35E 6D 86 06 ADC camX_hi
  1662. 0C361 8D 8D 06 STA camScreen
  1663. 0C364 ;LDA camScreen ;; bit 0, determines which nametable we are looking at.
  1664. 0C364
  1665. 0C364
  1666. 0C364
  1667. 0C364 29 01 AND #%00000001
  1668. 0C366 09 90 ORA #%10010000
  1669. 0C368
  1670. 0C368 8D 00 20 STA $2000
  1671. 0C36B
  1672. 0C36B
  1673. 0C36B AD 85 06 LDA camX
  1674. 0C36E 8D 05 20 STA $2005 ;reset scroll values to zero
  1675. 0C371 AD 88 06 LDA camY
  1676. 0C374 8D 05 20 STA $2005 ;reset scroll values to zero
  1677. 0C377
  1678. 0C377
  1679. 0C377 skipNMIstuff:
  1680. 0C377
  1681. 0C377
  1682. 0C377
  1683. 0C377 E6 18 INC vBlankTimer
  1684. 0C379 E6 19 INC randomSeed
  1685. 0C37B
  1686. 0C37B ;; music player things
  1687. 0C37B
  1688. 0C37B
  1689. 0C37B 98 48 AD 20 06 8D 21 06.. SwitchBank #$1B ;; music bank
  1690. 0C38A 20 45 80 JSR doSoundEngineUpdate
  1691. 0C38D 98 48 AC 21 06 20 83 C5.. ReturnBank
  1692. 0C397
  1693. 0C397
  1694. 0C397 68 PLA
  1695. 0C398 8D 23 06 STA chrRamBank
  1696. 0C39B 68 PLA
  1697. 0C39C 8D 22 06 STA tempBank
  1698. 0C39F 68 PLA
  1699. 0C3A0 8D 21 06 STA prevBank
  1700. 0C3A3 68 PLA
  1701. 0C3A4 8D 20 06 STA currentBank
  1702. 0C3A7
  1703. 0C3A7 68 PLA
  1704. 0C3A8 85 34 STA pointer6+1
  1705. 0C3AA 68 PLA
  1706. 0C3AB 85 33 STA pointer6
  1707. 0C3AD 68 PLA
  1708. 0C3AE 85 20 STA pointer3+1
  1709. 0C3B0 68 PLA
  1710. 0C3B1 85 1F STA pointer3
  1711. 0C3B3
  1712. 0C3B3 68 PLA
  1713. 0C3B4 85 1E STA pointer2+1
  1714. 0C3B6 68 PLA
  1715. 0C3B7 85 1D STA pointer2
  1716. 0C3B9
  1717. 0C3B9 68 PLA
  1718. 0C3BA 85 1C STA pointer+1
  1719. 0C3BC 68 PLA
  1720. 0C3BD 85 1B STA pointer
  1721. 0C3BF
  1722. 0C3BF 68 PLA
  1723. 0C3C0 85 15 STA temp16+1
  1724. 0C3C2 68 PLA
  1725. 0C3C3 85 14 STA temp16
  1726. 0C3C5
  1727. 0C3C5 68 PLA
  1728. 0C3C6 85 13 STA arg7_hold
  1729. 0C3C8 68 PLA
  1730. 0C3C9 85 12 STA arg6_hold
  1731. 0C3CB 68 PLA
  1732. 0C3CC 85 11 STA arg5_hold
  1733. 0C3CE 68 PLA
  1734. 0C3CF 85 10 STA arg4_hold
  1735. 0C3D1 68 PLA
  1736. 0C3D2 85 0F STA arg3_hold
  1737. 0C3D4 68 PLA
  1738. 0C3D5 85 0E STA arg2_hold
  1739. 0C3D7 68 PLA
  1740. 0C3D8 85 0D STA arg1_hold
  1741. 0C3DA 68 PLA
  1742. 0C3DB 85 0C STA arg0_hold
  1743. 0C3DD
  1744. 0C3DD 68 PLA
  1745. 0C3DE 85 0A STA tempD
  1746. 0C3E0 68 PLA
  1747. 0C3E1 85 09 STA tempC
  1748. 0C3E3 68 PLA
  1749. 0C3E4 85 08 STA tempB
  1750. 0C3E6 68 PLA
  1751. 0C3E7 85 07 STA tempA
  1752. 0C3E9
  1753. 0C3E9 68 PLA
  1754. 0C3EA 85 06 STA tempz
  1755. 0C3EC 68 PLA
  1756. 0C3ED 85 05 STA tempy
  1757. 0C3EF 68 PLA
  1758. 0C3F0 85 04 STA tempx
  1759. 0C3F2 68 PLA
  1760. 0C3F3 85 03 STA temp3
  1761. 0C3F5 68 PLA
  1762. 0C3F6 85 02 STA temp2
  1763. 0C3F8 68 PLA
  1764. 0C3F9 85 01 STA temp1
  1765. 0C3FB 68 PLA
  1766. 0C3FC 85 00 STA temp
  1767. 0C3FE
  1768. 0C3FE A9 00 LDA #$00
  1769. 0C400 85 16 STA doNMI
  1770. 0C402
  1771. 0C402 28 PLP
  1772. 0C403 68 PLA
  1773. 0C404 A8 TAY
  1774. 0C405 68 PLA
  1775. 0C406 AA TAX
  1776. 0C407 skipWholeNMI:
  1777. 0C407 A9 00 LDA #$00
  1778. 0C409 8D 45 06 STA waiting
  1779. 0C40C 68 PLA
  1780. 0C40D
  1781. 0C40D
  1782. 0C40D 40 RTI0C40E ;7. main game loop
  1783. 0C40E StartMainGameLoop:
  1784. 0C40E .include "Routines\BASE_4_5\Game\MainGameLoop.asm"
  1785. 0C40E ;;; main game loop.
  1786. 0C40E
  1787. 0C40E MainGameLoop:
  1788. 0C40E A5 18 LDA vBlankTimer
  1789. 0C410 vBlankTimerLoop:
  1790. 0C410 C5 18 CMP vBlankTimer
  1791. 0C412 F0 FC BEQ vBlankTimerLoop
  1792. 0C414
  1793. 0C414
  1794. 0C414 AD AB 06 LDA gameHandler
  1795. 0C417 29 80 AND #%10000000
  1796. 0C419 F0 03 BEQ dontSkipNormalGameLoop
  1797. 0C41B 4C 8F C4 JMP skipNormalGameLoop
  1798. 0C41E dontSkipNormalGameLoop:
  1799. 0C41E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1800. 0C41E ;; Handles box updates that need to be carried over a frame.
  1801. 0C41E AD B5 06 LDA queueFlags
  1802. 0C421 29 05 AND #%00000101
  1803. 0C423 D0 03 BNE doBoxUpdate
  1804. 0C425 4C 33 C4 JMP dontDoBoxUpdate
  1805. 0C428 doBoxUpdate:
  1806. 0C428 8A TXA
  1807. 0C429 48 PHA
  1808. 0C42A 98 TYA
  1809. 0C42B 48 PHA
  1810. 0C42C 20 CC E4 JSR doDrawBox
  1811. 0C42F 68 PLA
  1812. 0C430 A8 TAY
  1813. 0C431 68 PLA
  1814. 0C432 AA TAX
  1815. 0C433
  1816. 0C433 dontDoBoxUpdate
  1817. 0C433
  1818. 0C433 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1819. 0C433 ;; handles text updates that need to be carried over a frame.
  1820. 0C433 AD C0 06 LDA textHandler
  1821. 0C436 F0 03 BEQ noTextUpdates
  1822. 0C438 20 37 DE JSR doDrawText
  1823. 0C43B noTextUpdates:
  1824. 0C43B ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1825. 0C43B ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1826. 0C43B 20 09 EF JSR doHandleInputReads
  1827. 0C43E A9 00 LDA #$00
  1828. 0C440 85 2C STA spriteRamPointer
  1829. 0C442 98 48 AD 20 06 8D 21 06.. SwitchBank #$18
  1830. 0C451 20 50 80 JSR doScreenPreDraw
  1831. 0C454 98 48 AC 21 06 20 83 C5.. ReturnBank
  1832. 0C45E
  1833. 0C45E 20 BC E9 JSR doHandleObjects
  1834. 0C461 20 05 F3 JSR doCamera
  1835. 0C464 ;;;;;;;;;;;;;;;;;; SET GAME SCREEN
  1836. 0C464 ;;;;;; IN THE EVENT THERE IS NO ATTATCHED CAM SCRIPT TO DO IT
  1837. 0C464
  1838. 0C464 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1839. 0C464 98 48 AD 20 06 8D 21 06.. SwitchBank #$18
  1840. 0C473 20 FD 80 JSR doScreenPostDraw
  1841. 0C476 .include "Routines\BASE_4_5\Game\Space Birds\Game\handleGameTimer_shooter.asm"
  1842. 0C476 A5 A7 LDA bulletTimer
  1843. 0C478 F0 02 BEQ +skip
  1844. 0C47A C6 A7 DEC bulletTimer
  1845. 0C47C +skip
  1846. 0C47C
  1847. 0C47C A5 A9 LDA bulletTimer2
  1848. 0C47E F0 02 BEQ +skip
  1849. 0C480 C6 A9 DEC bulletTimer2
  1850. 0C482 +skip
  1851. 0C482 98 48 AC 21 06 20 83 C5.. ReturnBank
  1852. 0C48C 20 ED C8 JSR doCleanUpSpriteRam
  1853. 0C48F ;JSR doHandleUpdateCamera
  1854. 0C48F skipNormalGameLoop:
  1855. 0C48F 20 6B E3 JSR doHandleUpdateScreen
  1856. 0C492 98 48 AD 20 06 8D 21 06.. SwitchBank #$1B
  1857. 0C4A1 20 00 80 JSR doHandleUpdateMusic
  1858. 0C4A4
  1859. 0C4A4
  1860. 0C4A4 98 48 AC 21 06 20 83 C5.. ReturnBank
  1861. 0C4AE 4C 0E C4 JMP MainGameLoop0C4B1 ;8. subroutines
  1862. 0C4B1 .include "GameData\ScriptTables.asm"
  1863. 0C4B1 ;; *************** ScriptTables.asm ***************
  1864. 0C4B1 ;; Script link export. Saturday, March 6, 2021 6:48:13 PM
  1865. 0C4B1 ScriptAddressLo:
  1866. 0C4B1 6C 90 B4 D8 FC 0F 83 F7.. .db #<Script00, #<Script01, #<Script02, #<Script03, #<Script04, #<Script05, #<Script06, #<Script07, #<Script08, #<Script09
  1867. 0C4BB ScriptAddressHi:
  1868. 0C4BB F7 F7 F7 F7 F7 F8 F8 F8.. .db #>Script00, #>Script01, #>Script02, #>Script03, #>Script04, #>Script05, #>Script06, #>Script07, #>Script08, #>Script09
  1869. 0C4C5
  1870. 0C4C5 TargetScriptBank:
  1871. 0C4C5 14 14 14 14 14 14 14 14.. .db #DATABANK1, #DATABANK1, #DATABANK1, #DATABANK1, #DATABANK1, #DATABANK1, #DATABANK1, #DATABANK1, #DATABANK1, #DATABANK1
  1872. 0C4CF
  1873. 0C4CF ;;=======================PRESSED=======================
  1874. 0C4CF DefinedInputs_Pressed:
  1875. 0C4CF 01 01 08 08 04 .db #%00000001, #%00000001, #%00001000, #%00001000, #%00000100
  1876. 0C4D4
  1877. 0C4D4 DefinedScriptGameStates_Pressed:
  1878. 0C4D4 00 00 01 02 00 .db #$00, #$00, #$01, #$02, #$00
  1879. 0C4D9
  1880. 0C4D9 DefinedTargetObjects_Pressed:
  1881. 0C4D9 00 01 00 00 00 .db #$00, #$01, #$00, #$00, #$00
  1882. 0C4DE
  1883. 0C4DE DefinedTargetController_Pressed:
  1884. 0C4DE 00 01 00 00 00 .db #$00, #$01, #$00, #$00, #$00
  1885. 0C4E3
  1886. 0C4E3 TargetState_Pressed:
  1887. 0C4E3 00 00 00 00 00 .db #$00, #$00, #$00, #$00, #$00
  1888. 0C4E8
  1889. 0C4E8 DefinedTargetScripts_Pressed:
  1890. 0C4E8 06 07 08 08 09 .db #$06, #$07, #$08, #$08, #$09
  1891. 0C4ED
  1892. 0C4ED ;;=======================RELEASE=======================
  1893. 0C4ED DefinedInputs_Released:
  1894. 0C4ED 80 20 40 10 80 20 40 10 .db #%10000000, #%00100000, #%01000000, #%00010000, #%10000000, #%00100000, #%01000000, #%00010000
  1895. 0C4F5
  1896. 0C4F5 DefinedScriptGameStates_Released:
  1897. 0C4F5 00 00 00 00 00 00 00 00 .db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
  1898. 0C4FD
  1899. 0C4FD DefinedTargetObjects_Released:
  1900. 0C4FD 00 00 00 00 01 01 01 01 .db #$00, #$00, #$00, #$00, #$01, #$01, #$01, #$01
  1901. 0C505
  1902. 0C505 DefinedTargetController_Released:
  1903. 0C505 00 00 00 00 01 01 01 01 .db #$00, #$00, #$00, #$00, #$01, #$01, #$01, #$01
  1904. 0C50D
  1905. 0C50D TargetState_Released:
  1906. 0C50D 00 00 00 00 00 00 00 00 .db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
  1907. 0C515
  1908. 0C515 DefinedTargetScripts_Released:
  1909. 0C515 04 04 04 04 04 04 04 04 .db #$04, #$04, #$04, #$04, #$04, #$04, #$04, #$04
  1910. 0C51D
  1911. 0C51D ;;=======================HOLD=======================
  1912. 0C51D DefinedInputs_Held:
  1913. 0C51D 80 20 40 10 80 20 40 10 .db #%10000000, #%00100000, #%01000000, #%00010000, #%10000000, #%00100000, #%01000000, #%00010000
  1914. 0C525
  1915. 0C525 DefinedScriptGameStates_Held:
  1916. 0C525 00 00 00 00 00 00 00 00 .db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
  1917. 0C52D
  1918. 0C52D DefinedTargetObjects_Held:
  1919. 0C52D 00 00 00 00 01 01 01 01 .db #$00, #$00, #$00, #$00, #$01, #$01, #$01, #$01
  1920. 0C535
  1921. 0C535 DefinedTargetController_Held:
  1922. 0C535 00 00 00 00 01 01 01 01 .db #$00, #$00, #$00, #$00, #$01, #$01, #$01, #$01
  1923. 0C53D
  1924. 0C53D TargetState_Held:
  1925. 0C53D 00 00 00 00 00 00 00 00 .db #$00, #$00, #$00, #$00, #$00, #$00, #$00, #$00
  1926. 0C545
  1927. 0C545 DefinedTargetScripts_Held:
  1928. 0C545 00 01 02 03 00 01 02 03 .db #$00, #$01, #$02, #$03, #$00, #$01, #$02, #$03
  1929. 0C54D
  1930. 0C54D .include "Routines\BASE_4_5\System\simpleMath.asm"
  1931. 0C54D
  1932. 0C54D
  1933. 0C54D
  1934. 0C54D
  1935. 0C54D valueAddLoop:
  1936. 0C54D ;; the accumulator holds how much to add by.
  1937. 0C54D ;; x holds what place is being added to.
  1938. 0C54D 18 clc
  1939. 0C54E 75 83 adc value,x
  1940. 0C550 C9 0A cmp #$0A
  1941. 0C552 90 0F bcc skipCarryDecValue
  1942. 0C554 38 sec
  1943. 0C555 E9 0A sbc #$0A
  1944. 0C557 95 83 sta value,x
  1945. 0C559 E8 inx
  1946. 0C55A E0 08 cpx #$08 ;; how many 'places' the value has
  1947. 0C55C B0 07 bcs overflowThisNumber
  1948. 0C55E A9 01 lda #$01
  1949. 0C560 4C 4D C5 jmp valueAddLoop
  1950. 0C563 skipCarryDecValue:
  1951. 0C563 95 83 sta value,x
  1952. 0C565 overflowThisNumber:
  1953. 0C565 60 rts
  1954. 0C566
  1955. 0C566
  1956. 0C566 valueSubLoop:
  1957. 0C566 ;; temp holds the value to subtract.
  1958. 0C566 B5 83 lda value,x
  1959. 0C568 38 sec
  1960. 0C569 E5 00 sbc temp
  1961. 0C56B C9 00 cmp #$00
  1962. 0C56D 10 11 bpl skipCarryDecValue2
  1963. 0C56F 18 clc
  1964. 0C570 69 0A adc #$0A
  1965. 0C572 95 83 sta value,x
  1966. 0C574 E8 inx
  1967. 0C575 E0 08 cpx #$08 ;; how many 'places' the value has
  1968. 0C577 B0 09 bcs underflowThisNumber
  1969. 0C579 A9 01 lda #$01
  1970. 0C57B 85 00 STA temp
  1971. 0C57D 4C 66 C5 jmp valueSubLoop
  1972. 0C580 skipCarryDecValue2:
  1973. 0C580 95 83 sta value,x
  1974. 0C582 underflowThisNumber:
  1975. 0C582 60 rts0C583 .include "Routines\BASE_4_5\Game\Space Birds\LoadAllSubroutines.asm"
  1976. 0C583 .include Routines\BASE_4_5\\Game\Subroutines\doBankswitchY.asm
  1977. 0C583 doBankswitchY:
  1978. 0C583 ;STY currentBank
  1979. 0C583 8C 20 06 STY currentBank
  1980. 0C586 bankswitchNoSave:
  1981. 0C586 ;LDA #$00
  1982. 0C586 ;ORA banktable, y
  1983. 0C586 ;STA banktable,y
  1984. 0C586 AD 20 06 LDA currentBank
  1985. 0C589 29 1F AND #%00011111
  1986. 0C58B 0D 23 06 ORA chrRamBank
  1987. 0C58E
  1988. 0C58E
  1989. 0C58E 8D 00 C0 STA $c000
  1990. 0C591
  1991. 0C591 60 RTS 0C592 .include Routines\BASE_4_5\\Game\Subroutines\doLoadBackgroundPalette.asm
  1992. 0C592 doLoadBackgroundPalettes:
  1993. 0C592 ;; This is tied to the macro LoadBackgroundPalettes.
  1994. 0C592 ;; It uses bank and 16 bit label.
  1995. 0C592 8A TXA
  1996. 0C593 48 PHA
  1997. 0C594 98 TYA
  1998. 0C595 48 PHA
  1999. 0C596 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2000. 0C596 ;Get Palette Label based on INDEX
  2001. 0C596 98 48 AD 20 06 8D 21 06.. SwitchBank #$16
  2002. 0C5A5 A4 0C LDY arg0_hold
  2003. 0C5A7 B9 00 84 LDA GameBckPalLo,y
  2004. 0C5AA 85 14 STA temp16
  2005. 0C5AC B9 40 84 LDA GameBckPalHi,y
  2006. 0C5AF 85 15 STA temp16+1
  2007. 0C5B1
  2008. 0C5B1
  2009. 0C5B1 A0 00 LDY #$00
  2010. 0C5B3 loop_LoadBackgroundPalette:
  2011. 0C5B3 B1 14 LDA (temp16),y
  2012. 0C5B5 99 25 06 STA bckPal,y
  2013. 0C5B8 C8 INY
  2014. 0C5B9 C0 10 CPY #$10
  2015. 0C5BB D0 F6 BNE loop_LoadBackgroundPalette
  2016. 0C5BD ;;;; end of loop.
  2017. 0C5BD AD 24 06 LDA updateScreenData
  2018. 0C5C0 09 01 ORA #%00000001 ;; palette
  2019. 0C5C2 8D 24 06 STA updateScreenData
  2020. 0C5C5
  2021. 0C5C5
  2022. 0C5C5 98 48 AC 21 06 20 83 C5.. ReturnBank
  2023. 0C5CF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2024. 0C5CF
  2025. 0C5CF 68 PLA
  2026. 0C5D0 A8 TAY
  2027. 0C5D1 68 PLA
  2028. 0C5D2 AA TAX
  2029. 0C5D3 60 RTS0C5D4 .include Routines\BASE_4_5\\Game\Subroutines\doLoadObjectPalette.asm
  2030. 0C5D4 doLoadObjectPalettes:
  2031. 0C5D4 ;; This is tied to the macro LoadObjectPalettes.
  2032. 0C5D4 ;; It uses bank and 16 bit label.
  2033. 0C5D4 8A TXA
  2034. 0C5D5 48 PHA
  2035. 0C5D6 98 TYA
  2036. 0C5D7 48 PHA
  2037. 0C5D8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2038. 0C5D8 ;Get Palette Label based on INDEX
  2039. 0C5D8 98 48 AD 20 06 8D 21 06.. SwitchBank #$16
  2040. 0C5E7 A4 0C LDY arg0_hold
  2041. 0C5E9 B9 80 84 LDA ObjectPaletteDataLo,y
  2042. 0C5EC 85 14 STA temp16
  2043. 0C5EE B9 C0 84 LDA ObjectPaletteDataHi,y
  2044. 0C5F1 85 15 STA temp16+1
  2045. 0C5F3
  2046. 0C5F3
  2047. 0C5F3 A0 00 LDY #$00
  2048. 0C5F5 loop_LoadSpritePalette:
  2049. 0C5F5 B1 14 LDA (temp16),y
  2050. 0C5F7 99 35 06 STA sprPal,y
  2051. 0C5FA C8 INY
  2052. 0C5FB C0 10 CPY #$10
  2053. 0C5FD D0 F6 BNE loop_LoadSpritePalette
  2054. 0C5FF ;;;; end of loop.
  2055. 0C5FF AD 24 06 LDA updateScreenData
  2056. 0C602 09 02 ORA #%00000010 ;; sprite palette
  2057. 0C604 8D 24 06 STA updateScreenData
  2058. 0C607
  2059. 0C607
  2060. 0C607 98 48 AC 21 06 20 83 C5.. ReturnBank
  2061. 0C611 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2062. 0C611
  2063. 0C611 68 PLA
  2064. 0C612 A8 TAY
  2065. 0C613 68 PLA
  2066. 0C614 AA TAX
  2067. 0C615 60 RTS0C616 .include Routines\BASE_4_5\\Game\Subroutines\doLoadObjectSubPalette.asm
  2068. 0C616 doLoadObjectSubPalettes:
  2069. 0C616 ;; This is tied to the macro LoadObjectPalettes.
  2070. 0C616 ;; It uses bank and 16 bit label.
  2071. 0C616 8A TXA
  2072. 0C617 48 PHA
  2073. 0C618 98 TYA
  2074. 0C619 48 PHA
  2075. 0C61A ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2076. 0C61A ;Get Palette Label based on INDEX
  2077. 0C61A 98 48 AD 20 06 8D 21 06.. SwitchBank #$16
  2078. 0C629 A4 0C LDY arg0_hold
  2079. 0C62B B9 80 84 LDA ObjectPaletteDataLo,y
  2080. 0C62E 85 14 STA temp16
  2081. 0C630 B9 C0 84 LDA ObjectPaletteDataHi,y
  2082. 0C633 85 15 STA temp16+1
  2083. 0C635
  2084. 0C635 A6 0D LDX arg1_hold
  2085. 0C637 A0 00 LDY #$00
  2086. 0C639 loop_LoadSpriteSubPalette:
  2087. 0C639 B1 14 LDA (temp16),y
  2088. 0C63B 9D 35 06 STA sprPal,x
  2089. 0C63E C8 INY
  2090. 0C63F E8 INx
  2091. 0C640 C0 04 CPY #$04
  2092. 0C642 D0 F5 BNE loop_LoadSpriteSubPalette
  2093. 0C644 ;;;; end of loop.
  2094. 0C644 AD 24 06 LDA updateScreenData
  2095. 0C647 09 02 ORA #%00000010 ;; sprite palette
  2096. 0C649 8D 24 06 STA updateScreenData
  2097. 0C64C
  2098. 0C64C
  2099. 0C64C 98 48 AC 21 06 20 83 C5.. ReturnBank
  2100. 0C656 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2101. 0C656
  2102. 0C656 68 PLA
  2103. 0C657 A8 TAY
  2104. 0C658 68 PLA
  2105. 0C659 AA TAX
  2106. 0C65A 60 RTS0C65B .include Routines\BASE_4_5\\Game\Subroutines\doLoadChrRam.asm
  2107. 0C65B doLoadChrRam:
  2108. 0C65B ;;; this uses the LoadChrData macro
  2109. 0C65B 98 48 AD 20 06 8D 21 06.. SwitchBank tempBank
  2110. 0C66B 2C 02 20 bit $2002
  2111. 0C66E A5 0D LDA arg1_hold
  2112. 0C670 8D 06 20 STA $2006
  2113. 0C673 A5 0E LDA arg2_hold
  2114. 0C675 8D 06 20 STA $2006
  2115. 0C678 ;arg3_hold holds the number of tiles to be drawn.
  2116. 0C678 LoadTilesOuterLoop
  2117. 0C678 A9 10 LDA #$10
  2118. 0C67A 85 01 STA temp1 ;; tile counter.
  2119. 0C67C A0 00 LDY #$00
  2120. 0C67E LoadTilesLoop:
  2121. 0C67E A2 10 LDX #$10
  2122. 0C680 LoadChrRamLoop:
  2123. 0C680 B1 14 LDA (temp16),y
  2124. 0C682 8D 07 20 STA $2007
  2125. 0C685 C8 INY
  2126. 0C686 CA DEX
  2127. 0C687 D0 F7 BNE LoadChrRamLoop
  2128. 0C689 C6 01 DEC temp1
  2129. 0C68B D0 09 BNE keepLoading
  2130. 0C68D ;;; now a full tile has been loaded.
  2131. 0C68D C6 0F DEC arg3_hold
  2132. 0C68F F0 09 BEQ doneLoadingTiles
  2133. 0C691 E6 15 INC temp16+1
  2134. 0C693 4C 78 C6 JMP LoadTilesOuterLoop
  2135. 0C696 keepLoading:
  2136. 0C696 C6 0F DEC arg3_hold
  2137. 0C698 D0 E4 BNE LoadTilesLoop
  2138. 0C69A doneLoadingTiles:
  2139. 0C69A 98 48 AC 21 06 20 83 C5.. ReturnBank
  2140. 0C6A4 60 RTS
  2141. 0C6A5
  2142. 0C6A5
  2143. 0C6A5 .include Routines\BASE_4_5\\Game\Subroutines\doLoadNametableData.asm
  2144. 0C6A5 doLoadNametableData:
  2145. 0C6A5 ;;; currently, arg0_hold has the bank data
  2146. 0C6A5 ;;; arg1_hold has the screen index, if it is needed.
  2147. 0C6A5 ;;; arg2_hold has screen bits.
  2148. 0C6A5 ;;; bit 0 = overworld (0) underworld (1)
  2149. 0C6A5 ;;; bit 1 = metaTable (0) 8x8 table (1)
  2150. 0C6A5 ;arg0 = screen bank
  2151. 0C6A5 ;arg3_hold = columns to load
  2152. 0C6A5 ;arg4_hold = rows to load
  2153. 0C6A5 ;arg5_hold = start position hi
  2154. 0C6A5 ;arg6_hold = start position lo
  2155. 0C6A5 ;arg7_hold = start column
  2156. 0C6A5
  2157. 0C6A5 ;;; decreasing arg3_holder / arg4_holder will track if there are more columns/rows to load. If zero, that part is done.
  2158. 0C6A5 A5 12 LDA arg6_hold
  2159. 0C6A7 85 1B STA pointer
  2160. 0C6A9 A5 11 LDA arg5_hold
  2161. 0C6AB 85 1C STA pointer+1
  2162. 0C6AD
  2163. 0C6AD A5 0F LDA arg3_hold
  2164. 0C6AF 85 08 STA tempB ; we will use tempB to hold the number of columns
  2165. 0C6B1 ; so when we start a new row, we can return to the proper number of columns.
  2166. 0C6B1 ;;; now we can use the (pointer) to know the PPU address to write the nametable.
  2167. 0C6B1 ;;; whilte (temp16) denotes where the nametable data is being pulled from.
  2168. 0C6B1
  2169. 0C6B1 98 48 AD 20 06 8D 21 06.. SwitchBank arg0_hold;temp
  2170. 0C6C0
  2171. 0C6C0 A4 13 LDY arg7_hold ;;; in what column should the nametable begin?
  2172. 0C6C2 loop_LoadNametableMeta:
  2173. 0C6C2 A5 1C LDA pointer+1
  2174. 0C6C4 8D 06 20 STA $2006
  2175. 0C6C7 A5 1B LDA pointer
  2176. 0C6C9 8D 06 20 STA $2006
  2177. 0C6CC B1 14 LDA (temp16),y
  2178. 0C6CE 85 00 STA temp
  2179. 0C6D0 ;;; now we have to do an evaluation, to compare this to potential "blank" values and paths.
  2180. 0C6D0 20 24 C7 JSR doGetSingleMetaTileValues
  2181. 0C6D3 20 A2 C7 JSR doDrawSingleMetatile
  2182. 0C6D6 doneDrawingThisMetatile:
  2183. 0C6D6 C8 INY
  2184. 0C6D7 C6 08 DEC tempB ;; is a surrogate for columns
  2185. 0C6D9 A5 08 LDA tempB
  2186. 0C6DB F0 0A BEQ doneWithMetaTileColumn
  2187. 0C6DD A5 1B LDA pointer
  2188. 0C6DF 18 CLC
  2189. 0C6E0 69 02 ADC #$02
  2190. 0C6E2 85 1B STA pointer
  2191. 0C6E4 4C C2 C6 JMP loop_LoadNametableMeta
  2192. 0C6E7 doneWithMetaTileColumn:
  2193. 0C6E7 C6 10 DEC arg4_hold
  2194. 0C6E9 A5 10 LDA arg4_hold
  2195. 0C6EB F0 2C BEQ noMoreMetaTilesToLoad
  2196. 0C6ED C9 08 CMP #$08
  2197. 0C6EF D0 03 BNE +dontWaitFrame
  2198. 0C6F1 20 FB C8 JSR doWaitFrame
  2199. 0C6F4 +dontWaitFrame
  2200. 0C6F4 A5 0F LDA arg3_hold
  2201. 0C6F6 85 08 STA tempB ;; resets the amount of columns.
  2202. 0C6F8 ;;;;; calculate based on the number of columns drawn
  2203. 0C6F8 ;;;;; where the "beginning of the column" should be,
  2204. 0C6F8 ;;;;; and skip down to the next free line.
  2205. 0C6F8 0A ASL
  2206. 0C6F9 85 09 STA tempC ;
  2207. 0C6FB ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2208. 0C6FB A5 1B LDA pointer
  2209. 0C6FD 18 CLC
  2210. 0C6FE 69 02 ADC #$02
  2211. 0C700 38 SEC
  2212. 0C701 E5 09 SBC tempC
  2213. 0C703 18 clc
  2214. 0C704 69 40 adc #$40
  2215. 0C706 85 1B STA pointer
  2216. 0C708 A5 1C LDA pointer+1
  2217. 0C70A 69 00 ADC #$00
  2218. 0C70C 85 1C STA pointer+1
  2219. 0C70E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2220. 0C70E ;;; now, calculate where y should read from
  2221. 0C70E ;;; based on the number of columns being drawn.
  2222. 0C70E 98 TYA
  2223. 0C70F 18 CLC
  2224. 0C710 69 10 ADC #$10
  2225. 0C712 38 SEC
  2226. 0C713 E5 0F SBC arg3_hold
  2227. 0C715 A8 TAY
  2228. 0C716 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2229. 0C716 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2230. 0C716 4C C2 C6 JMP loop_LoadNametableMeta
  2231. 0C719
  2232. 0C719
  2233. 0C719 noMoreMetaTilesToLoad:
  2234. 0C719
  2235. 0C719 98 48 AC 21 06 20 83 C5.. ReturnBank
  2236. 0C723 60 RTS
  2237. 0C724
  2238. 0C724
  2239. 0C724
  2240. 0C724
  2241. 0C724 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2242. 0C724 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2243. 0C724
  2244. 0C724 doGetSingleMetaTileValues:
  2245. 0C724 85 00 STA temp
  2246. 0C726
  2247. 0C726 AD 96 06 LDA screenLoadTemps
  2248. 0C729 29 80 AND #%10000000
  2249. 0C72B D0 59 BNE notPath
  2250. 0C72D A5 00 LDA temp
  2251. 0C72F ; CMP #BLANK_TILE ;; solid BLACK translate.
  2252. 0C72F C9 F5 CMP #$f5
  2253. 0C731 F0 0F BEQ isBlankTile
  2254. 0C733 C9 FD CMP #$FD
  2255. 0C735 F0 0B BEQ isBlankTile ;isFDtile ;; solid "RED" translate
  2256. 0C737 C9 FE CMP #$FE
  2257. 0C739 F0 07 BEQ isBlankTile ;isFEtile ;; solid "GREEN" translate
  2258. 0C73B C9 FF CMP #$FF
  2259. 0C73D F0 03 BEQ isBlankTile ;isFFtile ;; solid "BLACK" translate
  2260. 0C73F 4C 4F C7 JMP notBlankTile
  2261. 0C742 isBlankTile:
  2262. 0C742 ;;; it was a blank tile. They are all now blank tiles
  2263. 0C742 8D 53 06 STA updateTile_00
  2264. 0C745 8D 54 06 STA updateTile_01
  2265. 0C748 8D 55 06 STA updateTile_02
  2266. 0C74B 8D 56 06 STA updateTile_03
  2267. 0C74E 60 RTS
  2268. 0C74F
  2269. 0C74F notBlankTile:
  2270. 0C74F
  2271. 0C74F ;;;; check for screen modes.
  2272. 0C74F AD 46 06 LDA tileLayout
  2273. 0C752 C9 40 CMP #%01000000
  2274. 0C754 F0 17 BEQ checkForPathUpdates
  2275. 0C756 C9 60 CMP #%01100000
  2276. 0C758 F0 06 BEQ checkForPathUpdates1
  2277. 0C75A ;;;; THIS DOES NOT USE PATHS!!!
  2278. 0C75A ;;;; so just restore the temp value and proceed with metaTiles as if it wasn't a path value.
  2279. 0C75A A5 00 LDA temp
  2280. 0C75C 4C 86 C7 JMP notPath
  2281. 0C75F 60 RTS
  2282. 0C760
  2283. 0C760 checkForPathUpdates1:
  2284. 0C760 ;;;;; THIS MODE USES ONLY THE FIRST TWO "paths" AS PATHS.
  2285. 0C760 A5 00 LDA temp
  2286. 0C762 C9 A0 CMP #$A0
  2287. 0C764 F0 1C BEQ doPathUpdate
  2288. 0C766 C9 B0 CMP #$B0
  2289. 0C768 F0 18 BEQ doPathUpdate
  2290. 0C76A 4C 86 C7 JMP notPath
  2291. 0C76D
  2292. 0C76D checkForPathUpdates:
  2293. 0C76D ;;;;;; THIS MODE USES ALL FOUR "paths" AS PATHS.
  2294. 0C76D
  2295. 0C76D A5 00 LDA temp
  2296. 0C76F C9 80 CMP #$80
  2297. 0C771 F0 0F BEQ doPathUpdate
  2298. 0C773 C9 90 CMP #$90
  2299. 0C775 F0 0B BEQ doPathUpdate
  2300. 0C777 C9 A0 CMP #$A0
  2301. 0C779 F0 07 BEQ doPathUpdate
  2302. 0C77B C9 B0 CMP #$B0
  2303. 0C77D F0 03 BEQ doPathUpdate
  2304. 0C77F 4C 86 C7 JMP notPath
  2305. 0C782
  2306. 0C782 doPathUpdate:
  2307. 0C782
  2308. 0C782 ;; now we have to do evaluations of other tiles around us to know
  2309. 0C782 ;; exactly what to draw here.
  2310. 0C782 20 D2 C7 JSR handlePath
  2311. 0C785 60 RTS
  2312. 0C786 notPath:
  2313. 0C786 8D 53 06 STA updateTile_00
  2314. 0C789 E6 00 INC temp
  2315. 0C78B A5 00 LDA temp
  2316. 0C78D 8D 54 06 STA updateTile_01
  2317. 0C790 ;;; now, what we need is a row down from our current position...updateNT_pointer
  2318. 0C790 ;;; and temp, increased to its next row.
  2319. 0C790 18 CLC
  2320. 0C791 69 0F ADC #$0f
  2321. 0C793 85 00 STA temp
  2322. 0C795 A5 00 LDA temp
  2323. 0C797 8D 55 06 STA updateTile_02
  2324. 0C79A E6 00 INC temp
  2325. 0C79C A5 00 LDA temp
  2326. 0C79E 8D 56 06 STA updateTile_03
  2327. 0C7A1 60 RTS
  2328. 0C7A2
  2329. 0C7A2 doDrawSingleMetatile:
  2330. 0C7A2 A5 1C LDA pointer+1
  2331. 0C7A4 8D 06 20 STA $2006
  2332. 0C7A7 A5 1B LDA pointer
  2333. 0C7A9 8D 06 20 STA $2006
  2334. 0C7AC
  2335. 0C7AC AD 53 06 LDA updateTile_00
  2336. 0C7AF 8D 07 20 STA $2007 ;write 1
  2337. 0C7B2 AD 54 06 LDA updateTile_01
  2338. 0C7B5 8D 07 20 STA $2007 ;; write 2
  2339. 0C7B8
  2340. 0C7B8 ;;; now, what we need is a row down from our current position...pointer
  2341. 0C7B8 ;;; and temp, increased to its next row.
  2342. 0C7B8 A5 1C LDA pointer+1
  2343. 0C7BA 8D 06 20 STA $2006
  2344. 0C7BD
  2345. 0C7BD A5 1B LDA pointer
  2346. 0C7BF 18 CLC
  2347. 0C7C0 69 20 ADC #$20 ;; dont store it into pointer
  2348. 0C7C2 ;; because then it will be easy to just add 2 to
  2349. 0C7C2 ;; for the next place to write.
  2350. 0C7C2 8D 06 20 STA $2006
  2351. 0C7C5
  2352. 0C7C5 ;; now get the tile
  2353. 0C7C5 AD 55 06 LDA updateTile_02
  2354. 0C7C8 8D 07 20 STA $2007 ; write 3
  2355. 0C7CB AD 56 06 LDA updateTile_03
  2356. 0C7CE 8D 07 20 STA $2007 ; write 4
  2357. 0C7D1 60 RTS
  2358. 0C7D2
  2359. 0C7D2
  2360. 0C7D2
  2361. 0C7D2
  2362. 0C7D2
  2363. 0C7D2
  2364. 0C7D2
  2365. 0C7D2
  2366. 0C7D2
  2367. 0C7D2
  2368. 0C7D2
  2369. 0C7D2
  2370. 0C7D2
  2371. 0C7D2
  2372. 0C7D2 handlePath:
  2373. 0C7D2 8A TXA
  2374. 0C7D3 48 PHA
  2375. 0C7D4 98 TYA
  2376. 0C7D5 48 PHA
  2377. 0C7D6
  2378. 0C7D6 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  2379. 0C7D6 ;blank0C7D6
  2380. 0C7D6
  2381. 0C7D6 68 PLA
  2382. 0C7D7 A8 TAY
  2383. 0C7D8 68 PLA
  2384. 0C7D9 AA TAX
  2385. 0C7DA
  2386. 0C7DA 60 RTS
  2387. 0C7DB 0C7DB .include Routines\BASE_4_5\\Game\Subroutines\doLoadAttributeData.asm
  2388. 0C7DB doLoadAttributeData:
  2389. 0C7DB
  2390. 0C7DB ;;; attributes have 8 columns per screen and 7 1/2 rows per screen.
  2391. 0C7DB ;;;
  2392. 0C7DB
  2393. 0C7DB ;;; currently, arg0_hold has the bank data
  2394. 0C7DB ;;; arg1_hold has the screen index, if it is needed.
  2395. 0C7DB ;;; arg2_hold has screen bits.
  2396. 0C7DB ;;; bit 0 = overworld (0) underworld (1)
  2397. 0C7DB ;;; bit 1 = metaTable (0) 8x8 table (1)
  2398. 0C7DB ;arg0 = screen bank
  2399. 0C7DB ;arg3_hold = columns to load
  2400. 0C7DB ;arg4_hold = rows to load
  2401. 0C7DB ;arg5_hold = start position hi
  2402. 0C7DB ;arg6_hold = start position lo
  2403. 0C7DB ;arg7_hold = start column
  2404. 0C7DB
  2405. 0C7DB ;;; decreasing arg3_holder / arg4_holder will track if there are more columns/rows to load. If zero, that part is done.
  2406. 0C7DB
  2407. 0C7DB A5 12 LDA arg6_hold
  2408. 0C7DD 85 1B STA pointer
  2409. 0C7DF A5 11 LDA arg5_hold
  2410. 0C7E1 85 1C STA pointer+1
  2411. 0C7E3
  2412. 0C7E3 A5 0F LDA arg3_hold
  2413. 0C7E5 85 08 STA tempB ; we will use tempB to hold the number of columns
  2414. 0C7E7 ; so when we start a new row, we can return to the proper number of columns.
  2415. 0C7E7 ;;; now we can use the (pointer) to know the PPU address to write the nametable.
  2416. 0C7E7 ;;; whilte (temp16) denotes where the nametable data is being pulled from.
  2417. 0C7E7 98 48 AD 20 06 8D 21 06.. SwitchBank arg0_hold
  2418. 0C7F6 A4 13 LDY arg7_hold ;;; in what column should the column begin?
  2419. 0C7F8 loop_LoadAttTable:
  2420. 0C7F8 A5 1C LDA pointer+1
  2421. 0C7FA 8D 06 20 STA $2006
  2422. 0C7FD A5 1B LDA pointer
  2423. 0C7FF 8D 06 20 STA $2006
  2424. 0C802 B1 14 LDA (temp16),y
  2425. 0C804 8D 07 20 STA $2007
  2426. 0C807
  2427. 0C807 doneDrawingThisAttributeTile:
  2428. 0C807 C8 INY
  2429. 0C808 C6 08 DEC tempB ;; is a surrogate for columns
  2430. 0C80A A5 08 LDA tempB
  2431. 0C80C F0 0A BEQ doneWithAttributeColumn
  2432. 0C80E
  2433. 0C80E A5 1B LDA pointer
  2434. 0C810 18 CLC
  2435. 0C811 69 01 ADC #$01
  2436. 0C813 85 1B STA pointer
  2437. 0C815 4C F8 C7 JMP loop_LoadAttTable
  2438. 0C818 doneWithAttributeColumn:
  2439. 0C818 C6 10 DEC arg4_hold
  2440. 0C81A A5 10 LDA arg4_hold
  2441. 0C81C F0 1C BEQ noMoreAttributeTilesToLoad
  2442. 0C81E A5 0F LDA arg3_hold
  2443. 0C820 85 08 STA tempB
  2444. 0C822 A5 1B LDA pointer
  2445. 0C824 38 SEC
  2446. 0C825 E5 08 SBC tempB
  2447. 0C827 18 CLC
  2448. 0C828 69 08 ADC #$08 ;; skip down to next attribute row.
  2449. 0C82A 18 CLC
  2450. 0C82B 69 01 ADC #$01
  2451. 0C82D 85 1B STA pointer
  2452. 0C82F
  2453. 0C82F 98 TYA
  2454. 0C830 38 SEC
  2455. 0C831 E5 08 SBC tempB
  2456. 0C833 18 CLC
  2457. 0C834 69 08 ADC #$08
  2458. 0C836 A8 TAY
  2459. 0C837 4C F8 C7 JMP loop_LoadAttTable
  2460. 0C83A noMoreAttributeTilesToLoad:
  2461. 0C83A 98 48 AC 21 06 20 83 C5.. ReturnBank
  2462. 0C844 60 RTS0C845 .include Routines\BASE_4_5\\Game\Subroutines\doLoadCollisionTable.asm
  2463. 0C845 doLoadCollisionTable:
  2464. 0C845 ;;; currently, arg0_hold has the bank data
  2465. 0C845 ;;; arg1_hold has the screen index, if it is needed.
  2466. 0C845 ;;; arg2_hold has screen bits.
  2467. 0C845 ;;; bit 0 = overworld (0) underworld (1)
  2468. 0C845 ;;; bit 1 = metaTable (0) 8x8 table (1)
  2469. 0C845 ;arg0 = screen bank
  2470. 0C845 ;arg3_hold = columns to load
  2471. 0C845 ;arg4_hold = rows to load
  2472. 0C845 ;arg5_hold = start row
  2473. 0C845 ;arg6_hold = start column
  2474. 0C845 ;arg7_hold = which nametable.
  2475. 0C845
  2476. 0C845
  2477. 0C845
  2478. 0C845 A5 12 LDA arg6_hold
  2479. 0C847 AA TAX ;; starting collision table write
  2480. 0C848 4A LSR
  2481. 0C849 A8 TAY ;; starting rom read.
  2482. 0C84A
  2483. 0C84A A5 0F LDA arg3_hold
  2484. 0C84C 85 08 STA tempB ; we will use tempB to hold the number of columns
  2485. 0C84E ; so when we start a new row, we can return to the proper number of columns.
  2486. 0C84E ;;; now we can use the (pointer) to know the PPU address to write the nametable.
  2487. 0C84E ;;; whilte (temp16) denotes where the nametable data is being pulled from.
  2488. 0C84E 98 48 AD 20 06 8D 21 06.. SwitchBank arg0_hold
  2489. 0C85D loop_LoadCollisionTable:
  2490. 0C85D 8A TxA
  2491. 0C85E 29 01 AND #%00000001
  2492. 0C860 loop_LoadColTable_inner:
  2493. 0C860 D0 2A BNE thisColTileIsOdd
  2494. 0C862 ;; this col tile is even
  2495. 0C862 B1 14 LDA (temp16),y
  2496. 0C864 4A LSR
  2497. 0C865 4A LSR
  2498. 0C866 4A LSR
  2499. 0C867 4A LSR
  2500. 0C868 85 09 STA tempC
  2501. 0C86A A5 13 LDA arg7_hold
  2502. 0C86C D0 0F BNE loadColToSecondCt_a
  2503. 0C86E AD 74 06 LDA currentNametable
  2504. 0C871 29 01 AND #%00000001
  2505. 0C873 D0 0F BNE loadColFlip2 ;; flip it
  2506. 0C875 loadColFlip:
  2507. 0C875 A5 09 LDA tempC
  2508. 0C877 9D 00 03 STA collisionTable,x
  2509. 0C87A 4C B6 C8 JMP checkColColumnCount
  2510. 0C87D loadColToSecondCt_a:
  2511. 0C87D AD 74 06 LDA currentNametable
  2512. 0C880 29 01 AND #%00000001
  2513. 0C882 D0 F1 BNE loadColFlip;; flip it
  2514. 0C884 loadColFlip2:
  2515. 0C884 A5 09 LDA tempC
  2516. 0C886 9D 00 05 STA collisionTable2,x
  2517. 0C889 4C B6 C8 JMP checkColColumnCount
  2518. 0C88C
  2519. 0C88C thisColTileIsOdd:
  2520. 0C88C ;;; this col tile is odd
  2521. 0C88C B1 14 LDA (temp16),y
  2522. 0C88E 29 0F AND #%00001111
  2523. 0C890 85 09 STA tempC
  2524. 0C892 A5 13 LDA arg7_hold
  2525. 0C894 D0 10 BNE loadColToSecondCt_b
  2526. 0C896 AD 74 06 LDA currentNametable
  2527. 0C899 29 01 AND #%00000001
  2528. 0C89B D0 10 BNE loadColFlip3
  2529. 0C89D loadColFlip4:
  2530. 0C89D A5 09 LDA tempC
  2531. 0C89F 9D 00 03 STA collisionTable,x
  2532. 0C8A2 C8 INY ;; y is only going to increase after odd is checked
  2533. 0C8A3 4C B6 C8 JMP checkColColumnCount
  2534. 0C8A6 loadColToSecondCt_b:
  2535. 0C8A6 AD 74 06 LDA currentNametable
  2536. 0C8A9 29 01 AND #%00000001
  2537. 0C8AB D0 F0 BNE loadColFlip4
  2538. 0C8AD loadColFlip3:
  2539. 0C8AD A5 09 LDA tempC
  2540. 0C8AF 9D 00 05 STA collisionTable2,x
  2541. 0C8B2 C8 INY
  2542. 0C8B3 4C B6 C8 JMP checkColColumnCount
  2543. 0C8B6
  2544. 0C8B6
  2545. 0C8B6 checkColColumnCount:
  2546. 0C8B6
  2547. 0C8B6 E8 INX
  2548. 0C8B7 C6 08 DEC tempB
  2549. 0C8B9 A5 08 LDA tempB
  2550. 0C8BB F0 03 BEQ doneWithColColumn
  2551. 0C8BD
  2552. 0C8BD 4C 5D C8 JMP loop_LoadCollisionTable
  2553. 0C8C0 doneWithColColumn:
  2554. 0C8C0 A5 0F LDA arg3_hold
  2555. 0C8C2 85 08 STA tempB ;; reset column counter.
  2556. 0C8C4
  2557. 0C8C4 C6 10 DEC arg4_hold
  2558. 0C8C6 A5 10 LDA arg4_hold
  2559. 0C8C8 F0 18 BEQ doneWithLoadingCOllisions
  2560. 0C8CA ;; now, the end of the column is reached.
  2561. 0C8CA ;; that means that subtracting the "columns to load"
  2562. 0C8CA ;; from x + 16 and columns to load/2 from y +8
  2563. 0C8CA ;; gives the new position for the new row.
  2564. 0C8CA 8A TxA
  2565. 0C8CB 38 SEC
  2566. 0C8CC E5 0F SBC arg3_hold
  2567. 0C8CE 18 CLC
  2568. 0C8CF 69 10 ADC #$10
  2569. 0C8D1 AA TAX
  2570. 0C8D2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; end get x offset one row down.
  2571. 0C8D2 A5 0F LDA arg3_hold
  2572. 0C8D4 4A LSR
  2573. 0C8D5 85 00 STA temp
  2574. 0C8D7 98 TYA
  2575. 0C8D8 38 SEC
  2576. 0C8D9 E5 00 SBC temp
  2577. 0C8DB 18 CLC
  2578. 0C8DC 69 08 ADC #$08
  2579. 0C8DE A8 TAY
  2580. 0C8DF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; end get y offset one row down
  2581. 0C8DF 4C 5D C8 JMP loop_LoadCollisionTable
  2582. 0C8E2
  2583. 0C8E2 doneWithLoadingCOllisions:
  2584. 0C8E2
  2585. 0C8E2 98 48 AC 21 06 20 83 C5.. ReturnBank
  2586. 0C8EC 60 RTS
  2587. 0C8ED
  2588. 0C8ED
  2589. 0C8ED 0C8ED .include Routines\BASE_4_5\\Game\Subroutines\doCleanUpSpriteRam.asm
  2590. 0C8ED ;; do clean up sprite ram
  2591. 0C8ED doCleanUpSpriteRam:
  2592. 0C8ED A4 2C LDY spriteRamPointer
  2593. 0C8EF clearSpriteRamLoop:
  2594. 0C8EF A9 FE LDA #$FE
  2595. 0C8F1 99 00 02 STA SpriteRam,y
  2596. 0C8F4 C8 INY
  2597. 0C8F5 C8 INY
  2598. 0C8F6 C8 INY
  2599. 0C8F7 C8 INY
  2600. 0C8F8 D0 F5 BNE clearSpriteRamLoop
  2601. 0C8FA 60 RTS0C8FB .include Routines\BASE_4_5\\Game\Subroutines\doWaitFrame.asm
  2602. 0C8FB doWaitFrame:
  2603. 0C8FB EE 45 06 inc waiting
  2604. 0C8FE waitLoop:
  2605. 0C8FE AD 45 06 lda waiting
  2606. 0C901 D0 FB BNE waitLoop
  2607. 0C903
  2608. 0C903 60 RTS0C904 .include Routines\BASE_4_5\\Game\Subroutines\doHandleBounds.asm
  2609. 0C904 doHandleBounds:
  2610. 0C904 98 48 AD 20 06 8D 21 06.. SwitchBank #$18
  2611. 0C913 20 4D 8A JSR doHandleBounds_bank18
  2612. 0C916 98 48 AC 21 06 20 83 C5.. ReturnBank
  2613. 0C920
  2614. 0C920 60 RTS0C921 .include Routines\BASE_4_5\\Game\Subroutines\doLoadScreen.asm
  2615. 0C921 doLoadScreen:
  2616. 0C921
  2617. 0C921 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2618. 0C921 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2619. 0C921 ;; zero out objects
  2620. 0C921 20 01 DE JSR doClearAllMonsters
  2621. 0C924 ; JSR doWaitFrame
  2622. 0C924
  2623. 0C924
  2624. 0C924 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2625. 0C924 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2626. 0C924
  2627. 0C924
  2628. 0C924 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2629. 0C924 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2630. 0C924 AD 74 06 LDA currentNametable
  2631. 0C927 29 01 AND #%00000001
  2632. 0C929 F0 0D BEQ isEvenNtForcamFocus_tiles
  2633. 0C92B A9 24 LDA #$24
  2634. 0C92D 8D BE 06 STA camFocus_tiles
  2635. 0C930 A9 27 LDA #$27
  2636. 0C932 8D BF 06 STA camFocus_att
  2637. 0C935 4C 42 C9 JMP gotcamFocus_tiles_forScreenLoad
  2638. 0C938 isEvenNtForcamFocus_tiles
  2639. 0C938 A9 20 LDA #$20
  2640. 0C93A 8D BE 06 STA camFocus_tiles
  2641. 0C93D A9 23 LDA #$23
  2642. 0C93F 8D BF 06 STA camFocus_att
  2643. 0C942 gotcamFocus_tiles_forScreenLoad:
  2644. 0C942
  2645. 0C942
  2646. 0C942 AD 74 06 LDA currentNametable
  2647. 0C945 4A LSR
  2648. 0C946 4A LSR
  2649. 0C947 4A LSR
  2650. 0C948 4A LSR
  2651. 0C949 4A LSR
  2652. 0C94A 85 00 STA temp ;; this is the screen bank.
  2653. 0C94C AD A4 06 LDA warpMap
  2654. 0C94F ;;; and other screen bytes needed - warp map is either 0 or 1
  2655. 0C94F 85 02 STA temp2
  2656. 0C951 A5 00 85 0C AD 74 06 85.. LoadScreenTableData temp, currentNametable, temp2
  2657. 0C99D ;; loads from the collision table, all of the screen info that needs to be loaded.
  2658. 0C99D ;; this needs to be BEFORE nametable, because it will determine if we're loading
  2659. 0C99D ;; a meta table or a full table.
  2660. 0C99D
  2661. 0C99D
  2662. 0C99D .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  2663. 0C99D ;blank0C99D
  2664. 0C99D A0 04 AD 9D 06 85 0C 20.. LoadBackgroundPalettes newPal
  2665. 0C9A7 20 FB C8 JSR doWaitFrame
  2666. 0C9AA ;; We wait this frame because the LoadBackgroundPalettes routine
  2667. 0C9AA ;; sets bckpal variables and activates the update palette.
  2668. 0C9AA ;; waiting this frame holds up on the next routine until the
  2669. 0C9AA ;; background palettes are loaded into the PPU.
  2670. 0C9AA ;LoadObjectPalettes #$00
  2671. 0C9AA
  2672. 0C9AA AD AD 06 85 0C A9 00 85.. LoadObjectSubPalettes spriteSubPal1, #$00
  2673. 0C9B6 AD AE 06 85 0C A9 04 85.. LoadObjectSubPalettes spriteSubPal2, #$04
  2674. 0C9C2 AD AF 06 85 0C A9 08 85.. LoadObjectSubPalettes spriteSubPal3, #$08
  2675. 0C9CE AD B0 06 85 0C A9 0C 85.. LoadObjectSubPalettes spriteSubPal4, #$0C
  2676. 0C9DA
  2677. 0C9DA
  2678. 0C9DA
  2679. 0C9DA 20 FB C8 JSR doWaitFrame
  2680. 0C9DD
  2681. 0C9DD
  2682. 0C9DD
  2683. 0C9DD AD 46 06 LDA tileLayout
  2684. 0C9E0 C9 40 CMP #%01000000
  2685. 0C9E2 F0 03 BEQ LOAD_MSP
  2686. 0C9E4 4C 75 CB JMP notMSP
  2687. 0C9E7 LOAD_MSP:
  2688. 0C9E7 AD 97 06 LDA backgroundTilesToLoad
  2689. 0C9EA 4A LSR
  2690. 0C9EB 4A LSR
  2691. 0C9EC 4A LSR
  2692. 0C9ED 4A LSR
  2693. 0C9EE 18 CLC
  2694. 0C9EF 69 0F ADC #$0F
  2695. 0C9F1 85 07 STA tempA
  2696. 0C9F3 AD 97 06 LDA backgroundTilesToLoad
  2697. 0C9F6 29 0F AND #%00001111
  2698. 0C9F8 85 08 STA tempB
  2699. 0C9FA A5 07 8D 22 06 A9 10 85.. LoadChrData tempA, #$10, #$00, #$60, BckCHRAddLo, BckCHRAddHi, tempB
  2700. 0CA4D ;arg0 - bank where graphics live
  2701. 0CA4D ;arg1 - row
  2702. 0CA4D ;arg2 - column (by 10s...must end in zero)
  2703. 0CA4D ;arg3 - how many tiles to load. If 00, will load whole sheet.
  2704. 0CA4D ;arg4 - Label in bank 16 table, low.
  2705. 0CA4D ;arg5 - Label in bank 16 table, hi.
  2706. 0CA4D ;arg6 - Bank 16 table offset
  2707. 0CA4D
  2708. 0CA4D 20 FB C8 JSR doWaitFrame
  2709. 0CA50 AD 98 06 LDA backgroundTilesToLoad+1
  2710. 0CA53 4A LSR
  2711. 0CA54 4A LSR
  2712. 0CA55 4A LSR
  2713. 0CA56 4A LSR
  2714. 0CA57 18 CLC
  2715. 0CA58 69 0F ADC #$0F
  2716. 0CA5A 85 07 STA tempA
  2717. 0CA5C AD 98 06 LDA backgroundTilesToLoad+1
  2718. 0CA5F 29 0F AND #%00001111
  2719. 0CA61 85 08 STA tempB
  2720. 0CA63 A5 07 8D 22 06 A9 16 85.. LoadChrData tempA, #$16, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2721. 0CAB6 ;;; load paths.
  2722. 0CAB6 20 FB C8 JSR doWaitFrame
  2723. 0CAB9 AD 99 06 LDA backgroundTilesToLoad+2
  2724. 0CABC 4A LSR
  2725. 0CABD 4A LSR
  2726. 0CABE 4A LSR
  2727. 0CABF 4A LSR
  2728. 0CAC0 18 CLC
  2729. 0CAC1 69 0F ADC #$0F
  2730. 0CAC3 85 07 STA tempA
  2731. 0CAC5 AD 99 06 LDA backgroundTilesToLoad+2
  2732. 0CAC8 29 0F AND #%00001111
  2733. 0CACA 85 08 STA tempB
  2734. 0CACC
  2735. 0CACC A5 07 8D 22 06 A9 18 85.. LoadChrData tempA, #$18, #$00, #$40, PathCHRAddLo, PathCHRAddHi, tempB
  2736. 0CB1F
  2737. 0CB1F
  2738. 0CB1F ;; Load Hud
  2739. 0CB1F A9 1E 8D 22 06 A9 1C 85.. LoadChrData #$1E, #$1C, #$00, #$40, OtherChrTiles_Lo, OtherChrTiles_Hi, #$00
  2740. 0CB72
  2741. 0CB72 4C C1 D2 JMP doneLoadingChrs
  2742. 0CB75 notMSP:
  2743. 0CB75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2744. 0CB75 ;;;DOUBLE MAIN;;;;;;;;;;;;;;;;;;;;;;;
  2745. 0CB75
  2746. 0CB75 C9 00 CMP #%00000000
  2747. 0CB77 F0 03 BEQ Load_MM
  2748. 0CB79 4C 9E CC JMP notMM
  2749. 0CB7C Load_MM:
  2750. 0CB7C AD 97 06 LDA backgroundTilesToLoad
  2751. 0CB7F 4A LSR
  2752. 0CB80 4A LSR
  2753. 0CB81 4A LSR
  2754. 0CB82 4A LSR
  2755. 0CB83 18 CLC
  2756. 0CB84 69 0F ADC #$0F
  2757. 0CB86 85 07 STA tempA
  2758. 0CB88 AD 97 06 LDA backgroundTilesToLoad
  2759. 0CB8B 29 0F AND #%00001111
  2760. 0CB8D 85 08 STA tempB
  2761. 0CB8F A5 07 8D 22 06 A9 10 85.. LoadChrData tempA, #$10, #$00, #$60, BckCHRAddLo, BckCHRAddHi, tempB
  2762. 0CBE2
  2763. 0CBE2 AD 98 06 LDA backgroundTilesToLoad+1
  2764. 0CBE5 4A LSR
  2765. 0CBE6 4A LSR
  2766. 0CBE7 4A LSR
  2767. 0CBE8 4A LSR
  2768. 0CBE9 18 CLC
  2769. 0CBEA 69 0F ADC #$0F
  2770. 0CBEC 85 07 STA tempA
  2771. 0CBEE AD 98 06 LDA backgroundTilesToLoad+1
  2772. 0CBF1 29 0F AND #%00001111
  2773. 0CBF3 85 08 STA tempB
  2774. 0CBF5 A5 07 8D 22 06 A9 16 85.. LoadChrData tempA, #$16, #$00, #$60, BckCHRAddLo, BckCHRAddHi, tempB
  2775. 0CC48
  2776. 0CC48 ;; Load Hud
  2777. 0CC48 A9 1E 8D 22 06 A9 1C 85.. LoadChrData #$1E, #$1C, #$00, #$40, OtherChrTiles_Lo, OtherChrTiles_Hi, #$00
  2778. 0CC9B
  2779. 0CC9B
  2780. 0CC9B 4C C1 D2 JMP doneLoadingChrs
  2781. 0CC9E notMM:
  2782. 0CC9E C9 70 CMP #%01110000
  2783. 0CCA0 F0 03 BEQ LOAD_MSSS
  2784. 0CCA2 4C 9C CE JMP notMSSS
  2785. 0CCA5 LOAD_MSSS:
  2786. 0CCA5 AD 97 06 LDA backgroundTilesToLoad
  2787. 0CCA8 4A LSR
  2788. 0CCA9 4A LSR
  2789. 0CCAA 4A LSR
  2790. 0CCAB 4A LSR
  2791. 0CCAC 18 CLC
  2792. 0CCAD 69 0F ADC #$0F
  2793. 0CCAF 85 07 STA tempA
  2794. 0CCB1 AD 97 06 LDA backgroundTilesToLoad
  2795. 0CCB4 29 0F AND #%00001111
  2796. 0CCB6 85 08 STA tempB
  2797. 0CCB8 A5 07 8D 22 06 A9 10 85.. LoadChrData tempA, #$10, #$00, #$60, BckCHRAddLo, BckCHRAddHi, tempB
  2798. 0CD0B
  2799. 0CD0B 20 FB C8 JSR doWaitFrame
  2800. 0CD0E AD 98 06 LDA backgroundTilesToLoad+1
  2801. 0CD11 4A LSR
  2802. 0CD12 4A LSR
  2803. 0CD13 4A LSR
  2804. 0CD14 4A LSR
  2805. 0CD15 18 CLC
  2806. 0CD16 69 0F ADC #$0F
  2807. 0CD18 85 07 STA tempA
  2808. 0CD1A AD 98 06 LDA backgroundTilesToLoad+1
  2809. 0CD1D 29 0F AND #%00001111
  2810. 0CD1F 85 08 STA tempB
  2811. 0CD21 A5 07 8D 22 06 A9 16 85.. LoadChrData tempA, #$16, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2812. 0CD74
  2813. 0CD74 20 FB C8 JSR doWaitFrame
  2814. 0CD77 AD 99 06 LDA backgroundTilesToLoad+2
  2815. 0CD7A 4A LSR
  2816. 0CD7B 4A LSR
  2817. 0CD7C 4A LSR
  2818. 0CD7D 4A LSR
  2819. 0CD7E 18 CLC
  2820. 0CD7F 69 0F ADC #$0F
  2821. 0CD81 85 07 STA tempA
  2822. 0CD83 AD 99 06 LDA backgroundTilesToLoad+2
  2823. 0CD86 29 0F AND #%00001111
  2824. 0CD88 85 08 STA tempB
  2825. 0CD8A A5 07 8D 22 06 A9 18 85.. LoadChrData tempA, #$18, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2826. 0CDDD
  2827. 0CDDD 20 FB C8 JSR doWaitFrame
  2828. 0CDE0 AD 9A 06 LDA backgroundTilesToLoad+3
  2829. 0CDE3 4A LSR
  2830. 0CDE4 4A LSR
  2831. 0CDE5 4A LSR
  2832. 0CDE6 4A LSR
  2833. 0CDE7 18 CLC
  2834. 0CDE8 69 0F ADC #$0F
  2835. 0CDEA 85 07 STA tempA
  2836. 0CDEC AD 9A 06 LDA backgroundTilesToLoad+3
  2837. 0CDEF 29 0F AND #%00001111
  2838. 0CDF1 85 08 STA tempB
  2839. 0CDF3 A5 07 8D 22 06 A9 1A 85.. LoadChrData tempA, #$1A, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2840. 0CE46
  2841. 0CE46
  2842. 0CE46 ;; Load Hud
  2843. 0CE46 A9 1E 8D 22 06 A9 1C 85.. LoadChrData #$1E, #$1C, #$00, #$40, OtherChrTiles_Lo, OtherChrTiles_Hi, #$00
  2844. 0CE99
  2845. 0CE99
  2846. 0CE99 4C C1 D2 JMP doneLoadingChrs
  2847. 0CE9C notMSSS:
  2848. 0CE9C C9 7C CMP #%01111100
  2849. 0CE9E F0 03 BEQ doMSSSSS
  2850. 0CEA0 4C 19 D1 JMP notMSSSSS
  2851. 0CEA3 doMSSSSS
  2852. 0CEA3 AD 97 06 LDA backgroundTilesToLoad
  2853. 0CEA6 4A LSR
  2854. 0CEA7 4A LSR
  2855. 0CEA8 4A LSR
  2856. 0CEA9 4A LSR
  2857. 0CEAA 18 CLC
  2858. 0CEAB 69 0F ADC #$0F
  2859. 0CEAD 85 07 STA tempA
  2860. 0CEAF AD 97 06 LDA backgroundTilesToLoad
  2861. 0CEB2 29 0F AND #%00001111
  2862. 0CEB4 85 08 STA tempB
  2863. 0CEB6 A5 07 8D 22 06 A9 10 85.. LoadChrData tempA, #$10, #$00, #$60, BckCHRAddLo, BckCHRAddHi, tempB
  2864. 0CF09
  2865. 0CF09 20 FB C8 JSR doWaitFrame
  2866. 0CF0C AD 98 06 LDA backgroundTilesToLoad+1
  2867. 0CF0F 4A LSR
  2868. 0CF10 4A LSR
  2869. 0CF11 4A LSR
  2870. 0CF12 4A LSR
  2871. 0CF13 18 CLC
  2872. 0CF14 69 0F ADC #$0F
  2873. 0CF16 85 07 STA tempA
  2874. 0CF18 AD 98 06 LDA backgroundTilesToLoad+1
  2875. 0CF1B 29 0F AND #%00001111
  2876. 0CF1D 85 08 STA tempB
  2877. 0CF1F A5 07 8D 22 06 A9 16 85.. LoadChrData tempA, #$16, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2878. 0CF72
  2879. 0CF72 20 FB C8 JSR doWaitFrame
  2880. 0CF75 AD 99 06 LDA backgroundTilesToLoad+2
  2881. 0CF78 4A LSR
  2882. 0CF79 4A LSR
  2883. 0CF7A 4A LSR
  2884. 0CF7B 4A LSR
  2885. 0CF7C 18 CLC
  2886. 0CF7D 69 0F ADC #$0F
  2887. 0CF7F 85 07 STA tempA
  2888. 0CF81 AD 99 06 LDA backgroundTilesToLoad+2
  2889. 0CF84 29 0F AND #%00001111
  2890. 0CF86 85 08 STA tempB
  2891. 0CF88 A5 07 8D 22 06 A9 18 85.. LoadChrData tempA, #$18, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2892. 0CFDB
  2893. 0CFDB 20 FB C8 JSR doWaitFrame
  2894. 0CFDE AD 9A 06 LDA backgroundTilesToLoad+3
  2895. 0CFE1 4A LSR
  2896. 0CFE2 4A LSR
  2897. 0CFE3 4A LSR
  2898. 0CFE4 4A LSR
  2899. 0CFE5 18 CLC
  2900. 0CFE6 69 0F ADC #$0F
  2901. 0CFE8 85 07 STA tempA
  2902. 0CFEA AD 9A 06 LDA backgroundTilesToLoad+3
  2903. 0CFED 29 0F AND #%00001111
  2904. 0CFEF 85 08 STA tempB
  2905. 0CFF1 A5 07 8D 22 06 A9 1A 85.. LoadChrData tempA, #$1A, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2906. 0D044
  2907. 0D044 20 FB C8 JSR doWaitFrame
  2908. 0D047 AD 9B 06 LDA backgroundTilesToLoad+4
  2909. 0D04A 4A LSR
  2910. 0D04B 4A LSR
  2911. 0D04C 4A LSR
  2912. 0D04D 4A LSR
  2913. 0D04E 18 CLC
  2914. 0D04F 69 0F ADC #$0F
  2915. 0D051 85 07 STA tempA
  2916. 0D053 AD 9B 06 LDA backgroundTilesToLoad+4
  2917. 0D056 29 0F AND #%00001111
  2918. 0D058 85 08 STA tempB
  2919. 0D05A A5 07 8D 22 06 A9 1C 85.. LoadChrData tempA, #$1C, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2920. 0D0AD
  2921. 0D0AD 20 FB C8 JSR doWaitFrame
  2922. 0D0B0 AD 9C 06 LDA backgroundTilesToLoad+5
  2923. 0D0B3 4A LSR
  2924. 0D0B4 4A LSR
  2925. 0D0B5 4A LSR
  2926. 0D0B6 4A LSR
  2927. 0D0B7 18 CLC
  2928. 0D0B8 69 0F ADC #$0F
  2929. 0D0BA 85 07 STA tempA
  2930. 0D0BC AD 9C 06 LDA backgroundTilesToLoad+5
  2931. 0D0BF 29 0F AND #%00001111
  2932. 0D0C1 85 08 STA tempB
  2933. 0D0C3 A5 07 8D 22 06 A9 1E 85.. LoadChrData tempA, #$1E, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2934. 0D116 4C C1 D2 JMP doneLoadingChrs
  2935. 0D119 notMSSSSS
  2936. 0D119 C9 0C CMP #%00001100
  2937. 0D11B F0 03 BEQ doMMSS
  2938. 0D11D 4C C1 D2 JMP notMMSS
  2939. 0D120 doMMSS:
  2940. 0D120 AD 97 06 LDA backgroundTilesToLoad
  2941. 0D123 4A LSR
  2942. 0D124 4A LSR
  2943. 0D125 4A LSR
  2944. 0D126 4A LSR
  2945. 0D127 18 CLC
  2946. 0D128 69 0F ADC #$0F
  2947. 0D12A 85 07 STA tempA
  2948. 0D12C AD 97 06 LDA backgroundTilesToLoad
  2949. 0D12F 29 0F AND #%00001111
  2950. 0D131 85 08 STA tempB
  2951. 0D133 A5 07 8D 22 06 A9 10 85.. LoadChrData tempA, #$10, #$00, #$60, BckCHRAddLo, BckCHRAddHi, tempB
  2952. 0D186
  2953. 0D186 AD 98 06 LDA backgroundTilesToLoad+1
  2954. 0D189 4A LSR
  2955. 0D18A 4A LSR
  2956. 0D18B 4A LSR
  2957. 0D18C 4A LSR
  2958. 0D18D 18 CLC
  2959. 0D18E 69 0F ADC #$0F
  2960. 0D190 85 07 STA tempA
  2961. 0D192 AD 98 06 LDA backgroundTilesToLoad+1
  2962. 0D195 29 0F AND #%00001111
  2963. 0D197 85 08 STA tempB
  2964. 0D199 A5 07 8D 22 06 A9 16 85.. LoadChrData tempA, #$16, #$00, #$60, BckCHRAddLo, BckCHRAddHi, tempB
  2965. 0D1EC 20 FB C8 JSR doWaitFrame
  2966. 0D1EF AD 99 06 LDA backgroundTilesToLoad+2
  2967. 0D1F2 4A LSR
  2968. 0D1F3 4A LSR
  2969. 0D1F4 4A LSR
  2970. 0D1F5 4A LSR
  2971. 0D1F6 18 CLC
  2972. 0D1F7 69 0F ADC #$0F
  2973. 0D1F9 85 07 STA tempA
  2974. 0D1FB AD 99 06 LDA backgroundTilesToLoad+2
  2975. 0D1FE 29 0F AND #%00001111
  2976. 0D200 85 08 STA tempB
  2977. 0D202 A5 07 8D 22 06 A9 1C 85.. LoadChrData tempA, #$1C, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2978. 0D255
  2979. 0D255 20 FB C8 JSR doWaitFrame
  2980. 0D258 AD 9A 06 LDA backgroundTilesToLoad+3
  2981. 0D25B 4A LSR
  2982. 0D25C 4A LSR
  2983. 0D25D 4A LSR
  2984. 0D25E 4A LSR
  2985. 0D25F 18 CLC
  2986. 0D260 69 0F ADC #$0F
  2987. 0D262 85 07 STA tempA
  2988. 0D264 AD 9A 06 LDA backgroundTilesToLoad+3
  2989. 0D267 29 0F AND #%00001111
  2990. 0D269 85 08 STA tempB
  2991. 0D26B A5 07 8D 22 06 A9 1E 85.. LoadChrData tempA, #$1E, #$00, #$20, BckSSChrAddLo, BckSSChrAddHi, tempB
  2992. 0D2BE
  2993. 0D2BE 4C C1 D2 JMP doneLoadingChrs
  2994. 0D2C1 notMMSS:
  2995. 0D2C1 doneLoadingChrs:
  2996. 0D2C1
  2997. 0D2C1
  2998. 0D2C1
  2999. 0D2C1
  3000. 0D2C1 A9 15 8D 22 06 A9 00 85.. LoadChrData #$15, #$00, #$00, #$80, GameObjectCHRAddLo, GameObjectCHRAddHi, #$00
  3001. 0D314 ;arg0 - bank where graphics live
  3002. 0D314 ;arg1 - row
  3003. 0D314 ;arg2 - column (by 10s...must end in zero)
  3004. 0D314 ;arg3 - how many tiles to load. If 00, will load whole sheet.
  3005. 0D314 ;arg4 - Label in bank 16 table, low.
  3006. 0D314 ;arg5 - Label in bank 16 table, hi.
  3007. 0D314 ;arg6 - Bank 16 table offset
  3008. 0D314
  3009. 0D314 AD AC 06 LDA monsterTableOffset
  3010. 0D317 C9 08 CMP #$08
  3011. 0D319 90 05 BCC inMonsterBank0
  3012. 0D31B ;; in monster bank 1
  3013. 0D31B A9 14 LDA #$14
  3014. 0D31D 4C 22 D3 JMP gotMonsterBank
  3015. 0D320 inMonsterBank0
  3016. 0D320 A9 13 LDA #$13
  3017. 0D322 gotMonsterBank:
  3018. 0D322 85 00 STA temp
  3019. 0D324
  3020. 0D324 A5 00 8D 22 06 A9 08 85.. LoadChrData temp, #$08, #$00, #$80, MonsterAddressLo, MonsterAddressHi, monsterTableOffset
  3021. 0D379 ;arg0 - bank where graphics live
  3022. 0D379 ;arg1 - row
  3023. 0D379 ;arg2 - column (by 10s...must end in zero)
  3024. 0D379 ;arg3 - how many tiles to load. If 00, will load whole sheet.
  3025. 0D379 ;arg4 - Label in bank 16 table, low.
  3026. 0D379 ;arg5 - Label in bank 16 table, hi.
  3027. 0D379 ;arg6 - Bank 16 table offset
  3028. 0D379 20 FB C8 JSR doWaitFrame
  3029. 0D37C
  3030. 0D37C
  3031. 0D37C
  3032. 0D37C AD 74 06 LDA currentNametable
  3033. 0D37F 29 01 AND #%00000001
  3034. 0D381 D0 0B BNE isOddNametable_loadToRightNT
  3035. 0D383 ;;is even nametable. 20/23
  3036. 0D383 A9 20 LDA #$20
  3037. 0D385 85 04 STA tempx
  3038. 0D387 A9 23 LDA #$23
  3039. 0D389 85 05 STA tempy
  3040. 0D38B 4C 96 D3 JMP gotStartingNT
  3041. 0D38E isOddNametable_loadToRightNT:
  3042. 0D38E A9 24 LDA #$24
  3043. 0D390 85 04 STA tempx
  3044. 0D392 A9 27 LDA #$27
  3045. 0D394 85 05 STA tempy
  3046. 0D396
  3047. 0D396 gotStartingNT:
  3048. 0D396 ;;; check if load full or meta nametable
  3049. 0D396 AD 96 06 LDA screenLoadTemps
  3050. 0D399 29 80 AND #%10000000
  3051. 0D39B F0 66 BEQ loadMetaNametable
  3052. 0D39D
  3053. 0D39D ;;; load 8x8 nametable.
  3054. 0D39D AD 74 06 LDA currentNametable
  3055. 0D3A0 4A LSR
  3056. 0D3A1 4A LSR
  3057. 0D3A2 4A LSR
  3058. 0D3A3 4A LSR
  3059. 0D3A4 4A LSR
  3060. 0D3A5 85 00 STA temp ;; this is the screen bank.
  3061. 0D3A7
  3062. 0D3A7 AD A4 06 LDA warpMap
  3063. 0D3AA ;;; and other screen bytes needed - warp map is either 0 or 1
  3064. 0D3AA 85 02 STA temp2
  3065. 0D3AC
  3066. 0D3AC A5 00 85 0C AD 74 06 85.. LoadNametableDataFull temp, currentNametable, temp2, tempx
  3067. 0D400 4C 76 D4 Jmp DoneLoadingNametable_metaOr8x8x
  3068. 0D403 loadMetaNametable:
  3069. 0D403 AD 74 06 LDA currentNametable
  3070. 0D406 4A LSR
  3071. 0D407 4A LSR
  3072. 0D408 4A LSR
  3073. 0D409 4A LSR
  3074. 0D40A 4A LSR
  3075. 0D40B 85 00 STA temp ;; this is the screen bank.
  3076. 0D40D AD A4 06 LDA warpMap
  3077. 0D410 ;;; and other screen bytes needed - warp map is either 0 or 1
  3078. 0D410 85 02 STA temp2
  3079. 0D412
  3080. 0D412 A5 00 85 0C AD 74 06 85.. LoadNametableData temp, currentNametable, temp2, #$10, #$0f, tempx, #$00, #$00
  3081. 0D476
  3082. 0D476 DoneLoadingNametable_metaOr8x8x:
  3083. 0D476 20 FB C8 JSR doWaitFrame
  3084. 0D479 AD 74 06 LDA currentNametable
  3085. 0D47C 4A LSR
  3086. 0D47D 4A LSR
  3087. 0D47E 4A LSR
  3088. 0D47F 4A LSR
  3089. 0D480 4A LSR
  3090. 0D481 85 00 STA temp ;; this is the screen bank.
  3091. 0D483 AD A4 06 LDA warpMap
  3092. 0D486 ;;; and other screen bytes needed - warp map is either 0 or 1
  3093. 0D486 85 02 STA temp2
  3094. 0D488
  3095. 0D488 A5 00 85 0C AD 74 06 85.. LoadAttributeData temp, currentNametable, temp2, #$08, #$08, tempy, #$C0, #$00
  3096. 0D4EC 20 FB C8 JSR doWaitFrame
  3097. 0D4EF AD 74 06 LDA currentNametable
  3098. 0D4F2 4A LSR
  3099. 0D4F3 4A LSR
  3100. 0D4F4 4A LSR
  3101. 0D4F5 4A LSR
  3102. 0D4F6 4A LSR
  3103. 0D4F7 85 00 STA temp ;; this is the screen bank.
  3104. 0D4F9 AD A4 06 LDA warpMap
  3105. 0D4FC ;;; and other screen bytes needed - warp map is either 0 or 1
  3106. 0D4FC 85 02 STA temp2
  3107. 0D4FE
  3108. 0D4FE A5 00 85 0C AD 74 06 85.. LoadCollisionData temp, currentNametable, temp2, #$10, #$0F, #$00, #$00, #$00
  3109. 0D562 20 FB C8 JSR doWaitFrame
  3110. 0D565
  3111. 0D565 AE 6D 06 LDX player1_object
  3112. 0D568 AD 75 06 LDA newX
  3113. 0D56B 9D 1A 04 STA Object_x_hi,x
  3114. 0D56E AD 76 06 LDA newY
  3115. 0D571 9D 41 04 STA Object_y_hi,x
  3116. 0D574
  3117. 0D574 AD B4 06 LDA screenUpdateByte
  3118. 0D577 29 04 AND #%00000100
  3119. 0D579 F0 20 BEQ nevermindSettingNewContinueByte
  3120. 0D57B AD A4 06 LDA warpMap
  3121. 0D57E 8D D5 06 STA continueMap
  3122. 0D581 AD 74 06 LDA currentNametable
  3123. 0D584 8D D2 06 STA continueScreen
  3124. 0D587 AD 75 06 LDA newX
  3125. 0D58A 8D D3 06 STA continueX
  3126. 0D58D AD 76 06 LDA newY
  3127. 0D590 8D D4 06 STA continueY
  3128. 0D593 AD B4 06 LDA screenUpdateByte
  3129. 0D596 29 FB AND #%11111011
  3130. 0D598 8D B4 06 STA screenUpdateByte
  3131. 0D59B nevermindSettingNewContinueByte:
  3132. 0D59B 20 FB C8 JSR doWaitFrame
  3133. 0D59E 20 6B F7 DrawHud
  3134. 0D5A1
  3135. 0D5A1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3136. 0D5A1 ;;; DO SOMETHING - CUSTOM
  3137. 0D5A1 ;;; I want to check all collisions. If they are type 6, set them to 0 and draw ground tiles over them.
  3138. 0D5A1 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  3139. 0D5A1 ;blank0D5A1
  3140. 0D5A1 A9 1E LDA #%00011110 ;;
  3141. 0D5A3 85 17 STA soft2001
  3142. 0D5A5 20 FB C8 JSR doWaitFrame
  3143. 0D5A8
  3144. 0D5A8 dontTurnOnScreenYet:
  3145. 0D5A8
  3146. 0D5A8 60 RTS0D5A9 .include Routines\BASE_4_5\\Game\Subroutines\doLoadScreen2.asm
  3147. 0D5A9 doLoadScreen2:
  3148. 0D5A9 AD 74 06 LDA currentNametable
  3149. 0D5AC 29 01 AND #%00000001
  3150. 0D5AE F0 0B BEQ secondNametableIsIn24
  3151. 0D5B0 A9 20 LDA #$20
  3152. 0D5B2 85 04 STA tempx
  3153. 0D5B4 A9 23 LDA #$23
  3154. 0D5B6 85 05 STA tempy
  3155. 0D5B8 4C C3 D5 JMP gotSecondNtStart
  3156. 0D5BB secondNametableIsIn24
  3157. 0D5BB
  3158. 0D5BB A9 24 LDA #$24
  3159. 0D5BD 85 04 STA tempx
  3160. 0D5BF A9 27 LDA #$27
  3161. 0D5C1 85 05 STA tempy
  3162. 0D5C3 gotSecondNtStart:
  3163. 0D5C3
  3164. 0D5C3
  3165. 0D5C3 AD 74 06 LDA currentNametable
  3166. 0D5C6 4A LSR
  3167. 0D5C7 4A LSR
  3168. 0D5C8 4A LSR
  3169. 0D5C9 4A LSR
  3170. 0D5CA 4A LSR
  3171. 0D5CB 85 00 STA temp ;; this is the screen bank.
  3172. 0D5CD
  3173. 0D5CD AD 74 06 LDA currentNametable
  3174. 0D5D0 18 CLC
  3175. 0D5D1 69 01 ADC #$01
  3176. 0D5D3 85 01 STA temp1
  3177. 0D5D5 4A LSR
  3178. 0D5D6 4A LSR
  3179. 0D5D7 4A LSR
  3180. 0D5D8 4A LSR
  3181. 0D5D9 4A LSR
  3182. 0D5DA 85 00 STA temp ;; this is the screen bank.
  3183. 0D5DC AD A4 06 LDA warpMap
  3184. 0D5DF ;;; and other screen bytes needed - warp map is either 0 or 1
  3185. 0D5DF 85 02 STA temp2
  3186. 0D5E1
  3187. 0D5E1 A5 00 85 0C A5 01 85 0D.. LoadNametableData temp, temp1, temp2, #$08, #$0F, tempx, #$00, #$00
  3188. 0D643 20 FB C8 JSR doWaitFrame
  3189. 0D646 AD 74 06 LDA currentNametable
  3190. 0D649 4A LSR
  3191. 0D64A 4A LSR
  3192. 0D64B 4A LSR
  3193. 0D64C 4A LSR
  3194. 0D64D 4A LSR
  3195. 0D64E 85 00 STA temp ;; this is the screen bank.
  3196. 0D650 AD A4 06 LDA warpMap
  3197. 0D653 ;;; and other screen bytes needed - warp map is either 0 or 1
  3198. 0D653 85 02 STA temp2
  3199. 0D655
  3200. 0D655 A5 00 85 0C A5 01 85 0D.. LoadAttributeData temp, temp1, temp2, #$04, #$08, tempy, #$C0, #$00
  3201. 0D6B7 20 FB C8 JSR doWaitFrame
  3202. 0D6BA
  3203. 0D6BA
  3204. 0D6BA
  3205. 0D6BA AD 74 06 LDA currentNametable
  3206. 0D6BD 38 sec
  3207. 0D6BE E9 01 sbc #$01
  3208. 0D6C0 85 01 STA temp1
  3209. 0D6C2 4A LSR
  3210. 0D6C3 4A LSR
  3211. 0D6C4 4A LSR
  3212. 0D6C5 4A LSR
  3213. 0D6C6 4A LSR
  3214. 0D6C7 85 00 STA temp ;; this is the screen bank.
  3215. 0D6C9 AD A4 06 LDA warpMap
  3216. 0D6CC ;;; and other screen bytes needed - warp map is either 0 or 1
  3217. 0D6CC 85 02 STA temp2
  3218. 0D6CE
  3219. 0D6CE A5 00 85 0C A5 01 85 0D.. LoadNametableData temp, temp1, temp2, #$08, #$0F, tempx, #$10, #$08
  3220. 0D730 20 FB C8 JSR doWaitFrame
  3221. 0D733 AD 74 06 LDA currentNametable
  3222. 0D736 38 sec
  3223. 0D737 E9 01 sbc #$01
  3224. 0D739 85 01 STA temp1
  3225. 0D73B 4A LSR
  3226. 0D73C 4A LSR
  3227. 0D73D 4A LSR
  3228. 0D73E 4A LSR
  3229. 0D73F 4A LSR
  3230. 0D740 85 00 STA temp ;; this is the screen bank.
  3231. 0D742 AD A4 06 LDA warpMap
  3232. 0D745 ;;; and other screen bytes needed - warp map is either 0 or 1
  3233. 0D745 85 02 STA temp2
  3234. 0D747
  3235. 0D747 A5 00 85 0C A5 01 85 0D.. LoadAttributeData temp, temp1, temp2, #$04, #$08, tempy, #$C4, #$04
  3236. 0D7A9 20 FB C8 JSR doWaitFrame
  3237. 0D7AC
  3238. 0D7AC AD 74 06 LDA currentNametable
  3239. 0D7AF 18 CLC
  3240. 0D7B0 69 01 ADC #$01
  3241. 0D7B2 85 01 STA temp1
  3242. 0D7B4 4A LSR
  3243. 0D7B5 4A LSR
  3244. 0D7B6 4A LSR
  3245. 0D7B7 4A LSR
  3246. 0D7B8 4A LSR
  3247. 0D7B9 85 00 STA temp ;; this is the screen bank.
  3248. 0D7BB AD A4 06 LDA warpMap
  3249. 0D7BE ;;; and other screen bytes needed - warp map is either 0 or 1
  3250. 0D7BE 85 02 STA temp2
  3251. 0D7C0
  3252. 0D7C0 A5 00 85 0C A5 01 85 0D.. LoadCollisionData temp, temp1, temp2, #$08, #$0F, #$00, #$00, #$01
  3253. 0D822 20 FB C8 JSR doWaitFrame
  3254. 0D825
  3255. 0D825 AD 74 06 LDA currentNametable
  3256. 0D828 38 sec
  3257. 0D829 E9 01 sbc #$01
  3258. 0D82B 85 01 STA temp1
  3259. 0D82D 4A LSR
  3260. 0D82E 4A LSR
  3261. 0D82F 4A LSR
  3262. 0D830 4A LSR
  3263. 0D831 4A LSR
  3264. 0D832 85 00 STA temp ;; this is the screen bank.
  3265. 0D834 AD A4 06 LDA warpMap
  3266. 0D837 ;;; and other screen bytes needed - warp map is either 0 or 1
  3267. 0D837 85 02 STA temp2
  3268. 0D839
  3269. 0D839 A5 00 85 0C A5 01 85 0D.. LoadCollisionData temp, temp1, temp2, #$08, #$0F, #$00, #$08, #$01
  3270. 0D89B 20 FB C8 JSR doWaitFrame
  3271. 0D89E
  3272. 0D89E
  3273. 0D89E
  3274. 0D89E 60 RTS
  3275. 0D89F
  3276. 0D89F
  3277. 0D89F monsterPositionOffsetTable: ;; normal state monster.
  3278. 0D89F 83 84 85 9E .db #131, #132, #133, #1580D8A3
  3279. 0D8A3 .include Routines\BASE_4_5\\Game\Subroutines\ToggleTables.asm
  3280. 0D8A3 ToggleNametable
  3281. 0D8A3 AD 8E 06 LDA updateNametable
  3282. 0D8A6 C9 20 CMP #$20
  3283. 0D8A8 D0 05 BNE switchToLeftNametable
  3284. 0D8AA ;; switch to right nametable
  3285. 0D8AA A9 24 LDA #$24
  3286. 0D8AC 4C B1 D8 JMP gotNametableToView
  3287. 0D8AF switchToLeftNametable:
  3288. 0D8AF A9 20 LDA #$20
  3289. 0D8B1 gotNametableToView:
  3290. 0D8B1 8D 8E 06 STA updateNametable
  3291. 0D8B4 60 RTS
  3292. 0D8B5
  3293. 0D8B5 ToggleAttributeTable
  3294. 0D8B5 AD 8F 06 LDA updateAttributeTable
  3295. 0D8B8 C9 23 CMP #$23
  3296. 0D8BA D0 05 BNE switchToLeftAtttable
  3297. 0D8BC ;; switch to right nametable
  3298. 0D8BC A9 27 LDA #$27
  3299. 0D8BE 4C C3 D8 JMP gotAttToView
  3300. 0D8C1 switchToLeftAtttable:
  3301. 0D8C1 A9 23 LDA #$23
  3302. 0D8C3 gotAttToView:
  3303. 0D8C3 8D 8F 06 STA updateAttributeTable
  3304. 0D8C6 60 RTS
  3305. 0D8C7
  3306. 0D8C7
  3307. 0D8C7 FactorSecondAttributeTable:
  3308. 0D8C7 ;; based on camera
  3309. 0D8C7 AD 86 06 LDA camX_hi
  3310. 0D8CA 29 01 AND #%00000001
  3311. 0D8CC F0 05 BEQ secondAttTableIs27
  3312. 0D8CE A9 23 LDA #$23
  3313. 0D8D0 4C D5 D8 JMP gotSecondAttTable
  3314. 0D8D3 secondAttTableIs27
  3315. 0D8D3 A9 27 LDA #$27
  3316. 0D8D5 gotSecondAttTable
  3317. 0D8D5 8D 8F 06 STA updateAttributeTable
  3318. 0D8D8
  3319. 0D8D8 60 RTS
  3320. 0D8D9
  3321. 0D8D9
  3322. 0D8D9
  3323. 0D8D9 ValToBitTable:
  3324. 0D8D9 80 40 20 10 08 04 02 01 .db #%10000000, #%01000000, #%00100000, #%00010000, #%00001000, #%00000100, #%00000010, #%00000001
  3325. 0D8E1
  3326. 0D8E1 ValToBitTable_inverse:
  3327. 0D8E1 01 02 04 08 10 20 40 80 .db #%00000001, #%00000010, #%000000100, #%00001000, #%00010000, #%00100000, #%01000000, #%10000000
  3328. 0D8E9
  3329. 0D8E9
  3330. 0D8E9 DirectionTable:
  3331. 0D8E9 30 20 80 C0 F0 E0 A0 B0 .db #DOWN, #UP, #LEFT, #RIGHT, #DOWNRIGHT, #UPRIGHT, #UPLEFT, #DOWNLEFT
  3332. 0D8F1
  3333. 0D8F1 FacingTable
  3334. 0D8F1 00 04 06 02 01 03 05 07 .db #FACE_DOWN, #FACE_UP, #FACE_LEFT, #FACE_RIGHT, #FACE_DOWNRIGHT, #FACE_UPRIGHT, #FACE_UPLEFT, #FACE_DOWNLEFT
  3335. 0D8F9
  3336. 0D8F9 DirectionTableOrdered:
  3337. 0D8F9 30 F0 C0 E0 20 A0 80 B0 .db #DOWN, #DOWNRIGHT, #RIGHT, #UPRIGHT, #UP, #UPLEFT, #LEFT, #DOWNLEFT
  3338. 0D901 FacingTableOrdered:
  3339. 0D901 00 01 02 03 04 05 06 07 .db #FACE_DOWN, #FACE_DOWNRIGHT, #FACE_RIGHT, #FACE_UPRIGHT, #FACE_UP, #FACE_UPLEFT, #FACE_LEFT, #FACE_DOWNLEFT
  3340. 0D909
  3341. 0D909
  3342. 0D909
  3343. 0D909 .include GameData\HUD_DEFINES.dat ;; because of tables created, this is a better place for this than constants.
  3344. 0D909 ;; *************** HUD_DEFINES.dat ***************
  3345. 0D909 ;; HUD defines export. Saturday, March 6, 2021 6:48:13 PM
  3346. 0D909
  3347. 0D909 CHECK_SPRITE_ZERO = $00
  3348. 0D909 SPRITE_ZERO_INDEX = $00
  3349. 0D909 SPRITE_ZERO_HBLANK = $00
  3350. 0D909 SPRITE_ZERO_X = $00
  3351. 0D909 SPRITE_ZERO_Y = $00
  3352. 0D909
  3353. 0D909 HUD_LOAD = $00
  3354. 0D909
  3355. 0D909
  3356. 0D909 HudAssetType_Table:
  3357. 0D909 FF FF FF FF .db #BOX_0_ASSET_0_TYPE, #BOX_0_ASSET_1_TYPE, #BOX_0_ASSET_2_TYPE, #BOX_0_ASSET_3_TYPE
  3358. 0D90D FF FF FF FF .db #BOX_0_ASSET_4_TYPE, #BOX_0_ASSET_5_TYPE, #BOX_0_ASSET_6_TYPE, #BOX_0_ASSET_7_TYPE
  3359. 0D911
  3360. 0D911 HudOffsetX_Table:
  3361. 0D911 00 00 00 00 .db #BOX_0_ASSET_0_X, #BOX_0_ASSET_1_X, #BOX_0_ASSET_2_X, #BOX_0_ASSET_3_X
  3362. 0D915 00 00 00 00 .db #BOX_0_ASSET_4_X, #BOX_0_ASSET_5_X, #BOX_0_ASSET_6_X, #BOX_0_ASSET_7_X
  3363. 0D919
  3364. 0D919 HudOffsetY_Table:
  3365. 0D919 00 00 00 00 .db #BOX_0_ASSET_0_Y, #BOX_0_ASSET_1_Y, #BOX_0_ASSET_2_Y, #BOX_0_ASSET_3_Y
  3366. 0D91D 00 00 00 00 .db #BOX_0_ASSET_4_Y, #BOX_0_ASSET_5_Y, #BOX_0_ASSET_6_Y, #BOX_0_ASSET_7_Y
  3367. 0D921
  3368. 0D921
  3369. 0D921 HudMaxValue:
  3370. 0D921 00 00 00 00 .db #BOX_0_ASSET_0_MAX_VALUE, #BOX_0_ASSET_1_MAX_VALUE, #BOX_0_ASSET_2_MAX_VALUE, #BOX_0_ASSET_3_MAX_VALUE
  3371. 0D925 00 00 00 00 .db #BOX_0_ASSET_4_MAX_VALUE, #BOX_0_ASSET_5_MAX_VALUE, #BOX_0_ASSET_6_MAX_VALUE, #BOX_0_ASSET_7_MAX_VALUE
  3372. 0D929
  3373. 0D929 HudFullImage: ;; really, only used for var tiles, but we can waste 8 bytes to save on more lost to complex rom data
  3374. 0D929 00 00 00 00 .db #$00, #$00, #$00, #$00
  3375. 0D92D 00 00 00 00 .db #$00, #$00, #$00, #$00
  3376. 0D931
  3377. 0D931 HudBlankImage: ;;;; really, only used for var tiles, but we can waste 8 bytes to save on more lost to complex rom data
  3378. 0D931 00 00 00 00 .db #BOX_0_ASSET_0_BLANK, #BOX_0_ASSET_1_BLANK, #BOX_0_ASSET_2_BLANK, #BOX_0_ASSET_3_BLANK
  3379. 0D935 00 00 00 00 .db #BOX_0_ASSET_4_BLANK, #BOX_0_ASSET_5_BLANK, #BOX_0_ASSET_6_BLANK, #BOX_0_ASSET_7_BLANK
  3380. 0D939
  3381. 0D939
  3382. 0D939 NumberBaseTable:
  3383. 0D939 00 01 02 03 04 05 06 07.. .db #$00, #$01, #$02, #$03, #$04, #$05, #$06, #$07, #$08, #$09
  3384. 0D943
  3385. 0D943
  3386. 0D943 ;; use this defined script for any extraneous tables.
  3387. 0D943 .include "Routines\BASE_4_5\Game\Space Birds\Game\SPACEBIRDS_ExtraTables.asm"
  3388. 0D943
  3389. 0D943 ;;;
  3390. 0D943 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3391. 0D943 ;; here, we load in <label and >label for each library value we might want.
  3392. 0D943 TextLibrary_lo:
  3393. 0D943 00 .db #$00
  3394. 0D944 TextLibrary_hi:
  3395. 0D944 00 .db #$00
  3396. 0D945 CheatCodeTable1:
  3397. 0D945 02 02 02 01 01 01 02 01 .db #$02, #$02, #$02, #$01, #$01, #$01, #$02, #$01
  3398. 0D94D DrawSprite_opcode_table:
  3399. 0D94D FA 95 .word DrawPlayer1-1
  3400. 0D94F 9D 96 .word DrawPlayer2-1
  3401. 0D951 40 97 .word DrawMonsterBullet-1
  3402. 0D953 94 97 .word DrawMissile1-1
  3403. 0D955 BA 97 .word DrawMissile2-1
  3404. 0D957 E0 97 .word DrawObject5-1
  3405. 0D959 E1 97 .word DrawObject6-1
  3406. 0D95B E2 97 .word DrawObject7-1
  3407. 0D95D E3 97 .word DrawObject8-1
  3408. 0D95F E4 97 .word DrawObject9-1
  3409. 0D961 E5 97 .word DrawObjectA-1
  3410. 0D963 E6 97 .word DrawObjectB-1
  3411. 0D965 E7 97 .word DrawObjectC-1
  3412. 0D967 E8 97 .word DrawObjectD-1
  3413. 0D969 E9 97 .word DrawObjectE-1
  3414. 0D96B EA 97 .word DrawObjectF-1
  3415. 0D96D EB 97 .word DrawAlien-1
  3416. 0D96F 8E 98 .word DrawAlienShooter-10D971 .include Routines\BASE_4_5\\Game\Subroutines\ejectionSubroutines.asm
  3417. 0D971
  3418. 0D971 doEjectLeft:
  3419. 0D971
  3420. 0D971 BD 1A 04 LDA Object_x_hi,x
  3421. 0D974 18 CLC
  3422. 0D975 69 10 ADC #$10; self_right
  3423. 0D977 29 F0 AND #%11110000
  3424. 0D979 38 SEC
  3425. 0D97A E9 10 SBC #$10
  3426. 0D97C 9D 1A 04 STA Object_x_hi,x
  3427. 0D97F A9 00 LDA #$00
  3428. 0D981 9D 0D 04 STA Object_x_lo,x
  3429. 0D984 9D 5B 04 STA Object_h_speed_hi,x
  3430. 0D987 9D 4E 04 STA Object_h_speed_lo,x
  3431. 0D98A 60 rts
  3432. 0D98B doEjectRight:
  3433. 0D98B
  3434. 0D98B BD 1A 04 LDA Object_x_hi,x
  3435. 0D98E 18 clc
  3436. 0D98F 6D 59 06 adc self_left
  3437. 0D992 29 F0 AND #%11110000
  3438. 0D994 18 CLC
  3439. 0D995 69 10 ADC #$10
  3440. 0D997 18 clc
  3441. 0D998 6D 59 06 adc self_left
  3442. 0D99B 9D 1A 04 STA Object_x_hi,x
  3443. 0D99E A9 00 LDA #$00
  3444. 0D9A0 9D 0D 04 STA Object_x_lo,x
  3445. 0D9A3 9D 5B 04 STA Object_h_speed_hi,x
  3446. 0D9A6 9D 4E 04 STA Object_h_speed_lo,x
  3447. 0D9A9 60 RTS
  3448. 0D9AA
  3449. 0D9AA
  3450. 0D9AA doEjectUp:
  3451. 0D9AA
  3452. 0D9AA BD 41 04 LDA Object_y_hi,x
  3453. 0D9AD 18 CLC
  3454. 0D9AE 6D 5C 06 ADC self_bottom
  3455. 0D9B1 29 F0 AND #%11110000
  3456. 0D9B3 38 SEC
  3457. 0D9B4 E9 10 SBC #$10
  3458. 0D9B6
  3459. 0D9B6 9D 41 04 STA Object_y_hi,x
  3460. 0D9B9 A9 00 LDA #$00
  3461. 0D9BB 9D 34 04 STA Object_y_lo,x
  3462. 0D9BE 9D 75 04 STA Object_v_speed_hi,x
  3463. 0D9C1 9D 68 04 STA Object_v_speed_lo,x
  3464. 0D9C4 60 RTS
  3465. 0D9C5
  3466. 0D9C5 doEjectDown:
  3467. 0D9C5
  3468. 0D9C5 BD 41 04 LDA Object_y_hi,x
  3469. 0D9C8 18 clc
  3470. 0D9C9 6D 5A 06 adc self_top
  3471. 0D9CC 29 F0 AND #%11110000
  3472. 0D9CE 18 CLC
  3473. 0D9CF 69 10 ADC #$10
  3474. 0D9D1 18 clc
  3475. 0D9D2 6D 5A 06 adc self_top
  3476. 0D9D5 9D 41 04 STA Object_y_hi,x
  3477. 0D9D8 A9 00 LDA #$00
  3478. 0D9DA 9D 34 04 STA Object_y_lo,x
  3479. 0D9DD 9D 75 04 STA Object_v_speed_hi,x
  3480. 0D9E0 9D 68 04 STA Object_v_speed_lo,x
  3481. 0D9E3 60 Rts
  3482. 0D9E4
  3483. 0D9E4 .include Routines\BASE_4_5\\Game\Subroutines\doLoadScreenData.asm
  3484. 0D9E4 doLoadScreenData:
  3485. 0D9E4
  3486. 0D9E4 ; JSR doClearAllMonsters
  3487. 0D9E4
  3488. 0D9E4 A9 00 LDA #$00
  3489. 0D9E6 85 2C STA spriteRamPointer
  3490. 0D9E8 20 ED C8 JSR doCleanUpSpriteRam
  3491. 0D9EB
  3492. 0D9EB
  3493. 0D9EB
  3494. 0D9EB 98 48 AD 20 06 8D 21 06.. SwitchBank arg0_hold
  3495. 0D9FA
  3496. 0D9FA ;;;;;;;;;;;;;;;;;;;;;
  3497. 0D9FA ;;; By default, screen data begins
  3498. 0D9FA ;;; 120 (dec) beyond the collision table label,
  3499. 0D9FA ;;; which is currently stored to collisionPointer.
  3500. 0D9FA A0 78 LDY #120
  3501. 0D9FC ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3502. 0D9FC ;=======================================
  3503. 0D9FC ;SET SCREEN TYPE
  3504. 0D9FC ;#120
  3505. 0D9FC B1 3F LDA (collisionPointer),y
  3506. 0D9FE 8D 9E 06 STA screenType
  3507. 0DA01 ;=======================================
  3508. 0DA01 C8 INY
  3509. 0DA02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3510. 0DA02 ;; #121 Legacied - was GraphicsBank - now screen bank is handled via logic.
  3511. 0DA02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3512. 0DA02 C8 INY
  3513. 0DA03 ;========================================
  3514. 0DA03 ;SET SCREEN PALETTE
  3515. 0DA03 ;#122
  3516. 0DA03 B1 3F LDA (collisionPointer),y ;; this is the palette data
  3517. 0DA05 8D 9D 06 STA newPal
  3518. 0DA08 ;=======================================
  3519. 0DA08 C8 INY
  3520. 0DA09 ;=======================================
  3521. 0DA09 ;; #123 Legacied - was MaineTileID / ScreenTileID, now handled in bytes below
  3522. 0DA09 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3523. 0DA09 C8 INY
  3524. 0DA0A ;=======================================
  3525. 0DA0A ;; #124 - Screen Byte 00
  3526. 0DA0A B1 3F LDA (collisionPointer),y
  3527. 0DA0C 8D 9F 06 STA ScreenFlags00
  3528. 0DA0F ;;; ScreenByte00 hold the screen flags.
  3529. 0DA0F ;=======================================
  3530. 0DA0F C8 INY
  3531. 0DA10 ;=======================================
  3532. 0DA10 ;; #125 - ScreenByte01 stuff.
  3533. 0DA10 ;first, load screenSpeed
  3534. 0DA10 B1 3F LDA (collisionPointer),y
  3535. 0DA12 8D A1 06 STA ScreenByte01
  3536. 0DA15 29 03 AND #%00000011
  3537. 0DA17 8D A2 06 STA screenSpeed
  3538. 0DA1A ; ;;;;;;;;;;;;;;;;;;;;;;
  3539. 0DA1A ; ;;; DO OTHER SCREEN BYTE 1 THINGS HERE!
  3540. 0DA1A ;=========================================
  3541. 0DA1A C8 INY
  3542. 0DA1B ;=========================================
  3543. 0DA1B
  3544. 0DA1B ;; #126 - Load paths, through a loop to figure out path choices
  3545. 0DA1B B1 3F LDA (collisionPointer),y
  3546. 0DA1D 85 00 STA temp
  3547. 0DA1F
  3548. 0DA1F 98 TYA
  3549. 0DA20 48 PHA
  3550. 0DA21
  3551. 0DA21 A0 00 LDY #$00
  3552. 0DA23 A2 00 LDX #$00
  3553. 0DA25 loadPathTilesLoop:
  3554. 0DA25 A5 00 LDA temp
  3555. 0DA27 39 D9 D8 AND ValToBitTable,y
  3556. 0DA2A F0 0D BEQ notFirstPath
  3557. 0DA2C 98 TYA
  3558. 0DA2D 9D A6 06 STA pathTile00,x
  3559. 0DA30 E8 INX
  3560. 0DA31 E0 04 CPX #$04
  3561. 0DA33 F0 08 BEQ doneGettingPaths
  3562. 0DA35 C8 INY
  3563. 0DA36 4C 25 DA JMP loadPathTilesLoop
  3564. 0DA39 notFirstPath:
  3565. 0DA39 C8 INY
  3566. 0DA3A
  3567. 0DA3A 4C 25 DA JMP loadPathTilesLoop
  3568. 0DA3D doneGettingPaths:
  3569. 0DA3D A4 05 LDY tempy
  3570. 0DA3F
  3571. 0DA3F 68 PLA
  3572. 0DA40 A8 TAY
  3573. 0DA41 ;========================================
  3574. 0DA41 C8 INY
  3575. 0DA42 ;========================================
  3576. 0DA42 ;; 127 - Warp out screen
  3577. 0DA42 B1 3F LDA (collisionPointer),y
  3578. 0DA44 8D A3 06 STA warpToScreen
  3579. 0DA47 ;=======================================
  3580. 0DA47 C8 INY
  3581. 0DA48 ;=======================================
  3582. 0DA48 ;; 128 - Warp In Position
  3583. 0DA48 ;; This might need to be skipped under certain warp conditions
  3584. 0DA48 ;; and should only be observed if the transition is of warp type.
  3585. 0DA48 AD A5 06 LDA screenTransitionType
  3586. 0DA4B F0 29 BEQ skipSettingWarpInXY
  3587. 0DA4D C9 01 CMP #$01
  3588. 0DA4F F0 13 BEQ setToStartValue
  3589. 0DA51 C9 02 CMP #$02
  3590. 0DA53 F0 00 BEQ setToContinueValue
  3591. 0DA55 ;;; other cases go here
  3592. 0DA55 setToContinueValue
  3593. 0DA55 AD D3 06 LDA continueX
  3594. 0DA58 8D 75 06 STA newX
  3595. 0DA5B AD D4 06 LDA continueY
  3596. 0DA5E 8D 76 06 STA newY
  3597. 0DA61 4C 76 DA JMP skipSettingWarpInXY
  3598. 0DA64 setToStartValue:
  3599. 0DA64
  3600. 0DA64 B1 3F LDA (collisionPointer),y
  3601. 0DA66 29 F0 AND #%11110000
  3602. 0DA68 8D 76 06 STA newY
  3603. 0DA6B
  3604. 0DA6B B1 3F LDA (collisionPointer),y
  3605. 0DA6D 29 0F AND #%00001111
  3606. 0DA6F 0A ASL
  3607. 0DA70 0A ASL
  3608. 0DA71 0A ASL
  3609. 0DA72 0A ASL
  3610. 0DA73 8D 75 06 STA newX
  3611. 0DA76
  3612. 0DA76
  3613. 0DA76 skipSettingWarpInXY:
  3614. 0DA76 A9 00 LDA #$00
  3615. 0DA78 8D A5 06 STA screenTransitionType ;; reset screen transition type
  3616. 0DA7B ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3617. 0DA7B ;==========================================
  3618. 0DA7B C8 INY
  3619. 0DA7C ;==========================================
  3620. 0DA7C ;; 129 - Legacied - used to be screen type and song number.
  3621. 0DA7C ;; Also, may have handled banks for monsters based on state.
  3622. 0DA7C ;==========================================
  3623. 0DA7C C8 INY
  3624. 0DA7D ;;=========================================
  3625. 0DA7D ;; 130 - needed bits
  3626. 0DA7D
  3627. 0DA7D B1 3F LDA (collisionPointer),y
  3628. 0DA7F 8D 96 06 STA screenLoadTemps ;; this is whether screen should load 8x8 or 16x16.
  3629. 0DA82 ; LDA (collisionPointer),y
  3630. 0DA82 29 01 AND #%00000001 ;; is this overworld or underworld map?
  3631. 0DA84 8D C8 06 STA warpToMap
  3632. 0DA87
  3633. 0DA87 AD 96 06 LDA screenLoadTemps
  3634. 0DA8A 29 70 AND #%01110000
  3635. 0DA8C 4A LSR
  3636. 0DA8D 4A LSR
  3637. 0DA8E 4A LSR
  3638. 0DA8F 4A LSR
  3639. 0DA90 29 07 AND #%00000111
  3640. 0DA92 85 2B STA gameState
  3641. 0DA94 ;;;;;========================================================
  3642. 0DA94 ;;;;;========================================================
  3643. 0DA94
  3644. 0DA94 ; ;; THIS is where we jump to load state specific data.
  3645. 0DA94 ; ;***********************
  3646. 0DA94 ;JSR GetScreenTriggerInfo
  3647. 0DA94 ; ;***********************
  3648. 0DA94 ; ;=====================================================
  3649. 0DA94 ;============================================
  3650. 0DA94 ;; 131
  3651. 0DA94
  3652. 0DA94 A0 B6 LDY #182
  3653. 0DA96 B1 3F LDA (collisionPointer),y
  3654. 0DA98 8D A0 06 STA ScreenFlags01
  3655. 0DA9B
  3656. 0DA9B
  3657. 0DA9B
  3658. 0DA9B A0 C4 LDY #196
  3659. 0DA9D B1 3F LDA (collisionPointer),y
  3660. 0DA9F
  3661. 0DA9F 8D 46 06 STA tileLayout
  3662. 0DAA2 C8 INY
  3663. 0DAA3 B1 3F LDA (collisionPointer),y
  3664. 0DAA5 8D 97 06 STA backgroundTilesToLoad
  3665. 0DAA8 C8 INY
  3666. 0DAA9 B1 3F LDA (collisionPointer),y
  3667. 0DAAB 8D 98 06 STA backgroundTilesToLoad+1
  3668. 0DAAE C8 INY
  3669. 0DAAF B1 3F LDA (collisionPointer),y
  3670. 0DAB1 8D 99 06 STA backgroundTilesToLoad+2
  3671. 0DAB4 C8 INY
  3672. 0DAB5 B1 3F LDA (collisionPointer),y
  3673. 0DAB7 8D 9A 06 STA backgroundTilesToLoad+3
  3674. 0DABA C8 INY
  3675. 0DABB B1 3F LDA (collisionPointer),y
  3676. 0DABD 8D 9B 06 STA backgroundTilesToLoad+4
  3677. 0DAC0 C8 INY
  3678. 0DAC1 B1 3F LDA (collisionPointer),y
  3679. 0DAC3 8D 9C 06 STA backgroundTilesToLoad+5
  3680. 0DAC6
  3681. 0DAC6
  3682. 0DAC6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3683. 0DAC6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3684. 0DAC6 ;;;;;; Handle state based data.
  3685. 0DAC6 8A TXA
  3686. 0DAC7 48 PHA
  3687. 0DAC8 20 13 DB JSR GetScreenTriggerInfo
  3688. 0DACB
  3689. 0DACB
  3690. 0DACB
  3691. 0DACB 68 PLA
  3692. 0DACC AA TAX
  3693. 0DACD
  3694. 0DACD
  3695. 0DACD ;;;;;;;;;;;;;;;; THERE WILL BE BYTES
  3696. 0DACD ;;;;;;;;;;;;;;;; That will contian this information on a screen by screen basis.
  3697. 0DACD ;;;;;;;;;;;;;;;; 00 = pacman
  3698. 0DACD ;;;;;;;;;;;;;;;; 01 = zelda screen
  3699. 0DACD ;;;;;;;;;;;;;;;; 02 = scroll (which updates the Object_screen,x
  3700. 0DACD ;;;;;;;;;;;;;;;; 03 = acts as a solid edge.
  3701. 0DACD
  3702. 0DACD ;;;;;;;;;;;;;;;; Right now, this is being hard coded.
  3703. 0DACD A9 00 LDA #%00000000
  3704. 0DACF 8D AA 06 STA screenEdgeBehavior
  3705. 0DAD2
  3706. 0DAD2 98 48 AC 21 06 20 83 C5.. ReturnBank
  3707. 0DADC
  3708. 0DADC getTextForScreen:
  3709. 0DADC 98 48 AD 20 06 8D 21 06.. SwitchBank #$16
  3710. 0DAEB
  3711. 0DAEB A5 8C LDA stringGroupPointer ;; this is the group of the string.
  3712. 0DAED 0A ASL
  3713. 0DAEE 0A ASL
  3714. 0DAEF A8 TAY
  3715. 0DAF0 B9 00 80 LDA AllTextGroups,y
  3716. 0DAF3 85 8D STA screenText
  3717. 0DAF5 C8 INY
  3718. 0DAF6 B9 00 80 LDA AllTextGroups,y
  3719. 0DAF9 85 8E STA screenText+1
  3720. 0DAFB C8 INY
  3721. 0DAFC B9 00 80 LDA AllTextGroups,y
  3722. 0DAFF 85 8F STA screenText+2
  3723. 0DB01 C8 INY
  3724. 0DB02 B9 00 80 LDA AllTextGroups,y
  3725. 0DB05 85 90 STA screenText+3
  3726. 0DB07
  3727. 0DB07 98 48 AC 21 06 20 83 C5.. ReturnBank
  3728. 0DB11 60 RTS
  3729. 0DB12
  3730. 0DB12
  3731. 0DB12
  3732. 0DB12
  3733. 0DB12 60 RTS
  3734. 0DB13
  3735. 0DB13
  3736. 0DB13
  3737. 0DB13
  3738. 0DB13
  3739. 0DB13
  3740. 0DB13
  3741. 0DB13 GetScreenTriggerInfo:
  3742. 0DB13 20 01 DE JSR doClearAllMonsters
  3743. 0DB16 ;;;;; MONSTERS
  3744. 0DB16 ;;; constants for banks
  3745. 0DB16
  3746. 0DB16
  3747. 0DB16 8A 48 98 48 AD 9E 06 29.. GetTrigger
  3748. 0DB39
  3749. 0DB39 ;; result of screenType trigger stored in temp3 and also in accum
  3750. 0DB39 ;; x and y restored.
  3751. 0DB39 F0 2B BEQ thisScreenIsNotTriggered
  3752. 0DB3B ;; this screen IS triggered
  3753. 0DB3B AD AB 06 LDA gameHandler
  3754. 0DB3E 29 01 AND #%00000001 ;; one = night
  3755. 0DB40 F0 13 BEQ isTriggeredDay
  3756. 0DB42 ;; triggered and night
  3757. 0DB42 A9 03 LDA #$03
  3758. 0DB44 85 98 STA screenState
  3759. 0DB46 AA TAX
  3760. 0DB47 A0 98 LDY #152
  3761. 0DB49 B1 3F LDA (collisionPointer),y
  3762. 0DB4B 4A LSR
  3763. 0DB4C 4A LSR
  3764. 0DB4D 4A LSR
  3765. 0DB4E 4A LSR
  3766. 0DB4F ; LDA #$03
  3767. 0DB4F 8D AC 06 STA monsterTableOffset
  3768. 0DB52 4C 91 DB JMP triggeredStateInfoIsLoaded
  3769. 0DB55 isTriggeredDay
  3770. 0DB55
  3771. 0DB55 ;; triggered and day
  3772. 0DB55 A9 02 LDA #$02
  3773. 0DB57 85 98 STA screenState
  3774. 0DB59 AA TAX
  3775. 0DB5A A0 99 LDY #153
  3776. 0DB5C B1 3F LDA (collisionPointer),y
  3777. 0DB5E 29 0F AND #%00001111
  3778. 0DB60 ; LDA #$02
  3779. 0DB60 8D AC 06 STA monsterTableOffset
  3780. 0DB63
  3781. 0DB63 4C 91 DB JMP triggeredStateInfoIsLoaded
  3782. 0DB66 ;;=================================
  3783. 0DB66 thisScreenIsNotTriggered
  3784. 0DB66 4C 83 DB JMP isNormalDay
  3785. 0DB69 AD AB 06 LDA gameHandler
  3786. 0DB6C 29 01 AND #%00000001 ;; one = night
  3787. 0DB6E F0 13 BEQ isNormalDay
  3788. 0DB70
  3789. 0DB70 ;; normal and night
  3790. 0DB70 A9 01 LDA #$01
  3791. 0DB72 85 98 STA screenState
  3792. 0DB74 AA TAX
  3793. 0DB75 A0 98 LDY #152
  3794. 0DB77 B1 3F LDA (collisionPointer),y
  3795. 0DB79 4A LSR
  3796. 0DB7A 4A LSR
  3797. 0DB7B 4A LSR
  3798. 0DB7C 4A LSR
  3799. 0DB7D ; LDA #$01
  3800. 0DB7D 8D AC 06 STA monsterTableOffset
  3801. 0DB80 4C 91 DB JMP triggeredStateInfoIsLoaded
  3802. 0DB83 isNormalDay:
  3803. 0DB83
  3804. 0DB83 ;; normal and day
  3805. 0DB83 A9 00 LDA #$00
  3806. 0DB85 85 98 STA screenState
  3807. 0DB87 AA TAX
  3808. 0DB88 ;;;;;;;;;;;
  3809. 0DB88 ;Load correspnding monster tileset.
  3810. 0DB88 A0 98 LDY #152
  3811. 0DB8A B1 3F LDA (collisionPointer),y
  3812. 0DB8C 29 0F AND #%00001111
  3813. 0DB8E ; LDA #$00
  3814. 0DB8E 8D AC 06 STA monsterTableOffset
  3815. 0DB91 triggeredStateInfoIsLoaded:
  3816. 0DB91
  3817. 0DB91 ;;=================================
  3818. 0DB91 ;Now, here, load all of the state specific stuff.
  3819. 0DB91 ;This will use X as an offset for small tables in ZeroOutAssets file.
  3820. 0DB91 ; We'll have to use the stack for any part of these routines that might need X.
  3821. 0DB91 ; ;;;;; considerations for the states.
  3822. 0DB91 ; ;1: Get Object Graphics Bank
  3823. 0DB91 ; ;2: String Data
  3824. 0DB91 ; ;3: Monster Spawn positions
  3825. 0DB91 ; ;4: Monster group (this is more complicated than a single digit)
  3826. 0DB91 ; ;5: Object palettes (also more complicated than a single digit)
  3827. 0DB91 ; ;6: Object tiles to load.
  3828. 0DB91 ; ;7: Object IDs
  3829. 0DB91 ; ;8: Song to play
  3830. 0DB91 ;;=============================================================
  3831. 0DB91 ;;=============================================================
  3832. 0DB91 BD CD F1 LDA StringDataChoice,x
  3833. 0DB94 A8 TAY ;; now y holds the byte offset value for the text string group.
  3834. 0DB95 B1 3F LDA (collisionPointer),y
  3835. 0DB97 85 8C STA stringGroupPointer
  3836. 0DB99
  3837. 0DB99
  3838. 0DB99 8A TXA
  3839. 0DB9A 48 PHA
  3840. 0DB9B ; LDX monsterTableOffset
  3841. 0DB9B ;;; Handle monster 1
  3842. 0DB9B
  3843. 0DB9B 20 36 F2 JSR LoadMonster_1
  3844. 0DB9E ; LDY Mon1SpawnLocation,x
  3845. 0DB9E ; LDA (collisionPointer),y
  3846. 0DB9E ; STA temp
  3847. 0DB9E ; AND #%11110000
  3848. 0DB9E ; CMP #%11110000
  3849. 0DB9E ; BNE loadMon1toPosition
  3850. 0DB9E ; LDA temp
  3851. 0DB9E ; AND #%00001111
  3852. 0DB9E ; CMP #%00000011
  3853. 0DB9E ; BEQ skipLoadingMonster1
  3854. 0DB9E ; ;;; Random / Edge cases here
  3855. 0DB9E
  3856. 0DB9E ; loadMon1toPosition:
  3857. 0DB9E ; ;;;;;;; Load monster 1.
  3858. 0DB9E ; LDY Monster1ID,x
  3859. 0DB9E ; LDA (collisionPointer),y
  3860. 0DB9E ; STA mon1_type
  3861. 0DB9E ; LDY Mon1SpawnLocation,x
  3862. 0DB9E ; LDA (collisionPointer),y
  3863. 0DB9E ; ASL
  3864. 0DB9E ; ASL
  3865. 0DB9E ; ASL
  3866. 0DB9E ; ASL
  3867. 0DB9E ; STA tempB ;; x value in tempB
  3868. 0DB9E ; LDY Mon1SpawnLocation,x
  3869. 0DB9E ; LDA (collisionPointer),y
  3870. 0DB9E ; AND #%11110000
  3871. 0DB9E ; STA tempC ;; y value in tempC
  3872. 0DB9E ; TXA
  3873. 0DB9E ; PHA
  3874. 0DB9E ; CreateObject tempB, tempC, mon1_type, #$00
  3875. 0DB9E
  3876. 0DB9E ; PLA
  3877. 0DB9E ; TAX
  3878. 0DB9E
  3879. 0DB9E
  3880. 0DB9E BC D5 F1 LDY Mon2SpawnLocation,x
  3881. 0DBA1 B1 3F LDA (collisionPointer),y
  3882. 0DBA3 85 00 STA temp
  3883. 0DBA5 29 F0 AND #%11110000
  3884. 0DBA7 C9 F0 CMP #%11110000
  3885. 0DBA9 D0 08 BNE loadMon2toPosition
  3886. 0DBAB A5 00 LDA temp
  3887. 0DBAD 29 0F AND #%00001111
  3888. 0DBAF C9 03 CMP #%00000011
  3889. 0DBB1 F0 4D BEQ skipLoadingMonster2
  3890. 0DBB3 ;;; Random / Edge cases here
  3891. 0DBB3 loadMon2toPosition
  3892. 0DBB3 ;;;;;;;; Load monster 1.
  3893. 0DBB3 BC F9 F1 LDY Monster2ID,x
  3894. 0DBB6 B1 3F LDA (collisionPointer),y
  3895. 0DBB8 8D D7 06 STA mon2_type ;; type of monster loaded into tempA
  3896. 0DBBB BC D5 F1 LDY Mon2SpawnLocation,x
  3897. 0DBBE B1 3F LDA (collisionPointer),y
  3898. 0DBC0 0A ASL
  3899. 0DBC1 0A ASL
  3900. 0DBC2 0A ASL
  3901. 0DBC3 0A ASL
  3902. 0DBC4 85 08 STA tempB ;; x value in tempB
  3903. 0DBC6 BC D5 F1 LDY Mon2SpawnLocation,x
  3904. 0DBC9 B1 3F LDA (collisionPointer),y
  3905. 0DBCB 29 F0 AND #%11110000
  3906. 0DBCD 85 09 STA tempC ;; y value in tempC
  3907. 0DBCF 8A TXA
  3908. 0DBD0 48 PHA
  3909. 0DBD1 20 BA F1 E0 FF D0 03 4C.. CreateObject tempB, tempC, mon2_type, #$00
  3910. 0DBF9 A9 01 LDA #$01
  3911. 0DBFB 9D 82 04 STA Object_id,x
  3912. 0DBFE 68 PLA
  3913. 0DBFF AA TAX
  3914. 0DC00 skipLoadingMonster2:
  3915. 0DC00 ;;; Handle monster 3
  3916. 0DC00
  3917. 0DC00 BC D9 F1 LDY Mon3SpawnLocation,x
  3918. 0DC03 B1 3F LDA (collisionPointer),y
  3919. 0DC05 85 00 STA temp
  3920. 0DC07 29 F0 AND #%11110000
  3921. 0DC09 C9 F0 CMP #%11110000
  3922. 0DC0B D0 08 BNE loadMon3toPosition
  3923. 0DC0D A5 00 LDA temp
  3924. 0DC0F 29 0F AND #%00001111
  3925. 0DC11 C9 03 CMP #%00000011
  3926. 0DC13 F0 4D BEQ skipLoadingMonster3
  3927. 0DC15 ;;; Random / Edge cases here
  3928. 0DC15 loadMon3toPosition
  3929. 0DC15 BC FD F1 LDY Monster3ID,x
  3930. 0DC18 B1 3F LDA (collisionPointer),y
  3931. 0DC1A 8D D8 06 STA mon3_type ;; type of monster loaded into tempA
  3932. 0DC1D BC D9 F1 LDY Mon3SpawnLocation,x
  3933. 0DC20 B1 3F LDA (collisionPointer),y
  3934. 0DC22 0A ASL
  3935. 0DC23 0A ASL
  3936. 0DC24 0A ASL
  3937. 0DC25 0A ASL
  3938. 0DC26 85 08 STA tempB ;; x value in tempB
  3939. 0DC28 BC D9 F1 LDY Mon3SpawnLocation,x
  3940. 0DC2B B1 3F LDA (collisionPointer),y
  3941. 0DC2D 29 F0 AND #%11110000
  3942. 0DC2F 85 09 STA tempC ;; y value in tempC
  3943. 0DC31 8A TXA
  3944. 0DC32 48 PHA
  3945. 0DC33 20 BA F1 E0 FF D0 03 4C.. CreateObject tempB, tempC, mon3_type, #$00
  3946. 0DC5B A9 02 LDA #$02
  3947. 0DC5D 9D 82 04 STA Object_id,x
  3948. 0DC60 68 PLA
  3949. 0DC61 AA TAX
  3950. 0DC62 skipLoadingMonster3:
  3951. 0DC62
  3952. 0DC62 ;;; Handle monster 4
  3953. 0DC62
  3954. 0DC62 BC DD F1 LDY Mon4SpawnLocation,x
  3955. 0DC65 B1 3F LDA (collisionPointer),y
  3956. 0DC67 85 00 STA temp
  3957. 0DC69 29 F0 AND #%11110000
  3958. 0DC6B C9 F0 CMP #%11110000
  3959. 0DC6D D0 08 BNE loadMon4toPosition
  3960. 0DC6F A5 00 LDA temp
  3961. 0DC71 29 0F AND #%00001111
  3962. 0DC73 C9 03 CMP #%00000011
  3963. 0DC75 F0 4D BEQ skipLoadingMonster4
  3964. 0DC77 ;;; Random / Edge cases here
  3965. 0DC77 loadMon4toPosition
  3966. 0DC77 ;;;;;;;; Load monster 1.
  3967. 0DC77 BC 01 F2 LDY Monster4ID,x
  3968. 0DC7A B1 3F LDA (collisionPointer),y
  3969. 0DC7C 8D D9 06 STA mon4_type ;; type of monster loaded into tempA
  3970. 0DC7F BC DD F1 LDY Mon4SpawnLocation,x
  3971. 0DC82 B1 3F LDA (collisionPointer),y
  3972. 0DC84 0A ASL
  3973. 0DC85 0A ASL
  3974. 0DC86 0A ASL
  3975. 0DC87 0A ASL
  3976. 0DC88 85 08 STA tempB ;; x value in tempB
  3977. 0DC8A BC DD F1 LDY Mon4SpawnLocation,x
  3978. 0DC8D B1 3F LDA (collisionPointer),y
  3979. 0DC8F 29 F0 AND #%11110000
  3980. 0DC91 85 09 STA tempC ;; y value in tempC
  3981. 0DC93 8A TXA
  3982. 0DC94 48 PHA
  3983. 0DC95 20 BA F1 E0 FF D0 03 4C.. CreateObject tempB, tempC, mon4_type, #$00
  3984. 0DCBD A9 03 LDA #$03
  3985. 0DCBF 9D 82 04 STA Object_id,x
  3986. 0DCC2 68 PLA
  3987. 0DCC3 AA TAX
  3988. 0DCC4 skipLoadingMonster4:
  3989. 0DCC4 68 PLA
  3990. 0DCC5 AA TAX
  3991. 0DCC6 ;PLA
  3992. 0DCC6 ;TAX
  3993. 0DCC6
  3994. 0DCC6
  3995. 0DCC6 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3996. 0DCC6 ;;============================================================
  3997. 0DCC6 ;;============================================================
  3998. 0DCC6 ;; Load subpalettes
  3999. 0DCC6 ;; HERE is where you could define game object sub palettes by reading a specific byte
  4000. 0DCC6 8A TXA
  4001. 0DCC7 48 PHA
  4002. 0DCC8 A6 98 LDX screenState
  4003. 0DCCA
  4004. 0DCCA BC ED F1 LDY GoPal1Choice,x
  4005. 0DCCD B1 3F LDA (collisionPointer),y
  4006. 0DCCF
  4007. 0DCCF 8D AF 06 STA spriteSubPal3;spriteSubPal1
  4008. 0DCD2 ;LDX screenState
  4009. 0DCD2 BC F1 F1 LDY GoPal2Choice,x
  4010. 0DCD5
  4011. 0DCD5 B1 3F LDA (collisionPointer),y
  4012. 0DCD7
  4013. 0DCD7 8D B0 06 STA spriteSubPal4;spriteSubPal2
  4014. 0DCDA ;LDX screenState
  4015. 0DCDA BC E5 F1 LDY MonPal1Choice,x
  4016. 0DCDD B1 3F LDA (collisionPointer),y
  4017. 0DCDF
  4018. 0DCDF 8D AD 06 STA spriteSubPal1
  4019. 0DCE2 BC E9 F1 LDY MonPal2Choice,x
  4020. 0DCE5 B1 3F LDA (collisionPointer),y
  4021. 0DCE7
  4022. 0DCE7 8D AE 06 STA spriteSubPal2
  4023. 0DCEA 68 PLA
  4024. 0DCEB AA TAX
  4025. 0DCEC
  4026. 0DCEC 98 TYA
  4027. 0DCED 48 PHA
  4028. 0DCEE
  4029. 0DCEE A0 B2 LDY #178
  4030. 0DCF0 B1 3F LDA (collisionPointer),y
  4031. 0DCF2 85 00 STA temp
  4032. 0DCF4 C9 FF CMP #$FF
  4033. 0DCF6 D0 13 BNE notStopSong
  4034. 0DCF8 8D CC 06 STA songToPlay
  4035. 0DCFB A9 FF 8D CC 06 AD CD 06.. StopSound
  4036. 0DD08 4C 1D DD JMP skipSongToPlay
  4037. 0DD0B notStopSong:
  4038. 0DD0B
  4039. 0DD0B CD CC 06 CMP songToPlay
  4040. 0DD0E F0 0D BEQ skipSongToPlay ;; already playing this song
  4041. 0DD10 A5 00 8D CC 06 AD CD 06.. PlaySong temp
  4042. 0DD1D skipSongToPlay:
  4043. 0DD1D
  4044. 0DD1D 68 PLA
  4045. 0DD1E A8 TAY
  4046. 0DD1F
  4047. 0DD1F 60 RTS
  4048. 0DD20
  4049. 0DD20
  4050. 0DD20
  4051. 0DD20
  4052. 0DD20
  4053. 0DD20
  4054. 0DD20
  4055. 0DD20
  4056. 0DD20
  4057. 0DD20
  4058. 0DD20
  4059. 0DD20
  4060. 0DD20
  4061. 0DD20
  4062. 0DD20
  4063. 0DD20
  4064. 0DD20 0DD20 .include Routines\BASE_4_5\\Game\Subroutines\doLoadNametableDataFull.asm
  4065. 0DD20 doLoadNametableDataFull:
  4066. 0DD20 8A TXA
  4067. 0DD21 48 PHA
  4068. 0DD22 98 TYA
  4069. 0DD23 48 PHA
  4070. 0DD24
  4071. 0DD24 98 48 AD 20 06 8D 21 06.. SwitchBank arg0_hold
  4072. 0DD33
  4073. 0DD33 A5 0F LDA arg3_hold
  4074. 0DD35 8D 06 20 STA $2006
  4075. 0DD38 A9 00 LDA #$00
  4076. 0DD3A 8D 06 20 STA $2006
  4077. 0DD3D
  4078. 0DD3D A2 04 LDX #$04
  4079. 0DD3F A0 00 LDY #$00
  4080. 0DD41 LoadNametableLoop:
  4081. 0DD41
  4082. 0DD41 B1 14 LDA (temp16),y
  4083. 0DD43 8D 07 20 STA $2007
  4084. 0DD46 C8 INY
  4085. 0DD47 D0 F8 BNE LoadNametableLoop
  4086. 0DD49 E6 15 INC temp16+1
  4087. 0DD4B CA DEX
  4088. 0DD4C D0 F3 BNE LoadNametableLoop
  4089. 0DD4E
  4090. 0DD4E 68 PLA
  4091. 0DD4F A8 TAY
  4092. 0DD50 68 PLA
  4093. 0DD51 AA TAX
  4094. 0DD52
  4095. 0DD52 98 48 AC 21 06 20 83 C5.. ReturnBank
  4096. 0DD5C
  4097. 0DD5C 60 RTS0DD5D .include Routines\BASE_4_5\\Game\Subroutines\doHandleCreateState.asm
  4098. 0DD5D ;;;;; read the first behavior and do the thing.
  4099. 0DD5D doHandleCreateState:
  4100. 0DD5D
  4101. 0DD5D BD 9C 04 LDA Object_frame,x
  4102. 0DD60 4A LSR
  4103. 0DD61 4A LSR
  4104. 0DD62 4A LSR
  4105. 0DD63 29 07 AND #%00000111
  4106. 0DD65 85 08 STA tempB
  4107. 0DD67 ; LDA #$00
  4108. 0DD67 ; STA tempD
  4109. 0DD67 ; SwitchBank #$1C
  4110. 0DD67 ; ;;; Then, get the behavior for that object on that frame number.
  4111. 0DD67 ; LDY Object_type,x
  4112. 0DD67 ; LDY #$10
  4113. 0DD67 ; LDA ObjectBehaviorTableLo,y
  4114. 0DD67 ; LDA #<Object0_ActionTypes
  4115. 0DD67 ; STA pointer
  4116. 0DD67
  4117. 0DD67 ; LDA ObjectBehaviorTableHi,y
  4118. 0DD67 ; LDA #>Object0_ActionTypes
  4119. 0DD67 ; STA pointer+1
  4120. 0DD67 ; LDY tempD
  4121. 0DD67 ; LDY #$00
  4122. 0DD67 ; LDA (pointer),y
  4123. 0DD67 ; AND #%00001111
  4124. 0DD67 ; STA tempB
  4125. 0DD67 ; ReturnBank
  4126. 0DD67 ;;;; object behavior tables are with the lut table.
  4127. 0DD67 ;;;; the lut table is in bank 1C.
  4128. 0DD67
  4129. 0DD67 8A TXA
  4130. 0DD68 85 07 STA tempA
  4131. 0DD6A
  4132. 0DD6A
  4133. 0DD6A 8A 48 A5 07 85 0C A5 08.. DoObjectAction tempA, tempB
  4134. 0DD92 ; ;arg0 = what object?
  4135. 0DD92 ;arg1 = what step for the behavior?
  4136. 0DD92
  4137. 0DD92
  4138. 0DD92 BD 00 04 LDA Object_status,x
  4139. 0DD95 29 3F AND #%00111111
  4140. 0DD97 09 80 ORA #%10000000
  4141. 0DD99 9D 00 04 STA Object_status,x ;; kick it to active
  4142. 0DD9C 60 RTS0DD9D .include Routines\BASE_4_5\\Game\Subroutines\doChangeActionStep.asm
  4143. 0DD9D doChangeActionStep:
  4144. 0DD9D 8A TXA
  4145. 0DD9E 48 PHA
  4146. 0DD9F A6 0C LDX arg0_hold
  4147. 0DDA1 A5 0D LDA arg1_hold
  4148. 0DDA3 0A ASL
  4149. 0DDA4 0A ASL
  4150. 0DDA5 0A ASL
  4151. 0DDA6 85 00 STA temp
  4152. 0DDA8 BD 9C 04 LDA Object_frame,x
  4153. 0DDAB 29 C7 AND #%11000111
  4154. 0DDAD 05 00 ORA temp
  4155. 0DDAF 9D 9C 04 STA Object_frame,x
  4156. 0DDB2
  4157. 0DDB2 8A 48 A5 0C 85 0C A5 0D.. DoObjectAction arg0_hold, arg1_hold
  4158. 0DDDA
  4159. 0DDDA 68 PLA
  4160. 0DDDB AA TAX
  4161. 0DDDC 60 RTS0DDDD .include Routines\BASE_4_5\\Game\Subroutines\doGetRandomNumber.asm
  4162. 0DDDD doGetRandomNumber:
  4163. 0DDDD AD B3 06 LDA randomSeed1
  4164. 0DDE0 0A ASL A
  4165. 0DDE1 0A ASL A
  4166. 0DDE2 18 CLC
  4167. 0DDE3 65 02 ADC temp2
  4168. 0DDE5 38 SEC
  4169. 0DDE6 E5 04 SBC tempx
  4170. 0DDE8 69 11 ADC #$11
  4171. 0DDEA E5 27 SBC gamepad
  4172. 0DDEC 69 36 ADC #$36
  4173. 0DDEE 65 32 ADC tileY
  4174. 0DDF0 E5 14 SBC temp16
  4175. 0DDF2 65 1B ADC pointer
  4176. 0DDF4 65 07 ADC tempA
  4177. 0DDF6 8D B3 06 STA randomSeed1
  4178. 0DDF9 69 03 ADC #$03
  4179. 0DDFB E5 18 SBC vBlankTimer
  4180. 0DDFD E5 18 SBC vBlankTimer
  4181. 0DDFF 60 RTS0DE00 .include Routines\BASE_4_5\\Game\Subroutines\updateAction.asm
  4182. 0DE00 updateAction:
  4183. 0DE00
  4184. 0DE00 60 RTS0DE01 .include Routines\BASE_4_5\\Game\Subroutines\doClearAllMonsters.asm
  4185. 0DE01 doClearAllMonsters:
  4186. 0DE01
  4187. 0DE01
  4188. 0DE01 98 48 AD 20 06 8D 21 06.. SwitchBank #$1C
  4189. 0DE10 A2 00 LDX #$00
  4190. 0DE12 doClearObjectsLoop:
  4191. 0DE12 BC 8F 04 LDY Object_type,x
  4192. 0DE15 B9 20 91 LDA ObjectFlags,y
  4193. 0DE18 29 01 AND #%00000001 ;; is it persistent?
  4194. 0DE1A D0 0B BNE doneClearingObject
  4195. 0DE1C A9 00 LDA #$00
  4196. 0DE1E 9D 00 04 STA Object_status,x
  4197. 0DE21 9D 9C 04 STA Object_frame,x
  4198. 0DE24 9D A9 04 STA Object_direction,x
  4199. 0DE27 doneClearingObject:
  4200. 0DE27 E8 INX
  4201. 0DE28 E0 0D CPX #TOTAL_MAX_OBJECTS
  4202. 0DE2A D0 E6 BNE doClearObjectsLoop
  4203. 0DE2C 98 48 AC 21 06 20 83 C5.. ReturnBank
  4204. 0DE36
  4205. 0DE36
  4206. 0DE36
  4207. 0DE36
  4208. 0DE36 60 RTS
  4209. 0DE37
  4210. 0DE37 ;.include ROOT\Game\Subroutines\doDrawBox.asm
  4211. 0DE37 .include Routines\BASE_4_5\\Game\Subroutines\doDrawText.asm
  4212. 0DE37 doDrawText:
  4213. 0DE37 8A TXA
  4214. 0DE38 48 PHA
  4215. 0DE39 98 TYA
  4216. 0DE3A 48 PHA
  4217. 0DE3B
  4218. 0DE3B AD C0 06 LDA textHandler
  4219. 0DE3E D0 29 BNE alreadyDrawingText
  4220. 0DE40 ;; setting up text.
  4221. 0DE40
  4222. 0DE40 A5 0E LDA arg2_hold ;; the x value, in metatiles, of the box draw.
  4223. 0DE42 0A ASL ;; multiplied by two, since metatiles are 16x16, but PPU addresses are 8x8.
  4224. 0DE43 85 00 STA temp
  4225. 0DE45 A5 0F LDA arg3_hold ;; the y value, in metatiles, of the box draw.
  4226. 0DE47 0A ASL ;; multiplied by two, since metatiles are 16x16, but ppu addresses are 8x8.
  4227. 0DE48 85 01 STA temp1
  4228. 0DE4A 0A ASL
  4229. 0DE4B 0A ASL
  4230. 0DE4C 0A ASL
  4231. 0DE4D 0A ASL
  4232. 0DE4E 0A ASL
  4233. 0DE4F 18 CLC
  4234. 0DE50 65 00 ADC temp
  4235. 0DE52 85 41 STA textOffset_lo
  4236. 0DE54
  4237. 0DE54
  4238. 0DE54 A5 01 LDA temp1
  4239. 0DE56 4A LSR
  4240. 0DE57 4A LSR
  4241. 0DE58 4A LSR
  4242. 0DE59 18 CLC
  4243. 0DE5A 6D BE 06 ADC camFocus_tiles
  4244. 0DE5D 85 42 STA textOffset_hi
  4245. 0DE5F
  4246. 0DE5F
  4247. 0DE5F A9 01 LDA #$01
  4248. 0DE61 8D C0 06 STA textHandler
  4249. 0DE64 A9 00 LDA #$00
  4250. 0DE66 8D BC 06 STA counter
  4251. 0DE69
  4252. 0DE69 alreadyDrawingText:
  4253. 0DE69 A9 00 LDA #$00
  4254. 0DE6B 8D 8A 06 STA scrollOffsetCounter
  4255. 0DE6E 98 48 AD 20 06 8D 21 06.. SwitchBank textBank
  4256. 0DE7E A0 00 LDY #$00
  4257. 0DE80 A5 42 LDA textOffset_hi
  4258. 0DE82 99 00 07 STA scrollUpdateRam,y
  4259. 0DE85 C8 INY
  4260. 0DE86 A5 41 LDA textOffset_lo
  4261. 0DE88 99 00 07 STA scrollUpdateRam,y
  4262. 0DE8B C8 INY
  4263. 0DE8C 98 TYA
  4264. 0DE8D 48 PHA
  4265. 0DE8E A0 00 LDY #$00
  4266. 0DE90 B1 43 LDA (textPointer),y
  4267. 0DE92 85 00 STA temp
  4268. 0DE94 68 PLA
  4269. 0DE95 A8 TAY
  4270. 0DE96
  4271. 0DE96
  4272. 0DE96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4273. 0DE96 ;; HERE, we will check for "end string" values.
  4274. 0DE96 ;; These are set up by default from the GUI.
  4275. 0DE96 ;; Mostly, they add a value from HUD_CONSANTS.dat
  4276. 0DE96 ;; that act as an opcode rather than a string value.
  4277. 0DE96 ;; Since there are 256 values, there are many at the end that
  4278. 0DE96 ;; will never be used.
  4279. 0DE96
  4280. 0DE96 ;; These are the ones that are default:
  4281. 0DE96 ;_BREAK = $FE
  4282. 0DE96 ;_END = $FF
  4283. 0DE96 ;_MORE = $FD
  4284. 0DE96 ;_ENDWIN = $FA
  4285. 0DE96 ;_ENDITEM = $FB
  4286. 0DE96 ;_ENDSHOP = $FC
  4287. 0DE96 ;_ENDTRIGGER = $F9
  4288. 0DE96
  4289. 0DE96 ;;FOR MANUAL USE:
  4290. 0DE96 ;; Drawing from a library of values based on a numeric offset can be invoked by using F8.
  4291. 0DE96 A5 00 LDA temp
  4292. 0DE98 C9 F8 CMP #$F8
  4293. 0DE9A D0 49 BNE +notDrawingFromLibrary
  4294. 0DE9C 98 TYA
  4295. 0DE9D 48 PHA
  4296. 0DE9E ;;; the library can have 256 values.
  4297. 0DE9E ;;; conceivably, you could make multiple libraries, and assignem them to different end of text reads.
  4298. 0DE9E ;;; So here is what this does.
  4299. 0DE9E ;;; 1) Reads an #$F8, so it knows to read from the library.
  4300. 0DE9E ;;; 2) Increases position. Gets the low value of var address to read
  4301. 0DE9E ;;; 3) Increases position. Gets the high value of var address to read. Puts the result of var into Y.
  4302. 0DE9E ;;; 3) Increases position and SAVES that program counter position.
  4303. 0DE9E ;;; 4) Reads the y offest of library table. That position becomes the new textPointer location.
  4304. 0DE9E ;;; 5) Writes as normal from that position.
  4305. 0DE9E ;;; 6) If it reads #$F7, it turns off library draw (so every library read should end in #$F7.
  4306. 0DE9E ;;; 7) Saved program counter position gets restored to textPointer, and draw text continues on
  4307. 0DE9E ;;; as normal.
  4308. 0DE9E A5 43 LDA textPointer
  4309. 0DEA0 18 CLC
  4310. 0DEA1 69 01 ADC #$01
  4311. 0DEA3 85 43 STA textPointer
  4312. 0DEA5 A5 44 LDA textPointer+1
  4313. 0DEA7 69 00 ADC #$00
  4314. 0DEA9 85 44 STA textPointer+1
  4315. 0DEAB A0 00 LDY #$00
  4316. 0DEAD B1 43 LDA (textPointer),y
  4317. 0DEAF 85 1B STA pointer
  4318. 0DEB1
  4319. 0DEB1 A5 43 LDA textPointer
  4320. 0DEB3 18 CLC
  4321. 0DEB4 69 01 ADC #$01
  4322. 0DEB6 85 43 STA textPointer
  4323. 0DEB8 A5 44 LDA textPointer+1
  4324. 0DEBA 69 00 ADC #$00
  4325. 0DEBC 85 44 STA textPointer+1
  4326. 0DEBE A0 00 LDY #$00
  4327. 0DEC0 B1 43 LDA (textPointer),y
  4328. 0DEC2 85 1C STA pointer+1
  4329. 0DEC4
  4330. 0DEC4 A0 00 LDY #$00
  4331. 0DEC6 B1 1B LDA (pointer),y
  4332. 0DEC8 A8 TAY ;; tempA now represents the offset value from the Library pointer table.
  4333. 0DEC9
  4334. 0DEC9 ;; store next offset position for a return point.
  4335. 0DEC9 A5 43 LDA textPointer
  4336. 0DECB 18 CLC
  4337. 0DECC 69 01 ADC #$01
  4338. 0DECE 85 A0 STA textPosHold
  4339. 0DED0 A5 44 LDA textPointer+1
  4340. 0DED2 69 00 ADC #$00
  4341. 0DED4 85 A1 STA textPosHold+1
  4342. 0DED6
  4343. 0DED6 ;; get the library table value
  4344. 0DED6 B9 43 D9 LDA TextLibrary_lo,y
  4345. 0DED9 85 43 STA textPointer
  4346. 0DEDB B9 44 D9 LDA TextLibrary_hi,y
  4347. 0DEDE 85 44 STA textPointer+1
  4348. 0DEE0 68 PLA
  4349. 0DEE1 A8 TAY
  4350. 0DEE2 4C 40 DF JMP +continueRoutine;doneWithText
  4351. 0DEE5
  4352. 0DEE5
  4353. 0DEE5 +notDrawingFromLibrary:
  4354. 0DEE5 C9 F7 CMP #$F7
  4355. 0DEE7 D0 15 BNE +notRestoringFromLibrary
  4356. 0DEE9 98 TYA
  4357. 0DEEA 48 PHA
  4358. 0DEEB ;; restorying from library.
  4359. 0DEEB A5 A0 LDA textPosHold
  4360. 0DEED 85 43 STA textPointer
  4361. 0DEEF A5 A1 LDA textPosHold+1
  4362. 0DEF1 85 44 STA textPointer+1
  4363. 0DEF3 A0 00 LDY #$00
  4364. 0DEF5 B1 43 LDA (textPointer),y
  4365. 0DEF7 85 00 STA temp ;; flow into the rest of the text routine.
  4366. 0DEF9 68 PLA
  4367. 0DEFA A8 TAY
  4368. 0DEFB 4C 40 DF JMP +continueRoutine
  4369. 0DEFE +notRestoringFromLibrary
  4370. 0DEFE ;;; a value of F6 is an opcode that lets the game know to draw the value of a variable in a given position
  4371. 0DEFE ;;; within a manual string.
  4372. 0DEFE ;;; 1) First, we see it is an F6 opcode.
  4373. 0DEFE ;;; 2) The next two bytes are the address of the variable that we want to read.
  4374. 0DEFE ;;; 3) It pushes that to y as an offset to NumberBaseTable, and then continues on to the routine.
  4375. 0DEFE C9 F6 CMP #$F6
  4376. 0DF00 D0 3E BNE +notDrawingVariableNumber
  4377. 0DF02 98 TYA
  4378. 0DF03 48 PHA
  4379. 0DF04 A5 43 LDA textPointer
  4380. 0DF06 18 CLC
  4381. 0DF07 69 01 ADC #$01
  4382. 0DF09 85 43 STA textPointer
  4383. 0DF0B A5 44 LDA textPointer+1
  4384. 0DF0D 69 00 ADC #$00
  4385. 0DF0F 85 44 STA textPointer+1
  4386. 0DF11 A0 00 LDY #$00
  4387. 0DF13 B1 43 LDA (textPointer),y
  4388. 0DF15 85 1B STA pointer
  4389. 0DF17
  4390. 0DF17 A5 43 LDA textPointer
  4391. 0DF19 18 CLC
  4392. 0DF1A 69 01 ADC #$01
  4393. 0DF1C 85 43 STA textPointer
  4394. 0DF1E A5 44 LDA textPointer+1
  4395. 0DF20 69 00 ADC #$00
  4396. 0DF22 85 44 STA textPointer+1
  4397. 0DF24 A0 00 LDY #$00
  4398. 0DF26 B1 43 LDA (textPointer),y
  4399. 0DF28 85 1C STA pointer+1
  4400. 0DF2A
  4401. 0DF2A A0 00 LDY #$00
  4402. 0DF2C B1 1B LDA (pointer),y
  4403. 0DF2E A8 TAY
  4404. 0DF2F
  4405. 0DF2F A9 39 LDA #<NumberBaseTable
  4406. 0DF31 85 1B STA pointer
  4407. 0DF33 A9 D9 LDA #>NumberBaseTable
  4408. 0DF35 85 1C STA pointer+1
  4409. 0DF37 B1 1B LDA (pointer),y
  4410. 0DF39 85 00 STA temp
  4411. 0DF3B 68 PLA
  4412. 0DF3C A8 TAY
  4413. 0DF3D 4C 40 DF JMP +continueRoutine
  4414. 0DF40
  4415. 0DF40 +notDrawingVariableNumber
  4416. 0DF40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4417. 0DF40 +continueRoutine
  4418. 0DF40 A5 00 LDA temp
  4419. 0DF42 C9 FF CMP #$FF
  4420. 0DF44 D0 16 BNE notEndOfText
  4421. 0DF46 endOfText:
  4422. 0DF46 ;; end of text
  4423. 0DF46 A9 00 LDA #$00
  4424. 0DF48 8D C0 06 STA textHandler
  4425. 0DF4B ;;;;;;;;; cue turn off.
  4426. 0DF4B AD C2 06 LDA textQueued
  4427. 0DF4E 09 02 ORA #%00000010
  4428. 0DF50 8D C2 06 STA textQueued ;; this will push a *turn off* notification.
  4429. 0DF53
  4430. 0DF53 A5 9B LDA gameStatusByte
  4431. 0DF55 29 FD AND #%11111101
  4432. 0DF57 85 9B STA gameStatusByte
  4433. 0DF59
  4434. 0DF59 4C 8B E0 JMP doneWithText
  4435. 0DF5C notEndOfText:
  4436. 0DF5C C9 FE CMP #$FE
  4437. 0DF5E D0 26 BNE notNewLineOfText
  4438. 0DF60
  4439. 0DF60 ;; new line of text
  4440. 0DF60 ;;;;;;;;;;;;;;;;;;;;;;;;;
  4441. 0DF60 ;; return to the leftmost side of the text string
  4442. 0DF60 ;; by subtracting "counter"
  4443. 0DF60 ;; then add #$20 (32), which jumps it to the next line.
  4444. 0DF60
  4445. 0DF60 A5 41 LDA textOffset_lo
  4446. 0DF62 38 SEC
  4447. 0DF63 ED BC 06 SBC counter
  4448. 0DF66 18 CLC
  4449. 0DF67 69 20 ADC #$20
  4450. 0DF69 85 41 STA textOffset_lo
  4451. 0DF6B A5 42 LDA textOffset_hi
  4452. 0DF6D 69 00 ADC #$00
  4453. 0DF6F 85 42 STA textOffset_hi
  4454. 0DF71
  4455. 0DF71 ;; start 'counter' over again for the length of the current line
  4456. 0DF71 A9 00 LDA #$00
  4457. 0DF73 8D BC 06 STA counter
  4458. 0DF76
  4459. 0DF76 ;; increase the position of the text pointer to get the next offset
  4460. 0DF76 ;; value in the string.
  4461. 0DF76 A5 43 LDA textPointer
  4462. 0DF78 18 CLC
  4463. 0DF79 69 01 ADC #$01
  4464. 0DF7B 85 43 STA textPointer
  4465. 0DF7D A5 44 LDA textPointer+1
  4466. 0DF7F 69 00 ADC #$00
  4467. 0DF81 85 44 STA textPointer+1
  4468. 0DF83
  4469. 0DF83 4C 8B E0 JMP doneWithText
  4470. 0DF86 notNewLineOfText:
  4471. 0DF86 C9 F9 CMP #_ENDTRIGGER
  4472. 0DF88 D0 41 BNE notEndTrigger
  4473. 0DF8A A5 43 LDA textPointer
  4474. 0DF8C 18 CLC
  4475. 0DF8D 69 01 ADC #$01
  4476. 0DF8F 85 43 STA textPointer
  4477. 0DF91 A5 44 LDA textPointer+1
  4478. 0DF93 69 00 ADC #$00
  4479. 0DF95 85 44 STA textPointer+1
  4480. 0DF97 ;;; NOW, get the modifier
  4481. 0DF97 98 TYA
  4482. 0DF98 48 PHA
  4483. 0DF99 A0 00 LDY #$00
  4484. 0DF9B B1 43 LDA (textPointer),y
  4485. 0DF9D ;;; accumulators now contains the trigger type
  4486. 0DF9D 85 00 STA temp
  4487. 0DF9F 8A 85 04 98 85 05 A5 00.. TriggerScreen temp
  4488. 0DFC1 68 PLA
  4489. 0DFC2 A8 TAY
  4490. 0DFC3 A9 00 LDA #$00
  4491. 0DFC5 8D C0 06 STA textHandler
  4492. 0DFC8 4C 46 DF JMP endOfText
  4493. 0DFCB notEndTrigger:
  4494. 0DFCB C9 FD CMP #_MORE
  4495. 0DFCD D0 44 BNE notMoreText
  4496. 0DFCF ;; There is more text.
  4497. 0DFCF ;; so first, we need to clear the text field.
  4498. 0DFCF ;; We will set up a queue for drawing a new black box and then more text.
  4499. 0DFCF AD C2 06 LDA textQueued
  4500. 0DFD2 09 01 ORA #%00000001
  4501. 0DFD4 8D C2 06 STA textQueued
  4502. 0DFD7 ;;; now, increase the text value so that it will read from the very next value
  4503. 0DFD7 ;;; when a new box is created.
  4504. 0DFD7
  4505. 0DFD7 A5 41 LDA textOffset_lo
  4506. 0DFD9 18 CLC
  4507. 0DFDA 69 02 ADC #$02
  4508. 0DFDC 85 41 STA textOffset_lo
  4509. 0DFDE A5 42 LDA textOffset_hi
  4510. 0DFE0 69 00 ADC #$00
  4511. 0DFE2 85 42 STA textOffset_hi
  4512. 0DFE4
  4513. 0DFE4
  4514. 0DFE4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4515. 0DFE4 ;;; Also, add a "MORE" indicator after finished text.
  4516. 0DFE4 ;;;
  4517. 0DFE4 A5 43 LDA textPointer
  4518. 0DFE6 18 CLC
  4519. 0DFE7 69 01 ADC #$01
  4520. 0DFE9 85 43 STA textPointer
  4521. 0DFEB A5 44 LDA textPointer+1
  4522. 0DFED 69 00 ADC #$00
  4523. 0DFEF 85 44 STA textPointer+1
  4524. 0DFF1 A9 00 LDA #$00
  4525. 0DFF3 8D C0 06 STA textHandler
  4526. 0DFF6
  4527. 0DFF6 A9 00 LDA #TEXT_MORE_INDICATOR
  4528. 0DFF8 85 00 STA temp
  4529. 0DFFA
  4530. 0DFFA A5 00 LDA temp
  4531. 0DFFC 18 CLC
  4532. 0DFFD 69 C0 ADC #HUD_OFFSET
  4533. 0DFFF 99 00 07 STA scrollUpdateRam,y
  4534. 0E002 C8 INY
  4535. 0E003 98 TYA
  4536. 0E004 8D 8B 06 STA maxScrollOffsetCounter
  4537. 0E007
  4538. 0E007 EE BC 06 inc counter ;; we will use counter for "length" of the current line.
  4539. 0E00A
  4540. 0E00A
  4541. 0E00A A5 9B LDA gameStatusByte
  4542. 0E00C 29 FD AND #%11111101
  4543. 0E00E 85 9B STA gameStatusByte
  4544. 0E010 4C 83 E0 JMP JustUpdateNewCharacter
  4545. 0E013
  4546. 0E013
  4547. 0E013 notMoreText:
  4548. 0E013 C9 FB CMP #_ENDITEM
  4549. 0E015 D0 42 BNE notEndItem
  4550. 0E017 ;; is end item.
  4551. 0E017 A5 43 LDA textPointer
  4552. 0E019 18 CLC
  4553. 0E01A 69 01 ADC #$01
  4554. 0E01C 85 43 STA textPointer
  4555. 0E01E A5 44 LDA textPointer+1
  4556. 0E020 69 00 ADC #$00
  4557. 0E022 85 44 STA textPointer+1
  4558. 0E024 A0 00 LDY #$00
  4559. 0E026 B1 43 LDA (textPointer),y
  4560. 0E028 ;; now A holds the "item to get".
  4561. 0E028 A8 TAY
  4562. 0E029 B9 E1 D8 LDA ValToBitTable_inverse,y
  4563. 0E02C 0D DF 06 ORA weaponsUnlocked
  4564. 0E02F 8D DF 06 STA weaponsUnlocked
  4565. 0E032 8A 85 04 98 85 05 AD 74.. TriggerScreen currentNametable
  4566. 0E056 4C 46 DF JMP endOfText
  4567. 0E059 notEndItem:
  4568. 0E059
  4569. 0E059
  4570. 0E059
  4571. 0E059 updateNormalTextCharacter:
  4572. 0E059 A5 00 LDA temp
  4573. 0E05B 18 CLC
  4574. 0E05C 69 C0 ADC #HUD_OFFSET
  4575. 0E05E 99 00 07 STA scrollUpdateRam,y
  4576. 0E061 C8 INY
  4577. 0E062 98 TYA
  4578. 0E063 8D 8B 06 STA maxScrollOffsetCounter
  4579. 0E066
  4580. 0E066 EE BC 06 inc counter ;; we will use counter for "length" of the current line.
  4581. 0E069
  4582. 0E069 A5 41 LDA textOffset_lo
  4583. 0E06B 18 CLC
  4584. 0E06C 69 01 ADC #$01
  4585. 0E06E 85 41 STA textOffset_lo
  4586. 0E070 A5 42 LDA textOffset_hi
  4587. 0E072 69 00 ADC #$00
  4588. 0E074 85 42 STA textOffset_hi
  4589. 0E076
  4590. 0E076 A5 43 LDA textPointer
  4591. 0E078 18 CLC
  4592. 0E079 69 01 ADC #$01
  4593. 0E07B 85 43 STA textPointer
  4594. 0E07D A5 44 LDA textPointer+1
  4595. 0E07F 69 00 ADC #$00
  4596. 0E081 85 44 STA textPointer+1
  4597. 0E083 JustUpdateNewCharacter:
  4598. 0E083 AD 24 06 LDA updateScreenData
  4599. 0E086 09 04 ORA #%00000100
  4600. 0E088 8D 24 06 STA updateScreenData
  4601. 0E08B doneWithText:
  4602. 0E08B 98 48 AC 21 06 20 83 C5.. ReturnBank
  4603. 0E095 68 PLA
  4604. 0E096 A8 TAY
  4605. 0E097 68 PLA
  4606. 0E098 AA TAX
  4607. 0E099 60 RTS0E09A .include Routines\BASE_4_5\\Game\Subroutines\doDrawTilesDirect.asm
  4608. 0E09A doDrawTilesDirect:
  4609. 0E09A ; ;;; draw hud box
  4610. 0E09A ; LDA #BOX_0_WIDTH
  4611. 0E09A ; ASL
  4612. 0E09A ; STA tempA
  4613. 0E09A ; LDA #BOX_0_HEIGHT
  4614. 0E09A ; ASL
  4615. 0E09A ; STA tempB
  4616. 0E09A ; LDA #BOX_0_ORIGIN_X ;; the x value, in metatiles, of the box draw.
  4617. 0E09A ; ASL ;; multiplied by two, since metatiles are 16x16, but PPU addresses are 8x8.
  4618. 0E09A ; CLC
  4619. 0E09A ;ADC arg2_hold
  4620. 0E09A A5 0E LDA arg2_hold
  4621. 0E09C 85 00 STA temp
  4622. 0E09E ; LDA #BOX_0_ORIGIN_Y ;; the y value, in metatiles, of the box draw.
  4623. 0E09E ; ASL ;; multiplied by two, since metatiles are 16x16, but ppu addresses are 8x8.
  4624. 0E09E ; CLC
  4625. 0E09E ; ADC
  4626. 0E09E A5 0F LDA arg3_hold
  4627. 0E0A0 85 01 STA temp1
  4628. 0E0A2 0A ASL
  4629. 0E0A3 0A ASL
  4630. 0E0A4 0A ASL
  4631. 0E0A5 0A ASL
  4632. 0E0A6 0A ASL
  4633. 0E0A7 18 CLC
  4634. 0E0A8 65 00 ADC temp
  4635. 0E0AA 85 03 STA temp3 ;; low byte.
  4636. 0E0AC
  4637. 0E0AC
  4638. 0E0AC A5 01 LDA temp1
  4639. 0E0AE 4A LSR
  4640. 0E0AF 4A LSR
  4641. 0E0B0 4A LSR
  4642. 0E0B1 18 CLC
  4643. 0E0B2 6D BE 06 ADC camFocus_tiles
  4644. 0E0B5 85 02 STA temp2 ;; high byte
  4645. 0E0B7 ;;; draw text direct does not need to wait for frame updates.
  4646. 0E0B7 ;;; it happens when the scren is turned off.
  4647. 0E0B7 98 48 AD 20 06 8D 21 06.. SwitchBank textBank
  4648. 0E0C7 A9 00 LDA #$00
  4649. 0E0C9 85 07 STA tempA ;; used for width.
  4650. 0E0CB loop_drawTextDirect:
  4651. 0E0CB A0 00 LDY #$00
  4652. 0E0CD A5 02 LDA temp2
  4653. 0E0CF 8D 06 20 STA $2006
  4654. 0E0D2 A5 03 LDA temp3
  4655. 0E0D4 8D 06 20 STA $2006
  4656. 0E0D7 B1 43 LDA (textPointer),y
  4657. 0E0D9 C9 FF CMP #$FF
  4658. 0E0DB F0 4D BEQ doneWithThisString
  4659. 0E0DD C9 FE CMP #$FE
  4660. 0E0DF F0 25 BEQ newLineForDrawTextDirect
  4661. 0E0E1 18 CLC
  4662. 0E0E2 65 10 ADC arg4_hold
  4663. 0E0E4 8D 07 20 STA $2007
  4664. 0E0E7
  4665. 0E0E7 A5 03 LDA temp3
  4666. 0E0E9 18 CLC
  4667. 0E0EA 69 01 ADC #$01
  4668. 0E0EC 85 03 STA temp3
  4669. 0E0EE A5 02 LDA temp2
  4670. 0E0F0 69 00 ADC #$00
  4671. 0E0F2 85 02 STA temp2
  4672. 0E0F4 E6 07 INC tempA
  4673. 0E0F6 A5 43 LDA textPointer
  4674. 0E0F8 18 CLC
  4675. 0E0F9 69 01 ADC #$01
  4676. 0E0FB 85 43 STA textPointer
  4677. 0E0FD A5 44 LDA textPointer+1
  4678. 0E0FF 69 00 ADC #$00
  4679. 0E101 85 44 STA textPointer+1
  4680. 0E103 4C CB E0 JMP loop_drawTextDirect
  4681. 0E106 newLineForDrawTextDirect:
  4682. 0E106 A5 03 LDA temp3
  4683. 0E108 38 SEC
  4684. 0E109 E5 07 SBC tempA
  4685. 0E10B 18 CLC
  4686. 0E10C 69 20 ADC #$20
  4687. 0E10E 85 03 STA temp3
  4688. 0E110 A5 02 LDA temp2
  4689. 0E112 69 00 ADC #$00
  4690. 0E114 85 02 STA temp2
  4691. 0E116 A9 00 LDA #$00
  4692. 0E118 85 07 STA tempA
  4693. 0E11A A5 43 LDA textPointer
  4694. 0E11C 18 CLC
  4695. 0E11D 69 01 ADC #$01
  4696. 0E11F 85 43 STA textPointer
  4697. 0E121 A5 44 LDA textPointer+1
  4698. 0E123 69 00 ADC #$00
  4699. 0E125 85 44 STA textPointer+1
  4700. 0E127
  4701. 0E127 4C CB E0 JMP loop_drawTextDirect
  4702. 0E12A doneWithThisString:
  4703. 0E12A 98 48 AC 21 06 20 83 C5.. ReturnBank
  4704. 0E134
  4705. 0E134 60 RTS0E135 .include Routines\BASE_4_5\\Game\Subroutines\doDrawVariableTiles.asm
  4706. 0E135 doDrawVariableTiles:
  4707. 0E135 A5 0C LDA arg0_hold
  4708. 0E137 85 00 STA temp
  4709. 0E139 ; LDA #BOX_0_ORIGIN_Y ;; the y value, in metatiles, of the box draw.
  4710. 0E139 ; ASL ;; multiplied by two, since metatiles are 16x16, but ppu addresses are 8x8.
  4711. 0E139 ; CLC
  4712. 0E139 ; ADC
  4713. 0E139 A5 0D LDA arg1_hold
  4714. 0E13B 85 01 STA temp1
  4715. 0E13D 0A ASL
  4716. 0E13E 0A ASL
  4717. 0E13F 0A ASL
  4718. 0E140 0A ASL
  4719. 0E141 0A ASL
  4720. 0E142 18 CLC
  4721. 0E143 65 00 ADC temp
  4722. 0E145 85 03 STA temp3 ;; low byte.
  4723. 0E147
  4724. 0E147
  4725. 0E147 A5 01 LDA temp1
  4726. 0E149 4A LSR
  4727. 0E14A 4A LSR
  4728. 0E14B 4A LSR
  4729. 0E14C 18 CLC
  4730. 0E14D 6D BE 06 ADC camFocus_tiles
  4731. 0E150 85 02 STA temp2 ;; high byte
  4732. 0E152
  4733. 0E152
  4734. 0E152 A2 00 LDX #$00;arg2_hold ; this is the FULL length of the tile thing.
  4735. 0E154
  4736. 0E154 A5 11 LDA arg5_hold ;; the tile to draw
  4737. 0E156 85 00 STA temp
  4738. 0E158
  4739. 0E158 loop_doDrawVar
  4740. 0E158 A5 10 LDA arg4_hold
  4741. 0E15A F0 04 BEQ changeToEmpty ;; if it's zero, change to empty.
  4742. 0E15C E4 10 CPX arg4_hold
  4743. 0E15E 90 04 BCC dontChangeToEmpty
  4744. 0E160 changeToEmpty
  4745. 0E160 A5 0F LDA arg3_hold
  4746. 0E162 85 00 STA temp
  4747. 0E164 dontChangeToEmpty
  4748. 0E164
  4749. 0E164 A5 02 LDA temp2
  4750. 0E166 8D 06 20 STA $2006
  4751. 0E169 A5 03 LDA temp3
  4752. 0E16B 8D 06 20 STA $2006
  4753. 0E16E A5 00 LDA temp
  4754. 0E170 18 CLC
  4755. 0E171 69 C0 ADC #HUD_OFFSET
  4756. 0E173 8D 07 20 STA $2007
  4757. 0E176 E6 03 INC temp3
  4758. 0E178 E8 INX
  4759. 0E179 E4 0E CPX arg2_hold
  4760. 0E17B F0 03 BEQ done_loop_doDrawVar
  4761. 0E17D
  4762. 0E17D 4C 58 E1 JMP loop_doDrawVar
  4763. 0E180 done_loop_doDrawVar:
  4764. 0E180
  4765. 0E180 60 RTS
  4766. 0E181
  4767. 0E181
  4768. 0E181 doDrawVariableTiles_update:
  4769. 0E181 A5 0C LDA arg0_hold
  4770. 0E183 85 00 STA temp
  4771. 0E185 ; LDA #BOX_0_ORIGIN_Y ;; the y value, in metatiles, of the box draw.
  4772. 0E185 ; ASL ;; multiplied by two, since metatiles are 16x16, but ppu addresses are 8x8.
  4773. 0E185 ; CLC
  4774. 0E185 ; ADC
  4775. 0E185 A5 0D LDA arg1_hold
  4776. 0E187 85 01 STA temp1
  4777. 0E189 0A ASL
  4778. 0E18A 0A ASL
  4779. 0E18B 0A ASL
  4780. 0E18C 0A ASL
  4781. 0E18D 0A ASL
  4782. 0E18E 18 CLC
  4783. 0E18F 65 00 ADC temp
  4784. 0E191 85 03 STA temp3 ;; low byte.
  4785. 0E193
  4786. 0E193
  4787. 0E193 A5 01 LDA temp1
  4788. 0E195 4A LSR
  4789. 0E196 4A LSR
  4790. 0E197 4A LSR
  4791. 0E198 18 CLC
  4792. 0E199 6D BE 06 ADC camFocus_tiles
  4793. 0E19C 85 02 STA temp2 ;; high byte
  4794. 0E19E
  4795. 0E19E
  4796. 0E19E A2 00 LDX #$00;arg2_hold ; this is the FULL length of the tile thing.
  4797. 0E1A0 A0 00 LDY #$00
  4798. 0E1A2 A5 11 LDA arg5_hold ;; the tile to draw
  4799. 0E1A4 85 00 STA temp
  4800. 0E1A6
  4801. 0E1A6 A9 00 LDA #$00
  4802. 0E1A8 8D 8A 06 STA scrollOffsetCounter
  4803. 0E1AB
  4804. 0E1AB loop_doDrawVar_update:
  4805. 0E1AB A5 10 LDA arg4_hold
  4806. 0E1AD F0 04 BEQ changeToEmpty_update ;; if it's zero, change to empty.
  4807. 0E1AF E4 10 CPX arg4_hold
  4808. 0E1B1 90 04 BCC dontChangeToEmpty_update
  4809. 0E1B3 changeToEmpty_update
  4810. 0E1B3 A5 0F LDA arg3_hold
  4811. 0E1B5 85 00 STA temp
  4812. 0E1B7 dontChangeToEmpty_update
  4813. 0E1B7
  4814. 0E1B7 A5 02 LDA temp2
  4815. 0E1B9 99 00 07 STA scrollUpdateRam,y
  4816. 0E1BC C8 INy
  4817. 0E1BD A5 03 LDA temp3
  4818. 0E1BF 99 00 07 STA scrollUpdateRam,y
  4819. 0E1C2 C8 INy
  4820. 0E1C3 A5 00 LDA temp
  4821. 0E1C5 18 CLC
  4822. 0E1C6 69 C0 ADC #HUD_OFFSET
  4823. 0E1C8 99 00 07 STA scrollUpdateRam,y
  4824. 0E1CB C8 INY
  4825. 0E1CC E6 03 INC temp3
  4826. 0E1CE E8 INX
  4827. 0E1CF E4 0E CPX arg2_hold
  4828. 0E1D1 F0 03 BEQ done_loop_doDrawVar_update
  4829. 0E1D3
  4830. 0E1D3 4C AB E1 JMP loop_doDrawVar_update
  4831. 0E1D6 done_loop_doDrawVar_update:
  4832. 0E1D6 98 TYA
  4833. 0E1D7 8D 8B 06 STA maxScrollOffsetCounter
  4834. 0E1DA
  4835. 0E1DA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4836. 0E1DA ;;; Turn on update screen on next frame.
  4837. 0E1DA AD 24 06 LDA updateScreenData
  4838. 0E1DD 09 04 ORA #%0000100
  4839. 0E1DF 8D 24 06 STA updateScreenData
  4840. 0E1E2 60 RTS0E1E3 .include Routines\BASE_4_5\\Game\Subroutines\doDrawNumbers.asm
  4841. 0E1E3 doDrawNumbers:
  4842. 0E1E3 A5 0C LDA arg0_hold
  4843. 0E1E5 18 CLC
  4844. 0E1E6 65 0F ADC arg3_hold
  4845. 0E1E8 38 SEC
  4846. 0E1E9 E9 01 SBC #$01
  4847. 0E1EB 85 00 STA temp
  4848. 0E1ED
  4849. 0E1ED ; LDA #BOX_0_ORIGIN_Y ;; the y value, in metatiles, of the box draw.
  4850. 0E1ED ; ASL ;; multiplied by two, since metatiles are 16x16, but ppu addresses are 8x8.
  4851. 0E1ED ; CLC
  4852. 0E1ED ; ADC
  4853. 0E1ED A5 0D LDA arg1_hold
  4854. 0E1EF 85 01 STA temp1
  4855. 0E1F1 0A ASL
  4856. 0E1F2 0A ASL
  4857. 0E1F3 0A ASL
  4858. 0E1F4 0A ASL
  4859. 0E1F5 0A ASL
  4860. 0E1F6 18 CLC
  4861. 0E1F7 65 00 ADC temp
  4862. 0E1F9 85 03 STA temp3 ;; low byte.
  4863. 0E1FB
  4864. 0E1FB
  4865. 0E1FB A5 01 LDA temp1
  4866. 0E1FD 4A LSR
  4867. 0E1FE 4A LSR
  4868. 0E1FF 4A LSR
  4869. 0E200 18 CLC
  4870. 0E201 6D BE 06 ADC camFocus_tiles
  4871. 0E204 85 02 STA temp2 ;; high byte
  4872. 0E206 A0 00 LDY #$00
  4873. 0E208 doDrawNumbersLoop:
  4874. 0E208 A5 02 LDA temp2
  4875. 0E20A 8D 06 20 STA $2006
  4876. 0E20D A5 03 LDA temp3
  4877. 0E20F 8D 06 20 STA $2006
  4878. 0E212 B1 1B LDA (pointer),y
  4879. 0E214 18 CLC
  4880. 0E215 69 D0 ADC #$d0 ;; number start
  4881. 0E217 8D 07 20 STA $2007
  4882. 0E21A C8 INY
  4883. 0E21B C6 03 DEC temp3
  4884. 0E21D C6 0F DEC arg3_hold
  4885. 0E21F A5 0F LDA arg3_hold
  4886. 0E221 D0 E5 BNE doDrawNumbersLoop
  4887. 0E223
  4888. 0E223 60 RTS
  4889. 0E224
  4890. 0E224
  4891. 0E224 doDrawNumbers_update:
  4892. 0E224
  4893. 0E224 A9 00 LDA #$00
  4894. 0E226 8D 8A 06 STA scrollOffsetCounter
  4895. 0E229
  4896. 0E229 A5 0C LDA arg0_hold
  4897. 0E22B 18 CLC
  4898. 0E22C 65 0F ADC arg3_hold
  4899. 0E22E 38 SEC
  4900. 0E22F E9 01 SBC #$01
  4901. 0E231 85 00 STA temp
  4902. 0E233
  4903. 0E233 ; LDA #BOX_0_ORIGIN_Y ;; the y value, in metatiles, of the box draw.
  4904. 0E233 ; ASL ;; multiplied by two, since metatiles are 16x16, but ppu addresses are 8x8.
  4905. 0E233 ; CLC
  4906. 0E233 ; ADC
  4907. 0E233 A5 0D LDA arg1_hold
  4908. 0E235 85 01 STA temp1
  4909. 0E237 0A ASL
  4910. 0E238 0A ASL
  4911. 0E239 0A ASL
  4912. 0E23A 0A ASL
  4913. 0E23B 0A ASL
  4914. 0E23C 18 CLC
  4915. 0E23D 65 00 ADC temp
  4916. 0E23F 85 03 STA temp3 ;; low byte.
  4917. 0E241
  4918. 0E241
  4919. 0E241 A5 01 LDA temp1
  4920. 0E243 4A LSR
  4921. 0E244 4A LSR
  4922. 0E245 4A LSR
  4923. 0E246 18 CLC
  4924. 0E247 6D BE 06 ADC camFocus_tiles
  4925. 0E24A 85 02 STA temp2 ;; high byte
  4926. 0E24C A2 00 LDX #$00
  4927. 0E24E A0 00 LDY #$00
  4928. 0E250 doDrawNumbersLoop_update:
  4929. 0E250 A5 02 LDA temp2
  4930. 0E252 9D 00 07 STA scrollUpdateRam,x
  4931. 0E255 E8 INX
  4932. 0E256 A5 03 LDA temp3
  4933. 0E258 9D 00 07 STA scrollUpdateRam,x
  4934. 0E25B E8 INX
  4935. 0E25C B1 1B LDA (pointer),y
  4936. 0E25E 18 CLC
  4937. 0E25F 69 D0 ADC #$d0 ;; number start
  4938. 0E261 9D 00 07 STA scrollUpdateRam,x
  4939. 0E264 E8 INX
  4940. 0E265 C8 INY
  4941. 0E266 C6 03 DEC temp3
  4942. 0E268 C6 0F DEC arg3_hold
  4943. 0E26A A5 0F LDA arg3_hold
  4944. 0E26C D0 E2 BNE doDrawNumbersLoop_update
  4945. 0E26E 8A TXA
  4946. 0E26F 8D 8B 06 STA maxScrollOffsetCounter
  4947. 0E272
  4948. 0E272 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4949. 0E272 ;;; Turn on update screen on next frame.
  4950. 0E272 AD 24 06 LDA updateScreenData
  4951. 0E275 09 04 ORA #%0000100
  4952. 0E277 8D 24 06 STA updateScreenData
  4953. 0E27A
  4954. 0E27A 60 RTS
  4955. 0E27B
  4956. 0E27B
  4957. 0E27B
  4958. 0E27B ;.include ROOT\Game\Subroutines\doUpdateHudElement.asm
  4959. 0E27B .include Routines\BASE_4_5\\Game\Subroutines\doUpdateHudTiles.asm
  4960. 0E27B doUpdateHudTiles:
  4961. 0E27B ;;; prevent this from happening if there are any other updates that should have priority.
  4962. 0E27B ;;;;;;
  4963. 0E27B ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4964. 0E27B
  4965. 0E27B A5 05 LDA tempy
  4966. 0E27D 85 01 STA temp1
  4967. 0E27F 0A ASL
  4968. 0E280 0A ASL
  4969. 0E281 0A ASL
  4970. 0E282 0A ASL
  4971. 0E283 0A ASL
  4972. 0E284 18 CLC
  4973. 0E285 65 04 ADC tempx
  4974. 0E287 85 03 STA temp3 ;; low byte
  4975. 0E289
  4976. 0E289
  4977. 0E289 A5 01 LDA temp1
  4978. 0E28B 4A LSR
  4979. 0E28C 4A LSR
  4980. 0E28D 4A LSR
  4981. 0E28E 18 CLC
  4982. 0E28F 6D BE 06 ADC camFocus_tiles
  4983. 0E292 85 02 STA temp2 ;; high byte
  4984. 0E294
  4985. 0E294 A9 00 LDA #$00
  4986. 0E296 8D 8A 06 STA scrollOffsetCounter
  4987. 0E299 A8 TAY
  4988. 0E29A doLoadUpdateHudQueueLoop:
  4989. 0E29A A5 02 LDA temp2
  4990. 0E29C 99 00 07 STA scrollUpdateRam,y
  4991. 0E29F C8 INY
  4992. 0E2A0 A5 03 LDA temp3
  4993. 0E2A2 99 00 07 STA scrollUpdateRam,y
  4994. 0E2A5 C8 INY
  4995. 0E2A6 A9 E0 LDA #$E0
  4996. 0E2A8 99 00 07 STA scrollUpdateRam,y
  4997. 0E2AB C8 INY
  4998. 0E2AC
  4999. 0E2AC 98 TYA
  5000. 0E2AD 8D 8B 06 STA maxScrollOffsetCounter
  5001. 0E2B0
  5002. 0E2B0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5003. 0E2B0 ;;; Turn on update screen on next frame.
  5004. 0E2B0 AD 24 06 LDA updateScreenData
  5005. 0E2B3 09 04 ORA #%0000100
  5006. 0E2B5 8D 24 06 STA updateScreenData
  5007. 0E2B8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5008. 0E2B8
  5009. 0E2B8
  5010. 0E2B8 60 RTS0E2B9 .include Routines\BASE_4_5\\Game\Subroutines\doUpdateHudVarTiles.asm
  5011. 0E2B9 doUpdateHudVarTiles:
  5012. 0E2B9 ;;; prevent this from happening if there are any other updates that should have priority.
  5013. 0E2B9 ;;;;;;
  5014. 0E2B9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5015. 0E2B9 ;; tempA holds max container number.
  5016. 0E2B9 ;; tempB hold "full" containers.
  5017. 0E2B9 ;; tempC holds blank image value
  5018. 0E2B9 ;; tempD holds full image value
  5019. 0E2B9
  5020. 0E2B9 A5 05 LDA tempy
  5021. 0E2BB 0A ASL
  5022. 0E2BC 0A ASL
  5023. 0E2BD 0A ASL
  5024. 0E2BE 0A ASL
  5025. 0E2BF 0A ASL
  5026. 0E2C0 18 CLC
  5027. 0E2C1 65 04 ADC tempx
  5028. 0E2C3 85 02 STA temp2
  5029. 0E2C5
  5030. 0E2C5
  5031. 0E2C5 A5 01 LDA temp1
  5032. 0E2C7 4A LSR
  5033. 0E2C8 4A LSR
  5034. 0E2C9 4A LSR
  5035. 0E2CA 18 CLC
  5036. 0E2CB 6D BE 06 ADC camFocus_tiles
  5037. 0E2CE 85 03 STA temp3
  5038. 0E2D0
  5039. 0E2D0 A9 00 LDA #$00
  5040. 0E2D2 8D 8A 06 STA scrollOffsetCounter
  5041. 0E2D5 85 01 STA temp1
  5042. 0E2D7 A8 TAY
  5043. 0E2D8
  5044. 0E2D8
  5045. 0E2D8 doLoadUpdateHudVarQueueLoop:
  5046. 0E2D8 A5 01 LDA temp1 ;; offset
  5047. 0E2DA C5 08 CMP tempB ;; full value
  5048. 0E2DC 90 05 BCC drawFullValue
  5049. 0E2DE ;; draw container value
  5050. 0E2DE A5 09 LDA tempC
  5051. 0E2E0 4C E5 E2 JMP gotDrawValue
  5052. 0E2E3 drawFullValue
  5053. 0E2E3 A5 0A LDA tempD
  5054. 0E2E5 gotDrawValue
  5055. 0E2E5 85 06 STA tempz
  5056. 0E2E7 A5 03 LDA temp3
  5057. 0E2E9 99 00 07 STA scrollUpdateRam,y
  5058. 0E2EC C8 INY
  5059. 0E2ED A5 02 LDA temp2
  5060. 0E2EF 18 CLC
  5061. 0E2F0 65 01 ADC temp1
  5062. 0E2F2 99 00 07 STA scrollUpdateRam,y
  5063. 0E2F5 C8 INY
  5064. 0E2F6 A5 06 LDA tempz
  5065. 0E2F8 99 00 07 STA scrollUpdateRam,y
  5066. 0E2FB C8 INY
  5067. 0E2FC E6 01 INC temp1
  5068. 0E2FE A5 01 LDA temp1
  5069. 0E300 C5 07 CMP tempA
  5070. 0E302 D0 D4 BNE doLoadUpdateHudVarQueueLoop
  5071. 0E304
  5072. 0E304
  5073. 0E304
  5074. 0E304
  5075. 0E304 98 TYA
  5076. 0E305 8D 8B 06 STA maxScrollOffsetCounter
  5077. 0E308
  5078. 0E308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5079. 0E308 ;;; Turn on update screen on next frame.
  5080. 0E308 AD 24 06 LDA updateScreenData
  5081. 0E30B 09 04 ORA #%0000100
  5082. 0E30D 8D 24 06 STA updateScreenData
  5083. 0E310 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5084. 0E310
  5085. 0E310
  5086. 0E310 60 RTS0E311 .include Routines\BASE_4_5\\Game\Subroutines\doUpdateHudNumber.asm
  5087. 0E311 doUpdateHudNumber:
  5088. 0E311 ;;; prevent this from happening if there are any other updates that should have priority.
  5089. 0E311 ;;;;;;
  5090. 0E311 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5091. 0E311 ;;
  5092. 0E311 ;;
  5093. 0E311 ;;
  5094. 0E311 ;;
  5095. 0E311
  5096. 0E311 A5 05 LDA tempy
  5097. 0E313 0A ASL
  5098. 0E314 0A ASL
  5099. 0E315 0A ASL
  5100. 0E316 0A ASL
  5101. 0E317 0A ASL
  5102. 0E318 18 CLC
  5103. 0E319 65 04 ADC tempx
  5104. 0E31B 18 CLC
  5105. 0E31C 65 07 ADC tempA ;; the width
  5106. 0E31E ;;; so that as it draws places backwards
  5107. 0E31E ;;; it ends at the proper x,y
  5108. 0E31E 85 02 STA temp2
  5109. 0E320
  5110. 0E320
  5111. 0E320 A5 01 LDA temp1
  5112. 0E322 4A LSR
  5113. 0E323 4A LSR
  5114. 0E324 4A LSR
  5115. 0E325 18 CLC
  5116. 0E326 6D BE 06 ADC camFocus_tiles
  5117. 0E329 85 03 STA temp3
  5118. 0E32B
  5119. 0E32B A9 00 LDA #$00
  5120. 0E32D 8D 8A 06 STA scrollOffsetCounter
  5121. 0E330 85 01 STA temp1
  5122. 0E332 A8 TAY
  5123. 0E333
  5124. 0E333
  5125. 0E333 doLoadUpdateHudNumberQueueLoop:
  5126. 0E333 ;LDA temp1 ;; offset
  5127. 0E333 A5 03 LDA temp3
  5128. 0E335 99 00 07 STA scrollUpdateRam,y
  5129. 0E338 C8 INY
  5130. 0E339 A5 02 LDA temp2
  5131. 0E33B 18 CLC
  5132. 0E33C 65 07 ADC tempA
  5133. 0E33E 99 00 07 STA scrollUpdateRam,y
  5134. 0E341 C8 INY
  5135. 0E342 98 TYA
  5136. 0E343 48 PHA
  5137. 0E344 A4 01 LDY temp1
  5138. 0E346 B1 1B LDA (pointer),y
  5139. 0E348 18 CLC
  5140. 0E349 69 C0 ADC #HUD_OFFSET
  5141. 0E34B 18 CLC
  5142. 0E34C 69 10 ADC #$10 ;; numbers
  5143. 0E34E 85 00 STA temp
  5144. 0E350 68 PLA
  5145. 0E351 A8 TAY
  5146. 0E352 A5 00 LDA temp
  5147. 0E354 99 00 07 STA scrollUpdateRam,y
  5148. 0E357 C8 INY
  5149. 0E358 E6 01 INC temp1
  5150. 0E35A C6 07 DEC tempA
  5151. 0E35C D0 D5 BNE doLoadUpdateHudNumberQueueLoop
  5152. 0E35E
  5153. 0E35E
  5154. 0E35E
  5155. 0E35E
  5156. 0E35E 98 TYA
  5157. 0E35F 8D 8B 06 STA maxScrollOffsetCounter
  5158. 0E362
  5159. 0E362 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5160. 0E362 ;;; Turn on update screen on next frame.
  5161. 0E362 AD 24 06 LDA updateScreenData
  5162. 0E365 09 04 ORA #%0000100
  5163. 0E367 8D 24 06 STA updateScreenData
  5164. 0E36A ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5165. 0E36A
  5166. 0E36A
  5167. 0E36A 60 RTS0E36B
  5168. 0E36B
  5169. 0E36B
  5170. 0E36B .include "Routines\BASE_4_5\Game\Space Birds\Subroutines\doHandleUpdateScreen_bossDeath.asm"
  5171. 0E36B doHandleUpdateScreen:
  5172. 0E36B
  5173. 0E36B
  5174. 0E36B
  5175. 0E36B ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5176. 0E36B ;; Set focus variables to know which nametable is the one to update.
  5177. 0E36B AE 6D 06 LDX player1_object
  5178. 0E36E BD 27 04 LDA Object_screen,x
  5179. 0E371 29 01 AND #%00000001
  5180. 0E373 F0 0D BEQ updatesToEvenNametable
  5181. 0E375 ;;updates to odd nametable
  5182. 0E375 A9 24 LDA #$24
  5183. 0E377 8D BE 06 STA camFocus_tiles
  5184. 0E37A A9 27 LDA #$27
  5185. 0E37C 8D BF 06 STA camFocus_att
  5186. 0E37F 4C 8C E3 JMP gotScreenFocus
  5187. 0E382 updatesToEvenNametable:
  5188. 0E382 A9 20 LDA #$20
  5189. 0E384 8D BE 06 STA camFocus_tiles
  5190. 0E387 A9 23 LDA #$23
  5191. 0E389 8D BF 06 STA camFocus_att
  5192. 0E38C gotScreenFocus:
  5193. 0E38C
  5194. 0E38C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5195. 0E38C ;; Boss byte has been flipped.
  5196. 0E38C ;; go through collision by collision to get rid of potential boss tiles.
  5197. 0E38C ;; held in bossTile_hold over frames.
  5198. 0E38C ;; assumes boss block is in tile 4
  5199. 0E38C A5 A2 LDA bossByte
  5200. 0E38E D0 03 BNE +doCheckForBossByteTiles
  5201. 0E390 ;;;skip boss byte tiles. Byte was not flipped
  5202. 0E390 4C 93 E4 JMP +skipBossByte
  5203. 0E393 +doCheckForBossByteTiles
  5204. 0E393 A4 A3 LDY bossTile_hold
  5205. 0E395 AD BE 06 LDA camFocus_tiles
  5206. 0E398 C9 20 CMP #$20
  5207. 0E39A D0 16 BNE +isSecondScreen
  5208. 0E39C B9 00 03 LDA collisionTable,y
  5209. 0E39F C9 04 CMP #$04 ;; value of boss block tile.
  5210. 0E3A1 F0 07 BEQ +dontSkipThisTile
  5211. 0E3A3 C9 05 CMP #$05 ;; value of boss block tile w/o collision
  5212. 0E3A5 F0 03 BEQ +dontSkipThisTile
  5213. 0E3A7 4C 5F E4 JMP +skipThisTile
  5214. 0E3AA +dontSkipThisTile
  5215. 0E3AA A9 00 LDA #$00
  5216. 0E3AC 99 00 03 STA collisionTable,y
  5217. 0E3AF 4C C1 E3 JMP +updateTile
  5218. 0E3B2 +isSecondScreen
  5219. 0E3B2 B9 00 05 LDA collisionTable2,y
  5220. 0E3B5 C9 04 CMP #$04
  5221. 0E3B7 F0 03 BEQ +dontSkipThisTile
  5222. 0E3B9 4C 5F E4 JMP +skipThisTile
  5223. 0E3BC +dontSkipThisTile
  5224. 0E3BC A9 00 LDA #$00
  5225. 0E3BE 99 00 05 STA collisionTable2,y
  5226. 0E3C1
  5227. 0E3C1 +updateTile
  5228. 0E3C1 AD BE 06 LDA camFocus_tiles
  5229. 0E3C4 85 01 STA temp1
  5230. 0E3C6
  5231. 0E3C6 98 TYA
  5232. 0E3C7 85 00 STA temp
  5233. 0E3C9 4A LSR
  5234. 0E3CA 4A LSR
  5235. 0E3CB 4A LSR
  5236. 0E3CC 4A LSR
  5237. 0E3CD 4A LSR
  5238. 0E3CE 4A LSR
  5239. 0E3CF 18 clc
  5240. 0E3D0 65 01 ADC temp1
  5241. 0E3D2 85 02 STA temp2 ;;;temp16+1
  5242. 0E3D4 98 TYA
  5243. 0E3D5 29 F0 AND #%11110000
  5244. 0E3D7 0A ASL
  5245. 0E3D8 0A ASL
  5246. 0E3D9 85 06 STA tempz
  5247. 0E3DB 98 TYA
  5248. 0E3DC 29 0F AND #%00001111
  5249. 0E3DE 0A ASL
  5250. 0E3DF 05 06 ORA tempz
  5251. 0E3E1 85 03 STA temp3 ;temp16
  5252. 0E3E3
  5253. 0E3E3 ;;; SET THE TILE NUMBER TO CHANGE TO.
  5254. 0E3E3 A9 00 LDA #$00 ;; the tile to change.
  5255. 0E3E5 ;;; this is in tiles, so if you wanted the second "metatile",
  5256. 0E3E5 ;;; use 2, not 1. If you wanted the tile in the next row,
  5257. 0E3E5 ;;; use #$20, not #$10. Etc.
  5258. 0E3E5 85 07 STA tempA
  5259. 0E3E7 18 CLC
  5260. 0E3E8 69 01 ADC #$01
  5261. 0E3EA 85 08 STA tempB
  5262. 0E3EC 18 CLC
  5263. 0E3ED 69 0F ADC #$0F ;;this was done instead of specifying a static number so that we can alter this code to use a variable instead of LDA #$00.
  5264. 0E3EF 85 09 STA tempC
  5265. 0E3F1 18 CLC
  5266. 0E3F2 69 01 ADC #$01
  5267. 0E3F4 85 0A STA tempD
  5268. 0E3F6
  5269. 0E3F6
  5270. 0E3F6 A0 00 LDY #$00
  5271. 0E3F8 A5 02 LDA temp2
  5272. 0E3FA 99 00 07 STA scrollUpdateRam,y
  5273. 0E3FD C8 INY
  5274. 0E3FE A5 03 LDA temp3
  5275. 0E400 99 00 07 STA scrollUpdateRam,y
  5276. 0E403 C8 INY
  5277. 0E404 A5 07 LDA tempA
  5278. 0E406 99 00 07 STA scrollUpdateRam,y
  5279. 0E409 C8 INY
  5280. 0E40A
  5281. 0E40A A5 02 LDA temp2
  5282. 0E40C 99 00 07 STA scrollUpdateRam,y
  5283. 0E40F C8 INY
  5284. 0E410 A5 03 LDA temp3
  5285. 0E412 18 CLC
  5286. 0E413 69 01 ADC #$01
  5287. 0E415 99 00 07 STA scrollUpdateRam,y
  5288. 0E418 C8 INY
  5289. 0E419 A5 08 LDA tempB
  5290. 0E41B 99 00 07 STA scrollUpdateRam,y
  5291. 0E41E C8 INY
  5292. 0E41F
  5293. 0E41F A5 03 LDA temp3
  5294. 0E421 18 CLC
  5295. 0E422 69 20 ADC #$20
  5296. 0E424 85 03 STA temp3
  5297. 0E426 A5 02 LDA temp2
  5298. 0E428 69 00 ADC #$00
  5299. 0E42A 85 02 STA temp2
  5300. 0E42C
  5301. 0E42C A5 02 LDA temp2
  5302. 0E42E 99 00 07 STA scrollUpdateRam,y
  5303. 0E431 C8 INY
  5304. 0E432 A5 03 LDA temp3
  5305. 0E434 99 00 07 STA scrollUpdateRam,y
  5306. 0E437 C8 INY
  5307. 0E438 A5 09 LDA tempC
  5308. 0E43A 99 00 07 STA scrollUpdateRam,y
  5309. 0E43D C8 INY
  5310. 0E43E
  5311. 0E43E A5 02 LDA temp2
  5312. 0E440 99 00 07 STA scrollUpdateRam,y
  5313. 0E443 C8 INY
  5314. 0E444 A5 03 LDA temp3
  5315. 0E446 18 CLC
  5316. 0E447 69 01 ADC #$01
  5317. 0E449 99 00 07 STA scrollUpdateRam,y
  5318. 0E44C C8 INY
  5319. 0E44D A5 0A LDA tempD
  5320. 0E44F 99 00 07 STA scrollUpdateRam,y
  5321. 0E452 C8 INY
  5322. 0E453
  5323. 0E453 98 TYA
  5324. 0E454 8D 8B 06 STA maxScrollOffsetCounter
  5325. 0E457
  5326. 0E457
  5327. 0E457
  5328. 0E457
  5329. 0E457 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5330. 0E457 ;;; Turn on update screen on next frame.
  5331. 0E457 AD 24 06 LDA updateScreenData
  5332. 0E45A 09 04 ORA #%0000100
  5333. 0E45C 8D 24 06 STA updateScreenData
  5334. 0E45F ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5335. 0E45F
  5336. 0E45F +skipThisTile
  5337. 0E45F A4 A3 LDY bossTile_hold
  5338. 0E461 C8 INY
  5339. 0E462 C0 F0 CPY #240
  5340. 0E464 F0 06 BEQ +doneWithScreenCheck
  5341. 0E466 ;;;not done yet.
  5342. 0E466 ;;;prepare to loop on next frame
  5343. 0E466
  5344. 0E466 98 TYA
  5345. 0E467 85 A3 STA bossTile_hold
  5346. 0E469 4C 93 E4 JMP +skipBossByte
  5347. 0E46C +doneWithScreenCheck
  5348. 0E46C A9 00 LDA #$00
  5349. 0E46E 85 A3 STA bossTile_hold
  5350. 0E470 85 A2 STA bossByte
  5351. 0E472 AD 9F 06 LDA ScreenFlags00
  5352. 0E475 29 E7 AND #%11100111
  5353. 0E477 8D 9F 06 STA ScreenFlags00
  5354. 0E47A AD 85 06 LDA camX
  5355. 0E47D 18 CLC
  5356. 0E47E 69 01 ADC #$01
  5357. 0E480 8D 85 06 STA camX
  5358. 0E483 AD 86 06 LDA camX_hi
  5359. 0E486 69 00 ADC #$00
  5360. 0E488 8D 86 06 STA camX_hi
  5361. 0E48B
  5362. 0E48B AD 8C 06 LDA scrollByte
  5363. 0E48E 09 02 ORA #%00000010
  5364. 0E490 8D 8C 06 STA scrollByte
  5365. 0E493 +skipBossByte
  5366. 0E493
  5367. 0E493
  5368. 0E493 AD AB 06 LDA gameHandler
  5369. 0E496 29 80 AND #%10000000
  5370. 0E498 D0 03 BNE doUpdateToNewScreen
  5371. 0E49A 4C CB E4 JMP dontUpdateToNewScreen
  5372. 0E49D doUpdateToNewScreen:
  5373. 0E49D A9 00 LDA #$00
  5374. 0E49F 85 17 STA soft2001
  5375. 0E4A1 20 FB C8 JSR doWaitFrame
  5376. 0E4A4
  5377. 0E4A4
  5378. 0E4A4
  5379. 0E4A4 AD 74 06 LDA currentNametable
  5380. 0E4A7 AE 6D 06 LDX player1_object
  5381. 0E4AA 9D 27 04 STA Object_screen,x
  5382. 0E4AD
  5383. 0E4AD 4A LSR
  5384. 0E4AE 4A LSR
  5385. 0E4AF 4A LSR
  5386. 0E4B0 4A LSR
  5387. 0E4B1 8D 89 06 STA camY_hi
  5388. 0E4B4 AD 74 06 LDA currentNametable
  5389. 0E4B7 29 0F AND #%00001111
  5390. 0E4B9 8D 86 06 STA camX_hi
  5391. 0E4BC
  5392. 0E4BC
  5393. 0E4BC 20 A9 D5 JSR doLoadScreen2
  5394. 0E4BF 20 21 C9 JSR doLoadScreen
  5395. 0E4C2 AD AB 06 LDA gameHandler
  5396. 0E4C5 29 7F AND #%01111111
  5397. 0E4C7 8D AB 06 STA gameHandler
  5398. 0E4CA 60 RTS
  5399. 0E4CB dontUpdateToNewScreen:
  5400. 0E4CB ;
  5401. 0E4CB
  5402. 0E4CB 60 RTS0E4CC .include "Routines\BASE_4_5\Game\Subroutines\doDrawBox.asm"
  5403. 0E4CC doDrawBox:
  5404. 0E4CC A5 9B LDA gameStatusByte
  5405. 0E4CE 29 02 AND #%00000010
  5406. 0E4D0 D0 06 BNE +skipNpcText
  5407. 0E4D2 A5 9B LDA gameStatusByte
  5408. 0E4D4 09 02 ORA #%00000010
  5409. 0E4D6 85 9B STA gameStatusByte
  5410. 0E4D8 +skipNpcText
  5411. 0E4D8
  5412. 0E4D8
  5413. 0E4D8 AD 24 06 LDA updateScreenData
  5414. 0E4DB 29 05 AND #%00000101 ;; if queued to push tiles or attributes
  5415. 0E4DD F0 01 BEQ +doTextBox
  5416. 0E4DF 60 RTS
  5417. 0E4E0 +doTextBox
  5418. 0E4E0
  5419. 0E4E0
  5420. 0E4E0 ; LDA updateScreenData
  5421. 0E4E0 ; AND #%00000101 ;; if queued to push tiles or attributes
  5422. 0E4E0 ; BEQ checkQueueFlags
  5423. 0E4E0
  5424. 0E4E0
  5425. 0E4E0 ; RTS
  5426. 0E4E0 checkQueueFlags:
  5427. 0E4E0
  5428. 0E4E0 AD B5 06 LDA queueFlags
  5429. 0E4E3 29 80 AND #%10000000
  5430. 0E4E5 F0 2C BEQ skipSettingUpBox
  5431. 0E4E7
  5432. 0E4E7 A5 9B LDA gameStatusByte
  5433. 0E4E9 09 01 ORA #%00000001 ;;; this will skip object handling.
  5434. 0E4EB 85 9B STA gameStatusByte
  5435. 0E4ED
  5436. 0E4ED ; LDA arg0_hold
  5437. 0E4ED ; STA Box_x_origin
  5438. 0E4ED AD B6 06 LDA Box_x_origin
  5439. 0E4F0 8D C4 06 STA temp_boxX
  5440. 0E4F3
  5441. 0E4F3 AD B7 06 LDA Box_y_origin
  5442. 0E4F6 8D BB 06 STA Box_y_hold
  5443. 0E4F9 8D C5 06 STA temp_boxY
  5444. 0E4FC
  5445. 0E4FC AD B8 06 LDA Box_width
  5446. 0E4FF 8D C6 06 STA temp_boxWidth
  5447. 0E502
  5448. 0E502 AD B9 06 LDA Box_height
  5449. 0E505 8D BA 06 STA Box_height_hold
  5450. 0E508 8D C7 06 STA temp_boxHeight
  5451. 0E50B ;;; legacied method:
  5452. 0E50B ; STA temp_boxX
  5453. 0E50B ; LDA arg1_hold
  5454. 0E50B ; STA Box_y_origin
  5455. 0E50B ; STA Box_y_hold
  5456. 0E50B ; STA temp_boxY
  5457. 0E50B ; LDA arg2_hold
  5458. 0E50B ; STA Box_width
  5459. 0E50B ; STA temp_boxWidth
  5460. 0E50B ; LDA arg3_hold
  5461. 0E50B ; STA Box_height
  5462. 0E50B ; STA Box_height_hold
  5463. 0E50B ; STA temp_boxHeight
  5464. 0E50B ;;;;;;;;;;;;;;;;
  5465. 0E50B AD B5 06 LDA queueFlags
  5466. 0E50E 29 7F AND #%01111111
  5467. 0E510 8D B5 06 STA queueFlags
  5468. 0E513
  5469. 0E513
  5470. 0E513 skipSettingUpBox:
  5471. 0E513 AD B5 06 LDA queueFlags
  5472. 0E516 29 04 AND #%00000100
  5473. 0E518 F0 03 BEQ notCurrentlyUpdatingQueuedAttributes
  5474. 0E51A 4C CF E6 JMP currentlyUpdatingQueuedAttribtues
  5475. 0E51D notCurrentlyUpdatingQueuedAttributes:
  5476. 0E51D ;;; draw box will update one metatile row at a time,
  5477. 0E51D ;;; so at max, it will be updating 16x4 tiles (64) x 3 bytes per tile (192).
  5478. 0E51D ;;; This makes multple frames of updates easy.
  5479. 0E51D ;;; If the queue flag bit 0 is activated, that means that we have moved on to another row, but are not done yet.
  5480. 0E51D
  5481. 0E51D AD B5 06 LDA queueFlags
  5482. 0E520 29 01 AND #%00000001
  5483. 0E522 F0 03 BEQ notCurrentlyUpdatingQueuedTiles
  5484. 0E524 ;; currently updating queued tiles
  5485. 0E524
  5486. 0E524 4C 2F E5 JMP currentlyUpdatingQueuedTiles
  5487. 0E527 notCurrentlyUpdatingQueuedTiles:
  5488. 0E527 ;;;;; We are JUST starting a box update.
  5489. 0E527 ; arg0_hold = X value, in metatiles
  5490. 0E527 ; arg1_hold = y value, in metatiles
  5491. 0E527 ; arg2_hold = width, in metatiles
  5492. 0E527 ; arg3_hold = height, in metatiles
  5493. 0E527
  5494. 0E527 AD B5 06 LDA queueFlags
  5495. 0E52A 09 01 ORA #%00000001
  5496. 0E52C 8D B5 06 STA queueFlags
  5497. 0E52F
  5498. 0E52F
  5499. 0E52F currentlyUpdatingQueuedTiles:
  5500. 0E52F
  5501. 0E52F AD B6 06 LDA Box_x_origin ;; the x value, in metatiles, of the box draw.
  5502. 0E532 0A ASL ;; multiplied by two, since metatiles are 16x16, but PPU addresses are 8x8.
  5503. 0E533 85 00 STA temp
  5504. 0E535 AD B7 06 LDA Box_y_origin ;; the y value, in metatiles, of the box draw.
  5505. 0E538 0A ASL ;; multiplied by two, since metatiles are 16x16, but ppu addresses are 8x8.
  5506. 0E539 85 01 STA temp1
  5507. 0E53B 0A ASL
  5508. 0E53C 0A ASL
  5509. 0E53D 0A ASL
  5510. 0E53E 0A ASL
  5511. 0E53F 0A ASL
  5512. 0E540 18 CLC
  5513. 0E541 65 00 ADC temp
  5514. 0E543 85 03 STA temp3
  5515. 0E545
  5516. 0E545
  5517. 0E545 A5 01 LDA temp1
  5518. 0E547 4A LSR
  5519. 0E548 4A LSR
  5520. 0E549 4A LSR
  5521. 0E54A 18 CLC
  5522. 0E54B 6D BE 06 ADC camFocus_tiles
  5523. 0E54E 85 02 STA temp2
  5524. 0E550
  5525. 0E550
  5526. 0E550
  5527. 0E550 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5528. 0E550 ;;; LOAD THE BYTES INTO SCRATCH RAM:
  5529. 0E550 ;;; High, Low, Tile.
  5530. 0E550 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5531. 0E550
  5532. 0E550
  5533. 0E550 A9 00 LDA #$00
  5534. 0E552
  5535. 0E552 8D 8A 06 STA scrollOffsetCounter
  5536. 0E555 A8 TAY
  5537. 0E556
  5538. 0E556 doDrawBoxLoop:
  5539. 0E556 A9 00 LDA #$00
  5540. 0E558 85 04 STA tempx
  5541. 0E55A AE B8 06 LDX Box_width ;; load the width into x.
  5542. 0E55D
  5543. 0E55D doDrawBoxLoop_inner:
  5544. 0E55D 98 TYA
  5545. 0E55E 85 05 STA tempy
  5546. 0E560 ;;;;;;;;;;;;; What do we draw?
  5547. 0E560 ;;;;;;;;;;;;; If we are creating a box, we just draw a blank tile.
  5548. 0E560 ;;;;;;;;;;;;; If we are erasing a box, we will get the tile data of the
  5549. 0E560 ;;;;;;;;;;;;; current screen, and push the updateTile variables into
  5550. 0E560 ;;;;;;;;;;;;; tempA-tempD.
  5551. 0E560 AD B5 06 LDA queueFlags
  5552. 0E563 29 02 AND #%00000010
  5553. 0E565 D0 03 BNE isRestoringBox
  5554. 0E567 4C 0D E6 JMP isJustDrawingBox
  5555. 0E56A isRestoringBox:
  5556. 0E56A AD B5 06 LDA queueFlags
  5557. 0E56D 09 40 ORA #%01000000
  5558. 0E56F 8D B5 06 STA queueFlags
  5559. 0E572 98 48 AD 20 06 8D 21 06.. SwitchBank #$16
  5560. 0E581
  5561. 0E581 AC 74 06 LDY currentNametable
  5562. 0E584
  5563. 0E584 AD A4 06 LDA warpMap
  5564. 0E587 F0 0D BEQ +loadFromMap1table
  5565. 0E589 ; ;;;load from map 2 table
  5566. 0E589 B9 00 87 LDA NameTablePointers_Map2_lo,y
  5567. 0E58C 85 14 STA temp16
  5568. 0E58E B9 00 88 LDA NameTablePointers_Map2_hi,y
  5569. 0E591 85 15 STA temp16+1
  5570. 0E593 4C A0 E5 JMP +GotNametableLoadPointer
  5571. 0E596 +loadFromMap1table:
  5572. 0E596 B9 00 85 LDA NameTablePointers_Map1_lo,y
  5573. 0E599 85 14 STA temp16
  5574. 0E59B B9 00 86 LDA NameTablePointers_Map1_hi,y
  5575. 0E59E 85 15 STA temp16+1
  5576. 0E5A0 +GotNametableLoadPointer:
  5577. 0E5A0 ;;now (temp16) holds the address of the nametable to be loaded.
  5578. 0E5A0 98 48 AC 21 06 20 83 C5.. ReturnBank
  5579. 0E5AA
  5580. 0E5AA
  5581. 0E5AA ;; is restoring the nametable.
  5582. 0E5AA ;; Find nametable value for this position.
  5583. 0E5AA ;; First, we have to jump to the proper bank.
  5584. 0E5AA AD 74 06 LDA currentNametable
  5585. 0E5AD 4A LSR
  5586. 0E5AE 4A LSR
  5587. 0E5AF 4A LSR
  5588. 0E5B0 4A LSR
  5589. 0E5B1 4A LSR
  5590. 0E5B2 85 00 STA temp
  5591. 0E5B4
  5592. 0E5B4 AD A4 06 LDA warpMap
  5593. 0E5B7 F0 0A BEQ +dontAdd8toScreenBank
  5594. 0E5B9 ;; ad 8 to screen bank
  5595. 0E5B9 A5 00 LDA temp
  5596. 0E5BB 18 CLC
  5597. 0E5BC 69 08 ADC #$08
  5598. 0E5BE 85 00 STA temp
  5599. 0E5C0 4C C5 E5 JMP +gotScreenBank
  5600. 0E5C3 +dontAdd8toScreenBank
  5601. 0E5C3 A5 00 LDA temp
  5602. 0E5C5 +gotScreenBank:
  5603. 0E5C5 98 48 AD 20 06 8D 21 06.. SwitchBank temp
  5604. 0E5D4 ;;; now we can load from temp16, with y as our offset.
  5605. 0E5D4 AD B7 06 LDA Box_y_origin
  5606. 0E5D7 0A ASL
  5607. 0E5D8 0A ASL
  5608. 0E5D9 0A ASL
  5609. 0E5DA 0A ASL
  5610. 0E5DB 18 CLC
  5611. 0E5DC 6D B6 06 ADC Box_x_origin
  5612. 0E5DF 18 CLC
  5613. 0E5E0 65 04 ADC tempx
  5614. 0E5E2 A8 TAY
  5615. 0E5E3 B1 14 LDA (temp16),y
  5616. 0E5E5 85 00 STA temp ;; it is this value that doGetSingleMetaTileValues uses.
  5617. 0E5E7
  5618. 0E5E7
  5619. 0E5E7 98 48 AC 21 06 20 83 C5.. ReturnBank
  5620. 0E5F1
  5621. 0E5F1 A5 00 LDA temp
  5622. 0E5F3 20 24 C7 JSR doGetSingleMetaTileValues
  5623. 0E5F6 AD 53 06 LDA updateTile_00
  5624. 0E5F9 85 07 STA tempA
  5625. 0E5FB AD 54 06 LDA updateTile_01
  5626. 0E5FE 85 08 STA tempB
  5627. 0E600 AD 55 06 LDA updateTile_02
  5628. 0E603 85 09 STA tempC
  5629. 0E605 AD 56 06 LDA updateTile_03
  5630. 0E608 85 0A STA tempD
  5631. 0E60A
  5632. 0E60A
  5633. 0E60A
  5634. 0E60A 4C 17 E6 JMP gotBoxFill
  5635. 0E60D isJustDrawingBox:
  5636. 0E60D
  5637. 0E60D A9 F5 LDA #$f5
  5638. 0E60F 85 07 STA tempA
  5639. 0E611 85 08 STA tempB
  5640. 0E613 85 09 STA tempC
  5641. 0E615 85 0A STA tempD
  5642. 0E617 gotBoxFill:
  5643. 0E617
  5644. 0E617 A4 05 LDY tempy
  5645. 0E619
  5646. 0E619 A5 02 LDA temp2
  5647. 0E61B 99 00 07 STA scrollUpdateRam,y
  5648. 0E61E C8 INY
  5649. 0E61F A5 03 LDA temp3
  5650. 0E621 99 00 07 STA scrollUpdateRam,y
  5651. 0E624 C8 INY
  5652. 0E625 A5 07 LDA tempA
  5653. 0E627 99 00 07 STA scrollUpdateRam,y
  5654. 0E62A C8 INY
  5655. 0E62B
  5656. 0E62B A5 02 LDA temp2
  5657. 0E62D 99 00 07 STA scrollUpdateRam,y
  5658. 0E630 C8 INY
  5659. 0E631 A5 03 LDA temp3
  5660. 0E633 18 CLC
  5661. 0E634 69 01 ADC #$01
  5662. 0E636 99 00 07 STA scrollUpdateRam,y
  5663. 0E639 C8 INY
  5664. 0E63A A5 08 LDA tempB
  5665. 0E63C 99 00 07 STA scrollUpdateRam,y
  5666. 0E63F C8 INY
  5667. 0E640
  5668. 0E640 A5 03 LDA temp3
  5669. 0E642 18 CLC
  5670. 0E643 69 20 ADC #$20
  5671. 0E645 85 03 STA temp3
  5672. 0E647 A5 02 LDA temp2
  5673. 0E649 69 00 ADC #$00
  5674. 0E64B 85 02 STA temp2
  5675. 0E64D
  5676. 0E64D A5 02 LDA temp2
  5677. 0E64F 99 00 07 STA scrollUpdateRam,y
  5678. 0E652 C8 INY
  5679. 0E653 A5 03 LDA temp3
  5680. 0E655 99 00 07 STA scrollUpdateRam,y
  5681. 0E658 C8 INY
  5682. 0E659 A5 09 LDA tempC
  5683. 0E65B 99 00 07 STA scrollUpdateRam,y
  5684. 0E65E C8 INY
  5685. 0E65F
  5686. 0E65F A5 02 LDA temp2
  5687. 0E661 99 00 07 STA scrollUpdateRam,y
  5688. 0E664 C8 INY
  5689. 0E665 A5 03 LDA temp3
  5690. 0E667 18 CLC
  5691. 0E668 69 01 ADC #$01
  5692. 0E66A 99 00 07 STA scrollUpdateRam,y
  5693. 0E66D C8 INY
  5694. 0E66E A5 0A LDA tempD
  5695. 0E670 99 00 07 STA scrollUpdateRam,y
  5696. 0E673 C8 INY
  5697. 0E674 E6 04 INC tempx ;; temp x is the TILE offset, where as y / scrollOffsetCounter represents
  5698. 0E676 ;;; the ram offset, which consists of high byte, low byte, AND tile.
  5699. 0E676 CA DEX
  5700. 0E677 F0 10 BEQ doneWithDrawBoxRow
  5701. 0E679 ;;; more box row to draw.
  5702. 0E679 A5 03 LDA temp3
  5703. 0E67B 38 SEC
  5704. 0E67C E9 1E SBC #$1E
  5705. 0E67E 85 03 STA temp3
  5706. 0E680 A5 02 LDA temp2
  5707. 0E682 E9 00 SBC #$00
  5708. 0E684 85 02 STA temp2
  5709. 0E686 4C 5D E5 JMP doDrawBoxLoop_inner
  5710. 0E689 doneWithDrawBoxRow:
  5711. 0E689 CE BA 06 DEC Box_height_hold
  5712. 0E68C AD BA 06 LDA Box_height_hold
  5713. 0E68F F0 0C BEQ doneWithBoxDrawOutterLoop
  5714. 0E691
  5715. 0E691 AD B7 06 LDA Box_y_origin
  5716. 0E694 18 CLC
  5717. 0E695 69 01 ADC #$01
  5718. 0E697 8D B7 06 STA Box_y_origin
  5719. 0E69A 4C C2 E6 JMP notDoneWithBoxDrawOutterLoop
  5720. 0E69D doneWithBoxDrawOutterLoop:
  5721. 0E69D AD B5 06 LDA queueFlags
  5722. 0E6A0 29 40 AND #%01000000
  5723. 0E6A2 F0 0E BEQ isCreatingBoxTiles
  5724. 0E6A4 ;; is restoring box tiles
  5725. 0E6A4 ;;; COMPLETLY DONE WITH BOX.
  5726. 0E6A4 A9 00 LDA #$00
  5727. 0E6A6 8D B5 06 STA queueFlags
  5728. 0E6A9 A5 9B LDA gameStatusByte
  5729. 0E6AB 29 FC AND #%11111100 ;;; this will skip object handling.
  5730. 0E6AD 85 9B STA gameStatusByte
  5731. 0E6AF 4C C2 E6 JMP notDoneWithBoxDrawOutterLoop
  5732. 0E6B2 isCreatingBoxTiles:
  5733. 0E6B2 AD B5 06 LDA queueFlags
  5734. 0E6B5 0A ASL
  5735. 0E6B6 0A ASL
  5736. 0E6B7 ;;; this shifts these bits to the left two places.
  5737. 0E6B7 ;;; 0001 will become 0100, meaning that we are driving all attributes to box attributes.
  5738. 0E6B7 ;;; 0011 will become 1100, meaning we are restoring the screen's attributes.
  5739. 0E6B7 29 0C AND #%00001100 ;; this will scrape off the bits if we have passed attribute queue.
  5740. 0E6B9 8D B5 06 STA queueFlags
  5741. 0E6BC AD C5 06 LDA temp_boxY
  5742. 0E6BF 8D B7 06 STA Box_y_origin
  5743. 0E6C2
  5744. 0E6C2
  5745. 0E6C2 notDoneWithBoxDrawOutterLoop:
  5746. 0E6C2
  5747. 0E6C2
  5748. 0E6C2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5749. 0E6C2 ;;; Push the offset so we know how many tiles to update.
  5750. 0E6C2 ;;; max would be 85 tiles.
  5751. 0E6C2 ;;; could make this metatiles to get more out of this.
  5752. 0E6C2 98 TYA
  5753. 0E6C3 8D 8B 06 STA maxScrollOffsetCounter
  5754. 0E6C6
  5755. 0E6C6
  5756. 0E6C6
  5757. 0E6C6
  5758. 0E6C6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5759. 0E6C6 ;;; Turn on update screen on next frame.
  5760. 0E6C6 AD 24 06 LDA updateScreenData
  5761. 0E6C9 09 04 ORA #%0000100
  5762. 0E6CB 8D 24 06 STA updateScreenData
  5763. 0E6CE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5764. 0E6CE
  5765. 0E6CE
  5766. 0E6CE
  5767. 0E6CE 60 RTS
  5768. 0E6CF
  5769. 0E6CF
  5770. 0E6CF
  5771. 0E6CF currentlyUpdatingQueuedAttribtues:
  5772. 0E6CF
  5773. 0E6CF ;;; the max amount of attributes to be updated on a screen is 64.
  5774. 0E6CF ;;; There are three bytes needed to be pushed into the scrollUpdateRam to update in the next refresh.
  5775. 0E6CF ;;; All attributes, then, can be updated within 256 bytes, so there is no reason to go row by row as we do with
  5776. 0E6CF ;;; metatiles, which need 4 tile definitions x hi and low bytes for each.
  5777. 0E6CF
  5778. 0E6CF AD B5 06 LDA queueFlags
  5779. 0E6D2 29 10 AND #%00010000
  5780. 0E6D4 F0 03 BEQ doSetupAttributeQueue
  5781. 0E6D6 4C E7 E6 JMP alreadySetupAttributeQueue
  5782. 0E6D9 doSetupAttributeQueue:
  5783. 0E6D9
  5784. 0E6D9
  5785. 0E6D9 AD B9 06 LDA Box_height
  5786. 0E6DC ;; allow for odd starts, if on odd, will need to add 1
  5787. 0E6DC 8D BA 06 STA Box_height_hold
  5788. 0E6DF
  5789. 0E6DF AD B5 06 LDA queueFlags
  5790. 0E6E2 09 10 ORA #%00010000
  5791. 0E6E4 8D B5 06 STA queueFlags
  5792. 0E6E7 alreadySetupAttributeQueue
  5793. 0E6E7
  5794. 0E6E7
  5795. 0E6E7 ; LDA queueFlags
  5796. 0E6E7 ; AND #%00001000
  5797. 0E6E7 ; BEQ doBlankBoxAttributes
  5798. 0E6E7 ; JMP doRestoreScreenAttributes
  5799. 0E6E7 ; doBlankBoxAttributes:
  5800. 0E6E7
  5801. 0E6E7
  5802. 0E6E7 ;; is writing 11 to all attributes that are within "the box".
  5803. 0E6E7 AD B6 06 LDA Box_x_origin
  5804. 0E6EA 4A LSR
  5805. 0E6EB 85 07 STA tempA
  5806. 0E6ED AD BB 06 LDA Box_y_hold
  5807. 0E6F0 4A LSR
  5808. 0E6F1 85 08 STA tempB
  5809. 0E6F3
  5810. 0E6F3 AD B8 06 LDA Box_width
  5811. 0E6F6 4A LSR
  5812. 0E6F7 ;; allow for odd starts, if on odd, will need to add 1
  5813. 0E6F7 85 09 STA tempC
  5814. 0E6F9 85 06 STA tempz
  5815. 0E6FB
  5816. 0E6FB ;; now, tempA*8+tempB gives us the starting position for the box's attributes.
  5817. 0E6FB
  5818. 0E6FB A9 00 LDA #$00
  5819. 0E6FD 8D 8A 06 STA scrollOffsetCounter
  5820. 0E700 A8 TAY
  5821. 0E701
  5822. 0E701 doDrawBoxAttributesLoop:
  5823. 0E701 98 TYA
  5824. 0E702 85 05 STA tempy
  5825. 0E704
  5826. 0E704 A5 08 LDA tempB
  5827. 0E706 0A ASL
  5828. 0E707 0A ASL
  5829. 0E708 0A ASL
  5830. 0E709 18 CLC
  5831. 0E70A 65 07 ADC tempA
  5832. 0E70C 85 04 sta tempx ;; tempx is our offset for the Attribute table.
  5833. 0E70E
  5834. 0E70E
  5835. 0E70E AD BF 06 LDA camFocus_att ;; high byte, have to change based on which nametable we are in.
  5836. 0E711 85 01 STA temp1
  5837. 0E713 A9 C0 LDA #$C0
  5838. 0E715 18 CLC
  5839. 0E716 65 04 ADC tempx
  5840. 0E718 85 02 STA temp2
  5841. 0E71A
  5842. 0E71A
  5843. 0E71A
  5844. 0E71A AD B5 06 LDA queueFlags
  5845. 0E71D 29 08 AND #%00001000
  5846. 0E71F D0 07 BNE isRestoringBoxAttributes
  5847. 0E721 A9 FF LDA #$FF ;; what attribute do you want to fill the box with?
  5848. 0E723 85 03 STA temp3
  5849. 0E725 4C A2 E7 JMP gotBoxAttributeFill
  5850. 0E728
  5851. 0E728 isRestoringBoxAttributes:
  5852. 0E728 AD B5 06 LDA queueFlags
  5853. 0E72B 09 40 ORA #%01000000
  5854. 0E72D 8D B5 06 STA queueFlags
  5855. 0E730 98 48 AD 20 06 8D 21 06.. SwitchBank #$16
  5856. 0E73F AC 74 06 LDY currentNametable
  5857. 0E742 AD A4 06 LDA warpMap
  5858. 0E745 F0 0D BEQ +loadAttFromTable1
  5859. 0E747 B9 00 8B LDA AttributeTables_Map2_Lo,y
  5860. 0E74A 85 14 STA temp16
  5861. 0E74C B9 00 8C LDA AttributeTables_Map2_Hi,y
  5862. 0E74F 85 15 STA temp16+1
  5863. 0E751 4C 5E E7 JMP +gotAttFromTable
  5864. 0E754 +loadAttFromTable1:
  5865. 0E754 B9 00 89 LDA AttributeTables_Map1_Lo,y
  5866. 0E757 85 14 STA temp16
  5867. 0E759 B9 00 8A LDA AttributeTables_Map1_Hi,y
  5868. 0E75C 85 15 STA temp16+1
  5869. 0E75E +gotAttFromTable
  5870. 0E75E 98 48 AC 21 06 20 83 C5.. ReturnBank
  5871. 0E768
  5872. 0E768 AD 74 06 LDA currentNametable
  5873. 0E76B 4A LSR
  5874. 0E76C 4A LSR
  5875. 0E76D 4A LSR
  5876. 0E76E 4A LSR
  5877. 0E76F 4A LSR
  5878. 0E770 85 00 STA temp
  5879. 0E772 AD A4 06 LDA warpMap
  5880. 0E775 F0 0A BEQ +dontAdd8toscreenBankforAtt
  5881. 0E777 ;; add 8 to screen bank
  5882. 0E777 A5 00 LDA temp
  5883. 0E779 18 CLC
  5884. 0E77A 69 08 ADC #$08
  5885. 0E77C 85 00 STA temp
  5886. 0E77E 4C 83 E7 JMP +gotScreenBankForAtt
  5887. 0E781 +dontAdd8toscreenBankforAtt
  5888. 0E781 A5 00 LDA temp
  5889. 0E783 +gotScreenBankForAtt
  5890. 0E783 98 48 AD 20 06 8D 21 06.. SwitchBank temp
  5891. 0E792 A4 04 LDY tempx
  5892. 0E794 B1 14 LDA (temp16),y
  5893. 0E796 85 03 STA temp3
  5894. 0E798 98 48 AC 21 06 20 83 C5.. ReturnBank
  5895. 0E7A2
  5896. 0E7A2 gotBoxAttributeFill:
  5897. 0E7A2 A4 05 LDY tempy
  5898. 0E7A4 A5 01 LDA temp1
  5899. 0E7A6 99 00 07 STA scrollUpdateRam,y
  5900. 0E7A9 C8 INY
  5901. 0E7AA A5 02 LDA temp2
  5902. 0E7AC 99 00 07 STA scrollUpdateRam,y
  5903. 0E7AF C8 INY
  5904. 0E7B0 A5 03 LDA temp3
  5905. 0E7B2 99 00 07 STA scrollUpdateRam,y
  5906. 0E7B5 C8 INY
  5907. 0E7B6 E6 07 INC tempA
  5908. 0E7B8 C6 06 DEC tempz
  5909. 0E7BA A5 06 LDA tempz
  5910. 0E7BC F0 03 BEQ doneWithDrawBoxAttributeRow
  5911. 0E7BE 4C 01 E7 JMP doDrawBoxAttributesLoop
  5912. 0E7C1 doneWithDrawBoxAttributeRow:
  5913. 0E7C1 CE BA 06 DEC Box_height_hold
  5914. 0E7C4 AD BA 06 LDA Box_height_hold
  5915. 0E7C7 F0 06 BEQ doneWithDrawBoxAttributes
  5916. 0E7C9 EE BB 06 INC Box_y_hold
  5917. 0E7CC 4C AE E9 JMP moreBoxAttributes
  5918. 0E7CF
  5919. 0E7CF
  5920. 0E7CF doneWithDrawBoxAttributes:
  5921. 0E7CF AD B5 06 LDA queueFlags
  5922. 0E7D2 29 40 AND #%01000000
  5923. 0E7D4 F0 08 BEQ isCreatingBoxAttributes
  5924. 0E7D6 ;; is restoring box attributes
  5925. 0E7D6 A9 83 LDA #%10000011
  5926. 0E7D8 8D B5 06 STA queueFlags
  5927. 0E7DB 4C AE E9 JMP moreBoxAttributes
  5928. 0E7DE isCreatingBoxAttributes
  5929. 0E7DE A9 00 LDA #$00
  5930. 0E7E0 8D B5 06 STA queueFlags
  5931. 0E7E3 AD C2 06 LDA textQueued
  5932. 0E7E6 29 02 AND #%00000010
  5933. 0E7E8 F0 0B BEQ notTurningOffTextbox
  5934. 0E7EA
  5935. 0E7EA ;; turning off textbox
  5936. 0E7EA AD C2 06 LDA textQueued
  5937. 0E7ED 29 FD AND #%11111101
  5938. 0E7EF 8D C2 06 STA textQueued
  5939. 0E7F2 4C BC E8 JMP do02endBoxAction
  5940. 0E7F5 notTurningOffTextbox:
  5941. 0E7F5 AD C3 06 LDA endDrawBoxAction
  5942. 0E7F8 D0 03 BNE notZeroEndBoxAction
  5943. 0E7FA 4C AE E9 JMP moreBoxAttributes ;; there is no text to draw in this box
  5944. 0E7FD notZeroEndBoxAction:
  5945. 0E7FD C9 01 CMP #$01
  5946. 0E7FF F0 03 BEQ do01endBoxAction ;; do erase box
  5947. 0E801 4C B5 E8 JMP notDo01endBoxAction
  5948. 0E804 do01endBoxAction:
  5949. 0E804 ;; this means direct text is queued.
  5950. 0E804 98 48 8A 48 A9 19 85 0C.. QueueText #$19, Text2, Box_x_origin, Box_y_origin, Text2
  5951. 0E8B2 4C AE E9 JMP moreBoxAttributes
  5952. 0E8B5 notDo01endBoxAction:
  5953. 0E8B5 C9 02 CMP #$02
  5954. 0E8B7 F0 03 BEQ do02endBoxAction
  5955. 0E8B9 4C EB E8 JMP notDo02endBoxAction
  5956. 0E8BC do02endBoxAction:
  5957. 0E8BC 8A 48 98 48 AD C4 06 85.. EraseBox temp_boxX, temp_boxY, temp_boxWidth, temp_boxHeight
  5958. 0E8E8 4C AE E9 jmp moreBoxAttributes
  5959. 0E8EB notDo02endBoxAction
  5960. 0E8EB C9 03 CMP #$03
  5961. 0E8ED F0 03 BEQ do03endBoxAction
  5962. 0E8EF 4C FA E8 JMP notDo03endBoxAction
  5963. 0E8F2 do03endBoxAction:
  5964. 0E8F2 ;;; 03 type box means that this was a HUD box
  5965. 0E8F2 A9 00 LDA #$00
  5966. 0E8F4 8D C9 06 STA updateHud
  5967. 0E8F7 4C AE E9 JMP moreBoxAttributes
  5968. 0E8FA notDo03endBoxAction
  5969. 0E8FA C9 04 CMP #$04
  5970. 0E8FC F0 03 BEQ do04endBoxAction
  5971. 0E8FE 4C AE E9 JMP notDo04EndBoxAction
  5972. 0E901 do04endBoxAction:
  5973. 0E901 ;; ok this means that this is an NPC box.
  5974. 0E901 98 48 8A 48 A9 19 85 0C.. QueueText #$19, textToWrite, Box_x_origin, Box_y_origin, #$01
  5975. 0E9AE notDo04EndBoxAction:
  5976. 0E9AE moreBoxAttributes:
  5977. 0E9AE 98 TYA
  5978. 0E9AF 8D 8B 06 STA maxScrollOffsetCounter
  5979. 0E9B2 justUpdateScreenData:
  5980. 0E9B2
  5981. 0E9B2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5982. 0E9B2 ;;; Turn on update screen on next frame.
  5983. 0E9B2 AD 24 06 LDA updateScreenData
  5984. 0E9B5 09 04 ORA #%0000100
  5985. 0E9B7 8D 24 06 STA updateScreenData
  5986. 0E9BA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5987. 0E9BA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5988. 0E9BA 60 RTS
  5989. 0E9BB
  5990. 0E9BB doRestoreScreenAttributes:
  5991. 0E9BB
  5992. 0E9BB
  5993. 0E9BB 60 RTS 0E9BC
  5994. 0E9BC
  5995. 0E9BC
  5996. 0E9BC
  5997. 0E9BC .include "Routines\BASE_4_5\Game\Subroutines\doHandleObjects_withinCamera.asm"
  5998. 0E9BC doHandleObjects:
  5999. 0E9BC A5 9B LDA gameStatusByte
  6000. 0E9BE 29 01 AND #%00000001 ;;; this will skip object handling.
  6001. 0E9C0 F0 01 BEQ dontSkipObjectHandling
  6002. 0E9C2 60 RTS
  6003. 0E9C3 dontSkipObjectHandling:
  6004. 0E9C3 AD AB 06 LDA gameHandler
  6005. 0E9C6 29 80 AND #%10000000
  6006. 0E9C8 F0 01 BEQ dontSkipObjectHandling2
  6007. 0E9CA ;;; this was in the middle of a screen transition
  6008. 0E9CA 60 RTS
  6009. 0E9CB dontSkipObjectHandling2
  6010. 0E9CB
  6011. 0E9CB ;;;; RESET ANY VARIABLES THAT NEED RESET BEFORE EVALUATION
  6012. 0E9CB AD DA 06 LDA npcTrigger
  6013. 0E9CE 29 FE AND #%11111110
  6014. 0E9D0 8D DA 06 STA npcTrigger
  6015. 0E9D3 ;;;; Create state
  6016. 0E9D3 A2 00 LDX #$00
  6017. 0E9D5
  6018. 0E9D5 loop_doHandleObjectsLoop:
  6019. 0E9D5
  6020. 0E9D5 BD 00 04 LDA Object_status,x
  6021. 0E9D8 29 C0 AND #%11000000
  6022. 0E9DA D0 03 BNE objectHasActivity
  6023. 0E9DC ;;;; this object is not being created
  6024. 0E9DC ;;;; and is not active.
  6025. 0E9DC 4C 00 EF JMP doObjectIsInactive
  6026. 0E9DF
  6027. 0E9DF objectHasActivity:
  6028. 0E9DF BD 00 04 LDA Object_status,x
  6029. 0E9E2 29 01 AND #OBJECT_QUEUED_FOR_DESTRUCTION
  6030. 0E9E4 F0 08 BEQ doNotDestroyThisObject
  6031. 0E9E6 ;;;; Destroy
  6032. 0E9E6 .include "Routines\BASE_4_5\Game\Subroutines\doDestroyState.asm"
  6033. 0E9E6 ;do object destroy state0E9E6 A9 00 LDA #$00
  6034. 0E9E8 9D 00 04 STA Object_status,x
  6035. 0E9EB 4C 00 EF JMP doObjectIsInactive ;; destroying will automatically set this object to inactive.
  6036. 0E9EE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6037. 0E9EE ;;;;;;;;END OF THE LINE FOR THIS OBJECT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6038. 0E9EE
  6039. 0E9EE doNotDestroyThisObject:
  6040. 0E9EE
  6041. 0E9EE BD 00 04 LDA Object_status,x
  6042. 0E9F1 29 80 AND #OBJECT_IS_ACTIVE
  6043. 0E9F3 F0 03 BEQ checkForObjectActivation
  6044. 0E9F5 4C 4C EA JMP doActiveObject
  6045. 0E9F8 checkForObjectActivation:
  6046. 0E9F8
  6047. 0E9F8 BD 00 04 LDA Object_status,x
  6048. 0E9FB 29 40 AND #OBJECT_QUEUED_FOR_ACTIVATION
  6049. 0E9FD D0 03 BNE doCreateThisNewObjectd
  6050. 0E9FF 4C 00 EF JMP doObjectIsInactive
  6051. 0EA02 doCreateThisNewObjectd:
  6052. 0EA02 ;;; create the new object.
  6053. 0EA02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6054. 0EA02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6055. 0EA02 ;; Here, we create a new object. It will exist upon the next frame.
  6056. 0EA02 .include "Routines\BASE_4_5\Game\MOD_AdventureBase\Subroutines\doCreateState_addExtraVariables_AdventureBase.asm"
  6057. 0EA02 98 48 AD 20 06 8D 21 06.. SwitchBank #$1C
  6058. 0EA11 BC 8F 04 LDY Object_type,x
  6059. 0EA14 B9 D0 90 LDA ObjectHealth,y
  6060. 0EA17 9D DD 04 STA Object_health,x
  6061. 0EA1A
  6062. 0EA1A
  6063. 0EA1A
  6064. 0EA1A
  6065. 0EA1A
  6066. 0EA1A
  6067. 0EA1A 98 48 AC 21 06 20 83 C5.. ReturnBank
  6068. 0EA24 0EA24
  6069. 0EA24 20 5D DD JSR doHandleCreateState
  6070. 0EA27 98 48 AD 20 06 8D 21 06.. SwitchBank #$1C
  6071. 0EA36 BC 8F 04 LDY Object_type,x
  6072. 0EA39 B9 20 91 LDA ObjectFlags,y
  6073. 0EA3C 9D D0 04 STA Object_flags,x
  6074. 0EA3F 98 48 AC 21 06 20 83 C5.. ReturnBank
  6075. 0EA49
  6076. 0EA49 4C 00 EF JMP doObjectIsInactive
  6077. 0EA4C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6078. 0EA4C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6079. 0EA4C ;; Below is everything that happens for an active object.
  6080. 0EA4C doActiveObject:
  6081. 0EA4C
  6082. 0EA4C ;;;; EVALUATE THE CAMERA POSITION
  6083. 0EA4C
  6084. 0EA4C BD 1A 04 LDA Object_x_hi,x
  6085. 0EA4F 85 1B STA pointer
  6086. 0EA51 BD 27 04 LDA Object_screen,x
  6087. 0EA54 29 0F AND #%00001111
  6088. 0EA56 85 1C STA pointer+1
  6089. 0EA58
  6090. 0EA58 A5 1C CD 86 06 D0 0A A5.. Compare16 pointer+1, pointer, camX_hi, camX
  6091. 0EA7C ; arg0 = high byte of first value
  6092. 0EA7C ; arg1 = low byte of first value
  6093. 0EA7C ; arg2 = high byte of second value
  6094. 0EA7C ; arg3 = low byte of second value
  6095. 0EA7C
  6096. 0EA7C +
  6097. 0EA7C 4C 82 EA JMP +checkRightForDrawingOffCamera
  6098. 0EA7F
  6099. 0EA7F ++
  6100. 0EA7F ;;; object is outside camera
  6101. 0EA7F ;;; so skip updating this object.
  6102. 0EA7F 4C 00 EF JMP doObjectIsInactive
  6103. 0EA82
  6104. 0EA82 +checkRightForDrawingOffCamera
  6105. 0EA82 BD 1A 04 LDA Object_x_hi,x
  6106. 0EA85 ;CLC
  6107. 0EA85 ;ADC #$10 ;; arbitrary - approximate width of objects
  6108. 0EA85 85 1B STA pointer
  6109. 0EA87 BD 27 04 LDA Object_screen,x
  6110. 0EA8A ;ADC #$00
  6111. 0EA8A 29 0F AND #%00001111
  6112. 0EA8C 85 1C STA pointer+1
  6113. 0EA8E
  6114. 0EA8E AD 85 06 LDA camX
  6115. 0EA91 85 23 STA pointer5
  6116. 0EA93 AD 86 06 LDA camX+1
  6117. 0EA96 18 clc
  6118. 0EA97 69 01 ADC #$01
  6119. 0EA99 85 00 STA temp
  6120. 0EA9B A5 1C C5 00 D0 09 A5 1B.. Compare16 pointer+1, pointer, temp, pointer5; camX
  6121. 0EABB +
  6122. 0EABB ;; this camera is out of camera range.
  6123. 0EABB 4C 00 EF JMP doObjectIsInactive
  6124. 0EABE ++
  6125. 0EABE ;;; this object is in camera range.
  6126. 0EABE ;;; cotninue evaluating this object.
  6127. 0EABE
  6128. 0EABE
  6129. 0EABE ;; ORDER OF OPERATIONS
  6130. 0EABE ; 1) Check to see if this object reads input (status byte). If not (0), skip input read.
  6131. 0EABE ; 2) We have the states from each button (8 buttons, two controllers) from input management.
  6132. 0EABE ; So now we compare it to this object, and whether or not it should
  6133. 0EABE ; have any behaviors associated with it's pressed, down, released, or up states.
  6134. 0EABE ; 3) Switch banks to the one that contains our LUTs for object data (sizes and whatnot)
  6135. 0EABE ; 4) Check to see if this object observes physics (status byte). If not (0), skip physics.
  6136. 0EABE
  6137. 0EABE ; 5) Do a basic physics update for this object.
  6138. 0EABE ; 6) Check to see if this object observes tile collisions. If not (0), skip tile collisions.
  6139. 0EABE ; 7) Check tile collisions.
  6140. 0EABE ; 8) Check to see if this object observes object collisions. If not (0), skip object collisions.
  6141. 0EABE ; 9) Check object collisions.
  6142. 0EABE ; 10) Check bounds.
  6143. 0EABE ; 11) Update the object's position and behavior based on above.
  6144. 0EABE ; 12) Check to see if this object should be drawn. If not (0), skip drawing.
  6145. 0EABE ; 13) Draw this object.
  6146. 0EABE ; 14) Return to main bank.
  6147. 0EABE
  6148. 0EABE ;; So status byte would be:
  6149. 0EABE ;; #% 7 6 5 4 3 2 1 0
  6150. 0EABE ;; | | | | | | | + - Queued for deactivation (?)
  6151. 0EABE ;; | | | | | | + --- Observes drawing
  6152. 0EABE ;; | | | | | + ----- Observes Object Collisions
  6153. 0EABE ;; | | | | + ------- Observes Tile Collisions
  6154. 0EABE ;; | | | + --------- Observes Physics
  6155. 0EABE ;; | | + ----------- Observes Input
  6156. 0EABE ;; | + ------------- Queued for activation
  6157. 0EABE ;; + --------------- Active
  6158. 0EABE
  6159. 0EABE BD 8F 04 LDA Object_type,x
  6160. 0EAC1 8D CA 06 STA tempObjType ;; not corrupted by any other routines
  6161. 0EAC4 ;; used in timer handlings so no reference to bank1c is needed.
  6162. 0EAC4 98 48 AD 20 06 8D 21 06.. SwitchBank #$18
  6163. 0EAD3 BC 8F 04 LDY Object_type,x
  6164. 0EAD6 B9 00 80 LDA ObjectReaction,y
  6165. 0EAD9 8D 6B 06 STA EdgeSolidReaction ;; temporarily holds this data.
  6166. 0EADC
  6167. 0EADC 98 48 AC 21 06 20 83 C5.. ReturnBank
  6168. 0EAE6
  6169. 0EAE6 BD 00 04 LDA Object_status,x
  6170. 0EAE9 29 20 AND #OBJECT_OBSERVES_INPUT
  6171. 0EAEB D0 03 BNE ObjectReceivesInput
  6172. 0EAED 4C F0 EA JMP ObjectDoesNotRecieveInput
  6173. 0EAF0 ObjectReceivesInput:
  6174. 0EAF0 ;;;; Input state
  6175. 0EAF0 .include "Routines\BASE_4_5\Game\Subroutines\doInputState.asm"
  6176. 0EAF0 ;;;input state0EAF0
  6177. 0EAF0
  6178. 0EAF0
  6179. 0EAF0
  6180. 0EAF0
  6181. 0EAF0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6182. 0EAF0 ObjectDoesNotRecieveInput:
  6183. 0EAF0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6184. 0EAF0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6185. 0EAF0
  6186. 0EAF0 BD 00 04 LDA Object_status,x
  6187. 0EAF3 29 10 AND #OBJECT_OBSERVES_PHYSICS
  6188. 0EAF5 D0 03 BNE ObjectDoesObservePhysics
  6189. 0EAF7 4C 66 EE JMP ObjectDoesNotObservePhysics
  6190. 0EAFA ObjectDoesObservePhysics:
  6191. 0EAFA ;;;;; SYSTEM PHYSICS
  6192. 0EAFA ;; we will use bank #$1C for physics since it has our lut tables in it.
  6193. 0EAFA 98 48 AD 20 06 8D 21 06.. SwitchBank #$1C
  6194. 0EB09 8A TXA
  6195. 0EB0A 48 PHA
  6196. 0EB0B .include "Routines\BASE_4_5\Game\MOD_shooter\Subroutines\doHandlePhysics_shooter2.asm"
  6197. 0EB0B ;; do handle physics.
  6198. 0EB0B
  6199. 0EB0B
  6200. 0EB0B BD 0D 04 LDA Object_x_lo,x
  6201. 0EB0E 8D 78 06 STA xHold_lo
  6202. 0EB11 BD 1A 04 LDA Object_x_hi,x
  6203. 0EB14 8D 79 06 STA xHold_hi
  6204. 0EB17 8D 7F 06 STA xPrev
  6205. 0EB1A
  6206. 0EB1A BD 27 04 LDA Object_screen,x
  6207. 0EB1D 8D 7A 06 STA xHold_screen
  6208. 0EB20 85 9F sta screenPrev
  6209. 0EB22
  6210. 0EB22 BD 34 04 LDA Object_y_lo,x
  6211. 0EB25 8D 7B 06 STA yHold_lo
  6212. 0EB28 BD 41 04 LDA Object_y_hi,x
  6213. 0EB2B 8D 7C 06 STA yHold_hi
  6214. 0EB2E 8D 80 06 STA yPrev
  6215. 0EB31
  6216. 0EB31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6217. 0EB31 ;;; Set up speeds and collision variables
  6218. 0EB31 BC 8F 04 LDY Object_type,x
  6219. 0EB34 B9 00 8E LDA ObjectMaxSpeed,y
  6220. 0EB37 0A ASL
  6221. 0EB38 0A ASL
  6222. 0EB39 0A ASL
  6223. 0EB3A 0A ASL
  6224. 0EB3B ;AND #%00001111
  6225. 0EB3B 8D 69 06 STA myMaxSpeed
  6226. 0EB3E B9 00 8E LDA ObjectMaxSpeed,y
  6227. 0EB41 4A LSR
  6228. 0EB42 4A LSR
  6229. 0EB43 4A LSR
  6230. 0EB44 4A LSR
  6231. 0EB45 8D 6A 06 STA myMaxSpeed+1
  6232. 0EB48 ;;; now high max speed byte is the actual high byte of speed
  6233. 0EB48 ;;; low max speed byte is the low byte of speed
  6234. 0EB48 A9 00 LDA #$00
  6235. 0EB4A 8D 68 06 STA myAcc+1
  6236. 0EB4D B9 70 91 LDA ObjectAccAmount,y
  6237. 0EB50 8D 67 06 STA myAcc
  6238. 0EB53
  6239. 0EB53
  6240. 0EB53 B9 A0 8E LDA ObjectBboxLeft,y
  6241. 0EB56 8D 59 06 STA self_left
  6242. 0EB59 18 CLC
  6243. 0EB5A 79 F0 8E ADC ObjectWidth,y
  6244. 0EB5D 8D 5B 06 STA self_right
  6245. 0EB60 38 SEC
  6246. 0EB61 ED 59 06 SBC self_left
  6247. 0EB64 4A LSR
  6248. 0EB65 8D 5D 06 STA self_center_x
  6249. 0EB68
  6250. 0EB68 B9 40 8F LDA ObjectBboxTop,y
  6251. 0EB6B 8D 5A 06 STA self_top
  6252. 0EB6E 18 CLC
  6253. 0EB6F 79 90 8F ADC ObjectHeight,y
  6254. 0EB72 8D 5C 06 STA self_bottom
  6255. 0EB75 38 SEC
  6256. 0EB76 ED 5A 06 SBC self_top
  6257. 0EB79 4A LSR
  6258. 0EB7A 8D 5E 06 STA self_center_y ;; self center in the vertical direction.
  6259. 0EB7D
  6260. 0EB7D ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6261. 0EB7D ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6262. 0EB7D
  6263. 0EB7D
  6264. 0EB7D
  6265. 0EB7D BD 00 04 LDA Object_status,x
  6266. 0EB80 29 04 AND #%00000100
  6267. 0EB82 D0 03 BNE doHandlePhysics
  6268. 0EB84 4C 33 EE JMP skipPhysics
  6269. 0EB87 doHandlePhysics:
  6270. 0EB87 A9 00 LDA #$00
  6271. 0EB89 8D 6C 06 STA collisionsToCheck ;; blank out collisions to check.
  6272. 0EB8C
  6273. 0EB8C ;;; check to see if we are using aiming physics.
  6274. 0EB8C ;;; if we are using aim physics, Object_direction will have it's 3rd bit flipped. xxxxXxxx
  6275. 0EB8C BD A9 04 LDA Object_direction,x
  6276. 0EB8F 29 08 AND #%00001000
  6277. 0EB91 D0 03 BNE +useAimedPhysics
  6278. 0EB93 4C 9A EC JMP useNormalDirectionalPhysics
  6279. 0EB96 +useAimedPhysics
  6280. 0EB96
  6281. 0EB96 A9 0F LDA #%00001111
  6282. 0EB98 8D 6C 06 STA collisionsToCheck
  6283. 0EB9B BC 8F 04 LDY Object_type,x
  6284. 0EB9E B9 00 8E LDA ObjectMaxSpeed,y
  6285. 0EBA1 4A LSR
  6286. 0EBA2 4A LSR
  6287. 0EBA3 4A LSR
  6288. 0EBA4 4A LSR
  6289. 0EBA5 85 07 STA tempA ;; high byte of "speed" will determine how many times we should update move towards speed.
  6290. 0EBA7 ;; use aimed physics.
  6291. 0EBA7 ;; Aimed physics doesn't need to update speed.
  6292. 0EBA7 BD 0D 04 LDA Object_x_lo,x
  6293. 0EBAA 8D 78 06 STA xHold_lo
  6294. 0EBAD BD 1A 04 LDA Object_x_hi,x
  6295. 0EBB0 8D 79 06 STA xHold_hi
  6296. 0EBB3
  6297. 0EBB3 BD 34 04 LDA Object_y_lo,x
  6298. 0EBB6 8D 7B 06 STA yHold_lo
  6299. 0EBB9 BD 41 04 LDA Object_y_hi,x
  6300. 0EBBC 8D 7C 06 STA yHold_hi
  6301. 0EBBF
  6302. 0EBBF BD 4E 04 LDA Object_h_speed_lo,x
  6303. 0EBC2 10 21 BPL AddHspeedToAimedX
  6304. 0EBC4 ;; subtract h speed to aimed x
  6305. 0EBC4 BD 4E 04 LDA Object_h_speed_lo,x
  6306. 0EBC7 49 FF EOR #$FF
  6307. 0EBC9 85 00 STA temp
  6308. 0EBCB A4 07 LDY tempA
  6309. 0EBCD doAimLoop1:
  6310. 0EBCD AD 78 06 LDA xHold_lo
  6311. 0EBD0 38 sec
  6312. 0EBD1 E5 00 sbc temp
  6313. 0EBD3 8D 78 06 STA xHold_lo
  6314. 0EBD6 AD 79 06 LDA xHold_hi
  6315. 0EBD9 FD 5B 04 sbc Object_h_speed_hi,x
  6316. 0EBDC 8D 79 06 STA xHold_hi
  6317. 0EBDF 88 DEY
  6318. 0EBE0 10 EB BPL doAimLoop1
  6319. 0EBE2
  6320. 0EBE2
  6321. 0EBE2
  6322. 0EBE2 4C FD EB JMP figureAimedVspeed
  6323. 0EBE5 AddHspeedToAimedX:
  6324. 0EBE5 A4 07 LDY tempA
  6325. 0EBE7 doAimLoop2:
  6326. 0EBE7 AD 78 06 LDA xHold_lo
  6327. 0EBEA 18 CLC
  6328. 0EBEB 7D 4E 04 ADC Object_h_speed_lo,x
  6329. 0EBEE 8D 78 06 STA xHold_lo
  6330. 0EBF1 AD 79 06 LDA xHold_hi
  6331. 0EBF4 7D 5B 04 ADC Object_h_speed_hi,x
  6332. 0EBF7 8D 79 06 STA xHold_hi
  6333. 0EBFA 88 DEY
  6334. 0EBFB 10 EA BPL doAimLoop2
  6335. 0EBFD
  6336. 0EBFD figureAimedVspeed:
  6337. 0EBFD
  6338. 0EBFD BD 68 04 LDA Object_v_speed_lo,x
  6339. 0EC00 10 21 BPL AddVSpeedToAimedY
  6340. 0EC02 ;; subtract v speed to aimed y
  6341. 0EC02 BD 68 04 LDA Object_v_speed_lo,x
  6342. 0EC05 49 FF EOR #$FF
  6343. 0EC07 85 00 STA temp
  6344. 0EC09 A4 07 LDY tempA
  6345. 0EC0B doAimLoop3:
  6346. 0EC0B AD 7B 06 LDA yHold_lo
  6347. 0EC0E 18 clc
  6348. 0EC0F 65 00 adc temp
  6349. 0EC11 8D 7B 06 STA yHold_lo
  6350. 0EC14 AD 7C 06 LDA yHold_hi
  6351. 0EC17 7D 75 04 adc Object_v_speed_hi,x
  6352. 0EC1A 8D 7C 06 STA yHold_hi
  6353. 0EC1D 88 DEY
  6354. 0EC1E 10 EB BPL doAimLoop3
  6355. 0EC20
  6356. 0EC20 4C 3B EC JMP doneWithAimedV
  6357. 0EC23 AddVSpeedToAimedY:
  6358. 0EC23 A4 07 LDY tempA
  6359. 0EC25 doAimLoop4:
  6360. 0EC25 AD 7B 06 LDA yHold_lo
  6361. 0EC28 38 sec
  6362. 0EC29 FD 68 04 sbc Object_v_speed_lo,x
  6363. 0EC2C 8D 7B 06 STA yHold_lo
  6364. 0EC2F AD 7C 06 LDA yHold_hi
  6365. 0EC32 FD 75 04 sbc Object_v_speed_hi,x
  6366. 0EC35 8D 7C 06 STA yHold_hi
  6367. 0EC38 88 DEY
  6368. 0EC39 10 EA BPL doAimLoop4
  6369. 0EC3B doneWithAimedV:
  6370. 0EC3B
  6371. 0EC3B ;;;;;;;;;;;;; check xHold_hi and yHold_hi against bounds.
  6372. 0EC3B
  6373. 0EC3B AD 7C 06 LDA yHold_hi
  6374. 0EC3E C9 00 CMP #BOUNDS_TOP
  6375. 0EC40 F0 05 BEQ +doTopBounds
  6376. 0EC42 90 03 BCC +doTopBounds
  6377. 0EC44 4C 52 EC JMP +doneWithTop
  6378. 0EC47 +doTopBounds
  6379. 0EC47
  6380. 0EC47 A9 02 LDA #$02
  6381. 0EC49 8D B4 06 STA screenUpdateByte
  6382. 0EC4C
  6383. 0EC4C 20 04 C9 JSR doHandleBounds
  6384. 0EC4F 4C 33 EE JMP skipPhysics
  6385. 0EC52
  6386. 0EC52 +doneWithTop
  6387. 0EC52
  6388. 0EC52 8D 7C 06 STA yHold_hi
  6389. 0EC55 18 CLC
  6390. 0EC56 6D 5C 06 ADC self_bottom
  6391. 0EC59 C9 F0 CMP #BOUNDS_BOTTOM ;#240
  6392. 0EC5B ; BEQ doBottomBounds
  6393. 0EC5B B0 03 BCS +doBottomBounds
  6394. 0EC5D 4C 69 EC JMP +doneWithBottom
  6395. 0EC60 +doBottomBounds:
  6396. 0EC60 8D B4 06 STA screenUpdateByte
  6397. 0EC63 20 04 C9 JSR doHandleBounds
  6398. 0EC66 4C 33 EE JMP skipPhysics
  6399. 0EC69
  6400. 0EC69 +doneWithBottom
  6401. 0EC69
  6402. 0EC69
  6403. 0EC69
  6404. 0EC69 AD 79 06 LDA xHold_hi
  6405. 0EC6C 18 clc
  6406. 0EC6D 6D 5B 06 ADC self_right
  6407. 0EC70 B0 03 BCS +doRightBounds
  6408. 0EC72 4C 80 EC JMP +doneWithRight
  6409. 0EC75 +doRightBounds:
  6410. 0EC75
  6411. 0EC75 A9 01 LDA #$01
  6412. 0EC77 8D B4 06 STA screenUpdateByte
  6413. 0EC7A 20 04 C9 JSR doHandleBounds
  6414. 0EC7D 4C 33 EE JMP skipPhysics
  6415. 0EC80
  6416. 0EC80 +doneWithRight
  6417. 0EC80 AD 79 06 LDA xHold_hi
  6418. 0EC83 C9 00 CMP #BOUNDS_LEFT
  6419. 0EC85 F0 05 BEQ +doLeftBounds
  6420. 0EC87 90 03 BCC +doLeftBounds
  6421. 0EC89 4C 97 EC JMP +doneWithLeft
  6422. 0EC8C +doLeftBounds
  6423. 0EC8C
  6424. 0EC8C A9 03 LDA #$03
  6425. 0EC8E 8D B4 06 STA screenUpdateByte
  6426. 0EC91 20 04 C9 JSR doHandleBounds
  6427. 0EC94 4C 33 EE JMP skipPhysics
  6428. 0EC97 +doneWithLeft
  6429. 0EC97 4C 33 EE JMP skipPhysics ;; skips all the acc/dec stuff and goes right to movement based on speed
  6430. 0EC9A ;; which was figured out in the directional macro.
  6431. 0EC9A
  6432. 0EC9A useNormalDirectionalPhysics:
  6433. 0EC9A
  6434. 0EC9A A9 00 LDA #$00
  6435. 0EC9C 8D 6C 06 STA collisionsToCheck ;; blank out collisions to check.
  6436. 0EC9F
  6437. 0EC9F BD A9 04 LDA Object_direction,x
  6438. 0ECA2 29 80 AND #%10000000
  6439. 0ECA4 D0 03 BNE +isHorMovement
  6440. 0ECA6 4C B1 ED JMP +noHorMovement
  6441. 0ECA9 +isHorMovement
  6442. 0ECA9 ;; there is vertical movement
  6443. 0ECA9 BD A9 04 LDA Object_direction,x
  6444. 0ECAC 29 40 AND #%01000000
  6445. 0ECAE D0 03 BNE +isNotLeftMovement
  6446. 0ECB0 4C 3D ED JMP +isLeftMovement
  6447. 0ECB3 +isNotLeftMovement
  6448. 0ECB3 ;; is right movement
  6449. 0ECB3 BD 0D 04 LDA Object_x_lo,x
  6450. 0ECB6 18 CLC
  6451. 0ECB7 6D 69 06 ADC myMaxSpeed;Object_v_speed_lo,x
  6452. 0ECBA 8D 78 06 STA xHold_lo
  6453. 0ECBD BD 1A 04 LDA Object_x_hi,x
  6454. 0ECC0 6D 6A 06 ADC myMaxSpeed+1;Object_v_speed_hi,x
  6455. 0ECC3 8D 79 06 STA xHold_hi
  6456. 0ECC6 BD 27 04 LDA Object_screen,x
  6457. 0ECC9 69 00 ADC #$00
  6458. 0ECCB 8D 7A 06 STA xHold_screen
  6459. 0ECCE
  6460. 0ECCE AD 79 06 LDA xHold_hi
  6461. 0ECD1 18 clc
  6462. 0ECD2 69 10 adc #$10
  6463. 0ECD4 85 02 STA temp2
  6464. 0ECD6
  6465. 0ECD6 BD 27 04 LDA Object_screen,x
  6466. 0ECD9 69 00 ADC #$00
  6467. 0ECDB 29 0F AND #%00001111
  6468. 0ECDD 85 00 STA temp
  6469. 0ECDF
  6470. 0ECDF AD 85 06 LDA camX
  6471. 0ECE2 18 CLC
  6472. 0ECE3 69 FE ADC #$FE
  6473. 0ECE5 85 07 STA tempA
  6474. 0ECE7 AD 86 06 LDA camX_hi
  6475. 0ECEA 69 00 ADC #$00
  6476. 0ECEC 85 01 STA temp1
  6477. 0ECEE
  6478. 0ECEE
  6479. 0ECEE
  6480. 0ECEE A5 01 C5 00 D0 09 A5 07.. Compare16 temp1, tempA, temp, temp2
  6481. 0ED0E +
  6482. 0ED0E 4C B1 ED JMP +noHorMovement
  6483. 0ED11 ++
  6484. 0ED11 EC 6D 06 CPX player1_object
  6485. 0ED14 F0 0B BEQ +isPlayer
  6486. 0ED16 BD 00 04 29 3F 9D 00 04 DestroyObject
  6487. 0ED1E 4C 33 EE JMP skipPhysics
  6488. 0ED21 +isPlayer
  6489. 0ED21 A9 00 LDA #$00
  6490. 0ED23 9D 4E 04 STA Object_h_speed_lo,x
  6491. 0ED26 9D 5B 04 STA Object_h_speed_hi,x
  6492. 0ED29 8D 78 06 STA xHold_lo
  6493. 0ED2C AD 7F 06 LDA xPrev
  6494. 0ED2F 8D 79 06 STA xHold_hi
  6495. 0ED32 A5 9F LDA screenPrev
  6496. 0ED34 8D 7A 06 STA xHold_screen
  6497. 0ED37 4C 33 EE JMP skipPhysics
  6498. 0ED3A 4C B1 ED JMP +noHorMovement
  6499. 0ED3D +isLeftMovement
  6500. 0ED3D
  6501. 0ED3D BD 0D 04 LDA Object_x_lo,x
  6502. 0ED40 38 SEC
  6503. 0ED41 ED 69 06 SBC myMaxSpeed;Object_v_speed_lo,x
  6504. 0ED44 8D 78 06 STA xHold_lo
  6505. 0ED47 BD 1A 04 LDA Object_x_hi,x
  6506. 0ED4A ED 6A 06 SBC myMaxSpeed+1;Object_v_speed_hi,x
  6507. 0ED4D 8D 79 06 STA xHold_hi
  6508. 0ED50 BD 27 04 LDA Object_screen,x
  6509. 0ED53 E9 00 SBC #$00
  6510. 0ED55 8D 7A 06 STA xHold_screen
  6511. 0ED58
  6512. 0ED58
  6513. 0ED58 AD 7A 06 LDA xHold_screen
  6514. 0ED5B 29 0F AND #%00001111
  6515. 0ED5D 85 00 STA temp
  6516. 0ED5F
  6517. 0ED5F AD 86 06 C5 00 D0 0B AD.. Compare16 camX_hi, camX, temp, xHold_hi
  6518. 0ED85
  6519. 0ED85 +
  6520. 0ED85 EC 6D 06 CPX player1_object
  6521. 0ED88 F0 0B BEQ +isPlayer
  6522. 0ED8A BD 00 04 29 3F 9D 00 04 DestroyObject
  6523. 0ED92 4C 33 EE JMP skipPhysics
  6524. 0ED95 +isPlayer
  6525. 0ED95 A9 00 LDA #$00
  6526. 0ED97 8D 78 06 STA xHold_lo
  6527. 0ED9A AD 7F 06 LDA xPrev
  6528. 0ED9D 8D 79 06 STA xHold_hi
  6529. 0EDA0 BD 27 04 LDA Object_screen,x
  6530. 0EDA3 8D 7A 06 STA xHold_screen
  6531. 0EDA6 4C 33 EE JMP skipPhysics
  6532. 0EDA9 BD 00 04 29 3F 9D 00 04 DestroyObject
  6533. 0EDB1 ++
  6534. 0EDB1
  6535. 0EDB1 +noHorMovement
  6536. 0EDB1
  6537. 0EDB1 BD A9 04 LDA Object_direction,x
  6538. 0EDB4 29 20 AND #%00100000
  6539. 0EDB6 F0 7B BEQ +noVertMovement
  6540. 0EDB8 ;; there is vertical movement
  6541. 0EDB8 BD A9 04 LDA Object_direction,x
  6542. 0EDBB 29 10 AND #%00010000
  6543. 0EDBD F0 3A BEQ +isUpMovement
  6544. 0EDBF ;; is down movement
  6545. 0EDBF BD 34 04 LDA Object_y_lo,x
  6546. 0EDC2 18 CLC
  6547. 0EDC3 6D 69 06 ADC myMaxSpeed;Object_v_speed_lo,x
  6548. 0EDC6 8D 7B 06 STA yHold_lo
  6549. 0EDC9 BD 41 04 LDA Object_y_hi,x
  6550. 0EDCC 6D 6A 06 ADC myMaxSpeed+1;Object_v_speed_hi,x
  6551. 0EDCF 8D 7C 06 STA yHold_hi
  6552. 0EDD2 18 CLC
  6553. 0EDD3 6D 5C 06 ADC self_bottom
  6554. 0EDD6 C9 F0 CMP #BOUNDS_BOTTOM ;#240
  6555. 0EDD8
  6556. 0EDD8 B0 03 BCS doBottomBounds
  6557. 0EDDA 4C 33 EE JMP +noVertMovement
  6558. 0EDDD doBottomBounds:
  6559. 0EDDD EC 6D 06 CPX player1_object
  6560. 0EDE0 F0 0B BEQ +isPlayer
  6561. 0EDE2 BD 00 04 29 3F 9D 00 04 DestroyObject
  6562. 0EDEA 4C 33 EE JMP skipPhysics
  6563. 0EDED +isPlayer
  6564. 0EDED AD 80 06 LDA yPrev
  6565. 0EDF0 8D 7C 06 STA yHold_hi
  6566. 0EDF3 9D 41 04 STA Object_y_hi,x
  6567. 0EDF6 ; LDA #$00
  6568. 0EDF6 ; STA Object_v_speed_hi,x
  6569. 0EDF6 ; STA Object_v_speed_lo,x
  6570. 0EDF6 ; LDA #$00
  6571. 0EDF6 ; STA screenUpdateByte
  6572. 0EDF6 ; JSR doHandleBounds
  6573. 0EDF6 4C 33 EE JMP skipPhysics
  6574. 0EDF9 +isUpMovement
  6575. 0EDF9 BD 34 04 LDA Object_y_lo,x
  6576. 0EDFC 38 SEC
  6577. 0EDFD ED 69 06 SBC myMaxSpeed;Object_v_speed_lo,x
  6578. 0EE00 8D 7B 06 STA yHold_lo
  6579. 0EE03 BD 41 04 LDA Object_y_hi,x
  6580. 0EE06 ED 6A 06 SBC myMaxSpeed+1;Object_v_speed_hi,x
  6581. 0EE09 90 0C BCC +doTopBounds ;; helps if top bounds is zero.
  6582. 0EE0B 8D 7C 06 STA yHold_hi
  6583. 0EE0E C9 00 CMP #BOUNDS_TOP
  6584. 0EE10 F0 05 BEQ +doTopBounds
  6585. 0EE12 90 03 BCC +doTopBounds
  6586. 0EE14 4C 33 EE JMP +noVertMovement
  6587. 0EE17 +doTopBounds
  6588. 0EE17 EC 6D 06 CPX player1_object
  6589. 0EE1A F0 0B BEQ +isPlayer
  6590. 0EE1C BD 00 04 29 3F 9D 00 04 DestroyObject
  6591. 0EE24 4C 33 EE JMP skipPhysics
  6592. 0EE27 +isPlayer
  6593. 0EE27
  6594. 0EE27 AD 80 06 LDA yPrev
  6595. 0EE2A 8D 7C 06 STA yHold_hi
  6596. 0EE2D 9D 41 04 STA Object_y_hi,x
  6597. 0EE30 ; LDA #$00
  6598. 0EE30 ; STA Object_v_speed_hi,x
  6599. 0EE30 ; STA Object_v_speed_lo,x
  6600. 0EE30 ; LDA #$02
  6601. 0EE30 ; STA screenUpdateByte
  6602. 0EE30 ; JSR doHandleBounds
  6603. 0EE30 4C 33 EE JMP skipPhysics
  6604. 0EE33 +noVertMovement
  6605. 0EE33
  6606. 0EE33
  6607. 0EE33 skipPhysics:
  6608. 0EE33
  6609. 0EE33 AD 9F 06 LDA ScreenFlags00
  6610. 0EE36 29 10 AND #%00010000
  6611. 0EE38 D0 20 BNE +skipCamMovement
  6612. 0EE3A BD EA 04 LDA Object_vulnerability,x
  6613. 0EE3D 29 01 AND #%00000001 ;; set this to "static object"
  6614. 0EE3F D0 19 BNE +skipCamMovement
  6615. 0EE41 AD 78 06 LDA xHold_lo
  6616. 0EE44 18 CLC
  6617. 0EE45 69 00 ADC #$00
  6618. 0EE47 8D 78 06 STA xHold_lo
  6619. 0EE4A AD 79 06 LDA xHold_hi
  6620. 0EE4D 69 01 ADC #$01;; this becomes the "SCROLL SPEED" - it is the offset at which the player moves.
  6621. 0EE4F ;; in conjunction with camera speed update, this could make it scroll faster.
  6622. 0EE4F 8D 79 06 STA xHold_hi
  6623. 0EE52 AD 7A 06 LDA xHold_screen
  6624. 0EE55 69 00 ADC #$00
  6625. 0EE57 8D 7A 06 STA xHold_screen
  6626. 0EE5A
  6627. 0EE5A
  6628. 0EE5A +skipCamMovement0EE5A 68 PLA
  6629. 0EE5B AA TAX
  6630. 0EE5C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEMO PHYSICS
  6631. 0EE5C 98 48 AC 21 06 20 83 C5.. ReturnBank
  6632. 0EE66
  6633. 0EE66 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6634. 0EE66 ObjectDoesNotObservePhysics:
  6635. 0EE66
  6636. 0EE66 98 48 AD 20 06 8D 21 06.. SwitchBank #$18
  6637. 0EE75 20 FE 80 JSR doTileObservationLogic
  6638. 0EE78 98 48 AC 21 06 20 83 C5.. ReturnBank
  6639. 0EE82
  6640. 0EE82 BD 00 04 LDA Object_status,x
  6641. 0EE85 29 04 AND #OBJECT_OBSERVES_OBJECTS
  6642. 0EE87 D0 03 BNE ObjectDoesObserveObjects
  6643. 0EE89 4C A8 EE JMP ObjectDoesNotObserveObjects
  6644. 0EE8C ObjectDoesObserveObjects:
  6645. 0EE8C ;; Object collisions
  6646. 0EE8C 98 48 AD 20 06 8D 21 06.. SwitchBank #$1C
  6647. 0EE9B 20 36 99 JSR doObjectCollisions_bank1C
  6648. 0EE9E 98 48 AC 21 06 20 83 C5.. ReturnBank
  6649. 0EEA8
  6650. 0EEA8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6651. 0EEA8 ObjectDoesNotObserveObjects:
  6652. 0EEA8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6653. 0EEA8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6654. 0EEA8
  6655. 0EEA8
  6656. 0EEA8 98 48 AD 20 06 8D 21 06.. SwitchBank #$18
  6657. 0EEB7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6658. 0EEB7
  6659. 0EEB7 ;;;: Bounds reached
  6660. 0EEB7 ; .include SCR_BOUNDS_STATE - this would be handled inside of physics. If a potential position
  6661. 0EEB7 ; represents the "bounds", this would be triggered.
  6662. 0EEB7
  6663. 0EEB7 ;;;; Update state
  6664. 0EEB7 ;; At ths point, physics and positioning are all figured out.
  6665. 0EEB7 ;; now we update the object. This includes pushing temp positions to new positions,
  6666. 0EEB7 ;; handling timers, doing AI mode updates and whatnot, etc, and anything that should happen
  6667. 0EEB7 ;; specifically for this object in the update state.
  6668. 0EEB7 8A TXA
  6669. 0EEB8 48 PHA
  6670. 0EEB9 20 F3 84 JSR doUpdateState
  6671. 0EEBC 20 F4 84 JSR doHandleObjectUpdate
  6672. 0EEBF 68 PLA
  6673. 0EEC0 AA TAX
  6674. 0EEC1 98 48 AC 21 06 20 83 C5.. ReturnBank
  6675. 0EECB
  6676. 0EECB SkipUpdateObjectPos:
  6677. 0EECB
  6678. 0EECB ;;;; Timer
  6679. 0EECB ;.include SCR_TIMER_STATE - timer's are handled inside of update state.
  6680. 0EECB JustDrawObject:
  6681. 0EECB 98 48 AD 20 06 8D 21 06.. SwitchBank #$1C
  6682. 0EEDA 8A TXA
  6683. 0EEDB 48 PHA
  6684. 0EEDC 20 35 99 JSR doUpdateActionTimer
  6685. 0EEDF 68 PLA
  6686. 0EEE0 AA TAX
  6687. 0EEE1 ;;;;;;;;;
  6688. 0EEE1 BD 00 04 LDA Object_status,x
  6689. 0EEE4 29 02 AND #OBJECT_OBSERVES_DRAWING
  6690. 0EEE6 F0 0E BEQ ObjectDoesNotDraw
  6691. 0EEE8 ;;; Lastly, we draw the sprite.
  6692. 0EEE8 ;;; The sprite should be drawn anyway, HERE.
  6693. 0EEE8
  6694. 0EEE8 8A TXA
  6695. 0EEE9 48 PHA
  6696. 0EEEA 98 TYA
  6697. 0EEEB 48 PHA
  6698. 0EEEC 20 C1 95 JSR doDrawSprites
  6699. 0EEEF 68 PLA
  6700. 0EEF0 A8 TAY
  6701. 0EEF1 68 PLA
  6702. 0EEF2 AA TAX
  6703. 0EEF3
  6704. 0EEF3 20 34 99 JSR doUpdateSpriteTimer
  6705. 0EEF6
  6706. 0EEF6
  6707. 0EEF6 ;;; And additional object specific drawing stuff would go here.
  6708. 0EEF6
  6709. 0EEF6 .include "Routines\BASE_4_5\Game\Subroutines\doDrawState.asm"
  6710. 0EEF6 ;; do draw state
  6711. 0EEF6 ;;; the new draw state will blast these off:
  6712. 0EEF6 ;;; y (offset in pixels), tile ID, attribute, x (offset in pixels).
  6713. 0EEF6 ;;; since the y offset can never be larger than F0, even if is taking up the whole screen,
  6714. 0EEF6 ;;; that means we have F0 - FF as opcodes when the y offset is being read.
  6715. 0EEF6 ;;; FF = THIS ITEM IS FINISHED.
  6716. 0EEF6 ;;; FE = Draw this off screen (no need to keep a "blank tile" anymore).
  6717. 0EEF6
  6718. 0EEF6 ;;; the old draw state, the ObjectInfo.dat file puts things in the format
  6719. 0EEF6 ;;; tile, attribute. It bases everything on a width / height tile draw.
  6720. 0EEF6
  6721. 0EEF6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6722. 0EEF6 ObjectDoesNotDraw:
  6723. 0EEF6 98 48 AC 21 06 20 83 C5.. ReturnBank
  6724. 0EF00 doObjectIsInactive:
  6725. 0EF00 ;; cycle through objects.
  6726. 0EF00 ; CPX camObject
  6727. 0EF00 ; BEQ isCamObjectForScrollHandle
  6728. 0EF00 ; JMP notCamObjectForScrollHandle
  6729. 0EF00 ; isCamObjectForScrollHandle:
  6730. 0EF00 ; .include SCR_HANDLE_H_SCROLL
  6731. 0EF00 ; .include SCR_HANDLE_V_SCROLL
  6732. 0EF00 ; notCamObjectForScrollHandle:
  6733. 0EF00 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6734. 0EF00 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6735. 0EF00 ;; End Object Update.
  6736. 0EF00 E8 INX
  6737. 0EF01 E0 0D CPX #TOTAL_MAX_OBJECTS ;; a number that is configured
  6738. 0EF03 ;; in the Object Variables tab
  6739. 0EF03 ;; of project settings.
  6740. 0EF03
  6741. 0EF03 ;; This space makes use of ObjectRam. By default, it is one page in size (256 bytes),
  6742. 0EF03 ;; however, it could stretch into the scratch ram if desired allowing for 512 bytes for object use.
  6743. 0EF03 F0 03 BEQ DoneHandlingObjects
  6744. 0EF05 4C D5 E9 JMP loop_doHandleObjectsLoop
  6745. 0EF08
  6746. 0EF08 DoneHandlingObjects:
  6747. 0EF08 ;;;;;;;;;;;;
  6748. 0EF08
  6749. 0EF08 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6750. 0EF08 60 RTS0EF09 .include Routines\BASE_4_5\\Game\Subroutines\doHandleInputReads.asm
  6751. 0EF09 doHandleInputReads:
  6752. 0EF09
  6753. 0EF09 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6754. 0EF09 ;; DO GamePadCheck
  6755. 0EF09 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6756. 0EF09
  6757. 0EF09 GamePadCheck:
  6758. 0EF09 A9 01 LDA #$01
  6759. 0EF0B 8D 16 40 STA $4016
  6760. 0EF0E ;STA gamepad2
  6761. 0EF0E 4A LSR
  6762. 0EF0F 8D 16 40 STA $4016
  6763. 0EF12
  6764. 0EF12 A9 80 LDA #$80
  6765. 0EF14 85 27 STA gamepad
  6766. 0EF16 85 28 STA gamepad2
  6767. 0EF18 ReadControllerBytesLoop:
  6768. 0EF18 AD 16 40 LDA $4016
  6769. 0EF1B 29 03 AND #%00000011
  6770. 0EF1D C9 01 CMP #%00000001
  6771. 0EF1F 66 27 ROR gamepad
  6772. 0EF21 AD 17 40 LDA $4017
  6773. 0EF24 29 03 AND #%00000011
  6774. 0EF26 C9 01 CMP #%00000001
  6775. 0EF28 66 28 ROR gamepad2
  6776. 0EF2A 90 EC BCC ReadControllerBytesLoop
  6777. 0EF2C ;RTS
  6778. 0EF2C ; LDA gamepad
  6779. 0EF2C ; AND #%11000000
  6780. 0EF2C ; CMP #%11000000
  6781. 0EF2C ; BNE NoFilter_LR
  6782. 0EF2C
  6783. 0EF2C ; EOR gamepad
  6784. 0EF2C ; STA gamepad
  6785. 0EF2C ; NoFilter_LR:
  6786. 0EF2C ; LDA gamepad
  6787. 0EF2C ; AND #%00110000
  6788. 0EF2C ; CMP #%00110000
  6789. 0EF2C ; BNE NoFilter_UD
  6790. 0EF2C ; EOR gamepad
  6791. 0EF2C ; STA gamepad
  6792. 0EF2C ; NoFilter_UD:
  6793. 0EF2C
  6794. 0EF2C
  6795. 0EF2C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6796. 0EF2C ;;;END GamePadCheck
  6797. 0EF2C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6798. 0EF2C
  6799. 0EF2C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6800. 0EF2C ;;Read input definitions
  6801. 0EF2C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6802. 0EF2C
  6803. 0EF2C 8A TXA
  6804. 0EF2D 48 PHA
  6805. 0EF2E 98 TYA
  6806. 0EF2F 48 PHA
  6807. 0EF30 AD 20 06 LDA currentBank
  6808. 0EF33 8D 22 06 STA tempBank
  6809. 0EF36
  6810. 0EF36 A5 27 LDA gamepad
  6811. 0EF38 8D D0 06 STA gamepad_hold
  6812. 0EF3B A5 29 LDA buttonStates
  6813. 0EF3D 8D CF 06 STA buttonStates_hold
  6814. 0EF40 A9 00 LDA #$00
  6815. 0EF42 8D D1 06 STA controllerNumber_hold
  6816. 0EF45 20 7E EF JSR doCheckControllerInputStates
  6817. 0EF48
  6818. 0EF48 A5 28 LDA gamepad2
  6819. 0EF4A 8D D0 06 STA gamepad_hold
  6820. 0EF4D A5 2A LDA buttonStates2
  6821. 0EF4F 8D CF 06 STA buttonStates_hold
  6822. 0EF52 A9 01 LDA #$01
  6823. 0EF54 8D D1 06 STA controllerNumber_hold
  6824. 0EF57 20 7E EF JSR doCheckControllerInputStates
  6825. 0EF5A
  6826. 0EF5A AC 22 06 LDy tempBank
  6827. 0EF5D 20 83 C5 JSR doBankswitchY
  6828. 0EF60
  6829. 0EF60 68 PLA
  6830. 0EF61 A8 TAY
  6831. 0EF62 68 PLA
  6832. 0EF63 AA TAX
  6833. 0EF64
  6834. 0EF64 A5 27 LDA gamepad
  6835. 0EF66 85 29 STA buttonStates
  6836. 0EF68 A5 28 LDA gamepad2
  6837. 0EF6A 85 2A STA buttonStates2
  6838. 0EF6C 60 RTS
  6839. 0EF6D
  6840. 0EF6D
  6841. 0EF6D
  6842. 0EF6D findObjectOfType:
  6843. 0EF6D
  6844. 0EF6D A2 00 LDX #$00
  6845. 0EF6F doFindObjectOfTypeLoop:
  6846. 0EF6F BD 8F 04 LDA Object_type,x
  6847. 0EF72 C5 08 CMP tempB
  6848. 0EF74 F0 07 BEQ xIsNowCorrect
  6849. 0EF76 E8 INX
  6850. 0EF77 E0 0D CPX #TOTAL_MAX_OBJECTS
  6851. 0EF79 D0 F4 BNE doFindObjectOfTypeLoop
  6852. 0EF7B A2 FF LDX #$FF
  6853. 0EF7D xIsNowCorrect:
  6854. 0EF7D 60 RTS
  6855. 0EF7E
  6856. 0EF7E
  6857. 0EF7E
  6858. 0EF7E
  6859. 0EF7E
  6860. 0EF7E
  6861. 0EF7E
  6862. 0EF7E
  6863. 0EF7E
  6864. 0EF7E
  6865. 0EF7E
  6866. 0EF7E
  6867. 0EF7E
  6868. 0EF7E
  6869. 0EF7E
  6870. 0EF7E doCheckControllerInputStates:
  6871. 0EF7E
  6872. 0EF7E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6873. 0EF7E ;;;; HANDLE HELD INPUTS ;;;;;;;;;;;;;;;;;;;;;;;;;;
  6874. 0EF7E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6875. 0EF7E
  6876. 0EF7E A9 08 LDA #HELD_INPUTS
  6877. 0EF80 D0 03 BNE doHeldInputs
  6878. 0EF82 4C FB EF JMP doneWithInputLoops_Held
  6879. 0EF85 doHeldInputs:
  6880. 0EF85 A9 00 LDA #$00
  6881. 0EF87 85 0B STA loopTemp
  6882. 0EF89 GetDefinedInputsLoop_Held:
  6883. 0EF89 A6 0B LDX loopTemp ;; set x temporarily to loopTemp variable for table reads
  6884. 0EF8B ;; we need to check to see if this input uses current game state
  6885. 0EF8B ;; if not, skip it.
  6886. 0EF8B BD 25 C5 LDA DefinedScriptGameStates_Held,x
  6887. 0EF8E C5 2B CMP gameState
  6888. 0EF90 F0 03 BEQ inputCheckGameStateIsCorrect_Held
  6889. 0EF92 4C F0 EF JMP skipThisInput_Held
  6890. 0EF95 inputCheckGameStateIsCorrect_Held:
  6891. 0EF95 BD 35 C5 LDA DefinedTargetController_Held,x
  6892. 0EF98 CD D1 06 CMP controllerNumber_hold
  6893. 0EF9B F0 03 BEQ inputCheckControllerIsCorrect_held
  6894. 0EF9D 4C F0 EF JMP skipThisInput_Held
  6895. 0EFA0 inputCheckControllerIsCorrect_held
  6896. 0EFA0
  6897. 0EFA0 ;;;; now check gamepad variable against the
  6898. 0EFA0 ;;; DefinedInputs table to see if the current
  6899. 0EFA0 ;;; gamepad state matches any of the chosen inputs.
  6900. 0EFA0 AD CF 06 LDA buttonStates_hold
  6901. 0EFA3 3D 1D C5 AND DefinedInputs_Held,x ;; this AND checks button states and
  6902. 0EFA6 ;; logically only checks about those
  6903. 0EFA6 ;; states being asked about. If we remove this,
  6904. 0EFA6 ;; the buttons have to be in the exact input state
  6905. 0EFA6 ;; as DefinedInputs_Pressed. With it in,
  6906. 0EFA6 ;; left will still do left things even if b-button
  6907. 0EFA6 ;; is pressed, for example.
  6908. 0EFA6 DD 1D C5 CMP DefinedInputs_Held,x
  6909. 0EFA9 D0 45 BNE skipThisInput_Held
  6910. 0EFAB
  6911. 0EFAB A4 0B LDY loopTemp ;;; THIS NEEDS TO EQUAL THE INDEX OF THE SCRIPT BEING CALLED
  6912. 0EFAD ;;; from the ScriptAddress table.
  6913. 0EFAD B9 2D C5 LDA DefinedTargetObjects_Held,y ;; this is the type of object we're looking for.
  6914. 0EFB0 85 08 STA tempB
  6915. 0EFB2 20 6D EF JSR findObjectOfType
  6916. 0EFB5 E0 FF CPX #$FF
  6917. 0EFB7 F0 37 BEQ skipThisInput_Held
  6918. 0EFB9
  6919. 0EFB9 ;LDX DefinedTargetObjects_Held,y
  6920. 0EFB9 B9 C5 C4 LDA TargetScriptBank,y
  6921. 0EFBC 85 00 STA temp
  6922. 0EFBE ;LDA currentBank
  6923. 0EFBE ;STA prevBank
  6924. 0EFBE
  6925. 0EFBE 98 48 AD 20 06 8D 21 06.. SwitchBank temp
  6926. 0EFCD
  6927. 0EFCD A4 0B LDY loopTemp ;;; THIS NEEDS TO EQUAL THE INDEX OF THE SCRIPT BEING CALLED
  6928. 0EFCF ;;; from the ScriptAddress table.
  6929. 0EFCF
  6930. 0EFCF B9 45 C5 LDA DefinedTargetScripts_Held,y
  6931. 0EFD2 A8 TAY
  6932. 0EFD3 B9 B1 C4 LDA ScriptAddressLo,y
  6933. 0EFD6 85 14 STA temp16
  6934. 0EFD8 B9 BB C4 LDA ScriptAddressHi,y
  6935. 0EFDB 85 15 STA temp16+1
  6936. 0EFDD 20 E3 EF JSR UseInputTrampoline_Held
  6937. 0EFE0 4C E6 EF JMP passedInputTrampoline_Held
  6938. 0EFE3 UseInputTrampoline_Held:
  6939. 0EFE3 ;;; ADVANCED CONCEPT:
  6940. 0EFE3 ;;;; since there is no such thing as an indirect JSR
  6941. 0EFE3 ;;; we have to use an indirect jump. However, we want this
  6942. 0EFE3 ;;; to behave as a JSR and jump back to this point in code
  6943. 0EFE3 ;;; at the end of the eventual routine.
  6944. 0EFE3 ;;; So we use this trampoline method, where
  6945. 0EFE3 ;;; Our JSR above sets the *return* point to that point in code.
  6946. 0EFE3 ;;; Then, at the end of the routine we jump to, when it hits an RTS,
  6947. 0EFE3 ;;; that return will return to the JSR above, which will immediately
  6948. 0EFE3 ;;; jump to the passedInputTrampoline below.
  6949. 0EFE3 6C 14 00 JMP (temp16)
  6950. 0EFE6
  6951. 0EFE6 passedInputTrampoline_Held:
  6952. 0EFE6
  6953. 0EFE6 98 48 AC 21 06 20 83 C5.. ReturnBank
  6954. 0EFF0 ;;;===========================
  6955. 0EFF0
  6956. 0EFF0
  6957. 0EFF0 skipThisInput_Held:
  6958. 0EFF0 E6 0B INC loopTemp
  6959. 0EFF2 A5 0B LDA loopTemp
  6960. 0EFF4 C9 08 CMP #HELD_INPUTS ;;; the total number of scripts to jump through
  6961. 0EFF6 B0 03 BCs doneWithInputLoops_Held
  6962. 0EFF8 4C 89 EF JMP GetDefinedInputsLoop_Held
  6963. 0EFFB doneWithInputLoops_Held:
  6964. 0EFFB
  6965. 0EFFB
  6966. 0EFFB ;;;;;;;;;;;;;;;END HELD
  6967. 0EFFB
  6968. 0EFFB
  6969. 0EFFB
  6970. 0EFFB
  6971. 0EFFB ;;;;;;;;;;;;;;;;;;;;PRESSED
  6972. 0EFFB ;JMP AllButtonStatesChecked
  6973. 0EFFB
  6974. 0EFFB A9 05 LDA #PRESSED_INPUTS
  6975. 0EFFD D0 03 BNE doPressedInputs
  6976. 0EFFF 4C 7D F0 JMP doneWithInputLoops_Pressed
  6977. 0F002 doPressedInputs:
  6978. 0F002
  6979. 0F002 A9 00 LDA #$00
  6980. 0F004 85 0B STA loopTemp
  6981. 0F006 GetDefinedPressedInputsLoop:
  6982. 0F006
  6983. 0F006 A6 0B LDX loopTemp ;; set x temporarily to loopTemp variable for table reads
  6984. 0F008 ;; we need to check to see if this input uses current game state
  6985. 0F008 ;; if not, skip it.
  6986. 0F008 BD D4 C4 LDA DefinedScriptGameStates_Pressed,x
  6987. 0F00B C5 2B CMP gameState
  6988. 0F00D F0 03 BEQ inputCheckGameStateIsCorrect_Pressed
  6989. 0F00F 4C 72 F0 JMP skipThisInput_Pressed
  6990. 0F012 inputCheckGameStateIsCorrect_Pressed:
  6991. 0F012 BD DE C4 LDA DefinedTargetController_Pressed,x
  6992. 0F015 CD D1 06 CMP controllerNumber_hold
  6993. 0F018 F0 03 BEQ inputCheckControllerIsCorrect_Pressed
  6994. 0F01A 4C 72 F0 JMP skipThisInput_Pressed
  6995. 0F01D inputCheckControllerIsCorrect_Pressed
  6996. 0F01D AD CF 06 LDA buttonStates_hold
  6997. 0F020 3D CF C4 AND DefinedInputs_Pressed,x
  6998. 0F023 D0 4D BNE skipThisInput_Pressed
  6999. 0F025
  7000. 0F025 AD D0 06 LDA gamepad_hold
  7001. 0F028 3D CF C4 AND DefinedInputs_Pressed,x
  7002. 0F02B F0 45 BEQ skipThisInput_Pressed
  7003. 0F02D
  7004. 0F02D
  7005. 0F02D
  7006. 0F02D
  7007. 0F02D DoInputActionTrampoline:
  7008. 0F02D
  7009. 0F02D ;LDX tempx
  7010. 0F02D ;;;===========================
  7011. 0F02D ;;;; TRAMPOLINE
  7012. 0F02D
  7013. 0F02D A4 0B LDY loopTemp ;;; THIS NEEDS TO EQUAL THE INDEX OF THE SCRIPT BEING CALLED
  7014. 0F02F ;;; from the ScriptAddress table
  7015. 0F02F B9 D9 C4 LDA DefinedTargetObjects_Pressed,y ;; this is the type of object we're looking for.
  7016. 0F032 85 08 STA tempB
  7017. 0F034 20 6D EF JSR findObjectOfType
  7018. 0F037 E0 FF CPX #$FF
  7019. 0F039 F0 37 BEQ skipThisInput_Pressed
  7020. 0F03B ;LDX DefinedTargetObjects_Pressed,y
  7021. 0F03B B9 C5 C4 LDA TargetScriptBank,y
  7022. 0F03E 85 00 STA temp
  7023. 0F040 98 48 AD 20 06 8D 21 06.. SwitchBank temp
  7024. 0F04F
  7025. 0F04F A4 0B LDY loopTemp ;;; THIS NEEDS TO EQUAL THE INDEX OF THE SCRIPT BEING CALLED
  7026. 0F051 ;;; from the ScriptAddress table.
  7027. 0F051 B9 E8 C4 LDA DefinedTargetScripts_Pressed,y
  7028. 0F054 A8 TAY
  7029. 0F055 B9 B1 C4 LDA ScriptAddressLo,y
  7030. 0F058 85 14 STA temp16
  7031. 0F05A B9 BB C4 LDA ScriptAddressHi,y
  7032. 0F05D 85 15 STA temp16+1
  7033. 0F05F
  7034. 0F05F 20 65 F0 JSR UseInputTrampoline
  7035. 0F062 4C 68 F0 JMP passedInputTrampoline
  7036. 0F065 UseInputTrampoline:
  7037. 0F065 ;;; ADVANCED CONCEPT:
  7038. 0F065 ;;;; since there is no such thing as an indirect JSR
  7039. 0F065 ;;; we have to use an indirect jump. However, we want this
  7040. 0F065 ;;; to behave as a JSR and jump back to this point in code
  7041. 0F065 ;;; at the end of the eventual routine.
  7042. 0F065 ;;; So we use this trampoline method, where
  7043. 0F065 ;;; Our JSR above sets the *return* point to that point in code.
  7044. 0F065 ;;; Then, at the end of the routine we jump to, when it hits an RTS,
  7045. 0F065 ;;; that return will return to the JSR above, which will immediately
  7046. 0F065 ;;; jump to the passedInputTrampoline below.
  7047. 0F065 6C 14 00 JMP (temp16)
  7048. 0F068
  7049. 0F068 passedInputTrampoline:
  7050. 0F068
  7051. 0F068 98 48 AC 21 06 20 83 C5.. ReturnBank
  7052. 0F072 ;;;===========================
  7053. 0F072
  7054. 0F072
  7055. 0F072 skipThisInput_Pressed:
  7056. 0F072 E6 0B INC loopTemp
  7057. 0F074 A5 0B LDA loopTemp
  7058. 0F076 C9 05 CMP #PRESSED_INPUTS ;;; the total number of scripts to jump through
  7059. 0F078 B0 03 BCs doneWithInputLoops_Pressed
  7060. 0F07A 4C 06 F0 JMP GetDefinedPressedInputsLoop
  7061. 0F07D doneWithInputLoops_Pressed:
  7062. 0F07D
  7063. 0F07D
  7064. 0F07D ;;===============RELEASED
  7065. 0F07D A9 08 LDA #RELEASED_INPUTS
  7066. 0F07F D0 03 BNE doReleasedInputs
  7067. 0F081 4C FF F0 JMP doneWithInputLoops_Released
  7068. 0F084 doReleasedInputs:
  7069. 0F084 A9 00 LDA #$00
  7070. 0F086 85 0B STA loopTemp
  7071. 0F088 GetDefinedInputsReleasedLoop:
  7072. 0F088 A6 0B LDX loopTemp ;; set x temporarily to loopTemp variable for table reads
  7073. 0F08A ;; we need to check to see if this input uses current game state
  7074. 0F08A ;; if not, skip it.
  7075. 0F08A BD F5 C4 LDA DefinedScriptGameStates_Released,x
  7076. 0F08D C5 2B CMP gameState
  7077. 0F08F F0 03 BEQ inputCheckGameStateIsCorrect_Released
  7078. 0F091 4C F4 F0 JMP skipThisInput_Released
  7079. 0F094 inputCheckGameStateIsCorrect_Released:
  7080. 0F094 BD 05 C5 LDA DefinedTargetController_Released,x
  7081. 0F097 CD D1 06 CMP controllerNumber_hold
  7082. 0F09A F0 03 BEQ inputCheckControllerIsCorrect_released
  7083. 0F09C 4C F4 F0 JMP skipThisInput_Released
  7084. 0F09F inputCheckControllerIsCorrect_released
  7085. 0F09F
  7086. 0F09F ;;;; now check gamepad variable against the
  7087. 0F09F ;;; DefinedInputs table to see if the current
  7088. 0F09F ;;; gamepad state matches any of the chosen inputs.
  7089. 0F09F
  7090. 0F09F
  7091. 0F09F AD CF 06 LDA buttonStates_hold
  7092. 0F0A2 3D ED C4 AND DefinedInputs_Released,x
  7093. 0F0A5 F0 4D BEQ skipThisInput_Released
  7094. 0F0A7
  7095. 0F0A7 AD D0 06 LDA gamepad_hold
  7096. 0F0AA 3D ED C4 AND DefinedInputs_Released,x
  7097. 0F0AD D0 45 BNE skipThisInput_Released
  7098. 0F0AF
  7099. 0F0AF
  7100. 0F0AF
  7101. 0F0AF DoInputActionTrampoline_Released:
  7102. 0F0AF ;JMP AllButtonStatesChecked
  7103. 0F0AF ;LDX tempx
  7104. 0F0AF ;;;===========================
  7105. 0F0AF ;;;; TRAMPOLINE
  7106. 0F0AF
  7107. 0F0AF A4 0B LDY loopTemp ;;; THIS NEEDS TO EQUAL THE INDEX OF THE SCRIPT BEING CALLED
  7108. 0F0B1 ;;; from the ScriptAddress table.
  7109. 0F0B1 B9 FD C4 LDA DefinedTargetObjects_Released,y ;; this is the type of object we're looking for.
  7110. 0F0B4 85 08 STA tempB
  7111. 0F0B6 20 6D EF JSR findObjectOfType
  7112. 0F0B9 E0 FF CPX #$FF
  7113. 0F0BB F0 37 BEQ skipThisInput_Released
  7114. 0F0BD ;LDX DefinedTargetObjects_Released,y
  7115. 0F0BD ;LDA DefinedTargetScripts_Released,y
  7116. 0F0BD ;TAY
  7117. 0F0BD B9 C5 C4 LDA TargetScriptBank,y
  7118. 0F0C0 85 00 STA temp
  7119. 0F0C2 98 48 AD 20 06 8D 21 06.. SwitchBank temp
  7120. 0F0D1
  7121. 0F0D1 A4 0B LDY loopTemp ;;; THIS NEEDS TO EQUAL THE INDEX OF THE SCRIPT BEING CALLED
  7122. 0F0D3 ;;; from the ScriptAddress table.
  7123. 0F0D3 B9 15 C5 LDA DefinedTargetScripts_Released,y
  7124. 0F0D6 A8 TAY
  7125. 0F0D7 B9 B1 C4 LDA ScriptAddressLo,y
  7126. 0F0DA 85 14 STA temp16
  7127. 0F0DC B9 BB C4 LDA ScriptAddressHi,y
  7128. 0F0DF 85 15 STA temp16+1
  7129. 0F0E1 20 E7 F0 JSR UseInputReleasedTrampoline
  7130. 0F0E4 4C EA F0 JMP passedInputReleasedTrampoline
  7131. 0F0E7 UseInputReleasedTrampoline:
  7132. 0F0E7 ;;; ADVANCED CONCEPT:
  7133. 0F0E7 ;;;; since there is no such thing as an indirect JSR
  7134. 0F0E7 ;;; we have to use an indirect jump. However, we want this
  7135. 0F0E7 ;;; to behave as a JSR and jump back to this point in code
  7136. 0F0E7 ;;; at the end of the eventual routine.
  7137. 0F0E7 ;;; So we use this trampoline method, where
  7138. 0F0E7 ;;; Our JSR above sets the *return* point to that point in code.
  7139. 0F0E7 ;;; Then, at the end of the routine we jump to, when it hits an RTS,
  7140. 0F0E7 ;;; that return will return to the JSR above, which will immediately
  7141. 0F0E7 ;;; jump to the passedInputTrampoline below.
  7142. 0F0E7 6C 14 00 JMP (temp16)
  7143. 0F0EA
  7144. 0F0EA passedInputReleasedTrampoline:
  7145. 0F0EA
  7146. 0F0EA 98 48 AC 21 06 20 83 C5.. ReturnBank
  7147. 0F0F4 ;;;===========================
  7148. 0F0F4
  7149. 0F0F4
  7150. 0F0F4 skipThisInput_Released:
  7151. 0F0F4 E6 0B INC loopTemp
  7152. 0F0F6 A5 0B LDA loopTemp
  7153. 0F0F8 C9 08 CMP #RELEASED_INPUTS ;;; the total number of scripts to jump through
  7154. 0F0FA B0 03 BCs doneWithInputLoops_Released
  7155. 0F0FC 4C 88 F0 JMP GetDefinedInputsReleasedLoop
  7156. 0F0FF doneWithInputLoops_Released:
  7157. 0F0FF
  7158. 0F0FF
  7159. 0F0FF ;=======================
  7160. 0F0FF
  7161. 0F0FF AllButtonStatesChecked:
  7162. 0F0FF
  7163. 0F0FF ; LDY #$14
  7164. 0F0FF ; JSR bankswitchY
  7165. 0F0FF ; JSR ExtraInputControl
  7166. 0F0FF
  7167. 0F0FF
  7168. 0F0FF 60 RTS0F100 .include Routines\BASE_4_5\\Game\Subroutines\doCreateObject.asm
  7169. 0F100 doCreateObject:
  7170. 0F100
  7171. 0F100 A9 7E LDA #%01111110
  7172. 0F102 9D 00 04 STA Object_status,x
  7173. 0F105
  7174. 0F105 A5 0C LDA arg0_hold
  7175. 0F107 9D 1A 04 STA Object_x_hi,x
  7176. 0F10A A5 0D LDA arg1_hold
  7177. 0F10C 9D 41 04 STA Object_y_hi,x
  7178. 0F10F A5 0E LDA arg2_hold
  7179. 0F111 9D 8F 04 STA Object_type,x
  7180. 0F114
  7181. 0F114 A5 0F LDA arg3_hold ;; this is the behavior step that is to be called.
  7182. 0F116 0A ASL
  7183. 0F117 0A ASL
  7184. 0F118 0A ASL
  7185. 0F119 85 00 STA temp
  7186. 0F11B BD 9C 04 LDA Object_frame,x
  7187. 0F11E 29 C0 AND #%11000000
  7188. 0F120 05 00 ORA temp
  7189. 0F122 9D 9C 04 STA Object_frame,x ;; now we have the 4th argument telling the object
  7190. 0F125 ;; which action frame he should begin with.
  7191. 0F125
  7192. 0F125
  7193. 0F125 A9 00 LDA #$00
  7194. 0F127 9D A9 04 STA Object_direction,x
  7195. 0F12A 9D 4E 04 STA Object_h_speed_lo,x
  7196. 0F12D 9D 5B 04 STA Object_h_speed_hi,x
  7197. 0F130 9D 68 04 STA Object_v_speed_lo,x
  7198. 0F133 9D 75 04 STA Object_v_speed_hi,x
  7199. 0F136
  7200. 0F136 60 RTS0F137 .include Routines\BASE_4_5\\Game\Subroutines\locationFinders.asm
  7201. 0F137 coordinatesToMetaNametableValue:
  7202. 0F137 ;;; Let's use this as essentially a tile space to nametable translation.
  7203. 0F137 ;; tileX is a value 0-15, tileY is a value 0-15
  7204. 0F137 A5 32 LDA tileY
  7205. 0F139 0A ASL
  7206. 0F13A 0A ASL
  7207. 0F13B 0A ASL
  7208. 0F13C 0A ASL
  7209. 0F13D 0A ASL
  7210. 0F13E 0A ASL
  7211. 0F13F 85 00 STA temp
  7212. 0F141 A5 31 LDA tileX
  7213. 0F143 0A ASL
  7214. 0F144 ;STA updateNT_tableLeft
  7215. 0F144 29 1E AND #%00011110
  7216. 0F146 18 CLC
  7217. 0F147 65 00 ADC temp
  7218. 0F149 85 14 STA temp16
  7219. 0F14B A5 32 LDA tileY
  7220. 0F14D 4A LSR
  7221. 0F14E 4A LSR
  7222. 0F14F 18 CLC
  7223. 0F150 6D BE 06 ADC camFocus_tiles
  7224. 0F153 85 15 STA temp16+1
  7225. 0F155 60 RTS
  7226. 0F156
  7227. 0F156
  7228. 0F156
  7229. 0F156
  7230. 0F156
  7231. 0F156 coordinatesToNametableValue:
  7232. 0F156 ;;; Let's use this as essentially a tile space to nametable translation on 8x8 grid.
  7233. 0F156 ;; tileX is a value 0-32, tileY is a value 0-30
  7234. 0F156 A5 32 LDA tileY
  7235. 0F158 4A LSR
  7236. 0F159 4A LSR
  7237. 0F15A 4A LSR
  7238. 0F15B 85 01 STA temp1
  7239. 0F15D
  7240. 0F15D A5 32 LDA tileY
  7241. 0F15F 0A ASL
  7242. 0F160 0A ASL
  7243. 0F161 0A ASL
  7244. 0F162 0A ASL
  7245. 0F163 0A ASL ;; now this represents 1 row for each value in tileY
  7246. 0F164 85 00 STA temp
  7247. 0F166 A5 31 LDA tileX
  7248. 0F168 18 clc
  7249. 0F169 65 00 ADC temp
  7250. 0F16B 85 14 STA temp16
  7251. 0F16D AD BE 06 LDA camFocus_tiles
  7252. 0F170 18 CLC
  7253. 0F171 65 01 ADC temp1
  7254. 0F173 85 15 STA temp16+1
  7255. 0F175 60 RTS
  7256. 0F176
  7257. 0F176
  7258. 0F176 A5 32 LDA tileY
  7259. 0F178 0A ASL
  7260. 0F179 0A ASL
  7261. 0F17A 0A ASL
  7262. 0F17B 0A ASL
  7263. 0F17C 0A ASL
  7264. 0F17D 0A ASL
  7265. 0F17E 0A ASL
  7266. 0F17F 85 00 STA temp
  7267. 0F181 A5 31 LDA tileX
  7268. 0F183 0A ASL
  7269. 0F184 0A ASL
  7270. 0F185 ;STA updateNT_tableLeft
  7271. 0F185 29 1F AND #%00011111
  7272. 0F187 18 CLC
  7273. 0F188 65 00 ADC temp
  7274. 0F18A 85 14 STA temp16
  7275. 0F18C A5 32 LDA tileY
  7276. 0F18E 4A LSR
  7277. 0F18F 4A LSR
  7278. 0F190 4A LSR
  7279. 0F191 18 CLC
  7280. 0F192 6D BE 06 ADC camFocus_tiles
  7281. 0F195 85 15 STA temp16+1
  7282. 0F197 60 RTS
  7283. 0F198
  7284. 0F198
  7285. 0F198
  7286. 0F198
  7287. 0F198
  7288. 0F198
  7289. 0F198 GetTileAtPosition:
  7290. 0F198 A5 32 LDA tileY
  7291. 0F19A 29 F0 AND #%11110000
  7292. 0F19C 85 06 STA tempz
  7293. 0F19E A5 31 LDA tileX
  7294. 0F1A0 4A LSR A
  7295. 0F1A1 4A LSR A
  7296. 0F1A2 4A LSR A
  7297. 0F1A3 4A LSR A
  7298. 0F1A4 05 06 ORA tempz
  7299. 0F1A6 A8 TAY ; stores it into Y, which will be important in checking collision.
  7300. 0F1A7 60 RTS
  7301. 0F1A8
  7302. 0F1A8
  7303. 0F1A8 GetAttributePosition:
  7304. 0F1A8 A5 32 LDA tileY
  7305. 0F1AA 4A LSR
  7306. 0F1AB
  7307. 0F1AB 0A asl
  7308. 0F1AC 0A asl
  7309. 0F1AD 0A asl ;; each y = one full row of offset...8 values.
  7310. 0F1AE 85 06 STA tempz
  7311. 0F1B0 A5 31 LDA tileX
  7312. 0F1B2 4A LSR
  7313. 0F1B3 18 clc
  7314. 0F1B4 65 06 adc tempz
  7315. 0F1B6 18 CLC
  7316. 0F1B7 69 C0 ADC #$c0 ;; because attributes start at 23"co"
  7317. 0F1B9 ;
  7318. 0F1B9 60 RTS
  7319. 0F1BA
  7320. 0F1BA
  7321. 0F1BA
  7322. 0F1BA
  7323. 0F1BA FindFreeObjectSlot:
  7324. 0F1BA A2 00 LDX #$00
  7325. 0F1BC doFindSlotLoop:
  7326. 0F1BC BD 00 04 LDA Object_status,x
  7327. 0F1BF 29 C1 AND #%11000001
  7328. 0F1C1 F0 07 BEQ thisObjectSlotIsFree
  7329. 0F1C3 E8 INX
  7330. 0F1C4 E0 0D CPX #TOTAL_MAX_OBJECTS
  7331. 0F1C6 D0 F4 BNE doFindSlotLoop
  7332. 0F1C8 A2 FF LDX #$FF
  7333. 0F1CA thisObjectSlotIsFree:
  7334. 0F1CA 60 RTS
  7335. 0F1CB
  7336. 0F1CB
  7337. 0F1CB MonsterBankValues:
  7338. 0F1CB ;; by default, there are two.
  7339. 0F1CB 13 14 .db #$13, #$14
  7340. 0F1CD
  7341. 0F1CD StringDataChoice:
  7342. 0F1CD 9A 9B 9C 9D .db #154, #155, #156, #157 ;; day, night, day trig, night trig
  7343. 0F1D1
  7344. 0F1D1 Mon1SpawnLocation:
  7345. 0F1D1 83 86 89 8C .db #131, #134, #137, #140
  7346. 0F1D5 Mon2SpawnLocation:
  7347. 0F1D5 84 87 8A 8D .db #132, #135, #138, #141
  7348. 0F1D9 Mon3SpawnLocation:
  7349. 0F1D9 85 88 8B 8E .db #133, #136, #139, #142
  7350. 0F1DD Mon4SpawnLocation:
  7351. 0F1DD 9E 9F A0 A1 .db #158, #159, #160, #161
  7352. 0F1E1 MonGroupChoice:
  7353. 0F1E1 8F 90 91 79 .db #143, #144, #145, #121 ;; day, night, dayT, nightT
  7354. 0F1E5 MonPal1Choice:
  7355. 0F1E5 92 93 94 7B .db #146, #147, #148, #123 ;; day, night, dayT, nightT
  7356. 0F1E9 MonPal2Choice:
  7357. 0F1E9 95 96 97 81 .db #149, #150, #151, #129
  7358. 0F1ED
  7359. 0F1ED GoPal1Choice:
  7360. 0F1ED CB CC CD CE .db #203, #204, #205, #206
  7361. 0F1F1 GoPal2Choice:
  7362. 0F1F1 B7 B8 B9 BA .db #183, #184, #185, #186
  7363. 0F1F5
  7364. 0F1F5
  7365. 0F1F5 Monster1ID:
  7366. 0F1F5 A2 AA A6 AE .db #162, #170, #166, #174
  7367. 0F1F9 Monster2ID:
  7368. 0F1F9 A3 AB A7 AF .db #163, #171, #167, #175
  7369. 0F1FD Monster3ID:
  7370. 0F1FD A4 AC A8 B0 .db #164, #172, #168, #176
  7371. 0F201 Monster4ID:
  7372. 0F201 A5 AD A9 B1 .db #165, #173, #169, #177
  7373. 0F205
  7374. 0F205 MonsterPlacementType:
  7375. 0F205 B7 B8 B9 BA .db #183,#184, #185, 186
  7376. 0F209
  7377. 0F209
  7378. 0F209
  7379. 0F209
  7380. 0F209
  7381. 0F209 getPointColTable:
  7382. 0F209 90 15 BCC +stayInSameColTable
  7383. 0F20B ;; check opposite col table
  7384. 0F20B BD 27 04 LDA Object_screen,x
  7385. 0F20E 29 01 AND #%00000001
  7386. 0F210 D0 07 BNE +stayInLeftTable
  7387. 0F212 A9 01 LDA #$01
  7388. 0F214 85 07 sTA tempA
  7389. 0F216 4C 35 F2 JMP +gotColTable
  7390. 0F219 +stayInLeftTable
  7391. 0F219 A9 00 LDA #$00
  7392. 0F21B 85 07 STA tempA
  7393. 0F21D 4C 35 F2 JMP +gotColTable
  7394. 0F220 +stayInSameColTable:
  7395. 0F220 BD 27 04 LDA Object_screen,x
  7396. 0F223 29 01 AND #%00000001
  7397. 0F225 F0 07 BEQ +stayInLeftTable
  7398. 0F227 A9 01 LDA #$01
  7399. 0F229 85 07 sTA tempA
  7400. 0F22B 4C 35 F2 JMP +gotColTable
  7401. 0F22E +stayInLeftTable
  7402. 0F22E A9 00 LDA #$00
  7403. 0F230 85 07 STA tempA
  7404. 0F232 4C 35 F2 JMP +gotColTable
  7405. 0F235 +gotColTable
  7406. 0F235 60 RTS
  7407. 0F236
  7408. 0F236
  7409. 0F236
  7410. 0F236
  7411. 0F236
  7412. 0F236
  7413. 0F236
  7414. 0F236 LoadMonster_1:
  7415. 0F236 BC D1 F1 LDY Mon1SpawnLocation,x
  7416. 0F239 B1 3F LDA (collisionPointer),y
  7417. 0F23B 85 00 STA temp
  7418. 0F23D 29 F0 AND #%11110000
  7419. 0F23F C9 F0 CMP #%11110000
  7420. 0F241 D0 08 BNE loadMon1toPosition
  7421. 0F243 A5 00 LDA temp
  7422. 0F245 29 0F AND #%00001111
  7423. 0F247 C9 03 CMP #%00000011
  7424. 0F249 F0 4D BEQ skipLoadingMonster1
  7425. 0F24B ;;; Random / Edge cases here
  7426. 0F24B
  7427. 0F24B loadMon1toPosition:
  7428. 0F24B ;;;;;;; Load monster 1.
  7429. 0F24B BC F5 F1 LDY Monster1ID,x
  7430. 0F24E B1 3F LDA (collisionPointer),y
  7431. 0F250 8D D6 06 STA mon1_type
  7432. 0F253 BC D1 F1 LDY Mon1SpawnLocation,x
  7433. 0F256 B1 3F LDA (collisionPointer),y
  7434. 0F258 0A ASL
  7435. 0F259 0A ASL
  7436. 0F25A 0A ASL
  7437. 0F25B 0A ASL
  7438. 0F25C 85 08 STA tempB ;; x value in tempB
  7439. 0F25E BC D1 F1 LDY Mon1SpawnLocation,x
  7440. 0F261 B1 3F LDA (collisionPointer),y
  7441. 0F263 29 F0 AND #%11110000
  7442. 0F265 85 09 STA tempC ;; y value in tempC
  7443. 0F267 8A TXA
  7444. 0F268 48 PHA
  7445. 0F269 20 BA F1 E0 FF D0 03 4C.. CreateObject tempB, tempC, mon1_type, #$00
  7446. 0F291 A9 00 LDA #$00
  7447. 0F293 9D 82 04 STA Object_id,x
  7448. 0F296 68 PLA
  7449. 0F297 AA TAX
  7450. 0F298 skipLoadingMonster1:
  7451. 0F298 60 RTS0F299 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  7452. 0F299 ;blank0F299 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  7453. 0F299 ;blank0F299
  7454. 0F299
  7455. 0F299 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7456. 0F299 ;; object subroutines
  7457. 0F299 .include "Routines\BASE_4_5\System\ObjectBehaviors\oUpdatePosition.asm"
  7458. 0F299 oUpdatePosition:
  7459. 0F299
  7460. 0F299 A6 0C LDX arg0_hold
  7461. 0F29B A5 0D LDA arg1_hold
  7462. 0F29D 9D 1A 04 STA Object_x_hi,x
  7463. 0F2A0 A5 0E LDA arg2_hold
  7464. 0F2A2 9D 41 04 STA Object_y_hi,x
  7465. 0F2A5 60 RTS
  7466. 0F2A6
  7467. 0F2A6 .include "Routines\BASE_4_5\System\ObjectBehaviors\oStartMovingInADirection.asm"
  7468. 0F2A6 oStartMovingInADirection:
  7469. 0F2A6 A5 0C LDA arg0_hold
  7470. 0F2A8 AA TAX
  7471. 0F2A9
  7472. 0F2A9 ;;;;;;;;;;;;;;;;;;;;;;
  7473. 0F2A9 BD A9 04 LDA Object_direction,x
  7474. 0F2AC 29 0F AND #%00001111 ; these bits need to be preserved
  7475. 0F2AE 85 01 STA temp1
  7476. 0F2B0
  7477. 0F2B0 A5 0D LDA arg1_hold
  7478. 0F2B2 29 80 AND #%10000000
  7479. 0F2B4 F0 05 BEQ notChangingDirectionH
  7480. 0F2B6 ;; is changing direction H
  7481. 0F2B6 A9 1F LDA #%00011111
  7482. 0F2B8 4C BD F2 JMP gotChangDirectionBlankout
  7483. 0F2BB notChangingDirectionH:
  7484. 0F2BB ;; is changing direction V
  7485. 0F2BB A9 4F LDA #%01001111
  7486. 0F2BD gotChangDirectionBlankout:
  7487. 0F2BD 85 00 STA temp ;; temp now blanks out the direction that the object is moving, either h or v
  7488. 0F2BF ;; and turns off acceleration in the opposite, while preserving the "direction"
  7489. 0F2BF ;; of inertia, so that it may still deccelerate in that direction.
  7490. 0F2BF ;; This is important for anything that isn't an abrupt direction change, but rather
  7491. 0F2BF ;; has acceleration / decceleration
  7492. 0F2BF
  7493. 0F2BF BD A9 04 LDA Object_direction,x
  7494. 0F2C2 25 00 AND temp
  7495. 0F2C4 05 0D ORA arg1_hold
  7496. 0F2C6 05 01 ORA temp1
  7497. 0F2C8 9D A9 04 STA Object_direction,x
  7498. 0F2CB
  7499. 0F2CB
  7500. 0F2CB
  7501. 0F2CB
  7502. 0F2CB ;;; right now, speed argument is unused,
  7503. 0F2CB ;;; as in default physics, max speed is maintained
  7504. 0F2CB ;;; in LUTs, and acceleration to that value
  7505. 0F2CB ;;; determines the speed.
  7506. 0F2CB 60 RTS
  7507. 0F2CC
  7508. 0F2CC
  7509. 0F2CC
  7510. 0F2CC
  7511. 0F2CC
  7512. 0F2CC .include "Routines\BASE_4_5\System\ObjectBehaviors\oStopMoving.asm"
  7513. 0F2CC oStopMoving:
  7514. 0F2CC A6 0C LDX arg0_hold
  7515. 0F2CE A5 0D LDA arg1_hold
  7516. 0F2D0 C9 FF CMP #$FF ;; we;; use ff to stop in both horizontal and vertical directions.
  7517. 0F2D2 D0 10 BNE notStopAllInertia
  7518. 0F2D4 A5 27 LDA gamepad
  7519. 0F2D6 29 C0 AND #%11000000
  7520. 0F2D8 F0 01 BEQ stopAllInertia
  7521. 0F2DA 60 RTS
  7522. 0F2DB stopAllInertia:
  7523. 0F2DB BD A9 04 LDA Object_direction,x
  7524. 0F2DE 29 5F AND #%01011111
  7525. 0F2E0 9D A9 04 STA Object_direction,x
  7526. 0F2E3 60 RTS
  7527. 0F2E4 notStopAllInertia
  7528. 0F2E4 85 00 STA temp
  7529. 0F2E6 29 5F AND #%01011111
  7530. 0F2E8 85 02 STA temp2 ;; holds the values we want to maintain.
  7531. 0F2EA ;; like facing direction and inertial direction.
  7532. 0F2EA A5 00 LDA temp
  7533. 0F2EC 49 FF EOR #$FF ;; flips the inertia bit
  7534. 0F2EE 29 A0 AND #%10100000 ;; but we only care about the "active" bits, h and v
  7535. 0F2F0 25 00 AND temp ;; and only the one defined by flipped bits in "direction"
  7536. 0F2F2 05 02 ORA temp2 ;; then put back the bit status of the rest of the byte.
  7537. 0F2F4 9D A9 04 STA Object_direction,x
  7538. 0F2F7
  7539. 0F2F7
  7540. 0F2F7 60 RTS0F2F8 .include "Routines\BASE_4_5\System\ObjectBehaviors\oChangeFacingDirection.asm"
  7541. 0F2F8 oChangeFacingDirection:
  7542. 0F2F8 A6 0C LDX arg0_hold
  7543. 0F2FA BD A9 04 LDA Object_direction,x
  7544. 0F2FD 29 F8 AND #%11111000
  7545. 0F2FF 05 0D ORA arg1_hold
  7546. 0F301 9D A9 04 STA Object_direction,x
  7547. 0F304 60 RTS0F305 ;.include SCR_COMPARE_BBOX
  7548. 0F305
  7549. 0F305
  7550. 0F305
  7551. 0F305 doCamera:
  7552. 0F305 .include "Routines\BASE_4_5\Game\Space Birds\Subroutines\doUpdateCamera_shooter2.asm"
  7553. 0F305
  7554. 0F305 ;; THIS SCRIPT HAS NOTHING TO DO WITH THE PLAYER AUTOMATICALLY MOVING RIGHT
  7555. 0F305 doUpdateCamera:
  7556. 0F305
  7557. 0F305 A5 2B LDA gameState
  7558. 0F307 F0 09 BEQ dontSkipCamHandling ;skips camera unless we are in main game.
  7559. 0F309 60 RTS
  7560. 0F30A
  7561. 0F30A AD AB 06 LDA gameHandler
  7562. 0F30D 29 80 AND #%10000000 ;;; this will skip object handling.
  7563. 0F30F F0 01 BEQ dontSkipCamHandling
  7564. 0F311 60 RTS
  7565. 0F312
  7566. 0F312
  7567. 0F312 dontSkipCamHandling:
  7568. 0F312
  7569. 0F312 AD 8C 06 LDA scrollByte
  7570. 0F315 09 C0 ORA #%11000000 ;ensures
  7571. 0F317 8D 8C 06 STA scrollByte
  7572. 0F31A
  7573. 0F31A A9 00 LDA #$00
  7574. 0F31C 85 07 STA tempA
  7575. 0F31E A9 01 LDA #$01
  7576. 0F320 85 08 STA tempB
  7577. 0F322
  7578. 0F322 AD 85 06 LDA camX
  7579. 0F325 29 F0 AND #%11110000
  7580. 0F327 85 06 STA tempz
  7581. 0F329
  7582. 0F329 AD 8C 06 LDA scrollByte
  7583. 0F32C 29 A2 AND #%10100010
  7584. 0F32E D0 03 BNE +scrollEngaged
  7585. 0F330 4C 30 F6 JMP skipScrollUpdate
  7586. 0F333 +scrollEngaged:
  7587. 0F333
  7588. 0F333 AD 8C 06 LDA scrollByte
  7589. 0F336 29 80 AND #%10000000
  7590. 0F338 D0 03 BNE doHorizontalCameraUpdate
  7591. 0F33A 4C 12 F4 JMP noHorizontalCameraUpdate
  7592. 0F33D doHorizontalCameraUpdate:
  7593. 0F33D
  7594. 0F33D AD 8C 06 LDA scrollByte
  7595. 0F340 29 40 AND #%01000000
  7596. 0F342 D0 00 BNE doRightCameraUpdate
  7597. 0F344
  7598. 0F344 ; ;; is left camera update
  7599. 0F344 ; LDA camX_lo
  7600. 0F344 ; sec
  7601. 0F344 ; sbc tempA
  7602. 0F344 ; STA camX_lo
  7603. 0F344 ; LDA camX
  7604. 0F344 ; sbc tempB
  7605. 0F344 ; STA temp
  7606. 0F344 ; BCS +skipCheckForScrollScreenEdge
  7607. 0F344 ; LDA ScreenFlags00
  7608. 0F344 ; AND #%00100000
  7609. 0F344 ; BEQ +skipCheckForScrollScreenEdge
  7610. 0F344 ; JMP noHorizontalCameraUpdate
  7611. 0F344 ; +skipCheckForScrollScreenEdge
  7612. 0F344 ; LDA temp
  7613. 0F344 ; STA camX
  7614. 0F344
  7615. 0F344 ; LDA camX_hi
  7616. 0F344 ; sbc #$00
  7617. 0F344 ; STA camX_hi
  7618. 0F344 ; JSR getCamSeam
  7619. 0F344 ; JMP noHorizontalCameraUpdate
  7620. 0F344 doRightCameraUpdate
  7621. 0F344 AD 9F 06 LDA ScreenFlags00
  7622. 0F347 29 10 AND #%00010000 ;checks if Right Edge for Scroll is ticked. If it is not, do a normal screen update. If it is ticked, stop scrolling.
  7623. 0F349 F0 03 BEQ +doNormalScreenUpdate
  7624. 0F34B 4C 12 F4 JMP +noHorizontalCameraUpdate
  7625. 0F34E +doNormalScreenUpdate
  7626. 0F34E AD 84 06 LDA camX_lo
  7627. 0F351 18 clc
  7628. 0F352 65 07 adc tempA
  7629. 0F354 ;STA camX_lo
  7630. 0F354 AD 85 06 LDA camX
  7631. 0F357 65 08 adc tempB
  7632. 0F359 ;STA temp
  7633. 0F359
  7634. 0F359 B0 03 BCS +dontSkipCheckForScrollScreenEdge
  7635. 0F35B 4C F6 F3 JMP +skipCheckForScrollScreenEdge
  7636. 0F35E +dontSkipCheckForScrollScreenEdge
  7637. 0F35E
  7638. 0F35E ;; here we have cross the screen boundary
  7639. 0F35E ;;; so if there is anything that needs updating for scrolling
  7640. 0F35E ;;; update it here.
  7641. 0F35E
  7642. 0F35E 98 48 AD 20 06 8D 21 06.. SwitchBank #$16
  7643. 0F36D AD 8D 06 LDA camScreen
  7644. 0F370 18 CLC
  7645. 0F371 69 01 ADC #$01
  7646. 0F373 A8 TAY
  7647. 0F374 B9 00 8D LDA CollisionTables_Map1_Lo,y ;(y equals the value of camScreen plus 1)
  7648. 0F377 85 14 STA temp16
  7649. 0F379 B9 00 8F LDA CollisionTables_Map1_Hi,y ;(y equals the value of camScreen plus 1)
  7650. 0F37C 85 15 STA temp16+1
  7651. 0F37E 98 48 AC 21 06 20 83 C5.. ReturnBank
  7652. 0F388 AD 8D 06 LDA camScreen
  7653. 0F38B 18 CLC
  7654. 0F38C 69 01 ADC #$01
  7655. 0F38E 4A LSR
  7656. 0F38F 4A LSR
  7657. 0F390 4A LSR
  7658. 0F391 4A LSR
  7659. 0F392 4A LSR
  7660. 0F393 85 00 STA temp ; bank
  7661. 0F395 98 48 AD 20 06 8D 21 06.. SwitchBank temp
  7662. 0F3A4 A0 7C LDY #124 ;why 124?
  7663. 0F3A6 B1 14 LDA (temp16),y
  7664. 0F3A8 8D 9F 06 STA ScreenFlags00
  7665. 0F3AB
  7666. 0F3AB 98 48 AC 21 06 20 83 C5.. ReturnBank
  7667. 0F3B5
  7668. 0F3B5 A9 08 85 07 8A 48 98 48.. CountObjects #%00001000
  7669. 0F3DE D0 0F BNE +dontTurnOffMonsterChecker ;if the result is not zero, don't turn off the monster checker because monsters still remain.
  7670. 0F3E0
  7671. 0F3E0
  7672. 0F3E0 ;; turn off monster checker.
  7673. 0F3E0 ;; because you already killed the monsters
  7674. 0F3E0 ;; before getting lined up to the screen.
  7675. 0F3E0
  7676. 0F3E0 ;; unless it is a boss screen
  7677. 0F3E0 AD 9F 06 LDA ScreenFlags00
  7678. 0F3E3 29 08 AND #%00001000 ;; is it a boss flag?
  7679. 0F3E5 D0 08 BNE +dontTurnOffMonsterChecker
  7680. 0F3E7 AD 9F 06 LDA ScreenFlags00
  7681. 0F3EA 29 EF AND #%11101111
  7682. 0F3EC 8D 9F 06 STA ScreenFlags00
  7683. 0F3EF +dontTurnOffMonsterChecker
  7684. 0F3EF
  7685. 0F3EF AD 9F 06 LDA ScreenFlags00
  7686. 0F3F2 29 10 AND #%00010000
  7687. 0F3F4 D0 1C BNE noHorizontalCameraUpdate
  7688. 0F3F6 +skipCheckForScrollScreenEdge
  7689. 0F3F6
  7690. 0F3F6
  7691. 0F3F6 ; LDA temp
  7692. 0F3F6 ; STA camX
  7693. 0F3F6 ; LDA camX_hi
  7694. 0F3F6 ; adc #$00
  7695. 0F3F6 ; STA camX_hi
  7696. 0F3F6
  7697. 0F3F6 AD 84 06 LDA camX_lo
  7698. 0F3F9 18 clc
  7699. 0F3FA 65 07 adc tempA
  7700. 0F3FC 8D 84 06 STA camX_lo
  7701. 0F3FF AD 85 06 LDA camX
  7702. 0F402 65 08 adc tempB
  7703. 0F404 8D 85 06 STA camX
  7704. 0F407 AD 86 06 LDA camX_hi
  7705. 0F40A 69 00 ADC #$00
  7706. 0F40C 8D 86 06 STA camX_hi
  7707. 0F40F 20 3F F6 JSR getCamSeam
  7708. 0F412 noHorizontalCameraUpdate:
  7709. 0F412
  7710. 0F412
  7711. 0F412
  7712. 0F412 +skipSettingScreenFlag
  7713. 0F412
  7714. 0F412
  7715. 0F412 AD 8C 06 LDA scrollByte
  7716. 0F415 29 01 AND #%00000001
  7717. 0F417 F0 03 BEQ +canUpdateScrollColumn ;if bit 0 is OFF, you can update the scroll column. If bit 0 is ON, skip scroll update.
  7718. 0F419 4C 30 F6 JMP skipScrollUpdate
  7719. 0F41C +canUpdateScrollColumn
  7720. 0F41C AD 8C 06 LDA scrollByte
  7721. 0F41F 29 02 AND #%00000010
  7722. 0F421 D0 0C BNE forceScrollColumnUpdate
  7723. 0F423 AD 85 06 LDA camX
  7724. 0F426 29 F0 AND #%11110000 ;is the camera at the right edge of the screen?
  7725. 0F428 C5 06 CMP tempz
  7726. 0F42A D0 0B BNE +canUpdateScrollColumn2
  7727. 0F42C 4C 30 F6 JMP skipScrollUpdate
  7728. 0F42F forceScrollColumnUpdate:
  7729. 0F42F AD 8C 06 LDA scrollByte
  7730. 0F432 29 FD AND #%11111101 ;bit 1 is forced to be off. All others are left as they are.
  7731. 0F434 8D 8C 06 STA scrollByte
  7732. 0F437 +canUpdateScrollColumn2
  7733. 0F437
  7734. 0F437 AD 8C 06 LDA scrollByte
  7735. 0F43A 09 05 ORA #%00000101 ;bits 0 and 2 are forced to be ON. all others are left as they are.
  7736. 0F43C 8D 8C 06 STA scrollByte
  7737. 0F43F ;;;;;;;;;; DO SCROLL UPDATE.
  7738. 0F43F 98 48 AD 20 06 8D 21 06.. SwitchBank #$16
  7739. 0F44E A4 92 LDY scrollUpdateScreen
  7740. 0F450 B9 00 85 LDA NameTablePointers_Map1_lo,y
  7741. 0F453 85 14 STA temp16
  7742. 0F455 B9 00 86 LDA NameTablePointers_Map1_hi,y
  7743. 0F458 85 15 STA temp16+1
  7744. 0F45A
  7745. 0F45A
  7746. 0F45A B9 00 89 LDA AttributeTables_Map1_Lo,y
  7747. 0F45D 85 1B STA pointer
  7748. 0F45F B9 00 8A LDA AttributeTables_Map1_Hi,y
  7749. 0F462 85 1C STA pointer+1
  7750. 0F464
  7751. 0F464
  7752. 0F464 B9 00 8D LDA CollisionTables_Map1_Lo,y
  7753. 0F467 85 33 STA pointer6
  7754. 0F469 B9 00 8F LDA CollisionTables_Map1_Hi,y
  7755. 0F46C 85 34 STA pointer6+1
  7756. 0F46E 98 48 AC 21 06 20 83 C5.. ReturnBank
  7757. 0F478 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7758. 0F478 ;;; now we have pointers for the fetch.
  7759. 0F478 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7760. 0F478
  7761. 0F478 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7762. 0F478 ;;; We can read from the pointers to get metatile data.
  7763. 0F478 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7764. 0F478 ;;; jump to the bank
  7765. 0F478 A5 92 LDA scrollUpdateScreen
  7766. 0F47A 4A LSR
  7767. 0F47B 4A LSR
  7768. 0F47C 4A LSR
  7769. 0F47D 4A LSR
  7770. 0F47E 4A LSR
  7771. 0F47F 85 00 STA temp ; bank
  7772. 0F481
  7773. 0F481 98 48 AD 20 06 8D 21 06.. SwitchBank temp
  7774. 0F490 ; LDX screenState
  7775. 0F490 ; LDY Mon1SpawnLocation,x
  7776. 0F490 ; LDA (pointer6),y
  7777. 0F490 ; STA scrollUpdateObjectLocation
  7778. 0F490
  7779. 0F490 ; LDY Mon2SpawnLocation,x
  7780. 0F490 ; LDA (pointer6),y
  7781. 0F490 ; STA scrollUpdateObjectLocation+1
  7782. 0F490
  7783. 0F490 ; LDY Mon3SpawnLocation,x
  7784. 0F490 ; LDA (pointer6),y
  7785. 0F490 ; STA scrollUpdateObjectLocation+2
  7786. 0F490
  7787. 0F490 ; LDY Mon4SpawnLocation,x
  7788. 0F490 ; LDA (pointer6),y
  7789. 0F490 ; STA scrollUpdateObjectLocation+3
  7790. 0F490
  7791. 0F490 A6 98 LDX screenState
  7792. 0F492 BC D1 F1 LDY Mon1SpawnLocation,x
  7793. 0F495 BD F5 F1 LDA Monster1ID,x
  7794. 0F498 85 0A STA tempD
  7795. 0F49A 20 21 F7 JSR checkSeamForMonsterPosition
  7796. 0F49D
  7797. 0F49D A6 98 LDX screenState
  7798. 0F49F BC D5 F1 LDY Mon2SpawnLocation,x
  7799. 0F4A2 BD F9 F1 LDA Monster2ID,x
  7800. 0F4A5 85 0A STA tempD
  7801. 0F4A7 20 21 F7 JSR checkSeamForMonsterPosition
  7802. 0F4AA
  7803. 0F4AA A6 98 LDX screenState
  7804. 0F4AC BC D9 F1 LDY Mon3SpawnLocation,x
  7805. 0F4AF BD FD F1 LDA Monster3ID,x
  7806. 0F4B2 85 0A STA tempD
  7807. 0F4B4 20 21 F7 JSR checkSeamForMonsterPosition
  7808. 0F4B7
  7809. 0F4B7 A6 98 LDX screenState
  7810. 0F4B9 BC DD F1 LDY Mon4SpawnLocation,x
  7811. 0F4BC BD 01 F2 LDA Monster4ID,x
  7812. 0F4BF 85 0A STA tempD
  7813. 0F4C1 20 21 F7 JSR checkSeamForMonsterPosition
  7814. 0F4C4
  7815. 0F4C4
  7816. 0F4C4
  7817. 0F4C4
  7818. 0F4C4 A5 92 LDA scrollUpdateScreen
  7819. 0F4C6 29 01 AND #%00000001
  7820. 0F4C8 0A ASL
  7821. 0F4C9 0A ASL
  7822. 0F4CA 09 20 ORA #%00100000
  7823. 0F4CC 85 01 STA temp1 ;; temp 1 now represents the high byte of the address to place
  7824. 0F4CE
  7825. 0F4CE A5 93 LDA scrollUpdateColumn
  7826. 0F4D0 4A LSR
  7827. 0F4D1 4A LSR
  7828. 0F4D2 4A LSR
  7829. 0F4D3 29 1F AND #%00011111
  7830. 0F4D5 85 02 STA temp2 ;; temp 2 now represents the low byte of the pushes.
  7831. 0F4D7
  7832. 0F4D7 A5 93 LDA scrollUpdateColumn
  7833. 0F4D9 4A LSR
  7834. 0F4DA 4A LSR
  7835. 0F4DB 4A LSR
  7836. 0F4DC 4A LSR
  7837. 0F4DD 85 03 STA temp3
  7838. 0F4DF
  7839. 0F4DF A9 00 LDA #$00
  7840. 0F4E1 8D 8A 06 STA scrollOffsetCounter
  7841. 0F4E4
  7842. 0F4E4 A2 00 LDX #$00 ;; will keep track of scroll update ram.
  7843. 0F4E6 A9 0F LDA #$0F
  7844. 0F4E8 85 07 STA tempA ;; will keep the track of how many tiles to draw.
  7845. 0F4EA ;; #$0f is an entire column.
  7846. 0F4EA loop_LoadNametableMeta_column:
  7847. 0F4EA A4 03 LDY temp3
  7848. 0F4EC B1 14 LDA (temp16),y
  7849. 0F4EE 85 00 STA temp
  7850. 0F4F0 20 24 C7 JSR doGetSingleMetaTileValues
  7851. 0F4F3
  7852. 0F4F3 A5 01 LDA temp1
  7853. 0F4F5 9D 00 07 STA scrollUpdateRam,x
  7854. 0F4F8 E8 INX
  7855. 0F4F9 A5 02 LDA temp2
  7856. 0F4FB 9D 00 07 STA scrollUpdateRam,x
  7857. 0F4FE E8 INX
  7858. 0F4FF AD 53 06 LDA updateTile_00
  7859. 0F502 9D 00 07 STA scrollUpdateRam,x
  7860. 0F505 E8 INX
  7861. 0F506
  7862. 0F506 A5 01 LDA temp1
  7863. 0F508 9D 00 07 STA scrollUpdateRam,x
  7864. 0F50B E8 INX
  7865. 0F50C A5 02 LDA temp2
  7866. 0F50E 18 CLC
  7867. 0F50F 69 01 ADC #$01
  7868. 0F511 9D 00 07 STA scrollUpdateRam,x
  7869. 0F514 E8 INX
  7870. 0F515 AD 54 06 LDA updateTile_01
  7871. 0F518 9D 00 07 STA scrollUpdateRam,x
  7872. 0F51B E8 INX
  7873. 0F51C
  7874. 0F51C A5 01 LDA temp1
  7875. 0F51E 9D 00 07 STA scrollUpdateRam,x
  7876. 0F521 E8 INX
  7877. 0F522 A5 02 LDA temp2
  7878. 0F524 18 CLC
  7879. 0F525 69 20 ADC #$20
  7880. 0F527 9D 00 07 STA scrollUpdateRam,x
  7881. 0F52A E8 INX
  7882. 0F52B AD 55 06 LDA updateTile_02
  7883. 0F52E 9D 00 07 STA scrollUpdateRam,x
  7884. 0F531 E8 INX
  7885. 0F532
  7886. 0F532 A5 01 LDA temp1
  7887. 0F534 9D 00 07 STA scrollUpdateRam,x
  7888. 0F537 E8 INX
  7889. 0F538 A5 02 LDA temp2
  7890. 0F53A 18 CLC
  7891. 0F53B 69 21 ADC #$21
  7892. 0F53D 9D 00 07 STA scrollUpdateRam,x
  7893. 0F540 E8 INX
  7894. 0F541 AD 56 06 LDA updateTile_03
  7895. 0F544 9D 00 07 STA scrollUpdateRam,x
  7896. 0F547 E8 INX
  7897. 0F548
  7898. 0F548 C6 07 DEC tempA
  7899. 0F54A A5 07 LDA tempA
  7900. 0F54C F0 17 BEQ +doneWithNtLoad
  7901. 0F54E ;; not done with NT load. Need more tiles.
  7902. 0F54E ;;;;;;;;;;;;;;;;;;;;;;;;;;
  7903. 0F54E ;; update the 16 bit position of the new place to push tiles to.
  7904. 0F54E A5 02 LDA temp2
  7905. 0F550 18 CLC
  7906. 0F551 69 40 ADC #$40
  7907. 0F553 85 02 STA temp2
  7908. 0F555 A5 01 LDA temp1
  7909. 0F557 69 00 ADC #$00
  7910. 0F559 85 01 STA temp1
  7911. 0F55B ;; update the tile read location.
  7912. 0F55B A5 03 LDA temp3
  7913. 0F55D 18 CLC
  7914. 0F55E 69 10 ADC #$10
  7915. 0F560 85 03 STA temp3
  7916. 0F562 4C EA F4 JMP loop_LoadNametableMeta_column
  7917. 0F565 +doneWithNtLoad
  7918. 0F565 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7919. 0F565 ;;;;;;; add attributes to the update list.
  7920. 0F565 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7921. 0F565 ;;;; 23 = 00100011
  7922. 0F565 ;;;; 27 = 00100111
  7923. 0F565 ;;;; so the last bit of scrollUpdateScreen and shift it twice to the left
  7924. 0F565 ;;;; then or it with 00100000 to get the high byte of the attribute update table.
  7925. 0F565 A5 92 LDA scrollUpdateScreen
  7926. 0F567 29 01 AND #%00000001
  7927. 0F569 0A ASL
  7928. 0F56A 0A ASL
  7929. 0F56B ;ASL
  7930. 0F56B 09 23 ORA #%00100011
  7931. 0F56D 85 01 STA temp1 ;; this is now the high byte of the attribute table update
  7932. 0F56F
  7933. 0F56F A5 93 LDA scrollUpdateColumn
  7934. 0F571 4A LSR
  7935. 0F572 4A LSR
  7936. 0F573 4A LSR
  7937. 0F574 4A LSR
  7938. 0F575 4A LSR
  7939. 0F576
  7940. 0F576 85 02 STA temp2 ;; temp 2 now represents the low byte of the pushes.
  7941. 0F578 ;; don't need a temp3 to keep track of pull position, because it will be 1 to 1.
  7942. 0F578
  7943. 0F578 A9 08 LDA #$08
  7944. 0F57A 85 07 STA tempA ;; will keep the track of how many tiles to draw.
  7945. 0F57C ;; #$0f is an entire column.
  7946. 0F57C loop_LoadAttribute_column:
  7947. 0F57C
  7948. 0F57C A4 02 LDY temp2
  7949. 0F57E B1 1B LDA (pointer),y
  7950. 0F580 85 00 STA temp
  7951. 0F582
  7952. 0F582 A5 01 LDA temp1
  7953. 0F584 9D 00 07 STA scrollUpdateRam,x
  7954. 0F587 E8 INX
  7955. 0F588 A5 02 LDA temp2
  7956. 0F58A 18 CLC
  7957. 0F58B 69 C0 ADC #$c0
  7958. 0F58D 9D 00 07 STA scrollUpdateRam,x
  7959. 0F590 E8 INX
  7960. 0F591 A5 00 LDA temp
  7961. 0F593 9D 00 07 STA scrollUpdateRam,x
  7962. 0F596 E8 INX
  7963. 0F597 C6 07 DEC tempA
  7964. 0F599 A5 07 LDA tempA
  7965. 0F59B F0 0A BEQ +doneWithAtLoad
  7966. 0F59D A5 02 LDA temp2
  7967. 0F59F 18 CLC
  7968. 0F5A0 69 08 ADC #$08
  7969. 0F5A2 85 02 STA temp2
  7970. 0F5A4 4C 7C F5 JMP loop_LoadAttribute_column
  7971. 0F5A7 +doneWithAtLoad
  7972. 0F5A7
  7973. 0F5A7
  7974. 0F5A7 8A TXA
  7975. 0F5A8 8D 8B 06 STA maxScrollOffsetCounter
  7976. 0F5AB
  7977. 0F5AB AD 24 06 LDA updateScreenData
  7978. 0F5AE 09 04 ORA #%00000100
  7979. 0F5B0 8D 24 06 STA updateScreenData
  7980. 0F5B3
  7981. 0F5B3
  7982. 0F5B3 A5 93 LDA scrollUpdateColumn
  7983. 0F5B5 4A LSR
  7984. 0F5B6 4A LSR
  7985. 0F5B7 4A LSR
  7986. 0F5B8 4A LSR
  7987. 0F5B9 85 01 STA temp1 ;; keeps track of where to place on the collision table.
  7988. 0F5BB 4A LSR
  7989. 0F5BC 85 02 STA temp2 ;; keeps track of the nubble being pulled from.
  7990. 0F5BE A2 0F LDX #$0F ;; keep track of how many values to load are left.
  7991. 0F5C0
  7992. 0F5C0 A5 92 LDA scrollUpdateScreen
  7993. 0F5C2 29 01 AND #%00000001
  7994. 0F5C4 D0 30 BNE +doUpdateOddCt
  7995. 0F5C6 ;; do update even CT
  7996. 0F5C6 ;; to ct table 1
  7997. 0F5C6 doUpdateCtLoop
  7998. 0F5C6 A5 01 LDA temp1
  7999. 0F5C8 29 01 AND #%00000001
  8000. 0F5CA D0 0B BNE +oddCol
  8001. 0F5CC A4 02 LDY temp2
  8002. 0F5CE B1 33 LDA (pointer6),y
  8003. 0F5D0 4A LSR
  8004. 0F5D1 4A LSR
  8005. 0F5D2 4A LSR
  8006. 0F5D3 4A LSR
  8007. 0F5D4 4C DD F5 JMP +pushToCol
  8008. 0F5D7 +oddCol
  8009. 0F5D7 A4 02 LDY temp2
  8010. 0F5D9 B1 33 LDA (pointer6),y
  8011. 0F5DB 29 0F AND #%00001111
  8012. 0F5DD
  8013. 0F5DD +pushToCol:
  8014. 0F5DD A4 01 LDY temp1
  8015. 0F5DF 99 00 03 STA collisionTable,y
  8016. 0F5E2 A5 01 LDA temp1
  8017. 0F5E4 18 CLC
  8018. 0F5E5 69 10 ADC #$10
  8019. 0F5E7 85 01 STA temp1
  8020. 0F5E9 A5 02 LDA temp2
  8021. 0F5EB 18 CLC
  8022. 0F5EC 69 08 ADC #$08
  8023. 0F5EE 85 02 STA temp2
  8024. 0F5F0 CA DEX
  8025. 0F5F1 D0 D3 BNE doUpdateCtLoop
  8026. 0F5F3 4C 26 F6 JMP +doneWithCtLoad
  8027. 0F5F6 +doUpdateOddCt
  8028. 0F5F6 ;; do update odd ct
  8029. 0F5F6 ;; to ct table 2
  8030. 0F5F6 doUpdateCtLoop2
  8031. 0F5F6 A5 01 LDA temp1
  8032. 0F5F8 29 01 AND #%00000001
  8033. 0F5FA D0 0B BNE +oddCol
  8034. 0F5FC A4 02 LDY temp2
  8035. 0F5FE B1 33 LDA (pointer6),y
  8036. 0F600 4A LSR
  8037. 0F601 4A LSR
  8038. 0F602 4A LSR
  8039. 0F603 4A LSR
  8040. 0F604 4C 0D F6 JMP +pushToCol
  8041. 0F607 +oddCol
  8042. 0F607 A4 02 LDY temp2
  8043. 0F609 B1 33 LDA (pointer6),y
  8044. 0F60B 29 0F AND #%00001111
  8045. 0F60D
  8046. 0F60D +pushToCol:
  8047. 0F60D A4 01 LDY temp1
  8048. 0F60F 99 00 05 STA collisionTable2,y
  8049. 0F612 A5 01 LDA temp1
  8050. 0F614 18 CLC
  8051. 0F615 69 10 ADC #$10
  8052. 0F617 85 01 STA temp1
  8053. 0F619 A5 02 LDA temp2
  8054. 0F61B 18 CLC
  8055. 0F61C 69 08 ADC #$08
  8056. 0F61E 85 02 STA temp2
  8057. 0F620 CA DEX
  8058. 0F621 D0 D3 BNE doUpdateCtLoop2
  8059. 0F623 4C 26 F6 JMP +doneWithCtLoad
  8060. 0F626 +doneWithCtLoad
  8061. 0F626
  8062. 0F626 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8063. 0F626
  8064. 0F626 98 48 AC 21 06 20 83 C5.. ReturnBank
  8065. 0F630
  8066. 0F630
  8067. 0F630 skipScrollUpdate
  8068. 0F630 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8069. 0F630 ;; Make sure we always update camScreen.
  8070. 0F630 AD 89 06 LDA camY_hi
  8071. 0F633 0A ASL
  8072. 0F634 0A ASL
  8073. 0F635 0A ASL
  8074. 0F636 0A ASL
  8075. 0F637 18 CLC
  8076. 0F638 6D 86 06 ADC camX_hi
  8077. 0F63B 8D 8D 06 STA camScreen
  8078. 0F63E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8079. 0F63E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8080. 0F63E ;JSR checkForMonsterCameraClipping
  8081. 0F63E
  8082. 0F63E 60 RTS
  8083. 0F63F
  8084. 0F63F
  8085. 0F63F
  8086. 0F63F getCamSeam:
  8087. 0F63F ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8088. 0F63F ;;; Since we use camScreen in this subroutine, we'll have to make sure it's properly updated
  8089. 0F63F ;;; before get our column and screen.
  8090. 0F63F AD 89 06 LDA camY_hi
  8091. 0F642 0A ASL
  8092. 0F643 0A ASL
  8093. 0F644 0A ASL
  8094. 0F645 0A ASL
  8095. 0F646 18 CLC
  8096. 0F647 6D 86 06 ADC camX_hi
  8097. 0F64A 8D 8D 06 STA camScreen
  8098. 0F64D
  8099. 0F64D AD 8C 06 LDA scrollByte
  8100. 0F650 29 40 AND #%01000000
  8101. 0F652 D0 12 BNE +getRightScrollUpdate
  8102. 0F654 ;; get left scroll update
  8103. 0F654 AD 85 06 LDA camX
  8104. 0F657 29 F0 AND #%11110000
  8105. 0F659 38 sec
  8106. 0F65A E9 70 sbc #$70
  8107. 0F65C 85 93 STA scrollUpdateColumn
  8108. 0F65E AD 8D 06 LDA camScreen
  8109. 0F661 E9 00 sbc #$00
  8110. 0F663 85 92 STA scrollUpdateScreen
  8111. 0F665
  8112. 0F665 60 RTS
  8113. 0F666 +getRightScrollUpdate
  8114. 0F666
  8115. 0F666 AD 85 06 LDA camX
  8116. 0F669 29 F0 AND #%11110000
  8117. 0F66B 18 CLC
  8118. 0F66C 69 80 ADC #$80
  8119. 0F66E 85 93 STA scrollUpdateColumn
  8120. 0F670 AD 8D 06 LDA camScreen
  8121. 0F673 69 01 ADC #$01
  8122. 0F675 85 92 STA scrollUpdateScreen
  8123. 0F677
  8124. 0F677 60 RTS
  8125. 0F678
  8126. 0F678
  8127. 0F678
  8128. 0F678 checkForMonsterCameraClipping:
  8129. 0F678
  8130. 0F678 60 RTS
  8131. 0F679 ;;; use temp16 to check for cam clips
  8132. 0F679 AD 86 06 LDA camX_hi
  8133. 0F67C 29 0F AND #%00001111
  8134. 0F67E D0 0C BNE notOnZeroScreen
  8135. 0F680 A9 00 LDA #$00
  8136. 0F682 85 14 STA temp16
  8137. 0F684 AD 86 06 LDA camX_hi
  8138. 0F687 85 15 STA temp16+1
  8139. 0F689 4C 98 F6 JMP +gotIt
  8140. 0F68C notOnZeroScreen:
  8141. 0F68C ;;; For this type of game, anything that reaches the left seam should be destroyed.
  8142. 0F68C AD 85 06 LDA camX
  8143. 0F68F ; SEC
  8144. 0F68F ; SBC #$80
  8145. 0F68F 85 14 STA temp16 ;; low left cam clip
  8146. 0F691 AD 86 06 LDA camX_hi
  8147. 0F694 ;AND #%00001111
  8148. 0F694 ; SBC #$00
  8149. 0F694 29 0F AND #%00001111
  8150. 0F696 85 15 STA temp16+1 ;; high left cam clip
  8151. 0F698 +gotIt:
  8152. 0F698 AD 85 06 LDA camX
  8153. 0F69B 18 CLC
  8154. 0F69C 69 90 ADC #$90
  8155. 0F69E 85 1B STA pointer ;; low right cam clip
  8156. 0F6A0 AD 86 06 LDA camX_hi
  8157. 0F6A3
  8158. 0F6A3 69 01 ADC #$01
  8159. 0F6A5 29 0F AND #%00001111
  8160. 0F6A7 85 1C STA pointer+1 ;; high right cam clip
  8161. 0F6A9
  8162. 0F6A9 A2 00 LDX #$00
  8163. 0F6AB skipCheckingThisObject_forEraseColumnLoop
  8164. 0F6AB BD D0 04 LDA Object_flags,x
  8165. 0F6AE 29 03 AND #%00000011
  8166. 0F6B0 F0 69 BEQ doEraseNonPlayerObjectsInThisColumnLoop
  8167. 0F6B2 BD 00 04 LDA Object_status,x
  8168. 0F6B5 29 80 AND #%10000000
  8169. 0F6B7 F0 62 BEQ doEraseNonPlayerObjectsInThisColumnLoop
  8170. 0F6B9 ;; check this monster's position
  8171. 0F6B9 BD 1A 04 LDA Object_x_hi,x
  8172. 0F6BC 85 00 STA temp
  8173. 0F6BE BD 27 04 LDA Object_screen,x
  8174. 0F6C1 29 0F AND #%00001111
  8175. 0F6C3 85 01 STA temp1
  8176. 0F6C5 A5 15 C5 01 D0 09 A5 14.. Compare16 temp16+1, temp16, temp1, temp
  8177. 0F6E5 +
  8178. 0F6E5 BD 00 04 29 3F 9D 00 04 DestroyObject
  8179. 0F6ED
  8180. 0F6ED
  8181. 0F6ED 4C 1B F7 JMP doEraseNonPlayerObjectsInThisColumnLoop
  8182. 0F6F0 ++
  8183. 0F6F0 ;; skip erasing from rightmost column.
  8184. 0F6F0 skipCheckingThisObject_forEraseColumnLoop2:
  8185. 0F6F0 A5 1C C5 01 D0 09 A5 1B.. Compare16 pointer+1, pointer, temp1, temp
  8186. 0F710 +
  8187. 0F710 4C 1B F7 JMP doEraseNonPlayerObjectsInThisColumnLoop
  8188. 0F713 ++
  8189. 0F713 BD 00 04 29 3F 9D 00 04 DestroyObject
  8190. 0F71B
  8191. 0F71B doEraseNonPlayerObjectsInThisColumnLoop:
  8192. 0F71B E8 INX
  8193. 0F71C E0 0D CPX #TOTAL_MAX_OBJECTS
  8194. 0F71E D0 8B BNE skipCheckingThisObject_forEraseColumnLoop
  8195. 0F720
  8196. 0F720 60 RTS
  8197. 0F721
  8198. 0F721 checkSeamForMonsterPosition:
  8199. 0F721 ;; y is loaded before subroutine.
  8200. 0F721 B1 33 LDA (pointer6),y
  8201. 0F723 85 00 STA temp
  8202. 0F725 0A ASL
  8203. 0F726 0A ASL
  8204. 0F727 0A ASL
  8205. 0F728 0A ASL
  8206. 0F729 85 02 STA temp2
  8207. 0F72B A5 93 LDA scrollUpdateColumn
  8208. 0F72D 29 F0 AND #%11110000
  8209. 0F72F C5 02 CMP temp2
  8210. 0F731 D0 36 BNE +noMonsterToLoadInThisColumn
  8211. 0F733 A5 00 LDA temp
  8212. 0F735 29 F0 AND #%11110000
  8213. 0F737 85 01 STA temp1
  8214. 0F739 C9 F0 CMP #%11110000
  8215. 0F73B F0 2C BEQ +noMonsterToLoadInThisColumn
  8216. 0F73D A4 0A LDY tempD
  8217. 0F73F B1 33 LDA (pointer6),y
  8218. 0F741 85 0A STA tempD
  8219. 0F743 20 BA F1 E0 FF D0 03 4C.. CreateObjectOnScreen temp2, temp1, tempD, #$00, scrollUpdateScreen
  8220. 0F769 +noMonsterToLoadInThisColumn:
  8221. 0F769 60 RTS
  8222. 0F76A 0F76A 60 RTS
  8223. 0F76B doDrawHud:
  8224. 0F76B .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8225. 0F76B ;blank0F76B 60 RTS
  8226. 0F76C
  8227. 0F76C
  8228. 0F76C .include "GameData\DataBank01_Includes.asm"
  8229. 0F76C ;; *************** DataBank01_Includes.asm ***************
  8230. 0F76C ;; Script data export. Saturday, March 6, 2021 6:48:13 PM
  8231. 0F76C Script00:
  8232. 0F76C .include "Routines\BASE_4_5\Game\MOD_shooter\Input\moveRight_shooter.asm"
  8233. 0F76C ;;;;
  8234. 0F76C 8A TXA
  8235. 0F76D 85 00 STA temp ;; assumes the object we want to move is in x.
  8236. 0F76F A6 00 BD 9C 04 4A 4A 4A.. GetActionStep temp
  8237. 0F779 C9 07 CMP #$07
  8238. 0F77B D0 03 BNE +notHurt
  8239. 0F77D 4C 8F F7 JMP +CantMove
  8240. 0F780 +notHurt
  8241. 0F780 8A 48 A5 00 85 0C A9 C0.. StartMoving temp, #RIGHT
  8242. 0F78F ; TXA
  8243. 0F78F ; STA temp ;; assumes the object we want to move is in x.
  8244. 0F78F ; ChangeFacingDirection temp, #FACE_RIGHT
  8245. 0F78F +CantMove
  8246. 0F78F 60 RTS0F790 Script01:
  8247. 0F790 .include "Routines\BASE_4_5\Game\MOD_shooter\Input\moveDown_shooter.asm"
  8248. 0F790 ;;;;
  8249. 0F790
  8250. 0F790 8A TXA
  8251. 0F791 85 00 STA temp ;; assumes the object we want to move is in x.
  8252. 0F793 A6 00 BD 9C 04 4A 4A 4A.. GetActionStep temp
  8253. 0F79D C9 07 CMP #$07
  8254. 0F79F D0 03 BNE +notHurt
  8255. 0F7A1 4C B3 F7 JMP +CantMove
  8256. 0F7A4 +notHurt
  8257. 0F7A4 8A 48 A5 00 85 0C A9 30.. StartMoving temp, #DOWN
  8258. 0F7B3 ; TXA
  8259. 0F7B3 ; STA temp ;; assumes the object we want to move is in x.
  8260. 0F7B3 ; ChangeFacingDirection temp, #FACE_DOWN
  8261. 0F7B3 +CantMove
  8262. 0F7B3 60 RTS0F7B4 Script02:
  8263. 0F7B4 .include "Routines\BASE_4_5\Game\MOD_shooter\Input\moveLeft_shooter.asm"
  8264. 0F7B4 ;;;;
  8265. 0F7B4
  8266. 0F7B4 8A TXA
  8267. 0F7B5 85 00 STA temp ;; assumes the object we want to move is in x.
  8268. 0F7B7 A6 00 BD 9C 04 4A 4A 4A.. GetActionStep temp
  8269. 0F7C1 C9 07 CMP #$07
  8270. 0F7C3 D0 03 BNE +notHurt
  8271. 0F7C5 4C D7 F7 JMP +CantMove
  8272. 0F7C8 +notHurt
  8273. 0F7C8 8A 48 A5 00 85 0C A9 80.. StartMoving temp, #LEFT
  8274. 0F7D7 ; TXA
  8275. 0F7D7 ; STA temp ;; assumes the object we want to move is in x.
  8276. 0F7D7 ; ChangeFacingDirection temp, #FACE_LEFT
  8277. 0F7D7 +CantMove
  8278. 0F7D7 60 RTS0F7D8 Script03:
  8279. 0F7D8 .include "Routines\BASE_4_5\Game\MOD_shooter\Input\moveUp_shooter.asm"
  8280. 0F7D8 ;;;;
  8281. 0F7D8 8A TXA
  8282. 0F7D9 85 00 STA temp ;; assumes the object we want to move is in x.
  8283. 0F7DB A6 00 BD 9C 04 4A 4A 4A.. GetActionStep temp
  8284. 0F7E5 C9 07 CMP #$07
  8285. 0F7E7 D0 03 BNE +notHurt
  8286. 0F7E9 4C FB F7 JMP +CantMove
  8287. 0F7EC +notHurt
  8288. 0F7EC 8A 48 A5 00 85 0C A9 20.. StartMoving temp, #UP
  8289. 0F7FB ; TXA
  8290. 0F7FB ; STA temp ;; assumes the object we want to move is in x.
  8291. 0F7FB ; ChangeFacingDirection temp, #FACE_UP
  8292. 0F7FB +CantMove
  8293. 0F7FB 60 RTS0F7FC Script04:
  8294. 0F7FC .include "Routines\BASE_4_5\Game\inputScripts\stopMoving.asm"
  8295. 0F7FC stopMoving:
  8296. 0F7FC ;;;;
  8297. 0F7FC 8A TXA
  8298. 0F7FD 85 00 STA temp ;; assumes the object we want to move is in x.
  8299. 0F7FF 8A 48 A5 00 85 0C A9 FF.. StopMoving temp, #$FF, #$00
  8300. 0F80E ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8301. 0F80E 60 RTS0F80F Script05:
  8302. 0F80F .include "Routines\BASE_4_5\Game\MOD_shooter\Input\shootProjectile_timer.asm"
  8303. 0F80F ;;; Create a Projectile.
  8304. 0F80F ;;; Assumes that the projectile you want to create is in GameObject Slot 01.
  8305. 0F80F A5 A7 LDA bulletTimer
  8306. 0F811 F0 01 BEQ +canShoot
  8307. 0F813 ;; bullet timer not reset yet.
  8308. 0F813 ;; we will decrease bullet timer in game timer scripts.
  8309. 0F813 ;; and if it is zero, keep it at zero.
  8310. 0F813 60 RTS
  8311. 0F814 +canShoot
  8312. 0F814
  8313. 0F814 8A TXA
  8314. 0F815 48 PHA
  8315. 0F816 98 TYA
  8316. 0F817 48 PHA
  8317. 0F818 AE 6D 06 LDX player1_object
  8318. 0F81B BD 27 04 LDA Object_screen,x
  8319. 0F81E
  8320. 0F81E 85 0A STA tempD
  8321. 0F820 BD 1A 04 LDA Object_x_hi,x
  8322. 0F823 18 CLC
  8323. 0F824 69 04 ADC #$04
  8324. 0F826 85 07 STA tempA
  8325. 0F828 BD 41 04 LDA Object_y_hi,x
  8326. 0F82B 18 CLC
  8327. 0F82C 69 04 ADC #$04
  8328. 0F82E 85 08 STA tempB
  8329. 0F830 BD A9 04 LDA Object_direction,x
  8330. 0F833 29 07 AND #%00000111
  8331. 0F835 85 09 STA tempC
  8332. 0F837 20 BA F1 E0 FF D0 03 4C.. CreateObjectOnScreen tempA, tempB, #$01, #$00, tempD
  8333. 0F85D ;;; x, y, object, starting action.
  8334. 0F85D ;;; and now with that object, copy the player's
  8335. 0F85D ;;; direction and start it moving that way.
  8336. 0F85D A5 09 LDA tempC
  8337. 0F85F 9D A9 04 STA Object_direction,x
  8338. 0F862 A8 TAY
  8339. 0F863 B9 F9 D8 LDA DirectionTableOrdered,y
  8340. 0F866 85 01 STA temp1
  8341. 0F868 8A TXA
  8342. 0F869 85 00 STA temp
  8343. 0F86B 8A 48 A5 00 85 0C A5 01.. StartMoving temp, temp1
  8344. 0F87A
  8345. 0F87A A9 10 LDA #$10
  8346. 0F87C 85 A7 STA bulletTimer
  8347. 0F87E 68 PLA
  8348. 0F87F A8 TAY
  8349. 0F880 68 PLA
  8350. 0F881 AA TAX
  8351. 0F882
  8352. 0F882 60 RTS0F883 Script06:
  8353. 0F883 .include "Routines\BASE_4_5\Game\Space Birds\Input\shootProjectile.asm"
  8354. 0F883 ;;; Create a Projectile.
  8355. 0F883 ;;; Assumes that the projectile you want to create is in GameObject Slot 03.
  8356. 0F883 A5 A7 LDA bulletTimer
  8357. 0F885 F0 01 BEQ +canShoot
  8358. 0F887 ;; bullet timer not reset yet.
  8359. 0F887 ;; we will decrease bullet timer in game timer scripts.
  8360. 0F887 ;; and if it is zero, keep it at zero.
  8361. 0F887 60 RTS
  8362. 0F888 +canShoot
  8363. 0F888
  8364. 0F888 8A TXA
  8365. 0F889 48 PHA
  8366. 0F88A 98 TYA
  8367. 0F88B 48 PHA
  8368. 0F88C AE 6D 06 LDX player1_object
  8369. 0F88F BD 27 04 LDA Object_screen,x
  8370. 0F892
  8371. 0F892 85 0A STA tempD
  8372. 0F894 BD 1A 04 LDA Object_x_hi,x
  8373. 0F897 18 CLC
  8374. 0F898 69 04 ADC #$04
  8375. 0F89A 85 07 STA tempA
  8376. 0F89C BD 41 04 LDA Object_y_hi,x
  8377. 0F89F 18 CLC
  8378. 0F8A0 69 04 ADC #$04
  8379. 0F8A2 85 08 STA tempB
  8380. 0F8A4 BD A9 04 LDA Object_direction,x
  8381. 0F8A7 29 07 AND #%00000111
  8382. 0F8A9 85 09 STA tempC
  8383. 0F8AB 20 BA F1 E0 FF D0 03 4C.. CreateObjectOnScreen tempA, tempB, #$03, #$00, tempD
  8384. 0F8D1 ;;; x, y, object, starting action.
  8385. 0F8D1 ;;; and now with that object, copy the player's
  8386. 0F8D1 ;;; direction and start it moving that way.
  8387. 0F8D1 A5 09 LDA tempC
  8388. 0F8D3 9D A9 04 STA Object_direction,x
  8389. 0F8D6 A8 TAY
  8390. 0F8D7 B9 F9 D8 LDA DirectionTableOrdered,y
  8391. 0F8DA 85 01 STA temp1
  8392. 0F8DC 8A TXA
  8393. 0F8DD 85 00 STA temp
  8394. 0F8DF 8A 48 A5 00 85 0C A5 01.. StartMoving temp, temp1
  8395. 0F8EE
  8396. 0F8EE A9 10 LDA #$10
  8397. 0F8F0 85 A7 STA bulletTimer
  8398. 0F8F2 68 PLA
  8399. 0F8F3 A8 TAY
  8400. 0F8F4 68 PLA
  8401. 0F8F5 AA TAX
  8402. 0F8F6
  8403. 0F8F6 60 RTS0F8F7 Script07:
  8404. 0F8F7 .include "Routines\BASE_4_5\Game\Space Birds\Input\shootProjectile_Player2.asm"
  8405. 0F8F7 ;;; Create a Projectile.
  8406. 0F8F7 ;;; Assumes that the projectile you want to create is in GameObject Slot 04.
  8407. 0F8F7 A5 A9 LDA bulletTimer2
  8408. 0F8F9 F0 01 BEQ +canShoot
  8409. 0F8FB ;; bullet timer not reset yet.
  8410. 0F8FB ;; we will decrease bullet timer in game timer scripts.
  8411. 0F8FB ;; and if it is zero, keep it at zero.
  8412. 0F8FB 60 RTS
  8413. 0F8FC +canShoot
  8414. 0F8FC
  8415. 0F8FC 8A TXA
  8416. 0F8FD 48 PHA
  8417. 0F8FE 98 TYA
  8418. 0F8FF 48 PHA
  8419. 0F900 AE 6E 06 LDX player2_object
  8420. 0F903 BD 27 04 LDA Object_screen,x
  8421. 0F906
  8422. 0F906 85 0A STA tempD
  8423. 0F908 BD 1A 04 LDA Object_x_hi,x
  8424. 0F90B 18 CLC
  8425. 0F90C 69 04 ADC #$04
  8426. 0F90E 85 07 STA tempA
  8427. 0F910 BD 41 04 LDA Object_y_hi,x
  8428. 0F913 18 CLC
  8429. 0F914 69 04 ADC #$04
  8430. 0F916 85 08 STA tempB
  8431. 0F918 A9 02 LDA #FACE_RIGHT ;not the preferred fix but it will do for now.
  8432. 0F91A 29 07 AND #%00000111
  8433. 0F91C 85 09 STA tempC
  8434. 0F91E 20 BA F1 E0 FF D0 03 4C.. CreateObjectOnScreen tempA, tempB, #$04, #$00, tempD
  8435. 0F944 ;;; x, y, object, starting action.
  8436. 0F944 ;;; and now with that object, copy the player's
  8437. 0F944 ;;; direction and start it moving that way.
  8438. 0F944 A5 09 LDA tempC
  8439. 0F946 9D A9 04 STA Object_direction,x
  8440. 0F949 A8 TAY
  8441. 0F94A B9 F9 D8 LDA DirectionTableOrdered,y
  8442. 0F94D 85 01 STA temp1
  8443. 0F94F 8A TXA
  8444. 0F950 85 00 STA temp
  8445. 0F952 8A 48 A5 00 85 0C A5 01.. StartMoving temp, temp1
  8446. 0F961
  8447. 0F961 A9 10 LDA #$10
  8448. 0F963 85 A9 STA bulletTimer2
  8449. 0F965 68 PLA
  8450. 0F966 A8 TAY
  8451. 0F967 68 PLA
  8452. 0F968 AA TAX
  8453. 0F969
  8454. 0F969 60 RTS0F96A Script08:
  8455. 0F96A .include "Routines\BASE_4_5\Game\Space Birds\Input\startGameWithNewContinuePoints.asm"
  8456. 0F96A ;;; This script can be used as a start game input script.
  8457. 0F96A ;;; It will take you to the first screen and set up new continue points based on
  8458. 0F96A ;;; that screen's info.
  8459. 0F96A startGameWithNewContinuePoints:
  8460. 0F96A
  8461. 0F96A AD E0 06 LDA isTwoPlayerGame
  8462. 0F96D F0 66 BEQ +onePlayerGame
  8463. 0F96F ;; two player game
  8464. 0F96F AD B4 06 LDA screenUpdateByte
  8465. 0F972 09 04 ORA #%00000100
  8466. 0F974 8D B4 06 STA screenUpdateByte
  8467. 0F977
  8468. 0F977 AD C8 06 LDA warpToMap
  8469. 0F97A
  8470. 0F97A 8D A4 06 STA warpMap
  8471. 0F97D
  8472. 0F97D AD A3 06 LDA warpToScreen
  8473. 0F980 8D 74 06 STA currentNametable
  8474. 0F983
  8475. 0F983 AE 6D 06 LDX player1_object
  8476. 0F986 9D 27 04 STA Object_screen,x
  8477. 0F989
  8478. 0F989 BD 1A 04 LDA Object_x_hi,x
  8479. 0F98C 85 04 STA tempx
  8480. 0F98E BD 41 04 LDA Object_y_hi,x
  8481. 0F991 18 CLC
  8482. 0F992 69 80 ADC #$80
  8483. 0F994 85 05 STA tempy
  8484. 0F996
  8485. 0F996 AE 6E 06 LDX player2_object
  8486. 0F999 20 BA F1 E0 FF D0 03 4C.. CreateObject tempx, tempy, player2_object, #$00
  8487. 0F9C1
  8488. 0F9C1 A9 03 LDA #3
  8489. 0F9C3 85 A4 STA myLives
  8490. 0F9C5 85 AA STA player2Lives
  8491. 0F9C7
  8492. 0F9C7 A9 01 LDA #$01
  8493. 0F9C9 8D A5 06 STA screenTransitionType ;; is of warp type
  8494. 0F9CC
  8495. 0F9CC
  8496. 0F9CC AD AB 06 LDA gameHandler
  8497. 0F9CF 09 80 ORA #%10000000
  8498. 0F9D1 8D AB 06 STA gameHandler ;; this will set the next game loop to update the screen.
  8499. 0F9D4 60 RTS
  8500. 0F9D5
  8501. 0F9D5 +onePlayerGame
  8502. 0F9D5 AD C8 06 LDA warpToMap
  8503. 0F9D8
  8504. 0F9D8 8D A4 06 STA warpMap
  8505. 0F9DB
  8506. 0F9DB AD A3 06 LDA warpToScreen
  8507. 0F9DE 8D 74 06 STA currentNametable
  8508. 0F9E1
  8509. 0F9E1 AE 6D 06 LDX player1_object
  8510. 0F9E4 9D 27 04 STA Object_screen,x
  8511. 0F9E7
  8512. 0F9E7 A9 01 LDA #$01
  8513. 0F9E9 8D A5 06 STA screenTransitionType ;; is of warp type
  8514. 0F9EC
  8515. 0F9EC
  8516. 0F9EC AD AB 06 LDA gameHandler
  8517. 0F9EF 09 80 ORA #%10000000
  8518. 0F9F1 8D AB 06 STA gameHandler ;; this will set the next game loop to update the screen.
  8519. 0F9F4 60 RTS0F9F5 Script09:
  8520. 0F9F5 .include "Routines\BASE_4_5\test.asm"
  8521. 0F9F5 A9 02 lda #%00000010
  8522. 0F9F7 8D 8C 06 sta scrollByte
  8523. 0F9FA 60 rts0F9FB
  8524. 0F9FB ;; AI routines
  8525. 0F9FB AI_0:
  8526. 0F9FB .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8527. 0F9FB ;blank0F9FB 60 RTS
  8528. 0F9FC AI_1:
  8529. 0F9FC .include "Routines\BASE_4_5\Game\AI_Scripts\MoveRandom_8Dir.asm"
  8530. 0F9FC ;;;; Choose out of 4 directions, UDLR.
  8531. 0F9FC 8A TXA
  8532. 0F9FD 85 07 STA tempA
  8533. 0F9FF 20 DD DD JSR doGetRandomNumber
  8534. 0FA02 29 07 AND #%00000111
  8535. 0FA04 A8 TAY
  8536. 0FA05 B9 E9 D8 LDA DirectionTable,y
  8537. 0FA08 85 08 STA tempB
  8538. 0FA0A B9 F1 D8 LDA FacingTable,y
  8539. 0FA0D 85 09 STA tempC
  8540. 0FA0F 8A 48 A5 07 85 0C A5 08.. StartMoving tempA, tempB, #$00
  8541. 0FA1E 8A 48 A5 07 85 0C A5 09.. ChangeFacingDirection tempA, tempC
  8542. 0FA2D 60 RTS
  8543. 0FA2E AI_2:
  8544. 0FA2E .include "Routines\BASE_4_5\Game\AI_Scripts\StopMoving.asm"
  8545. 0FA2E ;;; stop moving.
  8546. 0FA2E BD A9 04 LDA Object_direction,x
  8547. 0FA31 29 07 AND #%00000111
  8548. 0FA33 9D A9 04 STA Object_direction,x
  8549. 0FA36
  8550. 0FA36 60 RTS
  8551. 0FA37 AI_3:
  8552. 0FA37 .include "Routines\BASE_4_5\Game\MOD_PlatformerBase\AI\MoveLeft.asm"
  8553. 0FA37 ;;;; Choose out of 4 directions, UDLR.
  8554. 0FA37 8A TXA
  8555. 0FA38 85 07 STA tempA
  8556. 0FA3A A9 06 LDA #%00000110 ;; "left"
  8557. 0FA3C A8 TAY
  8558. 0FA3D B9 F9 D8 LDA DirectionTableOrdered,y
  8559. 0FA40 85 08 STA tempB
  8560. 0FA42 B9 01 D9 LDA FacingTableOrdered,y
  8561. 0FA45 85 09 STA tempC
  8562. 0FA47 8A 48 A5 07 85 0C A5 08.. StartMoving tempA, tempB, #$00
  8563. 0FA56 8A 48 A5 07 85 0C A5 09.. ChangeFacingDirection tempA, tempC0FA65 60 RTS
  8564. 0FA66 AI_4:
  8565. 0FA66 .include "Routines\BASE_4_5\Game\AI_Scripts\MoveTowardsPlayer.asm"
  8566. 0FA66 ;;; aim towards player.
  8567. 0FA66 98 TYA
  8568. 0FA67 48 PHA
  8569. 0FA68 8A TXA
  8570. 0FA69 48 PHA
  8571. 0FA6A 85 04 STA tempx
  8572. 0FA6C
  8573. 0FA6C BD 1A 04 LDA Object_x_hi,x
  8574. 0FA6F 85 07 STA tempA
  8575. 0FA71 BD 41 04 LDA Object_y_hi,x
  8576. 0FA74 85 08 STA tempB
  8577. 0FA76 AE 6D 06 LDX player1_object
  8578. 0FA79 BD 1A 04 LDA Object_x_hi,x
  8579. 0FA7C 85 09 STA tempC
  8580. 0FA7E BD 41 04 LDA Object_y_hi,x
  8581. 0FA81 85 0A STA tempD
  8582. 0FA83
  8583. 0FA83 A6 04 LDX tempx
  8584. 0FA85
  8585. 0FA85 8A 48 98 48 A5 07 85 0C.. MoveTowardsPoint tempA, tempC, tempB, tempD
  8586. 0FAD2 BD A9 04 LDA Object_direction,x
  8587. 0FAD5 29 07 AND #%00000111
  8588. 0FAD7 09 08 ORA #%00001000
  8589. 0FAD9 9D A9 04 STA Object_direction,x
  8590. 0FADC
  8591. 0FADC 68 PLA
  8592. 0FADD AA TAX
  8593. 0FADE 68 PLA
  8594. 0FADF A8 TAY0FAE0 60 RTS
  8595. 0FAE1 AI_5:
  8596. 0FAE1 .include "Routines\BASE_4_5\Game\MOD_shooter\AI\ShootAtPlayer.asm"
  8597. 0FAE1 BD 1A 04 LDA Object_x_hi,x
  8598. 0FAE4 ;; plus x offset
  8599. 0FAE4 85 07 STA tempA
  8600. 0FAE6 BD 41 04 LDA Object_y_hi,x
  8601. 0FAE9 ;; plus y offset
  8602. 0FAE9 85 08 STA tempB
  8603. 0FAEB A9 02 LDA #$02 ;; game object to create.
  8604. 0FAED 85 09 STA tempC
  8605. 0FAEF A9 00 LDA #$00 ;; action step for that object
  8606. 0FAF1 85 0A STA tempD
  8607. 0FAF3 BD 27 04 LDA Object_screen,x
  8608. 0FAF6 85 06 STA tempz
  8609. 0FAF8
  8610. 0FAF8 20 BA F1 E0 FF D0 03 4C.. CreateObjectOnScreen tempA, tempB, tempC, tempD, tempz
  8611. 0FB1E 0FB1E 60 RTS
  8612. 0FB1F AI_6:
  8613. 0FB1F .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8614. 0FB1F ;blank0FB1F 60 RTS
  8615. 0FB20 AI_7:
  8616. 0FB20 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8617. 0FB20 ;blank0FB20 60 RTS
  8618. 0FB21 AI_8:
  8619. 0FB21 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8620. 0FB21 ;blank0FB21 60 RTS
  8621. 0FB22 AI_9:
  8622. 0FB22 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8623. 0FB22 ;blank0FB22 60 RTS
  8624. 0FB23 AI_A:
  8625. 0FB23 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8626. 0FB23 ;blank0FB23 60 RTS
  8627. 0FB24 AI_B:
  8628. 0FB24 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8629. 0FB24 ;blank0FB24 60 RTS
  8630. 0FB25 AI_C:
  8631. 0FB25 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8632. 0FB25 ;blank0FB25 60 RTS
  8633. 0FB26 AI_D:
  8634. 0FB26 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8635. 0FB26 ;blank0FB26 60 RTS
  8636. 0FB27 AI_E:
  8637. 0FB27 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8638. 0FB27 ;blank0FB27 60 RTS
  8639. 0FB28 AI_F:
  8640. 0FB28 .include "Routines\BASE_4_5\Game\Subroutines\blank.asm"
  8641. 0FB28 ;blank0FB28 60 RTS
  8642. 0FB29
  8643. 0FB29
  8644. 0FB29 AI_table_lo:
  8645. 0FB29 FB FC 2E 37 66 E1 1F 20 .db #<AI_0, #<AI_1, #<AI_2, #<AI_3, #<AI_4, #<AI_5, #<AI_6, #<AI_7
  8646. 0FB31 21 22 23 24 25 26 27 28 .db #<AI_8, #<AI_9, #<AI_A, #<AI_B, #<AI_C, #<AI_D, #<AI_E, #<AI_F
  8647. 0FB39
  8648. 0FB39 AI_table_hi:
  8649. 0FB39 F9 F9 FA FA FA FA FB FB .db #>AI_0, #>AI_1, #>AI_2, #>AI_3, #>AI_4, #>AI_5, #>AI_6, #>AI_7
  8650. 0FB41 FB FB FB FB FB FB FB FB .db #>AI_8, #>AI_9, #>AI_A, #>AI_B, #>AI_C, #>AI_D, #>AI_E, #>AI_F
  8651. 0FB49
  8652. 0FB49
  8653. 0FB49 DATABANK1 = #$18
  8654. 0FB49 ;9. Vectors
  8655. 0FB49 .include "Routines\BASE_4_5\System\Vectors.asm"
  8656. 0FB49 00 00 00 00 00 00 00 00.. .org $fff0
  8657. 0FFF0 E7 DE EC E6 DA E4 DE EB.. .db #$e7, #$De, #$ec, #$e6, #$da, #$e4, #$de, #$eb, #$05, #$00
  8658. 0FFFA ;.org $fffa
  8659. 0FFFA 0A C2 .dw NMI
  8660. 0FFFC 00 C0 .dw RESET
  8661. 0FFFE 00 00 .dw 00
  8662. 10000 10000
  8663.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement