Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → Hacking Red Questions (Trade evolutions and adding more TMs)

#51 2015-09-18 12:56:31

megamctaco
Member
Registered: 2015-08-23
Post 26/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

I've just added Houndour and Houndoom, and I get an error saying "Unknown Symbol 'UpdateHPBar2Predef'"

Can't find it anywhere though.

Any ideas?

Offline

#52 2015-09-18 20:01:44

comet
Member
Registered: 2012-04-09
Post 604/679

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

The add_predef macro creates that label. So "add_predef UpdateHPBar2" would be missing from engine/predefs.asm, or engine/predefs.asm is missing from the build somehow (more likely).

Offline

#53 2015-09-20 09:41:39

megamctaco
Member
Registered: 2015-08-23
Post 27/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

comet wrote:

The add_predef macro creates that label. So "add_predef UpdateHPBar2" would be missing from engine/predefs.asm.

That was it! Cheers.

I ended up replacing the badge items (3 of them anyway) with stones (Ice, Steel and Fairy) because it seemed easier than adding completely new items, which I was struggling with big time. They work, which is great. However, my bag doesn't tell me the quantity I have and I can't sell them. What do I do there?

Last edited by megamctaco (2015-09-20 09:46:58)

Offline

#54 2015-09-20 15:16:05

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,037/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

You have to edit the data/key_items.asm file. Unless it has been changed since my copy, that file is a bunch of 1s and 0s marking whether an item is a key item or not. So you will need to count until you get to the 1 that matches those items' ID number and change it to a 0, then save the file.

Also, keep in mind that those badge items aren't completely unused. Sure you never obtain them as usable items in the pack, but they are used in the script of this guy in Cerulean City to generate the list of Badges so he can explain what each one does. By editing those items, you'll notice that the man's list will now claim Ice Stone, Steel Stone, and Fairy Stone are badges. In Red++ I decided I didn't care about having badge descriptions but instead changed and expanded his script to explain what all of the berries I added do. But yeah, that's something to keep in mind. You could also just change his script so he is a normal NPC, or presumably edit it to use a normal list instead of an Item List to display badge names.

Offline

#55 2015-09-21 01:14:10

megamctaco
Member
Registered: 2015-08-23
Post 28/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Mateo wrote:

You have to edit the data/key_items.asm file. Unless it has been changed since my copy, that file is a bunch of 1s and 0s marking whether an item is a key item or not. So you will need to count until you get to the 1 that matches those items' ID number and change it to a 0, then save the file.

Cheers! That took some trial and error but I got it.

Mateo wrote:

Also, keep in mind that those badge items aren't completely unused. Sure you never obtain them as usable items in the pack, but they are used in the script of this guy in Cerulean City to generate the list of Badges so he can explain what each one does. By editing those items, you'll notice that the man's list will now claim Ice Stone, Steel Stone, and Fairy Stone are badges. In Red++ I decided I didn't care about having badge descriptions but instead changed and expanded his script to explain what all of the berries I added do. But yeah, that's something to keep in mind. You could also just change his script so he is a normal NPC, or presumably edit it to use a normal list instead of an Item List to display badge names.

Yeah I had to change some badges to the new stones in the Cerulean House to be able to make it. I plan on either making it an information house for Evolution Stones (like you did with berries) or just make it a regular NPC house, with a possible in-game trade.

I'll probably work on that today. Another thing I'd like to do is have Oak's assistant in his lab give me either 5 Pokeballs, or Running Shoes (probably Pokeballs because that would make more sense). Can't seem to find a script for the assistants, however.

Offline

#56 2015-09-21 01:53:25

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,039/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

megamctaco wrote:
Mateo wrote:

You have to edit the data/key_items.asm file. Unless it has been changed since my copy, that file is a bunch of 1s and 0s marking whether an item is a key item or not. So you will need to count until you get to the 1 that matches those items' ID number and change it to a 0, then save the file.

Cheers! That took some trial and error but I got it.

Mateo wrote:

Also, keep in mind that those badge items aren't completely unused. Sure you never obtain them as usable items in the pack, but they are used in the script of this guy in Cerulean City to generate the list of Badges so he can explain what each one does. By editing those items, you'll notice that the man's list will now claim Ice Stone, Steel Stone, and Fairy Stone are badges. In Red++ I decided I didn't care about having badge descriptions but instead changed and expanded his script to explain what all of the berries I added do. But yeah, that's something to keep in mind. You could also just change his script so he is a normal NPC, or presumably edit it to use a normal list instead of an Item List to display badge names.

Yeah I had to change some badges to the new stones in the Cerulean House to be able to make it. I plan on either making it an information house for Evolution Stones (like you did with berries) or just make it a regular NPC house, with a possible in-game trade.

I'll probably work on that today. Another thing I'd like to do is have Oak's assistant in his lab give me either 5 Pokeballs, or Running Shoes (probably Pokeballs because that would make more sense). Can't seem to find a script for the assistants, however.


99.9% of the NPCs in the game don't have a detailed script. You'll notice that they just point to a text structure, but some of them use TX_ASM to load a custom routine making them do something more complex (like the in-game trades or the Badge Man and stuff like that). So you would just need to track down the proper Text entry for his Aid and do that. However, to avoid the hassle of adding even more "triggers" to catch you on the way out and make his Aid walk up to give them to you, it would probably be less of a hassle both to you and the player to just find the part of Oak's script where he gives you the Pokedex and make it so he gives you the 5 Pokeballs while he is at it. That way you aren't stopping the player an extra time and delaying their journey, and it would make sense for Oak to give you Pokeballs and explain their use at the same time he gives you the Pokedex and asks you to fill it up.

Offline

#57 2015-09-21 02:26:05

megamctaco
Member
Registered: 2015-08-23
Post 29/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Mateo wrote:

99.9% of the NPCs in the game don't have a detailed script. You'll notice that they just point to a text structure, but some of them use TX_ASM to load a custom routine making them do something more complex (like the in-game trades or the Badge Man and stuff like that). So you would just need to track down the proper Text entry for his Aid and do that. However, to avoid the hassle of adding even more "triggers" to catch you on the way out and make his Aid walk up to give them to you, it would probably be less of a hassle both to you and the player to just find the part of Oak's script where he gives you the Pokedex and make it so he gives you the 5 Pokeballs while he is at it. That way you aren't stopping the player an extra time and delaying their journey, and it would make sense for Oak to give you Pokeballs and explain their use at the same time he gives you the Pokedex and asks you to fill it up.

Cool, I'll try that out.

Ran into a bit of a problem when changing the script and text for the Cerulean Badge House.

The Fire, Water and Thunder stones work in the script, but the others don't. Also, if listed in correct order (Fire, Water, Thunder etc), the description of the Water Stone is that of the Thunder Stone and vice versa. If I list them incorrectly (which I will post under this), it has the correct description.

scripts/ceruleanhouse2.asm

CeruleanHouse2Script: ; 74e09 (1d:4e09)
    ld a, $1
    ld [wAutoTextBoxDrawingControl], a
    dec a
    ld [wDoNotWaitForButtonPressAfterDisplayingText], a
    ret

CeruleanHouse2TextPointers: ; 74e13 (1d:4e13)
    dw CeruleanHouse2Text1

CeruleanHouse2Text1: ; 74e15 (1d:4e15)
    TX_ASM
    ld hl, CeruleanHouse2Text_74e77
    call PrintText
    xor a
    ld [wCurrentMenuItem], a
    ld [wListScrollOffset], a
.asm_74e23
    ld hl, CeruleanHouse2Text_74e7c
    call PrintText
    ld hl, StoneItemList
    call LoadItemList
    ld hl, wItemList
    ld a, l
    ld [wListPointer], a
    ld a, h
    ld [wListPointer + 1], a
    xor a
    ld [wPrintItemPrices], a
    ld [wMenuItemToSwap], a
    ld a, SPECIALLISTMENU
    ld [wListMenuID], a
    call DisplayListMenuID
    jr c, .asm_74e60
    ld hl, MenuTextPointers
    ld a, [wcf91]
    sub FIRE_STONE
    add a
    ld d, $0
    ld e, a
    add hl, de
    ld a, [hli]
    ld h, [hl]
    ld l, a
    call PrintText
    jr .asm_74e23
.asm_74e60
    xor a
    ld [wListScrollOffset], a
    ld hl, CeruleanHouse2Text_74e81
    call PrintText
    jp TextScriptEnd

StoneItemList: ; 74e6d (1d:4e6d)
    db 9,FIRE_STONE,WATER_STONE,THUNDER_STONE,LEAF_STONE,ICE_STONE,STEEL_STONE,FAIRY_STONE,SUN_STONE,MOON_STONE,$FF

CeruleanHouse2Text_74e77: ; 74e77 (1d:4e77)
    TX_FAR _CeruleanHouse2Text_74e77
    db "@"

CeruleanHouse2Text_74e7c: ; 74e7c (1d:4e7c)
    TX_FAR _CeruleanHouse2Text_74e7c
    db "@"

CeruleanHouse2Text_74e81: ; 74e81 (1d:4e81)
    TX_FAR _CeruleanHouse2Text_74e81
    db "@"

MenuTextPointers:
    dw FireStoneText
    dw ThunderStoneText
    dw WaterStoneText
    dw LeafStoneText
    dw IceStoneText
    dw SteelStoneText
    dw FairyStoneText
    dw SunStoneText
    dw MoonStoneText

FireStoneText:
    TX_FAR _FireStoneText
    db "@"

WaterStoneText: 
    TX_FAR _WaterStoneText
    db "@"

ThunderStoneText:
    TX_FAR _ThunderStoneText
    db "@"

LeafStoneText:
    TX_FAR _LeafStoneText
    db "@"

IceStoneText:
    TX_FAR _IceStoneText
    db "@"

SteelStoneText:
    TX_FAR _SteelStoneText
    db "@"

FairyStoneText:
    TX_FAR _FairyStoneText
    db "@"

SunStoneText:
    TX_FAR _SunStoneText
    db "@"

MoonStoneText:
    TX_FAR _MoonStoneText
    db "@"

text/cerulean_badge_house.asm

_CeruleanHouse2Text_74e77:: ; 990c9 (26:50c9)
    text "Evolution STONEs"
    line "can make certain"
    cont "#MON evolve."

    para "I see you have"
    line "at least one."

    para "Those STONEs have"
    line "mysterious power!"
    prompt

_CeruleanHouse2Text_74e7c:: ; 9913a (26:513a)
    text "Now then..."

    para "Which of the 9"
    line "Stones should I"
    cont "describe?"
    done

_CeruleanHouse2Text_74e81:: ; 99170 (26:5170)
IF DEF(_YELLOW)
    text "Come visit me any-"
ELSE
    text "Come visit me any"
ENDC
    line "time you wish."
    done

_FireStoneText::
    text "Evolves Fire"
    line "type #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "VULPIX."
    prompt

_WaterStoneText::
    text "Evolves Water"
    line "type #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "SHELLDER."
    prompt
    
_ThunderStoneText::
    text "Evolves Thunder"
    line "type #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "PIKACHU."
    prompt

_LeafStoneText::
    text "Evolves Grass"
    line "type #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "GLOOM."
    prompt

_IceStoneText::
    text "Evolves a"
    line "special #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "EEVEE."
    prompt

_SteelStoneText::
    text "Evolves a"
    line "special #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "SCYTHER."
    prompt

_FairyStoneText::
    text "Evolves a"
    line "special #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "EEVEE."
    prompt

_SunStoneText::
    text "Evolves a"
    line "special #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "EEVEE."
    prompt
    
_MoonStoneText::
    text "Evolves a"
    line "special #MON."
    
    para "Use it on"
    line "#MON such as"
    cont "EEVEE."
    prompt

Offline

#58 2015-09-21 02:37:15

megamctaco
Member
Registered: 2015-08-23
Post 30/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Seems as if Oak's balls are already in the script.

.asm_1d2d0
    CheckAndSetEvent EVENT_GOT_POKEBALLS_FROM_OAK
    jr nz, .asm_1d2e7
    lb bc, POKE_BALL, 5
    call GiveItem
    ld hl, OaksLabGivePokeballsText
    call PrintText
    jr .asm_1d2ed

I assume that's for Yellow version?

Offline

#59 2015-09-21 04:54:54

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,040/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

In the first script, it assumes that all of the items in the list have ID numbers that are all together in order the way the badges are. Since they aren't, because that isn't how stones are stored, it can't find the right pointer from the table when it tries to look it up. It isn't directly checking "which numbered entry in the list is this" it's taking the item ID, subtracting Fire Stone's ID from that value, and then using what is left to determine how many entries to skip ahead. So in the original script, all the Badge items were stored together in the ID list. So when it subtracts Boulderbadge, then choosing Boulderbadge would start on the first entry, Cascadebadge would add one, getting the second entry, etc. All of my berries are stored together at the end of the item list, and so it still worked the same way his badge list did.  You're going to have to redo the script a bit if you want it to work with IDs that aren't actually together in the list like that.


As for the Oak pokeballs, no, that isn't yellow-exclusive, it's just something that practically nobody knows about. He doesn't give them right away like we want him to. Instead, you have to beat your rival on the route between Viridian and the Pokemon league without catching any Pokemon. Then go back and talk to Oak. He'll see that you only have 1 Pokemon still, and he will say "You can't complete the Pokedex just by seeing Pokemon, you need to capture them. here, use these" and gives you 5 Pokeballs. It's absurd that they did it that way, but it's been there since Red and Blue. lol.

Offline

#60 2015-09-21 05:35:15

comet
Member
Registered: 2012-04-09
Post 606/679

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

CeruleanHouse2Text1:
    ...
    ld a, [wcf91]
    sub FIRE_STONE

This is relating the id of the item (minus FIRE_STONE) to the text pointer, but you really want the index of the item in the list.

I believe you want to replace those two lines with "ld a, [wCurrentMenuItem]".

Offline

#61 2015-09-21 06:02:05

megamctaco
Member
Registered: 2015-08-23
Post 31/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

comet wrote:
CeruleanHouse2Text1:
    ...
    ld a, [wcf91]
    sub FIRE_STONE

This is relating the id of the item (minus FIRE_STONE) to the text pointer, but you really want the index of the item in the list.

I believe you want to replace those two lines with "ld a, [wCurrentMenuItem]".

Well that stopped it all from having glitched text or no text at all. However, only Fire, Water and Thunder Stones have the correct description. Every other stone has the Water Stone description.

I made a commit before where I just made the guy in the house a regular NPC who briefly mentions Stones, and replaced the Rare Candy outside his house with a Sun Stone. That's my backup plan if the stone descriptions don't work.

Offline

#62 2015-09-21 06:13:07

comet
Member
Registered: 2012-04-09
Post 607/679

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Oh my bad, I was wondering what wListScrollOffset was for. Use wWhichPokemon instead of wCurrentMenuItem.

Offline

#63 2015-09-21 06:28:23

megamctaco
Member
Registered: 2015-08-23
Post 32/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

comet wrote:

Oh my bad, I was wondering what wListScrollOffset was for. Use wWhichPokemon instead of wCurrentMenuItem.

Fixed! Thanks heaps.

I've got a few more new things I want to try next before I continue editing wild Pokemon to get closer to releasing a beta of my hack.

1. How do I add new music? I've got some original compositions I'd like to put in the game.
2. How do I assign trades to an NPC? For example, I'd like to use the unused Butterfree - Beedrill trade in the game.
3. Is it possible to change the name of traded Pokemon with the Name Rater, rather than changing the nicknames to the species name in trades.asm
4. How do I add "Trainers" like Mewtwo in Unknown Dungeon. Seeing as it isn't listed as a wild Pokemon on the map.

Offline

#64 2015-09-21 12:53:37

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,041/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

To make an NPC into a trader, you would just put this for their text data:

Museum2FText5: ; 5c33c (17:433c)
TX_ASM
ld a, $2
ld [wWhichTrade], a
predef DoInGameTradeDialogue
jp TextScriptEnd

Ok the first line is just the text entry I used, you would use whichever one is relevant to your NPC.

Let's break down what that is doing, so you understand.

TX_ASM - Means we're doing a custom routine instead of just normal text
ld a, $2 - Which entry in the list is this? Note that the first entry would be $0, the second would be $1, and the third would be $2, so this would be the unused trade you wanted.
ld [wWhichTrade], a - Store that value where the routine needs it
predef DoInGameTradeDialogue - This is calling the actual trade routine
jp TexScriptEnd - we're done here

Offline

#65 2015-09-21 23:41:03

megamctaco
Member
Registered: 2015-08-23
Post 33/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Mateo wrote:

To make an NPC into a trader, you would just put this for their text data:

Museum2FText5: ; 5c33c (17:433c)
TX_ASM
ld a, $2
ld [wWhichTrade], a
predef DoInGameTradeDialogue
jp TextScriptEnd

Ok the first line is just the text entry I used, you would use whichever one is relevant to your NPC.

Let's break down what that is doing, so you understand.

TX_ASM - Means we're doing a custom routine instead of just normal text
ld a, $2 - Which entry in the list is this? Note that the first entry would be $0, the second would be $1, and the third would be $2, so this would be the unused trade you wanted.
ld [wWhichTrade], a - Store that value where the routine needs it
predef DoInGameTradeDialogue - This is calling the actual trade routine
jp TexScriptEnd - we're done here

Cheers. I had to add "::" for it to work.

So if I wanted to make more in-game trades, I'd use that code to replace an NPC's text, and use $1A (for example) for the new trade entry. Is that right?

Offline

#66 2015-09-22 00:54:51

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,043/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

megamctaco wrote:
Mateo wrote:

To make an NPC into a trader, you would just put this for their text data:

Museum2FText5: ; 5c33c (17:433c)
TX_ASM
ld a, $2
ld [wWhichTrade], a
predef DoInGameTradeDialogue
jp TextScriptEnd

Ok the first line is just the text entry I used, you would use whichever one is relevant to your NPC.

Let's break down what that is doing, so you understand.

TX_ASM - Means we're doing a custom routine instead of just normal text
ld a, $2 - Which entry in the list is this? Note that the first entry would be $0, the second would be $1, and the third would be $2, so this would be the unused trade you wanted.
ld [wWhichTrade], a - Store that value where the routine needs it
predef DoInGameTradeDialogue - This is calling the actual trade routine
jp TexScriptEnd - we're done here

Cheers. I had to add "::" for it to work.

So if I wanted to make more in-game trades, I'd use that code to replace an NPC's text, and use $1A (for example) for the new trade entry. Is that right?

Pretty much. You'd need to add new entries in data/trades.asm of course, and you'd also need to check out wram.asm and make sure that there is enough space in wCompletedInGameTradeFlags:: to store the amount of trades that you want to use. By default, I see ds 2 and then another ds 2. That's 4 bytes, each byte can hold 8 flags, so that appears to be enough for 32 in-game trades unless I'm overlooking something. So yeah, it looks like you would be able to add more without having to do anything other than add the entry in data/trades.asm and then make the NPC call the proper trade number.

Offline

#67 2015-09-22 01:18:48

megamctaco
Member
Registered: 2015-08-23
Post 35/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Mateo wrote:
megamctaco wrote:
Mateo wrote:

To make an NPC into a trader, you would just put this for their text data:

Museum2FText5: ; 5c33c (17:433c)
TX_ASM
ld a, $2
ld [wWhichTrade], a
predef DoInGameTradeDialogue
jp TextScriptEnd

Ok the first line is just the text entry I used, you would use whichever one is relevant to your NPC.

Let's break down what that is doing, so you understand.

TX_ASM - Means we're doing a custom routine instead of just normal text
ld a, $2 - Which entry in the list is this? Note that the first entry would be $0, the second would be $1, and the third would be $2, so this would be the unused trade you wanted.
ld [wWhichTrade], a - Store that value where the routine needs it
predef DoInGameTradeDialogue - This is calling the actual trade routine
jp TexScriptEnd - we're done here

Cheers. I had to add "::" for it to work.

So if I wanted to make more in-game trades, I'd use that code to replace an NPC's text, and use $1A (for example) for the new trade entry. Is that right?

Pretty much. You'd need to add new entries in data/trades.asm of course, and you'd also need to check out wram.asm and make sure that there is enough space in wCompletedInGameTradeFlags:: to store the amount of trades that you want to use. By default, I see ds 2 and then another ds 2. That's 4 bytes, each byte can hold 8 flags, so that appears to be enough for 32 in-game trades unless I'm overlooking something. So yeah, it looks like you would be able to add more without having to do anything other than add the entry in data/trades.asm and then make the NPC call the proper trade number.

Awesome.

Would adding more TMs be a similar process?

Offline

#68 2015-09-22 04:55:40

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,044/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

megamctaco wrote:
Mateo wrote:
megamctaco wrote:

Cheers. I had to add "::" for it to work.

So if I wanted to make more in-game trades, I'd use that code to replace an NPC's text, and use $1A (for example) for the new trade entry. Is that right?

Pretty much. You'd need to add new entries in data/trades.asm of course, and you'd also need to check out wram.asm and make sure that there is enough space in wCompletedInGameTradeFlags:: to store the amount of trades that you want to use. By default, I see ds 2 and then another ds 2. That's 4 bytes, each byte can hold 8 flags, so that appears to be enough for 32 in-game trades unless I'm overlooking something. So yeah, it looks like you would be able to add more without having to do anything other than add the entry in data/trades.asm and then make the NPC call the proper trade number.

Awesome.

Would adding more TMs be a similar process?

Unless you only want to add HM06, adding TMs will be a lot more complicated than that. I'd have to look into what all would be involved to tell you more specifically, but I know you would have to expand the baseStats structure on all the Pokemon to include more TM/HM flags, and you'd need to modify the routines involved in using a TM, and you'd need to add the new moves onto the end of the data/tms.asm file, and (unless it's dynamic now) you'd have to expand how much space was allocated in RAM for storing the loaded Pokemon's tm/hm flags as well. There's probably a few other things I'm not thinking of.

Last edited by Mateo (2015-09-22 04:56:34)

Offline

#69 2015-09-27 10:14:48

megamctaco
Member
Registered: 2015-08-23
Post 36/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Hey Mateo,

I'm *trying* to test out using Field Moves from the overworld by following how you did it in your repository. I'm getting an error that says "Unable to load fixed ROM0 section at $1DDE".

I've no idea what that means. I assume I've run out of space somewhere? Not even sure how to make more room haha

EDIT: I think my problem lies somewhere in hidden_items.asm

Last edited by megamctaco (2015-09-27 10:38:40)

Offline

#70 2015-09-27 13:13:04

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,049/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

You probably are out of room in that bank, so you'll need to move something else around. There is not a lot of space in bank 0, so it fills up really quickly when you add things. One thing I've done in Red++ is move all of the Mart data out of Bank 0. Now, I have each Mart inventory in the same bank as the other scripts for that map, and instead of a single data/mart_inventories.asm I have a folder called data/martInventories/ and each mart is their own .asm file in that folder, and there are INCLUDE lines for all of those in main.asm right next to the INCLUDE for that mart's scripts. That freed up a good bit of space, which came in handy for me, because I've done so many tileset changes that I kept running out of room trying to include the new collision data. (if you do that, you'd need to remember to remove the INCLUDE "data/mart_inventories.asm" line in home.asm). I'll try to think of other things you can move out if you need the space.

Last edited by Mateo (2015-09-27 13:28:10)

Offline

#71 2015-09-27 13:24:21

megamctaco
Member
Registered: 2015-08-23
Post 37/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Mateo wrote:

You probably are out of room in that bank, so you'll need to move something else around.

I've tried changing the bank multiple times in main.asm but nothing seems to work. Is there a way to change the bank in one of the other files like hidden_items.asm, or does main.asm control it all?

Last edited by megamctaco (2015-09-27 13:24:42)

Offline

#72 2015-09-27 13:30:00

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,050/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

It looks like it is having a problem in bank 0, not in whatever later bank you included the main field move routine. Can you post a link to your changes so we can look over them?

Offline

#73 2015-09-27 13:39:54

megamctaco
Member
Registered: 2015-08-23
Post 38/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

cut.asm

UsedCut: ; ef54 (3:6f54)
    xor a
    ld [wActionResultOrTookBattleTurn], a ; initialise to failure value
    ld a, [W_CURMAPTILESET]
    and a ; OVERWORLD
    jr z, .overworld
    cp GYM
    jr nz, .nothingToCut
    ld a, [wTileInFrontOfPlayer]
    cp $50 ; gym cut tree
    jr nz, .nothingToCut
    jr .canCut
.overworld
    dec a
    ld a, [wTileInFrontOfPlayer]
    cp $3d ; cut tree
    jr z, .canCut
    cp $52 ; grass
    jr z, .canCut
.nothingToCut
    ld hl, .NothingToCutText
    jp PrintText

.NothingToCutText
    TX_FAR _NothingToCutText
    db "@"

.canCut
    ld [wCutTile], a
    ld a, 1
    ld [wActionResultOrTookBattleTurn], a ; used cut
    ld a, [wWhichPokemon]
    ld hl, wPartyMonNicks
    call GetPartyMonName
    ld hl, wd730
    set 6, [hl]
    call GBPalWhiteOutWithDelay3
    call ClearSprites
    call RestoreScreenTilesAndReloadTilePatterns
    ld a, SCREEN_HEIGHT_PIXELS
    ld [hWY], a
    call Delay3
    call LoadGBPal
    call LoadCurrentMapView
    call SaveScreenTilesToBuffer2
    call Delay3
    xor a
    ld [hWY], a
    
Cut2:: ; added for Field Move hack    
    ld hl, UsedCutText
    call PrintText
    call LoadScreenTilesFromBuffer2
    ld hl, wd730
    res 6, [hl]
    ld a, $ff
    ld [wUpdateSpritesEnabled], a
    call InitCutAnimOAM
    ld de, CutTreeBlockSwaps
    call ReplaceTreeTileBlock
    call RedrawMapView
    callba AnimCut
    ld a, $1
    ld [wUpdateSpritesEnabled], a
    ld a, SFX_CUT
    call PlaySound
    ld a, $90
    ld [hWY], a
    call UpdateSprites
    jp RedrawMapView

UsedCutText: ; eff2 (3:6ff2)
    TX_FAR _UsedCutText
    db "@"

InitCutAnimOAM: ; eff7 (3:6ff7)
    xor a
    ld [wWhichAnimationOffsets], a
    ld a, $e4
    ld [rOBP1], a
    ld a, [wCutTile]
    cp $52
    jr z, .grass
; tree
    ld de, Overworld_GFX + $2d0 ; cuttable tree sprite top row
    ld hl, vChars1 + $7c0
    lb bc, BANK(Overworld_GFX), $02
    call CopyVideoData
    ld de, Overworld_GFX + $3d0 ; cuttable tree sprite bottom row
    ld hl, vChars1 + $7e0
    lb bc, BANK(Overworld_GFX), $02
    call CopyVideoData
    jr WriteCutOrBoulderDustAnimationOAMBlock
.grass
    ld hl, vChars1 + $7c0
    call LoadCutGrassAnimationTilePattern
    ld hl, vChars1 + $7d0
    call LoadCutGrassAnimationTilePattern
    ld hl, vChars1 + $7e0
    call LoadCutGrassAnimationTilePattern
    ld hl, vChars1 + $7f0
    call LoadCutGrassAnimationTilePattern
    call WriteCutOrBoulderDustAnimationOAMBlock
    ld hl, wOAMBuffer + $93
    ld de, 4
    ld a, $30
    ld c, e
.loop
    ld [hl], a
    add hl, de
    xor $60
    dec c
    jr nz, .loop
    ret

LoadCutGrassAnimationTilePattern: ; f04c (3:704c)
    ld de, AnimationTileset2 + $60 ; tile depicting a leaf
    lb bc, BANK(AnimationTileset2), $01
    jp CopyVideoData

WriteCutOrBoulderDustAnimationOAMBlock: ; f055 (3:7055)
    call GetCutOrBoulderDustAnimationOffsets
    ld a, $9
    ld de, CutOrBoulderDustAnimationTilesAndAttributes
    jp WriteOAMBlock

CutOrBoulderDustAnimationTilesAndAttributes: ; f060 (3:7060)
    db $FC,$10,$FD,$10
    db $FE,$10,$FF,$10

GetCutOrBoulderDustAnimationOffsets: ; f068 (3:7068)
    ld hl, wSpriteStateData1 + 4
    ld a, [hli] ; player's sprite screen Y position
    ld b, a
    inc hl
    ld a, [hli] ; player's sprite screen X position
    ld c, a ; bc holds ypos/xpos of player's sprite
    inc hl
    inc hl
    ld a, [hl] ; a holds direction of player (00: down, 04: up, 08: left, 0C: right)
    srl a
    ld e, a
    ld d, $0 ; de holds direction (00: down, 02: up, 04: left, 06: right)
    ld a, [wWhichAnimationOffsets]
    and a
    ld hl, CutAnimationOffsets
    jr z, .next
    ld hl, BoulderDustAnimationOffsets
.next
    add hl, de
    ld e, [hl]
    inc hl
    ld d, [hl]
    ld a, b
    add d
    ld b, a
    ld a, c
    add e
    ld c, a
    ret

CutAnimationOffsets: ; f08f (3:708f)
; Each pair represents the x and y pixels offsets from the player of where the cut tree animation should be drawn
    db  8, 36 ; player is facing down
    db  8,  4 ; player is facing up
    db -8, 20 ; player is facing left
    db 24, 20 ; player is facing right

BoulderDustAnimationOffsets: ; f097 (3:7097)
; Each pair represents the x and y pixels offsets from the player of where the cut tree animation should be drawn
; These offsets represent 2 blocks away from the player
    db  8,  52 ; player is facing down
    db  8, -12 ; player is facing up
    db -24, 20 ; player is facing left
    db 40,  20 ; player is facing right

ReplaceTreeTileBlock: ; f09f (3:709f)
; Determine the address of the tile block that contains the tile in front of the
; player (i.e. where the tree is) and replace it with the corresponding tile
; block that doesn't have the tree.
    push de
    ld a, [W_CURMAPWIDTH]
    add 6
    ld c, a
    ld b, 0
    ld d, 0
    ld hl, wCurrentTileBlockMapViewPointer
    ld a, [hli]
    ld h, [hl]
    ld l, a
    add hl, bc
    ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
    and a
    jr z, .down
    cp SPRITE_FACING_UP
    jr z, .up
    cp SPRITE_FACING_LEFT
    jr z, .left
; right
    ld a, [W_XBLOCKCOORD]
    and a
    jr z, .centerTileBlock
    jr .rightOfCenter
.down
    ld a, [W_YBLOCKCOORD]
    and a
    jr z, .centerTileBlock
    jr .belowCenter
.up
    ld a, [W_YBLOCKCOORD]
    and a
    jr z, .aboveCenter
    jr .centerTileBlock
.left
    ld a, [W_XBLOCKCOORD]
    and a
    jr z, .leftOfCenter
    jr .centerTileBlock
.belowCenter
    add hl, bc
.centerTileBlock
    add hl, bc
.aboveCenter
    ld e, $2
    add hl, de
    jr .next
.leftOfCenter
    ld e, $1
    add hl, bc
    add hl, de
    jr .next
.rightOfCenter
    ld e, $3
    add hl, bc
    add hl, de
.next
    pop de
    ld a, [hl]
    ld c, a
.loop ; find the matching tile block in the array
    ld a, [de]
    inc de
    inc de
    cp $ff
    ret z
    cp c
    jr nz, .loop
    dec de
    ld a, [de] ; replacement tile block from matching array entry
    ld [hl], a
    ret

CutTreeBlockSwaps: ; f100 (3:7100)
; first byte = tileset block containing the cut tree
; second byte = corresponding tileset block after the cut animation happens
    db $32, $6D
    db $33, $6C
    db $34, $6F
    db $35, $4C
    db $60, $6E
    db $0B, $0A
    db $3C, $35
    db $3F, $35
    db $3D, $36
    db $FF ; list terminator

field_moves.asm

TryFieldMove:: ; predef
    call GetPredefRegisters

.Main:
    call TrySurf
    ret z
    call TryCut
;    ret z
    ret

TrySurf:
    ld a, [wWalkBikeSurfState]
    cp 2
    jr z, .no

    call IsSurfTile
    jr nc, .no

    ld d, SURF
    call HasPartyMove
    jr nz, .no

    ld a, [W_OBTAINEDBADGES]
    bit 4, a ; SOUL_BADGE
    jr z, .no

    call Text2_EnterTheText
    call GetPartyMonName2
    ld a, SURFBOARD
    ld [wcf91], a
    ld [wd152], a
    call UseItem
    call Text3_DrakesDeception

.yes
    xor a
    ret

.no
    ld a, 1
    and a
    ret

TryCut:
    call IsCutTile
    jr nc, .no

    ld d, CUT
    call HasPartyMove
    jr nz, .no

    ld a, [W_OBTAINEDBADGES]
    bit 4, a ; SOUL_BADGE
    jr z, .no

    call Text2_EnterTheText
    call GetPartyMonName2
    farcall Cut2
    call Text3_DrakesDeception

.yes
    xor a
    ret

.no
    ld a, 1
    and a
    ret


IsSurfTile:
    ld a, [W_CURMAPTILESET]
    ld hl, WaterTilesets2
    ld de,1
    call IsInArray
    jr nc, .no

    ld a, [W_CURMAPTILESET]
    cp SHIP_PORT
    ld a, [wTileInFrontOfPlayer]
    jr z, .ok
    cp $48 ; east shore (safari zone)
    jr z, .yes
    cp $32 ; east shore
    jr z, .yes
.ok
    cp $14 ; water
    jr z, .yes
.no
    and a
    ret
.yes
    scf
    ret

; tilesets with water
WaterTilesets2: ; e8e0 (3:68e0)
    db OVERWORLD
    db FOREST
    db SAFARI
    db GYM
    db SHIP
    db SHIP_PORT
    db CAVERN
    db FACILITY
    db PLATEAU
    db -1

IsCutTile:
    ld a, [W_CURMAPTILESET]
    and a ; OVERWORLD
    jr z, .overworld

    cp GYM
    jr z, .gym

    jr .no

.gym
    ld a, [wTileInFrontOfPlayer]
    cp $50 ; gym cut tree
    jr z, .yes
    jr .no

.overworld
    ld a, [wTileInFrontOfPlayer]
    cp $3d ; cut tree
    jr z, .yes
;    cp $52 ; grass
;    jr z, .yes
;    jr .no

.no
    and a
    ret
.yes
    scf
    ret


HasPartyMove::
; Return z (optional: in wWhichTrade) if a PartyMon has move d.
; Updates wWhichPokemon.

    push bc
    push de
    push hl

    ld a, [wPartyCount]
    and a
    jr z, .no
    ld b, a
    ld c, 0
    ld hl, wPartyMons + (wPartyMon1Moves - wPartyMon1)
.loop
    ld e, NUM_MOVES
.check_move
    ld a, [hli]
    cp d
    jr z, .yes
    dec e
    jr nz, .check_move

    ld a, wPartyMon2 - wPartyMon1 - NUM_MOVES
    add l
    ld l, a
    ld a, 0
    adc h
    ld h, a

    inc c
    ld a, c
    cp b
    jr c, .loop
    jr .no

.yes
    ld a, c
    ld [wWhichPokemon], a
    xor a ; probably redundant
    ld [wWhichTrade], a
    jr .done
.no
    ld a, 1
    and a
    ld [wWhichTrade], a
.done
    pop hl
    pop de
    pop bc
    ret


Text2_EnterTheText:
    call EnableAutoTextBoxDrawing
    ld a, 1 ; not 0
    ld [hSpriteIndexOrTextID], a
    farcall DisplayTextIDInit
    ret

Text3_DrakesDeception:
    ld a,[H_LOADEDROMBANK]
    push af
    jp CloseTextDisplay

hidden_items.asm

[HiddenItems: ; 76688 (1d:6688)
    ld hl, HiddenItemCoords
    call FindHiddenItemOrCoinsIndex
    ld [wHiddenItemOrCoinsIndex], a
    ld hl, wObtainedHiddenItemsFlags
    ld a, [wHiddenItemOrCoinsIndex]
    ld c, a
    ld b, FLAG_TEST
    predef FlagActionPredef
    ld a, c
    and a
    jr nz, .nope ; originally ret nz
    call EnableAutoTextBoxDrawing
    ld a, 1
    ld [wDoNotWaitForButtonPressAfterDisplayingText], a
    ld a, [wHiddenObjectFunctionArgument] ; item ID
    ld [wd11e], a
    call GetItemName
    tx_pre_jump FoundHiddenItemText

; added for field move hack
.nope
    predef TryFieldMove
    ret
    
INCLUDE "data/hidden_item_coords.asm"

FoundHiddenItemText: ; 7675b (1d:675b)
    TX_FAR _FoundHiddenItemText
    TX_ASM
    ld a, [wHiddenObjectFunctionArgument] ; item ID
    ld b, a
    ld c, 1
    call GiveItem
    jr nc, .BagFull
    ld hl, wObtainedHiddenItemsFlags
    ld a, [wHiddenItemOrCoinsIndex]
    ld c, a
    ld b, FLAG_SET
    predef FlagActionPredef
    ld a, SFX_GET_ITEM_2
    call PlaySoundWaitForCurrent
    call WaitForSoundToFinish
    jp TextScriptEnd
.BagFull
    call WaitForTextScrollButtonPress ; wait for button press
    xor a
    ld [wDoNotWaitForButtonPressAfterDisplayingText], a
    ld hl, HiddenItemBagFullText
    call PrintText
    jp TextScriptEnd

HiddenItemBagFullText: ; 76794 (1d:6794)
    TX_FAR _HiddenItemBagFullText
    db "@"

HiddenCoins: ; 76799 (1d:6799)
    ld b, COIN_CASE
    predef GetQuantityOfItemInBag
    ld a, b
    and a
    ret z
    ld hl, HiddenCoinCoords
    call FindHiddenItemOrCoinsIndex
    ld [wHiddenItemOrCoinsIndex], a
    ld hl, wObtainedHiddenCoinsFlags
    ld a, [wHiddenItemOrCoinsIndex]
    ld c, a
    ld b, FLAG_TEST
    predef FlagActionPredef
    ld a, c
    and a
    ret nz
    xor a
    ld [hUnusedCoinsByte], a
    ld [hCoins], a
    ld [hCoins + 1], a
    ld a, [wHiddenObjectFunctionArgument]
    sub COIN
    cp 10
    jr z, .bcd10
    cp 20
    jr z, .bcd20
    cp 40
    jr z, .bcd20
    jr .bcd100
.bcd10
    ld a, $10
    ld [hCoins + 1], a
    jr .bcddone
.bcd20
    ld a, $20
    ld [hCoins + 1], a
    jr .bcddone
.bcd40 ; due to a typo, this is never used
    ld a, $40
    ld [hCoins + 1], a
    jr .bcddone
.bcd100
    ld a, $1
    ld [hCoins], a
.bcddone
    ld de, wPlayerCoins + 1
    ld hl, hCoins + 1
    ld c, $2
    predef AddBCDPredef
    ld hl, wObtainedHiddenCoinsFlags
    ld a, [wHiddenItemOrCoinsIndex]
    ld c, a
    ld b, FLAG_SET
    predef FlagActionPredef
    call EnableAutoTextBoxDrawing
    ld a, [wPlayerCoins]
    cp $99
    jr nz, .RoomInCoinCase
    ld a, [wPlayerCoins + 1]
    cp $99
    jr nz, .RoomInCoinCase
    tx_pre_id DroppedHiddenCoinsText
    jr .done
.RoomInCoinCase
    tx_pre_id FoundHiddenCoinsText
.done
    jp PrintPredefTextID

INCLUDE "data/hidden_coins.asm"

FoundHiddenCoinsText: ; 76847 (1d:6847)
    TX_FAR _FoundHiddenCoinsText
    db $10,"@"

DroppedHiddenCoinsText: ; 7684d (1d:684d)
    TX_FAR _FoundHiddenCoins2Text
    db $10
    TX_FAR _DroppedHiddenCoinsText
    db "@"

FindHiddenItemOrCoinsIndex: ; 76857 (1d:6857)
    ld a, [wHiddenObjectY]
    ld d, a
    ld a, [wHiddenObjectX]
    ld e, a
    ld a, [W_CURMAP]
    ld b, a
    ld c, -1
.loop
    inc c
    ld a, [hli]
    cp $ff ; end of the list?
    ret z  ; if so, we're done here
    cp b
    jr nz, .next1
    ld a, [hli]
    cp d
    jr nz, .next2
    ld a, [hli]
    cp e
    jr nz, .loop
    ld a, c
    ret
.next1
    inc hl
.next2
    inc hl
    jr .loop

predefs.asm

GetPredefPointer:
; Store the contents of the register
; pairs (hl, de, bc) at wPredefRegisters.
; Then put the bank and address of predef
; wPredefID in [wPredefBank] and hl.

    ld a,h
    ld [wPredefRegisters],a
    ld a,l
    ld [wPredefRegisters + 1],a

    ld hl,wPredefRegisters + 2
    ld a,d
    ld [hli],a
    ld a,e
    ld [hli],a

    ld a,b
    ld [hli],a
    ld [hl],c

    ld hl,PredefPointers
    ld de,0

    ld a,[wPredefID]
    ld e,a
    add a
    add e
    ld e,a
    jr nc,.next
    inc d

.next
    add hl,de
    ld d,h
    ld e,l

    ; get bank of predef routine
    ld a,[de]
    ld [wPredefBank],a

    ; get pointer
    inc de
    ld a,[de]
    ld l,a
    inc de
    ld a,[de]
    ld h,a

    ret

PredefPointers:: ; 4fe79 (13:7e79)
; these are pointers to ASM routines.
; they appear to be used in overworld map scripts.
    add_predef DrawPlayerHUDAndHPBar
    add_predef CopyUncompressedPicToTilemap
    add_predef AnimateSendingOutMon
    add_predef ScaleSpriteByTwo
    add_predef LoadMonBackPic
    add_predef CopyDownscaledMonTiles
    add_predef LoadMissableObjects
    add_predef HealParty
    add_predef MoveAnimation; 08 play move animation
    add_predef DivideBCDPredef
    add_predef DivideBCDPredef2
    add_predef AddBCDPredef
    add_predef SubBCDPredef
    add_predef DivideBCDPredef3
    add_predef DivideBCDPredef4
    add_predef InitPlayerData
    add_predef FlagActionPredef
    add_predef HideObject
    add_predef IsObjectHidden
    add_predef ApplyOutOfBattlePoisonDamage
    add_predef AnyPartyAlive
    add_predef ShowObject
    add_predef ShowObject2
    add_predef ReplaceTileBlock
    add_predef InitPlayerData2
    add_predef LoadTilesetHeader
    add_predef LearnMoveFromLevelUp
    add_predef LearnMove
    add_predef GetQuantityOfItemInBag
    dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0
    dbw $03,GiveItem
    add_predef ChangeBGPalColor0_4Frames
    add_predef FindPathToPlayer
    add_predef PredefShakeScreenVertically
    add_predef CalcPositionOfPlayerRelativeToNPC
    add_predef ConvertNPCMovementDirectionsToJoypadMasks
    add_predef PredefShakeScreenHorizontally
    add_predef UpdateHPBar
    add_predef UpdateHPBar2
    add_predef HPBarLength
    add_predef Diploma_TextBoxBorder
    add_predef DoubleOrHalveSelectedStats
    add_predef ShowPokedexMenu
    add_predef EvolutionAfterBattle
    add_predef SaveSAVtoSRAM0
    add_predef InitOpponent
    add_predef CableClub_Run
    add_predef DrawBadges
    add_predef ExternalClockTradeAnim
    add_predef BattleTransition
    add_predef CopyTileIDsFromList
    add_predef PlayIntro
    add_predef GetMoveSoundB
    add_predef FlashScreen
    add_predef GetTileAndCoordsInFrontOfPlayer
    add_predef StatusScreen
    add_predef StatusScreen2
    add_predef InternalClockTradeAnim
    add_predef TrainerEngage
    add_predef IndexToPokedex
    add_predef DisplayPicCenteredOrUpperRight
    add_predef UsedCut
    add_predef ShowPokedexData
    add_predef WriteMonMoves
    add_predef SaveSAV
    add_predef LoadSGB
    add_predef MarkTownVisitedAndLoadMissableObjects
    add_predef SetPartyMonTypes
    add_predef CanLearnTM
    add_predef TMToMove
    add_predef _RunPaletteCommand
    add_predef StarterDex ; 46
    add_predef _AddPartyMon
    add_predef UpdateHPBar_Hook
    add_predef DrawEnemyHUDAndHPBar
    add_predef LoadTownMap_Nest
    add_predef PrintMonType
    add_predef EmotionBubble
    add_predef EmptyFunc3; return immediately
    add_predef AskName
    add_predef PewterGuys
    add_predef SaveSAVtoSRAM2
    add_predef LoadSAV2
    add_predef LoadSAV
    add_predef SaveSAVtoSRAM1
    add_predef DoInGameTradeDialogue
    add_predef HallOfFamePC
    add_predef DisplayDexRating
    dbw $1E, _LeaveMapAnim ; wrong bank
    dbw $1E, EnterMapAnim ; wrong bank
    add_predef GetTileTwoStepsInFrontOfPlayer
    add_predef CheckForCollisionWhenPushingBoulder
    add_predef PrintStrengthTxt
    add_predef PickUpItem
    add_predef PrintMoveType
    add_predef LoadMovePPs
    add_predef DrawHP ; 5F
    add_predef DrawHP2
    add_predef DisplayElevatorFloorMenu
    add_predef OaksAideScript
    add_predef TryFieldMove

home.asm

BoulderText:: ; 24e5 (0:24e5)
    TX_FAR _BoulderText
    db $08 ; asm
    
    ld a, [W_OBTAINEDBADGES]
    bit 3,a ; RAINBOWBADGE
    jr z, .done
    
    ld d, STRENGTH
    farcall HasPartyMove
    ld a, [wWhichTrade]
    and a
    jr nz, .done
    
    ld a, [wWhichPokemon]
    push af
    call ManualTextScroll
    pop af
    ld [wWhichPokemon], a
    call GetPartyMonName2
    predef PrintStrengthTxt
    
.done
    jp TextScriptEnd
    ;db "@"

MartSignText:: ; 24ea (0:24ea)
    TX_FAR _MartSignText
    db "@"

overworld.asm

.startButtonNotPressed
    bit 0,a ; A button
    jp z,.checkIfDownButtonIsPressed
; if A is pressed
    ld a,[wd730]
    bit 2,a
    jp nz,.noDirectionButtonsPressed
    call IsPlayerCharacterBeingControlledByGame
    jr nz,.checkForOpponent
    call CheckForHiddenObjectOrBookshelfOrCardKeyDoor
    ld a,[$ffeb]
    and a
    jp z,OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found
    call IsSpriteOrSignInFrontOfPlayer
    ld a,[hSpriteIndexOrTextID]
    and a
    jr nz, .displayDialogue
    
    ; Check for field moves that interact with the bg.
    predef TryFieldMove
    jp OverworldLoop
    
.displayDialogue
    predef GetTileAndCoordsInFrontOfPlayer
    call UpdateSprites
    ld a,[wFlags_0xcd60]
jpab: MACRO
    ld hl, \1
    ld b, BANK(\1)
    jp Bankswitch
    ENDM

farcall EQUS "callba"    
    
bcd2: MACRO
    dn ((\1) / 1000) % 10, ((\1) / 100) % 10
    dn ((\1) / 10) % 10, (\1) % 10
    ENDM

bcd3: MACRO

main.asm

; function that performs initialization for DisplayTextID
DisplayTextIDInit:: ; 7096 (1:7096)
    xor a
    ld [wListMenuID],a
    ld a,[wAutoTextBoxDrawingControl]
    bit 0,a
    jr nz,.skipDrawingTextBoxBorder
    ld a,[hSpriteIndexOrTextID] ; text ID (or sprite ID)
    and a
    jr nz,.notStartMenu

main.asm

MarowakPicFront:     INCBIN "pic/bmon/marowak.pic"
MarowakPicBack:      INCBIN "pic/monback/marowakb.pic"
ENDC

SECTION "field moves", ROMX,BANK[$37]

INCLUDE "engine/overworld/field_moves.asm"

IF DEF(_OPTION_BEACH_HOUSE)
SECTION "bank3C",ROMX[$4314],BANK[$3C]

BeachHouse_GFX:
    INCBIN "gfx/tilesets/beachhouse.2bpp"

BeachHouse_Block:
    INCBIN "gfx/blocksets/beachhouse.bst"
ENDC

Offline

#74 2015-09-27 16:34:15

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,051/3,506

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

It looks like you inserted it correctly, based on what you posted. Hard to tell for sure, since doing it this way doesn't highlight your changes like using Github would, but it looks like you did it right.

Changing the bank of the SECTION "field moves" part shouldn't matter, unless you had already used Bank $37 for something and didn't have room for it. That seems to be in a bank by itself at the end of the rom like it is in mine, and that doesn't look to be where your problems are coming in. The section if claims to have a problem with is in bank 0. The stuff that you edited in Bank 0 has to stay in Bank 0, because it is called from all over the place. So it looks like you will need to move some unrelated stuff out of Bank 0 to make room. That's why I suggested moving the Mart Data out of Bank 0. Unlike the important multi-use routines that are in Bank 0, there is absolutely no reason that you can't move Mart Data to be with the other scripts on the map. I'm sure they grouped them together simply for convenience originally, but since you can group the files inside a folder once they are split up, you don't really lose any convenience in editing, and you free up more room in Bank 0 for important stuff.

Here is the commit where I moved Mart Data out of Bank 0. Really wasn't that difficult. Just a bit of copy and pasting, then adding a few new INCLUDE lines. In this commit, I put the INCLUDE lines inside the main scripts file for that map, but this caused errors with Glitchmap, so in a later commit I put the INCLUDE lines inside main.asm for example, like this:

INCLUDE "data/mapHeaders/indigoplateaulobby.asm"
INCLUDE "scripts/indigoplateaulobby.asm"
INCLUDE "data/mapObjects/indigoplateaulobby.asm"
INCLUDE "data/martInventories/indigo_plateau.asm"
IndigoPlateauLobbyBlocks: INCBIN "maps/indigoplateaulobby.blk"

Not super difficult, and it frees up space in Bank 0.

Offline

#75 2015-09-28 00:21:35

megamctaco
Member
Registered: 2015-08-23
Post 39/103

Re: Hacking Red Questions (Trade evolutions and adding more TMs)

Mateo wrote:

It looks like you inserted it correctly, based on what you posted. Hard to tell for sure, since doing it this way doesn't highlight your changes like using Github would, but it looks like you did it right.

Changing the bank of the SECTION "field moves" part shouldn't matter, unless you had already used Bank $37 for something and didn't have room for it. That seems to be in a bank by itself at the end of the rom like it is in mine, and that doesn't look to be where your problems are coming in. The section if claims to have a problem with is in bank 0. The stuff that you edited in Bank 0 has to stay in Bank 0, because it is called from all over the place. So it looks like you will need to move some unrelated stuff out of Bank 0 to make room. That's why I suggested moving the Mart Data out of Bank 0. Unlike the important multi-use routines that are in Bank 0, there is absolutely no reason that you can't move Mart Data to be with the other scripts on the map. I'm sure they grouped them together simply for convenience originally, but since you can group the files inside a folder once they are split up, you don't really lose any convenience in editing, and you free up more room in Bank 0 for important stuff.

Here is the commit where I moved Mart Data out of Bank 0. Really wasn't that difficult. Just a bit of copy and pasting, then adding a few new INCLUDE lines. In this commit, I put the INCLUDE lines inside the main scripts file for that map, but this caused errors with Glitchmap, so in a later commit I put the INCLUDE lines inside main.asm for example, like this:

INCLUDE "data/mapHeaders/indigoplateaulobby.asm"
INCLUDE "scripts/indigoplateaulobby.asm"
INCLUDE "data/mapObjects/indigoplateaulobby.asm"
INCLUDE "data/martInventories/indigo_plateau.asm"
IndigoPlateauLobbyBlocks: INCBIN "maps/indigoplateaulobby.blk"

Not super difficult, and it frees up space in Bank 0.

Cool. I'll try that today.

Last edited by megamctaco (2015-09-28 00:30:46)

Offline

  • Index
  • → Help/Question
  • → Hacking Red Questions (Trade evolutions and adding more TMs)

Board footer

Powered by FluxBB