Hi, now I have read trough your 4800 lines of code and have seen multible things which are handled completely different than in my user subroutine which is posted here:
topics/171604-user-subroutine-with-neobitz-c-dev-kit-datlibPlease check out the instructions HPMAN has posted there, the first thing you need to do is to change the ASM code in your "common_crt0_cart.s" and "crt0_cart.s" file and run the main loop as "void USER(void)".
Also, I would suggest to separate your game code for the user subroutine and handle both independently. The subroutine is a quite complicated thing, maybe it would be easier to create a smaller test project first before starting to integrate it in your game.