| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
Mixing multiple effects is messing up stuff
I am doing a small and very lowtech demo but I seem to be confused about the raster timing - probably like any other C64 newbie out there(?).
I know(?) this is related to the raster interrupt I am using plus my routines and that everyone will shout out "learn to code before you do a demo" and you are right but I really need some directions or hints here as I cannot get my head around this problem. I have read a lot on the C64 Codebase and here in the forum but still I don't get it (no hope for me!?).
I am trying to get a static (not moving) rasterbar below a 2x2 scroll plus some music - this must be "demo programming day 1". I have done each part individually and they work but together they are screwing up things (of course!?). Well, the music and the 2x2 scroll I can get working but introducing the raster gets ne problems.
What I have is a rasterbar... fired up at raster pos #$80 (as an example). A few lines below I am starting my scroll and this is totally messing up things... the scroll is veeery slow and shifting between the 2x2 charset and the system charset and when playing music I can hear it is slowing down to 1/4 of the normal pace or alike. This must be because the rasters are overlapping but how can I overcome this?
This is not a matter of getting the rasterbars looking nice but a more fundamental problem I think - then the prettyness of the bars will be a problem for later on.
If anyone would explain me how or point me to a fool-proof-dummy-guide on how I might can solve this I would really appreciate it as I am getting really frustrated now and I don't see any solutions for it (though there obvioulsy is one). |
|
... 21 posts hidden. Click here to view all posts.... |
| |
ready.
Registered: Feb 2003 Posts: 441 |
as far as I see you have a problem in rolltxt, the code seems to get stuck there.
Furthermore, I understand you want to have 2 IRQs per frame: one for the raster bars, one for setting the scroll. Thus each irq call should write the new irq entry raster for the next irq:
int1
jsr raster
lda #<int2
sta $0314
lda #>int2
sta $0315
lda #int2_irq_entry_point
sta $d012
lda #$01
sta $d019 ; clear our irq
jmp $ea81
int2
jsr scroll2x2
jsr musplay
lda #<int1
sta $0314
lda #>int1
sta $0315
lda #int1_irq_entry_point
sta $d012
lda #$01
sta $d019 ; clear our irq
and also #$01 is enough for $d019.
Bebug the code using VICE monitor, it helps a lot :)
|
| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
I don't see it gets stuck in "rolltxt"? If you are referring to this:rolltxt lda scrtxt ; read next char
cmp #$00 ; stopchar? "@"
bne nextchar ; if not then jmp
lda #<scrtxt ; restart scroll
sta rolltxt+1
lda #>scrtxt
sta rolltxt+2
jmp rolltxt ; continue scroll
nextchar sta $0400+(10*40)+39
CUT.. This is just reinitializing the scrolltext in case of the stopchar has been reached. Or else please let me know what you mean.
Your code with the IRQ raster point makes perfectly good sense to me as it then would work in the same way as the initial "setup" IRQ. But... I cannot get it working. If I have your code I am back at the 1/4 speed problem. This is because of the "sta $d019" in "int1" - without it, it runs in the normal speed but then I cannot get the rasterbars stable. Please see this picture, http://cobrakid.dk/asm/mydmo3.png. There you can see there is a black line between the two yellow colors... there is no black line there in my colors so I don't see how I can tweak that with NOP or anything else?
The code which is not working:
http://cobrakid.dk/asm/mydmo3-asm.txt
Running with the initial code it works fine.
Debug in VICE? You mean reset and check memory? I guess it is not possible to do a trace frame-by-frame? |
| |
j0x
Registered: Mar 2004 Posts: 215 |
There *are* black lines (value 0) in your colours. In fact, every 8th colour is black.
There's also another problem:
You begin at raster line $7a, then make numcols=59 rastercolour lines, and then trigger the next IRQ at raster line $8a. Since, after drawing the raster colours, you've passed line $8a, this next IRQ won't trigger until the frame after, which is why your entire screen is flashing.
Once you get the individual routines to work together, you still have the job of getting the raster colour timing right, most notably synchronizing your "8,8,8,8,8,8,8,1" delay tables to your badlines.
I look forward to seeing the end result.
|
| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
Ahhh, and the black line in the middle was because of the badline - got it.
OK, I now think I have got rid of the badline. As I understand it, this is only needed to be fixed once so I did it in the setup part where I added a 21 cycles delay (7 x "bit #$ff"). It is not pretty but it works.
Is this the correct way of dealing with the badline?
Furthermore I cannot get it working when having a "sta $d019" in the first interrupt (then it does the 1/4 of the speed). Am I doing something wrong? I know it works but this could still be pure luck?
See the source:
http://cobrakid.dk/asm/mydmo4-asm.txt
The next thing must be a 1x1 scroll but I assume this can fit in the "int2" section without too much problems. |
| |
TWW
Registered: Jul 2009 Posts: 545 |
Forget the bit $ffff's they do you no good.
You should study up on how your interrupt ruitine is buildt up and how it works. As it looks now it seems like a cut and paste garble from several different sources. You mix up methods on how to position the code vs. the raster.
If you are using the $d011/$d012 raster position to trigger an interrupt at some point, why begin with a polling loop (cmp $d012) in the middle of this? Secondly, you have to ack. a interrupt ($d019) if you wish it to become ready again.
As stated above, your raster routine spews out 59 raster lines which is too much, you only have 16 available before your next interrupt occurs ($7a-8a).
In your first post you said you wanted some rasters below a scroller so why bother splitting up with IRQ's in the first place.
what you need to do is:
#1: Determine where you want your scroller
#2: Make a single IRQ trigger on the rasterline you want your raster-collors to begin
#3: draw raster collors
#4: Scroll the scroll
#5: Play the music
#6: Set up for the next IRQ ($0314/0315) and ack.
then the VIC will tell the CPU when to begin all over again.
if this isn't clear enough, do this:
SEI
LDA #WhereTheFuckYouWantIt
STA $d012
BLABLABLA (this part is correct)
CLI
JMP *
irq:
DEC $d019
JSR Raster
JSR Scroller
JSR Music
LDA #WhereTheFuckYouWantIt
STA $d012
LDA #<irq
sta $0314
lda #>irq
sta $0315
jmp $ea81 |
| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
Well, maybe I have not made this clear enough but I want the raster and scroller to be on top of eachother... naturally with the scroller in front (maybe that's why I said the raster should be "below" the scroller - I meant "behind" it).
So I do need the splitscreen and the "cmp $d012" to end it (as far as I know).
I do understand your method but I don't see how I can do this without having the two interrupts as I cannot draw it all in one go?
I will try your approach tomorrow but if you look at the web (which is how I learn + old tutorials) then you see sooo many different ways of doing this. Some says "sta $d019" other says "inc" or "dec" so it is not easy to know what exactly is the correct way of doing it. If you can recommend some good learning tutorials on interrupts I really want to read them. |
| |
Mr. SID
Registered: Jan 2003 Posts: 424 |
That's because there is no correct way. There are multiple possible solutions. You have to be able to substitute that on the fly.
inc $d019
dec $d019
asl $d019
etc.
all do the same thing, i.e. acknowledging the IRQ has been handled (otherwise it will trigger again immediately).
What you need to do is understand how the system works, before writing the code. For me, a piece of paper and a pencil is a useful tool to do that.
And then you need to get an idea how long your code is in raster lines. You need to measure that (with inc $d020/dec $d020) or count cycles, to understand what will happen if you execute that code at a specific line on the screen.
It's almost never possible to just copy/paste parts from different sources together. Use Codebase64 not as a code repository, but as a learning tool. |
| |
Cobrakid
Registered: Oct 2011 Posts: 23 |
If you have any good readings for me, then please let me know. What I have found so far is reference books (not very good ones), Ghouls Assembly Course (really good and in danish but doesn't cover the irq routine) and then too many different methods on the internet without proper explanation.
What I really would love to see is a good book that gets me from A-Z... or at least covers the basics like frames, cycles, irqs and badlines etc. This source I cannot find so I am doomed to read thousands of different methods out there and piece together that info into how I think it works.
So... please let me know of good reading materials - especially on the irq routine as I would like to get that right. |
| |
Frantic
Registered: Mar 2003 Posts: 1648 |
Maybe some of this would be helpful?
http://codebase64.org/doku.php?id=base:demo_coding_introduction
http://codebase64.org/doku.php?id=magazines:chacking3#rasters_-.. |
| |
ready.
Registered: Feb 2003 Posts: 441 |
this will help also:
http://unusedino.de/ec64/technical/aay/c64/
as a reference for hardware registers involved with IRQs |
Previous - 1 | 2 | 3 | 4 - Next |