123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892 |
- ; CHEFMOVE.S
- ; THIS ROUTINE MAKES THE CHEFS CHASE THE HERO.
- ; EACH CHEF HAS A CERTAIN POINT ON THE SCREEN TO AIM FOR. THE
- ; COORDINATES OF THIS POINT ARE STORED IN "XGOAL", "YGOAL".
- ; THE FIRST PART OF THE CHEF LOOP FIGURES OUT THESE TWO VALUES
- ; DEPENDING ON WHICH CHEF IS CURRENTLY BEING PROCESSED; THE LATER
- ; PART MOVES THE CHEF TOWARDS THAT POINT.
- ; THE METHOD OF FIGURING THE DIRECTION IS OBSCURE:
- ; DO X AND Y AXES SEPARATELY. FIRST DO THE Y AXIS.
- ; FOR EACH AXIS, COMPARE THE GOAL AND THE CHEF COORDINATES-; IF
- ; EQUAL, "STA 0". SAVE THIS VALUE IN "TEMP0" WHILE DOING THE
- ; SAME FOR X AXIS. USE THE FOLLOWING FORMULA TO DERIVE AN INDEX
- ; INTO THE DIRECTION TABLE FROM THESE TWO VALUES:
- ; (X + 2) * 4 + (Y + 1) - 4
- GLBL CHASE
- GLBL CHEFMOVE
- GLBL MKREJOY
- CHEFMOVE LDA STATUS ; IF THEY'RE WAITING AFTER A RISE,
- CMP #STATWAIT ; THEN DON'T DO ANYTHING
- BNE CHCONT0
- JMP RISELOOP
- CHCONT0 LDX #12 ; #CHEFSTRT+#NUMCHEF-3
- DOCHEF STX TEMPX
- LDA CSTATE,X ; STATUS IS >= STATDIEH
- CMP #REJOYING
- BMI CHCONT12 there are two rejoice states, $15 and
- JMP REJOICE $16
- CHCONT12 CMP #FEETFALL ; THREE FALLING STATES
- BNE CHCONT1
- JMP FTFALL
- CHCONT1 CMP #HEADFALL
- BNE CHCONT2
- JMP HDFALL
- CHCONT2 CMP #HATFALL
- BNE CHCONT4
- JMP HTFALL
- CHCONT4 CMP #HATRISE ; THREE RISING STATES
- BNE CHCONT5
- JMP HTRISE
- CHCONT5 CMP #HEADRISE
- BNE CHCONT6
- JMP HDRISE
- CHCONT6 CMP #FEETRISE
- BNE CHCONT7
- JMP FTRISE
- CHCONT7 CMP #LEAVING
- BNE CHCONT8
- JMP CHMOVE
- CHCONT8 CMP #NOTYET ; IF THIS IS AN EARLY RACK
- BNE CHCONT9
- JMP NXTCHEF
- ; DON'T PROCESS INVISIBLE CHEFS IF THE STATUS IS WON OR BON.
- ; OR DYING !
- CHCONT9
- LDA STATUS
- CMP #STATWON ; IF HERO IS MUNCHING, KEEP DIRECTION
- BEQ ZCH204
- CMP #STATBON ; IF FOOD IS HITTING SCORE
- BEQ ZCH204
- CMP #STATDIEH ; IF CHUCK HAS DIED VIA ANYTHING
- BPL ZCH204 ; ALSO HANDLES "STATEND"
- LDA CREATOR,X ; COUNTER FOR DEATH AND REBIRTH
- BEQ ZCH202
- ZCH201 DEC CREATOR,X ; IF NOT ZERO, DECREMENT
- ZCH202 LDA CYPOS,X ; IF ZERO, GO TO CHEFWAIT
- BNE ZCH203 ; ELSE, MOVE HIM
- JMP CHEFWAIT
- ZCH203 LDA CINFO,X ; A DIRECTION-CHANGE TIMER
- BMI ZCH100 ; ONLY CHANGE WHEN IT REACHES 0
- DEC CINFO,X ; OTHERWISE, DECREMENT AND MOVE HIM
- ; WE ALWAYS COME HERE BEFORE CONTINUING THROUGH THIS ROUTINE:
- ZCH204 LDA CYPOS,X ; DO THIS TEST AGAIN FOR THE CASE
- BNE ZCH205 ; WHERE THE RACK IS ENDING
- JMP NXTCHEF ; DON'T PROCESS DEAD CHEFS
- ZCH205 JMP CHMOVE ; SKIP OVER DIRECTION CHANGE STUFF
- ; IF WE GET HERE, IT'S TIME TO CHANGE THE DIRECTION OF THIS CHEF:
- ZCH100 JSR RANDOM ; RESET THE MOOD COUNTER
- AND MOODTUFF ; 0-$1F
- STA CINFO,X
- ; THE NEXT BODY OF CODE DECIDES WHICH "GOALX, GOALY" SETTING ROUTINE
- ; TO USE.
- STX TEMP0 ; SAVE REGISTER
- LDA JOYDIR ; JOYSTICK FOR HERO
- CMP #8 ; IF JOYSTICK IS CENTERED,
- BNE SETCHASE
- ALLCHASE JMP FCHEF ; FOLLOWER ALGORITHM
- SETCHASE CPX #3 ; FOLLOWER
- BNE ZCH010 ; IF NOT, CONTINUE
- JMP FCHEF ; FOLLOWER CHEF
- ZCH010 CPX #9 ; INTERLOPER
- BNE ZCH020 ; IF NOT, CONTINUE
- JMP ICHEF ; INTERLOPER CHEF
- ZCH020 CPX #12 ; ANTICIPATOR CHEF
- BNE ZCH030
- JMP ACHEF
- ZCH030 JMP BCHEF ; BEHINDOR CHEF IS THE 2ND (IDX = 6)
- ZCHASE STA GOALY
- LDX TEMP0 ; RESTORE REGISTER
- JSR CHASE ; SETS NEW DIRECTION
- ; BASED ON VALUES IN "GOALX, GOALY".
- LDA CDIR,X ; NO CENTER FOR CHEFS !
- CMP #8
- BNE ZCHASE00
- LDA OLDDIR,X ; KEEP OLD DIRECTION.,
- STA CDIR,X
- ; NOW SET THE HEAD TO FACE IN THIS DIRECTION:
- ZCHASE00 TAY
- LDA CHHEADS,Y ; TELLS US THE CHARACTER
- STA CSTAMP+1,X ; HEAD STAMP (SECOND OF THE THREE)
- CHMOVE LDA CDIR,X ; IF DIRECTION HAS CHANGED,
- CMP OLDDIR,X ; RESET THE DELTAS
- BEQ CHMOVE01
- LDY CSINDEX,X
- LDA MTABINC,Y ; GET INDEX FOR PROPER TABLE AND DIR
- ASL A
- ASL A
- ASL A
- ADC CDIR,X
- TAY
- LDA STABXL,Y
- STA CXSPEEDL,X
- LDA STABXH,Y
- STA CXSPEED,X
- LDA STABYL,Y
- STA CYSPEEDL,X
- LDA STABYH,Y
- STA CYSPEED,X
- LDA CDIR,X
- STA OLDDIR,X
- CHMOVE01 JSR MOVE ; DO THE ACTUAL MOVEMENT
- ; AT THIS POINT, CFRAME,X+1 IS THE ANIMATE COUNTER. IF ZERO, DO THE
- ; ANIMATION; ELSE, JUST SKIP EVERYTHING.
- LDA CFRAME+1,X ; ANIMATE COUNT IS X+1
- BNE ZCHEFA00
- CHEFANIM
- LDA CDIR,X ; GET DIRECTION
- CMP #4 ; 0-3 GET RIGHT ANIMATION
- BPL CHFLANIM
- CHFRANIM LDY CACOUNT,X
- LDA CSTATE,X
- CMP #CARRYING ; IF CARRYING, USE ARM
- BEQ ZCHC00
- LDA CHRUNR,Y ; ELSE, DON'T
- JMP ZCHC01
- ZCHC00 LDA CHRUNRC,Y
- ZCHC01
- STA CSTAMP+2,X ; FEET STAMP
- JMP ZCHEFA01
- CHFLANIM LDA CACOUNT,X
- TAY
- LDA CSTATE,X
- CMP #CARRYING
- BEQ ZCHC02
- LDA CHRUNL,Y
- JMP ZCHC03
- ZCHC02 LDA CHRUNLC,Y
- ZCHC03
- STA CSTAMP+2,X ; STORE TO FEET STAMP (3RD STAMP)
- ZCHEFA01 DEC CACOUNT,X
- LDA CACOUNT,X
- BPL ZCHEFA00
- ZCHF001 LDA #3 ; NUMBER OF CHEF ANIMATIONS (4 FRAMES)
- STA CACOUNT,X
- ; CONTINUE PROCESSING AFTER MOVEMENT AND ANIMATION:
- ZCHEFA00
- LDA CSTATE,X
- CMP #CARRYING
- BEQ CHCONT31
- JMP CHCONT3 ; IF NOT CARRYING, DON'T ADJUST
- ; AND DON'T DEC THRWTIME
- ; IF WE GET HERE, THEN CHECK FOR THROWING AND/OR ADJUSTING FOOD:
- CHCONT31 JSR FOODADJ ; WE KNOW TO ADJUST IF HE'S CARRYING
- LDA THRWTIME,X
- BEQ CHTHROW
- DEC THRWTIME,X ; IN ANY CASE, IF TIMER IS NOT
- ; 0, THEN DECREMENT AND LEAVE
- JMP CHCONT3
- CHTHROW
- LDA THRWTUFF
- STA THRWTIME,X
- LDY HELDFOOD,X
- LDA CDIR,X
- STA CDIR,Y
- ; LDA CXSPEED,X ; SET FOOD DELTAS
- ; STA CXSPEED,Y
- ; LDA CXSPEEDL,X
- ; STA CXSPEEDL,Y
- ; LDA CYSPEED,X
- ; STA CYSPEED,Y
- ; LDA CYSPEEDL,X
- ; STA CYSPEEDL,Y
- LDA #FLYING ; FOR FOODMOVE
- STA CSTATE,Y
- LDA CTYPE,Y
- CMP #2 ; IF IT'S A PIE
- BEQ CHTH004
- CMP #1 ; PEAS
- BNE CHTH0042
- CHTH004 LDA CDIR,X ; USE DIRECTION AS INDEX
- TAX
- LDA PIEFLY,X
- STA CSTAMP,Y ; STORE STAMP
- LDA PIEFLYPW,X
- STA CPALW,Y ; GET PROPER WIDTH OF STAMP
- BNE CHTH005 a jump
- CHTH0041 LDA #1 ; PEAS
- STA CACOUNT,Y
- LDA #16
- STA CINFO,Y
- JMP CHTH005
- CHTH0042 LDA #0 ; ANYTHING NOT PEAS (BANANAS)
- STA CACOUNT,Y
- LDA #1
- STA CINFO,Y
- CHTH005 LDA CTYPE,Y ; MODIFY FLYING SPEED BASED ON
- CMP #4
- BNE CHTH0051
- JSR RANDOM ; WATERMELON CHOOSES RANDOM BEHAVIOR
- AND #$3
- CHTH0051 TAX
- LDA FLYDIST,X ; MODIFY DISTANCE BASED ON TYPE OF
- STA CFLYTIME,Y ; FOOD AND NUMBER OF CYCLES PER FRAME
- ; GET THE "CSINDEX" AND SET "CSPEED" AND THE DELTAS ACCORDINGLY.
- LDA CHFLYSPD,X ; BASED ON FOOD TYPE
- SEC
- SBC HOWHARD faster based on difficulty level
- JSR SETFSPD sets all the food speed stuff
- LDX TEMPX
- LDA #RUNNING ; FREE HIM TO PICK UP MORE FOOD
- STA CSTATE,X
- CHCONT3 LDA CXPOS,X ; SET BOTTOM THIRD COORDS.
- STA CXPOS+2,X ; FEET
- STA CXPOS+1,X ; HEAD
- INC CXPOS+1,X
- LDA CYPOS,X
- SEC
- SBC #HEADTOP ; TOP OF THE HEAD
- STA CYPOS+1,X
- SEC
- SBC #FEETTOP ; TOP OF THE FEET (3RD) STAMP
- STA CYPOS+2,X
- JMP NXTCHEF
- ; JUMP HERE IF THE CHEF'S Y COORDINATE IS ZERO (DEAD CHEF).
- ; IF THE COUNTER HAS REACHED ZERO, THEN MAKE HIM APPEAR.
- ; THE COUNTER TAKES UP TWO BYTES-- LOW BYTE AT CACOUNT,X
- ; HIGH BYTE AT CACOUNT,X+1
- CHEFWAIT LDA CACOUNT,X
- BEQ CH301
- DEC CACOUNT,X ; LOW BYTE
- JMP NXTCHEF
- CH301
- LDA CACOUNT+1,X ; HIGH BYTE
- BEQ CH3032
- DEC CACOUNT+1,X
- LDA #$7F
- STA CACOUNT,X ; LOW BYTE
- JMP NXTCHEF
- ; THE CHEF CAN RISE OUT OF ANY HOLE, OPEN OR SHUT. "CHEFDRAW" WILL OPEN
- ; THE HOLE IF IT'S SHUT--
- CH3032 JSR RANDOM ; PICK A RANDOM OPEN HOLE
- AND #$0F ; TO GET 0-F
- CMP HOLENUM
- BMI CH303 ; NUMBER IS OK
- CH3031 SEC ; KEEP SUBTRACTING UNTIL IT'S OK
- SBC #3
- CMP HOLENUM
- BPL CH3031
- CH303 CLC
- ADC #HOLESTRT
- TAY
- LDA FINFO,Y ; IF "TRUE", SOMEONE'S RISING FROM IT
- BMI CH3032 ; ALREADY
- STY TEMPY ; PLACE IN Y FOR "CHEFDRAW"
- LDA FDLPOS,Y
- AND #$0F ; DISPLAY LIST
- TAX
- LDA LISTTABL,X
- STA LISTPTRA
- LDA LISTTABH,X
- STA LISTPTRA+1
- LDA FDLPOS,Y
- AND #$F0 ; GET POSITION IN DLIST
- LSR A ; POSITION TIMES 4
- LSR A
- TAY
- LDA #OPENCHAR ; DISPLAY THE OPEN HOLE CHARACTER
- STA (LISTPTRA),Y ; LOW BYTE OF HEADER
- LDX TEMPX
- LDY TEMPY
- JSR CHEFDRAW
- NXTCHEF DEX
- DEX
- DEX ; SUBTRACT THREE ! EACH CHEF IS
- ; THREE CHARACTERS
- CPX #CHEFSTRT ; COMPARE X WITH #CHEFSTRT
- BMI CHEFBYE
- JMP DOCHEF
- CHEFBYE
- RTS
- ; THE ROUTINES TO DETERMINE "GOALX, GOALY" FOLLOW:
- FCHEF LDA CXPOS
- STA GOALX
- LDA CYPOS ; STORE ABOVE
- JMP ZCHASE
- ICHEF LDA CXPOS ; GO BETWEEN HERO AND CONE
- CLC
- ADC FXPOS+CONESTRT ; ADD CONE X
- LSR A ; DIVIDE BY 2
- STA GOALX
- LDA CYPOS
- CLC
- ADC FYPOS+CONESTRT
- ROR A ; DIVIDE BY 2 (BRING IN CARRY BIT
- ; SINCE IT CAN BE > 256)
- JMP ZCHASE
- ACHEF LDX JOYDIR ; USE HERO'S DIR AS INDEX TO GOAL
- LDA XCHTAB,X ; COORD. TABLE
- CLC
- ADC CXPOS ; IN FRONT OF HERO
- STA GOALX
- LDA YCHTAB,X
- CLC
- ADC CYPOS ; STORE AFTER RETURN
- JMP ZCHASE
- BCHEF LDX JOYDIR ; USE SAME TABLE, BUT SUBTRACT
- LDA CXPOS
- SEC
- SBC XCHTAB,X ; GO BEHIND HERO
- STA GOALX
- LDA CYPOS
- SEC
- SBC YCHTAB,X ; STORE ABOVE
- JMP ZCHASE
- ; THESE TABLES TELL HOW FAR IN FRONT OF OR BEHIND THE HERO TO AIM FOR,
- ; FOR THE ANTICIPATOR AND BEHINDOR.
- ; requires a 00 in the following table:
- YCHTAB DB $10,$0D,$00,-$0D,-$10,-$0D,$00,$0D
- XCHTAB DB $00,$0D,$10,$0D,$00,-$0D,-$10,-$0D,$00
- CHASETAB DB 5,6,7,$FF,4,8,0,$FF,3,2,1 ; $FF REPRESENTS IMPOSSIBLE
- ; RESULTS FOR THE FORMULA
- ; THE FOLLOWING ROUTINES HANDLE THE THREE FALLING STAGES:
- FTFALL DEC CACOUNT,X
- BEQ ZFT001
- JMP NXTCHEF
- ZFT001 LDA #FSPEED
- STA CACOUNT,X
- DEC CYPOS,X ; LOWER HAT
- DEC CYPOS+1,X ; LOWER HEAD
- DEC CYPOS+2,X ; LOWER FEET
- LDA CYPOS+2,X ; FEET Y POSITION
- CMP CFRAME,X ; BOTTOM OF ZONE
- BMI MKHDFALL ; IF IT'S THERE, GO TO HEAD FALL
- NCHFJMP JMP NXTCHEF
- MKHDFALL LDA #HEADFALL
- STA CSTATE,X
- LDA #$FF ; LOWER ZONE OF HEAD NOT VISIBLE
- STA CSECOND+1,X
- LDA #0
- STA CYPOS+2,X ; FEET POSITION-- ERASE FROM SCREEN
- BEQ NCHFJMP a jump
- HDFALL DEC CACOUNT,X
- BEQ ZHD001
- JMP NXTCHEF
- ZHD001 LDA #FSPEED
- STA CACOUNT,X
- DEC CYPOS,X ; HAT POSITION
- DEC CYPOS+1,X ; HEAD POSITION
- LDA CYPOS+1,X
- CMP CFRAME,X ; BOTTOM OF ZONE
- BMI MKHTFALL
- JMP NXTCHEF
- MKHTFALL LDA #HATFALL
- STA CSTATE,X
- LDA #$FF ; MAKE BOTTOM HALF OF HAT INVISO
- STA CSECOND,X
- LDA #0
- STA CYPOS+1,X ; ERASE HEAD STAMP
- JMP NXTCHEF
- HTFALL DEC CACOUNT,X
- BNE NCHFJMP
- ZHT001 LDA #FSPEED
- STA CACOUNT,X
- DEC CYPOS,X ; HAT POSITION
- LDA CYPOS,X
- CMP CFRAME,X ; BOTTOM OF ZONE
- BMI FLEND
- JMP NXTCHEF
- FLEND LDA #0
- STA CYPOS,X ; ERASE HAT
- LDA #DEAD
- STA CSTATE,X
- LDY HOLEUSED,X ; HOLE NO LONGER IN USE
- LDA #FALSE
- STA FINFO,Y
- INC NUMFALL ; IF IT'S 3, ALL CHEFS HAVE FALLEN
- LDA NUMFALL
- CMP #4
- BNE ZFL002
- ZFL001 LDX LASTCHEF ; LOAD LAST CHEF TO HAVE FALLEN
- LDA #0
- STA CACOUNT,X ; SET COUNTER TO 0 SO IT RISES
- STA CACOUNT+1,X
- LDX TEMPX ; RESTORE CURRENT CHEF INDEX
- ZFL002 STX LASTCHEF ; IN CASE ALL HAVE FALLEN AT ONCE
- LDA #0 ; DISPLAY AS NORMAL WHEN REAPPEARS
- STA CSECOND,X
- STA CSECOND+1,X
- STA CSECOND+2,X
- LDA #$7F
- STA CACOUNT,X ; LOW BYTE OF TIMER
- LDA #1
- STA CACOUNT+1,X ; HIGH BYTE OF TIMER
- JMP NXTCHEF ; GO TO NEXT CHARACTER
- ; THE FOLLOWING ROUTINES HANDLE THE CHEF RISING FROM A HOLE:
- HTRISE DEC CACOUNT,X
- BEQ ZHTRS01
- JMP NXTCHEF
- ZHTRS01 LDA #RZSPEED
- STA CACOUNT,X
- INC CYPOS,X ; HAT Y
- INC CFRAME,X
- LDA CFRAME,X
- CMP #HATHITE ; GROW UNTIL ALL IS VISIBLE
- BEQ MKHDRISE
- JMP NXTCHEF
- MKHDRISE LDA #HEADRISE
- STA CSTATE,X
- LDA #0
- STA CSECOND,X ; MAKE HAT ALL VISIBLE
- LDA CXPOS,X ; HAT X
- CLC
- ADC #1
- STA CXPOS+1,X ; HEAD X
- LDA CYPOS,X ; HAT Y
- SEC
- SBC #HATHITE
- STA CYPOS+1,X ; HEAD Y
- LDA #$FF
- STA CSECOND+1,X ; HEAD-- SECOND HALF INVISO
- LDA #0
- STA CFRAME,X
- JMP NXTCHEF
- HDRISE DEC CACOUNT,X
- BEQ ZHDRS01
- JMP NXTCHEF
- ZHDRS01 LDA #RZSPEED
- STA CACOUNT,X
- INC CYPOS,X ; HAT Y
- INC CYPOS+1,X ; HEAD Y
- INC CFRAME,X
- LDA CFRAME,X
- CMP #HEADHITE
- BEQ MKFTRISE ; IF HEAD IS ALL VISIBLE
- JMP NXTCHEF
- MKFTRISE LDA #FEETRISE
- STA CSTATE,X
- LDA #0
- STA CSECOND+1,X ; MAKE HEAD ALL VISIBLE
- STA CFRAME,X
- LDA #$FF
- STA CSECOND+2,X ; MAKE BOTTOM HALF OF FEET INVISO
- LDA CXPOS,X ; HAT X
- STA CXPOS+2,X ; FEET X
- LDA #$38 ; FEET STAMP
- STA CSTAMP+2,X
- LDA CYPOS+1,X ; HEAD Y
- SEC
- SBC #1
- STA CYPOS+2,X ; FEET Y
- JMP NXTCHEF
- FTRISE DEC CACOUNT,X
- BEQ ZFTRS01
- JMP NXTCHEF
- ZFTRS01 LDA #RZSPEED
- STA CACOUNT,X
- INC CYPOS,X ; HAT Y
- INC CYPOS+1,X ; HEAD Y
- INC CYPOS+2,X ; FEET Y
- INC CFRAME,X
- LDA CFRAME,X
- CMP #FEETHITE
- BEQ ENDRISE ; IF FEET ARE ALL VISIBLE
- JMP NXTCHEF
- ENDRISE LDA #0
- STA CSECOND+2,X ; FEET ALL VISIBLE
- LDY HOLEUSED,X ; FREE HOLE FOR RISINGS
- LDA #FALSE
- STA FINFO,Y
- LDA STATUS
- CMP #STATWON ; IF HE SHOULD RUN RIGHT AND RETREAT
- BEQ ZER000
- CMP #STATBON
- BEQ ZER000
- CMP #STATEND should cover STATENDR also
- BPL ZER011 means that chuck is dead
- CMP #STATDIEH ; REJOICE IF GREATER THAN THIS STATE
- BMI ZER001 ; ELSE, JUST START RUNNING
- ; Come here if STATEND or STATENDR. If it is, then chuck could have WON
- ; or be DEAD-- depending on this, chef should be LEAVING or
- ; REJOICING.
- ZER011 LDA CHEFPALW-3,X change him back from yellow
- STA CPALW,X
- LDA CHEFPALW-2,X
- STA CPALW+1,X
- LDA CHEFPALW-1,X
- STA CPALW+2,X
- LDA CSTATE make him LEAVE if CHUCK just won.
- CMP #WON
- BEQ ZER000
- JSR MKREJOY else, make him rejoice-- chuck is dead
- JMP NXTCHEF
- ZER000 LDA #2 ; MAKE HIM RUN RIGHT
- STA CDIR,X
- LDA #LEAVING ; SO THAT HE DOESN'T CHANGE DIRECTION
- JMP ZER0013
- ZER001 LDA #RUNNING
- ZER0013 STA CSTATE,X
- ZER0012 LDA CSPEED,X
- STA CFRAME,X
- ASL A
- STA CFRAME+1,X
- LDA #3
- STA CACOUNT,X
- LDA #10
- STA CINFO,X
- LDA STATUS
- CMP #STATINIT
- BEQ RWTSTRT ; MAKE THEM SIT GREY FOR AWHILE
- LDA CHEFPALW-3,X ; ELSE, MAKE THIS ONE CHANGE BACK
- STA CPALW,X ; TO REGULAR CHEF PALETTE
- LDA CHEFPALW-2,X
- STA CPALW+1,X
- LDA CHEFPALW-1,X
- STA CPALW+2,X
- JMP NXTCHEF
- RWTSTRT LDA CYCLECNT ; WAIT FOR TWO SECONDS
- CLC
- ADC #60
- STA WAITCNT
- LDA #STATWAIT
- STA STATUS
- CBIJUMP JMP CHEFBYE
- RISELOOP LDA CYCLECNT
- CMP WAITCNT
- BNE CBIJUMP a jump
- RISEOVER LDA #STATPLAY ; MAKE THE GAME START
- STA STATUS
- ; SETUP THE OVERALL SPEED SCALING:
- JSR MAXSET
- LDA #$0F ; THE COLOR WHITE
- STA COLORS+6 ; MAKES THE CHEFS CHANGE
- JMP CHEFBYE
- ; This routine is also called from INIT.S
- MAXSET LDX #1
- LDA PLRACK
- CMP #$10
- BMI MAXCSET if 1-16, set to 1
- INX else set to 2
- MAXCSET STX MAXCYCLE
- RTS
- ; THIS ROUTINE IS USED BY CHEFS MOSTLY, BUT ALSO BY THE FOOD WHEN
- ; IT MUST FLY AT THE HERO AT THE END OF A RACK.
- CHASE LDA CYPOS,X
- SEC
- SBC GOALY
- BPL ZCHEF011
- EOR #$FF
- CLC
- ADC #1
- ZCHEF011 LDY #0
- CMP #4 compares accumulator
- BCC YEND ; CHASE CHUCK ON THE HORIZONTAL
- LDA CYPOS,X ; ELSE, SEE IF HE'S ABOVE OR BELOW
- CMP GOALY ; DESTINATION Y COORD
- BCC ZCHEF01 ; GOAL IS ABOVE
- DEY
- BMI YEND a jump
- ZCHEF01 INY
- YEND STY TEMP0 ; Y VALUE
- LDA CXPOS,X ; NOW DO THE X TEST
- SEC
- SBC GOALX
- BPL ZCHEF031
- EOR #$FF
- CLC
- ADC #1
- ZCHEF031 LDY #0
- CMP #4
- BCC XEND ; CHASE ALONG THE VERTICAL
- LDA CXPOS,X ; ELSE, HE'S RIGHT OR LEFT
- CMP GOALX ; DESTINATION X COORDINATE
- BCC ZCHEF04 ; HERO TO THE RIGHT
- DEY
- BNE XEND a jump
- ZCHEF04 INY
- XEND
- TYA
- ; NOW REGISTER A CONTAINS THE X AXIS INFO, AND "TEMP0" CONTAINS THE Y.
- ; CALCULATE THE "CHASETAB" INDEX USING THE FORMULA ABOVE:
- CLC
- ADC #2 ; X = 1,2,3
- ASL A
- ASL A ; X = 4,8,12
- ; CLC
- ADC TEMP0 ; ADD Y = -1,0,1
- ; SEC
- ADC #$FD ; Y - 3 = -4,-3,-2
- TAY
- LDA CHASETAB,Y ; GET DIRECTION
- CMP #8
- BEQ CHASEBYE
- STA CDIR,X
- CHASEBYE RTS
- ; ALMOST THE SAME AS NORMAL ANIMATION, EXCEPT THERE'S NO VARIATION
- ; FOR DIRECTION
- REJOICE
- DEC CFRAME+1,X
- LDA CFRAME+1,X ; ANIMATE COUNT IS X+1
- BEQ REJANIM ; IF ZERO, ANIMATE
- JMP NXTCHEF ; ELSE, LEAVE THE ROUTINE
- REJANIM
- LDA CSPEED,X ; ANIMATE COUNT IS SPEED TIMES 2
- ASL A
- STA CFRAME+1,X
- LDA CACOUNT,X
- CMP #1 ; LAST TWO FRAMES ARE HIGHER
- BEQ REJ001
- CMP #3 ; FIRST TWO FRAMES MUST BE LOWER
- BEQ REJ002
- BNE REJ003 a jump
- REJ001
- INC CYPOS+2,X
- LDA CACOUNT,X
- JMP REJ003
- REJ002
- DEC CYPOS+2,X
- REJ003 LDY CACOUNT,X
- LDA REJOYCH,Y
- STA CSTAMP+2,X ; FEET STAMP
- DEC CACOUNT,X
- LDA CACOUNT,X
- BPL NCJUMP will be a jump
- ZREJ001 LDA #3 ; NUMBER OF CHEF ANIMATIONS (4 FRAMES)
- STA CACOUNT,X
- NCJUMP JMP NXTCHEF
- ; Used from both chuck and chefmove-- placing it here cuts the number of
- ; bytes needed in half !
- SETFSPD STA CSINDEX,Y
- TAX
- LDA MTABSPD,X
- STA CSPEED,Y
- STA CFRAME,Y
- LDA MTABINC,X ; TELLS WHICH INCREMENT TABLE TO USE
- ASL A ; MULTIPLY BY 8 FOR TABLE BASE
- ASL A
- ASL A
- ADC CDIR,Y ; GET INCREMENT FOR THIS DIRECTION
- TAX
- LDA STABXL,X ; SET FOOD DELTAS
- STA CXSPEEDL,Y
- LDA STABXH,X
- STA CXSPEED,Y
- LDA STABYL,X
- STA CYSPEEDL,Y
- LDA STABYH,X
- STA CYSPEED,Y
- RTS
|