• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Other] Rounding Error in Assembly - Odd Number of Colored Types in TCG

  • 81
    Posts
    9
    Years
    • She/her/hers
    • Seen Oct 26, 2023
    Hello!

    I'm trying to add the Dark type to the TCG game using the TCG Disassembly.

    Everything seems to be working with one exception: Dark type energy requirements are being treated as colorless energy requirements.

    The problem is in src/engine/duel/core.asm, under _CheckIfEnoughEnergiesToAttack:.
    Spoiler:

    It's ld c, (NUM_COLORED_TYPES) / 2 under .got_atk.

    Normally there are 6 colored types, but in src/constants/card_data_constants.asm I changed it to 7. I think that 7 / 2 is being rounded down from 3.5 to 3, which is causing Dark to function as a colorless type. I tried replacing NUM_COLORED_TYPES with 8 so that the calc would result in 4, and that made both Dark and Colorless function as colored types. I want Dark to function as a colored type and Colorless to function as a colorless type.

    So I'm pretty sure that I need (NUM_COLORED_TYPES) / 2 to equal 3.5, but because of rounding it can only equal either 3 or 4.

    I am fairly unfamiliar with assembly as a language. Is there a way to prevent or bypass this rounding issue?

    My edited files can be found here. There is a save file that can be used for testing. Thanks.
     
    Hello!

    I'm trying to add the Dark type to the TCG game using the TCG Disassembly.

    Everything seems to be working with one exception: Dark type energy requirements are being treated as colorless energy requirements.

    The problem is in src/engine/duel/core.asm, under _CheckIfEnoughEnergiesToAttack:.
    Spoiler:

    It's ld c, (NUM_COLORED_TYPES) / 2 under .got_atk.

    Normally there are 6 colored types, but in src/constants/card_data_constants.asm I changed it to 7. I think that 7 / 2 is being rounded down from 3.5 to 3, which is causing Dark to function as a colorless type. I tried replacing NUM_COLORED_TYPES with 8 so that the calc would result in 4, and that made both Dark and Colorless function as colored types. I want Dark to function as a colored type and Colorless to function as a colorless type.

    So I'm pretty sure that I need (NUM_COLORED_TYPES) / 2 to equal 3.5, but because of rounding it can only equal either 3 or 4.

    I am fairly unfamiliar with assembly as a language. Is there a way to prevent or bypass this rounding issue?

    My edited files can be found here. There is a save file that can be used for testing. Thanks.

    The Gameboy's CPU doesn't support floating point numbers or division. The division you're seeing is syntactic sugar provided by the assembler. In the compiled ROM the value has to be either 3 or 4. You can find out more about the assembler's capabilities in its documentation.

    At a glance it seems like the code is looping through the "colored" types two at a time and calling "CheckIfEnoughEnergiesOfType" for each type. If that's the case, you could probably let the loop run 3 times and add a new check for your new type after the loop.
     
    The Gameboy's CPU doesn't support floating point numbers or division. The division you're seeing is syntactic sugar provided by the assembler. In the compiled ROM the value has to be either 3 or 4. You can find out more about the assembler's capabilities in its documentation.

    At a glance it seems like the code is looping through the "colored" types two at a time and calling "CheckIfEnoughEnergiesOfType" for each type. If that's the case, you could probably let the loop run 3 times and add a new check for your new type after the loop.

    I see. Thank you very much for the information! :)
     
    The Gameboy's CPU doesn't support floating point numbers or division. The division you're seeing is syntactic sugar provided by the assembler. In the compiled ROM the value has to be either 3 or 4. You can find out more about the assembler's capabilities in its documentation.

    At a glance it seems like the code is looping through the "colored" types two at a time and calling "CheckIfEnoughEnergiesOfType" for each type. If that's the case, you could probably let the loop run 3 times and add a new check for your new type after the loop.

    It works! I added the stuff in bold.

    Spoiler:


    Thanks again for the help!
     
    Back
    Top