Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

#1 2013-05-31 02:44:12

Munchulax
Member
From: Somewhere in Johto
Registered: 2011-08-10
Post 358/410

Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

I found this post in the Useful Offsets thread a while back:

blackopient wrote:

Awesome post. Extremely valuable.

When messing with replacing the Text Borders, I was curious where I might find the data that says which order to draw which tiles in around the text to make it a box. I am trying to add new border graphics, but they are in a different format and use more tiles than the way Gold is set up.
For example:
Here are the original 1 bpp borders borders.png
and here is one I would like to replace it with realfonty.png

As you can see the new one uses a different format, where it doesn't recycle tiles for the middle across and down sections.

I looked at the bgmap in no$gmb and read that it was using tiles 79 (top left border tile) 7A (middle tile), thinking it might use a tilemap, I searched for 797A and found a few things and made changes but nothing happened. I thought maybe then it might be elsewhere since the borders are dynamically drawn depending on the size coordinates it's fed.

I'm aware on how to change the text borders to load 2bpp and how to repoint it to the proper gfx but, does anyone have any ideas on maybe where or how I might find the routine to modify it to draw the extra tiles needed?

I know blackopient was able modify the routine and successfully make it so that the game didn't recycle tiles, but I never really understood how he/she did it.  Also, I want to apply this change to Crystal, and blackopient was hacking Gold.  Can anyone help me understand what I need to do so I can do the same thing for my Crystal hack?

Last edited by Munchulax (2013-06-25 03:07:50)


“To live is the rarest thing in the world. Most people exist, that is all.” ― Oscar Wilde

Offline

#2 2013-05-31 04:11:12

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 2,539/3,471

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

I think I have the offset written down somewhere. I know I messed with this once before, and had it loading the border tiles in 4 colors and not repeating tiles (also using tile values from the same graphic loaded by the font). It was listed in (I think) a document I got from MeanMrMustard. I'll look around and see what I can find, and pass it on when I know more. That's about the offset in Gold anyway, you would still need to find the equivalent function in Crystal.

Offline

#3 2013-05-31 09:24:13

RED
Member
From: Japan
Registered: 2012-09-03
Post 380/517

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

0xFf2- upper side
0x1009-right side
0x1002- left side
0x1013-downleft
0x1016- down part
0x101b-downright


わたし の なまえ わ レン レン  でづ

Offline

#4 2013-05-31 22:47:23

comet
Member
Registered: 2012-04-09
Post 251/673

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

From pokecrystal:

TextBoxBorder: ; ff1
; Draw a text box width c height b at hl

; Top
    push hl
    ld a, "┌"
    ld [hli], a
    inc a ; "─"
    call NPlaceChar
    inc a ; "┐"
    ld [hl], a

; Middle
    pop hl
    ld de, 20 ; screen width
    add hl, de
.PlaceRow
    push hl
    ld a, "│"
    ld [hli], a
    ld a, " "
    call NPlaceChar
    ld [hl], "│"
    pop hl
    ld de, 20 ; screen width
    add hl, de
    dec b
    jr nz, .PlaceRow

; Bottom
    ld a, "└"
    ld [hli], a
    ld a, "─"
    call NPlaceChar
    ld [hl], "┘"

    ret
; 101e


NPlaceChar: ; 101e
; place char a c times
    ld d,c
.loop
    ld [hli],a
    dec d
    jr nz, .loop
    ret
; 1024

Offline

#5 2013-06-01 19:43:55

Munchulax
Member
From: Somewhere in Johto
Registered: 2011-08-10
Post 361/410

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

Okay, I understand how I would replace change the tile that the script points to now, but now I need to find the location of the script that loads the borders into VRAM in the first place.  I want the borders placement in VRAM to start where the leftover ぇ is right now, at tile 77 instead of at tile 79, that way the game can still have multiple borders available for the player to choose.  I also know that I would have to repoint the location of the borders, but that's simple enough to do later on.

Last edited by Munchulax (2013-06-02 01:06:07)


“To live is the rarest thing in the world. Most people exist, that is all.” ― Oscar Wilde

Offline

#6 2013-06-01 21:25:03

RED
Member
From: Japan
Registered: 2012-09-03
Post 381/517

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

If you will do that, you will need to repoint everything.


わたし の なまえ わ レン レン  でづ

Offline

#7 2013-06-01 21:27:43

Munchulax
Member
From: Somewhere in Johto
Registered: 2011-08-10
Post 362/410

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

Don't I only have to repoint the routine that loads the tiles into VRAM and the borders themselves?  Unless I'm missing something here.


“To live is the rarest thing in the world. Most people exist, that is all.” ― Oscar Wilde

Offline

#8 2013-06-01 22:45:35

comet
Member
Registered: 2012-04-09
Post 252/673

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

the tiles you mentioned are used by the hud in battle. tile 72 is unused, and if you are ok with tracking down any text using [po] [ke] you can make those text characters instead to free up tile 70 (71 is also used in battle).

Last edited by comet (2013-06-01 22:46:13)

Offline

#9 2013-06-02 18:04:26

Munchulax
Member
From: Somewhere in Johto
Registered: 2011-08-10
Post 363/410

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

So this is what I have right now:
x5wVmSvD
(The borders are placeholders)

Back in September last year I asked a question about changing 1bpp borders to 2bpp borders.  Sawakita replied with a disassembly of the border code in Gold:

Sawakita wrote:

Well, let's look at the code then:

RO3E:4040 fa 9b d1         ld   a,(d19b)   ; get index of border (0-7)
RO3E:4043 e6 07            and  a,07      ; probably makes sure that A be less than 8
RO3E:4045 01 30 00         ld   bc,0030    ; each 1bpp tile is 0x08 bytes large -> 0x30 = (0x8 * 6) bytes
RO3E:4048 21 f2 48         ld   hl,48f2    ; pointer to first border graphics (they're consecutives)
RO3E:404b cd a3 31         call 31a3       ; calculate correct pointer (HL + (BC * A))
RO3E:404e 54               ld   d,h       ; put graphics pointer
RO3E:404f 5d               ld   e,l        ; into de
RO3E:4050 21 90 97         ld   hl,9790    ; (¹) VRAM destination
RO3E:4053 01 06 3e         ld   bc,3e06    ; (²) put bank in B and number of tiles in C
RO3E:4056 cd 72 0e         call 0e8d       ; (³) load 1bpp graphics (on-the-fly conversion to 2bpp) into VRAM
; we're not interested in the following but I'll just put it here anyway
RO3E:4059 21 f0 97         ld   hl,97f0    ; same as (¹)
RO3E:405c 11 f6 52         ld   de,52f6    ; 1bpp graphics source
RO3E:405f 01 01 3e         ld   bc,3e01    ; same as (²)
RO3E:4062 cd 8d 0e         call 0e8d       ; same as (³)
RO3E:4065 c9               ret

As you see the routine that loads 1bpp graphics (and converts it to 2bpp on-the-fly) is 0xe8d; the equivalent routine for 2bpp graphics is 0xe72.

The beginning of the code he posted started at 3E:4040 in Gold.  I have found the equivalent code in Crystal at 3E:74CC:

ld a,(CFCE)    ; get current border type from CFCE in RAM (0-7)
and a,07        ; probably makes sure that A be less than 8 
ld bc,0030        ; each 1bpp tile is 0x08 bytes large -> 0x30 = (0x8 * 6) bytes
ld hl,4800        ; pointer to first border graphics (they're consecutives)
call 30FE        ; calculate correct pointer (HL + (BC * A))
ld d,h            ; put graphics pointer
ld e,l                ; into de
ld hl,9790        ; (¹) VRAM destination
ld bc,3E06        ; (²) put bank in B and number of tiles in C
call 0DDC         ; (³) load 1bpp graphics (on-the-fly conversion to 2bpp) into VRAM
ld hl,97F0         ; same as (¹)
ld de,5204        ; 1bpp graphics source
ld bc,3E01     ; same as (²)
call 0DDC         ; same as (³)
ret

Looking at the code, I think I know what I need to modify in order to load parts of borders into certain addresses in VRAM, but I'm not sure if the actual code for the borders starts here or not because I can't find a pointer in the same ROM bank (3E) that points to FB4CC.  Could someone point me in the right direction so that I can repoint the routine so I can modify the routine that loads the tiles into VRAM?


“To live is the rarest thing in the world. Most people exist, that is all.” ― Oscar Wilde

Offline

#10 2013-06-02 22:27:03

Tauwasser
Member
Registered: 2010-10-16
Post 396/447

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

3E:750A
3E:74CA

So the pointers are right before and after that code.. What were you looking for?

cYa,

Tauwasser

Offline

#11 2013-06-23 02:40:22

Munchulax
Member
From: Somewhere in Johto
Registered: 2011-08-10
Post 386/410

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

Now that I have time to work on this again:

comet wrote:

the tiles you mentioned are used by the hud in battle. tile 72 is unused, and if you are ok with tracking down any text using [po] [ke] you can make those text characters instead to free up tile 70 (71 is also used in battle).

I felt like that would be the easy way to do it (even though players of the hack and the game itself don't care and it doesn't make a difference), so I changed some of the code that loads the borders from ROM into VRAM, and now the tile arrangement looks like this (borders are placeholders):

Overworld: Fjy1P154   In Battle: BlAnMQ2O

S6p4MQw2
Borders load correctly and correctly change as well.  The only problem I have now is that I can't figure out where the code that tells the game where to place Battle HUD tiles onscreen is in the ROM.  Therefore, because the code is currently unmodified the Battle HUD looks like this because:
cSQsTyKDwas shifted left from 0:9710 to 0:9700
YTi9nLtcwas shifted left from 0:9740 to 0:9710
YnjMXxejwas shifted left from 0:9740 - 0:9770 to 0:9720 - 0:9750

Could someone point me in the right direction with this problem so I can fix the Battle HUD?


“To live is the rarest thing in the world. Most people exist, that is all.” ― Oscar Wilde

Offline

#12 2013-06-25 02:46:27

Munchulax
Member
From: Somewhere in Johto
Registered: 2011-08-10
Post 392/410

Re: Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

From pokecrystal:

RefreshBattleHuds: ; 39c9
    call UpdateBattleHuds
    ld c, 3
    call DelayFrames
    jp WaitBGMap
; 39d4

UpdateBattleHuds: ; 39d4
    ld a, $f
    ld hl, $5f48
    rst FarCall ; UpdatePlayerHud
    ld a, $f
    ld hl, $6036
    rst FarCall ; UpdateEnemyHud
    ret
; 39e1

I think "UpdatePlayerHud" and "UpdateEnemyHud" is probably I'm looking for, because the HUD updates every time you press a button, but I'm not sure what I would have to change even if I am in the right place.  Could someone tell me if I'm even going in the right direction and maybe help me out a little?

Last edited by Munchulax (2013-06-25 02:46:47)


“To live is the rarest thing in the world. Most people exist, that is all.” ― Oscar Wilde

Offline

  • Index
  • → Help/Question
  • → Editing Battle HUD tilemap / Non-recycling border tiles (Crystal)

Board footer

Powered by FluxBB