| |
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 |
Dr.Science, this is exactly the kind of effect I'm trying to obtain. It was very silly of me not to think your intro, since I've been staring at that petscii quite a bit when it came out.
Indeed, the current version of my attempt is exactly what you have done there: manual timing line by line for a small portion of the screen. Although your code looks way more polished :-P.
I think it must be possible to have it for generally long areas and with a LUT to change the colors at will, but perhaps I'm wrong. I'll keep researching and I'll post my findings if I ever land somewhere.
Thanks everybody for your support :-) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
cpu is too slow for LUT based timing on this IMHO.
here's a pointer: try to make it work for one character (8 lines including bad line on top)
then it should be possible to repeat this code (macro or copy paste) for every char row. |
| |
Mantiz Account closed
Registered: Apr 2006 Posts: 36 |
You can do as above and load the colors directly from a color table somewhere in memory without indexing. Instead you manipulate the color table in the bottom and top border.
For 200 lines it will be 400 bytes at most to change, for which enough cpu time should be available in the top/bottom borders.
(unless the music takes too much time or you are doing something spectacular, then you have to do some of the manipulating during the rasterlines instead, or place some color data in ZP to save cycles.) |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
As Oswald stated, is possible to do this with a loop, or a macro, but timing should be "hand-made" for each "text" line:
https://dl.dropboxusercontent.com/u/93655104/border-poc.jpg
Colors may be loaded from a table... |
| |
Trurl
Registered: Mar 2002 Posts: 61 |
Another example: Mietaa |
| |
MagerValp
Registered: Dec 2001 Posts: 1078 |
Hmm, what am I missing in my test code? Ah, have to use an rmw op (e.g. sta $d020,x) to get it to write at the right cycle. Silly me. This works of course:
.macro delay
ldx #9
: dex
bne :-
bit $ea
.endmacro
lda #left
sta $d020
nop
nop
bit $ea
lda #right
sta $d020,x
lda #left
sta $d020,x
delay
lda #right
sta $d020,x
lda #left
sta $d020,x
delay
lda #right
sta $d020,x
lda #left
sta $d020,x
delay
lda #right
sta $d020,x
lda #left
sta $d020,x
delay
lda #right
sta $d020,x
lda #left
sta $d020,x
delay
lda #right
sta $d020,x
lda #left
sta $d020,x
delay
lda #right
sta $d020,x
lda #left
sta $d020,x
delay
lda #right
sta $d020,x |
| |
The Phantom
Registered: Jan 2004 Posts: 360 |
It can be a pain in the butt, for sure.
You can also see it here... Nightmare Intro
The code for the lower splits is somewhere around $5000... |
| |
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. |
Previous - 1 | 2 | 3 - Next |