-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.X68
executable file
·2502 lines (2139 loc) · 63.7 KB
/
tasks.X68
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*-----------------------------------------------------------
* Program : Some routines implementing tasks to be used
* with taskmanager installed on trap #0. See
* taskmanager.x68 for more details.
* Written by : A. Burguera
* Date : 11-Dec-2011
* Description: There are four tasks implemented in this file:
* - T1 (Ball): Plots a ball bouncing on the screen.
* - T2 (Double buffer): Manages double buffering
* - T3 (Keyboard): Checks SPACE and creates a new
* ball if pressed.
* - T4 (Mouse): Plots mouse coordinates and checks
* if mouse is inside a ball. If so, the ball
* color is set to green. Also, if mouse is
* clicked, the ball task is killed. This task
* is a good example of how a given task can
* iterate over all tasks to perform actions
* on them.
*-----------------------------------------------------------
************************************************************
* COMMON CONSTANTS *
************************************************************
TK_SCREEN_WIDTH EQU 640
TK_SCREEN_HEIGHT EQU 480
; Task types
TK_TYPE_SPACE EQU 0
TK_TYPE_MAIN EQU 1
TK_TYPE_HIST EQU 2
TK_TYPE_LOSE EQU 3
TK_TYPE_WIN EQU 4
TK_TYPE_SCREEN EQU 5
TK_TYPE_KEYBOARD EQU 6
TK_TYPE_SHIP EQU 7
TK_TYPE_ENEMY EQU 8
TK_TYPE_BULLET EQU 9
TK_TYPE_ENEMY_BULLET EQU 10
TK_TYPE_ENEMY_CREATOR EQU 11
TK_TYPE_LIFE_BAR EQU 12
TK_TYPE_BULLET_COLLECTOR EQU 13
; Variable offsets used for all tasks
TK_VAR_FIRST_TIME EQU 0
TK_VAR_ID EQU 1
TK_VAR_TYPE EQU 2
; Variable offsets used on shared memory
TK_BULLET_COUNT EQU 0
TK_LIFE_HIT EQU 1
TK_SHIP_YPOS EQU 2
TK_BULLET_IDS EQU 4
; Constants
TK_ENTER_XCOR EQU 29
TK_ENTER_YCOR EQU 30
TK_PERM_BULLET EQU 3
************************************************************
* COMMON MACROS *
************************************************************
* ----------------------------------------------------------
TK_SET_RES MACRO
* Sets graphics to window mode and resolution
* Parameters: \1 Width, \2 Height
* ----------------------------------------------------------
move.l #1, D1
move.b #33, D0
trap #15
move.b #33, D0
move.l #\1*$10000+\2, D1
trap #15
ENDM
* ----------------------------------------------------------
TK_DRAW_RECTANGLE MACRO
* Just a wrapper for trap #15 task 87. Parameters must
* be previously loaded in registers as explained in task 87
* docs.
* ----------------------------------------------------------
move.b #87, D0
trap #15
ENDM
* ----------------------------------------------------------
TK_DRAW_ELLIPSE MACRO
* Just a wrapper for trap #15 task 88. Parameters must
* be previously loaded in registers as explained in task 88
* docs.
* ----------------------------------------------------------
move.b #88, D0
trap #15
ENDM
* ----------------------------------------------------------
TK_SET_PEN MACRO
* Sets the drawing pen color
* Parameters: \1 Pen color in format $00BBGGRR
* ----------------------------------------------------------
move.l \1, D1
move.b #80, D0
trap #15
ENDM
* ----------------------------------------------------------
TK_SET_FILL MACRO
* Sets the drawing fill color
* Parameters: \1 fill color in format $00BBGGRR
* ----------------------------------------------------------
move.l \1, D1
move.b #81, D0
trap #15
ENDM
************************************************************
* COMMON STRING *
************************************************************
TK_STR_CONT dc.b 'Press ENTER to continue',0
************************************************************
* INITIALIZATION ROUTINE *
************************************************************
* ----------------------------------------------------------
TK_INIT:
* Adds the tasks in the apropiate order into the task
* manager.
* ----------------------------------------------------------
; Define minimum cycle time
move.l #0, D1
move.b #8, D0
trap #0
; Add draw space task
lea T1_START, A0
clr.b D0
trap #0
; Add main page task
lea T2_START, A0
clr.b D0
trap #0
; Add the double buffer manager
lea T6_START, A0
clr.b D0
trap #0
; Add the keyboard manager
lea T7_START, A0
clr.b D0
trap #0
; Begin music
; lea MUSIC, A1
; move.b #71, D0
; move.b #1, D1
; trap #15
; move.l #1, D2
; move.b #76, D0
; trap #15
rts
* ----------------------------------------------------------
;MUSIC dc.b 'sound02.wav',0
************************************************************
* TASK 1 *
************************************************************
; ==========================================================
; Task 1 constants
; ==========================================================
T1_VAR_X EQU 4
T1_MOD_X EQU 6
T1_MOD_Y EQU 8
T1_VAR_COLOR EQU 10
; ==========================================================
; Task 1 functions
; ==========================================================
* ----------------------------------------------------------
T1_START:
* Task 1 entry point
* Draws starry space on the screen
* ----------------------------------------------------------
; Task memory is set to 0 when task is created. Use
; this to decide whether is the first time or not.
cmp.b #0, TK_VAR_FIRST_TIME(A0)
beq T1_INIT
; If this is not the first time, draw space
; Get and set pen color
TK_SET_PEN T1_VAR_COLOR(A0)
; Start boolean to control X pointer alternation
clr.b D3
; Get starting position
move.w T1_VAR_X(A0), D1
move.w T1_MOD_Y(A0), D2
; Loop to draw first line of stars
.LOOP: move.b #82, D0
trap #15
add.w T1_MOD_X(A0), D1
cmp.w #TK_SCREEN_WIDTH, D1
ble .LOOP
; Jump to next line
not.b D3
cmp.b #$FF, D3
beq .ALTX
move.w T1_VAR_X(A0), D1
bra .MODY
.ALTX: move.w T1_MOD_X(A0), D1
.MODY: add.w T1_MOD_Y(A0), D2
cmp.w #TK_SCREEN_HEIGHT, D2
ble .LOOP
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
T1_INIT:
* Task 1 initialization
* Sets initial space coordinates and loop adds
* ----------------------------------------------------------
; Store task ID. When switching to a task, the ID is in D1, but
; storing in task memory makes things easier.
move.b D1, TK_VAR_ID(A0)
; Store the task type
move.b #TK_TYPE_SPACE, TK_VAR_TYPE(A0)
; Remember that next time will not be the first one
move.b #$FF, TK_VAR_FIRST_TIME(A0)
; Set coordinates where to begin drawing
move.w #5, T1_VAR_X(A0)
; Set distance modifiers
move.w #20, T1_MOD_X(A0)
move.w #10, T1_MOD_Y(A0)
; Set color to white
move.l #$00FFFFFF, T1_VAR_COLOR(A0)
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
************************************************************
* TASK 2 *
************************************************************
; ==========================================================
; Task 2 constants
; ==========================================================
T2_J_X EQU 4
T2_J_Y EQU 6
T2_E_X EQU 8
T2_E_Y EQU 10
T2_T1_X EQU 12
T2_T1_Y EQU 14
T2_T2_X EQU 16
T2_T2_Y EQU 18
T2_A_X EQU 20
T2_A_Y EQU 22
T2_S_X EQU 24
T2_S_Y EQU 26
T2_K_X EQU 28
T2_K_Y EQU 30
T2_PEN_COLOR EQU 32
T2_FILL_COLOR EQU 36
; ==========================================================
; Task 2 functions
; ==========================================================
* ----------------------------------------------------------
T2_START:
* Task 2 entry point
* Shows main page screen
* ----------------------------------------------------------
; Task memory is set to 0 when task is created. Use
; this to decide whether is the first time or not.
cmp.b #0, TK_VAR_FIRST_TIME(A0)
beq T2_INIT
; If this is not the first time, draw title screen
; Set pen and fill color
TK_SET_PEN T2_PEN_COLOR(A0)
TK_SET_FILL T2_FILL_COLOR(A0)
; Draw each letter
move.w T2_J_X(A0), D1
move.w T2_J_Y(A0), D2
bsr TK_J
move.w T2_E_X(A0), D1
move.w T2_E_Y(A0), D2
bsr TK_E
move.w T2_T1_X(A0), D1
move.w T2_T1_Y(A0), D2
bsr TK_T
move.w T2_T2_X(A0), D1
move.w T2_T2_Y(A0), D2
bsr TK_T
move.w T2_A_X(A0), D1
move.w T2_A_Y(A0), D2
bsr TK_A
move.w T2_S_X(A0), D1
move.w T2_S_Y(A0), D2
bsr TK_S
move.w T2_K_X(A0), D1
move.w T2_K_Y(A0), D2
bsr TK_K
bsr TK_ENTER
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
T2_INIT:
* Task 2 initialization
* Sets initial coordinates for each letter
* ----------------------------------------------------------
; Store task ID. When switching to a task, the ID is in D1, but
; storing in task memory makes things easier.
move.b D1, TK_VAR_ID(A0)
; Store the task type
move.b #TK_TYPE_MAIN, TK_VAR_TYPE(A0)
; Remember that next time will not be the first one
move.b #$FF, TK_VAR_FIRST_TIME(A0)
; Set starting coordinates of each letter
move.w #190, T2_J_X(A0)
move.w #115, T2_J_Y(A0)
move.w #280, T2_E_X(A0)
move.w #115, T2_E_Y(A0)
move.w #370, T2_T1_X(A0)
move.w #115, T2_T1_Y(A0)
move.w #145, T2_T2_X(A0)
move.w #205, T2_T2_Y(A0)
move.w #235, T2_A_X(A0)
move.w #205, T2_A_Y(A0)
move.w #405, T2_S_X(A0)
move.w #205, T2_S_Y(A0)
move.w #415, T2_K_X(A0)
move.w #205, T2_K_Y(A0)
; Set pen and fill colors
move.l #$00187AF0, T2_PEN_COLOR(A0)
move.l #$001818F0, T2_FILL_COLOR(A0)
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
************************************************************
* TASK 3 *
************************************************************
; ==========================================================
; Task 3 constants
; ==========================================================
T3_VAR_X EQU 18
T3_VAR_Y EQU 10
; ==========================================================
; Task 3 functions
; ==========================================================
* ----------------------------------------------------------
T3_START:
* Task 3 entry point
* Writes game history
* ----------------------------------------------------------
; Task memory is set to 0 when task is created. Use
; this to decide whether is the first time or not.
cmp.b #0, TK_VAR_FIRST_TIME(A0)
beq T3_INIT
; If this is not the first time, write history
; Set pen and fill color
TK_SET_PEN #$00FFFFFF ; White pen
TK_SET_FILL #$00000000 ; Black fill
; Get and set starting position
move.b #T3_VAR_X, D1
lsl.w #8, D1
move.b #T3_VAR_Y, D1
move.b #11, D0
trap #15
; Draw strings. Set position before every string
lea T3_STR_1, A1
move.b #14, D0
trap #15
or.w #$FF00, D1
and.w #$0AFF, D1
addq.w #2, D1
move.b #11, D0
trap #15
lea T3_STR_2, A1
move.b #14, D0
trap #15
or.w #$FF00, D1
and.w #$0DFF, D1
addq.w #2, D1
move.b #11, D0
trap #15
lea T3_STR_3, A1
move.b #14, D0
trap #15
or.w #$FF00, D1
and.w #$06FF, D1
addq.w #2, D1
move.b #11, D0
trap #15
lea T3_STR_4, A1
move.b #14, D0
trap #15
or.w #$FF00, D1
and.w #$1EFF, D1
addq.w #2, D1
move.b #11, D0
trap #15
lea T3_STR_5, A1
move.b #14, D0
trap #15
bsr TK_ENTER
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
T3_INIT:
* Task 3 initialization
* Sets initial string coordinates
* ----------------------------------------------------------
; Store task ID. When switching to a task, the ID is in D1, but
; storing in task memory makes things easier.
move.b D1, TK_VAR_ID(A0)
; Store the task type
move.b #TK_TYPE_HIST, TK_VAR_TYPE(A0)
; Remember that next time will not be the first one
move.b #$FF, TK_VAR_FIRST_TIME(A0)
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
; ==========================================================
; Task 3 strings
; ==========================================================
T3_STR_1 dc.b 'A new war is developed in the Andromeda galaxy.',0
T3_STR_2 dc.b 'Talaskia creatures have sent an scout to undermine our defenses.',0
T3_STR_3 dc.b 'It is suspected that some commander is behind the attack.',0
T3_STR_4 dc.b 'Your mission, as captain of the KOBAYASHI MARU, is to stop the advance.',0
T3_STR_5 dc.b 'Long live and prosper.',0
************************************************************
* TASK 4 *
************************************************************
; ==========================================================
; Task 4 constants
; ==========================================================
T4_G_X EQU 4
T4_G_Y EQU 6
T4_A_X EQU 8
T4_A_Y EQU 10
T4_M_X EQU 12
T4_M_Y EQU 14
T4_E1_X EQU 16
T4_E1_Y EQU 18
T4_O_X EQU 20
T4_O_Y EQU 22
T4_V_X EQU 24
T4_V_Y EQU 26
T4_E2_X EQU 28
T4_E2_Y EQU 30
T4_R_X EQU 32
T4_R_Y EQU 34
T4_PEN_COLOR EQU 36
T4_FILL_COLOR EQU 40
; ==========================================================
; Task 4 functions
; ==========================================================
* ----------------------------------------------------------
T4_START:
* Task 4 entry point
* Shows GAME OVER screen
* ----------------------------------------------------------
; Task memory is set to 0 when task is created. Use
; this to decide whether is the first time or not.
cmp.b #0, TK_VAR_FIRST_TIME(A0)
beq T4_INIT
; If this is not the first time, draw GAME OVER screen
; Set pen and fill color
TK_SET_PEN T4_PEN_COLOR(A0)
TK_SET_FILL T4_FILL_COLOR(A0)
; Draw each letter
move.w T4_G_X(A0), D1
move.w T4_G_Y(A0), D2
bsr TK_G
move.w T4_A_X(A0), D1
move.w T4_A_Y(A0), D2
bsr TK_A
move.w T4_M_X(A0), D1
move.w T4_M_Y(A0), D2
bsr TK_M
move.w T4_E1_X(A0), D1
move.w T4_E1_Y(A0), D2
bsr TK_E
move.w T4_O_X(A0), D1
move.w T4_O_Y(A0), D2
bsr TK_O
move.w T4_V_X(A0), D1
move.w T4_V_Y(A0), D2
bsr TK_V
move.w T4_E2_X(A0), D1
move.w T4_E2_Y(A0), D2
bsr TK_E
move.w T4_R_X(A0), D1
move.w T4_R_Y(A0), D2
bsr TK_R
bsr TK_ENTER
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
T4_INIT:
* Task 4 initialization
* Sets initial coordinates for each letter
* Also deletes al tasks of game play
* ----------------------------------------------------------
; Store task ID. When switching to a task, the ID is in D1, but
; storing in task memory makes things easier.
move.b D1, TK_VAR_ID(A0)
; Store the task type
move.b #TK_TYPE_LOSE, TK_VAR_TYPE(A0)
; Remember that next time will not be the first one
move.b #$FF, TK_VAR_FIRST_TIME(A0)
; Set starting coordinates of each letter
move.w #225, T4_G_X(A0)
move.w #115, T4_G_Y(A0)
move.w #235, T4_A_X(A0)
move.w #115, T4_A_Y(A0)
move.w #325, T4_M_X(A0)
move.w #195, T4_M_Y(A0)
move.w #415, T4_E1_X(A0)
move.w #115, T4_E1_Y(A0)
move.w #145, T4_O_X(A0)
move.w #205, T4_O_Y(A0)
move.w #235, T4_V_X(A0)
move.w #205, T4_V_Y(A0)
move.w #325, T4_E2_X(A0)
move.w #205, T4_E2_Y(A0)
move.w #495, T4_R_X(A0)
move.w #205, T4_R_Y(A0)
; Set pen and fill colors
move.l #$00187AF0, T4_PEN_COLOR(A0)
move.l #$001818F0, T4_FILL_COLOR(A0)
; Delete all tasks except SPACE, BUFFER, KEYBOARD and this one
bsr TK_DELETE
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
************************************************************
* TASK 5 *
************************************************************
; ==========================================================
; Task 5 constants
; ==========================================================
T5_VAR_X EQU 32
T5_VAR_Y EQU 10
; ==========================================================
; Task 5 functions
; ==========================================================
* ----------------------------------------------------------
T5_START:
* Task 5 entry point
* Writes game win page
* ----------------------------------------------------------
; Task memory is set to 0 when task is created. Use
; this to decide whether is the first time or not.
cmp.b #0, TK_VAR_FIRST_TIME(A0)
beq T5_INIT
; If this is not the first time, draw CONGRATULATIONS screen
; Set pen and fill color
TK_SET_PEN #$00FFFFFF ; White pen
TK_SET_FILL #$00000000 ; Black fill
; Get and set starting position
move.b #T5_VAR_X, D1
lsl.w #8, D1
move.b #T5_VAR_Y, D1
move.b #11, D0
trap #15
; Draw strings. Set position before every string
lea T5_STR_1, A1
move.b #14, D0
trap #15
or.w #$FF00, D1
and.w #$0CFF, D1
addq.w #3, D1
move.b #11, D0
trap #15
lea T5_STR_2, A1
move.b #14, D0
trap #15
or.w #$FF00, D1
and.w #$16FF, D1
addq.w #2, D1
move.b #11, D0
trap #15
lea T5_STR_3, A1
move.b #14, D0
trap #15
bsr TK_ENTER
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
T5_INIT:
* Task 5 initialization
* Sets initial string coordinates
* Also deletes al tasks of game play
* ----------------------------------------------------------
; Store task ID. When switching to a task, the ID is in D1, but
; storing in task memory makes things easier.
move.b D1, TK_VAR_ID(A0)
; Store the task type
move.b #TK_TYPE_WIN, TK_VAR_TYPE(A0)
; Remember that next time will not be the first one
move.b #$FF, TK_VAR_FIRST_TIME(A0)
; Delete all tasks except SPACE, BUFFER, KEYBOARD and this one
bsr TK_DELETE
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
; ==========================================================
; Task 5 strings
; ==========================================================
T5_STR_1 dc.b 'CONGRATULATIONS!',0
T5_STR_2 dc.b 'You have defeated the Talaskian scout and its commander.',0
T5_STR_3 dc.b 'Return to base and enjoy your reward.',0
************************************************************
* TASK 6 *
************************************************************
; ==========================================================
; Task 6 functions
; ==========================================================
* ----------------------------------------------------------
T6_START:
* Task 6 entry point
* Does the double buffer thing
* First time:
* - Init double buffer
* - Clears hidden buffer
* Further executions
* - Shows graphics
* Note: This task must be added to Task Manager after all those
* tasks that paint something on screen
* ----------------------------------------------------------
cmp.b #0, TK_VAR_FIRST_TIME(A0)
beq T6_INIT
; Show hidden buffer
move.b #94, D0
trap #15
; Clear hidden buffer and exit
bra T6_CLEAR_HIDDEN
* ----------------------------------------------------------
T6_INIT:
* Task 6 initialization
* ----------------------------------------------------------
; Store task ID. When switching to a task, the ID is in D1, but
; storing in task memory makes things easier.
move.b D1, TK_VAR_ID(A0)
; Store the task type
move.b #TK_TYPE_SCREEN, TK_VAR_TYPE(A0)
; Remember next time will not be the first one
move.b #$FF, TK_VAR_FIRST_TIME(A0)
; Set resolution
TK_SET_RES TK_SCREEN_WIDTH, TK_SCREEN_HEIGHT
; Init double buffer
move.b #92, D0
move.b #17, D1
trap #15
; Clear hidden buffer (make it black)
T6_CLEAR_HIDDEN: TK_SET_PEN #$00000000
TK_SET_FILL #$00000000
move.w #0, D1
move.w #0, D2
move.w #TK_SCREEN_WIDTH, D3
move.w #TK_SCREEN_HEIGHT, D4
move.b #87, D0
trap #15
; move.w #$FF00, D1
; move.b #11, D0
; trap #15
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
************************************************************
* TASK 7 *
************************************************************
; ==========================================================
; Task 7 constants
; ==========================================================
T7_VAR_UP EQU 4
T7_VAR_DOWN EQU 5
T7_VAR_SPACE EQU 6
T7_VAR_ENTER EQU 7
; ==========================================================
; Task 7 functions
; ==========================================================
* ----------------------------------------------------------
T7_START:
* Task 7 entry point
* Checks for [UP], [DOWN], [SPACE] and [ENTER]
* Different functions with each button if pressed
* ----------------------------------------------------------
cmp.b #0, TK_VAR_FIRST_TIME(A0)
beq T7_INIT
; Check and get UP, DOWN, SPACE and ENTER keys state
move.b #19, D0
move.l #$2628200D, D1
;move.l #'W'<<24+'S'<<16,D1
;move.w #$200D, D1 ; Check for Up, Down, Space and Enter
trap #15
and.l #$01010101, D1 ; Just change FF to 01 to
; avoid sign problems
move.b D1, D3
lsr.l #8, D1
move.b D1, D4
lsr.l #8, D1
move.b D1, T7_VAR_DOWN(A0)
lsr.l #8, D1
move.b D1, T7_VAR_UP(A0)
; Check for SHIP task. If it not exist, jump to ENTER operations
move.b #6, D0
trap #0
T7_TASK_LOOP: cmp.b #TK_TYPE_SHIP, TK_VAR_TYPE(A1)
beq T7_UDS_OP
move.b #7, D0
trap #0
cmp.b #$FF, D1
bne T7_TASK_LOOP
bra T7_ENTER_OP
; If UP key was not pressed, jump to DOWN operations
T7_UDS_OP: btst.b #0, T7_VAR_UP(A0)
beq T7_DOWN_OP
subq.w #1, T8_VAR_Y(A1)
; If DOWN key was not pressed, jump to SPACE operations
T7_DOWN_OP: btst.b #0, T7_VAR_DOWN(A0)
beq T7_SPACE_OP
addq.w #1, T8_VAR_Y(A1)
; Check if SPACE was pressed previously.
T7_SPACE_OP: move.b D4, D1
sub.b T7_VAR_SPACE(A0), D1
cmp.b #1, D1
bne T7_END
move.w T8_VAR_Y(A1), D5 ; Save current y-position of space ship
; Recover task data
move.b #4, D0
trap #0
move.w D5, TK_SHIP_YPOS(A1) ; Save space ship current y-position in shared memory
; If there are more than the permitted bullets on screen, do nothing
cmp.b #0, TK_BULLET_COUNT(A1)
beq T7_END
; If not, create a new bullet and subtract one from the permitted bullets
lea T10_START, A0
clr.b D0
trap #0
subq.b #1, TK_BULLET_COUNT(A1)
bra T7_END ; Jump ENTER operations
; Check that ENTER was not pressed previously
T7_ENTER_OP: move.b D3, D1
sub.b T7_VAR_ENTER(A0), D1
cmp.b #1, D1
bne T7_END
; If ENTER was pressed, search in which task was
move.b #6, D0
trap #0
T7_ENTER_LOOP: cmp.b #TK_TYPE_MAIN, TK_VAR_TYPE(A1)
beq T7_MAIN_OP
cmp.b #TK_TYPE_HIST, TK_VAR_TYPE(A1)
beq T7_HIST_OP
cmp.b #TK_TYPE_LOSE, TK_VAR_TYPE(A1)
beq T7_LW_OP
cmp.b #TK_TYPE_WIN, TK_VAR_TYPE(A1)
beq T7_LW_OP
move.b #7, D0
trap #0
bra T7_ENTER_LOOP
; If it's MAIN task, then remove it and put HISTORY task
T7_MAIN_OP: move.b D2, D1
move.b #1, D0
trap #0
lea T3_START, A0
clr.b D0
trap #0
bra T7_END
; It it's HISTORY task, then remove it and put SHIP, ENEMY_CREATOR,
; LIFE_BAR and BULLET_COLLECTOR tasks
T7_HIST_OP: move.b D2, D1
move.b #1, D0
trap #0
clr.b D0
lea T8_START, A0
trap #0
lea T12_START, A0
trap #0
lea T13_START, A0
trap #0
lea T14_START, A0
trap #0
bra T7_END
; If it's GAME_OVER or CONGRATULATION task, then remove it and put MAIN task
T7_LW_OP: move.b D2, D1
move.b #1, D0
trap #0
lea T2_START, A0
clr.b D0
trap #0
; End by switching to next task
T7_END: move.b #4, D0
trap #0
move.b D3, T7_VAR_ENTER(A0)
move.b D4, T7_VAR_SPACE(A0)
move.b #3, D0
trap #0
* ----------------------------------------------------------
T7_INIT:
* Task 7 initialization
* ----------------------------------------------------------
; Store task ID. When switching to a task, the ID is in D1, but
; storing in task memory makes things easier.
move.b D1, TK_VAR_ID(A0)
; Store the task type
move.b #TK_TYPE_KEYBOARD, TK_VAR_TYPE(A0)
; Remember next time will not be the first one
move.b #$FF, TK_VAR_FIRST_TIME(A0)
; Assuming that prior to execution keys were not pressed
clr.b T7_VAR_UP(A0)
clr.b T7_VAR_DOWN(A0)
clr.b T7_VAR_SPACE(A0)
clr.b T7_VAR_ENTER(A0)
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
************************************************************
* TASK 8 *
************************************************************
; ==========================================================
; Task 8 constants
; ==========================================================
T8_VAR_Y EQU 4
T8_PEN_COLOR EQU 6
T8_FILL_COLOR EQU 10
T8_SHIP_DIST EQU 5
T8_RADIUS EQU 15
; ==========================================================
; Task 8 functions
; ==========================================================
* ----------------------------------------------------------
T8_START:
* Task 8 entry point
* Draw space ship
* ----------------------------------------------------------
; Task memory is set to 0 when task is created. Use
; this to decide whether is the first time or not.
cmp.b #0, TK_VAR_FIRST_TIME(A0)
beq T8_INIT
; If this is not the first time, draw space ship
; Set pen and fill color
TK_SET_PEN T8_PEN_COLOR(A0)
TK_SET_FILL T8_FILL_COLOR(A0)
; Set coordinates
move.w #T8_RADIUS, D1
lsl.w #1, D1
addq.w #T8_SHIP_DIST, D1
move.w D1, D3 ; For later use
move.w T8_VAR_Y(A0), D2
move.w D2, D4 ; For later use
move.b #86, D0
trap #15
; Draw space ship lines
move.b #85, D0
move.w #T8_SHIP_DIST, D1
sub.w #T8_RADIUS, D2
trap #15
move.w D4, D2
add.w #T8_RADIUS, D2
trap #15
move.w D3, D1
move.w D4, D2
trap #15
; Fill space ship
sub.w #T8_SHIP_DIST, D1
move.b #89, D0
trap #15
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
T8_INIT:
* Task 8 initialization
* Sets initial space ship coordinates and color
* ----------------------------------------------------------
; Store task ID. When switching to a task, the ID is in D1, but
; storing in task memory makes things easier.
move.b D1, TK_VAR_ID(A0)
; Store the task type
move.b #TK_TYPE_SHIP, TK_VAR_TYPE(A0)
; Remember that next time will not be the first one
move.b #$FF, TK_VAR_FIRST_TIME(A0)
; Set ship starting coordinates
move.w #TK_SCREEN_HEIGHT/2, T8_VAR_Y(A0)
; Set space ship pen and fill colors
move.l #$0000FF00, T8_PEN_COLOR(A0)
move.l #$0000AB00, T8_FILL_COLOR(A0)
; End by switching to next task
move.b #3, D0
trap #0
* ----------------------------------------------------------
************************************************************
* TASK 9 *
************************************************************
; ==========================================================
; Task 9 constants
; ==========================================================
T9_VAR_X EQU 4
T9_VAR_Y EQU 6
T9_VAR_SX EQU 8
T9_VAR_SY EQU 10
T9_PEN_COLOR EQU 12
T9_FILL_COLOR EQU 16
T9_SHOOT_COUNTER EQU 20
T9_SHOOT_READY EQU 22
T9_ENEMY_SIDE EQU 52