News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

using both interrupts and firmware

Started by Xifos, 11:08, 28 March 13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Xifos

Hi,

I am trying to use the 6 fixed interrupts to just change the background color.
I am using sdcc, but i wrote an asm function to do that.
I put a jp myfunction at 038h, di at the beginning, and  at the end of my function, i am jumping at B942h (winape as 6128).
In this function i am trying to change the color folowing a counter.

Here's my algorithm :
di
save registers on stack
test if vbl is set
if vbl counter set it as 0
test counter, set color
inc counter
restore registers
jp B942h
ret

Everything works fine, colors are changed at the right time.
But if i do a firmware call in the main program, for exemple a keyboard vector call (call BB1Eh), it goes wrong, as if the counter was lost.

I know it's not good to use firmware, but in that case i would like to undertsand what's happening.
Are there just 6 interrupts per vbl doing rst 038h, or can there be more ?

I know i'am not good at using interrupts neither at writing in english ! :(

AMSDOS

Think you'll need to Enable Interrupts before using the Firmware.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

arnoldemu

don't fight the firmware.

try something like this:



typedef  void (*ticker_fn)(void);

void InstallFastTicker(void *pDataBlock, ticker_fn fn)
{
    __asm
        ld hl,#_pDataBlock ;; block
        ld b,#0x080        ;; class
        ld c,#0x0ff        ;; rom select
        ld de,#_fn        ;; function
        call 0x0bce3    ;;kl_new_fast_ticker
    __endasm
}

void DelFastTicker(void *pDataBlock)
{
    __asm
    {
        ld hl,#_pDataBlock
        call 0x0bce6    ;;kl_del_fast_ticker
    }
}

void MyFastTicker()
{
    // here...

}


// not sure of the size of the block
unsigned char MyFastTickerBlock[32];

void main()
{
    InstallFastTicker(MyFastTickerBlock, MyFastTicker);
}



Code is not tested!!
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Xifos

Thanks for the replies.
:)

> AMSDOS
You 're saying , put ei before the part where i jump to B941 ?
no changes
The fact is that everything works fine if i don't use system vectors !

>Arnoldemu
When doing this, does not my routine need to be between 4000h and c000h ?
I'am not good at doing relocatable code ! (i know i know)
:(

But i'll try, probably this week end...

arnoldemu

Yes probably between 4000 and 8000. It may work from Rom but the kernel b l rock must be in ram. Try it.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

AMSDOS

Quote from: Xifos on 19:34, 28 March 13
Thanks for the replies.
:)

> AMSDOS
You 're saying , put ei before the part where i jump to B941 ?
no changes
The fact is that everything works fine if i don't use system vectors !


Hmmm, yes, I think this maybe a bit out of my league.  :(  My feeling was you cannot use Firmware routines like &BB1E while Interrupts are disabled.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Xifos

I finally did it, following Arnoldemu's way.
And after seeing this : source/intpos.asm

One thing is that i have to forget trying to detect if i'm in the vbl interrupt or no.
I am just reseting the counter after 5.
The other annoying thing is that the fast ticker routine and it's block have to be between 4000 and 8000.
And i don't understand what exactly means this part :
ld b,#0x080        ;; class
ld c,#0x0ff        ;; rom select

The good things is that that's working, even with firmware routines calls, even without vbl synchro in the main program, but i find that the interrupts locations are not equal.

Thanks for your help !!!  :)

arnoldemu

Quote from: Xifos on 16:08, 29 March 13
I finally did it, following Arnoldemu's way.
And after seeing this : source/intpos.asm

One thing is that i have to forget trying to detect if i'm in the vbl interrupt or no.
I am just reseting the counter after 5.
The other annoying thing is that the fast ticker routine and it's block have to be between 4000 and 8000.
And i don't understand what exactly means this part :
ld b,#0x080        ;; class
ld c,#0x0ff        ;; rom select

The good things is that that's working, even with firmware routines calls, even without vbl synchro in the main program, but i find that the interrupts locations are not equal.

Thanks for your help !!!  :)

The class and Rom select are described in the soft968 manual.
In this programming part of the forum I posted some assembly code which gives exact interrupt position for mode and colour splits. I use a special type of fast ticker firmware interrupt to make this. I had to disassemble the Cpc firmware to discover the way to do this.

When I have time I will post a full c example of the code I gave in my post above.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Xifos

Ah, i understand now.
:)
I could put my fast ticker routine at a far address, but it seems that the fast ticker block must stay between 4000 and c000.
The locations of the code relative to the interrupts are better now.
(i am a good student, isn'it ?)


Powered by SMFPacks Menu Editor Mod