Jump to content

Zach's Projects

  • entries
    53
  • comments
    535
  • views
    67,251

Five colors.

Sign in to follow this  
Zach

1,972 views

 

(actual screenshot)

 

Here's another kernel that I would have not thought possible earlier. It draws up to 17 objects that can independently be any of 5 colors. I'll give you all a chance to guess how this works before explaining it.

 

Here are some details. Are they useful as hints?

  • The ball is available as a cursor, and can be a 6th color.
  • Colors are very limited: the choices are $3X $7X $BX or $FX.
  • If the number of objects in a row is at most 11, the color choices are unrestricted (except for one, which depends on A and X.)
  • If the number of objects per row is 10 or less, you can make more interesting shapes with the PF.

One fun application would be a Sega Swirl clone.

Sign in to follow this  


9 Comments


Recommended Comments

If the Ball is available as a sixth color, that would suggest that you're using score mode. Not sure exactly what you're doing with the players and missiles, though.

 

Using blending, it's possible to get a lot of colors per scan line. Since you describe the colors in hex terms, though, I'm guessing you're not talking about blended colors.

Share this comment


Link to comment

I'm not using the playfield, so it doesn't matter whether score mode is on. I guess by blended colors you mean flickering? The colors are all solid, and the screenshot is of a single frame.

 

Here's another hint: I am taking advantage of some simple combinatorics. There will always be one color that appears three times at most. To prove this just consider what would happen if five colors appeared four times. That would be 20 objects. The color that appears no more than thrice is handled differently from the other four.

 

BTW, I was a bit mistaken when I described the available colors. At present, they must be in the form XX11XX0X.

Share this comment


Link to comment

I'm not using the playfield, so it doesn't matter whether score mode is on. I guess by blended colors you mean flickering? The colors are all solid, and the screenshot is of a single frame.

 

Here's another hint: I am taking advantage of some simple combinatorics. There will always be one color that appears three times at most. To prove this just consider what would happen if five colors appeared four times. That would be 20 objects. The color that appears no more than thrice is handled differently from the other four.

 

BTW, I was a bit mistaken when I described the available colors. At present, they must be in the form XX11XX0X.

You must use both players and both missiles for the special color. But the blocks must be 9 pixels wide, it seems you need some tricks to make it work.

 

Maybe the leftmost object is two missiles overlapped to make 9, and the color pre-determined. The next object is player0, say >=5 double-wide units and the next is player1. You change your RAM routine as follows to insert the three objects:

 

A kernel line may look like this:

; copied to RAM at $80
ramkernel:; 57 cycles
 sta COLUBK
 stx COLUBK
 sax COLUBK
 nop 0; placeholder for two missiles
 sty COLUBK
 sta COLUBK
 sty COLUBK
 stx COLUBK
 sta COLUBK
 stx COLUBK
 sax COLUBK; color of NEXT block
 sax COLUP0; color of block stored to player
 stx COLUBK
 sty COLUBK
 stx COLUBK; same deal as above
 stx COLUP1; but change player1
 sta COLUBK
 rts


kernel; enter just before visible screen
 jsr $80
; back from RAM at 60 cycles
 sta temp
 lda fifthcolor
 sta COLUP0
 sta COLUP1
 lda.w temp
; instructions above repeat for every scanline we draw stuff

 

Would this work, or did you do it a different way?

Share this comment


Link to comment

Would this work, or did you do it a different way?

Both, I think. :D Your way would have not restrictions on colors.

 

The way I do it is to combine players and missiles to make two 9-pixel blocks. The special case color is stored in P and is pushed to color the third block, and that is why certain bits are fixed.

 

  lda #colorP
  sta WSYNC
  sta COLUP1
  sta COLUP0
  lda #colorA
  jmp loop

loop		 
  ldx #COLUBK
  plp
  txs
  ldx #colorX; sets N and Z flags, and restricts colorP
  stx COLUBK
  sty COLUBK
  sax COLUBK
  sty COLUBK
  php
  sax COLUBK
  sta COLUBK
  sty COLUBK
  sta COLUBK
  stx COLUBK
  sta COLUBK; covered by P0 and M0
  sax COLUBK
  sty COLUBK
  sta COLUBK; covered by P1 and M1
  sax COLUBK
  stx COLUBK
  sta COLUBK
  sty COLUBK
  ldx #colorP_addr-1 
  txs
  dec counter
  bne loop
  jmp out
  sty COLUP1; assume Y is background color
  sty COLUP0

Share this comment


Link to comment

How would you handle the color sequence "F037F037F037F037F"? Only four colors, but all of them occur at least four times and no combination of three will work for STA/STX/SAX.

 

Incidentally, you could avoid using the PHP trick if you set the sprite colors on the start of each scan line, programmed both players to be 10-18 pixels wide (easiest way is a double-wide $FF) and positioned them at the second and third "special" spots. Replace the "ST? COLUBK" which would go "under" a player with "ST? COLUBK" for the FOLLOWING color. Replace the "ST? COLUBK" following the player with "ST? COLUP?".

 

It is possible to come up with color sets that will work, though. For a background color of zero, I think all of the workable color sets have one of the following forms (where A, B, C, and D have no bits in common)

 

0 A B A+B A+C

0 A B A+C A+D

0 A B A+B+C A+D

0 A A+B A+C B+D

 

I've not worked out whether there are any interesting cases with a non-zero background color (other than the obvious one of OR'ing a fixed value into everything).

Share this comment


Link to comment

How would you handle the color sequence "F037F037F037F037F"? Only four colors, but all of them occur at least four times and no combination of three will work for STA/STX/SAX.

Didn't consider that case. I guess the number of objects per row will have to be limited to 15.

Share this comment


Link to comment

How would you handle the color sequence "F037F037F037F037F"? Only four colors, but all of them occur at least four times and no combination of three will work for STA/STX/SAX.

Didn't consider that case. I guess the number of objects per row will have to be limited to 15.

 

I just finished editing my post above; with different color sets, your 17-color thing should work.

Share this comment


Link to comment
I just finished editing my post above; with different color sets, your 17-color thing should work.

 

Further info: chose three colors, A, B, and C, such that ((A and C) and not B)==0. Then you'll also get colors (A and B) and (A and C). Note that if ((A and C) and not B) is not zero, and if all your colors are distinct, it will not be possible to manage to get the set of four colors (B, C, A and B, A and C).

Share this comment


Link to comment

Thanks for the suggestions, John. I will create an updated proof of concept at some point.

Share this comment


Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...