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

Contents of /users/twilighte/Stormlord/Driver.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: 12427 byte(s)
Added Stormlord
1 ;Driver
2 #define HIRES $EC33
3 #define MAP_END 128
4
5 #define MAP_LEVEL1 0
6 #define MAP_LEVEL2 1
7 #define MAP_LEVEL3 2
8
9 #define SYS_IRQVECTOR $0229 ;0245 for Atmos
10
11 #define VIA_PORTB $0300
12 #define VIA_PORTAH $0301
13 #define VIA_DDRB $0302
14 #define VIA_DDRA $0303
15 #define VIA_T1CL $0304
16 #define VIA_T1CH $0305
17 #define VIA_T1LL $0306
18 #define VIA_T1LH $0307
19 #define VIA_T2LL $0308
20 #define VIA_T2CH $0309
21 #define VIA_PCR $030C
22 #define VIA_IFR $030D
23 #define VIA_IER $030E
24 #define VIA_PORTA $030F
25
26 #define VIA2_PORTB $0320
27
28 #define GAME_NORMAL 0
29 #define GAME_BONUS 1
30 #define GAME_ENDOFBONUS 128
31 #define GAME_OUTOFTIME 129
32 #define GAME_NOMORELIVES 130
33
34 #define GFX_FAIRYINPOT 0
35 #define GFX_STONEBLOCK1 1
36 #define GFX_DOOR 2
37 #define GFX_FAIRY 3
38 #define GFX_TRAMPOLINE 4
39 #define GFX_CHAIN 5
40 #define GFX_LARGEBRICK 6
41 #define GFX_FLORA1 7
42 #define GFX_BLUEVASE 8
43 #define GFX_SPHERELAUNCHER 9
44 #define GFX_KEY 10
45 #define GFX_SPHERE 11
46 #define GFX_COLUMNTOP 12
47 #define GFX_COLUMN 13
48 #define GFX_SMALLBRICKS 14
49
50 ;#define SCREENSCORE
51 #define CB_EXIT 3
52 #define CB_BACKGROUND 0
53
54 #define NPCA_BALLRISING 0
55 #define NPCA_BALLBOUNCE 1
56 #define NPCA_BALLPAUSE 2
57 #define NPCA_GRUBPEEP 3
58 #define NPCA_GRUBMOVE 4
59 #define NPCA_RAINDROP 5
60 #define NPCA_EGGWASP 6
61 #define NPCA_DRAGONLEFT 7
62 #define NPCA_DRAGONRIGHT 8
63 #define NPCA_BEE 9
64 #define NPCA_EXPLODE 10
65 #define NPCA_SPIDER 11
66 #define NPCA_TRIFFID 12
67 #define NPCA_FAIRY 13
68 #define NPCA_THROWNTEAR 14
69 #define NPCA_FLOORTEAR 15
70 #define NPCA_MELTTEAR 16
71
72 #define NPCF_BALL0 0
73 #define NPCF_BALL1 1
74 #define NPCF_BALL2 2
75 #define NPCF_BALL3 3
76 #define NPCF_GRUBMOVELEFT0 4
77 #define NPCF_GRUBMOVELEFT1 5
78 #define NPCF_GRUBMOVERIGHT0 6
79 #define NPCF_GRUBMOVERIGHT0 7
80 #define NPCF_GRUBPEEPLEFT 8
81 #define NPCF_GRUBPEEPRIGHT 9
82 #define NPCF_RAINDROP 10
83 #define NPCF_DRAGONLEFT 11
84 #define NPCF_DRAGONRIGHT 12
85 #define NPCF_BEE 13
86 #define NPCF_EXPLOSION 19
87 #define NPCF_AFTEREXPLODE 25
88 #define NPCF_EGG 25
89 #define NPCF_HATCH 26
90 #define NPCF_SWARMINGWASP 27
91 #define NPCF_SPIDER0 32
92 #define NPCF_SPIDER1 33
93 #define NPCF_FAIRY0 34
94 #define NPCF_FAIRY1 35
95
96 #define BONUSFAIRYSPEED 2
97
98 ;CollisionValue..
99 ;B0-3
100 #define BCKC_BG 0 ; 00 Background
101 #define BCKC_WALL 1 ; 01 Wall/Surface/Solid
102 #define BCKC_DEATH 2 ; 02 Death(Flames)
103 #define BCKC_ICELEDGE 3 ; 03 Ice Ledge
104 #define BCKC_TEARS 4 ; 04-15 Tear(NPC ID)
105 #define BCKC_OBJECTKEY 4 ; 04 Object 1 Key
106 #define BCKC_OBJECTHONEY 5 ; 05 Object 2 Honey
107 #define BCKC_OBJECTUMBRELLA 6 ; 06 Object 3 Umbrella
108 #define BCKC_OBJECTBOOTS 7 ; 07 Object 4 Boots
109 #define BCKC_FAIRY 8 ; 08 Fairy
110 #define BCKC_DOOR 9 ; 09 Door
111 #define BCKC_TRAMPOLENE 10 ; 10 Trampolene
112 #define BCKC_TRIFFID 11 ; 11 Triffid
113
114 #define STARFIELD_WEST 1
115 #define STARFIELD_EAST 248
116
117 #define GFXF_ORB 28
118 #define GFXF_SWORDRIGHT 29
119 #define GFXF_SWORDLEFT 30
120 #define GFXF_HEART 31
121
122 #define FIREPERIOD4SWORD 4
123
124 #define OBJECT_KEY 4
125 #define OBJECT_HONEY 5
126 #define OBJECT_UMBRELLA 6
127 #define OBJECT_BOOTS 7
128
129 #define TR_GAMEOVER 0
130 #define TR_TIMEOUT 1
131
132
133 ;SFX's
134 #define SFX_LEVELCOMPLETE 15
135 #define SFX_KILLED 0
136 #define SFX_EXPLOSION 13
137 #define SFX_GAMEOVER 14
138
139 ;#define SFX_PASSFAIRY
140
141 #define SFX_LAUNCHER 4
142 #define SFX_RAINDROP 6
143 ;#define SFX_FAIRYTEAR ;Raindrop
144 ;#define SFX_GRUB
145 #define SFX_SPIDER 11
146 #define SFX_BEES 12
147 #define SFX_COLLECTKEY 5
148 #define SFX_COLLECTFAIRY 7
149 #define SFX_COLLECTUMBRELLA 16
150 #define SFX_COLLECTHONEY 17
151 #define SFX_COLLECTSHOES 18
152 ;#define SFX_COLLECTTEAR
153 #define SFX_OPENDOOR 9
154 #define SFX_USETRAMPOLENE 8
155 #define SFX_FIREHEART 3
156 #define SFX_FIREORB 1
157 #define SFX_FIRESWORD 2
158 #define SFX_FOOTSTEP 10
159 #define SFX_STARFIELD 19
160
161 #define OVERLAY_TITLE 0
162 #define OVERLAY_REDEFINE 1
163 #define OVERLAY_OPTIONS 2
164 #define OVERLAY_STUFF 3
165 #define OVERLAY_HISCOREENTRY 4
166 #define OVERLAY_TIMEOUT 5
167 #define OVERLAY_GAMEOVER 6
168 #define OVERLAY_LEVELINTRO1 7
169 #define OVERLAY_GAMECOMPLETE 10
170
171 #define FRONTEND_TITLE 0
172 #define FRONTEND_OPTIONS 1
173 #define FRONTEND_STUFF 2
174
175 #define CTRL_LEFT 1
176 #define CTRL_RIGHT 2
177 #define CTRL_UP 16
178 #define CTRL_DOWN 8
179 #define CTRL_FIRE 32
180 #define CTRL_FIRE2 64
181
182 .zero
183 *=$00
184
185 #include "ZeroPage.s"
186
187 .text
188 *=$500
189
190 Driver jmp Driver2
191 ;$503 - Tables to $5FF
192 #include "Tables5035FF.s"
193 ;$600 - pmeLoopOrEnd
194 PageAlligned2_600
195 #include "Wave_PageAllignedStuff.s"
196 #include "Tables6DB6FF.s"
197 PageAlligned2_700
198 BackgroundBuffer ;10E0
199 .dsb 40*108,0
200 ;The collision map is based on 6x6 cells
201 ;00 Background
202 ;01 Wall/Surface/Solid
203 ;02 Death
204 ;03 Exit (Left/Right)
205 ;04 Object 1 Key
206 ;05 Object 2 Honey
207 ;06 Object 3 Umbrella
208 ;07 Object 4 Boots
209 ;08-15
210 ;16 Fairy
211 ;17 Door
212 ;18 Trampolene
213 ;+32 Left(0) or Right(1) Block (Only needed for collisions over 2)
214
215 Object_X
216 .dsb 8,0
217 Object_Y
218 .dsb 8,0
219 Object_MapLo
220 .dsb 8,0
221 Object_MapHi
222 .dsb 8,0
223
224 ;Above tables pad the following to become page alligned
225 CollisionMap
226 StarfieldX
227 .dsb 100,0
228 StarfieldY
229 .dsb 100,0
230 StarfieldStep
231 .dsb 100,0
232 ;(40x18)-(300 already defined above)
233 .dsb 420,0 ;40*18,0
234
235
236 Driver2 lda #30
237 sta $BFDF
238 jsr ClearLowerScreen
239 lda #128
240 sta GameFlag
241 jsr SetupIRQ
242 ;Restore BB80 area(Cassette load corrupts it)
243 ldx #39
244 .(
245 loop1 lda BB80Restoration,x
246 sta $A000+40*176,x
247 dex
248 bpl loop1
249 .)
250 lda #00
251 sta usm_SunMoonYPos
252 sta usm_RowIndex
253
254 .(
255 loop1 lda KeyRegister
256 bne loop1
257 loop2 lda KeyRegister
258 beq loop2
259 .)
260 jsr ClearScreen
261 GameStartLoop
262 sei
263 lda #00
264 sta ayw_Volume
265 sta ayw_Volume+1
266 sta ayw_Volume+2
267 jsr InitMusic
268 lda #<10000
269 sta VIA_T1CL
270 sta VIA_T1LL
271 lda #>10000
272 sta VIA_T1CH
273 sta VIA_T1LH
274 cli
275
276 lda #00
277 sta GameFlag
278 lda #10
279 sta CounterReference
280
281 jsr FrontEnd
282
283 lda #1
284 sta GameFlag
285 sei
286 jsr InitMusic
287 lda #<40000
288 sta VIA_T1CL
289 sta VIA_T1LL
290 lda #>40000
291 sta VIA_T1CH
292 sta VIA_T1LH
293 ;Stop any EG activity
294 lda #00
295 sta ayw_Volume
296 sta ayw_Volume+1
297 sta ayw_Volume+2
298 cli
299
300 ;Reset and display Score
301 lda #00
302 sta HeroScore
303 sta HeroScore+1
304 sta HeroScore+2
305 jsr DisplayScore
306
307 ;Set lives dependant on difficulty
308 ldx Option_Difficulty
309 lda InitialLives,x
310 ; lda #3
311 sta HeroLives
312 jsr DisplayLives
313
314 ;Set Game start (Level1) start Position
315 lda #0
316 sta LevelID
317 NextLevelLoop
318 jsr SetupLevel
319 ldx LevelID
320 jsr UnpackData
321
322 jsr DrawMap ;And pop bgbuff
323 ;Clear and redisplay Object Pocket
324 lda #128
325 sta HeroHolding
326 jsr DisplayHeldObject
327
328 ;Sunmoon speed is based on level aswell as difficulty
329 ;Difficulty == 0-2
330 ;level == 0-2
331 jsr SetTimeLimit
332
333 ;Reset Fairies collected
334 lda #00
335 sta HeroCapturedFairies
336 jsr DisplayCapturedFairies
337
338 ;Reset Hero frame(death was causing death frame) and redisplay
339 lda #8
340 sta HeroFrame
341 jsr PlotHero
342
343 ;Display Level Name
344 jsr DisplayLevelName
345
346 lda #GAME_NORMAL
347 sta GameAction
348
349
350 GameLoop jsr SpeedDampener
351 ; jsr TestWriteBinaryKeys
352 jsr NPCControl
353 jsr HeroControl
354 lda GameAction
355 .(
356 bmi skip3
357 jsr FireEngine
358 jsr PlotHero
359 jsr ManageBeePosition
360 lda KeyRegister
361 cmp #CTRL_FIRE2
362 beq skip2
363
364 lda GameAction
365 bpl GameLoop
366 skip3 cmp #GAME_ENDOFBONUS
367 beq EndOfBonusScreen
368 cmp #GAME_NOMORELIVES
369 beq skip1
370 ;Shouldn't be anything other than out of time here
371
372 ;Display Out of Time
373 ldx #OVERLAY_TIMEOUT
374 jsr DisplayOverlay
375
376 skip1 ;Delay a few seconds
377 jsr CommonTextDelay
378
379 ;Check highscore
380 jsr CheckHiscore
381
382 skip5 ;Return to title
383 jmp GameStartLoop
384
385 skip2 ;Esc pressed
386 jsr EscMenu
387 ; lda KeyRegister
388 ; and #31
389 ; beq skip6
390 ; inc LevelID
391 ; jmp skip7
392 ;skip6 lda KeyRegister
393 ; cmp #CTRL_FIRE2
394 ; ;Result is in Carry..
395 ; ;Clr - Restart Level
396 ; ;Set - Return to Title
397 bcs skip5
398
399 ;Restore Score
400 ldx #2
401
402 loop1 lda HeroLevelScore,x
403 sta HeroScore,x
404 dex
405 bpl loop1
406
407 ;Display Score
408 jsr DisplayScore
409
410 ;Decrement 1 life
411 dec HeroLives
412
413 beq skip4
414
415 jsr DisplayLives
416 skip7 jmp NextLevelLoop
417 skip4 jsr ClearScreen
418 ;Display Game Over mid screen
419 ldx #OVERLAY_GAMEOVER
420 jsr DisplayOverlay
421 jmp skip1
422 .)
423
424 EndOfBonusScreen
425 ;Record the score (ESC resets level and score too)
426 ldx #2
427 .(
428 loop1 lda HeroScore,x
429 sta HeroLevelScore,x
430 dex
431 bpl loop1
432 .)
433 ;then proceed to next level or finish game
434 inc LevelID
435 lda LevelID
436 cmp #3
437 bcs GameCompleted
438
439 lda #SFX_LEVELCOMPLETE
440 jsr KickSFX
441
442 ; ;Restore sunmoon speed
443 ; ldx Option_Difficulty
444 ; lda GameSpeed,x
445 ; sta CounterReference
446 ; jsr UpdateSunMoon_Cont
447
448 ;Restore midday
449 lda #00
450 sta usm_SunMoonYPos
451
452 ;Loop
453 jmp NextLevelLoop
454
455 GameCompleted
456 ldx #OVERLAY_GAMECOMPLETE
457 jsr DisplayOverlay
458 ;Kick some SFX
459 lda #SFX_STARFIELD
460 jsr KickSFX
461 ;Wait a while
462 lda #150
463 jsr CommonTextDelay2
464 ;Check hiscore
465 jsr CheckHiscore
466 ;then return to title
467 jmp GameStartLoop
468
469
470
471 DisplayLevelName
472 lda LevelID
473 adc #OVERLAY_LEVELINTRO1
474 tax
475 jsr DisplayOverlay
476 jsr CommonTextDelay
477 jmp DrawMap
478
479 CommonTextDelay
480 lda #50
481 CommonTextDelay2
482 sta ProgrammableCountdown
483 .(
484 loop1 lda ProgrammableCountdown
485 bne loop1
486 .)
487 rts
488
489 ManageBeePosition
490 ;Move Bees?
491 lda BeeTravellingFlag
492 .(
493 beq skip1
494
495 ;Fetch the current Bee position
496 lda BeeOriginX
497 ldy BeeOriginY
498
499 ;Have we reached the destination?
500 cmp BeesDestinationX
501 bne skip2
502 cpy BeesDestinationY
503 beq ReachedDestination
504
505 skip2 ;Progress X
506 cmp BeesDestinationX
507 bcc IncBeeX
508 DecBeeX dec BeeOriginX
509 jmp skip3
510 IncBeeX inc BeeOriginX
511
512 skip3 ;Progress Y
513 cpy BeesDestinationY
514 bcc IncBeeY
515 DecBeeY dec BeeOriginY
516 rts
517 IncBeeY inc BeeOriginY
518 rts
519
520 ReachedDestination
521 lda #00
522 sta BeeTravellingFlag
523 skip1 rts
524 .)
525
526 SpeedDampener
527 lda ProgrammableCountdown
528 bne SpeedDampener
529 lda #2
530 sta ProgrammableCountdown
531 rts
532
533 SetupLevel
534 ;Unpack Level Map here
535
536 ldx LevelID
537
538 lda LevelStart_MapX,x
539 sta MapX
540
541 lda LevelStart_HeroX,x
542 sta HeroX
543
544 lda #30
545 sta HeroY
546
547 lda LevelStart_Fairies2Collect,x
548 sta HeroRequiredFairies
549 jsr DisplayRequiredFairies
550
551 lda #00
552 sta usm_SunMoonYPos
553 jsr DisplayLives
554
555 lda #25
556 sta SecondCounter
557 rts
558
559
560 ;TestWriteBinaryKeys
561 ; ldx #6
562 ;.(
563 ;loop1 lda KeyRegister
564 ; ldy #16
565 ; and Bitpos,x
566 ; beq skip1
567 ; iny
568 ;skip1 tya
569 ; sta $BF68,x
570 ; dex
571 ; bpl loop1
572 ;.)
573 ; rts
574
575 #include "LevelSpecificData.s"
576 #include "Frontend.s"
577 #include "GenericCode.s"
578 #include "NPC_Engine.s"
579 #include "GenericTables.s"
580 #include "GenericVariables.s"
581 #include "CommonRoutines.s"
582 #include "Tiles.s"
583 #include "GraphicBlocks.s"
584 #include "GraphicSprites.s" ;gfx in shared/euph1007/disks/ssm73_*/npcs.mem
585 Stormlord_Map
586 #include "Stormlord_Map.s"
587 Stormlord_Map_End
588 #include "MapCode.s"
589 #include "HeroCode.s"
590 #include "IRQRoutine.s"
591 #include "HeroFire.s"
592 #include "Unpack.s"
593 #include "sfx.s"
594 #include "sfx_scripts.s"
595 #include "PackedLevel1.s"
596 #include "PackedLevel2.s"
597 #include "PackedLevel3.s"
598 #include "Wave_Player.s"
599 #include "CompiledMusic.s"
600 #include "JoystickDrivers.s"
601 #include "SafeZones.s"
602 #include "SetTimeLimit.s"
603 BB80Restoration
604 .byt $06,$40,$40,$58,$50,$4B,$40,$C9,$43,$40,$49,$4E,$60,$40,$40,$40,$40,$4E,$60,$40,$40,$40,$42,$4E,$60,$40,$40,$40,$40,$6E,$64,$40,$58,$02,$76,$06,$76,$43,$40,$40
605 ClearLowerScreen
606 ldx #00
607 txa
608 .(
609 loop1 sta $BD88,x
610 sta $BE88,x
611 sta $BEDF,x
612 inx
613 bne loop1
614 .)
615 rts
616
617
618 Himem
619 .byt 0
620
621 TopOfMemory
622 .dsb $A000-*
623 HiresScreen
624 #include "TwilighteLogo.s"
625 ScorePanelArea ;b770
626 #include "ScorePanel.s"
627 ;BD88-BF3F - Fill remainder of screen with 0
628 ;RestOfHires
629 ;.dsb $BF40-*
630 ;;BF40-BF67 - Spare 40 bytes
631 ;BB80Restoration
632 ; .byt $06,$40,$40,$58,$50,$4B,$40,$C9,$43,$40,$49,$4E,$60,$40,$40,$40,$40,$4E,$60,$40,$40,$40,$42,$4E,$60,$40,$40,$40,$40,$6E,$64,$40,$58,$02,$76,$06,$76,$43,$40,$40
633 ;;BF68-BFDE - Text Area
634 ;TextArea
635 ; .dsb 119,0
636 ;;BFDF - HIRES Switch
637 ;HIRESSwitch
638 ; .byt 30 ;28
639 ;;BFE0-BFFF - Spare 32 bytes
640 ;HimemSpare
641 ; .dsb 32,0
642
643

  ViewVC Help
Powered by ViewVC 1.1.26