| |
tonysavon
Registered: Apr 2014 Posts: 25 |
Different side border colors
I'm trying to obtain (what I thought was) a very simple effect. While displaying a bitmap, I need the side borders to be of different colors just for the 200 lines visible part of the screen (so top and bottom borders would be black). Say I want the left border to be white and the right border to be red.
I played a bit with timing and I kinda achieved something, but it's not really working very well yet. I was wondering if there was a pre-made piece of code somewhere for doing this kind of vertical splits, possibly with a LUT, so that I could have 200 different colors on the left and 200 different colors on the right. Right now I feel like if I keep hammering this spaghetti mess I have in front of me I'll eventually manage to do something, but I wouldn't want to re-invent the wheel and I'm sure there's a clean, short way of doing this
Thanks |
|
... 17 posts hidden. Click here to view all posts.... |
| |
tonysavon
Registered: Apr 2014 Posts: 25 |
OK, I think I got there. This is it for a block of 8 lines, the first one being a badline.
https://www.dropbox.com/s/urjdz6fkvvjd7h9/split.bmp?dl=0
The trick is to preload A and Y with the values you want to use, just before the badline, then stabilize the raster using only the x register, and shoot those two values straight away to $d020, with a nop in between. The remaining lines of the block are not badlines and can be done quite easily.
Here is my irq code for that. colortable and colortable+14 are the LUT for left and right borders. colortable is $100 aligned. I think from here it should be easy to extend it to the whole 200 lines that I need.
irq: pha
txa
pha
tya
pha
lda colortable
ldy colortable+14
:stabilize()
sta $d020
nop
sty $d020
ldy #$08
lda colortable+1
sta $d020
!:
dey
beq !skp+
ldx #$02
dex
bne *-1
inc smf + 1
inc smf2 + 1
smf: lda colortable + 14
sta $d020
smf2: lda colortable + 1
ldx $d012
cpx $d012
beq *-3
sta $d020
jmp !-
!skp:
lda #14
sta smf + 1
lda #1
sta smf2 + 1
lda #<irq
sta $fffe
lda #>irq
sta $ffff
inc $d019
lda #$31
sta $d012
pla
tay
pla
tax
pla
rti |
| |
SIDWAVE Account closed
Registered: Apr 2002 Posts: 2238 |
well, its pretty, but i wish that i could add a spacebarcheck and keep the effect as it is.. :)
23 Byte Effect |
| |
Mixer
Registered: Apr 2008 Posts: 452 |
I read the posts and was wondering: "What is going on here, how on earth it is doable...?" Then I had the major "Doh!" moment.
Since sideborders can be opened on a badline even with 4 sprites on with the first d016 write taking place at cycle 56 - a cycle before right border when screen is x expanded - then it is natural to assume that same is doable with any memory address or register. Done that dozens of times for checking the d016 timing and still I could not connect the dots here :). Fail. |
| |
SIDWAVE Account closed
Registered: Apr 2002 Posts: 2238 |
just do it the oldstyle way. look in some upfront demo. |
| |
Krill
Registered: Apr 2002 Posts: 2980 |
WAT. Of course it's trivial, and there are plenty of cycles left even with look-up table action including indexed table access and a loop.
Kompokürbis (Yes, i coded this on short notice, at a party, while having a couple of beers. Seems i have used an assembler, not a monitor, though.)
In which strange parallel dimension have i awoken today? Where have the skills of some of the best coders on this machine gone? Since when is "sta mem,x" a read-modify-write operation?
WHAT. THE. FUCK. |
| |
Peacemaker
Registered: Sep 2004 Posts: 275 |
irq1:
ldx #$20
jsr rasternail (make raster stable)
lda #$32
cmp $d012
bne *-3
ldy #$0b
dey
bne *-1
nop
nop
nop
.var count = 0
.for(var a=0;a<200;a++) {
.eval count = count +1
ldx color1+a
ldy color2+a
stx $d020
sty $d020
.if ( count <= 7 ) {
jsr delay
} else {
.eval count = 0
nop
nop
}
}
inc $d019
pla
tay
pla
tax
pla
rti
delay:
nop
nop
ldx #$06
dex
bne *-1
rts |
| |
Peacemaker
Registered: Sep 2004 Posts: 275 |
Quote: You would need to update the border colors per rasterline in order to achieve this (stable raster is not needed as you can update the d020 register in the non-visible area's)
a simple delay loop taking into account badlines will work well but use up valuable cpu time. (using nmi or timers, or interleaving code inbetween can be done instead however)
stable raster is ofcourse needed. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
Hey Gunnar, I was reading the posts lazily and I thought LUT's would be for delays across bad / non bad lines :) I bet the other best coders have similarly good excuses :) |
| |
MagerValp
Registered: Dec 2001 Posts: 1078 |
Haha, well that's what happens when I do a quick forum check and throw together some broken test code before rushing off to work. :)
And yup, don't need RMW but you do need an op with more than one write cycle, lest DMA steals the cycle you need.
As an interesting side note of it'd be a challenge to do it with a 65C02 since extra write cycles in RMW and indexed ops have been replaced by read cycles. |
| |
HCL
Registered: Feb 2003 Posts: 728 |
You guys are funny :) |
Previous - 1 | 2 | 3 - Next |