Login
Back to forumReply to this topicGo to last reply

Posted By

carrion
on 2018-04-24
08:50:36
 IRQ Interrupt examples

Hi all
I try to write small program and I'm in need to do raster interrupts irq handler.
I tried to do it in analogy to what I did before on c64 and it works on Vice xplus4 - sort of.
But when run in Yape or Plus4Emu it won't work at all.
Are there any examples of how to setup simple basic irq handler so I could use it.
Thanks in advance.

Posted By

bubis
on 2018-04-24
09:32:11
 Re: IRQ Interrupt examples

This is what you do if you don't need ROM.

rasterline = 200

sei
sta $ff3f
lda #lo(irq)
sta $fffe
lda #hi(irq)
sta $ffff
lda #2+hi(rasterline)
sta $ff0a
lda #lo(rasterline)
sta $ff0b
dec $ff09
cli

...

irq:
pha
txa
pha
tya
pha

...

dec $ff09
pla
tay
pla
tax
pla
rti


Posted By

carrion
on 2018-04-24
11:10:23
 Re: IRQ Interrupt examples

OK
So what I have is quite the same but looks like my problem is elsewhere.
what I do is I set the multicolor and charmap to $2000 doing it like this:

lda #$18 // multicolor
sta $ff07
lda #$20
sta $ff13

and it works in Vice (I know its not perfect emulation) and doesn't work in Yape/Plus4Emu

I download the SVS xls memory map tool which I remember seeing and it was excellent
but maybe you could point me right here and now to what I do do wrong?
also what is the best way to change charmaps in many areas of the screen.
which solution is better:

to wait for raster like this:
lda #$d0
cmp $ff1d
bne *-3

or to do another irq and set fffe/ff vectors to poin at new raster line?

Posted By

KiCHY
on 2018-04-24
11:40:41
 Re: IRQ Interrupt examples

Hi Carrion,

One issue can be the direct writing of $ff07. You erase the NTSC flag, and if you left your emulator in NTSC video mode, interesting things can happen happy

Can you specify that "won't work at all" thing? Does the IRQ setup routine finish running? Does the interrupt fires at least once? What can you see on screen? Etc.

If you want several effects at different raster positions, perform them in separate interrupts (reconfiguring $fffe-f and $ff0b). Never wait 10-20-100 raster lines in the interrupt. Don't forget: when your interrupt runs, the main program is suspended. Spending several 10s percent CPU time in interrupt only to wait for raster position is not recommended.

Posted By

Mad
on 2018-04-24
11:43:53
 Re: IRQ Interrupt examples

Seems to be ok to me! A hard "bug" I encountered several times, was to set $ff07 without the $80 bit. Without it you just have the lower 128 characters accessible. I don't know what's happening at your setup but the lines you posted are Ok from a first view, I am at work and cannot test them here.

Waiting for rasterlines in gerneral is no good idea, except if you wait for the vsync to change a frame, but even there it is better to use Irqs and perhaps a tripple instead of a double buffer. If you use Irqs be aware that NTSC has a lot less rasterlines than Pal machines. If you use Irqs you can do much of the other stuff you need in the mean time instead of waiting for a rasterline and blocking all the CPU for that.

And it's always a good idea to preserve the $40 bit of $ff07 since it will "fuckup" NTSC machines if changed to the startup state.

I hope you get your bug fixed. All the best!

edit: Ah Kichy answered already, too! :)

Posted By

carrion
on 2018-04-24
12:11:47
 Re: IRQ Interrupt examples

I think I partially solved it...
I've added
lda #$00
sta $ff12

I've seen it in some demo or game I disassembled to see how they do it wink
I don't understand it yet, I don't know what's exactly is going on and I need to study the .xls mem map by SVS more to get it right. For now it works so I can progress with my little proof-of-concept program. maybe to unveil soon wink

so be prepared for more questions like this.

Posted By

gerliczer
on 2018-04-24
13:18:04
 Re: IRQ Interrupt examples

That seems to be like forgetting to set up TED to properly take charset data from RAM instead of ROM, or at least that's what my hazy memory points at after seeing you zeroing $FF12. Was your issue the displayed characters being a constantly changing garbled mass?

Posted By

carrion
on 2018-04-24
15:15:35
 Re: IRQ Interrupt examples

@gerliczer
you're right . that was exactly what I was seeing. a garbaged constantly changed full screen of chars.

Posted By

gerliczer
on 2018-04-24
23:59:23
 Re: IRQ Interrupt examples

Well, you could have described the issue earlier. bubis, KiCHY and Mad would have given you the explanation of the problem and its solution much sooner, without you having to decipher it from SVS's excellent information collection.

Posted By

carrion
on 2018-04-26
16:48:47
 Re: IRQ Interrupt examples

Guys
as you probably figured it out I started to work on a small game port from Atari.
The game looks like easy to code but I think right now the biggest challange for me is to do a smooth scrolling in 4 directions (left/ right, up/down)
the screen is divided for game part itself and the info (points, lines, collectables) part.
I can do a smooth horizontal scroll now using $FF07
but the challange is to do vertical scroll with $FF06 but still having a screen splitted for both parts of the game screen. I know its a classic thing on C64 (and described on codebase64.org) but I haven't seen it on C+4 yet. Is it even possible? are there any games utilizing this concept? Where should I start? I want to look how other did it before asking more detailed questions.
Please advice and help me here if possible.
TIA

Posted By

Mad
on 2018-04-26
22:49:29
 Re: IRQ Interrupt examples

Hello Carrion,

You can take a look into this thread: http://plus4world.powweb.com/forum/35837

Apparently it is possible. We even did it in Pets Rescue. But there are different ways to achieve this. Hope the descriptions in this relatively fresh thread can help you. I had some trouble to implement two independent moving planes. I hope this can all be found in the thread above. Perhaps other people have some more help or codeexamples for you!

If you don't want this rastertrickery (which would be the best option to use) you can also just place 2 characters one over the other for the numbers below your playfield. And scroll the chars by a character animation (8 frames). But this is !NO! pro tip! :) You even would have to cut the screen above by replacing for instance the complete charset by an empty one on the right line, which is mostly a no go at least for me.

Hope the thread above helps! All the best..




Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024