Thread: [Tutorial] Flags, Vars, & Script Tiles
View Single Post
Old July 20th, 2013 (5:08 PM).
karatekid552's Avatar
karatekid552 karatekid552 is offline
What happens if I push it?....
    Join Date: Nov 2012
    Location: Do you really want to know? Really?
    Gender: Male
    Nature: Bold
    Posts: 1,766
    Okay, so today, I finally decided to look into the "unknown" in script tile and person event making in A-Map. You know, the one that everyone says should be 3, if nothing but for consistency's sake? Well, here is the routine that deals with it for script tiles:

    r0= First thing, it gets the byte in question loaded to it.
    r4= Offset of data for script tile. +4 is the byte in question.
    r5= Same as r4.
    r6= Nothing (00000000).
    r7= 00000003 <- Number of script tiles on map, I believe.
    r8= 00000003 <- Compared to r0.

    ROM:0806DDF8 LDRB R0, <R4,#4>
    ROM:0806DDFA CMP R0, R8
    ROM:0806DDFC BEQ loc_806DE02
    ROM:0806DDFE CMP R0, #0
    ROM:0806DE00 BNE loc_806DE0C
    ROM:0806DE02 loc_806DE02 ; CODE XREF: sub_806DDC0+3Cj
    ROM:0806DE02 MOVS R0, R5
    ROM:0806DE04 BL sub_806DD80
    ROM:0806DE08 CMP R0, #0
    ROM:0806DE0A BNE loc_806DE18
    ROM:0806DE0C loc_806DE0C ; CODE XREF: sub_806DDC0+30j
    ROM:0806DE0C ; sub_806DDC0+36j ...
    ROM:0806DE0C ADDS R4, #0x10
    ROM:0806DE0E ADDS R5, #0x10
    ROM:0806DE10 ADDS R6, #1
    ROM:0806DE12 CMP R6, R7
    ROM:0806DE14 BLT loc_806DDEC

    If you can read this, you will see that if the byte is set to 0 or 3, it goes to the exact same place. This place is some code at 0806DD80 which reads the rest of the data, like the var value and script offset and runs them accordingly.

    If it is anything but 03 or 00, it jumps ahead to 0806DE0C prematurely, adds 10 to r4 and r5, (which had the offset of the event data). Event data is 10 bytes long, so guess what, it just reads the next event in line.Tongue I haven't actually tested that his happens, but it is a possibility. This belief is reinforced by the two lines at 0806DE12, which only allow the loop to run if there are script tiles remaining to be run.

    So, in all reality, it makes no difference if you change this byte at all, just as long as you only change it to 03 if you do change it. Hope this clears some things up!

    Paired with Simba
    Reply With Quote