/[projet1]/users/twilighte/Stormlord/NPC_Engine.s
Defence Force logotype

Contents of /users/twilighte/Stormlord/NPC_Engine.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 412 - (show annotations)
Thu Oct 7 20:50:23 2010 UTC (8 years, 8 months ago) by dbug
File size: 30571 byte(s)
Added Stormlord
1 ;NPC_Engine.s
2
3 ;NPC's are...
4 ; The launched Ball
5 ; Behaviour - The ball is pumped out of the ground launcher. It rises every 2 steps then is catapulted
6 ; vertically up where it well finally reach a height and decend. It will fall back into the
7 ; Launcher only to be pumped out again
8 ; Contact - Kills hero on contact
9 ; Quantity - 1
10 ; Initialise- Initialised by MapCode
11 ; The flying dragons
12 ; Behaviour - These fly in from left or right at byte level
13 ; Contact - Kills hero on contact
14 ; Quantity - Up to 5
15 ; Initialise- Initialised in Realtime
16 ; Acid Water drops
17 ; Behaviour - These fall from the clouds to the ground and disperse
18 ; Contact - Kills hero on contact (unless he carries the umbrella)
19 ; Quantity - Up to 5
20 ; Initialise- Initialised by MapCode
21 ; Triffid
22 ; Behaviour - These lye on the ground and will animate if affected by hero
23 ; Contact - Kills hero if he falls on them.
24 ; Quantity - 1
25 ; Initialise- Initialised by MapCode
26 ; Grubs
27 ; Behaviour - These rise from the ledges (only) then scurry to lower levels
28 ; Contact - Kills hero on contact
29 ; Quantity - Up to 5
30 ; Initialise- Initialised in Realtime
31 ; Bees
32 ; Behaviour - These(5?) swarm around blue vase but will be attracted to Honeypot
33 ; Contact - Kills hero on contact
34 ; Quantity - 5
35 ; Initialise- Initialised in Realtime
36 ; Egg Wasps
37 ; Behaviour - These fall from the sky as eggs which break on impact into wasp that oscillates vertically
38 ; Contact - Kills hero on contact
39 ; Quantity - Up to 5
40 ; Initialise- Initialised in Realtime
41 ; Fairy (Bonus sections only)
42 ; Behaviour - X using sine table byte steps, reinitiating on bounds, Y using sine table in x2 pixel steps
43 ; Contact - Hero fires hearts which fire vertically upwards and on hitting fairy it throws tear to ground
44 ; which remains on floor for 2 seconds that disappears.
45 ; Quantity - Up to 5
46 ; Initialise- Initialised in Realtime
47 ; Spider (New)
48
49 ;
50 ;Level 1
51 ;0 Ball
52 ;14 Grubs
53 ;28 Grubs
54 ;42 Triffid,Ball
55 ;56 Ball,Triffidx2,Bees(Depends on honeypot)
56 ;70 Bees
57 ;84 Triffid,Eggs
58 ;98 Triffid,Ball,Eggs
59 ;112 Ball
60 ;126 Ballx2,Rain drops
61 ;140 Ballx2,Rain drops
62 ;154 Dragons
63 ;168 Bees(swarm around key)
64 ;182 Bees(around key or honeypot),Triffidx2
65 ;196 Triffid,Ball
66 ;210 -
67 ;224 Bonus Level
68 ;248 -
69
70 NPCControl
71 lda ssnpc_Type
72 .(
73 bmi skip2
74 jsr SpawnRealtimeNPC
75 skip2 ;Control NPC setup in the Map Code
76 ldx NPCUltimateIndex
77 bmi skip1
78 loop1 ldy NPC_Activity,x
79 lda NPCActivityVectorLo,y
80 sta vector1+1
81 lda NPCActivityVectorHi,y
82 sta vector1+2
83 stx npcc_TempX
84 vector1 jsr $dead
85 ldx npcc_TempX
86 dex
87 bpl loop1
88 skip1 rts
89 .)
90
91 ;Plot Sprite with Mask
92 ;screen
93 ;SpriteFrame
94 ;Preserve X
95 PlotSpriteWithMask
96 stx pswm_TempX
97 ldy SpriteFrame
98 lda gfxSpriteBMPLo,y
99 sta graphic
100 lda gfxSpriteBMPHi,y
101 sta graphic+1
102 lda gfxSpriteMSKLo,y
103 sta mask
104 lda gfxSpriteMSKHi,y
105 sta mask+1
106 lda gfxSpriteWidth,y
107 sta pswm_TempW
108 ldx gfxSpriteHeight,y
109 .(
110 loop2 ldy pswm_TempW
111 dey
112 loop1 lda (screen),y
113 bpl ProcNormal
114 ProcInverse
115 eor #63
116 and (mask),y
117 ora (graphic),y
118 eor #63+128
119 jmp ProcContinue
120 ProcNormal
121 and (mask),y
122 ora (graphic),y
123 ProcContinue
124 sta (screen),y
125 dey
126 bpl loop1
127
128 lda graphic
129 clc
130 adc pswm_TempW
131 sta graphic
132 lda graphic+1
133 adc #00
134 sta graphic+1
135
136 lda screen
137 adc #40
138 sta screen
139 lda screen+1
140 adc #00
141 sta screen+1
142
143 lda mask
144 adc pswm_TempW
145 sta mask
146 lda mask+1
147 adc #00
148 sta mask+1
149
150 dex
151 bne loop2
152 .)
153 ldx pswm_TempX
154 rts
155
156 RestoreSpriteBG
157 stx rsbg_RestorationOfX+1
158 ldy NPC_ScreenY,x
159 lda NPC_ScreenX,x
160 RestoreSpriteBG2
161 sec
162 sbc #1
163 jsr RecalcBGBuff
164
165 ldy SpriteFrame
166 lda gfxSpriteWidth,y
167 sta pswm_TempW
168 ldx gfxSpriteHeight,y
169 .(
170 loop2 ldy pswm_TempW
171 dey
172 loop1 lda (bgbuff),y
173 sta (screen),y
174 dey
175 bpl loop1
176
177 jsr nlBgbuff
178 jsr nlScreen
179 dex
180 bne loop2
181 .)
182 rsbg_RestorationOfX
183 ldx #00
184 rts
185
186
187 ;On each new screen flip or level load the possible screen NPC's are set to Init
188 ;NPC Activities
189 ;00 Ball Rising
190 ; rising 2 pixels using frames less mask
191 ;01 Ball Bounce
192 ; Rising and falling using 2's compliment with mask
193 ;02 Ball Delay
194 ; Delay before ball rises again
195
196 ;02 Dragon Initiate
197 ; Init based on hero not being at sides
198 ; Direction based on side of screen hero is
199 ; Height is random
200 ;03 Dragon Flight Left
201 ;04 Dragon Flight Right
202 ;05 Dragon Death
203 ;06 Acid Drop Initiate
204 ; Decent step between 2 and 4(creating parralax)
205 ; X pos random along length of cloud
206 ;07 Acid Drop flight
207 ;08 Acid drop land and dissipate
208 ;09 Triffid Animate
209 ;10 TriffidMonitoring
210 ;11 Grub Initiate
211 ;12 Grub Rise and look
212 ;13 Grub scurry Left
213 ;14 Grub scurry right
214 ;15 Grub Fall
215 ;16 Grub Death
216 ;17 Bees flight
217 ; moving in random direction but centred around object
218 ;18 Egg Wasps Initiate
219 ; From top of screen
220 ; Decent rate always the same
221 ;19 Egg Decent
222 ;20 Egg Hatch
223 ;21 Wasp Attack
224 ; Wasp homes on hero with oversteer
225 ;22 Wasp Death
226 NPCActivityVectorLo
227 .byt <BallRising ;0
228 .byt <BallBounce ;1
229 .byt <BallPause ;2
230 .byt <GrubPeep ;3
231 .byt <GrubMove ;4
232 .byt <RainDrop ;5
233 .byt <EggWasp ;6
234 .byt <DragonLeft ;7
235 .byt <DragonRight ;8
236 .byt <BeeBuzz ;9
237 .byt <Destroy ;10
238 .byt <Spider ;11
239 .byt <Triffid ;12
240 .byt <ChannelFairy ;13
241 .byt <ThrownTear ;14
242
243 NPCActivityVectorHi
244 .byt >BallRising
245 .byt >BallBounce
246 .byt >BallPause
247 .byt >GrubPeep
248 .byt >GrubMove
249 .byt >RainDrop
250 .byt >EggWasp ;6
251 .byt >DragonLeft ;7
252 .byt >DragonRight ;8
253 .byt >BeeBuzz ;9
254 .byt >Destroy ;10
255 .byt >Spider ;11
256 .byt >Triffid ;12
257 .byt >ChannelFairy ;13
258 .byt >ThrownTear ;14
259
260 BallRising
261 ;Display this frame(3x9)
262 lda NPC_Progress,x
263 clc
264 adc #NPCF_BALL0
265 sta SpriteFrame
266
267 ldy NPC_ScreenY,x
268 lda NPC_ScreenX,x
269 jsr RecalcScreen
270
271 jsr PlotSpriteWithMask
272
273 ;Write to Collision Map
274 lda NPC_ScreenX,x
275 ldy NPC_ScreenY,x
276 jsr PlotNPCInCollisionMap
277
278 ;Progress NPC
279 lda NPC_Progress,x
280 adc #1
281 cmp #3
282 bcs CatapultBall
283 sta NPC_Progress,x
284 rts
285
286 CatapultBall
287 lda #NPCA_BALLBOUNCE
288 sta NPC_Activity,x
289 lda #249
290 sta NPC_Progress,x
291
292 rts
293
294 ;A == X(0-39)
295 ;Y == Y(0-137)
296 RecalcScreen
297 ;(Yx40)+X+$A000
298 sta TempRX
299 lda #00
300 sta screen+1
301 tya
302
303 ;Yx8
304 asl
305 rol screen+1
306 asl
307 rol screen+1
308 asl
309 rol screen+1
310 sta TempLo
311 ldy screen+1
312
313 ;Yx32
314 asl
315 rol screen+1
316 asl
317 rol screen+1
318
319 ;Yx8 + Yx32
320 adc TempLo
321 sta screen
322 tya
323 adc screen+1
324 tay
325
326 ;+X
327 lda screen
328 adc TempRX
329 sta screen
330
331 ;+$A000
332 tya
333 adc #$A0
334 sta screen+1
335 rts
336
337 ;A == X
338 ;Y == Y
339 RecalcBGBuff
340 ;(Yx40)+X+(>BackgroundBuffer)
341 sta TempRX
342 lda #00
343 sta bgbuff+1
344 tya
345 sec
346 sbc #30
347
348 ;Yx8
349 asl
350 rol bgbuff+1
351 asl
352 rol bgbuff+1
353 asl
354 rol bgbuff+1
355 sta TempLo
356 ldy bgbuff+1
357
358 ;Yx32
359 asl
360 rol bgbuff+1
361 asl
362 rol bgbuff+1
363
364 ;Yx8 + Yx32
365 adc TempLo
366 sta bgbuff
367 tya
368 adc bgbuff+1
369 tay
370
371 ;+X
372 lda bgbuff
373 adc TempRX
374 sta bgbuff
375
376 ;+(>BackgroundBuffer)
377 tya
378 adc #>BackgroundBuffer
379 sta bgbuff+1
380 rts
381
382 BallBounce
383 ;Delete Old Frame
384 ldy NPC_ScreenY,x
385 lda NPC_ScreenX,x
386 jsr RecalcScreen
387 lda #NPCF_BALL3
388 sta SpriteFrame
389 jsr RestoreSpriteBG
390
391 ;Remove from Collision map
392 lda NPC_ScreenX,x
393 ldy NPC_ScreenY,x
394 jsr RemoveNPCFromCollisionMap
395
396 ;Progress Ball
397 lda NPC_ScreenY,x
398 clc
399 adc NPC_Progress,x
400 and #$FE ;Allign to 2 steps
401 cmp #106
402 bcs BackInLauncher
403 sta NPC_ScreenY,x
404 inc NPC_Progress,x
405
406 ldy NPC_ScreenY,x
407 lda NPC_ScreenX,x
408 jsr RecalcScreen
409
410 ;Plot Sprite
411 jsr PlotSpriteWithMask
412
413 ;Write to Collision Map
414 lda NPC_ScreenX,x
415 ldy NPC_ScreenY,x
416 jmp PlotNPCInCollisionMap
417
418 BackInLauncher
419 ;Process to Pause phase
420 lda #NPCA_BALLPAUSE
421 sta NPC_Activity,x
422 lda #00
423 sta NPC_Progress,x
424 rts
425
426 BallPause
427 ;
428 lda NPC_Progress,x
429 .(
430 bne skip1
431 ;First time - Delete Ball
432 ldy NPC_ScreenY,x
433 lda NPC_ScreenX,x
434 jsr RecalcScreen
435 lda #NPCF_BALL3
436 sta SpriteFrame
437 jsr RestoreSpriteBG
438
439 ;Remove from Collision map
440 lda NPC_ScreenX,x
441 ldy NPC_ScreenY,x
442 jsr RemoveNPCFromCollisionMap
443
444 skip1 ;Progress Ball Pause
445 .)
446 lda NPC_Progress,x
447 adc #1
448 cmp #10
449 bcs BackToRise
450 sta NPC_Progress,x
451 rts
452
453 BackToRise
454 ;Process to Pause phase
455 lda #NPCA_BALLRISING
456 sta NPC_Activity,x
457 lda #00
458 sta NPC_Progress,x
459 lda NPC_ScreenXOrigin,x
460 sta NPC_ScreenX,x
461 lda NPC_ScreenYOrigin,x
462 sta NPC_ScreenY,x
463 lda #SFX_LAUNCHER
464 jsr KickSFX
465 rts
466
467 GrubPeep
468 ;Peep Left/Right 4 times before proceeding to GrubMove
469 dec NPC_Progress,x
470 bmi OnToGrubMove
471 lda NPC_Direction,x
472 beq GrubPeepLeft
473 GrubPeepRight
474 lda #NPCF_GRUBPEEPRIGHT
475 sta SpriteFrame
476 jmp GrubPeepRent1
477 GrubPeepLeft
478 lda #NPCF_GRUBPEEPLEFT
479 sta SpriteFrame
480 GrubPeepRent1
481 dec NPC_Special,x
482 .(
483 bne skip1
484 lda #4
485 sta NPC_Special,x
486 lda NPC_Direction,x
487 eor #2
488 sta NPC_Direction,x
489
490 skip1 ldy NPC_ScreenY,x
491 .)
492 lda NPC_ScreenX,x
493 jsr RecalcScreen
494 jsr PlotSpriteWithMask
495
496 ;Write to Collision Map
497 lda NPC_ScreenX,x
498 adc #2
499 ldy NPC_ScreenY,x
500 jmp PlotNPCInCollisionMap
501
502 OnToGrubMove
503 lda #NPCA_GRUBMOVE
504 sta NPC_Activity,x
505 lda #00
506 sta NPC_Progress,x
507 ; jsr GetRandomNumber
508 ; sta NPC_Special,x ;This indicates its life span
509 rts
510 GrubMove
511 ;Delete Old Frame
512 ldy NPC_ScreenY,x
513 lda NPC_ScreenX,x
514 jsr RecalcScreen
515 lda #NPCF_GRUBMOVELEFT0
516 sta SpriteFrame
517 jsr RestoreSpriteBG
518
519 ;Remove from Collision map
520 lda NPC_ScreenX,x
521 adc #2
522 ldy NPC_ScreenY,x
523 jsr RemoveNPCFromCollisionMap
524
525 ;Check lifespan
526 ; dec NPC_Special,x
527 ;.(
528 ; bne skip1
529 ; ;Setup New Grub
530 ; jsr SetupNewGrub
531 ; ;Destroy Grub
532 ; txa
533 ; tay
534 ; jsr HitNPC2
535 ;skip1 ;Progress Grub
536 ;.)
537 lda NPC_ScreenY,x
538 adc #6
539 tay
540 lda NPC_ScreenX,x
541 adc #2
542 jsr FetchCollisionCell
543 beq FallingGrub
544
545 lda NPC_Direction,x
546 bne GrubMoveRight
547 GrubMoveLeft
548 ;Check left collision
549 lda NPC_ScreenX,x
550 sec
551 sbc #1
552 ldy NPC_ScreenY,x
553 jsr FetchCollisionCell
554 bne InvertGrubDirection
555 dec NPC_ScreenX,x
556 jmp GrubContinue
557 GrubMoveRight
558 ;Check Right collision
559 lda NPC_ScreenX,x
560 clc
561 adc #5
562 ldy NPC_ScreenY,x
563 jsr FetchCollisionCell
564 bne InvertGrubDirection
565 inc NPC_ScreenX,x
566 jmp GrubContinue
567 FallingGrub
568 lda NPC_ScreenY,x
569 adc #5
570 and #$FE ;Force Allignment
571 sta NPC_ScreenY,x
572 jmp GrubContinue
573 InvertGrubDirection
574 lda NPC_Direction,x
575 eor #2
576 sta NPC_Direction,x
577 GrubContinue
578 ;Set frame based on direction(0 or 2)
579 lda NPC_Progress,x
580 eor #1
581 sta NPC_Progress,x
582 ora NPC_Direction,x
583 clc
584 adc #NPCF_GRUBMOVELEFT0
585 sta SpriteFrame
586
587 ldy NPC_ScreenY,x
588 lda NPC_ScreenX,x
589 jsr RecalcScreen
590
591 ;Plot Sprite
592 jsr PlotSpriteWithMask
593
594 ;Write to Collision Map
595 lda NPC_ScreenX,x
596 clc
597 adc #2
598 ldy NPC_ScreenY,x
599 jmp PlotNPCInCollisionMap
600
601
602 RainDrop
603 ;Delete Old Frame
604 ldy NPC_ScreenY,x
605 lda NPC_ScreenX,x
606 jsr RecalcScreen
607 lda #NPCF_RAINDROP
608 sta SpriteFrame
609 jsr RestoreSpriteBG
610
611 ;Remove from Collision map
612 lda NPC_ScreenX,x
613 ldy NPC_ScreenY,x
614 jsr RemoveNPCFromCollisionMap
615
616
617 ;Progress Droplet
618 lda NPC_ScreenY,x
619 adc NPC_Progress,x
620 and #$FE ;Row Allign
621 ;Check no rogue ones reach beyond boundary
622 cmp #120
623 bcs RestartRainDrop
624 sta NPC_ScreenY,x
625 ;And check when they hit an object
626 tay
627 lda NPC_ScreenX,x
628 adc #1
629 jsr CheckForBackgroundInCollisionMap
630 bcs RestartRainDrop
631
632 ldy NPC_ScreenY,x
633 lda NPC_ScreenX,x
634 jsr RecalcScreen
635
636 ;Plot Sprite
637 jsr PlotSpriteWithMask
638
639 ;Write to Collision Map
640 lda NPC_ScreenX,x
641 ldy NPC_ScreenY,x
642 jmp PlotNPCInCollisionMap
643
644 RestartRainDrop
645 txa
646 and #3
647 clc
648 adc NPC_ScreenXOrigin,x
649 sta NPC_ScreenX,x
650 lda NPC_ScreenYOrigin,x
651 sta NPC_ScreenY,x
652 lda VIA_T2LL
653 and #7
654 ora #2
655 sta NPC_Progress,x
656 lda #SFX_RAINDROP
657 jsr KickSFX
658 rts
659
660 Spider ;Delete Old Frame
661 ldy NPC_ScreenY,x
662 lda NPC_ScreenX,x
663 jsr RecalcScreen
664 lda #NPCF_SPIDER0
665 sta SpriteFrame
666 jsr RestoreSpriteBG
667
668 ;Remove from Collision map
669 lda NPC_ScreenX,x
670 clc
671 adc #1
672 ldy NPC_ScreenY,x
673 jsr RemoveNPCFromCollisionMap
674
675 ;Progress Spider
676 lda NPC_ScreenY,x
677 adc NPC_Direction,x
678 and #$FE
679 cmp #32
680 .(
681 bcc ChangeDirection
682 cmp #120
683 bcs ChangeDirection
684 sta NPC_ScreenY,x
685
686 tay
687 lda NPC_ScreenX,x
688 clc
689 adc #1
690 jsr CheckForBackgroundInCollisionMap
691 bcc skip1
692 ChangeDirection
693 ;Kick Spider SFX
694 lda #SFX_SPIDER
695 jsr KickSFX
696 ;Change direction
697 lda NPC_Direction,x
698 ;Direction is either 2(00000010) or 254(11111110) so eor with 252(11111100)
699 eor #252
700 sta NPC_Direction,x
701
702 skip1
703 .)
704
705 ;Fetch BGBuff address
706 ldy NPC_ScreenY,x
707 lda NPC_ScreenX,x
708 sec
709 sbc #1
710 jsr RecalcBGBuff
711
712 ;Is Spider descending?
713 lda NPC_Direction,x
714 .(
715 bmi skip2
716 ;Spider Descending - plot thread
717 ldy #01
718 lda #%01001000
719 sta (bgbuff),y
720 lda #%01000100
721 ldy #41
722 sta (bgbuff),y
723 jmp skip1
724 skip2 ;Spider ascending - Delete Thread
725 ldy #01
726 lda #%01000000
727 sta (bgbuff),y
728 lda #%01000000
729 ldy #41
730 sta (bgbuff),y
731
732 skip1 ;Select frame
733 .)
734 lda NPC_ScreenY,x
735 lsr
736 lsr
737 lsr
738 lda #32
739 adc #00
740 sta SpriteFrame
741
742 ;Plot Sprite
743 ldy NPC_ScreenY,x
744 lda NPC_ScreenX,x
745 jsr RecalcScreen
746 jsr PlotSpriteWithMask
747
748 ;Write to Collision Map
749 lda NPC_ScreenX,x
750 clc
751 adc #1
752 ldy NPC_ScreenY,x
753 jmp PlotNPCInCollisionMap
754
755 Triffid ;The triffid doesn't do anything until the hero treds or falls on it
756 ;and then it animates between frames
757 rts
758
759 ;The humble bee must revolve around the object until such time as the honey pot appears
760 ;whereby the object origin will gradually move to the honeypot
761 BeeBuzz
762 ; nop
763 ; jmp BeeBuzz
764 ;Delete Old Frame(Observing shifted position)
765 ldy NPC_ScreenX,x
766 lda XLOC,y
767 ldy NPC_ScreenY,x
768 jsr RecalcScreen
769 lda #NPCF_BEE
770 sta SpriteFrame
771 stx rsbg_RestorationOfX+1
772 ldy NPC_ScreenX,x
773 lda XLOC,y
774 ldy NPC_ScreenY,x
775 jsr RestoreSpriteBG2
776
777 ;Remove from Collision map
778 ldy NPC_ScreenX,x
779 lda XLOC,y
780 clc
781 adc #1
782 ldy NPC_ScreenY,x
783 jsr RemoveNPCFromCollisionMap
784
785 ;Progress Bee
786 ;Bees must buzz around a set point so that when the honeypot arrives the single point can be moved
787 ;instead of each individual bee
788 ;So they should use a 2's compliment signed sine table then have a random index for both x and y to create
789 ;a movement pattern similar to the wave demo for wurlde.
790
791 inc NPC_Progress,x
792 inc NPC_Progress,x
793 ldy NPC_Progress,x ;Bee Sine Index
794 lda BeeOriginY ;The common position that will change if honeypot dropped near
795 clc
796 adc SignedSineTable,y ;256x(-7 to +7) Imperfect sine
797 ora #1
798 sta NPC_ScreenY,x
799 ;For X use same index eored with 128
800 tya
801 clc
802 adc #128
803 tay
804 lda BeeOriginX
805 clc
806 adc SignedSineTable,y
807 sta NPC_ScreenX,x
808
809 ;Use X to find correct Bee frame
810 tay
811 lda BitIndex,y
812 ;Which returns a number 0 to 5
813 clc
814 adc #NPCF_BEE
815 sta SpriteFrame
816
817 ;X is pixel based so fetch byte offset
818 ldy NPC_ScreenX,x
819 lda XLOC,y
820 ldy NPC_ScreenY,x
821 jsr RecalcScreen
822
823 ;Plot Sprite
824 jsr PlotSpriteWithMask
825
826 ;Write to Collision Map
827 ldy NPC_ScreenX,x
828 lda XLOC,y
829 clc
830 adc #1
831 ldy NPC_ScreenY,x
832
833 ;A==X Pos
834 ;Y==Y Pos
835 ;X==NPC Index
836 PlotNPCInCollisionMap
837 ;Fetch top left Location and size of NPC in collision map
838 jsr FetchCollisionLocAndSizeOfNPC
839
840 .(
841 loop2 ldy CollisionWidth
842 dey
843 loop1 lda (cmap),y
844 and #15
845 ora NPCCollisionID,x
846 sta (cmap),y
847 dey
848 bpl loop1
849 lda cmap
850 clc
851 adc #40
852 sta cmap
853 bcc skip1
854 inc cmap+1
855 skip1 dec CollisionHeightCount
856 bne loop2
857 .)
858 rts
859
860
861 FetchCollisionLocAndSizeOfNPC
862 clc
863 adc CollisionMapYLOCL-30,y
864 sta cmap
865 lda CollisionMapYLOCH-30,y
866 adc #00
867 sta cmap+1
868
869 ;Calculate size of NPC
870 ldy NPC_Activity,x
871 lda Action2CollisionHeight,y
872 sta CollisionHeightCount
873 lda Action2CollisionWidth,y
874 sta CollisionWidth
875 rts
876
877 ; ldy #00
878 ; lda (cmap),y
879 ; and #15
880 ; ora NPCCollisionID,x
881 ; sta (cmap),y
882 ; rts
883
884 ;Collision cell represents 6x6 pixels on screen
885 Action2CollisionWidth
886 .byt 2 ;BALLRISING 0
887 .byt 2 ;BALLBOUNCE 1
888 .byt 1 ;BALLPAUSE 2
889 .byt 1 ;GRUBPEEP 3
890 .byt 3 ;GRUBMOVE 4
891 .byt 1 ;RAINDROP 5
892 .byt 2 ;EGGWASP 6
893 .byt 4 ;DRAGONLEFT 7
894 .byt 4 ;DRAGONRIGHT 8
895 .byt 1 ;BEE 9
896 .byt 2 ;EXPLODE 10
897 .byt 2 ;SPIDER 11
898 .byt 3 ;TRIFFID 12
899 .byt 3 ;FAIRY 13
900 .byt 1 ;THROWNTEAR 14
901 .byt 1 ;FLOORTEAR 15
902 .byt 1 ;MELTTEAR 16
903 Action2CollisionHeight
904 .byt 1 ;BALLRISING 0
905 .byt 2 ;BALLBOUNCE 1
906 .byt 1 ;BALLPAUSE 2
907 .byt 1 ;GRUBPEEP 3
908 .byt 1 ;GRUBMOVE 4
909 .byt 1 ;RAINDROP 5
910 .byt 2 ;EGGWASP 6
911 .byt 1 ;DRAGONLEFT 7
912 .byt 1 ;DRAGONRIGHT 8
913 .byt 1 ;BEE 9
914 .byt 2 ;EXPLODE 10
915 .byt 2 ;SPIDER 11
916 .byt 2 ;TRIFFID 12
917 .byt 3 ;FAIRY 13
918 .byt 1 ;THROWNTEAR 14
919 .byt 1 ;FLOORTEAR 15
920 .byt 1 ;MELTTEAR 16
921
922 RemoveNPCFromCollisionMap
923 ;Fetch top left Location and size of NPC in collision map
924 jsr FetchCollisionLocAndSizeOfNPC
925
926 .(
927 loop2 ldy CollisionWidth
928 dey
929 loop1 lda (cmap),y
930 and #15
931 sta (cmap),y
932 dey
933 bpl loop1
934 lda cmap
935 clc
936 adc #40
937 sta cmap
938 bcc skip1
939 inc cmap+1
940 skip1 dec CollisionHeightCount
941 bne loop2
942 .)
943 rts
944
945 CheckForBackgroundInCollisionMap
946 ;Fetch top left Location and size of NPC in collision map
947 jsr FetchCollisionLocAndSizeOfNPC
948
949 .(
950 loop2 ldy CollisionWidth
951 dey
952 loop1 lda (cmap),y
953 and #15
954 cmp #1
955 bcs skip2
956 dey
957 bpl loop1
958 lda cmap
959 clc
960 adc #40
961 sta cmap
962 bcc skip1
963 inc cmap+1
964 skip1 dec CollisionHeightCount
965 bne loop2
966 clc
967 skip2 rts
968 .)
969
970 ; clc
971 ; adc CollisionMapYLOCL-30,y
972 ; sta cmap
973 ; lda CollisionMapYLOCH-30,y
974 ; adc #00
975 ; sta cmap+1
976 ; ldy #00
977 ; lda (cmap),y
978 ; and #15
979 ; cmp #1
980 ; rts
981
982 ;B4-7 Sprite Collisions
983 ; 00 Background
984 ; 01-0C NPC Index
985 NPCCollisionID
986 .byt 16*1
987 .byt 16*2
988 .byt 16*3
989 .byt 16*4
990 .byt 16*5
991 .byt 16*6
992 .byt 16*7
993 .byt 16*8
994 .byt 16*9
995 .byt 16*10
996 .byt 16*11
997 .byt 16*12
998
999
1000
1001
1002 Destroy
1003 ; nop
1004 ; jmp Destroy
1005 ;The explosion action cycles once through the 6 explosion frames repeating the frame
1006 ;X number of times right as specified in NPC_Count
1007 ;The position for the leftmost explosion is always held in Origin
1008 ;ie. Dragon is 4 bytes wide so NPC_Count would be 2
1009 lda #00
1010 sta TempCount
1011 .(
1012 loop1 ;Multiply current count by 2
1013 lda TempCount
1014 asl
1015 ;And add to screen X origin
1016 adc NPC_ScreenXOrigin,x
1017 sta NPC_ScreenX,x
1018
1019 ;Set the y position to Origin
1020 lda NPC_ScreenYOrigin,x
1021 sta NPC_ScreenY,x
1022
1023 ;Set the frame to NPC_Progress
1024 lda NPC_Progress,x
1025 sta SpriteFrame
1026
1027 ldy NPC_ScreenY,x
1028 lda NPC_ScreenX,x
1029 jsr RecalcScreen
1030
1031 jsr PlotSpriteWithMask
1032
1033 inc TempCount
1034 lda TempCount
1035 cmp NPC_Count,x
1036 bcc loop1
1037 .)
1038 ;Progress NPC
1039 lda NPC_Progress,x
1040 clc
1041 adc #1
1042 cmp #NPCF_AFTEREXPLODE
1043 bcs RemoveExplosion
1044 sta NPC_Progress,x
1045 rts
1046
1047 RemoveExplosion
1048 ;Remove NPC and restore bg over screen area
1049 lda NPC_Count,x
1050 sta TempCount
1051 .(
1052 loop1 lda NPC_ScreenXOrigin,x
1053 ldy NPC_ScreenYOrigin,x
1054 jsr RecalcScreen
1055 lda NPC_ScreenXOrigin,x
1056 ldy NPC_ScreenYOrigin,x
1057 stx rsbg_RestorationOfX+1
1058 jsr RestoreSpriteBG2
1059 inc NPC_ScreenXOrigin,x
1060 inc NPC_ScreenXOrigin,x
1061 dec TempCount
1062 bne loop1
1063 .)
1064 ;Another problem is that if the width and/or height of the original NPC is slightly larger than
1065 ;explosion then we end up with artifacts on screen so keep
1066 ;record of original NPC Frame and restore BG
1067 lda NPC_SpriteFrame,x
1068 sta SpriteFrame
1069 ldy NPC_ScreenY,x
1070 lda NPC_ScreenX,x
1071 jsr RecalcScreen
1072 stx rsbg_RestorationOfX+1
1073 ldy NPC_ScreenY,x
1074 lda NPC_ScreenX,x
1075 jsr RestoreSpriteBG2
1076
1077 jmp DestroyDragon
1078
1079 FetchCollisionCell
1080 clc
1081 adc CollisionMapYLOCL-30,y
1082 .(
1083 sta vector1+1
1084 lda CollisionMapYLOCH-30,y
1085 adc #00
1086 sta vector1+2
1087 vector1 lda $dead
1088 .)
1089 rts
1090
1091
1092 ;DragonInitiate
1093 ;DragonFlightLeft
1094 ;DragonFlightRight
1095 ;DragonDeath
1096 ;AcidDropInitiate
1097 ;AcidDropFlight
1098 ;AcidDropLandAndDissipate
1099 ;TriffidAnimate
1100 ;TriffidMonitoring
1101 ;GrubInitiate
1102 ;GrubRiseAndLook
1103 ;GrubScurryLeft
1104 ;GrubScurryRight
1105 ;GrubFall
1106 ;GrubDeath
1107 ;BeesFlight
1108 ;EggWaspsInitiate
1109 ;EggDescent
1110 ;EggHatch
1111 ;WaspAttack
1112 ;WaspDeath
1113
1114 SpawnRealtimeNPC
1115 beq SpawnDragon
1116 cmp #1
1117 beq SpawnEggWasps
1118 jmp SpawnFairy
1119
1120 SpawnDragon
1121 ;Dragons appear on left or right of screen and swoop down then up
1122 dec DelayBetweenRRNPC
1123 .(
1124 bne skip1
1125 lda #20
1126 sta DelayBetweenRRNPC
1127 ;Avoid spawning dragon if hero close to side
1128 lda HeroX
1129 cmp #6
1130 bcc skip1
1131 cmp #35
1132 bcs skip1
1133 ;Spawn Dragon
1134 jsr FetchNewNPCIndex
1135 bcs skip1
1136 ;Randomise Y position (40-103)
1137 jsr GetRandomNumber
1138 and #31
1139 clc
1140 adc #50
1141 sta NPC_ScreenY,y
1142 lda #2 ;Initially swoop down
1143 sta NPC_Direction,y
1144 ;The direction of the dragons depends on the direction the hero is facing
1145 lda HeroFrame
1146 cmp #8
1147 bcs ApproachFromLeft
1148 ApproachFromRight
1149 ;Moving left
1150 lda #NPCA_DRAGONLEFT
1151 sta NPC_Activity,y
1152 lda #39-5
1153 sta NPC_ScreenX,y
1154 rts
1155 ApproachFromLeft
1156 ;Moving right
1157 lda #NPCA_DRAGONRIGHT
1158 sta NPC_Activity,y
1159 lda #1
1160 sta NPC_ScreenX,y
1161 skip1 rts
1162 .)
1163
1164
1165 SpawnEggWasps
1166 ;Egg wasps float down from above, crack then turn into wasps that home in on hero
1167 ;with potential over-run
1168 dec DelayBetweenRRNPC
1169 .(
1170 bne skip1
1171 lda #20
1172 sta DelayBetweenRRNPC
1173 ;Spawn Egg
1174 jsr FetchNewNPCIndex
1175 bcs skip1
1176 ;Set progress to falling Egg
1177 lda #00
1178 sta NPC_Progress,y
1179 lda #NPCA_EGGWASP
1180 sta NPC_Activity,y
1181 ;Randomise X
1182 jsr GetRandomNumber
1183 and #15
1184 clc
1185 adc #18
1186 sta NPC_ScreenX,y
1187 ;Set Y to 30
1188 lda #31
1189 sta NPC_ScreenY,y
1190 skip1 rts
1191 .)
1192
1193 EggWasp ;6
1194 lda NPC_Progress,x
1195 ;00 Descending Egg
1196 ;01 Breaking Egg
1197 ;80 Swarming Wasp
1198 .(
1199 bpl skip1
1200 jmp SwarmingWasp
1201 skip1 bne HatchingEgg
1202 .)
1203 ;Descending Egg
1204
1205 ;Delete Old Frame
1206 ldy NPC_ScreenY,x
1207 lda NPC_ScreenX,x
1208 jsr RecalcScreen
1209 lda #NPCF_EGG
1210 sta SpriteFrame
1211 jsr RestoreSpriteBG
1212
1213 ;Remove from Collision map
1214 lda NPC_ScreenX,x
1215 ldy NPC_ScreenY,x
1216 jsr RemoveNPCFromCollisionMap
1217
1218 ;Progress Egg
1219 inc NPC_ScreenY,x
1220 inc NPC_ScreenY,x
1221 inc NPC_ScreenY,x
1222 inc NPC_ScreenY,x
1223
1224 ;Check Collision below
1225 lda NPC_ScreenY,x
1226 cmp #120
1227 bcs ProceedToHatching
1228 adc #12
1229 tay
1230 lda NPC_ScreenX,x
1231 adc #1
1232 jsr CheckForBackgroundInCollisionMap
1233 bcs ProceedToHatching
1234
1235 ;Plot Sprite
1236 ldy NPC_ScreenY,x
1237 lda NPC_ScreenX,x
1238 jsr RecalcScreen
1239 jsr PlotSpriteWithMask
1240
1241 ;Write to Collision Map
1242 lda NPC_ScreenX,x
1243 ; adc #1
1244 ldy NPC_ScreenY,x
1245 jmp PlotNPCInCollisionMap
1246
1247 ProceedToHatching
1248 lda #1
1249 sta NPC_Progress,x
1250 lda #5
1251 sta NPC_Count,x
1252 rts
1253
1254 ; bmi SwarmingWasp
1255 HatchingEgg
1256 lda #NPCF_HATCH
1257 sta SpriteFrame
1258
1259 ;Plot Sprite
1260 ldy NPC_ScreenY,x
1261 lda NPC_ScreenX,x
1262 jsr RecalcScreen
1263 jsr PlotSpriteWithMask
1264
1265 ;Progress Hatch
1266 dec NPC_Count,x
1267 beq ProceedToSwarmingWasp
1268 rts
1269
1270 SpawnFairy
1271 ;Fairies appear on left or right of screen and oscillate left/right across top of screen
1272 dec DelayBetweenRRNPC
1273 .(
1274 bne skip1
1275 lda #20
1276 sta DelayBetweenRRNPC
1277
1278 ;Only allow 3 Fairies
1279 lda NPCUltimateIndex
1280 bmi skip2
1281 cmp #2
1282 bcs skip1
1283
1284 skip2 ;Spawn Fairy
1285 jsr FetchNewNPCIndex
1286 bcs skip1
1287
1288 ;Randomise Y position (40-103)
1289 jsr GetRandomNumber
1290 sta NPC_Special,y
1291 and #31
1292 clc
1293 adc #42
1294 and #$FE
1295 sta NPC_ScreenYOrigin,y
1296 sta NPC_ScreenY,y
1297
1298 ;Count is used to slowdown fairies
1299 lda #BONUSFAIRYSPEED
1300 sta NPC_Count,y
1301
1302 ;Randomise X position
1303 jsr GetRandomNumber
1304 and #15
1305 clc
1306 adc #12
1307 sta NPC_ScreenXOrigin,y
1308 sta NPC_ScreenX,y
1309
1310 lda #NPCA_FAIRY
1311 sta NPC_Activity,y
1312 skip1 rts
1313 .)
1314
1315 ProceedToSwarmingWasp
1316 lda #128
1317 sta NPC_Progress,x ;This becomes index of sine table
1318 lda #00
1319 sta NPC_Special,x
1320 ;Delete existing hatch since different size to Wasp
1321 ldy NPC_ScreenY,x
1322 lda NPC_ScreenX,x
1323 jsr RecalcScreen
1324 lda #NPCF_EGG
1325 sta SpriteFrame
1326 jsr RestoreSpriteBG
1327
1328 ;Then plot wasp frame
1329 lda #NPCF_SWARMINGWASP
1330 sta SpriteFrame
1331
1332 ;Plot Sprite
1333 lda NPC_ScreenY,x
1334 sta NPC_ScreenYOrigin,x
1335 tay
1336 lda NPC_ScreenX,x
1337 sta NPC_ScreenXOrigin,x
1338 jsr RecalcScreen
1339 jsr PlotSpriteWithMask
1340
1341 rts
1342
1343 SwarmingWasp
1344 ; nop
1345 ; jmp SwarmingWasp
1346 ;Delete Old Frame
1347 ldy NPC_ScreenY,x
1348 lda NPC_ScreenX,x
1349 jsr RecalcScreen
1350 lda #NPCF_SWARMINGWASP
1351 sta SpriteFrame
1352 jsr RestoreSpriteBG
1353
1354 ;Remove from Collision map
1355 lda NPC_ScreenX,x
1356 ldy NPC_ScreenY,x
1357 jsr RemoveNPCFromCollisionMap
1358
1359 inc NPC_Special,x
1360 inc NPC_Special,x
1361 ldy NPC_Special,x ;Wasp Sine Index
1362 lda NPC_ScreenYOrigin,x ;The common position that will change if honeypot dropped near
1363 clc
1364 adc SignedSineTable,y ;256x(-7 to +7) Imperfect sine
1365 ora #1
1366 sta NPC_ScreenY,x
1367
1368 ;Write to Collision Map
1369 lda NPC_ScreenX,x
1370 ; adc #1
1371 ldy NPC_ScreenY,x
1372 jsr PlotNPCInCollisionMap
1373
1374 ;Plot Sprite
1375 ldy NPC_ScreenY,x
1376 lda NPC_ScreenX,x
1377 jsr RecalcScreen
1378 jsr PlotSpriteWithMask
1379
1380 rts
1381
1382 ChannelFairy ;hehe, typo
1383 ;Slow down fairies
1384 dec NPC_Count,x
1385 .(
1386 beq skip1
1387 rts
1388
1389 skip1 lda #BONUSFAIRYSPEED
1390 .)
1391 sta NPC_Count,x
1392
1393 ;Delete Old Frame
1394 ldy NPC_ScreenY,x
1395 lda NPC_ScreenX,x
1396 jsr RecalcScreen
1397
1398 lda #NPCF_FAIRY0
1399 sta SpriteFrame
1400 jsr RestoreSpriteBG
1401
1402 ;Remove from Collision map
1403 lda NPC_ScreenX,x
1404 ldy NPC_ScreenY,x
1405 jsr RemoveNPCFromCollisionMap
1406
1407 ;Animate Fairy wings
1408 inc NPC_Special,x
1409 lda NPC_Special,x
1410 lsr
1411 lda #NPCF_FAIRY0
1412 adc #00
1413 sta SpriteFrame
1414
1415 ;Progress Fairy
1416 ; inc NPC_Progress,x
1417 inc NPC_Progress,x
1418 ldy NPC_Progress,x
1419 lda NPC_ScreenXOrigin,x
1420 clc
1421 adc SignedSineTable,y
1422 ;boundary checks
1423 cmp #3
1424 .(
1425 bcc skip1
1426 cmp #35
1427 bcs skip1
1428 sta NPC_ScreenX,x
1429
1430 tya
1431 adc #128
1432 tay
1433
1434 lda NPC_ScreenYOrigin,x
1435 clc
1436 adc SignedSineTable,y
1437 and #$FE ;This alligns Fairy to correct colour pair
1438 ;boundary checks
1439 cmp #32
1440 bcc skip1
1441 sta NPC_ScreenY,x
1442
1443 skip1 ;Plot Sprite
1444 .)
1445 ldy NPC_ScreenY,x
1446 lda NPC_ScreenX,x
1447 jsr RecalcScreen
1448 jsr PlotSpriteWithMask
1449
1450 ;Write to Collision Map
1451 lda NPC_ScreenX,x
1452 ldy NPC_ScreenY,x
1453 jmp PlotNPCInCollisionMap
1454
1455 ;The Tear has 3 phases of life.
1456 ;Phase 1
1457 ; Tear is thrown from Fairy up and then down in an arc towards the ground
1458 ; During this time it is NOT written to the collision map
1459 ; When it hits the ground the next phase starts
1460 ;Phase 2
1461 ; The tear remains on the ground for 2 seconds
1462 ; During this time it is written to the collision map and may be picked up by Stormlord whereupon it is destroyed
1463 ; Once 2 seconds has expired the next phase begins
1464 ;Phase 3
1465 ; The tears is removed from the collision map and melts into the ground.
1466 ; After it has melted the tear is destroyed
1467
1468 ThrownTear
1469 ; nop
1470 ; jmp ThrownTear
1471 lda NPC_Progress,x
1472 .(
1473 bne skip4
1474
1475 ;Delete Old Frame
1476 ldy NPC_ScreenY,x
1477 lda NPC_ScreenX,x
1478 jsr RecalcScreen
1479 lda #NPCF_RAINDROP ;3x8
1480 sta SpriteFrame
1481 jsr RestoreSpriteBG
1482
1483 ; ;Remove from Collision map
1484 ; lda NPC_ScreenX,x
1485 ; ldy NPC_ScreenY,x
1486 ; jsr RemoveNPCFromCollisionMap
1487
1488 ;We'll use the start of the sine table here to ensure a calculated rise and fall remains
1489 ;within the screen bounds (we know min height of Fairies is 42).
1490
1491 ;Progress Y
1492 ldy NPC_Special,x (7-
1493 lda NPC_ScreenY,x
1494 clc
1495 adc SignedSineTable,y
1496
1497 ;Ensure Y does not rise above arena
1498 cmp #30
1499 bcc skip5
1500 sta NPC_ScreenY,x
1501
1502 skip5 ;Progress Special (Index in sine table) until 5
1503 lda SignedSineTable,y
1504 cmp #5
1505 beq skip1
1506 inc NPC_ScreenX,x
1507 inc NPC_Special,x
1508
1509 skip1 ;Ensure X does not reach beyond right of screen
1510 lda NPC_ScreenX,x
1511 cmp #36
1512 bcc skip2
1513 lda #36
1514 sta NPC_ScreenX,x
1515
1516 skip2 ;Check Y does not exceed floor
1517
1518 lda NPC_ScreenY,x
1519 cmp #118
1520 bcc skip3
1521 ;Switch2TearPhase2
1522 ;This is special since we must continue NPC but write non-npc to colmap
1523 ;for moment just ensure it remains at 118
1524 lda #118
1525 sta NPC_ScreenY,x
1526 lda #1
1527 sta NPC_Progress,x
1528 ;We'll use Special to time tears on ground
1529 lda #25
1530 sta NPC_Special,x
1531
1532 skip3 ;Plot Sprite
1533
1534 ldy NPC_ScreenY,x
1535 lda NPC_ScreenX,x
1536 jsr RecalcScreen
1537 jsr PlotSpriteWithMask
1538
1539 rts
1540
1541 skip4 ;Tears on ground for about 2 seconds
1542 lda #NPCF_RAINDROP ;3x8
1543 sta SpriteFrame
1544
1545 ;Write tear to row 16, col X collision map
1546 ldy NPC_ScreenX,x
1547 txa
1548 clc
1549 adc #4
1550 sta CollisionMap+40*14,y
1551
1552 ;We need to trigger Raindrop SFX but only once
1553 lda NPC_Special,x
1554 cmp #25
1555 bne skip6
1556 lda #SFX_RAINDROP
1557 jsr KickSFX
1558
1559 skip6 ;Progress tear timeout
1560 dec NPC_Special,x
1561 bne skip3
1562 .)
1563 jmp RemoveTear
1564
1565 DragonLeft ;7
1566 ;Delete Old Frame
1567 ldy NPC_ScreenY,x
1568 lda NPC_ScreenX,x
1569 jsr RecalcScreen
1570 lda #NPCF_DRAGONLEFT
1571 sta SpriteFrame
1572 jsr RestoreSpriteBG
1573
1574 ;Remove from Collision map
1575 lda NPC_ScreenX,x
1576 ldy NPC_ScreenY,x
1577 jsr RemoveNPCFromCollisionMap
1578
1579 ;Progress Dragon
1580 inc NPC_ScreenY,x
1581 inc NPC_ScreenY,x
1582 dec NPC_ScreenX,x
1583
1584 ;Check Collision below
1585 lda NPC_ScreenX,x
1586 cmp #2
1587 bcc DestroyDragon
1588 lda NPC_ScreenY,x
1589 cmp #126
1590 bcs DestroyDragon
1591
1592 ;Plot Sprite
1593 ldy NPC_ScreenY,x
1594 lda NPC_ScreenX,x
1595 jsr RecalcScreen
1596 jsr PlotSpriteWithMask
1597
1598 ;Write to Collision Map
1599 lda NPC_ScreenX,x
1600 ; adc #1
1601 ldy NPC_ScreenY,x
1602 jmp PlotNPCInCollisionMap
1603
1604 DestroyDragon
1605 jmp DestroyNPC
1606
1607
1608 DragonRight ;8
1609 ;Delete Old Frame
1610 ldy NPC_ScreenY,x
1611 lda NPC_ScreenX,x
1612 jsr RecalcScreen
1613 lda #NPCF_DRAGONRIGHT
1614 sta SpriteFrame
1615 jsr RestoreSpriteBG
1616
1617 ;Remove from Collision map
1618 lda NPC_ScreenX,x
1619 ldy NPC_ScreenY,x
1620 jsr RemoveNPCFromCollisionMap
1621
1622 ;Progress Dragon
1623 inc NPC_ScreenY,x
1624 inc NPC_ScreenY,x
1625 inc NPC_ScreenX,x
1626
1627 ;Check Collision below
1628 lda NPC_ScreenX,x
1629 cmp #34
1630 bcs DestroyDragon
1631 lda NPC_ScreenY,x
1632 cmp #126
1633 bcs DestroyDragon
1634
1635 ;Plot Sprite
1636 ldy NPC_ScreenY,x
1637 lda NPC_ScreenX,x
1638 jsr RecalcScreen
1639 jsr PlotSpriteWithMask
1640
1641 ;Write to Collision Map
1642 lda NPC_ScreenX,x
1643 ; adc #1
1644 ldy NPC_ScreenY,x
1645 jmp PlotNPCInCollisionMap
1646
1647 DelayBetweenRRNPC .byt 0
1648
1649 ;RemoveSpiderThread
1650 ; ;NPC in Y but old activity in X
1651 ; cpx #NPCA_SPIDER
1652 ;.(
1653 ; bne skip1
1654 ; ;Run from NPC_ScreenYOrigin to NPC_ScreenY
1655 ; sty vector1+1
1656 ; tya
1657 ; tax
1658 ;
1659 ;loop1 ;Fetch BGBuff address
1660 ; ldy NPC_ScreenYOrigin,x
1661 ; lda NPC_ScreenXOrigin,x
1662 ; sec
1663 ; sbc #1
1664 ; jsr RecalcBGBuff
1665 ;
1666 ; ;also show on screen
1667 ; ldy NPC_ScreenYOrigin,x
1668 ; lda NPC_ScreenXOrigin,x
1669 ; jsr RecalcScreen
1670 ;
1671 ;
1672 ; ldy #01
1673 ; lda #%01000000
1674 ; sta (screen),y
1675 ; sta (bgbuff),y
1676 ; lda #%01000000
1677 ; ldy #41
1678 ; sta (screen),y
1679 ; sta (bgbuff),y
1680 ;
1681 ; inc NPC_ScreenYOrigin,x
1682 ; inc NPC_ScreenYOrigin,x
1683 ;
1684 ; lda NPC_ScreenYOrigin,x
1685 ; cmp NPC_ScreenY,x
1686 ; bcc loop1
1687 ;vector1 ldy #00
1688 ;skip1 rts
1689 ;.)
1690 ;

  ViewVC Help
Powered by ViewVC 1.1.26