’Cause all games were better on the GBC

You are not logged in.

#1 2015-02-26 18:57:52

Registered: 2010-10-16
Post 211/276

ASM Script Help

So basically I'm looking for some help in writing an ASM script for Viridian Forest map in Red. I've had a look over the Cerulean City and Pewter City scripts. Basically I want a certain NPC to disappear when spoken to and to activate the flag that means the Pewter City guy has disappeared also. Right now the Pewter City guy has been moved to in front of the GYM, he says a message about the gym leader not being there, you find the gym leader in the forest, he walks off screen and then the guy in front of pewter gym is no longer there (the leader has returned).

This is all I have so far but I think setting up the flags and hiding the NPCs is what im struggling with.

    db $08 ; asm
    ld hl, HackScript1
    call PrintText
    predef EmotionBubble
    ld hl, HackScript2
    call PrintText
    jp TextScriptEnd

    TX_FAR _ViridianForestText8
    db "@"
    TX_FAR _ViridianForestText9
    db "@"


#2 2015-02-26 19:40:52

Registered: 2013-12-04
Post 210/344

Re: ASM Script Help

There is a list of global ids that correspond to objects in the game that can be hidden. It's a bit painful to add new objects to this list, at least in my experience. You can see this list by looking at the MapHS data structure. I would recommend borrowing an item from viridian forest, and turning it into an NPC. Then just use that item's global HS (hide/show) Id. There is a predef function that hides an object. You can look at other map scripts for an example on how to use it.

Hope that helps some.


#3 2015-02-26 20:28:54

Danny-E 33
Registered: 2012-06-09
Post 861/1,206

Re: ASM Script Help

It is no longer difficult to edit the currently existing hide/show objects.

Simply add a new Hide/Show object after the three items in Viridian Forest:

MapHS33: ; cc16 (3:4c16)
    db VIRIDIAN_FOREST,$05,Show
    db VIRIDIAN_FOREST,$06,Show
    db VIRIDIAN_FOREST,$07,Show

So add a forth line, where VIRIDIAN_FOREST is the map, followed by the object id for that map (from data/mapObjects/viridianforest.asm), followed by the default state (Show).

Then add a constant for that hide/show npc in constants/hide_show_constants.asm
You have to add this constant immediately after the three existing Viridian Forest constants.

Notice how the Pewter City Gym script removes an object from a different map (Pewter City):

ld a, HS_GYM_GUY
ld [wcc4d], a
predef HideObject

So you could easily hide the Pewter City gym guy from inside the Viridian Forest map script.


#4 2015-02-26 21:40:10

Registered: 2013-12-04
Post 211/344

Re: ASM Script Help

Awesome! One thing to note is that you won't be able to add many more brand new HS objects. Since their ID is one byte, there are a max of 256, and i believe there are already roughly 240 in the game. I would do some txt checking, but I'm doing this on my phone and might be wrong again.

Last edited by ShantyTown (2015-02-26 21:40:34)


#5 2015-08-23 19:30:09

Registered: 2009-11-25
Post 3,027/3,665

Re: ASM Script Help

Wanted to bump this thread with a relevant question.

I notice that in wram.asm

; bit array of missable objects. set = removed
    ds 39

There seem to be 39 bytes assigned for storing flags, which works out to 312 individual flags assuming it is a normal bit array. So that would indicate we can add new hide/show entries to the end of the list (for a new area, for example) without having to allocate more space in wram.asm, correct?

EDIT: Just to clarify, in my experimenting, it does seem like this is the case, since Articuno is the last entry in the list, and there is more room afterwards that isn't used, so it looks to be safe, but I just wanted to make sure there wasn't something else I'm missing that would make it unsafe.

Last edited by Luna (2015-08-23 20:36:46)

I am not very active on this forum. I only pop in from time to time.


Board footer

Powered by FluxBB