Posted Sat Apr 19, 2008 4:51 PM
Posted Sat Apr 19, 2008 10:49 PM
atari2600land, on Sat Apr 19, 2008 6:51 PM, said:
set kernel_options no_blank_lines readpaddleNote that the "readpaddle" option *cannot* be used by itself-- you *must* specify the "no_blank_lines" option as well-- so that means you can't use missile0 if you're going to read the paddles, since using the "no_blank_lines" option means you lose the use of missile0. Also, the "kernel_options" work only with the standard kernel, so you can't read the paddles if you're using the multisprite kernel.
currentpaddle = 0Note that there are two controller ports, and the paddles come in pairs-- two paddles are connected to one plug-- so you can have either two paddles plugged into one port (and something else, like a joystick, plugged into the other port), or you can have four paddles plugged into two ports. Paddles 0 and 1 are the two paddles plugged into the left controller port, and paddles 2 and 3 are the two paddles plugged into the right controller port.
drawscreenThat doesn't mean you have to call "drawscreen" right away, but the paddle you've selected gets read during "drawscreen," so you won't be able to tell what the value of the selected paddle is until after the "drawscreen" routine has finished.
if paddle = 10 then do_something : rem * not very useful player0x = paddle : rem * more usefulNote that the value of "paddle" will be between 0 and 77, inclusive (the online help manual says "from about 0-80," but if I use the score to display the value of "paddle," it indicates that the highest value returned is 77).
player0x = 2 * paddle + 1 if player0x > 153 then player0x = 153(6) You can read only one paddle at a time, so if you want to read two paddles, you'll need to use two drawscreens:
currentpaddle = 0 drawscreen player0x = 2 * paddle + 1 if player0x > 153 then player0x = 153 currentpaddle = 1 drawscreen player1x = 2 * paddle + 1 if player1x > 153 then player1x = 153(7) Chances are you won't want to actually put two "drawscreen" statements in your loop, so you could use "currentpaddle" as a way of telling your program which paddle to process after "drawscreen" has finished:
set kernel_options no_blank_lines readpaddle loop currentpaddle = currentpaddle + 1 : rem * to get the next paddle if currentpaddle = 2 then currentpaddle = 0 : rem * to read 0, then 1, then 0 again, etc. drawscreen on currentpaddle goto paddle_0 paddle_1 comeback rem * do some more stuff if you want goto loop paddle_0 player0x = 2 * paddle + 1 if player0x > 153 then player0x = 153 goto comeback paddle_1 player1x = 2 * paddle + 1 if player1x > 153 then player1x = 153 goto comebackMichael
Edited by SeaGtGruff, Sat Apr 19, 2008 11:05 PM.
Posted Sat Apr 19, 2008 11:02 PM
Posted Sat Apr 19, 2008 11:06 PM
atari2600land, on Sun Apr 20, 2008 1:02 AM, said:
Posted Sun Apr 20, 2008 10:33 AM
currentpaddle = currentpaddle + 1 : rem * to get the next paddle if currentpaddle = 2 then currentpaddle = 0 : rem * to read 0, then 1, then 0 again, etc.
currentpaddle = 1 - currentpaddle : rem * to get the next paddle
Posted Sun Apr 20, 2008 11:05 AM
SpiceWare, on Sun Apr 20, 2008 12:33 PM, said:
currentpaddle = currentpaddle + 1 : rem * to get the next paddle if currentpaddle = 2 then currentpaddle = 0 : rem * to read 0, then 1, then 0 again, etc.
currentpaddle = 1 - currentpaddle : rem * to get the next paddle
currentpaddle = currentpaddle ^ 1which I think saves 1 byte and 2 cycles. My only lame-ass excuse for the method I used in my original post is that my dog ate my homework... er, I mean, I wanted to give an example that could be modified for other situations-- e.g., a joystick is in the left controller port, and a pair of paddles is in the right controller port:
set kernel_options no_blank_lines readpaddle currentpaddle = 1 loop currentpaddle = currentpaddle + 1 if currentpaddle = 4 then currentpaddle = 2 : rem * read 2, 3, 2, 3, etc. drawscreen a = currentpaddle - 2 on a goto paddle_2 paddle_3 comeback rem * do something else goto loop paddle_2 rem * do something goto comeback paddle_3 rem * do something goto comebackThat's my story, and I'm stickin' to it!
Posted Sun Apr 20, 2008 12:44 PM
currentpaddle = 5 - currentpaddle
Edited by SpiceWare, Sun Apr 20, 2008 12:45 PM.
Posted Sun Apr 20, 2008 2:17 PM
SpiceWare, on Sun Apr 20, 2008 2:44 PM, said:
currentpaddle = 5 - currentpaddle
currentpaddle = (currentpaddle + 1) & 3which doesn't compile as small as it could:
LDA currentpaddle; 2 bytes, 3 cycles CLC; 1 byte, 2 cycles ADC #1; 2 bytes, 2 cycles AND #3; 2 bytes, 2 cycles STA currentpaddle; 2 bytes, 3 cycles -- total 9 bytes, 12 cyclesBut it could be replaced with some inline assembly:
asm INC currentpaddle; 2 bytes, 5 cycles LDA #3; 2 bytes, 2 cycles AND currentpaddle; 2 bytes, 3 cycles STA currentpaddle; 2 bytes, 3 cycles -- total 8 bytes, 13 cycles endSo you could use one or the other, depending on whether you wanted to save 1 byte or 1 cycle.
Edited by SeaGtGruff, Sun Apr 20, 2008 2:17 PM.
Posted Sun Apr 20, 2008 6:17 PM
Posted Fri Jul 11, 2008 10:33 AM
Quote
Posted Fri Jul 11, 2008 2:25 PM
Posted Sat Jul 12, 2008 12:43 PM
SeaGtGruff, on Sun Apr 20, 2008 3:17 PM, said:
currentpaddle++ currentpaddle &= 3I would think that would give the same result as the ASM version. If the X register is free, though, the ASM version can be improved:
lda #3 ldx currentpaddle inx sax currentpaddleSeven bytes and ten cycles.
Posted Fri Aug 8, 2008 3:29 PM
Posted Fri Aug 8, 2008 3:53 PM
0 members, 0 guests, 0 anonymous users