This repository has been archived by the owner on Oct 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
ATTRACT.S
174 lines (127 loc) · 5.72 KB
/
ATTRACT.S
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
; ATTRACT.S
; THIS ROUTINE IS CALLED BY "GOD" WHEN THE "MODE==MATTRACT".
; IF THIS IS THE FIRST GAME, CHUCK USES RANDOM DIRECTIONS,
; FOR RANDOM AMOUNTS OF TIME.
; IF THIS ISN'T THE FIRST GAME, USE THE INSTANT REPLAY TABLE
; FOR ATTRACT MODES.
;
GLBL DIRTABL,DIRTABH
GLBL CDIR
GLBL RANDOM
GLBL DOGAME
GLBL REPLAY
GLBL GAMEINIT
GLBL AWOLDRAW
GLBL ATTRACT
GLBL MKAUTO
GLBL MKLOGO
GLBL CINFO,FINFO,NEWRACK,MATTRACT
GLBL WON,FALSE
GLBL NEWGAME
GLBL GOD
GLBL STATEND,STATDIE,GLCONT21
GLBL THRWTIME
GLBL DRIPTIME
GLBL ASET
RAMDEF ; ZERO PAGE
RSEG CODE1
ATTRACT LDA STATUS ; IF THIS IS A DEATH WAIT LOOP,
CMP #STATEND ; THEN DON'T CHECK CONTROLLERS
BEQ DOAUTO
LDA NUMCYCLE ; MAKE SURE THAT TIMERS ARE STILL
CMP #1 ; BASED ON REAL (INTERRUPT) TIME
BNE ASKIPINC
INC CYCLECNT ; MAKE SURE THIS IS ONLY ONCE
; PER FRAME
DEC DRIPTIME ; ICE CREAM CONE TIMER FOR ANIMATION
DEC SYSCOUNT ; GENERAL PURPOSE SYSTEM COUNTER
LDA CYCLECNT update FINFO every odd frame
LSR A
BCC ATTCONTZ
DEC FINFO
ASKIPINC JMP DOAUTO
ATTCONTZ LSR A update direction and button every
;fourth frame
BCS ASKIPINC a jump -- not a fourth frame
; ONCE WE REACH HERE, EVERYTHING THAT FOLLOWS IS BEING EXECUTED ONCE
; EVERY TWO FRAMES, REGARDLESS OF "MAXCYCLE"
ATTCONT0 LDA STATUS ; IF HIS EYES ARE ROLLING
CMP #STATDIE
BPL DOAUTO jump-- he's dying
ATTCONT1 LDA GAMECNT use IR tables if its not the first
BEQ ATTCONT2 game, and at least one rack is
LDA ASET completed
; BEQ ATTCONT2
BNE USEIR a jump
ATTCONT2 LDA #6 just make him go left, if no tables
STA JOYDIR
STA CDIR
BNE DOAUTO jump
USEIR JSR REPLAY ; IN "MAIN.S"
; ONLY INCREMENT "CYCLEIDX" AND "THROWIDX" FOR CYCLES
; DURING WHICH CONTROLLERS ARE POLLED
INC CYCLEIDX each table is $80 values of CYCLEIDX
BPL ZATT001
INC CYCLEIDX+1 ; GO TO NEXT BLOCK OF STORAGE
LDX #0
STX CYCLEIDX
ZATT001 LDA CYCLEIDX
AND #$07
BNE DOAUTO
INC THROWIDX ; INCREMENT EVERY 8 TIMES
; TEST FOR THROW, RESET, AND SELECT BUTTONS BEFORE EXECUTING THE GAME
; DRIVER CODE.
; ADDED: TEST THE JOYSTICK: IF "HJOYDIR != CENTER" THEN GO TO LOGO MODE
DOAUTO LDX HTHROW ; SEE IF WE SHOULD START A GAME
BEQ DOAUTO1
LDX THREADY
BEQ DOAUTO1
INX will be TRUE ($FF) if we get here
STX THREADY
BEQ NGJSR a jump
; ELSE, TEST FOR THE RESET BUTTON:
DOAUTO1 LDA FPRESET ; IF RESET BUTTON IS PUSHED, NEW GAME
BEQ DOAUTO2
LDA RESREADY ; MUST BE READY ALSO !
BEQ DOAUTO2
STX RESREADY X=0, the value of FALSE
NGJSR JMP NEWGAME ; BUTTON WAS JUST PUSHED
; ENDCYCLE
DOAUTO2 LDA FPSELECT ; TEST THE SELECT BUTTON
BEQ DOAUTO3
LDA SELREADY
; BEQ DOAUTO3
BNE MKLJMP ; BACK TO THE MENU
; a jump
DOAUTO3 LDA HJOYDIR ; IF THE JOYSTICK HAS BEEN TOUCHED
CMP #08
BEQ DOAUTO4
MKLJMP JMP MKLOGO ; GO TO THE MENU
; SAME AS AT THE BEGINNING OF "GAME"; HANDLES THE WAIT LOOPS AT THE END OF THE
; RACK
DOAUTO4 LDA STATUS
CMP #STATEND
; BEQ ATTCONTA
BNE AUTOON a jump
ATTCONTA DEC WAITCNT ; IF WAITCNT HAS REACHED 0,
BNE ATTCONTB
JMP GLCONT21 ; TIME TO COMPLETE WAIT
ATTCONTB ENDCYCLE
AUTOON JMP DOGAME ; IN "MAIN.S"
; THIS ROUTINE INITIATES THE ATTRACT MODE. IT CALLS ALL THE SAME
; CODE AS "NEWRACK".
MKAUTO LDA #MATTRACT
STA MODE
NEWSTATE ATTRACT
; DMAOFF turn off while loading
LDA GAMECNT ; IF USING THE LAST IR, DON'T RESET
BNE MKAUTO1 ; GAME VARIABLES
JSR GAMEINIT ; SETS APPROPRIATE VARIABLES
MKAUTO1 JSR AWOLDRAW ; DRAWS THE PLAYFIELD WALLS
LDA #FALSE
STA DOITOVER ; SO THAT "RACKINIT" WILL DO IT
LDA #WON
STA CSTATE
JMP NEWRACK same as JSR followed by RTS
; turns DMA back on
END