123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- ; FOODMOVE.S
- ; (THIS FILE ALSO CONTAINS THE ICE CREAM CONE DRIVER, "ICEMELT").
- ; THIS ROUTINE MAKES THE FOODS FLY THROUGH THE AIR. IN ADDITION, IT
- ; DECREMENTS THE TIME COUNTER ("FINFO"), AND IF IT'S ZERO,
- ; DECREMENTS THE SECOND TIME COUNTER ("FLYTIMER"). WHEN THIS TIMER
- ; IS ZERO, THEN IT'S TIME TO FADE OUT THE FOOD.
- ; THE MOVEMENT ALGORITHM USED IS THE SAME AS FOR THE CHEFS AND CHUCK;
- ; TO GET A FASTER SPEED, DIFFERENT MOVEMENT TABLES MUST BE USED.
- ; THESE ARE USED BY CHUCK AND CHEFS IN HIGHER RACKS ANYWAY TO
- ; GET LIGHTNING FAST GAMES.
- ; 8/26/83 : CODE FOR THE ANIMATED BANANA INSERTED.
- ; 9/01/83 : CODE FOR THE DISPERSING PEAS INSERTED.
- ; 11/04/83 : CODE FOR ANGLED MOVEMENT INSERTED
- GLBL PLRACK,GOD
- GLBL STATBON,STATDIE
- GLBL NUMFOOD
- GLBL CHSTAMP,BLOCK1,SPLATCH,SPLATPW,THRWTIME
- GLBL NEXTPILE,LASTPILE,FINFO,NUMEPILE
- GLBL TAKEFOOD,FXPOS,FYPOS,CSPEED,CFRAME,CTYPE,CFLYTIME
- GLBL SPLAT,FLYING,STATHIT,CDIR
- GLBL CHASE,MOVE,DEAD,WON,CACOUNT,CSTAMP,CPALW
- GLBL ANGLE,STICKING,NUMSTUCK
- GLBL CINFO,NUMINAIR,ALLGONE
- GLBL STATEND
- GLBL STATENDR
- GLBL CXSPEED,CXSPEEDL,CYSPEED,CYSPEEDL
- GLBL CXPOSL,CYPOSL
- GLBL FLYCHAR,FLYPALW
- GLBL FSTATE
- GLBL FOODMOVE
- GLBL WAIT
- GLBL PIEFLY,PIEFLYPW,BANFLY,BANFLYPW,PEAFLY
- GLBL XVECTORH,XVECTORL,YVECTORH,YVECTORL,SCOREX
- FOODSTRT EQU $0F
- PILESTRT EQU $01
- SCOREY EQU $AF
- RAMDEF ; ZERO PAGE
- RSEG CODE2
- FOODMOVE LDA STATUS
- CMP #STATBON
- ; BNE FMCONT11
- BEQ FMWONJMP becomes a jump
- FMCONT11 CMP #STATHIT
- BNE FMCONT10
- FMWONJMP JMP FMWON
- FMWONBYE
- FMCONT10 LDX #$1E foodstrt($f) + numfood($10) - 1
- FLOOP LDA CYPOS,X
- ; BNE FMSKIP11
- BEQ NXTFJMP becomes a jump
- FMSKIP11 LDA CSTATE,X
- CMP #STICKING
- BNE FMSKIP12
- NXTFJMP JMP NXTFOOD
- FMSKIP12 CMP #SPLAT
- BNE FMSKIP1
- JMP FMSPLAT
- FMSKIP1
- STX TEMPX
- CMP #FLYING
- BEQ FM040
- CMP #ANGLE
- ; BEQ FM030
- BNE NXTFJMP same as a jump
- FM030 LDY TEMPX ; IF IT'S HITTING SCORE OR CHUCK
- ; PUT THE FOOD INDEX IN Y
- JSR SETDELTA
- LDX TEMPX ; RESTORE FOR "MOVE"
- FM040 JSR MOVE ; MOVES THE FOOD
- LDX TEMPX ; RESTORE FOOD INDEX
- FM060 LDA CSTATE,X ; SEE IF "MOVE" JUST SET THE FOOD
- CMP #SPLAT ; TO BE SPLATTING
- ; BNE FMSKIP21
- BEQ NXTFJMP same as a jump
- FMSKIP21 CMP #ANGLE ; IF FLYING AT END OF RACK,
- BEQ FMSKIP22 ; DON'T LET IT DISAPPEAR
- LDA NUMCYCLE only decrement once every second
- CMP #1
- BNE FMSKIP22
- DEC CFLYTIME,X ; DECREMENT THE TIMER
- BEQ FDERASE ; IF ZERO, REMOVE FOOD
- ; NOW TEST TO SEE IF ANIMATION IS NECESSARY:
- FMSKIP22 LDA CTYPE,X ; TYPE OF FOOD
- BEQ BANANI1 ; BANANA TYPE IS 0
- CMP #1 ; PEAS
- BEQ PEAANI1
- JNXTFD JMP NXTFOOD
- BANANI1 LDA CFRAME,X
- AND #$7F
- BNE NXTFOOD
- LDA PLRACK ; IF RACK 17 OR ABOVE
- AND #$F0 ; THEN ONLY ANIMATE EVERY OTHER TIME.
- BEQ BANANI2
- LDA CYCLECNT
- AND #$01
- BNE NXTFOOD
- BANANI2 LDA CACOUNT,X ; TELLS WHICH FRAME OF ANIMATION
- TAY
- LDA BANFLY,Y
- STA CSTAMP,X
- LDA BANFLYPW,Y
- STA CPALW,X
- DEC CACOUNT,X
- ; BMI ZFM001
- BPL JNXTFD
- ZFM001 LDA #7 ; 8 DIFFERENT BANANA FRAMES
- STA CACOUNT,X
- JMP NXTFOOD
- PEAANI1 DEC CINFO,X ; ANIMATE COUNTER
- ; BEQ PEAANI2
- BNE NXTFOOD same as a jump
- PEAANI2 LDA #8 ; RESET ANIMATE COUNTER
- STA CINFO,X
- LDY CACOUNT,X ; FRAME INDEX
- BMI NXTFOOD ; IF LAST FRAME WAS ALREADY REACHED
- LDA PEAFLY,Y
- STA CSTAMP,X
- DEC CACOUNT,X ; PREPARE FOR NEXT FRAME
- JMP NXTFOOD
- FDERASE LDA STATUS
- CMP #STATBON ; IF FLYING TOWARDS SCORE,
- BEQ FDERASE1 ; GO ALL THE WAY TO THE WALL
- CMP #STATDIE ; IF FLYING TOWARDS HERO,
- BMI FDERASE2
- FDERASE1 LDA #$7F ; KEEP IT FLYING
- STA CFLYTIME,X
- BNE NXTFOOD same as a jump
- FDERASE2 LDA #0
- STA CYPOS,X
- NXTFOOD DEX
- CPX #FOODSTRT
- BMI FMSKIP9
- JMP FLOOP
- FMSKIP9
- FMBYE
- RTS
- ; THIS CODE IS EXECUTED WHEN THE HERO HAS FINISHED MUNCHING AND
- ; IS SMILING; THE FOOD SHOULD ALL FLY UP TO THE SCORE
- ; THIS SAME CODE IS USED TO MAKE THE FOOD FLY AT THE HERO
- ; WHEN HE'S JUST DIED.
- ;FMDIE LDA STATUS
- ; CMP #STATHIT
- ; BEQ FMWON
- ; JMP FMBYE
- FMDIE
- FMWON
- LDA NUMINAIR ; IF THERE'S A FREE FOOD SPACE, THROW
- CMP #NUMFOOD
- ; BMI FMWCONT0
- BPL FMWBYE
- FMWCONT0 LDA ALLGONE ; TEST TO SEE IF ALL ARE IN THE AIR
- BNE ZFM003 ; IF SO, STOP IF NUMINAIR == 0
- LDA THRWTIME ; SPACES OUT FOOD THROWS
- BEQ ZFM004 ; THROW IF IT'S TIME
- DEC THRWTIME
- FMWBYE JMP FMWONBYE
- ZFM003 LDA NUMINAIR
- BNE FMWBYE
- JMP ALLOVER ; IF NO FOODS REMAIN IN THE AIR
- ZFM004 LDA #5 ; "DEBOUNCING" TIMER FOR FOOD
- STA THRWTIME
- LDX NEXTPILE ; FIND A FOOD
- STX LASTPILE
- ZFMLOOP1 LDA FINFO,X
- ASL A ; BIT 6 HIGH MEANS BOTTOM HALF
- BMI ZFMEND1 ; ONLY TOP HALVES
- AND #$08 ; DONT THROW WATERMELONS AT SCORE
- BEQ ZFMENDZZ
- LDA STATUS ; THROW WATERMELON IF CHARLIE DIED.
- CMP #STATHIT
- BNE ZFMEND1
- ZFMENDZZ LDA FSTATE,X
- BNE ZFMWONTH ; IF THE PILE IS NON-EMPTY
- ZFMEND1 INX
- STX NEXTPILE
- CPX LASTPILE
- BNE ZFMEND2
- JMP SETALLGN ; IF WE'VE LOOPED ALL THE WAY AROUND
- ZFMEND2 CPX #PILESTRT+NUMEPILE
- BMI ZFMLOOP1
- LDX #PILESTRT ; WE'VE REACHED THE END-- WRAP AROUND
- STX NEXTPILE
- CPX LASTPILE
- BNE ZFMLOOP1
- JMP SETALLGN
- ZFMWONTH INC NEXTPILE ; NEXT ONE TO CHECK IS ONE BEYOND
- LDA NEXTPILE
- CMP #PILESTRT+NUMEPILE
- BMI ITSOKAY
- LDA #PILESTRT
- STA NEXTPILE
- ITSOKAY TXA
- PHA ; SAVE PILE INDEX
- TAY ; PILE INDEX MUST BE IN Y
- JSR TAKEFOOD ; GET ONE FOOD FROM PILE
- TAY ; FOOD INDEX IS NOW IN A
- PLA
- TAX ; X CONTAINS PILE INDEX
- INC NUMINAIR
- LDA FXPOS,X ; SET FOOD POSITION
- STA CXPOS,Y
- LDA FYPOS,X
- STA CYPOS,Y
- LDA #ANGLE
- STA CSTATE,Y
- ; INITIALIZE THE DELTA VALUES FOR ANGLED MOVEMENT
- LDA STATUS
- CMP #STATBON
- BNE ZFMDIE ; "GOALN" SET IN "HEROKILL"
- LDX CURRENT ; ELSE ITS HITTING CHUCK
- LDA SCOREX,X
- STA GOALX
- LDA #SCOREY
- STA GOALY
- ZFMDIE
- JSR SETDELTA ; DOESN'T ALTER Y
- STY TEMPY
- LDX TEMPY ; FOOD INDEX IN "X" FOR CHASE
- JSR CHASE ; SETS "CDIR" FOR SPLAT POSITION
- LDY TEMPY ; "Y" USED BY "CHASE"
- LDA #0 ; INITIALIZE LOW BYTES OF POSITION
- STA CYPOSL,Y
- STA CXPOSL,Y
- ; NOW INITIALIZE FOOD FOR ANIMATION, CHARACTERS, ETC.
- ZFMANIM LDA CTYPE,Y
- CMP #2 ; PIE TYPE IS 2
- BEQ ZFMTH00
- CMP #1 ; PEAS
- BEQ ZFMTH01
- ZFMTH02 LDA #01 ;ANYTHING BUT PEAS
- STA CINFO,Y ; FOR ALL TYPES OTHER THAN PEAS
- LDA #0
- STA CACOUNT,Y
- JMP ZFMTH10
- ZFMTH00 LDA CDIR,Y ; USE DIRECTION AS TABLE INDEX
- TAX
- LDA PIEFLY,X ; GET STAMP
- STA CSTAMP,Y ; STORE IT
- LDA PIEFLYPW,X ; GET PALETTE WIDTH
- STA CPALW,Y
- JMP ZFMTH10
- ZFMTH01 LDA #1 ; IF IT'S PEAS, SET UP FOR DISPERSAL
- STA CACOUNT,Y ; FRAME INDEX
- LDA #16
- STA CINFO,Y
- *ZFMTH10 LDA #$81 ; DOUBLE THE SPEED
- ZFMTH10 LDA #0
- STA CSPEED,Y
- STA CFRAME,Y
- LDA #$FF ; 4 SECONDS
- STA CFLYTIME,Y
- JMP FMWONBYE ; THROW ONE PER CODE CYCLE
- SETALLGN LDA #$FF
- STA ALLGONE
- JMP FMWONBYE
- ALLOVER LDA STATUS
- CMP #STATBON ; IF HE'S WON
- BEQ ZALLOV01
- LDA #DEAD ; ELSE, WE KNOW HE'S LOST
- STA CSTATE
- JMP ZALLOV02
- ZALLOV01 LDA #WON
- STA CSTATE ; MAKES NEW RACK START
- ZALLOV02 LDA #90 ; WAIT FOR 1.5 SECONDS
- STA WAITCNT
- LDA DOITOVER
- BEQ ZALLOV03 ; NOT AN IR
- LDA #STATENDR ; AN IR
- JMP ZALLOV04
- ZALLOV03 LDA #STATEND ; ONLY CHEF DRIVER WILL RUN
- ZALLOV04 STA STATUS
- ; INSTEAD OF "RTS" TO "GAME", POP THE RETURN ADDRESS AND JUMP TO GOD
- PLA
- PLA
- ENDCYCLE
- ; HANDLE THE ANIMATION OF THE SPLATTING CHARACTER
- ; NOTE: IF IT'S HITTING THE HERO, MAKE IT STICK; THIS WILL BE THE CASE
- ; IF "STATUS" IS "STATHIT"
- FMSPLAT DEC CACOUNT,X
- BEQ ZFMSP00
- RTS ; JMP FMBYE
- ZFMSP00 LDA #2
- STA CACOUNT,X
- DEC CFRAME,X
- BMI AENDSPLT
- LDY CFRAME,X
- LDA SPLATCH,Y
- STA CSTAMP,X
- LDA CPALW,X
- AND #$E0 ; TOP THREE BITS ARE PALETTE
- ORA SPLATPW,Y
- STA CPALW,X
- JMP NXTFOOD
- ; Make the food dissappear-- check to see if it's hitting the score
- AENDSPLT LDA #DEAD ; NO LONGER SPLAT
- STA CSTATE,X
- LDA #0 ; MAKE IT AVAILABLE FOR NEXT TAKEFOOD
- STA CYPOS,X
- LDA STATUS
- CMP #STATBON
- BNE ZENDSP02
- DEC NUMINAIR
- ZENDSP02 LDA #BLOCK1
- STA CHSTAMP,X
- JMP NXTFOOD
- ; THIS ROUTINE IS CALLED FIRST WHEN EACH FOOD IS TAKEN FROM A PILE AND
- ; LATER TO PERIODICALLY UPDATE IT'S FLIGHT.
- SETDELTA LDA #0
- STA TEMP2
- STA TEMP3
- STA TEMP4
- LDA GOALX
- SEC
- SBC CXPOS,Y
- BCS SD0001
- INC TEMP2 ; FLAG FOR NEGATIVE DX
- EOR #$FF
- CLC
- ADC #1
- SD0001 STA TEMP0 ; DX
- LDA GOALY
- SEC
- SBC CYPOS,Y
- BCS SD0002
- INC TEMP3 ; FLAG FOR NEGATIVE DY
- EOR #$FF
- CLC
- ADC #1
- SD0002 STA TEMP1 ; DY
- ; NORMALIZE VECTOR FOR ASPECT RATIO. FLIP THE VECTOR TO THE FIRST OCTANT
- ; (NNE)
- LSR A ; 5/8 = 1/2 + 1/8
- STA TEMP5
- LSR A
- LSR A
- CLC
- ADC TEMP5
- CMP TEMP0
- BCS SD0003
- INC TEMP4 ; FLAG FOR OCTANT FLIP
- TAX ; SWITCH DX AND DY
- LDA TEMP0
- STX TEMP0
- SD0003 LSR A ; DY = DY/4
- LSR A
- STA TEMP1
- ; COMPUTE 3/8 DX
- LDA TEMP0
- LSR A
- LSR A
- STA TEMP5
- LSR A
- CLC
- ADC TEMP5
- STA TEMP6
- ; COMPUTE SECTOR 0,1,2,3
- LDA TEMP0
- LSR A
- STA TEMP5
- LSR A
- LSR A
- CLC
- ADC TEMP5
- LDX #0
- CMP TEMP1
- BCC SECTOR01
- LDX #2
- LDA #0
- JMP SECTOR23
- SECTOR01 LDA TEMP0
- SECTOR23 CLC
- ADC TEMP6
- CMP TEMP1
- BCC SECTOR02
- SECTOR13 INX
- SECTOR02 STX TEMP0
- ; NOW UNFOLD THIS 0-3 NUMBER INTO THE CORRECT OCTANT BY
- ; USING THE THREE "NEGATIVE" FLAGS:
- LDX TEMP4 ; DIAGONAL FLIP
- BEQ SD0010
- LDA #7
- SEC
- SBC TEMP0
- STA TEMP0
- SD0010
- LDX TEMP3 ; DY NEGATIVE
- BEQ SD0011
- LDA #15
- SEC
- SBC TEMP0
- STA TEMP0
- SD0011
- LDX TEMP2 ; DX NEGATIVE
- BEQ SD0012
- LDA #31
- SEC
- SBC TEMP0
- STA TEMP0
- SD0012
- LDA TEMP0
- AND #$1F
- ; NOW AT LAST WE'VE GOT AN INDEX 0-31. SET THE FIXNUM DELTAS FROM THE
- ; TABLES
- TAX
- LDA XVECTORH,X
- STA CXSPEED,Y
- LDA XVECTORL,X
- STA CXSPEEDL,Y
- LDA YVECTORH,X
- STA CYSPEED,Y
- LDA YVECTORL,X
- STA CYSPEEDL,Y
- RTS
- END
|