News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

cpctelera interrupts and colours

Started by luckpro, 22:34, 03 September 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

luckpro

Hello everyone, I continue with my first game with cpctelera 1.4.2 but I am having some problem with the interrupts.


I change palette in each interrupt to get more than 4 colours in mode 1, and also to debug in the rest of the code I am using some setBorder with diferents colours.

Everything works correctly, but sometimes it happens that setBorder or setPalette does not receive the color that it sent and it is painted black (incorrect colour i supose).  :doh:  In case of setPalette only change the 0 pen with black.

It does not always happen and that is why I am not able to debug it with winape.  :'(

I think it could be happening that while the setBorder is running call the interrupt and crossing the information sends to the crtc.  :-\

Is this possible to happen?

Any suggestions?

Thanks in advance.

pelrun

Yes, what you are seeing is the interrupt happening while you are already in the middle of changing the palette. Welcome to the world of concurrent programming!


Make sure you disable interrupts around any setPalette calls you are doing in the main program.

luckpro

ou yeah!, I thought I was crazy.


I can not turn off the interrupts because logic of the game, but anyway setBorder will remove them at the end and they will not give me problems, they are only to debug times.


Thanks a lot.

pelrun

No, I mean you disable them (with DI) before the setPalette call and re-enable them (with EI) immediately afterwards. You only need to disable the interrupts during the critical section.

luckpro

I need all interrupts calls, i can not skip any, but no problem, i eliminate all setBorder calls and works without problem. Thank you.

pelrun

If an interrupt is raised while they're disabled, it's not skipped, just postponed until interrupts are re-enabled.

Powered by SMFPacks Menu Editor Mod