Jump to content

Bug hunting


Recommended Posts

Coding for the Jaguar is a nightmare... Ok, let's go to the topic and see if someone spot what I'm doing wrong.


I've a something like a filesystem to get the assets from the ROM, (sounds, graphics or anything else), then I upload the game code to the skunk board (default address $4000) and play/test the game.


Now I've the assets of three games burned together into the ROM, I upload the code of each game and it works.


I've coded the menu to select a game and launch it, the code copy a small code at the end of the ram and run it, this small code copy the game to $4000 and jumps there. Now comes the funny thing.


Game 1 works

Game 2 you can see the menu, but it hangs when it shows the intro scene

Game 3 you hear the music but no image, sometimes it runs but with glitches and I doesn't read very well the joypad (I've to press fire several times to start the game)


Even if I call run_game at the start of the code it doesn't work. It looks like the Jaguar can't be initalizated two times, one for the menu, the other at the start of each game.


I've no idea why this doesn't work.


LOAD_ADDRESS    .equ 2*1024*1024-64		; end of ram

;_run_game(const void *begin, const void *end)
    move.w #$2700,sr
    move.w #$7fff,VI          ; VI

    lea _copy_run,a0
    move.l #LOAD_ADDRESS,a1
    move.w #(_end_copy_run-_copy_run)/2-1,d7
    move.w (a0)+,(a1)+
    dbf d7,.loop
    move.l 4(sp),a0
    move.l 8(sp),a1

    move.l #$4000,a2
    move.w (a0),$f00058         ; BG
    move.l (a0)+,(a2)+
    cmp.l a0,a1
    bge.s .loop

    jmp $4000.w


Link to comment
Share on other sites

    move.l 4(sp),a0
    move.l 8(sp),a1

If the stack pointer is located at the end of RAM, at that point the values on the stack may have been overwritten by the code you've copied there. Load the values from the stack before copying.


Also, check the operator priority there:

    move.w #(_end_copy_run-_copy_run)/2-1,d7

Is it evaluated as ((_end_copy_run-_copy_run)/2)-1, or (_end_copy_run-_copy_run)/(2-1)?




Edited by Zerosquare
Link to comment
Share on other sites

The stack pointer is located at $4000-4 in all games.


I think that the problem is somewhere in the init code, because the games boot but sometimes it hangs or have a lot of graphics glitches (some black horizontal lines).


I'm going to copy the init code and call it into the main function.


Link to comment
Share on other sites

2 hours ago, Zerosquare said:

I don't mean the stack pointer in the game, I mean the stack pointer in your menu code.

It's also at $4000-4


I've found the following.


This is part of the menu of BurgerTom, I've included all the DPRINT to see where it hangs. If I upload the code to the skunk if works and I get a lot of text messages BUT if I load the menu that just execute the copy_run code I don't get the "new strip" message.


WTF!?! It's defined and initialized to 0, why it doesn't work when I copy the code at $4000? _text_strip must be somewhere in the data segment and it must be part of the binary code that I upload.


static SPRITE_STRIP *_text_strip = NULL;

void init_text()

	if ( _text_strip == NULL )
		DPRINT("new strip\n");
    	_text_strip = new_strip(256, 224, 0);

	DPRINT("clear strip\n");
	DPRINT("clear strip done\n");

    _text_metadata.offset = 0;
	_text_metadata.width = 4;
	_text_metadata.hx = 0;
    _text_metadata.hy = 0;

Looking at the .map file...  it's into the bss? ?


                0x00000000000357fc       0x18
                0x00000000000357fc       0x18 obj/menu.o

                0x0000000000035818        0x4
                0x0000000000035818        0x4 obj/menu.o

                0x000000000003581c       0x20
                0x000000000003581c       0x20 obj/menu.o


Edited by swapd0
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.

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.

  • Recently Browsing   0 members

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