;*************************************************************** ; ; 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 noinlinedata 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 = player0x.d dim _P1_U_D = player0y.e dim _P2_L_R = player0x.f dim _P2_U_D = player0y.g dim _P3_L_R = player0x.h dim _P3_U_D = player0y.i dim _P4_L_R = player0x.j dim _P4_U_D = player0y.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 ;**************************************************************** ; ; set screenheight and pixels ; pfheight=3 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 ; player0x = 76 : player0y = 54 : _Bit0_P0_Floor = 3 player1x = 38 : player1y = 64 ;**************************************************************** ; ; Set up playfield and players ; gosub rs0 : gosub __Frame_LR_02 : gosub __Move_Ghost_Left : 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 ;*************************************************************** ; ; Player0 Controls ; gosub __Pac_Man_Controls ;**************************************************************** ; ; Flips player0 sprite when necessary. ; if _Bit6_Flip_P0{6} then REFP0 = 8 ;*************************************************************** ; ; Displays the screen. ; drawscreen goto __Main_Loop ;*************************************************************** ; ; 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 ; __Pac_Man_Controls ;*************************************************************** ; ; 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 ;*************************************************************** ; ; 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 = ** (5th floor) ; player0y = ** (6th floor) ; if _Bit0_P0_Floor = 1 then gosub __1F_L1 if _Bit0_P0_Floor = 2 then gosub __2F_L1 if _Bit0_P0_Floor = 3 then gosub __3F_L1 if _Bit0_P0_Floor = 4 then gosub __4F_L1 if _Bit0_P0_Floor = 5 then gosub __5F_L1 if _Bit0_P0_Floor = 6 then gosub __6F_L1 return __1F_L1 ;*************************************************************** ; ; Allows player0 to move down to a level 2 ; if player0x = 19 && player0y <= 78 then gosub __Down if player0x = 60 && player0y <= 78 then gosub __Down if player0x = 92 && player0y <= 78 then gosub __Down if player0x = 133 && player0y <= 78 then gosub __Down if player0y = 66 then _Bit0_P0_Floor = 2 : return if player0y < 78 then return ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; if player0x > 18 && player0x < 134 then gosub __Left_Right if player0x = 18 then gosub __Right if player0x = 134 then gosub __Left return __2F_L1 ;*************************************************************** ; ; Allows player0 to move up to a level 1 ; if player0x = 19 && player0y >= 66 then gosub __Up if player0x = 60 && player0y >= 66 then gosub __Up if player0x = 92 && player0y >= 66 then gosub __Up if player0x = 133 && player0y >= 66 then gosub __Up if player0y = 78 then _Bit0_P0_Floor = 1 : return if player0y > 66 then return ;*************************************************************** ; ; Allows player0 to move down to a level 3 ; if player0x = 19 && player0y <= 66 then gosub __Down if player0x = 40 && player0y <= 66 then gosub __Down if player0x = 112 && player0y <= 66 then gosub __Down if player0x = 133 && player0y <= 66 then gosub __Down if player0y = 54 then _Bit0_P0_Floor = 3 : return if player0y < 66 then return ;*************************************************************** ; ; Sets player0 right side limits based off of playfiield ; if player0x > 18 && player0x < 70 then gosub __Left_Right if player0x = 18 then gosub __Right if player0x = 70 then gosub __Left ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; if player0x > 82 && player0x < 134 then gosub __Left_Right if player0x = 82 then gosub __Right if player0x = 134 then gosub __Left return ;*************************************************************** ; ; 3rd Floor ***Always the starting point. Even after death** ; If the joystick isn't moved then skip this section and return ; __3F_L1 ;*************************************************************** ; ; Allows player0 to move up to a level 2 ; if player0x = 19 && player0y >=54 then gosub __Up if player0x = 40 && player0y >=54 then gosub __Up if player0x = 112 && player0y >=54 then gosub __Up if player0x = 133 && player0y >=54 then gosub __Up if player0y = 66 then _Bit0_P0_Floor = 2 : return if player0y > 54 then return ;*************************************************************** ; ; Allows player0 to move down to a level 4 ; if player0x = 19 && player0y <= 54 then gosub __Down if player0x = 52 && player0y <= 54 then gosub __Down if player0x = 100 && player0y <= 54 then gosub __Down if player0x = 133 && player0y <= 54 then gosub __Down if player0y = 42 then _Bit0_P0_Floor = 4 : return if player0y < 54 then return ;*************************************************************** ; ; Sets player0 left and rights limits based off of playfiield ; if player0x > 30 && player0x < 122 then gosub __Left_Right if player0x = 30 then gosub __Right if player0x = 122 then gosub __Left return __4F_L1 ;*************************************************************** ; ; Allows player0 to move up to a level3 ; if player0x = 19 && player0y <= 54 then gosub __Up if player0x = 52 && player0y <= 54 then gosub __Up if player0x = 100 && player0y <= 54 then gosub __Up if player0x = 133 && player0y <= 54 then gosub __Up if player0y = 54 then _Bit0_P0_Floor = 3 : return if player0y > 42 then return ;*************************************************************** ; ; Allows player0 to move down to a level 5 ; if player0x = 19 && player0y <= 42 then gosub __Down if player0x = 69 && player0y <= 42 then gosub __Down if player0x = 83 && player0y <= 42 then gosub __Down if player0x = 133 && player0y <= 42 then gosub __Down if player0y = 30 then _Bit0_P0_Floor = 5 : return if player0y < 42 then return ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; if player0x > 18 && player0x < 134 then gosub __Left_Right if player0x = 18 then gosub __Right if player0x = 134 then gosub __Left return __5F_L1 ;*************************************************************** ; ; Allows player0 to move up to a level4 ; if player0x = 19 && player0y <= 42 then gosub __Up if player0x = 69 && player0y <= 42 then gosub __Up if player0x = 83 && player0y <= 42 then gosub __Up if player0x = 133 && player0y <= 42 then gosub __Up if player0y = 42 then _Bit0_P0_Floor = 4 : return if player0y > 30 then return ;*************************************************************** ; ; Allows player0 to move down to a level 6 ; if player0x = 19 && player0y <= 30 then gosub __Down if player0x = 40 && player0y <=30 then gosub __Down if player0x = 57 && player0y <= 30 then gosub __Down if player0x = 95 && player0y <= 30 then gosub __Down if player0x = 112 && player0y <=30 then gosub __Down if player0x = 133 && player0y <= 30 then gosub __Down if player0y = 18 then _Bit0_P0_Floor = 6 : return if player0y < 30 then return ;*************************************************************** ; ; Sets player0 right side limits based off of playfiield ; if player0x > 18 && player0x < 70 then gosub __Left_Right if player0x = 18 then gosub __Right if player0x = 70 then gosub __Left ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; if player0x > 82 && player0x < 134 then gosub __Left_Right if player0x = 82 then gosub __Right if player0x = 134 then gosub __Left return __6F_L1 ;*************************************************************** ; ; Allows player0 to move up to a level5 ; if player0x = 19 && player0y <= 30 then gosub __Up if player0x = 40 && player0y <=30 then gosub __Up if player0x = 57 && player0y <= 30 then gosub __Up if player0x = 95 && player0y <= 30 then gosub __Up if player0x = 112 && player0y <=30 then gosub __Up if player0x = 133 && player0y <= 30 then gosub __Up if player0y = 30 then _Bit0_P0_Floor = 5 : return if player0y > 18 then return ;*************************************************************** ; ; Sets player0 left side limits based off of playfiield ; if player0x > 18 && player0x < 134 then gosub __Left_Right if player0x = 18 then gosub __Right if player0x = 134 then gosub __Left return ;*************************************************************** ; ; Common Controls there are defined stopping points ; __Left if joy0left then _BitO_P0_Direction = 1 : _Bit6_Flip_P0{6} = 1 if _BitO_P0_Direction = 2 then _P0_L_R = _P0_L_R - .5 ;``````````````````````````````````````````````````````````````` ; Sprite animation. ; on _Frame_Counter gosub __Frame_LR_00 __Frame_LR_01 __Frame_LR_02 __Frame_LR_01 return __Right if joy0right then _BitO_P0_Direction = 2 : _Bit6_Flip_P0{6} = 0 if _BitO_P0_Direction = 1 then _P0_L_R = _P0_L_R + .5 ;``````````````````````````````````````````````````````````````` ; Sprite animation. ; on _Frame_Counter gosub __Frame_LR_00 __Frame_LR_01 __Frame_LR_02 __Frame_LR_01 return __Up if joy0up then _BitO_P0_Direction = 3 if _BitO_P0_Direction = 3 then _P0_U_D = _P0_U_D + .5 ;``````````````````````````````````````````````````````````````` ; Sprite animation. ; on _Frame_Counter gosub __Frame_U_00 __Frame_U_01 __Frame_U_02 __Frame_U_01 return __Down if joy0down then _BitO_P0_Direction = 4 if _BitO_P0_Direction = 4 then _P0_U_D = _P0_U_D - .5 ;``````````````````````````````````````````````````````````````` ; Sprite animation. ; on _Frame_Counter gosub __Frame_D_00 __Frame_D_01 __Frame_D_02 __Frame_D_01 return __Left_Right if joy0left then _BitO_P0_Direction = 1 : _Bit6_Flip_P0{6} = 1 if joy0right then _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 ;``````````````````````````````````````````````````````````````` ; Sprite animation. ; on _Frame_Counter gosub __Frame_LR_00 __Frame_LR_01 __Frame_LR_02 __Frame_LR_01 return rs0 playfield: XXXXXXXXXXXXXXXX X............... X............... X..XXXXXXXX..XXX X..............X X..............X X..XXX..XXXXXXXX ...X............ ...X............ X..XXXXXX..XXXXX X............... X............... X..XXXXXXXXXX..X X..............X X..............X X..XXX..XX..XXXX X............... X............... XXXXXXXXXXXXXXXX ................ end return ;**************************************************************** ; ; Left/right animation frames for player. ; __Frame_LR_00 player0: %01111100 %11111110 %11110000 %11110000 %11110000 %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 __Move_Ghost_Left player1-4: %10101010 %11111110 %11111110 %10101110 %10101110 %11111110 %11111110 %01111100 end return ; ****************************** ; ****End Bank 1 *************** ; ****************************** ; ****************************** ; ****Start Bank 2 ************* ; ****************************** bank 2 ; ****************************** ; ****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 ; ****************************** ; ****End Bank 6 *************** ; ****************************** ; ****************************** ; ****Start Bank 7 ************* ; ****************************** bank 7 ; ****************************** ; ****End Bank 7 *************** ; ****************************** ; ****************************** ; ****Start Bank 8 ************* ; ****************************** bank 8 ;*************************************************************** ; If you are using the multisprite kernel, you can use a special pfread module, ; called pfread_msk.asm, made just for this kernel. It is not enabled by default. ; To enable it, you can use the include or inline command in a 2K or 4K game. ; For a bankswitched game, only the inline command will work, and the command must be placed in the last bank. ; inline pfread_msk.asm