Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
T9000 HL reg issue
#1
While debugging my game, I found 1 strange issue.


I had a method to print an integer which starts like this :

Code:
void VDP_printInteger(u8 planeId, u8 xpos, u8 ypos, u8 palId, u16 number, u8 length, u8 leading){
    u16 *vramAddr = SCROLL_PLANE_1; 

looking at the code produced, it sets HL to 0x9000, nothing wrong here

later on my game, I do a collide test

Code:
unsigned char testCollide( ){
if (collide)
    return1

return 0;
}

this will produce a LD L,1
nothing wrong here too


my problem is with this code

Code:
if (testCollide( ) == 1)
{
     doSomething();
}

it will produce a CP HL, 1
not a CP L, 1

if I call VDP_printInteger BEFORE testCollide, HL = 9001, and so the test is "wrong"


I solved the issue using adecl, to force cleaner use of register XWA, XBC, XDE and XHL.  but  what should be done to avoid that ?!
Unless using adecl on every function using HL (sic!), I see no way to avoid this.....

what is even worst is that another similar test, with same return type
if ( testCollideNPC() == 1)
works like a charm! 

I found a "fix" but I didn't find the reason so if anyone had an idea, let me know Smile

Note: I'm actually trying to export the asm of every C file, to see where the problem happens on other methods but -la doesn't since to work.....
Reply


Messages In This Thread
T9000 HL reg issue - by KanedaFr - 07-07-2025, 08:47 PM
RE: T9000 HL reg issue - by KanedaFr - 07-07-2025, 09:12 PM
RE: T9000 HL reg issue - by KanedaFr - 07-07-2025, 09:25 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)