Jump to content
IGNORED

Karris template with own game -- setcollisiondetection(1) freeze


Bochum_Boy

Recommended Posts

Dear all,

 

for my Bentley Bear project I switched to karris card template. But whenever I use tgi_setcollisiondetection(1) in the resident.c or game.c my Lynx freezes without loading the main game. Setting tgi_setcollisiondetection(0) makes the game run again, but I need the collision detection. Any ideas?

 

Here is main main(void) from resident.c:

int main(void)
{
    tgi_install(&tgi_static_stddrv);
    tgi_install(&lynx_160_102_16);
    tgi_setcollisiondetection(0);
    
    tgi_init();
    joy_install(&joy_static_stddrv);
    lynx_snd_init();
    CLI();
    


    lynx_load((int)&TUNE0_FILENR);
#if 0
    lynx_snd_pause();
    lynx_snd_play(0, musicptr.music0);
    lynx_snd_play(1, musicptr.music1);
    lynx_snd_play(2, musicptr.music2);
    lynx_snd_play(3, musicptr.music3);
    lynx_snd_continue();
#endif


    while (1) {
        lynx_load((int)&INTRO_FILENR);
        intro();
        
        lynx_load((int)&GAME_FILENR);
        tgi_setcollisiondetection(1);
        game();
    }
    return 0;
}

 

Link to comment
Share on other sites

Dear all,

 

for my Bentley Bear project I switched to karris card template. But whenever I use tgi_setcollisiondetection(1) in the resident.c or game.c my Lynx freezes without loading the main game. Setting tgi_setcollisiondetection(0) makes the game run again, but I need the collision detection. Any ideas?

 

Here is main main(void) from resident.c:

int main(void)
{
    tgi_install(&tgi_static_stddrv);
    tgi_install(&lynx_160_102_16);
    tgi_setcollisiondetection(0);
    
    tgi_init();
    joy_install(&joy_static_stddrv);
    lynx_snd_init();
    CLI();
    


    lynx_load((int)&TUNE0_FILENR);
#if 0
    lynx_snd_pause();
    lynx_snd_play(0, musicptr.music0);
    lynx_snd_play(1, musicptr.music1);
    lynx_snd_play(2, musicptr.music2);
    lynx_snd_play(3, musicptr.music3);
    lynx_snd_continue();
#endif


    while (1) {
        lynx_load((int)&INTRO_FILENR);
        intro();
        
        lynx_load((int)&GAME_FILENR);
        tgi_setcollisiondetection(1);
        game();
    }
    return 0;
}

 

 

The first problem is that you initialize the screen through two drivers. Please remove the line tgi_install(&lynx_160_102_16);

 

Have you told the linker that you need space for the collision buffer?

RAM: file = %O, define = yes, start = $0200, size = $9E58 - __STACKSIZE__;

Link to comment
Share on other sites

 

The first problem is that you initialize the screen through two drivers. Please remove the line tgi_install(&lynx_160_102_16);

 

Have you told the linker that you need space for the collision buffer?

RAM: file = %O, define = yes, start = $0200, size = $9E58 - __STACKSIZE__;

 

Thanks Karri, I removed the second driver. I tried to add the RAM line to lynx.cfg but it threw me an error with illegal code. I attached my current lynx.cfg:

SYMBOLS {
    __BLOCKSIZE__: value = 1024, type = export; # 1024 bytes / block
    __BOOTLDR__: type = import;
    __HEADERSIZE__: value = 64, type = export;
    __STARTOFDIRECTORY__: value = $CB, type = export;
    __DIRECTORYSIZE__: value = 5*8, type = export;
    __MEMORY_TOP__: value = $fff8, type = export;
    # Screen is just below the top vectors
    __SCREEN_SIZE__: value = 8160, type = export;
    __MEMORY_SCREEN1__: value = __MEMORY_TOP__ - __SCREEN_SIZE__, type = export;
    __MEMORY_SCREEN0__: value = __MEMORY_SCREEN1__ - __SCREEN_SIZE__, type = export;
    # Under the screen we put the C-stack
    __STACKSIZE__: value = $800, type = export; # 2K stack
    __MEMORY_STACK__: value = __MEMORY_SCREEN0__ - __STACKSIZE__, type = export;
    # Under the stack we must put the resident RAM segment
    __RAM_RESIDENT_SIZE__: value = $3000, type = export;
    __MEMORY_RAM__: value = __MEMORY_STACK__ - __RAM_RESIDENT_SIZE__, type = export;
    # Under the resident code we place the tunes
    __TUNES_SIZE__: value = $11dc, type = export;
    __MEMORY_TUNES__: value = __MEMORY_RAM__ - __TUNES_SIZE__, type = export;
    # Modules start adress
    __MEMORY_MODULES__: value = $0200, type = export;
    __MODULES_SIZE__: value = __MEMORY_TUNES__ - __MEMORY_MODULES__, type = export;
}
MEMORY {
    ZP: start = 0, size = $0100, type = rw, define = yes;
    HEADER: start = $0, size = __HEADERSIZE__, file = %O;
    BOOT: start = $0, size = __STARTOFDIRECTORY__, file = %O;
    DIR: start = $0, size = __DIRECTORYSIZE__, file = %O;
    RAM: start = __MEMORY_RAM__, size = __RAM_RESIDENT_SIZE__, define = yes, file = %O;
    INTRO: start = __MEMORY_MODULES__, size = __MODULES_SIZE__, define = yes, file = %O;
    GAME: start = __MEMORY_MODULES__, size = __MODULES_SIZE__, define = yes, file = %O;
    TUNE: start = __MEMORY_TUNES__, size = __TUNES_SIZE__, define = yes, file = %O;
}
SEGMENTS {
    # The cart.lnx _must_ be built in the order set here!!!

    # lnx header
    EXEHDR: load = HEADER, type = rw, define = yes;
    # encrypted  + secondary bootloader
    BOOTLDR: load = BOOT, type = rw, define = yes;
    # cart directory
    DIRECTORY: load = DIR, type = rw, define = yes;

    # resident code that stays in memory always
    STARTUP: load = RAM, type = ro, define = yes;
    LOWCODE: load = RAM, type = ro, define = yes, optional = yes;
    INIT: load = RAM, type = ro, define = yes, optional = yes;
    CODE: load = RAM, type = ro, define = yes;
    RODATA: load = RAM, type = ro, define = yes;
    DATA: load = RAM, type = rw, define = yes;
    BSS: load = RAM, type = bss, define = yes;
    ZEROPAGE: load = ZP, type = zp;
    EXTZP: load = ZP, type = zp;
    APPZP: load = ZP, type = zp;

    # Intro module
    INTRO_CODE: load = INTRO, type = ro, define = yes;
    INTRO_RODATA: load = INTRO, type = ro, define = yes;
    INTRO_DATA: load = INTRO, type = rw, define = yes;
    INTRO_BSS: load = INTRO, type = bss, optional = yes;

    # The game
    GAME_CODE: load = GAME, type = ro, define = yes;
    GAME_RODATA: load = GAME, type = ro, define = yes;
    GAME_DATA: load = GAME, type = rw, define = yes;
    GAME_BSS: load = GAME, type = bss, optional = yes;
    
     # Tunes
    TUNE0_RODATA: load = TUNE, type = rw, define = yes;
}
FEATURES {
    CONDES: segment = RODATA,
	    type = constructor,
	    label = __CONSTRUCTOR_TABLE__,
	    count = __CONSTRUCTOR_COUNT__;
    CONDES: segment = RODATA,
	    type = destructor,
	    label = __DESTRUCTOR_TABLE__,
	    count = __DESTRUCTOR_COUNT__;
    CONDES: segment = DATA,
	    type = interruptor,
	    label = __INTERRUPTOR_TABLE__,
	    count = __INTERRUPTOR_COUNT__;
}

Edited by Bochum_Boy
Link to comment
Share on other sites

Yep. That is the problem.

 

You have one screen buffer for display.

One screen buffer for drawing.

You lack one screen buffer for collisions.

 

Add:

__MEMORY_SCREENCOLLISION__: value = __MEMORY_SCREEN0__ - __SCREEN_SIZE__, type = export;

 

Then change:

__MEMORY_STACK__: value = __MEMORY_SCREENCOLLISION__ - __STACKSIZE__, type = export;

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...