Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2016-06-15 19:27:31

Montblanc
Member
Registered: 2016-02-23
Post 23/47

Adding Gym leader names to the status screen

Hi

I am trying to add the Gym leader names in the status screen, but after adding the graphics for the letters I've found that it is limited to 2 tiles each, so they show up like this:

i69yro.png

I am thinking in two possible solutions to fix it... First one will be making the code to draw three tiles for the name instead of the blank tiles on the right and leave some blank space for the short names. The other possibility I thought is to add code and call it so before the games shows on screen the normal result it moves the tiles I want to the correct position. But I don't know how to start with any of them (is possible to write something like "grab tile 62, replace with it the tile at x y position, grab tile 72"...?)

The code for the leader faces/badges/names is in the file main.asm:

DrawBadges: ; ea03 (3:6a03)
; Draw 4x2 gym leader faces, with the faces replaced by
; badges if they are owned. Used in the player status screen.

; In Japanese versions, names are displayed above faces.
; Instead of removing relevant code, the name graphics were erased.

; Tile ids for face/badge graphics.
ld de, wBadgeOrFaceTiles
ld hl, .FaceBadgeTiles
ld bc, 8
call CopyData

; Booleans for each badge.
ld hl, wTempObtainedBadgesBooleans
ld bc, 8
xor a
call FillMemory

; Alter these based on owned badges.
ld de, wTempObtainedBadgesBooleans
ld hl, wBadgeOrFaceTiles
ld a, [wObtainedBadges]
ld b, a
ld c, 8
.CheckBadge
srl b
jr nc, .NextBadge
ld a, [hl]
add 4 ; Badge graphics are after each face
ld [hl], a
ld a, 1
ld [de], a
.NextBadge
inc hl
inc de
dec c
jr nz, .CheckBadge

; Draw two rows of badges.
ld hl, wBadgeNumberTile
ld a, $d8 ; [1]
ld [hli], a
ld [hl], $60 ; First name

coord hl, 2, 11
ld de, wTempObtainedBadgesBooleans
call .DrawBadgeRow

coord hl, 2, 14
ld de, wTempObtainedBadgesBooleans + 4
; call .DrawBadgeRow
; ret

.DrawBadgeRow ; ea4c (3:6a4c)
; Draw 4 badges.

ld c, 4
.DrawBadge
push de
push hl

; Badge no.
ld a, [wBadgeNumberTile]
ld [hli], a
inc a
ld [wBadgeNumberTile], a

; Names aren't printed if the badge is owned.
ld a, [de]
and a
ld a, [wBadgeNameTile]
jr nz, .SkipName
call .PlaceTiles
jr .PlaceBadge

.SkipName
inc a
inc a
inc hl

.PlaceBadge
ld [wBadgeNameTile], a
ld de, SCREEN_WIDTH - 1
add hl, de
ld a, [wBadgeOrFaceTiles]
call .PlaceTiles
add hl, de
call .PlaceTiles

; Shift badge array back one byte.
push bc
ld hl, wBadgeOrFaceTiles + 1
ld de, wBadgeOrFaceTiles
ld bc, 8
call CopyData
pop bc

pop hl
ld de, 4
add hl, de

pop de
inc de
dec c
jr nz, .DrawBadge
ret

.PlaceTiles
ld [hli], a
inc a
ld [hl], a
inc a
ret

.FaceBadgeTiles
db $20, $28, $30, $38, $40, $48, $50, $58

Any ideas?

Offline

#2 2016-06-15 21:08:20

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 385/415
Website

Re: Adding Gym leader names to the status screen

Well first off it looks like tile id's 76 and 77 would overlap with others already used for the player screen layout. You might want to start at id 5E given that the text isn't printed if you own the badge. (5C-5F are the 8th badge tiles).

But other than that minor issue, it shouldn't be complicated at all. I think these changes will do:

; Names aren't printed if the badge is owned.
ld a, [de]
and a
ld a, [wBadgeNameTile]
jr nz, .SkipName
call .PlaceTiles2
jr .PlaceBadge

.SkipName
inc a
inc a
inc a
inc hl

.PlaceBadge
ld [wBadgeNameTile], a
ld de, SCREEN_WIDTH - 2
add hl, de
ld a, [wBadgeOrFaceTiles]
call .PlaceTiles
[b]inc de[/b]
add hl, de
call .PlaceTiles

(...)

.PlaceTiles2
ld [hli], a
inc a
ld [hli], a
inc a
ld [hl], a
inc a
ret

Last edited by Crystal_ (2016-06-17 09:20:02)

Offline

#3 2016-06-16 22:14:22

Montblanc
Member
Registered: 2016-02-23
Post 24/47

Re: Adding Gym leader names to the status screen

Thank you for the reply!

But how can I start from 5E, if that tile is part of the 8th badge? Also the Gym leader faces and the badge sprites are sliced in two. Sorry but I'm still a noob at this...

Offline

#4 2016-06-17 09:35:34

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 386/415
Website

Re: Adding Gym leader names to the status screen

Let's do the following instead, given that Koga and Erika only require two tiles for their names:

; Names aren't printed if the badge is owned.
ld a, [de]
and a
ld a, [wBadgeNameTile]
jr nz, .SkipName
call .PlaceTiles2
jr .PlaceBadge

.SkipName
inc a
inc a
cp $60 + 11
jr z, .ok1
cp $60 + 13
jr z, .ok1
inc a
.ok1
inc hl

.PlaceBadge
ld [wBadgeNameTile], a
ld de, SCREEN_WIDTH - 1
add hl, de
ld a, [wBadgeOrFaceTiles]
call .PlaceTiles
add hl, de
call .PlaceTiles

(...)

.PlaceTiles2
ld [hli], a
inc a
ld [hl], a
inc a
cp $60 + 11
ret z
cp $60 + 13
ret z
inc hl
ld [hl], a
inc a
dec hl
ret

Wouldn't be surprised if I had messed something up.

Last edited by Crystal_ (2016-06-17 09:48:29)

Offline

#5 2016-06-17 21:54:28

Montblanc
Member
Registered: 2016-02-23
Post 25/47

Re: Adding Gym leader names to the status screen

Thanks, that worked! Misty's name also uses two tiles, but I figured how to fix it:

huehc2.png

; Names aren't printed if the badge is owned.
ld a, [de]
and a
ld a, [wBadgeNameTile]
jr nz, .SkipName
call .PlaceTiles2
jr .PlaceBadge

.SkipName
inc a
inc a
cp $60 + 5
jr z, .ok1
cp $60 + 10
jr z, .ok1
cp $60 + 12
jr z, .ok1
inc a
.ok1
inc hl

.PlaceBadge
ld [wBadgeNameTile], a
ld de, SCREEN_WIDTH - 1
add hl, de
ld a, [wBadgeOrFaceTiles]
call .PlaceTiles
add hl, de
call .PlaceTiles


(...)


.PlaceTiles2
ld [hli], a
inc a
ld [hl], a
inc a
cp $60 + 5
ret z
cp $60 + 10
ret z
cp $60 + 12
ret z
inc hl
ld [hl], a
inc a
dec hl
ret

Now I only have to port the new code to the other ROMs using the hex editor and it's done.

Offline

#6 2016-08-05 02:36:21

Montblanc
Member
Registered: 2016-02-23
Post 36/47

Re: Adding Gym leader names to the status screen

Edit: Sorry, it was something not related with the changes on the code as I thought.

Last edited by Montblanc (2016-08-05 03:07:06)

Offline

Board footer

Powered by FluxBB