• 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.

[SOLVED] make returns error "cannot decrease the current addres"

  • 2
    Posts
    337
    Days
    • Seen Jun 24, 2024
    TL;DR: the make command prints the error message "error: layout.link(38): Cannot decrease the current address (from $... to $...)" and I currently have zero understanding of this error.

    I use the pokered-gbc as a base and try to incorporate some quality of life enhancements from other rom hacks. Some of these attempts lead to the make command returning an error that I do not understand. The latest example of this happened when I tried to port the HM-auto-use feature (use an HM simply by pressing Select, if applicable) from shin pokered. Here's what I tried:
    1. I added the folder "custom_functions" to the root folder of the pokered-gbc disassembly, since that did not have it already.
    2. I copied "func_overworld.asm" from shin pokered into that folder. I did not edit this file, except for removing the surf-board check when trying to use SURF, since my romhack does not have that item.
    3. I INCLUDED the file in "main.asm". I deliberately put it into a bank where it would not fit at first and make complained that there was not enough space ("would overflow ROMX..."). I changed it to a different bank and that error disappeared, so I am quite confident that there is enough space in the bank.
    4. I changed "OverworldLoopLessDelay::" in "overworld.asm" to use the new function: FROM

    ; if A is pressed
    ld a, [wd730]
    bit 2, a
    jp nz, .noDirectionButtonsPressed
    call IsPlayerCharacterBeingControlledByGame
    jr nz, .checkForOpponent
    call CheckForHiddenObjectOrBookshelfOrCardKeyDoor
    ...

    TO

    ; if A or SELECT is pressed
    .AorSelectPressed
    ld a, [wd730]
    bit 2, a ;check if input is being ignored
    jp nz, .noDirectionButtonsPressed
    call IsPlayerCharacterBeingControlledByGame
    jr nz, .checkForOpponent
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;joenote - for smart HM use
    ld a, [hJoyPressed]
    bit 2, a ;is Select being pressed?
    jr z, .notselect
    callba CheckForSmartHMuse ;this function jumps back to OverworldLoop on completion
    jp OverworldLoop
    .notselect
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    call CheckForHiddenObjectOrBookshelfOrCardKeyDoor
    ...

    When I now run the make command, I get "error: layout.link(38): Cannot decrease the current address (from $1671 to $1665) Linking failed with 1 error". The error disappears if I comment out the three lines before ".notselect" and reappears if I then uncomment any of those three.

    My main problem is that I do not understand what exactly the error is. I know what an address is, and what decreasing it means, but I see neither what address is decreased here (well, $1671, but I mean from a semantic point of view), nor do I see why it has to happen or why it is impossible. I could not find any pointers to this error message on the internet. Can someone here explain what the problem is? I think if I got a rough understanding I could work on finding a solution from there.

    Cheers
    aloha
     
    TL;DR: the make command prints the error message "error: layout.link(38): Cannot decrease the current address (from $... to $...)" and I currently have zero understanding of this error.

    I use the pokered-gbc as a base and try to incorporate some quality of life enhancements from other rom hacks. Some of these attempts lead to the make command returning an error that I do not understand. The latest example of this happened when I tried to port the HM-auto-use feature (use an HM simply by pressing Select, if applicable) from shin pokered. Here's what I tried:
    1. I added the folder "custom_functions" to the root folder of the pokered-gbc disassembly, since that did not have it already.
    2. I copied "func_overworld.asm" from shin pokered into that folder. I did not edit this file, except for removing the surf-board check when trying to use SURF, since my romhack does not have that item.
    3. I INCLUDED the file in "main.asm". I deliberately put it into a bank where it would not fit at first and make complained that there was not enough space ("would overflow ROMX..."). I changed it to a different bank and that error disappeared, so I am quite confident that there is enough space in the bank.
    4. I changed "OverworldLoopLessDelay::" in "overworld.asm" to use the new function: FROM

    ; if A is pressed
    ld a, [wd730]
    bit 2, a
    jp nz, .noDirectionButtonsPressed
    call IsPlayerCharacterBeingControlledByGame
    jr nz, .checkForOpponent
    call CheckForHiddenObjectOrBookshelfOrCardKeyDoor
    ...

    TO

    ; if A or SELECT is pressed
    .AorSelectPressed
    ld a, [wd730]
    bit 2, a ;check if input is being ignored
    jp nz, .noDirectionButtonsPressed
    call IsPlayerCharacterBeingControlledByGame
    jr nz, .checkForOpponent
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;joenote - for smart HM use
    ld a, [hJoyPressed]
    bit 2, a ;is Select being pressed?
    jr z, .notselect
    callba CheckForSmartHMuse ;this function jumps back to OverworldLoop on completion
    jp OverworldLoop
    .notselect
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    call CheckForHiddenObjectOrBookshelfOrCardKeyDoor
    ...

    When I now run the make command, I get "error: layout.link(38): Cannot decrease the current address (from $1671 to $1665) Linking failed with 1 error". The error disappears if I comment out the three lines before ".notselect" and reappears if I then uncomment any of those three.

    My main problem is that I do not understand what exactly the error is. I know what an address is, and what decreasing it means, but I see neither what address is decreased here (well, $1671, but I mean from a semantic point of view), nor do I see why it has to happen or why it is impossible. I could not find any pointers to this error message on the internet. Can someone here explain what the problem is? I think if I got a rough understanding I could work on finding a solution from there.

    Cheers
    aloha
    Your error says that the problem is on line 38 of layout.link which contains
    Code:
    org $1665
    The documentation for RGBDS says that
    'ORG addr' sets the "current address" to addr. This directive cannot be used to move the address backwards: addr must be greater than or equal to the "current address".

    The problem is that your changes have made the previous "Home" section larger and the end of that section is now at $1671 which causes the org directive to attempt to move the address backwards.
     
    Back
    Top