toiletunes Posted April 22, 2007 Share Posted April 22, 2007 I'm having trouble trying to figure out how to use a paddle to change the position of player0. Here's some simple code for reference- what am I missing? set kernel_options no_blank_lines readpaddle COLUP0 = 40 player0: %11111111 %01100110 end player0x = 30 player0y = 50 COLUBK = 80 COLUPF = 20 playfield: ...............XX............... X..............................X ...............XX............... ................................ X..............................X .................XX............. ...............XX............... X..............................X ...............XX............... .............XX................. X..............................X end mainloop drawscreen player0x = paddle goto mainloop (The Batari Basic command reference mentions something called currentpaddle, but I get an "unknown Keyword" error every time I add it to the lines above) Quote Link to comment Share on other sites More sharing options...
+batari Posted April 22, 2007 Share Posted April 22, 2007 I'm having trouble trying to figure out how to use a paddle to change the position of player0. Here's some simple code for reference- what am I missing? I tried your code and it works. The problem is probably that you haven't told the emulator that the binary uses the paddle, as it assumes joystick by default. (The Batari Basic command reference mentions something called currentpaddle, but I get an "unknown Keyword" error every time I add it to the lines above) currentpaddle is the paddle you are reading during the next frame. I couldn't repeat the error you describe with currentpaddle, but if you intend to use paddle 0, there's no need to change it. Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted April 22, 2007 Share Posted April 22, 2007 I tried your code and it works. The problem is probably that you haven't told the emulator that the binary uses the paddle, as it assumes joystick by default. Darn, I was trying his code and couldn't get it to work, for the same reason-- I hadn't changed the game properties in Stella to say that a pair of paddles was plugged into the left controller port. currentpaddle is the paddle you are reading during the next frame. I couldn't repeat the error you describe with currentpaddle, but if you intend to use paddle 0, there's no need to change it. I think he was using the "currentpaddle" keyword by itself, rather than assigning a value to it, which does give the error message he mentioned. The HTML batari Basic manual doesn't give an example of how to use "currentpaddle." You use it as follows: rem *** to read paddle 0 and store its value in variable a currentpaddle = 0 drawscreen a = paddle rem *** to read paddle 1 and store its value in variable b currentpaddle = 1 drawscreen b = paddle rem *** to read paddle 2 and store its value in variable c currentpaddle = 2 drawscreen c = paddle rem *** to read paddle 3 and store its value in variable d currentpaddle = 3 drawscreen d = paddle Note that "paddle" will return a number between 0 and 77 (I think), which isn't large enough to span the screen, since the players' horizontal positions range from 1 to 160. So if we multiply "paddle" by 2, and then add 1, we get a value between 1 and 155, which is better. But if the player is 8 pixels wide, and each pixel is 1 color clock wide, then we'd want a maximum horizontal position of 153, which would put the player's rightmost pixel at position 160. So here's a modified version of the code, to move player0 from the left side of the screen to the right side of the screen: include div_mul.asm rem *** Note that this modified code uses multiplication, rem *** so we have to include the div_mul.asm code. set kernel_options no_blank_lines readpaddle player0: %11111111 %01100110 end player0x = 30 player0y = 50 COLUBK = 80 COLUPF = 20 playfield: ...............XX............... X..............................X ...............XX............... ................................ X..............................X .................XX............. ...............XX............... X..............................X ...............XX............... .............XX................. X..............................X end currentpaddle = 0 rem *** Note that since all page-zero RAM is initialized to 0 rem *** by batari Basic, currentpaddle will default to 0. mainloop COLUP0 = 40 rem *** Note that COLUP0 should be set within the display rem *** loop, because drawscreen changes it to the same rem *** value as scorecolor when the score is displayed. drawscreen player0x = 2 * paddle + 1 if player0x > 153 then player0x = 153 goto mainloop After you compile the code, run it in the Stella emulator. But then you have to tell Stella to use the paddles, so press the TAB key, click the GAME PROPERTIES button, click the CONTROLLER tab, click the LEFT CONTROLLER dropdown box, click the PADDLES selection, click the OK button, and click the EXIT MENU button. Then press the BACKSLASH ("\") key (usually found just above the ENTER key), and click the RELOAD ROM button. Then you can move the player by moving the mouse back and forth, as long as the mouse pointer is over the game screen (if you're running Stella in a window). If you want to use the keyboard to control the paddle-- say, to use the COMMA to move left (since it has the left-pointing LESS THAN symbol on it), and to use the PERIOD to move right (since it has the right-pointing GREATER THAN symbol on it)-- press the TAB key, click the INPUT SETTINGS button, scroll down and click PADDLE 1 DECREASE, click the MAP button, press the COMMA key, click PADDLE 1 INCREASE, click the MAP button, press the PERIOD key, click the OK button, and click the EXIT MENU button. Then press the BACKSLASH key and click RELOAD ROM again, and the COMMA and PERIOD keys will move the player-- but so will the mouse. To prevent the mouse from moving the paddle, press TAB, click INPUT SETTINGS, click VIRTUAL DEVICES, click the MOUSE IS PADDLE box to change it to something other than 0, click OK, click EXIT MENU, press BACKSLASH, and click RELOAD ROM. Michael Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 22, 2007 Share Posted April 22, 2007 I think he was using the "currentpaddle" keyword by itself, rather than assigning a value to it, which does give the error message he mentioned. The HTML batari Basic manual doesn't give an example of how to use "currentpaddle." You use it as follows: rem *** to read paddle 0 and store its value in variable a currentpaddle = 0 drawscreen a = paddle rem *** to read paddle 1 and store its value in variable b currentpaddle = 1 drawscreen b = paddle rem *** to read paddle 2 and store its value in variable c currentpaddle = 2 drawscreen c = paddle rem *** to read paddle 3 and store its value in variable d currentpaddle = 3 drawscreen d = paddle Note that "paddle" will return a number between 0 and 77 (I think), which isn't large enough to span the screen, since the players' horizontal positions range from 1 to 160. So if we multiply "paddle" by 2, and then add 1, we get a value between 1 and 155, which is better. But if the player is 8 pixels wide, and each pixel is 1 color clock wide, then we'd want a maximum horizontal position of 153, which would put the player's rightmost pixel at position 160. Is it OK if I put your example on both bB pages? My personal version and the official one? Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted April 22, 2007 Share Posted April 22, 2007 Is it OK if I put your example on both bB pages? My personal version and the official one? By all means, help yourself! You're welcome to use any explanations or examples that I post-- as long as they don't contain any erroneous information, that is. Michael Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 22, 2007 Share Posted April 22, 2007 Is it OK if I put your example on both bB pages? My personal version and the official one?By all means, help yourself! You're welcome to use any explanations or examples that I post-- as long as they don't contain any erroneous information, that is. Thanks. I'll go add it right now before I forget. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 22, 2007 Share Posted April 22, 2007 SeaGtGruff, before I add it to the official page, can you check this to make sure I didn't mangle your example too horribly: http://www.randomterrain.com/atari-2600-me...l#paddlereading Thanks. Quote Link to comment Share on other sites More sharing options...
+stephena Posted April 22, 2007 Share Posted April 22, 2007 After you compile the code, run it in the Stella emulator. But then you have to tell Stella to use the paddles, so press the TAB key, click the GAME PROPERTIES button, click the CONTROLLER tab, click the LEFT CONTROLLER dropdown box, click the PADDLES selection, click the OK button, and click the EXIT MENU button. Then press the BACKSLASH ("\") key (usually found just above the ENTER key), and click the RELOAD ROM button. Then you can move the player by moving the mouse back and forth, as long as the mouse pointer is over the game screen (if you're running Stella in a window). I just wanted to add that if you're more accustomed to the commandline, you can start Stella with paddles as follows: 'stella -lc paddles ROMNAME'. Also, you can do a ROM reload by pressing 'Ctrl r', instead of going to the command menu (the one with the '/'). Quote Link to comment Share on other sites More sharing options...
toiletunes Posted April 22, 2007 Author Share Posted April 22, 2007 (edited) Thank you everyone, especially batari, SeaGtGruff, Random Terrain, and stephena. This community is so friendly and supportive, I wish I could move here! Edited April 22, 2007 by toiletunes Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted April 22, 2007 Share Posted April 22, 2007 SeaGtGruff, before I add it to the official page, can you check this to make sure I didn't mangle your example too horribly: Perhaps it might be good to use this slightly-revised example instead? rem *** read paddle 0, use it to position player0x across the screen currentpaddle = 0 drawscreen player0x = 2 * paddle + 1 : if player0x > 153 then player0x = 153 rem *** read paddle 1, use it to position player1x across the screen currentpaddle = 1 drawscreen player1x = 2 * paddle + 1 : if player1x > 153 then player1x = 153 Michael Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 23, 2007 Share Posted April 23, 2007 SeaGtGruff, before I add it to the official page, can you check this to make sure I didn't mangle your example too horribly: Perhaps it might be good to use this slightly-revised example instead? rem *** read paddle 0, use it to position player0x across the screen currentpaddle = 0 drawscreen player0x = 2 * paddle + 1 : if player0x > 153 then player0x = 153 rem *** read paddle 1, use it to position player1x across the screen currentpaddle = 1 drawscreen player1x = 2 * paddle + 1 : if player1x > 153 then player1x = 153 Thanks. Here is the latest change: http://www.randomterrain.com/atari-2600-me...l#paddlereading I'll add it to the official page now. Please let me know if you'd like the text above the example to be changed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.