jrok Posted May 13, 2016 Share Posted May 13, 2016 (edited) I've noticed it's fairly straightforward to randomize P0's colors with the statement: player0color = rand Is there a similarly simple method of assigning random colors to a virtual player? Thanks, J Edited May 13, 2016 by jrok Quote Link to comment Share on other sites More sharing options...
RevEng Posted May 13, 2016 Share Posted May 13, 2016 It's not as simple with DPC+. DPC+ maintains ARM memory pointers to virtual player's color, so you need to call a DPC+ function to update these pointer values. For player1color: it would look like... asm lda #<(playerpointers+18) sta DF0LOW lda #(>(playerpointers+18)) & $0F sta DF0HI LDX rand STX DF0WRITE LDA #0 STA DF0WRITE end For player2colors change the 18's to 20's. For player3colors: change the 18's to 22's. Keep adding +2 for later colors. Quote Link to comment Share on other sites More sharing options...
jrok Posted May 14, 2016 Author Share Posted May 14, 2016 Thank you! 1 Quote Link to comment Share on other sites More sharing options...
jrok Posted May 16, 2016 Author Share Posted May 16, 2016 I have related question: Suppose I wanted to do the following: - Define the colors for each line of a virtual sprite (in a data statement, I'm guessing? Then push them into the sprite?) - Add a multiple of 16 to each line when the code is run. I'm trying to build a palette swapping function, preserving each line's brightness while shifting the hue. Thanks again. Quote Link to comment Share on other sites More sharing options...
RevEng Posted May 17, 2016 Share Posted May 17, 2016 Ok, so I dug into this a bit more and refreshed myself on the details... I've updated my previous explanation as a result, but the code I gave earlier still holds. Changing the hue values isn't going to happen easily. When you use player#colors: with DPC+, the color values are stored in "ROM" same as with other kernels. bB then sets up the ARM player#color pointers to point to where that ROM color data appears in ARM memory. Since it's all in ROM, you'd first need to change that ARM pointer to point to ARM RAM instead, so you can modify the contents. I tried pointing it to the bB DPC+ stack page, but that didn't seem to work correctly. I'm sure I'm missing some ARM pointer implementation detail, but I've reached the limit of my knowledge here. Quote Link to comment Share on other sites More sharing options...
jrok Posted May 17, 2016 Author Share Posted May 17, 2016 (edited) No worries. Just in case I wasn't explaining myself right, I wrote a little test program a while back that does a similar color swap with the playfield object. set kernel DPC+ dim PF_line = a dim chroma = b dim chroma_shift = c goto Start bank2 bank 2 Start playfield: ..............XXX............... .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. .............XXXXX.............. ..............XXX............... end data zonelumshift $00,$00,$02,$02,$04,$06,$08,$0A,$0C,$0E, $00,$00,$00,$02,$02,$02,$04,$04,$04,$06, $02,$02,$04,$04,$02,$02,$04,$04,$02,$02, $00,$02,$04,$06,$08,$08,$06,$04,$02,$00, $00,$02,$00,$04,$00,$06,$00,$08,$00,$0A end chroma = 16 WritePFColorLoop DF0FRACINC=128 DF1FRACINC=128 DF2FRACINC=128 DF3FRACINC=128 DF4FRACINC=128 DF6FRACINC=128 DF7HI = 10 DF7LOW = 52 PFColor for temp1 = 0 to zonelumshift_length DF7PUSH = zonelumshift[PF_line] + chroma PF_line = PF_line + 1 next PF_line = 0 rem Press and release the fire button to change the color if joy0fire then chroma_shift = 1 if !joy0fire && chroma_shift then chroma_shift = 0 : chroma = chroma + 16 drawscreen goto WritePFColorLoop It's been a couple of years since I've tucked into bB, and I forget how I determined the hi and lo pointers for the playfield. I assume I could use a similar technique to color the background, right? Edited May 17, 2016 by jrok Quote Link to comment Share on other sites More sharing options...
RevEng Posted May 17, 2016 Share Posted May 17, 2016 I assume I could use a similar technique to color the background, right? Sort of confused if we're talking about sprite colors or background playfield colors. Your earlier post talked about sprite colors, here you mention background [playfield] colors. bB DPC+ playfields (and colors) are RAM based, and can be modified, swapped, etc. bB DPC+ players (and colors) are pointers to ROM, which can't be modified. (in theory, you can point them to RAM, and modify the RAM, but I can't get this to work.) If you wish to modify the PF background color, change the "DF7HI" index to point to another queue/page in your example. IIRC, it's probably 11 for background colors. The "DF7LOW" value is the byte offset within the playfield data. Quote Link to comment Share on other sites More sharing options...
jrok Posted May 17, 2016 Author Share Posted May 17, 2016 Sort of confused if we're talking about sprite colors or background playfield colors. Your earlier post talked about sprite colors, here you mention background [playfield] colors. bB DPC+ playfields (and colors) are RAM based, and can be modified, swapped, etc. bB DPC+ players (and colors) are pointers to ROM, which can't be modified. (in theory, you can point them to RAM, and modify the RAM, but I can't get this to work.). Sorry, I drifted off topic there. Yeah, that was the original question, I just included that sample in case I wasn't explaining the desired (sprite) effect well enough. If you wish to modify the PF background color, change the "DF7HI" index to point to another queue/page in your example. IIRC, it's probably 11 for background colors... Yes, it is. I tried to RTFM for this, but I couldn't find it documented anywhere. Thanks, again. Quote Link to comment Share on other sites More sharing options...
RevEng Posted May 18, 2016 Share Posted May 18, 2016 No worries. Glad to help! Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted April 18, 2018 Share Posted April 18, 2018 I've been playing around with changing the pf and bgcolors for a couple days and came up with a really cool thing for my game but now that I got a chance to try it on real hardware it doesn't change anything, so I tried jrok's code and it works in stella but just boots a black screen on real hardware (mine atleast) Here's my little test that does boot up but doesn't change anything like it does in stella, Something wrong with my code? like byte offset (I used the d variable to pick those numbers) or has this never worked on real hardware? colorchange.bas Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted May 1, 2018 Share Posted May 1, 2018 I really need some help with my question above. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted May 1, 2018 Share Posted May 1, 2018 At least as a starting point, your playfield definition is messed up. It is inconsistently indented (which makes it hard to read), some lines are not indented at all (everything other than the "end" statement needs to be indented by at least once character), and some lines are the wrong length (all of them should be 32 characters). Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted May 2, 2018 Share Posted May 2, 2018 (edited) Ok I fixed that, and changed every temp variables to regular ones, moved some stuff around and tried different things until I thought it could only be the value for DF7LOW that's wrong, so I changed it to a counter and thought it must hit the right number some time and have some effect? So right now in stella the pf and bgcolors scrolls and you can change colors with the fire button, but on real hardware it has no effect.. d=d+1 ;df7low counter if joy0fire then chroma = chroma + 16 DF7HI = 10 DF7LOW = d ;.............................rails PF_line = 0 PFColor for e = 1 to 9 DF7PUSH = zonelumshift[PF_line] + chroma PF_line = PF_line + 1 next ;...........................top wall PF_line = 0 DF7HI = 11 DF7LOW = d for e = 1 to 10 DF7PUSH = zonelumshift3[PF_line] + chroma PF_line = PF_line + 1 next ;...........................bottom wall PF_line = 0 DF7HI = 11 DF7LOW = d for e = 1 to 10 DF7PUSH = zonelumshift2[PF_line] + chroma PF_line = PF_line + 1 next Just a normal display of the colors in the initialization???? colorchange (2).bas Edited May 2, 2018 by Lillapojkenpåön Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted May 4, 2018 Share Posted May 4, 2018 Got it to work colorchange (5).bas 1 Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted May 8, 2018 Share Posted May 8, 2018 I have a related question.. Does storing values to DF0HI, DF0LOW and DF0PUSH take alot of cycles similar to using the stack? 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.