Advertiser Content

Development Making Dive Work in FireRed

Started by Giga Universe July 19th, 2011 8:53 AM
  • 16137 views
  • 21 replies

Giga Universe

Working on a tool.

Age 24
Male
South Africa
Seen September 30th, 2012
Posted August 15th, 2011
121 posts
12.2 Years
Dive doesn't work in FireRed, I'm not sure if the code is there for it to work, but I suppose we could just write some more, as we could then create things like the underground.
I'm not sure if it helps, but I wrote a routine that finds a connection and stores the map and bank of that connection in a variable. You have to tell it what kind of connection to search for though...
0x5 is a 'Dive' connection, and 0x6 is a 'Emerge' connection.

.text
.align 2
.thumb
.thumb_func

main:
	push {r0-r5,lr}
	ldr r0, mapheader
	ldr r0, [r0,#0xC]
	ldr r1, [r0]
	ldr r0, [r0,#0x4]
	ldr r4, variable
	ldrh r5, [r4]
	mov r2, #0x0
	b search

search:
	cmp r1, #0x0
	beq notfound
	ldrb r3, [r0,r2]
	cmp r3, r5
	beq found
	add r2,#0xC
	sub r1, #0x1
	b search
	
notfound:
	pop {r0-r5,pc}

found:
	add r2, #0x8
	ldrb r1, [r0,r2]
	add r2, #0x1
	ldrb r2, [r0,r2]
	lsl r3, r1, #0x8
	orr r3, r2
	strh r3, [r4]
	pop {r0-r5,pc}
	
.align 2

mapheader:
	.word 0x02036DFC
	
variable:
	.word 0x020370D0 @Last result
All we need from here is to make it warp, and then we can make a tile behavior for it or something. I have absolutely no idea how to make it warp, so if someone could help there, then I could make this thing work...
Female
Seen October 4th, 2018
Posted January 24th, 2015
192 posts
12.2 Years
From Underwater: call script 081BE3D4
From Overworld: call script 081BE38B

To connect change the hometown-connection to a dive-connection set 08352754 to 05

To disable the check whether you actually have a dive pokemon with you set the 6 bytes 081BE394-081BE399 to 0. This function also decides which pokemon is shown in the black bar. So if you disable it and see a bad egg. That's because of this.

Disable the badge-check for HMs set 0812462E to 0.

There are two ways to warp. The special one is just used when the behaviour of the tile the player is standing on is 0x19 and when the light byte is set to 0x5. Through different ways the execution can reach 0806DFB0. To avoid that you can destroy the bne/beqs. Write 0000 to 0806DF82 and 0806DF9C. This is not a good solution though. I'm sure there is a reason why these if's are there.

I don't know if the warp destination is correct. But the bank and mapnumber are in the variables 7004 and 7005.

Lyzo

Back from vacation

Age 24
Male
The Netherlands
Seen 3 Weeks Ago
Posted July 2nd, 2019
263 posts
12.6 Years
Perhaps this is flawed somehow, but could this not effectively be done using signpost scripts? You'd have to use it sparingly unless you had the space to spare, but then, using too many dive points is kind of obnoxious anyway.
You could do that, but if you wanted to make big dive areas like in Ruby and Saphire, this would make the game lag. So putting an ASM routine in the tile behaviour, either using JPAN's engine, or... something else :P Is much more efficient.

If you would like to make Dive work in only one part of your game, then your solution would work ;)


^^ Thank you The Blueprint !!!

sonic1

ASM is my life now...

Age 24
Male
Portugal
Seen May 29th, 2018
Posted November 30th, 2012
79 posts
11.4 Years
Why don't you locate one of those useless tile behaviour scripts like the ones that are the TV's talking or something and make a 'goto' (like in asm bx r0 xD ) to the diving scripts?

This way it isn't needed JPAN's engine for it to work. And its more easier IMO.
This signature has been disabled.
over 350px high
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Seen May 16th, 2014
Posted October 16th, 2013
182 posts
9 Years
Wow, I was just about to start a thread about this :3

When it comes to ASM hacking Pokemon games I know nothing, in fact, my ASM knowledge is limited at best, and only limited to the Sonic The Hedgehog titles for the Genesis, lol. If you can port various things from one Sonic title to another though, I'm sure someone could port Dive and it's functionality to Fire Red. Sooo, yeah, if anyone is working on this, keep at it!
Seen 1 Week Ago
Posted August 6th, 2012
275 posts
9.3 Years
Why don't you locate one of those useless tile behaviour scripts like the ones that are the TV's talking or something and make a 'goto' (like in asm bx r0 xD ) to the diving scripts?
Those are actually scripts, not ASM.

As for the DIVE functionality, I can tell you guys that the scripts (as in XSE) for it still exist in FireRed. They don't have any identifiable warp calls, so either the warping results from the field move animation commands, or ASM detects when the script ends and warps then.

If the former, then that would explain why the DIVE field move animation crashes when triggered from script: it needs to read values from some location to know where to warp to, and it's not getting valid ones. Figure out how the field move animation works, and it may then be possible to make DIVE fully-functional.

sonic1

ASM is my life now...

Age 24
Male
Portugal
Seen May 29th, 2018
Posted November 30th, 2012
79 posts
11.4 Years
I know that they were scripts. I was refering to the 'goto' script command.

About DIVE, i already have a fully functional version, and if you watch carefully, the coordinates are the ones of the player when warping.

(Cheap Test): http://www.youtube.com/watch?v=pZiSs0r9yHI
This signature has been disabled.
over 350px high
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Seen June 17th, 2013
Posted December 8th, 2012
35 posts
12.2 Years
Wow, it´s realy working?
for dive you can insert a new tileset (underwater tileset maybe tiles from kyledove). Ok, I try to make it work on a german rom. I hope I´m succesful.
What do I need in the Script? Should I use any special commands?

//Edit1: Ok, it works on a german rom, too.

//Edit2: Ok, I have written a tutorial. I hope you can understand it. If not please tell me and I would explain it. http://www.pokecommunity.com/showthread.php?t=276031
Temporarily not available

Lance32497

LanceKoijer of Pokemon_Addicts

Male
Criscanto town-Ginoa Region xD
Seen August 13th, 2017
Posted January 1st, 2017
793 posts
5.2 Years
From Underwater: call script 081BE3D4
From Overworld: call script 081BE38B
Good Day knizz, about the quoted one, How to call that offsets? So do I need to call it as a script or something? What is the step by step procedure?

To connect change the hometown-connection to a dive-connection set 08352754 to 05
What is 08352754? Is that 0x352754 offset? And 08 refers to a POINTER? Am I right?



And.... Do I need to insert the ASM code given by giga universe?

Spherical Ice

Age 21
Bristol, UK
Online now
Posted 3 Weeks Ago
5,254 posts
11.9 Years

FireRed Dive


Download and fully extract the .zip file attached to this post.
Load firered_dive.asm in your text editor of choice and follow its instructions.

The attached download simply contains the file firered_dive.asm (found in the spoiler below and at https://pastebin.com/raw/1yjWuuuz), Lunar IPS, and base.gba (simply a 0xFFFFFF-sized file of just 0xFF bytes -- the .gba extension is just for simplicity's sake as it will mean Lunar IPS lists it by default).


Spoiler: firered_dive.asm
.thumb
.global firered_dive

@ FireRed v1.0 HM08 DIVE Port
@ Credits: Spherical Ice, Squeetz

@ CHANGE THESE:
.equ offset, 0x800000 @ ROM address of 0x400 bytes of free space
.equ OW_MALE_DIVE, 14 @ male player's diving overworld sprite number
.equ OW_FEMALE_DIVE, 15 @ female player's diving overworld sprite number
.equ FLAG_ALLOW_DIVE, 0x827 @ flag which allows the use of Dive
@ YOU MUST CHANGE THE ABOVE VALUES

@ INSTALL:
@ 1. Change the .equ values above, labelled CHANGE THESE
@ 2. If you wish to disable badge checking, follow the DISABLE BADGE CHECKING instructions below
@ 3. Save this file
@ 4. Assemble this file using the following command:
@ thumb firered_dive.s firered_dive.gba
@ 5. Create a .IPS patch using Lunar IPS:
@ Use the included base.gba file as the base ROM
@ Use the newly generated firered_dive.gba file as the modified ROM
@ 6. Patch your FireRed v1.0 ROM with the generated .IPS patch
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ DISABLE BADGE CHECKS:
@ Find and remove the appropriately labelled lines of code below
@ Ctrl + F: REMOVE THE FOLLOWING 5 LINES TO DISABLE BADGE CHECK
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ MAKE DIVE POSSIBLE IN MAPS:
@ Set the second behaviour byte of Dive-able tiles to the value of DIVE_TILE_BYTE below (0x23 by default)
@ Set their second behaviour byte of Emerge-able tiles to the value of EMERGE_TILE_BYTE below (0x24 by default)
@ Set underwater maps' light level (the Type: field in the Header view on AdvanceMap) to Underwater (0x5)
@ Create Emerge map connections to underwater maps leading to their surface maps
@ Create Dive map connections to surface maps leading to their underwater maps
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ Changing these is optional (they are the default FireRed currently)
.equ OW_MALE_WALK, 0 @ male player's normal, walking overworld sprite number
.equ OW_MALE_CYCLE, 1 @ male player's cycling overworld sprite number
.equ OW_MALE_SURF, 2 @ male player's surfing/"sat down" overworld sprite number
.equ OW_MALE_ITEM_0, 3 @ male player's first item usage overworld sprite number
.equ OW_MALE_FISH, 4 @ male player's fishing overworld sprite number
.equ OW_MALE_ITEM_1, 5 @ male player's second item usage overworld sprite number
.equ OW_FEMALE_WALK, 7 @ female player's normal, walking overworld sprite number
.equ OW_FEMALE_CYCLE, 8 @ female player's cycling overworld sprite number
.equ OW_FEMALE_SURF, 9 @ female player's surfing/"sat down" overworld sprite number
.equ OW_FEMALE_ITEM_0, 10 @ female player's first item usage overworld sprite number
.equ OW_FEMALE_FISH, 11 @ female player's fishing overworld sprite number
.equ OW_FEMALE_ITEM_1, 12 @ female player's second item usage overworld sprite number
.equ DIVE_TILE_BYTE, 0x23 @ second behaviour byte value for diving
.equ EMERGE_TILE_BYTE, 0x24 @ second behaviour byte value for emerging
.equ FLAG_ALLOW_RUN, 0x82F @ flag which allows the use of the Running Shoes
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ DO NOT CHANGE THESE VALUES:
.equ rom, 0x08000000
@ DO NOT CHANGE THE ABOVE VALUES

@ Hooks and branches
.org 0x5BA30, 0xFF
    ldr r0, =(disable_running_underwater + rom + 1)
    bx r0
.pool

.org 0x5C7F4, 0xFF
    .word player_overworld_list + rom

.org 0x5C826, 0xFF
    ldr r1, =(get_gender_from_sprite + rom + 1)
    bx r1
.pool

.org 0x5C9B0, 0xFF
    .word walkrun_overworld_list + rom

.org 0x5C9BA, 0xFF
    cmp r2, #3

.org 0x5C9F4, 0xFF
    .word walkrun_overworld_list + rom

.org 0x6CB30, 0xFF
    ldr r0, =(check_for_events + rom + 1)
    bx r0
.pool
    
.org 0x6CCCC, 0xFF
    ldr r1, =(check_dive + rom + 1)
    bx r1
.pool

.org 0x6DF78, 0xFF
    b 0x6DF84

.org 0x35B854, 0xFF
    .word change_sprite_to_diving + rom + 1

.org 0x471EEC, 0xFF
    .word player_behaviour_dive + rom + 1

.org offset, 0xFF
@ New data
player_overworld_list:
    .byte OW_MALE_WALK, OW_FEMALE_WALK
    .byte OW_MALE_CYCLE, OW_FEMALE_CYCLE
    .byte OW_MALE_SURF, OW_FEMALE_SURF
    .byte OW_MALE_ITEM_0, OW_FEMALE_ITEM_0
    .byte OW_MALE_FISH, OW_FEMALE_FISH
    .byte OW_MALE_ITEM_1, OW_FEMALE_ITEM_1
    .byte OW_MALE_DIVE, OW_FEMALE_DIVE

walkrun_overworld_list:
    .byte OW_MALE_WALK, 0b00001
    .byte OW_MALE_CYCLE, 0b00010
    .byte OW_MALE_SURF, 0b01000
    .byte OW_MALE_DIVE, 0b10000
    .byte OW_FEMALE_WALK, 0b00001
    .byte OW_FEMALE_CYCLE, 0b00010
    .byte OW_FEMALE_SURF, 0b01000
    .byte OW_FEMALE_DIVE, 0b10000

@ New code
disable_running_underwater:
	ldr r6, =(0x02037078) @ walkrun_state
	ldrb r1, [r6, #0] @ walkrun->bitfield
	mov r0, #16
	and r0, r1
	cmp r0, #0
	bne i_forgot_what_this_label_is
	mov r0, #2
	and r5, r0
	cmp r5, #0
	beq cannot_run
	ldr r0, =(FLAG_ALLOW_RUN)
	ldr r3, =(0x0806E6D0+1) @ flag_check
	bl call_via_r3
	lsl r0, r0, #24
	lsr r0, r0, #24
	cmp r0, #0
	beq cannot_run
	ldr r2, =(0x02036E38) @ npc_states
	ldrb r1, [r6, #5]
	lsl r0, r1, #3
	add r0, r0, r1
	lsl r0, r0, #2
	add r0, r0, r2
	ldrb r0, [r0, #30]
	ldr r3, =(0x080BD488+1) @ is_tile_to_run_on
	bl call_via_r3
	cmp r0, #0
	bne cannot_run

can_run:
	ldr r0, =(0x0805BA5A+1)
	bx r0

i_forgot_what_this_label_is:
	ldr r0, =(0x0805BA9E+1)
	bx r0

cannot_run:
	ldr r0, =(0x0805BA8C+1)
	bx r0

.pool

get_gender_from_sprite:
    lsl r0, r0, #24
    lsr r0, r0, #24
    cmp r0, #OW_MALE_DIVE
    beq male
    cmp r0, #OW_FEMALE_DIVE
    beq female
    cmp r0, #OW_FEMALE_FISH
    bgt male
    cmp r0, #OW_FEMALE_WALK
    blt male

female:
    mov r0, #1
    b return_to_x5C838
    
male:
    mov r0, #0
    
return_to_x5C838:
    ldr r1, =(0x0805C838 + 1)
    bx r1
.pool

check_for_events:
    mov r0, #0x80
    and r0, r1
    cmp r0, #0
    beq check_aftermove
    bl consider_dive_emerging
    cmp r0, #1
    beq something_happened

check_aftermove:
    ldrb r1, [r5]
    mov r0, #0x40
    and r0, r1
    cmp r0, #0
    beq check_move
    ldr r0, =(0x0806CB38 + 1)
    bx r0
    
something_happened:
    ldr r0, =(0x0806CB6C + 1)
    bx r0
    
check_move:
    ldr r0, =(0x0806CB74 + 1)
    bx r0
.pool

consider_dive_emerging:
    push {lr}
@ REMOVE THE FOLLOWING 5 LINES TO DISABLE BADGE CHECK 
    ldr r0, =(FLAG_ALLOW_DIVE)
    ldr r1, =(0x0806E6D0 + 1) @ checkflag
    bl call_via_r1
    cmp r0, #0
    beq no_emerging
@ REMOVE THE ABOVE 5 LINES TO DISABLE BADGE CHECK
    ldr r0, =(0x02036DFC) @ map_header
    ldrb r0, [r0, #23] @ map_header->light_level
    cmp r0, #5
    bne no_emerging
    bl get_block_secondary_role
    cmp r0, #EMERGE_TILE_BYTE
    bne no_emerging
    ldr r0, =(0x081BE3D4) @ emerge_script
    ldr r1, =(0x08069AE4 + 1) @ script_start
    bl call_via_r1
    mov r0, #1
    b dive_return
    
no_emerging:
    mov r0, #0

dive_return:
    pop {r1}
    bx r1
.pool

check_dive:
    ldrb r1, [r5]
    mov r0, #1
    and r0, r1
    cmp r0, #0
    beq no_dive
    bl consider_diving
    cmp r0, #1
    beq something_happened

no_dive:
    ldrb r1, [r5]
    mov r0, #4
    and r0, r1
    cmp r0, #0
    beq something
    ldr r2, =(0x0806CCD6 + 1)
    bx r2
    
something:
    ldr r0, =(0x0806CCFC + 1)
    bx r0
.pool
    
consider_diving:
    push {lr}
@ REMOVE THE FOLLOWING 5 LINES TO DISABLE BADGE CHECK
    ldr r0, =(FLAG_ALLOW_DIVE)
    ldr r1, =(0x0806E6D0 + 1) @ checkflag
    bl call_via_r1
    cmp r0, #0
    beq cant_dive
@ REMOVE THE ABOVE 5 LINES TO DISABLE BADGE CHECK
    bl get_block_secondary_role
    cmp r0, #DIVE_TILE_BYTE
    bne cant_dive
    ldr r0, =(0x081BE38B) @ dive_script
    ldr r1, =(0x08069AE4 + 1) @ script_start
    bl call_via_r1
    mov r0, #1
    b dive_pop
    
cant_dive:
    mov r0, #0

dive_pop:
    pop {r1}
    bx r1
.pool

get_block_secondary_role:
    push {r4, lr}
    sub sp, sp, #4
    mov r4, sp
    add r4, #2
    mov r0, sp
    mov r1, r4    
    ldr r3, =(0x0805C538 + 1) @ player_get_pos_to
    bl call_via_r3
    mov r0, sp
    mov r1, #0
    ldsh r0, [r0, r1]
    mov r2, #0
    ldsh r1, [r4, r2]
    lsl r0, r0, #16
    asr r0, r0, #16
    lsl r1, r1, #16
    asr r1, r1, #16
    mov r2, #8
    ldr r3, =(0x08058F48 + 1) @ cur_mapdata_block_get_field_at
    bl call_via_r3
    lsl r0, r0, #16
    lsr r0, r0, #24
    add sp, sp, #4
    pop {r4}
    pop {r1}
    bx r1
.pool

player_behaviour_dive:
    push {r4, lr}
    ldr r0, =(0x02037078) @ walkrun_state
    ldrb r0, [r0, #5] @ walkrun_state->npcid
    lsl r4, r0, #3
    add r4, r4, r0
    lsl r4, r4, #2
    ldr r0, =(0x02036E38) @ npc_states
    add r4, r4, r0
    mov r0, #6
    ldr r3, =(0x0805C808 + 1) @ get_sprite_for_player
    bl call_via_r3
    add r1, r0, #0
    lsl r1, r1, #24
    lsr r1, r1, #24
    add r0, r4, #0
    ldr r3, =(0x081507BC + 1) @ npc_change_sprite_call
    bl call_via_r3
    ldrb r1, [r4, #24]
    lsr r1, r1, #4
    add r0, r4, #0
    ldr r3, =(0x0805F218 + 1) @ npc_turn
    bl call_via_r3
    mov r0, #16
    ldr r3, =(0x0805C970 + 1) @ change_sprite_bitfield
    bl call_via_r3
    ldrb r0, [r4, #4]
    ldr r3, =(0x080DC6B0 + 1) @ bobbing
    bl call_via_r3
    strb r0,[r4, #26]
    pop {r4}
    pop {r0}
    bx r0
.pool

change_sprite_to_diving:
    push {lr}
    mov r0, #4

set:
    ldr r1, =(0x08150498 + 1) @ set_player_behaviour
    bl call_via_r1
    pop {r1}

call_via_r1:
    bx r1

call_via_r3:
    bx r3
.pool

.org 0xFFFFFF, 0xFF
.byte 0xFF

Spherical Ice

Age 21
Bristol, UK
Online now
Posted 3 Weeks Ago
5,254 posts
11.9 Years

FireRed Dive

Bumping again, I added a routine which force prevents running when underwater because it was still possible despite B being used for emerging if you started walking first. This is somewhat untested on a clean ROM so confirmation it works would be appreciated. I'm fairly certain it should work fine, though.

Spherical Ice

Age 21
Bristol, UK
Online now
Posted 3 Weeks Ago
5,254 posts
11.9 Years
Couldn't you just use AdvanceMap? There's an option to create Dive/Emerge connections...
The Dive/Emerge connections work in FRLG, but everything else about Dive doesn't work without the work mentioned above.
Seen July 31st, 2019
Posted August 17th, 2018
23 posts
2.2 Years

FireRed Dive


Download and fully extract the .zip file attached to this post.
Load firered_dive.asm in your text editor of choice and follow its instructions.

The attached download simply contains the file firered_dive.asm (found in the spoiler below and at https://pastebin.com/raw/1yjWuuuz), Lunar IPS, and base.gba (simply a 0xFFFFFF-sized file of just 0xFF bytes -- the .gba extension is just for simplicity's sake as it will mean Lunar IPS lists it by default).


Spoiler: firered_dive.asm
.thumb
.global firered_dive

@ FireRed v1.0 HM08 DIVE Port
@ Credits: Spherical Ice, Squeetz

@ CHANGE THESE:
.equ offset, 0x800000 @ ROM address of 0x1D8 bytes of free space
.equ OW_MALE_DIVE, 14 @ male player's diving overworld sprite number
.equ OW_FEMALE_DIVE, 15 @ female player's diving overworld sprite number
.equ FLAG_ALLOW_DIVE, 0x827 @ flag which allows the use of Dive
@ YOU MUST CHANGE THE ABOVE VALUES

@ INSTALL:
@ 1. Change the .equ values above, labelled CHANGE THESE
@ 2. If you wish to disable badge checking, follow the DISABLE BADGE CHECKING instructions below
@ 3. Save this file
@ 4. Assemble this file using the following command:
@ thumb firered_dive.s firered_dive.gba
@ 5. Create a .IPS patch using Lunar IPS:
@ Use the included base.gba file as the base ROM
@ Use the newly generated firered_dive.gba file as the modified ROM
@ 6. Patch your FireRed v1.0 ROM with the generated .IPS patch
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ DISABLE BADGE CHECKS:
@ Find and remove the appropriately labelled lines of code below
@ Ctrl + F: REMOVE THE FOLLOWING 5 LINES TO DISABLE BADGE CHECK
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ MAKE DIVE POSSIBLE IN MAPS:
@ Set the second behaviour byte of Dive-able tiles to the value of DIVE_TILE_BYTE below (0x23 by default)
@ Set their second behaviour byte of Emerge-able tiles to the value of EMERGE_TILE_BYTE below (0x24 by default)
@ Set underwater maps' light level (the Type: field in the Header view on AdvanceMap) to Underwater (0x5)
@ Create Emerge map connections to underwater maps leading to their surface maps
@ Create Dive map connections to surface maps leading to their underwater maps
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ Changing these is optional (they are the default FireRed currently)
.equ OW_MALE_WALK, 0 @ male player's normal, walking overworld sprite number
.equ OW_MALE_CYCLE, 1 @ male player's cycling overworld sprite number
.equ OW_MALE_SURF, 2 @ male player's surfing/"sat down" overworld sprite number
.equ OW_MALE_ITEM_0, 3 @ male player's first item usage overworld sprite number
.equ OW_MALE_FISH, 4 @ male player's fishing overworld sprite number
.equ OW_MALE_ITEM_1, 5 @ male player's second item usage overworld sprite number
.equ OW_FEMALE_WALK, 7 @ female player's normal, walking overworld sprite number
.equ OW_FEMALE_CYCLE, 8 @ female player's cycling overworld sprite number
.equ OW_FEMALE_SURF, 9 @ female player's surfing/"sat down" overworld sprite number
.equ OW_FEMALE_ITEM_0, 10 @ female player's first item usage overworld sprite number
.equ OW_FEMALE_FISH, 11 @ female player's fishing overworld sprite number
.equ OW_FEMALE_ITEM_1, 12 @ female player's second item usage overworld sprite number
.equ DIVE_TILE_BYTE, 0x23 @ second behaviour byte value for diving
.equ EMERGE_TILE_BYTE, 0x24 @ second behaviour byte value for emerging
.equ FLAG_ALLOW_RUN, 0x82F @ flag which allows the use of the Running Shoes
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ DO NOT CHANGE THESE VALUES:
.equ rom, 0x08000000
@ DO NOT CHANGE THE ABOVE VALUES

@ Hooks and branches
.org 0x5BA30, 0xFF
    ldr r0, =(disable_running_underwater + rom + 1)
    bx r0
.pool

.org 0x5C7F4, 0xFF
    .word player_overworld_list + rom

.org 0x5C826, 0xFF
    ldr r1, =(get_gender_from_sprite + rom + 1)
    bx r1
.pool

.org 0x5C9B0, 0xFF
    .word walkrun_overworld_list + rom

.org 0x5C9BA, 0xFF
    cmp r2, #3

.org 0x5C9F4, 0xFF
    .word walkrun_overworld_list + rom

.org 0x6CB30, 0xFF
    ldr r0, =(check_for_events + rom + 1)
    bx r0
.pool
    
.org 0x6CCCC, 0xFF
    ldr r1, =(check_dive + rom + 1)
    bx r1
.pool

.org 0x6DF78, 0xFF
    b 0x6DF84

.org 0x35B854, 0xFF
    .word change_sprite_to_diving + rom + 1

.org 0x471EEC, 0xFF
    .word player_behaviour_dive + rom + 1

.org offset, 0xFF
@ New data
player_overworld_list:
    .byte OW_MALE_WALK, OW_FEMALE_WALK
    .byte OW_MALE_CYCLE, OW_FEMALE_CYCLE
    .byte OW_MALE_SURF, OW_FEMALE_SURF
    .byte OW_MALE_ITEM_0, OW_FEMALE_ITEM_0
    .byte OW_MALE_FISH, OW_FEMALE_FISH
    .byte OW_MALE_ITEM_1, OW_FEMALE_ITEM_1
    .byte OW_MALE_DIVE, OW_FEMALE_DIVE

walkrun_overworld_list:
    .byte OW_MALE_WALK, 0b00001
    .byte OW_MALE_CYCLE, 0b00010
    .byte OW_MALE_SURF, 0b01000
    .byte OW_MALE_DIVE, 0b10000
    .byte OW_FEMALE_WALK, 0b00001
    .byte OW_FEMALE_CYCLE, 0b00010
    .byte OW_FEMALE_SURF, 0b01000
    .byte OW_FEMALE_DIVE, 0b10000

@ New code
disable_running_underwater:
	ldr r6, =(0x02037078) @ walkrun_state
	ldrb r1, [r6, #0] @ walkrun->bitfield
	mov r0, #16
	and r0, r1
	cmp r0, #0
	bne i_forgot_what_this_label_is
	mov r0, #2
	and r5, r0
	cmp r5, #0
	beq cannot_run
	ldr r0, =(FLAG_ALLOW_RUN)
	ldr r3, =(0x0806E6D0+1) @ flag_check
	bl call_via_r3
	lsl r0, r0, #24
	lsr r0, r0, #24
	cmp r0, #0
	beq cannot_run
	ldr r2, =(0x02036E38) @ npc_states
	ldrb r1, [r6, #5]
	lsl r0, r1, #3
	add r0, r0, r1
	lsl r0, r0, #2
	add r0, r0, r2
	ldrb r0, [r0, #30]
	ldr r3, =(0x080BD488+1) @ is_tile_to_run_on
	bl call_via_r3
	cmp r0, #0
	bne cannot_run

can_run:
	ldr r0, =(0x0805BA5A+1)
	bx r0

i_forgot_what_this_label_is:
	ldr r0, =(0x0805BA9E+1)
	bx r0

cannot_run:
	ldr r0, =(0x0805BA8C+1)
	bx r0

.pool

get_gender_from_sprite:
    lsl r0, r0, #24
    lsr r0, r0, #24
    cmp r0, #OW_MALE_DIVE
    beq male
    cmp r0, #OW_FEMALE_DIVE
    beq female
    cmp r0, #OW_FEMALE_FISH
    bgt male
    cmp r0, #OW_FEMALE_WALK
    blt male

female:
    mov r0, #1
    b return_to_x5C838
    
male:
    mov r0, #0
    
return_to_x5C838:
    ldr r1, =(0x0805C838 + 1)
    bx r1
.pool

check_for_events:
    mov r0, #0x80
    and r0, r1
    cmp r0, #0
    beq check_aftermove
    bl consider_dive_emerging
    cmp r0, #1
    beq something_happened

check_aftermove:
    ldrb r1, [r5]
    mov r0, #0x40
    and r0, r1
    cmp r0, #0
    beq check_move
    ldr r0, =(0x0806CB38 + 1)
    bx r0
    
something_happened:
    ldr r0, =(0x0806CB6C + 1)
    bx r0
    
check_move:
    ldr r0, =(0x0806CB74 + 1)
    bx r0
.pool

consider_dive_emerging:
    push {lr}
@ REMOVE THE FOLLOWING 5 LINES TO DISABLE BADGE CHECK 
    ldr r0, =(FLAG_ALLOW_DIVE)
    ldr r1, =(0x0806E6D0 + 1) @ checkflag
    bl call_via_r1
    cmp r0, #0
    beq no_emerging
@ REMOVE THE ABOVE 5 LINES TO DISABLE BADGE CHECK
    ldr r0, =(0x02036DFC) @ map_header
    ldrb r0, [r0, #23] @ map_header->light_level
    cmp r0, #5
    bne no_emerging
    bl get_block_secondary_role
    cmp r0, #EMERGE_TILE_BYTE
    bne no_emerging
    ldr r0, =(0x081BE3D4) @ emerge_script
    ldr r1, =(0x08069AE4 + 1) @ script_start
    bl call_via_r1
    mov r0, #1
    b dive_return
    
no_emerging:
    mov r0, #0

dive_return:
    pop {r1}
    bx r1
.pool

check_dive:
    ldrb r1, [r5]
    mov r0, #1
    and r0, r1
    cmp r0, #0
    beq no_dive
    bl consider_diving
    cmp r0, #1
    beq something_happened

no_dive:
    ldrb r1, [r5]
    mov r0, #4
    and r0, r1
    cmp r0, #0
    beq something
    ldr r2, =(0x0806CCD6 + 1)
    bx r2
    
something:
    ldr r0, =(0x0806CCFC + 1)
    bx r0
.pool
    
consider_diving:
    push {lr}
@ REMOVE THE FOLLOWING 5 LINES TO DISABLE BADGE CHECK
    ldr r0, =(FLAG_ALLOW_DIVE)
    ldr r1, =(0x0806E6D0 + 1) @ checkflag
    bl call_via_r1
    cmp r0, #0
    beq cant_dive
@ REMOVE THE ABOVE 5 LINES TO DISABLE BADGE CHECK
    bl get_block_secondary_role
    cmp r0, #DIVE_TILE_BYTE
    bne cant_dive
    ldr r0, =(0x081BE38B) @ dive_script
    ldr r1, =(0x08069AE4 + 1) @ script_start
    bl call_via_r1
    mov r0, #1
    b dive_pop
    
cant_dive:
    mov r0, #0

dive_pop:
    pop {r1}
    bx r1
.pool

get_block_secondary_role:
    push {r4, lr}
    sub sp, sp, #4
    mov r4, sp
    add r4, #2
    mov r0, sp
    mov r1, r4    
    ldr r3, =(0x0805C538 + 1) @ player_get_pos_to
    bl call_via_r3
    mov r0, sp
    mov r1, #0
    ldsh r0, [r0, r1]
    mov r2, #0
    ldsh r1, [r4, r2]
    lsl r0, r0, #16
    asr r0, r0, #16
    lsl r1, r1, #16
    asr r1, r1, #16
    mov r2, #8
    ldr r3, =(0x08058F48 + 1) @ cur_mapdata_block_get_field_at
    bl call_via_r3
    lsl r0, r0, #16
    lsr r0, r0, #24
    add sp, sp, #4
    pop {r4}
    pop {r1}
    bx r1
.pool

player_behaviour_dive:
    push {r4, lr}
    ldr r0, =(0x02037078) @ walkrun_state
    ldrb r0, [r0, #5] @ walkrun_state->npcid
    lsl r4, r0, #3
    add r4, r4, r0
    lsl r4, r4, #2
    ldr r0, =(0x02036E38) @ npc_states
    add r4, r4, r0
    mov r0, #6
    ldr r3, =(0x0805C808 + 1) @ get_sprite_for_player
    bl call_via_r3
    add r1, r0, #0
    lsl r1, r1, #24
    lsr r1, r1, #24
    add r0, r4, #0
    ldr r3, =(0x081507BC + 1) @ npc_change_sprite_call
    bl call_via_r3
    ldrb r1, [r4, #24]
    lsr r1, r1, #4
    add r0, r4, #0
    ldr r3, =(0x0805F218 + 1) @ npc_turn
    bl call_via_r3
    mov r0, #16
    ldr r3, =(0x0805C970 + 1) @ change_sprite_bitfield
    bl call_via_r3
    ldrb r0, [r4, #4]
    ldr r3, =(0x080DC6B0 + 1) @ bobbing
    bl call_via_r3
    strb r0,[r4, #26]
    pop {r4}
    pop {r0}
    bx r0
.pool

change_sprite_to_diving:
    push {lr}
    mov r0, #4

set:
    ldr r1, =(0x08150498 + 1) @ set_player_behaviour
    bl call_via_r1
    pop {r1}

call_via_r1:
    bx r1

call_via_r3:
    bx r3
.pool

.org 0xFFFFFF, 0xFF
.byte 0xFF
@spherical ice how do you apply these to a script sorry im new in asm things
Advertiser Content