;*************************************************************** ; ; 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 Multsprite Demo ;*************************************************************** ; ; msk_pf_rd demo ; code provided by Bogax ; ;``````````````````````````````````````````````````````````````` ;*************************************************************** ; ; 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 ; ;``````````````````````````````````````````````````````````````` ;*************************************************************** ; ; Batari Basic Programing Page / Tips ; Page maintained by Randon Terrain (RT) ; ; http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html ; ;``````````````````````````````````````````````````````````````` ;*************************************************************** ; ; Atari Age Batari Basic Forum ; This forum is excellent to post and search for answers to programming problems ; ; http://atariage.com/forums/forum/65-batari-basic/ ; ;``````````````````````````````````````````````````````````````` ;*************************************************************** ; ; Kernel setup. ; neeed to work on bank switch for more space ; include div_mul.asm include fixed_point_math.asm includesfile multisprite.inc set kernel multisprite set romsize 4k set tv ntsc ;*************************************************************** ; ; Variable aliases go here (DIMs) ; ; You can have more than one alias for each variable. ; If you use different aliases for bit operations, ; it's easier to understand and remember what they do. ; ; I start variable aliases with one underscore so I won't ; have to worry that I might be using bB keywords by mistake. ; I also start labels with two underscores for the same ; reason. The second underscore also makes labels stand out ; so I can tell at a glance that they are labels and not ; variables. ; ; When every variable has an alias and all aliases are near the beginning ; of your program in an alphabetical list, you (and anyone else that might ; have to read your code) will be able to easily see the variables you are ; using and which variables are free to use. Please do not sprinkle DIMs ; throughout your code. Keep them all together in an alphabetical list near ; the beginning of your program. ; ; Use bit operations any time you need a simple off/on ; variable. One variable essentially becomes 8 smaller ; variables when you use bit operations. ; ; I start my bit aliases with "_Bit" then follow that ; with the bit number from 0 to 7, then another underscore ; and the name. Example: _Bit0_Reset_Restrainer ; ;``````````````````````````````````````````````````````````````` ;``````````````````````````````````````````````````````````````` ; Player1-4 fixed point variables for more flexibility in ; gameplay mechanics. ; dim _P0_L_R = player0x.a dim _P0_U_D = player0y.b dim sf = c ;``````````````````````````````````````````````````````````````` ; "screenheight" ; At this time, the only supported values are 80 and 84, and 80 only works ; for row heights < 8 while 84 only works for row heights < 4. Other values ; for screenheight may be allowed in the future. If you try to use other values ; now, strange things may happen. ; ; "pfheight" ; pfheight is a special variable that specifies the height of ; playfield blocks, minus one. Acceptable values are 31, 15, 7, 3, 1, and 0. ; However pfheight 0 doesn't work properly when sprites are on the screen, ; so it's probably only useful for static displays like title screens. ; const screenheight=80 pfheight=1 ;*************************************************************** ; ; Clears all normal variables and old playfield variables ; (fastest way). ; a = 0 : b = 0 : c = 0 : d = 0 : e = 0 : f = 0 : g = 0 : h = 0 : i = 0 j = 0 : k = 0 : l = 0 : m = 0 : n = 0 : o = 0 : p = 0 : q = 0 : r = 0 s = 0 : t = 0 : u = 0 : v = 0 : w = 0 : x = 0 : y = 0 : z = 0 ;*************************************************************** ; ; Displays the screen to avoid going over 262. ; drawscreen ;*************************************************************** ; ; Sets starting position of player0. ; player0x=76 player0y=50 playfield: ..XXXXXXXXXXXXX. ..XXXXXXXXXXXXX. ..X........X.... ..X........X.... ..X........X.... ..X........X.... ..X..XXXX..X..XX ..X............. ..X............. ..X............. ..X............. ..X..XXXXXXX..XX ..X..X.....X.... ..X..X.....X.... ..X..X.....X.... ..X..X.....X.... ........X.....X. ........X.....X. ........X.....X. ........X.....X. ..X..XXXXXXX..X. ..X............. ..X............. ..X............. ..X............. ..XXXX..XXXXXXX. ..X........X.... ..X........X.... ..X........X.... ..X........X.... ..X..X..X..X..XX ..X..X..X..X..X. ..X..X..X..X..X. ..X..X..X..X..XX ..X.....X....... ..X.....X....... ..X.....X....... ..X.....X....... ..XXXXXXXXXXXXX. ..XXXXXXXXXXXXX. end player0: %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 %01111111 end ;*************************************************************** ;*************************************************************** ; ; MAIN LOOP (MAKES THE PROGRAM GO) ; Also used for unpause the game ; __Main_Loop ;*************************************************************** ; ; Sets colors. ; COLUP0 = $44 : COLUBK= 0 : COLUPF = $86 ;*************************************************************** ; Need to adjust to make speed increase or decrease ; Below is the link that helped me with SWCHA ; http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#SWCHA ; temp2 = SWCHA / 16 temp3 = temp2 & 3 : player0y = player0y - dtbl[temp3] temp3 = (temp2/4) ^ 3 : player0x = player0x - dtbl[temp3] ;*************************************************************** ; ; Replace above code to revert back to Bogax 1 pixel movement ; ; temp2 = ((SWCHA ^ $FF) & sf)/16 : sf = SWCHA ; ; temp3 = temp2 & 3 : player0y = player0y + dtbl[temp3] ; temp3 = (temp2/4) ^ 3 : player0x = player0x + dtbl[temp3] ; ;*************************************************************** temp1 = player0x temp2 = player0y temp1 = (player0x - 16)/4 temp2 = (player0y-3)/2 temp1 = msk_pf_rd(temp1, temp2) ;*************************************************************** ; ; Need to adjust to make the collision better. ; ;*************************************************************** ; ; Don't move up if pfpixel is in the way. (Works somewhat, 1 pixel) ; Don't move up off screen. Boundry set. ; ; To adjust the speed of the sprite .8 and .2 must = 1 ; The 1 is related to the "data dtbl" 0, 1, 1, 0" ; Since you can't use fixed point math in the "data dbtl" ; this is the only work around "I know of" ; if joy0up then _P0_U_D = _P0_U_D -.2 if joy0up && temp1 then _P0_U_D = _P0_U_D -.8 if player0y > 84 then player0y = player0y - 1 ;*************************************************************** ; ; Don't move down if pfpixel is in the way. ; Don't move up off screen. Boundry set. ; ; To adjust the speed of the sprite .8 and .2 must = 1 ; The 1 is related to the "data dtbl" 0, 1, 1, 0" ; Since you can't use fixed point math in the "data dbtl" ; this is the only work around "I know of" ; if joy0down then _P0_U_D = _P0_U_D +.2 if joy0down && temp1 then _P0_U_D = _P0_U_D +.8 if player0y < 4 then player0y = player0y + 1 ;*************************************************************** ; ; Don't move right if pfpixel is in the way. ; Don't move right off screen. Boundry set. ; ; To adjust the speed of the sprite .8 and .2 must = 1 ; The 1 is related to the "data dtbl" 0, 1, 1, 0" ; Since you can't use fixed point math in the "data dbtl" ; this is the only work around "I know of" ; if joy0right then _P0_L_R = _P0_L_R -.2 if joy0right && temp1 then _P0_L_R = _P0_L_R -.8 if player0x > 132 then player0x = player0x - 1 ;*************************************************************** ; ; Don't move Left if pfpixel is in the way. (Works somewhat, 1 pixel) ; Don't move left off screen. Boundry set. ; ; To adjust the speed of the sprite .8 and .2 must = 1 ; The 1 is related to the "data dtbl" 0, 1, 1, 0" ; Since you can't use fixed point math in the "data dbtl" ; this is the only work around "I know of" ; if joy0left then _P0_L_R = _P0_L_R +.2 if joy0left && temp1 then _P0_L_R = _P0_L_R +.8 if player0x < 24 then player0x = player0x + 1 drawscreen goto __Main_Loop data dtbl 0, 1, -1, 0, end function msk_pf_rd() if temp1 & 8 then temp1 = temp1 ^ 7 if temp1 > 15 then temp1 = temp1 ^ 8 if temp1 & 8 then skip_PF1 asm ldy temp2 lda (PF1pointer),y sta temp2 end goto skip_PF2 skip_PF1 asm ldy temp2 lda (PF2pointer),y sta temp2 end skip_PF2 temp1 = temp1 & 7 temp1 = bits[temp1] & temp2 if temp1 then temp1 = 255 return data bits $80,$40,$20,$10,8,4,2,1 end