salzmafia.com Posted September 30, 2012 Share Posted September 30, 2012 Is there a way to randomly change the colors of a multicolored sprite? If so how do you do it without a bunch of jumps to different "player0color"s? Quote Link to comment Share on other sites More sharing options...
RevEng Posted September 30, 2012 Share Posted September 30, 2012 One example... set kernel_options player1colors playercolors pfcolors dim p0colorl=player0color dim p0colorh=player0color+1 player0x=80 player0y=50 player0: %11111111 %11000011 %10111101 %10111101 %10111101 %10111101 %11000011 %11111111 end main p0colorl=0 p0colorh=rand drawscreen ...in a nutshell, it points player0color to the beginning of a random page of memory. As-is it flashes yellow a lot because there's a lot of unused rom in the kernel bank. As you use the rest of the space in the kernel bank the color will be more random appearing. Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted October 1, 2012 Share Posted October 1, 2012 One example... set kernel_options player1colors playercolors pfcolors dim p0colorl=player0color dim p0colorh=player0color+1 player0x=80 player0y=50 player0: %11111111 %11000011 %10111101 %10111101 %10111101 %10111101 %11000011 %11111111 end main p0colorl=0 p0colorh=rand drawscreen ...in a nutshell, it points player0color to the beginning of a random page of memory. As-is it flashes yellow a lot because there's a lot of unused rom in the kernel bank. As you use the rest of the space in the kernel bank the color will be more random appearing. How about pointing player0color to a section of RIOT or Superchip RAM and then changing that RAM to random color values? Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted October 1, 2012 Share Posted October 1, 2012 (edited) How about pointing player0color to a section of RIOT or Superchip RAM and then changing that RAM to random color values? I found this old example I made of pointing player1's color table to RAM. It scrolls through all 128 colors, but it should be easy to change it to do random colors. set kernel_options player1colors dim p1color = a dim p1color_row1 = a dim p1color_row2 = b dim p1color_row3 = c dim p1color_row4 = d dim p1color_row5 = e dim p1color_row6 = f dim p1color_row7 = g rem * now set the player1color pointers rem * to the address of variable a (or p1color) asm LDA #<p1color STA player1color LDA #>p1color STA player1color+1 end rem * define the player1 shape player1: %00111100 %01111110 %11111111 %11111111 %11111111 %01111110 %00111100 end rem * set the initial color for each row p1color_row1 = $00 p1color_row2 = $02 p1color_row3 = $04 p1color_row4 = $06 p1color_row5 = $08 p1color_row6 = $0A p1color_row7 = $0C rem * position the player player1x = 76 player1y = 48 rem * now do the display loop loop drawscreen rem * cycle the colors p1color_row1 = p1color_row1 + 1 p1color_row2 = p1color_row2 + 1 p1color_row3 = p1color_row3 + 1 p1color_row4 = p1color_row4 + 1 p1color_row5 = p1color_row5 + 1 p1color_row6 = p1color_row6 + 1 p1color_row7 = p1color_row7 + 1 rem * adding 1 instead of 2 makes them cycle a little slower goto loop Edit: Pasting the code didn't work too well-- use the attached source instead. test_player1colors_in_RAM.bas test_player1colors_in_RAM.bas.bin Edited October 1, 2012 by SeaGtGruff Quote Link to comment Share on other sites More sharing options...
salzmafia.com Posted October 1, 2012 Author Share Posted October 1, 2012 One example... set kernel_options player1colors playercolors pfcolors dim p0colorl=player0color dim p0colorh=player0color+1 player0x=80 player0y=50 player0: %11111111 %11000011 %10111101 %10111101 %10111101 %10111101 %11000011 %11111111 end main p0colorl=0 p0colorh=rand drawscreen ...in a nutshell, it points player0color to the beginning of a random page of memory. As-is it flashes yellow a lot because there's a lot of unused rom in the kernel bank. As you use the rest of the space in the kernel bank the color will be more random appearing. Worked perfect. Thanks! Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted October 1, 2012 Share Posted October 1, 2012 I redid my old example to do random colors. test_player1colors_in_RAM.bas test_player1colors_in_RAM.bas.bin 1 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.