cc65: [bug?][pce] I get a broken binary if I build for the PCE target but OK on all other targets

If I build my new game Cross Horde with make pce -f Makefile.horde with my Cross-Lib tool-chain (https://github.com/Fabrizio-Caruso/CROSS-LIB), I get a broken game with the PCE target only, where it works fine on all other cc65 targets and other compilers (sdcc, gcc, etc.).

REMARK: I get this problem ONLY with -Or. It seems really PCE -related.

I have not managed to isolate it but the part of the code that seems broken is either:

                item->_effect();
                _XL_PING_SOUND();
                item->_active=0;

where it seems that _effect() is called but _active is not set to 0. or the check on item->_active.

This is the complete function

void handle_item(register Item* item)
{
    if(item->_active)
    {
        if(item->_y<BOW_Y)
        {
            _XL_DELETE(item->_x,item->_y);
            if(main_loop_counter&1)
            {
                ++(item->_y);
            }
            _XL_DRAW(item->_x,item->_y,item->_tile,item->_color);
        }
        else //((item->_y==BOW_Y)) //  && (item->_counter)
        {
            if(item->_counter&1)
            {
                _XL_DELETE(item->_x,item->_y);
            }
            else
            {
                _XL_DRAW(item->_x,item->_y,item->_tile,item->_color);
            }
 
            if(item->_x==(bow_x/2)+(bow_x&1))
            {
                item->_effect();
                _XL_PING_SOUND();
                item->_active=0;
            }
            display_bow();
            --(item->_counter);
            if(!(item->_counter))
            {
                item->_active=0;
            }
        }
    }   
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (21 by maintainers)

Most upvoted comments

OK. Now you can use -Or in makefile PCE recipes.

Oh yeah, the zeropage is kindof “special” in PCE. I dont remember the details, but i remember the default mapping does no more map it to $0000 for some reason (which, i guess, is what creates the problems you are seeing then).