/[james]/archive/heeheehee/RunImage
ViewVC logotype

Annotation of /archive/heeheehee/RunImage

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (hide annotations) (download)
Mon Feb 10 22:41:48 2003 UTC (21 years, 8 months ago) by james
File size: 29544 byte(s)
Initial import.

1 james 14 REM > <HeeHeeHee$Dir>.!RunImage
2    
3     LIBRARY "<HeeHeeHee$Dir>.GameLib"
4    
5     ON ERROR MODE 12: PROCGameLib_Error
6     MODE 15: MODE 13: OFF
7    
8     DIM B% 1000, Stars% 40000
9     Table_Character% = 0
10     Table_Bullets% = 1
11     Table_Platforms% = 2
12     Table_Ladders% = 3
13     Table_Walls% = 4
14     Table_Enemies% = 5
15     Table_Xplosions% = 6
16     Table_Droids% = 7
17     Table_Items% = 8
18    
19     Total_Droids% = 100
20     Size_Droids% = 44
21    
22     PROCGameLib_Show(&80000000, "")
23     PROCGameLib_Text("Choose a level . . .")
24     PROCGameLib_Text(" 1 - James")
25     PROCGameLib_Text(" 2 - James 2")
26     Level$ = ""
27     REPEAT
28     a$ = GET$
29     CASE a$ OF
30     WHEN "1": Level$ = "James"
31     WHEN "2": Level$ = "James2"
32     OTHERWISE: VDU7
33     ENDCASE
34     UNTIL Level$ <> ""
35    
36     PROCGameLib_Show(&80008000, "Loading...")
37     PROCMakeStars
38     PROCAssemble
39     PROCAmnesia_Init(500000)
40     PROCFastSpr_Load(0, "<HeeHeeHee$Dir>.Grafix")
41     PROCFastSpr_Load(1, "<HeeHeeHee$Dir>.Icons")
42     PROCAmnesia_ClaimTable(Table_Character%, 1, 1, 32)
43     PROCAmnesia_ClaimTable(Table_Bullets%, 1, 10, 32)
44     PROCAmnesia_ClaimTable(Table_Platforms%, 0, 1000, 32)
45     PROCAmnesia_ClaimTable(Table_Ladders%, 1, 500, 32)
46     PROCAmnesia_ClaimTable(Table_Walls%, 1, 1000, 32)
47     PROCAmnesia_ClaimTable(Table_Enemies%, 1, 10, 32+30*12)
48     PROCAmnesia_ClaimTable(Table_Xplosions%, 0, 10, 32)
49     PROCAmnesia_ClaimTable(Table_Droids%, 1, Total_Droids%, Size_Droids%)
50     PROCAmnesia_ClaimTable(Table_Items%, 1, 100, 32)
51     PROCAmnesia_SetGravity(0, 1 << 10)
52     PROCLevel_Init(Level$)
53     PROCAmnesia_SetWindow(0, 0, 0, Wide% << 16, High% << 16)
54     PROCAmnesia_SetWindow(1, -1 << 16, -1 << 16, 20 << 16, 15 << 16)
55     PROCAmnesia_SetWindow(2, 0, 0, Wide% << 16, High% << 16)
56     PROCGameLib_Fade
57     PROCFastSpr_Bank(2)
58     PROCFastSpr_Plot(&01000000, 160, 244)
59     PROCFastSpr_Bank(1)
60     PROCFastSpr_Plot(&01000000, 160, 244)
61     PROCFastSpr_SetClipWindow(0, 0, 320, 240)
62     PROCFastSpr_SetBackdrop(0)
63    
64     CASE USR(Code%) OF
65     WHEN 0: PROCGameLib_Show(&00800000, "Level Complete")
66     WHEN 1: PROCGameLib_Show(&00008000, "Game Over")
67     ENDCASE
68    
69     T% = TIME: REPEAT: UNTIL TIME > T% + 100
70     SYS"OS_Byte", 15, 1
71     IF GET THEN PROCGameLib_Fade
72     END
73    
74     REM ������������������������������������������������������������������������
75    
76     DEF PROCAssemble
77    
78     fire_delay% = 10
79     REMrobot_timer% = &00C80001
80    
81     Size% = 3 * 1024
82     DIM Code% Size% - 1
83     L% = Code% + Size% - 1
84    
85     REM FOR Pass% = 8 TO 11 STEP 3
86     FOR Pass% = 8 TO 10 STEP 2
87     P% = Code%
88     [OPT Pass%
89     ; <- R0 = reason for end
90     ; 0 = level complete
91     ; 1 = game over
92     ; --------------------------------------------------------------------------
93     ;initialisation
94     STMFD R13!, {R14}
95     STR R13, exit
96     MOV R0, #1
97     STR R0, bank
98    
99     MOV R0, #Table_Character%
100     BL object_find
101    
102     ; --------------------------------------------------------------------------
103     .main
104     LDR R0, frame
105     ADD R0, R0, #1
106     STR R0, frame
107    
108     BL swap_screen_bank
109    
110     BL escape
111     BL scan_keys
112     TST R0, #(1 << 0) : BLne move_left
113     TST R0, #(1 << 1) : BLne move_right
114     TST R0, #(1 << 2) : BLne move_jump
115     TST R0, #(1 << 4) : BLne move_down
116     TST R0, #(%11) : BLeq move_stand
117     AND R8, R0, #%1001: CMP R8, #%1001 : BLeq fire_left
118     AND R8, R0, #%1010: CMP R8, #%1010 : BLeq fire_right
119     AND R8, R0, #%1000: CMP R8, #%1000 : BLeq fire_stand
120    
121     BL platforms
122     BL droids
123    
124     BL screen_background
125     MOV R2, #0
126     MOV R0, #Table_Platforms% : BL process_table
127     MOV R0, #Table_Walls% : BL process_table
128     MOV R0, #Table_Ladders% : BL process_table
129     MOV R0, #Table_Items% : BL process_table
130     MOV R0, #Table_Character% : BL process_table
131     MOV R0, #Table_Enemies% : BL process_Enemies
132     MOV R0, #Table_Droids% : BL process_Droids
133     MOV R0, #Table_Xplosions% : BL process_table
134     MOV R0, #Table_Bullets% : BL process_table
135    
136     BL stars
137    
138     BL collisions_Character_Bullets
139     BL collisions_Bullets_Bullets
140     BL collisions_Walls_Bullets
141     BL collisions_Enemies_Bullets
142     BL collisions_Droids_Bullets
143     BL collisions_Character_Enemies
144     BL collisions_Character_Droids
145     BL collisions_Droids_Walls
146     BL collisions_Character_Items
147    
148     B main
149    
150     .frame
151     EQUD 0
152    
153     ; --------------------------------------------------------------------------
154     .finalisation
155     MOV R3, R0
156     MOV R0, #15
157     MOV R1, #1
158     SWI "OS_Byte"
159     MOV R0, R3
160     LDR R13, exit
161     LDMFD R13!, {PC}^
162    
163     ; --------------------------------------------------------------------------
164     ; data
165     .exit
166     EQUD 0
167     .bank
168     EQUD 0
169     .energy
170     EQUD 320
171    
172     ; --------------------------------------------------------------------------
173     .swap_screen_bank
174     ; -> nothing
175     ; <- no change
176     STMFD R13!, {R0-R3}
177    
178     MOV R0, #19 ; WAIT
179     SWI "OS_Byte"
180    
181     LDR R3, bank ; load bank from memory
182    
183     MOV R0, #113 ; display screen bank
184     MOV R1, R3
185     SWI "OS_Byte"
186    
187     RSB R3, R3, #3 ; swap bank
188    
189     SUB R0, R3, #1 ; set bank for FastSpr
190     SWI "FastSpr_ScreenBank"
191    
192     MOV R0, #112 ; VDU driver screen bank
193     MOV R1, R3
194     SWI "OS_Byte"
195    
196     STR R3, bank ; save bank to memory
197    
198     LDMFD R13!, {R0-R3}
199     MOV PC, R14
200    
201     ; --------------------------------------------------------------------------
202     .screen_background
203     ; -> R0 = backdrop sprite number
204     ; <- no change
205     STMFD R13!, {R0-R2}
206    
207     ;LDR R1, scroll_x
208     ;MOV R1, R1, ASR#12
209     ;LDR R2, scroll_y
210     ;MOV R2, R2, ASR#12
211     ;SWI "FastSpr_Plot"
212    
213     SWI "FastSpr_ClearWindow"
214    
215     LDMFD R13!, {R0-R2}
216     MOV PC, R14
217    
218     ; --------------------------------------------------------------------------
219     .escape
220     ; -> nothing
221     ; <- exits if escape was pressed
222     STMFD R13!, {R0-R1}
223    
224     MOV R0, #121
225     MOV R1, #(112 EOR &80)
226     SWI "OS_Byte"
227     CMP R1, #&FF
228     LDMneFD R13!, {R0-R1}
229     MOVne PC, R14
230    
231     MOV R0, #1
232     B finalisation
233    
234     ; --------------------------------------------------------------------------
235     .scan_keys
236     ; -> nothing
237     ; <- R0 = key flags bit key
238     ; 0 left
239     ; 1 right
240     ; 2 jump
241     ; 3 fire
242     ; 4 down
243     STMFD R13!, {R1-R3}
244    
245     MOV R3, #0
246     MOV R0, #121
247    
248     MOV R1, #(97 EOR &80)
249     SWI "OS_Byte"
250     CMP R1, #&FF
251     ORReq R3, R3, #%001
252    
253     MOV R1, #(66 EOR &80)
254     SWI "OS_Byte"
255     CMP R1, #&FF
256     ORReq R3, R3, #%010
257    
258     CMP R3, #%11
259     MOVeq R3, #0
260    
261     MOV R1, #(79 EOR &80)
262     SWI "OS_Byte"
263     CMP R1, #&FF
264     ORReq R3, R3, #%100
265    
266     MOV R1, #(73 EOR &80)
267     SWI "OS_Byte"
268     CMP R1, #&FF
269     ORReq R3, R3, #%1000
270    
271     MOV R1, #(104 EOR &80)
272     SWI "OS_Byte"
273     CMP R1, #&FF
274     ORReq R3, R3, #%10000
275    
276     MOV R0, R3
277    
278     LDMFD R13!, {R1-R3}
279     MOV PC, R14
280    
281     ; --------------------------------------------------------------------------
282     .object_find
283     ; -> R0 = table
284     ; <- R1 = pointer to first object
285     STMFD R13!, {R0, R2}
286    
287     MOV R1, #0
288     MOV R2, #1
289     SWI "Amnesia_SelectTable"
290    
291     LDMFD R13!, {R0, R2}
292     MOV PC, R14
293    
294     ; --------------------------------------------------------------------------
295     .move_stand
296     ; -> R1 = pointer to character
297     ; <- no change
298     STMFD R13!, {R0, R2}
299    
300     LDR R2, move_char_now
301     ADD R2, R2, #1
302     AND R2, R2, #3
303     STR R2, move_char_now
304     ADR R0, move_chars
305     LDR R0, [R0, R2, LSL #2]
306     STR R0, [R1]
307    
308     LDMFD R13!, {R0, R2}
309     MOV PC, R14
310    
311     .move_char_now
312     EQUD 0
313     .move_chars
314     EQUD &00010001 ; 0 left 1
315     EQUD &00000001 ; 1 standard
316     EQUD &00030001 ; 2 right 1
317     EQUD &00000001 ; 3 standard
318     ; left
319     EQUD &00030001 ; 6 right 1
320     EQUD &00040001 ; 7 right 2
321     ; right
322     EQUD &00010001 ; 4 left 1
323     EQUD &00020001 ; 5 left 2
324    
325     ; --------------------------------------------------------------------------
326     .move_left
327     ; -> R1 = pointer to character
328     ; <- no change
329     STMFD R13!, {R0-R3, R14}
330    
331     LDR R2, move_char_now ; increment animation
332     CMP R2, #3
333     MOVle R2, #3
334     CMP R2, #6
335     MOVge R2, #3
336     ADD R2, R2, #1
337     CMP R2, #6
338     MOVeq R2, #4
339     STR R2, move_char_now
340     ADR R0, move_chars
341     LDR R0, [R0, R2, LSL #2]
342     STR R0, [R1]
343    
344     LDR R0, [R1, #8] ; move left
345     CMP R0, #(1 << 15)
346     LDMeqFD R13!, {R0-R3, R14} ; exit if already at furthest left
347     MOVeq PC, R14
348    
349     MOV R3, R0
350     SUB R0, R0, #(2 << 12)
351     STR R0, [R1, #8]
352    
353     MOV R2, #0
354     STR R2, fire_direction
355    
356     STMFD R13!, {R0, R2}
357     MOV R0, #Table_Character%
358     MOV R2, #1
359     BL process_table
360     LDMFD R13!, {R0, R2}
361    
362     BL collisions_Character_Walls
363     MOVne R0, R3
364     STRne R0, [R1, #8]
365    
366     BL scroll_horizontal
367    
368     LDMFD R13!, {R0-R3, R14}
369     MOV PC, R14
370    
371     ; --------------------------------------------------------------------------
372     .move_right
373     ; -> R1 = pointer to character
374     ; <- no change
375     STMFD R13!, {R0-R3, R14}
376    
377     LDR R2, move_char_now
378     CMP R2, #5
379     MOVle R2, #5
380     ADD R2, R2, #1
381     CMP R2, #8
382     MOVeq R2, #6
383     STR R2, move_char_now
384     ADR R0, move_chars
385     LDR R0, [R0, R2, LSL #2]
386     STR R0, [R1]
387    
388     LDR R0, [R1, #8] ; move right
389     LDR R2, move_right_edge
390     CMP R0, R2
391     LDMeqFD R13!, {R0-R3, R14} ; exit if already at furthest right
392     MOVeq PC, R14
393    
394     MOV R3, R0
395     ADD R0, R0, #(2 << 12)
396     STR R0, [R1, #8]
397    
398     MOV R2, #1
399     STR R2, fire_direction
400    
401     STMFD R13!, {R0, R2}
402     MOV R0, #Table_Character%
403     MOV R2, #1
404     BL process_table
405     LDMFD R13!, {R0, R2}
406    
407     BL collisions_Character_Walls
408     MOVne R0, R3
409     STRne R0, [R1, #8]
410    
411     BL scroll_horizontal
412    
413     LDMFD R13!, {R0-R3, R14}
414     MOV PC, R14
415    
416     .move_right_edge
417     EQUD 0 ;((Wide% - 1) << 16) + (1 << 15)
418    
419     ; --------------------------------------------------------------------------
420     .scroll_horizontal
421     ; -> R0 = character x position
422     ; <- no change
423     STMFD R13!, {R0-R1}
424    
425     RSB R0, R0, #0
426     ADD R0, R0, #(160 << 12)
427     CMP R0, #0
428     MOVgt R0, #0
429     LDR R1, scroll_x_end
430     CMP R0, R1
431     MOVlt R0, R1
432     STR R0, scroll_x
433     LDR R1, scroll_y
434     SWI "Amnesia_SetPlotOffset"
435    
436     LDMFD R13!, {R0-R1}
437     MOV PC, R14
438    
439     .scroll_x
440     EQUD 0 ;(Wide% << 16) - (320 << 12)
441     .scroll_x_end
442     EQUD 0 ;(Wide% << 16) - (320 << 12)
443    
444     ; --------------------------------------------------------------------------
445     .scroll_vertical
446     ; -> R1 = character y position
447     ; <- no change
448     STMFD R13!, {R0-R1}
449    
450     RSB R1, R1, #0
451     ADD R1, R1, #(120 << 12)
452     CMP R1, #0
453     MOVgt R1, #0
454     LDR R0, scroll_y_end
455     CMP R1, R0
456     MOVlt R1, R0
457     STR R1, scroll_y
458     LDR R0, scroll_x
459     SWI "Amnesia_SetPlotOffset"
460    
461     LDMFD R13!, {R0-R1}
462     MOV PC, R14
463    
464     .scroll_y
465     EQUD 0 ;-((High% << 16) - (240 << 12))
466     .scroll_y_end
467     EQUD 0 ;-((High% << 16) - (240 << 12))
468    
469     ; --------------------------------------------------------------------------
470     .move_jump
471     ; -> R1 = pointer to character
472     ; <- no change
473     STMFD R13!, {R0, R14}
474    
475     LDR R0, [R1, #4]
476     TST R0, #(1 << 3)
477     LDMneFD R13!, {R0, R14}
478     MOVne PC, R14
479    
480     BL collisions_Character_Ladders
481     Beq move_jump_1
482    
483     LDR R0, [R1, #12]
484     SUB R0, R0, #(2 << 12)
485     STR R0, [R1, #12]
486    
487     STMFD R13!, {R2}
488     MOV R0, #Table_Character%
489     MOV R2, #1
490     BL process_table
491     LDMFD R13!, {R2}
492    
493     LDMFD R13!, {R0, R14}
494     MOV PC, R14
495    
496     .move_jump_1
497     ORR R0, R0, #(1 << 3)
498     STR R0, [R1, #4]
499     LDR R0, move_jump_velocity
500     STR R0, [R1, #20]
501    
502     LDMFD R13!, {R0, R14}
503     MOV PC, R14
504    
505     .move_jump_velocity
506     EQUD -(4 << 12)
507    
508     ; --------------------------------------------------------------------------
509     .move_down
510     ; -> R1 = pointer to character
511     ; <- no change
512     STMFD R13!, {R0, R14}
513    
514     LDR R0, [R1, #4]
515     TST R0, #(1 << 3)
516     LDMneFD R13!, {R0, R14}
517     MOVne PC, R14
518    
519     ;L collisions_1_8
520     ;DMeqFD R13!, {R0, R14}
521     ;OVeq PC, R14
522    
523     LDR R0, [R1, #12]
524     ADD R0, R0, #(2 << 12)
525     STR R0, [R1, #12]
526    
527     STMFD R13!, {R2}
528     MOV R0, #Table_Character%
529     MOV R2, #1
530     BL process_table
531     LDMFD R13!, {R2}
532    
533     LDMFD R13!, {R0, R14}
534     MOV PC, R14
535    
536     ; --------------------------------------------------------------------------
537     .fire_left
538     ; -> R1 = pointer to character
539     ; <- no change
540     STMFD R13!, {R0-R9}
541    
542     .fire_left_jump
543     LDR R4, fired_frame
544     LDR R5, frame
545     ADD R4, R4, #fire_delay%
546     CMP R5, R4
547     LDMltFD R13!, {R0-R9}
548     MOVlt PC, R14
549     STR R5, fired_frame
550    
551     MOV R9, R1
552    
553     MOV R0, #Table_Bullets%
554     MOV R1, #2
555     LDR R2, fire_flags
556     LDR R3, [R9, #8]
557     SUB R3, R3, #(1 << 15)
558     LDR R4, [R9, #12]
559     LDR R5, fire_left_velocity
560     MOV R6, #0
561     LDR R7, bullet_timer
562     MOV R8, #0
563     SWI "Amnesia_MakeObject"
564    
565     LDMFD R13!, {R0-R9}
566     MOV PC, R14
567    
568     .fire_left_velocity
569     EQUD -(1 << 14)
570    
571     .fire_flags
572     EQUD %11000001011010101
573    
574     .bullet_timer
575     EQUD &00320001
576    
577     ; --------------------------------------------------------------------------
578     .fire_right
579     ; -> R1 = pointer to character
580     ; <- no change
581     STMFD R13!, {R0-R9}
582    
583     .fire_right_jump
584     LDR R4, fired_frame
585     LDR R5, frame
586     ADD R4, R4, #fire_delay%
587     CMP R5, R4
588     LDMltFD R13!, {R0-R9}
589     MOVlt PC, R14
590     STR R5, fired_frame
591    
592     MOV R9, R1
593    
594     MOV R0, #Table_Bullets%
595     MOV R1, #2
596     LDR R2, fire_flags
597     LDR R3, [R9, #8]
598     ADD R3, R3, #(1 << 15)
599     LDR R4, [R9, #12]
600     LDR R5, fire_right_velocity
601     MOV R6, #0
602     LDR R7, bullet_timer
603     MOV R8, #0
604     SWI "Amnesia_MakeObject"
605    
606     LDMFD R13!, {R0-R9}
607     MOV PC, R14
608    
609     .fire_right_velocity
610     EQUD (1 << 14)
611    
612     ; --------------------------------------------------------------------------
613     .fire_stand
614     ; -> R1 = pointer to character
615     ; <- no change
616     STMFD R13!, {R0-R9}
617    
618     LDR R0, fire_direction
619     CMP R0, #0
620     Beq fire_left_jump
621     B fire_right_jump
622    
623     .fire_direction
624     EQUD 1 ; 0 = left, 1 = right
625     .fired_frame
626     EQUD 0
627    
628     ; --------------------------------------------------------------------------
629     .process_table
630     ; -> R0 = table to process
631     ; R2 = plot action (0 = plot, 1 = don't)
632     ; <- no change
633     STMFD R13!, {R0-R2}
634    
635     MOV R1, #0
636     SWI "Amnesia_SelectTable"
637     .process_table_loop
638     SWI "Amnesia_ProcessTable"
639     CMP R2, #0
640     Bne process_table_loop
641    
642     LDMFD R13!, {R0-R2}
643     MOV PC, R14
644    
645     ; --------------------------------------------------------------------------
646     .process_Enemies
647     ; -> R0 = table to process
648     ; R2 = plot action (0 = plot, 1 = don't)
649     ; <- no change
650     STMFD R13!, {R0-R3}
651    
652     MOV R1, #0
653     SWI "Amnesia_SelectTable"
654     .process_Enemies_loop
655     SWI "Amnesia_ProcessTable"
656     CMP R2, #0
657     LDMeqFD R13!, {R0-R3}
658     MOVeq PC, R14
659    
660     TST R2, #(1 << 8)
661     Beq process_Enemies_loop
662    
663     STMFD R13!, {R0-R3}
664    
665     LDR R0, [R1, #36] ; increment move
666     ADD R0, R0, #1
667     LDR R2, [R1, #32]
668     CMP R0, R2
669     MOVeq R0, #0
670     STR R0, [R1, #36]
671    
672     MOV R3, #12 ; calculate position
673     MUL R2, R0, R3
674     ADD R2, R2, #40
675     ADD R2, R1, R2
676    
677     LDR R0, [R2, #00] ; copy velocity etc
678     STR R0, [R1, #16]
679     LDR R0, [R2, #04]
680     STR R0, [R1, #20]
681     LDR R0, [R2, #08]
682     STR R0, [R1, #24]
683    
684     LDMFD R13!, {R0-R3}
685    
686     B process_Enemies_loop
687    
688     ; --------------------------------------------------------------------------
689     .process_Droids
690     ; -> R0 = table to process
691     ; R2 = plot action (0 = plot, 1 = don't)
692     ; <- no change
693     STMFD R13!, {R0-R2}
694    
695     MOV R1, #0
696     SWI "Amnesia_SelectTable"
697     .process_Droids_loop
698     SWI "Amnesia_ProcessTable"
699     CMP R2, #0
700     LDMeqFD R13!, {R0-R2}
701     MOVeq PC, R14
702    
703     TST R2, #(1 << 8)
704     Beq process_Droids_loop
705    
706     STMFD R13!, {R0-R3}
707    
708     LDR R0, [R1, #00]
709     AND R0, R0, #&FF0000
710     LDR R2, [R1, #32]
711     LDR R3, [R1, #36]
712     CMP R0, #0
713     MOVeq R0, R2
714     MOVne R0, R3
715     STR R0, [R1, #24]
716    
717     LDR R0, [R1, #00]
718     EOR R0, R0, #&10000
719     STR R0, [R1, #00]
720    
721     LDMFD R13!, {R0-R3}
722    
723     B process_Droids_loop
724    
725     ; ----------------------------------------------------------------
726     .platforms
727     ; -> R1 = pointer to character
728     ; <- no change
729     STMFD R13!, {R0-R9, R14}
730    
731     MOV R8, R1
732     MOV R0, #Table_Platforms%
733     MOV R1, #1
734     MOV R2, #8
735     ; find all platforms in same x position as char
736     LDR R3, [R8, #8]
737     MOV R3, R3, LSR #16
738     MOV R3, R3, LSL #16
739     ADD R3, R3, #(1 << 15)
740     MOV R4, #0
741     SWI "Amnesia_SelectTable"
742     .process_platforms
743     SWI "Amnesia_ProcessTable"
744     CMP R2, #0
745     Beq process_platforms_end
746     ; examine y position
747     LDR R5, [R8, #12]
748     ADD R5, R5, #(1 << 16)
749     LDR R6, [R1, #12]
750     SUB R6, R6, #(1 << 15)
751     CMP R5, R6
752     Blt process_platforms_fall
753     SUB R5, R5, #(1 << 15)
754     CMP R5, R6
755     Bgt process_platforms_fall
756    
757     LDR R7, [R8, #20]
758     CMP R7, #0 ; filter out rises
759     Blt process_platforms
760     LDR R7, [R8, #12]
761     MOV R7, R7, LSR #16
762     MOV R7, R7, LSL #16
763     STR R7, [R8, #12]
764     .process_platforms_nofall
765     LDR R7, [R8, #4]
766     BIC R7, R7, #(1 << 3)
767     STR R7, [R8, #4]
768     MOV R7, #0
769     STR R7, [R8, #20]
770     B process_platforms_end
771    
772     .process_platforms_fall
773     BL collisions_Character_Ladders
774     Bne process_platforms_nofall
775    
776     LDR R7, [R8, #4]
777     ORR R7, R7, #(1 << 3)
778     STR R7, [R8, #4]
779     LDR R7, [R8, #12]
780     LDR R9, platforms_base
781     CMP R7, R9
782     LDMgtFD R13!, {R0-R9, R14}
783     MOVgt R0, #1
784     Bgt finalisation
785     B process_platforms
786    
787     .platforms_base
788     EQUD 0 ;(High% << 16)
789    
790     .process_platforms_end
791     LDR R1, [R8, #12]
792     BL scroll_vertical
793    
794     LDMFD R13!, {R0-R9, R14}
795     MOV PC, R14
796    
797     ; --------------------------------------------------------------------------
798     .collisions_Character_Walls
799     ; -> nothing
800     ; <- flags updated
801     STMFD R13!, {R0-R3, R14}
802    
803     MOV R0, #Table_Character%
804     MOV R1, #Table_Walls%
805     SWI "Amnesia_CollisionCheck"
806     CMP R0, #0
807     LDMFD R13!, {R0-R3, R14}
808     MOV PC, R14
809    
810     ; --------------------------------------------------------------------------
811     .collisions_Character_Ladders
812     ; -> nothing
813     ; <- no change
814     STMFD R13!, {R0-R3, R14}
815    
816     MOV R0, #Table_Character%
817     MOV R1, #Table_Ladders%
818     SWI "Amnesia_CollisionCheck"
819     CMP R0, #0
820     LDMFD R13!, {R0-R3, R14}
821     MOV PC, R14
822    
823     ; --------------------------------------------------------------------------
824     .collisions_Character_Bullets
825     ; -> nothing
826     ; <- no change
827     STMFD R13!, {R0-R4, R14}
828    
829     MOV R0, #Table_Character%
830     MOV R1, #Table_Bullets%
831     .collisions_Character_Bullets_loop
832     SWI "Amnesia_CollisionCheck"
833     CMP R0, #0
834     LDMeqFD R13!, {R0-R4, R14}
835     MOVeq PC, R14
836    
837     STMFD R13!, {R0}
838     MOV R0, #0 ; remove bullet
839     STR R0, [R1]
840     MOV R0, #80 ; reduce energy
841     BL energy_reduce
842     LDMFD R13!, {R0}
843     B collisions_Character_Bullets_loop
844    
845     ; --------------------------------------------------------------------------
846     .collisions_Bullets_Bullets
847     ; -> nothing
848     ; <- no change
849     STMFD R13!, {R0-R4, R14}
850    
851     MOV R0, #Table_Bullets%
852     MOV R1, #Table_Bullets%
853     .collisions_Bullets_Bullets_loop
854     SWI "Amnesia_CollisionCheck"
855     CMP R0, #0
856     LDMeqFD R13!, {R0-R4, R14}
857     MOVeq PC, R14
858    
859     MOV R4, #0
860     STR R4, [R0]
861     STR R4, [R1]
862     B collisions_Bullets_Bullets_loop
863    
864     ; --------------------------------------------------------------------------
865     .collisions_Walls_Bullets
866     ; -> nothing
867     ; <- no change
868     STMFD R13!, {R0-R4, R14}
869    
870     MOV R0, #Table_Bullets%
871     MOV R1, #Table_Walls%
872     .collisions_Walls_Bullets_loop
873     SWI "Amnesia_CollisionCheck"
874     CMP R0, #0
875     LDMeqFD R13!, {R0-R4, R14}
876     MOVeq PC, R14
877    
878     LDR R4, [R0, #16]
879     RSB R4, R4, #0
880     STR R4, [R0, #16]
881     B collisions_Walls_Bullets_loop
882    
883     ; --------------------------------------------------------------------------
884     .collisions_Enemies_Bullets
885     ; -> nothing
886     ; <- no change
887     STMFD R13!, {R0-R4, R14}
888    
889     MOV R0, #Table_Bullets%
890     MOV R1, #Table_Enemies%
891     .collisions_Enemies_Bullets_loop
892     SWI "Amnesia_CollisionCheck"
893     CMP R0, #0
894     LDMeqFD R13!, {R0-R4, R14}
895     MOVeq PC, R14
896    
897     MOV R4, #0 ; remove bullet & enemy
898     STR R4, [R0]
899     STR R4, [R1]
900    
901     STMFD R13!, {R0-R8}
902     LDR R3, [R1, #08]
903     LDR R4, [R1, #12]
904     MOV R0, #Table_Xplosions%
905     LDR R1, Xplosion1 + 00
906     LDR R2, Xplosion1 + 04
907     MOV R5, #0
908     MOV R6, #0
909     LDR R7, Xplosion1 + 08
910     SWI "Amnesia_MakeObject"
911     LDMFD R13!, {R0-R8}
912    
913     B collisions_Enemies_Bullets_loop
914    
915     .Xplosion1
916     EQUD &00000007
917     EQUD %1000001001110001
918     EQUD &06000080
919    
920     ; --------------------------------------------------------------------------
921     .collisions_Droids_Bullets
922     ; -> nothing
923     ; <- no change
924     STMFD R13!, {R0-R4, R14}
925    
926     MOV R0, #Table_Bullets%
927     MOV R1, #Table_Droids%
928     .collisions_Bullets_Droids_loop
929     SWI "Amnesia_CollisionCheck"
930     CMP R0, #0
931     LDMeqFD R13!, {R0-R4, R14}
932     MOVeq PC, R14
933    
934     MOV R4, #0 ; remove bullet
935     STR R4, [R0]
936    
937     LDR R4, [R1, #40] ; droid lives
938     SUB R4, R4, #1
939     STR R4, [R1, #40]
940     CMP R4, #0
941     Bne collisions_Bullets_Droids_loop
942    
943     MOV R4, #0 ; remove droid
944     STR R4, [R1]
945    
946     STMFD R13!, {R0-R8}
947     LDR R3, [R1, #08]
948     LDR R4, [R1, #12]
949     MOV R0, #Table_Xplosions%
950     LDR R1, Xplosion2 + 00
951     LDR R2, Xplosion2 + 04
952     MOV R5, #0
953     MOV R6, #0
954     LDR R7, Xplosion2 + 08
955     SWI "Amnesia_MakeObject"
956     LDMFD R13!, {R0-R8}
957    
958     B collisions_Bullets_Droids_loop
959    
960     .Xplosion2
961     EQUD &00000009
962     EQUD %1000001001110001
963     EQUD &04000080
964    
965     ; --------------------------------------------------------------------------
966     .collisions_Character_Enemies
967     ; -> nothing
968     ; <- no change
969     STMFD R13!, {R0-R4, R14}
970    
971     MOV R0, #Table_Character%
972     MOV R1, #Table_Enemies%
973     .collisions_Character_Enemies_loop
974     SWI "Amnesia_CollisionCheck"
975     CMP R0, #0
976     LDMeqFD R13!, {R0-R4, R14}
977     MOVeq PC, R14
978    
979     STMFD R13!, {R0}
980     MOV R0, #1
981     BL energy_reduce
982     LDMFD R13!, {R0}
983     B collisions_Character_Enemies_loop
984    
985     ; --------------------------------------------------------------------------
986     .collisions_Character_Droids
987     ; -> nothing
988     ; <- no change
989     STMFD R13!, {R0-R4, R14}
990    
991     MOV R0, #Table_Character%
992     MOV R1, #Table_Droids%
993     .collisions_Character_Droids_loop
994     SWI "Amnesia_CollisionCheck"
995     CMP R0, #0
996     LDMeqFD R13!, {R0-R4, R14}
997     MOVeq PC, R14
998    
999     STMFD R13!, {R0}
1000     MOV R0, #2
1001     BL energy_reduce
1002     LDMFD R13!, {R0}
1003     B collisions_Character_Droids_loop
1004    
1005     ; --------------------------------------------------------------------------
1006     .collisions_Droids_Walls
1007     ; -> nothing
1008     ; <- no change
1009     STMFD R13!, {R0-R5, R14}
1010    
1011     MOV R0, #Table_Droids%
1012     MOV R1, #Table_Walls%
1013     .collisions_Droids_Walls_loop
1014     SWI "Amnesia_CollisionCheck"
1015     CMP R0, #0
1016     LDMeqFD R13!, {R0-R5, R14}
1017     MOVeq PC, R14
1018    
1019     LDR R4, [R0, #08]
1020     LDR R5, [R0, #16]
1021     SUB R4, R4, R5
1022     STR R4, [R0, #08]
1023    
1024     B collisions_Droids_Walls_loop
1025    
1026     ; --------------------------------------------------------------------------
1027     .collisions_Character_Items
1028     ; -> nothing
1029     ; <- no change
1030     STMFD R13!, {R0-R3, R14}
1031    
1032     MOV R0, #Table_Character%
1033     MOV R1, #Table_Items%
1034     .collisions_Character_Items_loop
1035     SWI "Amnesia_CollisionCheck"
1036     CMP R0, #0
1037     LDMeqFD R13!, {R0-R3, R14}
1038     MOVeq PC, R14
1039    
1040     LDR R0, [R1, #0]
1041     SUB R0, R0, #10
1042     B finalisation
1043    
1044     ; --------------------------------------------------------------------------
1045     .energy_reduce
1046     ; -> R0 = amount of energy to reduce by
1047     ; <- no change
1048     STMFD R13!, {R0-R4}
1049    
1050     LDR R1, energy
1051     SUB R0, R1, R0
1052     STR R0, energy
1053     CMP R0, #0
1054     LDMleFD R13!, {R0-R4}
1055     MOVle R0, #1
1056     Ble finalisation
1057    
1058     MOV R1, #240
1059     MOV R2, #320
1060     MOV R3, #256
1061     SWI "FastSpr_SetClipWindow"
1062     SWI "FastSpr_ClearWindow"
1063    
1064     LDR R0, bank ; load bank from memory
1065     SUB R0, R0, #1
1066     RSB R0, R0, #1
1067     SWI "FastSpr_ScreenBank"
1068     SWI "FastSpr_ClearWindow"
1069     LDR R0, bank ; load bank from memory
1070     SUB R0, R0, #1 ; set bank for FastSpr
1071     SWI "FastSpr_ScreenBank"
1072    
1073     MOV R0, #0
1074     MOV R1, #0
1075     MOV R2, #320
1076     MOV R3, #240
1077     SWI "FastSpr_SetClipWindow"
1078    
1079     LDMFD R13!, {R0-R4}
1080     MOV PC, R14
1081    
1082     .energy_reduce_sprite
1083     EQUD &01000001
1084    
1085     ; --------------------------------------------------------------------------
1086     .droids
1087     ; -> R1 = pointer to character
1088     ; <- no change
1089     STMFD R13!, {R0-R8, R14}
1090    
1091     MOV R2, R1 ; R2 -> character
1092    
1093     MOV R0, #Table_Droids%
1094     BL object_find ; R1 -> droid
1095    
1096     MOV R0, #Total_Droids% ; R0 = droid count
1097     .droids_loop
1098     LDR R4, [R2, #0]
1099     CMP R4, #0
1100     Beq droids_next
1101    
1102     LDR R4, [R2, #08] ; character x
1103     LDR R5, [R1, #08] ; droid x
1104     LDR R6, [R2, #12] ; character y
1105     LDR R7, [R1, #12] ; droid y
1106    
1107     LDR R3, [R1, #04] ; has it been activated?
1108     TST R3, #(1 << 2)
1109     BLeq droids_activate
1110    
1111     MOV R3, #(1 << 12) ; x
1112     CMP R4, R5
1113     RSBlt R3, R3, #0
1114     MOVeq R3, #0
1115     STR R3, [R1, #16]
1116    
1117     MOV R3, #(1 << 12) ; y
1118     CMP R6, R7
1119     RSBlt R3, R3, #0
1120     MOVeq R3, #0
1121     STR R3, [R1, #20]
1122    
1123     .droids_next
1124     SUB R0, R0, #1
1125     ADD R1, R1, #Size_Droids%
1126     CMP R0, #0
1127     Bne droids_loop
1128    
1129     LDMFD R13!, {R0-R8, R14}
1130     MOV PC, R14
1131    
1132     .droids_activate
1133     CMP R4, R5 ; find x difference
1134     SUBge R8, R4, R5
1135     SUBlt R8, R5, R4
1136     CMP R8, #(1 << 19)
1137     MOVgt PC, R14
1138    
1139     CMP R6, R7 ; find y difference
1140     SUBge R8, R6, R7
1141     SUBlt R8, R7, R6
1142     CMP R8, #(1 << 19)
1143     MOVgt PC, R14
1144    
1145     ORR R3, R3, #(1 << 2)
1146     STR R3, [R1, #04]
1147     MOV PC, R14
1148    
1149     ; --------------------------------------------------------------------------
1150     .stars
1151     STMFD R13!, {R0-R9, R14}
1152    
1153     ADR R0, stars_block
1154     ADR R1, screen_base
1155     SWI "OS_ReadVduVariables"
1156     LDR R0, screen_base ; R0 = base of screen memory
1157     LDR R1, starfield ; R1 = starfield list
1158    
1159     LDR R2, stars_scroll
1160     ADD R2, R2, #5
1161     CMP R2, #(320*240)
1162     MOVeq R2, #0
1163     STR R2, stars_scroll ; R2 = offset of star start from R0
1164    
1165     LDR R9, stars_total
1166     MVN R3, #3 ; R3 = position in starfield list
1167     .starloop
1168     ADD R3, R3, #4
1169    
1170     CMP R3, R9
1171     Beq stars_exit
1172    
1173     LDR R4, [R1, R3] ; get distance between stars
1174     ADD R2, R2, R4 ; add it to screen offset
1175     CMP R2, #(320*240) ; wrap round
1176     SUBgt R2, R2, #(320*240)
1177     LDRB R5, [R0, R2]
1178     CMP R5, #0
1179     Bne starloop
1180    
1181     MOV R5, #208
1182     STRB R5, [R0, R2]
1183     B starloop
1184    
1185     .stars_exit
1186     LDMFD R13!, {R0-R9, R14}
1187     MOV PC, R14
1188    
1189     .starfield
1190     EQUD Stars%
1191     .stars_scroll
1192     EQUD 0
1193     .stars_block
1194     EQUD 148
1195     EQUD -1
1196     .screen_base
1197     EQUD 0
1198     .stars_total
1199     EQUD ((Star% - 1) * 4)
1200    
1201     ; --------------------------------------------------------------------------
1202     ;.debug_r0
1203     ; -> R0 = number to display
1204     ; <- no change
1205     ;STMFD R13!, {R0-R2}
1206     ;ADR R1, buffer
1207     ;MOV R2, #16
1208     ;SWI "OS_ConvertHex8"
1209     ;SWI &100 + 30
1210     ;SWI "OS_Write0"
1211     ;LDMFD R13!, {R0-R2}
1212     ;MOV PC, R14
1213     ;.buffer
1214     ; --------------------------------------------------------------------------
1215     ]
1216     NEXT
1217    
1218     ENDPROC
1219    
1220     REM ������������������������������������������������������������������������
1221    
1222     DEF PROCLevel_Init(Level$)
1223     Data% = OPENIN("<HeeHeeHee$Dir>.Levels."+Level$+".Data")
1224     Wide% = VAL(GET$#Data%)
1225     High% = VAL(GET$#Data%)
1226     Y% = 0
1227     X% = 0
1228     REPEAT
1229     Tile% = BGET#Data%
1230    
1231     CASE Tile% OF
1232    
1233     WHEN 10
1234     Y% += 1: X% = 0
1235    
1236     WHEN ASC" "
1237     X% += 1
1238    
1239     WHEN ASC"P"
1240     PROCAmnesia_MakeObject(Table_Platforms%, 3, %1000000001010001, (X% << 16) + (1 << 15), (Y% << 16) + (1 << 15))
1241     X% += 1
1242    
1243     WHEN ASC"L"
1244     Object% = FNAmnesia_MakeObject(Table_Ladders%, 4, %1000000011010001, (X% << 16) + (1 << 15), (Y% << 16) + (1 << 15))
1245     Object%!28 = &0008000F
1246     X% += 1
1247    
1248     WHEN ASC"W"
1249     PROCAmnesia_MakeObject(Table_Walls%, 5, %1000000011010001, (X% << 16) + (1 << 15), (Y% << 16) + (1 << 15))
1250     X% += 1
1251    
1252     WHEN ASC"*"
1253     PROCAmnesia_MakeObject(Table_Items%, 11, %1000000011010001, (X% << 16) + (1 << 15), (Y% << 16) + (1 << 15))
1254     X% += 1
1255    
1256     WHEN ASC"S"
1257     PROCAmnesia_MakeObject(Table_Character%, 1, %1000000011010101, (X% << 16) + (1 << 15), (Y% << 16))
1258     PROCAmnesia_SetPlotOffset((X% << 16) + (1 << 15) + (160 << 12), (Y% << 16) - (120 << 12))
1259    
1260     WHEN ASC"F"
1261     PROCAmnesia_MakeObject(Table_Items%, 10, %1000000011010001, (X% << 16) + (1 << 15), (Y% << 16) + (1 << 15))
1262    
1263     ENDCASE
1264    
1265     UNTIL Y% = High%
1266     CLOSE#Data%
1267    
1268    
1269     Enem% = OPENIN("<HeeHeeHee$Dir>.Levels."+Level$+".Enemies")
1270     WHILE NOT EOF#Enem%
1271     Object% = FNAmnesia_MakeObject(Table_Enemies%, 6, %1000000111010101, (VAL(GET$#Enem%) << 16), (VAL(GET$#Enem%) << 16) + (1 << 15))
1272     Moves% = 0
1273     Object%!36 = 0
1274     Move$ = GET$#Enem%
1275     REPEAT
1276     Object%!(40 + 12 * Moves%) = FNCutVal(Move$) << 12
1277     Object%!(44 + 12 * Moves%) = FNCutVal(Move$) << 12
1278     Object%!(48 + 12 * Moves%) = ((FNCutVal(Move$) - 1) << 16) + 1
1279     Moves% += 1
1280     Move$ = GET$#Enem%
1281     UNTIL Move$ = ""
1282     Object%!32 = Moves%
1283     Object%!16 = Object%!40
1284     Object%!20 = Object%!44
1285     Object%!24 = Object%!48
1286     ENDWHILE
1287     CLOSE#Enem%
1288    
1289    
1290     Droi% = OPENIN("<HeeHeeHee$Dir>.Levels."+Level$+".Droids")
1291     WHILE NOT EOF#Droi%
1292     Object% = FNAmnesia_MakeObject(Table_Droids%, 8, %1000000111010001, (VAL(GET$#Droi%) << 16) + (1 << 15), ((VAL(GET$#Droi%) - 1) << 16) + (1 << 15))
1293     Object%!24 = &00100001 :REM blue (starts)
1294     Object%!32 = &00020001 :REM orange
1295     Object%!36 = &00100001 :REM blue
1296     Object%!40 = 2 :REM lives
1297     ENDWHILE
1298     CLOSE#Droi%
1299    
1300    
1301     !move_right_edge = ((Wide% - 1) << 16) + (1 << 15)
1302     !scroll_x = 0
1303     !scroll_x_end = -((Wide% << 16) - (320 << 12))
1304     !scroll_y = -((High% << 16) - (240 << 12))
1305     !scroll_y_end = -((High% << 16) - (240 << 12))
1306     !platforms_base = (High% << 16)
1307     ENDPROC
1308    
1309     DEF FNCutVal(RETURN Text$)
1310     LOCAL Result$
1311     IF INSTR(Text$, ",") = 0 THEN Result$ = Text$: Text$ = "": =VAL(Result$)
1312     Result$ = LEFT$(Text$, INSTR(Text$, ",") - 1)
1313     Text$ = MID$(Text$, INSTR(Text$, ",") + 1)
1314     =VAL(Result$)
1315    
1316     DEF PROCMakeStars
1317     Star% = 0
1318     Rand% = RND(500)
1319     Addr% = Rand%
1320     REPEAT
1321     Stars%!(Star% * 4) = Rand%
1322     Star% += 1
1323     Rand% = RND(500)
1324     Addr% += Rand%
1325     UNTIL Addr% > (320*240)
1326     ENDPROC

  ViewVC Help
Powered by ViewVC 1.1.26