DavidEth Posted September 27, 2010 Share Posted September 27, 2010 Seems like it could work -- the mountains in Chopper Command might be doing it. Assume I have a grid of squares, and I want each square to have an arbitrary color based on terrain type. (Using SCORE mode works great for games like Medieval Mayhem, not sure it applies here) Assuming I had a subroutine for each of several combinations of terrain, can I hit COLUBK multiple times per scanline and expect it to work on real hardware? Seems like the fastest I could do it is every 9 color clocks (a bunch of STA/STX/STY COLUBK's to pick between three colors), but that doesn't line up with the playfield and I would be unable to update the playfield registers either. Every color clock being 3 cpu cycles makes it a bit of a pain in the ass to line up though. Does the write from the CPU happen on the last cycle of the instruction? ST{AXY} COLUP0 ; 3 cycles, 9 color clocks; 17 tiles across, only 3 colors. ST{AXY}.w COLUP0 ; 4 cycles, 12 color clocks. 13 tiles across. Playing field would line up at least. LDA #NN STA COLUP0 ; 5 cycles, 15 color clocks. 10 tiles across. Arbitrary colors. LDA #NN STA.w COLUP0 ; 6 cycles, 18 color clocks. 8 tiles across. Arbitrary colors. LDA #NN NOP STA COLUUP0 ; 7 cycles, 21 color clocks, not very useful. LDA #NN STA zp_dummy STA COLUP0; 8 cycles, 24 color clocks. 6 tiles across. Playing field would line up. I guess the only practical one gives me a whopping 6 tiles across while still having enough time to update playfield registers too. If I wanted a bigger map I guess it could scroll? -Dave Quote Link to comment Share on other sites More sharing options...
Crazyace Posted September 27, 2010 Share Posted September 27, 2010 Hi Dave, I use this to get 6 different coloured graphic shapes ( all the same character ) for a puzzle game style kernel ( Players set 3 copies narrow as P0 P1 P0 P1 P0 P1 ) ;Single line of graphics ldx #10 line stx index inx ldy colour stx COLUPF lda graphic-2,x sta GRP0 sta GRP1 ldx colour+5 txs sty COLUP0 ldy colour+1 sty COLUP1 ldx colour+3 ldy colour+4 lda #$f2 sta COLUBK lda colour+2 sta COLUP0 stx COLUP1 sty COLUP0 tsx stx COLUP1 lda #0 sta COLUBK ldx index dex bne line Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted September 28, 2010 Share Posted September 28, 2010 Yes, you can display multiple colors per scan line using a single color register. And as you've already figured out, getting the color changes to align with the playfield pixels can be tricky. Assuming you've already got the accumulator, X register, and Y register loaded with the colors you want to use, the fastest color change is STA COLUBK ; 3 machine cycles * 3 color clocks = 9 screen positions STX COLUBK ; 3 machine cycles * 3 color clocks = 9 screen positions STY COLUBK ; 3 machine cycles * 3 color clocks = 9 screen positions If you want to make the color changes line up with the playfield pixels, use absolute addressing: STA.a COLUBK ; 4 machine cycles * 3 color clocks = 12 screen positions / 4 color clocks = 3 playfield pixels STX.a COLUBK ; 4 machine cycles * 3 color clocks = 12 screen positions / 4 color clocks = 3 playfield pixels STY.a COLUBK ; 4 machine cycles * 3 color clocks = 12 screen positions / 4 color clocks = 3 playfield pixels Of course, that limits you to switching between 3 colors-- which might be enough for what you want to do-- and you have to have the colors preloaded. Or, if you want one of the colors to continue for a bit before it's changed, you might need to have only 2 colors preloaded. If you don't want any of the colors to repeat, the fastest you can load and change colors is LDA #val1 ; 2 machine cycles + STA COLUBK ; 3 machine cycles = 5 cycles * 3 clocks = 15 positions LDA #val2 STA COLUBK This could be used with the Harmony's DPC+ fast-fetch mode, or the code could be stored in RAM so the values loaded by the LDA# instructions can be changed. Otherwise, the fastest loads for variable data are LDA zp1 ; 3 cycles + STA COLUBK ; 3 cycles = 6 cycles * 3 clocks = 18 positions All of those examples assume you're using a single color register. If you use two or more color registers, you can get more colors on a line, or have color changes that are closer together. Michael 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.