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..


Posted By

carrion
on 2024-08-05
07:51:11
 Re: IRQ Interrupt examples

Hi Guys!
Digging out an old thread, as I'm slowly back to do some coding on C+4. I go through my old code trying to understand how things work on C+4. So my first question is about line #0 on the screen
I start irq at line 0 but looks like line #0 is where the visible screen starts and not like on c64 line 0 is somwhere on top border.
Do I do something wrong or line 0 is on the start of visible area on C+4?

more questions on the way wink

Posted By

Csabo
on 2024-08-05
09:03:15
 Re: IRQ Interrupt examples

The first visible line on the screen is 4 ($04), the last one is 4+199 = 203 ($CB).

Posted By

carrion
on 2024-08-05
10:05:45
 Re: IRQ Interrupt examples

OK Thanks
But what about the other lines? how many lines is there in overall?
can I start my irq in line 210? 256?

Posted By

gerliczer
on 2024-08-05
11:15:09
 Re: IRQ Interrupt examples

312 lines in PAL, 262 lines in NTSC systems. As per usual in Commodore 8 bit machines. You can trigger your IRQ in any line you wish.

Posted By

carrion
on 2024-08-06
07:37:51
 Re: IRQ Interrupt examples

Thanks @gerliczer
And sorry for another probably lame questions:
1. how can I see all RAM? something equivalent to #$35 -> $01 on C64?
2. How much RAM can I address then? Is it possible to use from $0800 - $ff00 ?
EDIT:and one more thing
3. can I place characterset, screens and colormaps data everywhere in the memory or are there banks line in VIC-II ?
4. Can I have screen, colors in 0800 and 0c00 and characterset in $6000? I probably do soemthing wrong because it doesnt work for me this way.
anyway TIA

Posted By

Csabo
on 2024-08-06
08:32:17
 Re: IRQ Interrupt examples

1. STA $FF3F banks in RAM. (The "opposite" is STA $FF3E, which banks in ROM - default).
2. Regardless of what's banked in, you can always address the full 64K memory happy ($0000-$FFFF) When ROM is banked in, $8000-$FCFF will be read only.
3. Yes, screens and charsets can go anywhere (on $0800 boundaries, so $6000 is possible, $6100 is not).
4. Not 100% sure what you're asking, but you can have either screen or charset on $6000, or even both.

Posted By

gerliczer
on 2024-08-06
09:54:05
 Re: IRQ Interrupt examples

Some additions. When you page out ROM, memory above the TED register area is also usable, although it is not much. Similarly, the unused bytes in the register area can be used too, but that is even less. To put char.gen. or bitmap into RAM, you have to clear register $FF12, bit 2. Char.gen. can be $400 aligned, but only if it is 128 characters long ($FF07, bit 7 = 0).

And finally, get Ultimate Map. Answers to every questions you asked can most probably be found in it.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon