;*************************************************************** ; ; Special thanks below for the smaple codes on Batari Basic ; hints, tips, code snippets, and more from AtariAge members ; such as batari, SeaGtGruff, RevEng, Robert M, Nukey Shay, ; Atarius Maximus, jrok, supercat, GroovyBee, and bogax. ; code snippets from Atarius Maximus's "GTA style game" ; code snippets from Quad Runner's "move_around_rooms" ; code snippets from Stargunner's "Space dungeon" ; code snippets from Mountain King "GizzlewapG16" ; code snippets from Gemintronic 4 Way Scroller ; sprite codes from PAC-MAN-RED ; sprites codes from GoB! Fight for the Desert Patrick Jahn, Greg Kinsey, John Swisshelm ; code below complied together by Lewis2907 to make AFP PacMan Eat & Run ; ;``````````````````````````````````````````````````````````````` ;*************************************************************** ; ; If this program will not compile for you, get the latest ; version of batari Basic: ; ; http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#gettingstarted ; ;``````````````````````````````````````````````````````````````` ;*************************************************************** ; ; Kernel setup. ; includesfile multisprite_bankswitch.inc include fixed_point_math.asm set tv ntsc set kernel multisprite set romsize 32kSC set optimization speed set smartbranching on set optimization inlinerand ;**************************************************************** ; ; Player0-4 fixed point variables for more flexibility in ; gameplay mechanics. ; "c" is used in joy0 checks for last movement ; dim _P0_L_R = player0x.a dim _P0_U_D = player0y.b dim _P1_L_R = player1x.d dim _P1_U_D = player1y.e dim _P2_L_R = player2x.f dim _P2_U_D = player2y.g dim _P3_L_R = player3x.h dim _P3_U_D = player3y.i dim _P4_L_R = player4x.j dim _P4_U_D = player4y.k ;**************************************************************** ; ; Flips player0 sprite when necessary. ; dim _Bit6_Flip_P0 = l ;**************************************************************** ; ; Player0/player1 direction bits. ; dim _BitO_P0_Direction = m dim _Bit0_P0_Floor = n ;**************************************************************** ; ; Animation counters. ; dim _Master_Counter = o dim _Frame_Counter = p dim Clock = q dim room = r ;``````````````````````````````````````````````````````````````` ; Ghost AI ; Value "x" and "y" used for collision ; dim Orange_Ghost = v dim Pink_Ghost = u dim Blue_Ghost = t dim Red_Ghost = w dim _Bit0_Reset_Restrainer = z ;``````````````````````````````````````````````````````````````` ; ; Constants used for each level instead of variables level ; Constants since Batari Basic had a limit of 500 constants ; ;``````````````````````````````````````````````````````````````` ; Constants for Room 0 ; const P0_D_FL1_RS0 = Dat_FL1RS0_D - 1 const P0_U_FL2_RS0 = Dat_FL2RS0_U - 1 const P0_D_FL2_RS0 = Dat_FL2RS0_D - 1 const P0_U_FL3_RS0 = Dat_FL3RS0_U - 1 const P0_D_FL3_RS0 = Dat_FL3RS0_D - 1 const P0_U_FL4_RS0 = Dat_FL4RS0_U - 1 const P0_D_FL4_RS0 = Dat_FL4RS0_D - 1 const P0_U_FL5_RS0 = Dat_FL5RS0_U - 1 ;**************************************************************** ; ; set screenheight and pixels ; pfheight=1 const screenheight = 80 ;**************************************************************** ; ; Set player positions (Test Screen Postions here) ; Center Floor is _Bit0_P0_Floor = 3 ; must use this for the calulations to work correctly ; rs1 will eqaul the same as room ; gosub rs0 bank8 : room = 0 :_Bit0_P0_Floor = 3 ;**************************************************************** ; ; Set player positions (Test Screen Postions here) ; Center Floor is _Bit0_P0_Floor = 3 ; must use this for the calulations to work correctly ; player0x = 77 : player0y = 46 player1x = 28 : player1y = 72 ; Red Ghost player2x = 141 : player2y = 58 ; Blue Ghost player3x = 28 : player3y = 30 ; Pink Ghost player4x = 141 : player4y = 16 ; Orange Ghost ;**************************************************************** ; ; Set up playfield and players ; gosub __Frame_LR_01 : COLUPF = $86 ;*************************************************************** ;*************************************************************** ; ; PROGRAM START/RESTART ; __Start_Restart ;*************************************************************** ;*************************************************************** ; ; MAIN LOOP (MAKES THE PROGRAM GO) ; Also used for unpause the game ; __Main_Loop ;*************************************************************** ; ; Sets player0/1/2 color ; COLUP0=$1C : _COLUP1=$44 ;*************************************************************** ; ; Place Holder to help in playfield "X" and "Y" Checks ; ; drawscreen : goto __Main_Loop ;**************************************************************** ; ; Flips player0 sprite when necessary. ; if _Bit6_Flip_P0{6} then REFP0 = 8 ;*************************************************************** ; ; Controls animation speed. ; _Master_Counter = _Master_Counter + 1 if _Master_Counter < 4 then goto __Skip_Frame_Counter _Frame_Counter = _Frame_Counter + 1 : _Master_Counter = 0 if _Frame_Counter > 3 then _Frame_Counter = 0 __Skip_Frame_Counter ;**************************************************************** ; ; Flips player0 sprite when necessary. ; if _Bit6_Flip_P0{6} then REFP0 = 8 ;``````````````````````````````````````````````````````````````` ; Sprite animation. ; if c{1} then on _Frame_Counter gosub __Frame_U_00 __Frame_U_01 __Frame_U_02 __Frame_U_01 if c{2} then on _Frame_Counter gosub __Frame_D_00 __Frame_D_01 __Frame_D_02 __Frame_D_01 if c{3} then on _Frame_Counter gosub __Frame_LR_00 __Frame_LR_01 __Frame_LR_02 __Frame_LR_01 if c{4} then on _Frame_Counter gosub __Frame_LR_00 __Frame_LR_01 __Frame_LR_02 __Frame_LR_01 if _BitO_P0_Direction = 7 then on _Frame_Counter gosub __Frame_U_00 __Frame_U_01 __Frame_U_02 __Frame_U_01 ;*************************************************************** ; ; Select the correct floor based on player0y positions ; y position is in crements of 12 ; player0y = 78 (1st floor) ; player0y = 66 (2nd floor) ; player0y = 54 (3rd floor) ; player0y = 42 (4th floor) ; player0y = 30 (5th floor) ; player0y = 18 (6th floor) ; ;*************************************************************** ; ; player0x = 76 : player0y = 54 : Center of screen ; player0x = 32 : player0y = 54 : Center far left ; player0x = 112 : player0y = 54 : Center far right ; Center Floor is _Bit0_P0_Floor = 3 ; ;*************************************************************** ; ; Select the correct room and floor based on player0y positions ; if room = 0 then gosub __Room_0_Controls bank2 ; if room = 1 then gosub __Room_1_Controls bank2 ; if room = 2 then gosub __Room_2_Controls bank2 ; if room = 3 then gosub __Room_3_Controls bank2 ; if room = 4 then gosub __Room_4_Controls bank2 ; if room = 5 then gosub __Room_5_Controls bank2 ; if room = 6 then gosub __Room_6_Controls bank2 ; if room = 7 then gosub __Room_7_Controls bank2 ; if room = 8 then gosub __Room_8_Controls bank2 ;*************************************************************** ; ; Displays the screen. ; drawscreen goto __Main_Loop ;**************************************************************** ; ; Left/right animation frames for player. ; __Frame_LR_00 player0: %01111100 %11111110 %11111110 %11111110 %11111110 %11011110 %11111110 %01111100 end return __Frame_LR_01 player0: %01111100 %11111110 %11111000 %11100000 %11111000 %11011110 %11111110 %01111100 end return __Frame_LR_02 player0: %01111100 %11111000 %11110000 %11100000 %11100000 %11010000 %11111000 %01111100 end return ;**************************************************************** ; ; Down animation frames for player. ; __Frame_D_00 player0: %01101100 %11101110 %11101110 %11111110 %11111110 %11111010 %11111110 %01111100 end return __Frame_D_01 player0: %01000100 %11000110 %11101110 %11101110 %11101110 %11111010 %11111110 %01111100 end return __Frame_D_02 player0: %00000000 %10000010 %11000110 %11101110 %11101110 %11111010 %11111110 %01111100 end return ;**************************************************************** ; ; Up animation frames for player. ; __Frame_U_00 player0: %01111100 %11111110 %11111010 %11111110 %11111110 %11101110 %11101110 %01101100 end return __Frame_U_01 player0: %01111100 %11111110 %11111010 %11101110 %11101110 %11101110 %11000110 %01000100 end return __Frame_U_02 player0: %01111100 %11111110 %11111010 %11101110 %11101110 %11000110 %10000010 %00000000 end return ; ****************************** ; ****End Bank 1 *************** ; ****************************** ; ****************************** ; ****Start Bank 2 ************* ; ****************************** bank 2 ; ****************************** ; ****End Bank 2 *************** ; ****************************** ; ****************************** ; ****Start Bank 3 ************* ; ****************************** ;**************************************; ; ; ; Room Shape O and Controls ; ; ; ;*************************************** __Room_0_Controls ;*********************************** ; Select correct floor ; if _Bit0_P0_Floor = 1 then gosub __1F_L0 if _Bit0_P0_Floor = 2 then gosub __2F_L0 if _Bit0_P0_Floor = 3 then gosub __3F_L0 if _Bit0_P0_Floor = 4 then gosub __4F_L0 if _Bit0_P0_Floor = 5 then gosub __5F_L0 ;*********************************** ; Ghost AI ; ;gosub __AI_Controls_Room_0_Red_Ghost bank7 ;gosub __AI_Controls_Room_0_Blue_Ghost bank7 ;gosub __AI_Controls_Room_0_Pink_Ghost bank7 ;gosub __AI_Controls_Room_0_Orange_Ghost bank7 return __1F_L0 ;*************************************************************** ; ; Allows player0 to move down to floor 2 ; temp1 = 4 __PO_D_FL1RS0 if player0x = P0_D_FL1_RS0[temp1] then gosub __Down bank6 temp1 = temp1 - 1 if temp1 then __PO_D_FL1RS0 if player0y = 60 then _Bit0_P0_Floor = 2 : return otherbank if player0y < 74 then return otherbank ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; gosub __Long_Floor bank6 return otherbank ;*************************************************************** ; ; Data to move down to Floor 2 ; data Dat_FL1RS0_D 20, 76, 77, 132 end ;*************************************************************** ; ; Level I / Floor 2 Information ; ;``````````````````````````````````````````````````````````````` __2F_L0 ;*************************************************************** ; ; Allows player0 to move up to a level 1 ; temp1 = 4 __PO_U_FL2RS0 if player0x = P0_U_FL2_RS0[temp1] then gosub __Up bank6 temp1 = temp1 - 1 if temp1 then __PO_U_FL2RS0 if player0y = 74 then _Bit0_P0_Floor = 1 : return otherbank if player0y > 60 then return otherbank ;*************************************************************** ; ; Allows player0 to move down to floor 3 ; temp1 = 4 __PO_D_FL2RS0 if player0x = P0_D_FL2_RS0[temp1] then gosub __Down bank6 temp1 = temp1 - 1 if temp1 then __PO_D_FL2RS0 if player0y = 46 then _Bit0_P0_Floor = 3 : return otherbank if player0y < 60 then return otherbank ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; gosub __Long_Floor bank6 return otherbank ;*************************************************************** ; ; Data to move up to Floor 3 ; data Dat_FL2RS0_D 44, 109 end ;*************************************************************** ; ; Data to move up to Floor 2 ; data Dat_FL2RS0_U 20, 77, 132 end ;*************************************************************** ; ; 3rd Floor ***Always the starting point. Even after death** ; If the joystick isn't moved then skip this section and return ; ;*************************************************************** ; ; Level I / Floor 3 Information ; ;``````````````````````````````````````````````````````````````` __3F_L0 ;*************************************************************** ; ; Allows player0 to move up to floor 2 ; temp1 = 4 __PO_U_FL3RS0 if player0x = P0_U_FL3_RS0[temp1] then gosub __Up bank6 temp1 = temp1 - 1 if temp1 then __PO_U_FL3RS0 if player0y = 60 then _Bit0_P0_Floor = 2 : return otherbank if player0y > 46 then return otherbank ;*************************************************************** ; ; Allows player0 to move down to floor 4 ; temp1 = 4 __PO_D_FL3RS0 if player0x = P0_D_FL3_RS0[temp1] then gosub __Down bank6 temp1 = temp1 - 1 if temp1 then __PO_D_FL3RS0 if player0y = 32 then _Bit0_P0_Floor = 4 : return otherbank if player0y < 46 then return otherbank ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; gosub __Long_Floor bank6 return otherbank ;*************************************************************** ; ; Data to move down to Floor 4 ; data Dat_FL3RS0_D 44, 109 end ;*************************************************************** ; ; Data to move up to Floor 2 ; data Dat_FL3RS0_U 44, 109 end ;*************************************************************** ; ; Level I / Floor 4 Information ; ;``````````````````````````````````````````````````````````````` __4F_L0 ;*************************************************************** ; ; Allows player0 to move up to a level3 ; temp1 = 4 __PO_U_FL4RS0 if player0x = P0_U_FL4_RS0[temp1] then gosub __Up bank6 temp1 = temp1 - 1 if temp1 then __PO_U_FL4RS0 if player0y = 46 then _Bit0_P0_Floor = 3 : return otherbank if player0y > 32 then return otherbank ;*************************************************************** ; ; Allows player0 to move down to a level 5 ; temp1 = 4 __PO_D_FL4RS0 if player0x = P0_D_FL4_RS0[temp1] then gosub __Down bank6 temp1 = temp1 - 1 if temp1 then __PO_D_FL4RS0 if player0y = 18 then _Bit0_P0_Floor = 5 : return otherbank if player0y < 32 then return otherbank ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; gosub __Long_Floor bank6 return otherbank ;*************************************************************** ; ; Data to move down to Floor 5 ; data Dat_FL4RS0_D 20, 77, 132 end ;*************************************************************** ; ; Data to move up to Floor 3 ; data Dat_FL4RS0_U 44, 109 end ;*************************************************************** ; ; Level I / Floor 5 Information ; ;``````````````````````````````````````````````````````````````` __5F_L0 ;*************************************************************** ; ; Allows player0 to move up to floor 4 ; temp1 = 4 __PO_U_FL5RS0 if player0x = P0_U_FL5_RS0[temp1] then gosub __Up bank6 temp1 = temp1 - 1 if temp1 then __PO_U_FL5RS0 if player0y = 32 then _Bit0_P0_Floor = 4 : return otherbank if player0y > 18 then return otherbank ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; gosub __Long_Floor bank6 return otherbank ;*************************************************************** ; ; Data to move up to Floor 4 ; data Dat_FL5RS0_U 20, 76, 77, 132 end ; ****************************** ; ****End Bank 2 *************** ; ****************************** ; ****************************** ; ****Start Bank 3 ************* ; ****************************** bank 3 ; ****************************** ; ****End Bank 3 *************** ; ****************************** ; ****************************** ; ****Start Bank 4 ************* ; ****************************** bank 4 ; ****************************** ; ****End Bank 4 *************** ; ****************************** ; ****************************** ; ****Start Bank 5 ************* ; ****************************** bank 5 ; ****************************** ; ****End Bank 5 *************** ; ****************************** ; ****************************** ; ****Start Bank 6 ************* ; ****************************** bank 6 ;*************************************************************** ; ; Common Controls there are defined stopping points ; __Left if joy0left then c{1}=0:c{2}=0:c{3}=1:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : _BitO_P0_Direction = 2 if _BitO_P0_Direction = 2 then _P0_L_R = _P0_L_R - .5 if _P0_L_R = 19 && joy0left then c{1}=0:c{2}=0:c{3}=1:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : return if _P0_L_R = 133 && joy0right then c{1}=0:c{2}=0:c{3}=0:c{4}=1:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : return return __Right if joy0right then c{1}=0:c{2}=0:c{3}=0:c{4}=1:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : _BitO_P0_Direction = 1 if _BitO_P0_Direction = 1 then _P0_L_R = _P0_L_R + .5 if _P0_L_R = 19 && joy0left then c{1}=0:c{2}=0:c{3}=1:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : return if _P0_L_R = 133 && joy0right then c{1}=0:c{2}=0:c{3}=0:c{4}=1:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : return return __Up if joy0up then c{1}=1:c{2}=0:c{3}=0:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : _BitO_P0_Direction = 3 if _BitO_P0_Direction = 3 then _P0_U_D = _P0_U_D + .5 return __Down if joy0down then c{1}=0:c{2}=1:c{3}=0:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : _BitO_P0_Direction = 4 if _BitO_P0_Direction = 4 then _P0_U_D = _P0_U_D - .5 return __Left_Right if _P0_L_R = 19 && joy0left then c{1}=0:c{2}=0:c{3}=1:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : return if _P0_L_R = 133 && joy0right then c{1}=0:c{2}=0:c{3}=0:c{4}=1:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : return if joy0left then c{1}=0:c{2}=0:c{3}=1:c{4}=0:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : _BitO_P0_Direction = 1 : _Bit6_Flip_P0{6} = 1 if joy0right then c{1}=0:c{2}=0:c{3}=0:c{4}=1:c{5}=0:c{6}=0:c{7}=0:c{0}=0 : _BitO_P0_Direction = 2 : _Bit6_Flip_P0{6} = 0 if _BitO_P0_Direction = 1 then _P0_L_R = _P0_L_R - .5 if _BitO_P0_Direction = 2 then _P0_L_R = _P0_L_R + .5 return ;*************************************************************** ; ; left / right warp / exit "Middle of Screen" ; __Right_Warp _P0_L_R = _P0_L_R + .2 return __Left_Warp _P0_L_R = _P0_L_R - .2 return __Up_Warp _P0_U_D = _P0_U_D + .2 return __Down_Warp _P0_U_D = _P0_U_D - .2 return __Static_Player return __Long_Floor ;*************************************************************** ; ; Sets player0 left and rights limits based off of playfiield ; if _P0_L_R > 19 && _P0_L_R < 133 then gosub __Left_Right if _P0_L_R = 19 then gosub __Right if _P0_L_R = 133 then gosub __Left return ; ****************************** ; ****End Bank 6 *************** ; ****************************** ; ****************************** ; ****Start Bank 7 ************* ; ****************************** bank 7 ; ****************************** ; ****End Bank 7 *************** ; ****************************** ; ****************************** ; ****Start Bank 8 ************* ; ****************************** bank 8 rs0 playfield: ........X....... ................ XXXXXXXXXXXXXXX. X............... X............... X............... X............... X............... X............... X..XXXXXXXXXXXX. X............... X............... X............... X............... X............... X............... XXXXXXX..XXXXXXX ................ ................ ................ ................ ................ ................ XXXXXXX..XXXXXXX X............... X............... X............... X............... X............... X............... X..XXXXXXXXXXXX. X............... X............... X............... X............... X............... X............... XXXXXXXXXXXXXXX. ................ ........X....... end return ; ****************************** ; ****End Bank 8 *************** ; ******************************