Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2012-09-28 16:43:33

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

[Gold] 2bpp Borders

xfTD492wTRHHIzLisuqLOhrM5tYn0xg4G7yuIjhoQOeaJFw2CryhRdWhVkoKHhdc

I changed the amount of color for borders to 2bpp (4 colors) and now every other border is a border made of incorrectly placed border tiles.
Does anyone know what I may have did wrong here?


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

Offline

#2 2012-09-28 18:44:38

Miksy91
Member
Registered: 2010-10-16
Post 1,121/2,317

Re: [Gold] 2bpp Borders

The game still looks for the border graphics in the original rom locations if you haven't done a thing about it.

Offline

#3 2012-09-28 23:49:30

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

Re: [Gold] 2bpp Borders

I have already repointed the graphics to B0000 in the ROM.


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

Offline

#4 2012-09-29 05:32:24

Miksy91
Member
Registered: 2010-10-16
Post 1,122/2,317

Re: [Gold] 2bpp Borders

Heck, that's what I didn't mean to say actually...
Your issue is most likely with VRAM (where the border graphics are stored). If the border graphics are still looked for in the same ram locations as before, it might lead this looking like what it currently does.

Offline

#5 2012-09-29 09:27:43

Sawakita
Administrator
Registered: 2010-10-16
Post 301/364

Re: [Gold] 2bpp Borders

munchulax wrote:

I changed the amount of color for borders to 2bpp (4 colors) and now every other border is a border made of incorrectly placed border tiles.
Does anyone know what I may have did wrong here?

munchulax wrote:

I have already repointed the graphics to B0000 in the ROM.

But what about the routine that loads the border graphics to VRAM? Did you edit the game to use the routine that deals with 2bpp format instead of the 1bpp loading routine? From your screenshots this really seem to be the most likely reason.

1bpp graphics, as the name suggests, takes half as much space than 2bpp graphics; though, since Game Boy video hardware only understands the latter format, the games convert 1bpp data to 2bpp format "on-the-fly" when it needs to load it to VRAM.
This conversion simply consist of adding a second layer that is exactly a copy of the first (which is the only layer in 1bpp data).

1BPP DATA:
                1 2 3 4 5 6 7 8 ...
1BPP TO 2BPP DATA:
                1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 ...

Now, as I'm conjecturing that you didn't edit the code to use the correct routine call, what is happening is something like this:

2BPP DATA:
                1A 1B 2A 2B 3A 3B 4A 4B 5A 5B 6A 6B 7A 7B 8A 8B...
2BPP (interpreted as 1bpp) TO 2BPP DATA:
                1A 1A 1B 1B 2A 2A 2B 2B 3A 3A 3B 3B 4A 4A 4B 4B...

Last edited by Sawakita (2012-09-29 10:45:09)

Offline

#6 2012-09-30 03:50:21

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

Re: [Gold] 2bpp Borders

Ah, that makes sense.  But how would I fix it?  That is, what code would I need to change in the ROM?


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

Offline

#7 2012-09-30 17:47:27

Sawakita
Administrator
Registered: 2010-10-16
Post 302/364

Re: [Gold] 2bpp Borders

First, I'd like you to explain more throughly what edits you exactly did, you just said that you put 2bpp graphics (thus twice as large than the original one) in a different bank than the original graphics data.
You clearly edited the pointers, since you managed to display different border graphics than the original ones (you didn't overwrite existing graphics, did you?). So, if you edited the pointers you knew where the code about them was. Therefore, if all my suppositions are correct, you should also know about the code that loads these graphics.

But since you're asking what code you need to change, it really looks like my suppositions are in fact wrong and you don't know where the code and even the pointers are. Please, explain exactly all the changes you made (and whether you just hex edited the ROM, or used one of "those" tools), concerning border graphics data, pointers and loading routines.

Then, we can start from there.

Offline

#8 2012-09-30 19:03:44

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 1,608/3,508

Re: [Gold] 2bpp Borders

If I had to guess, it was done based on this, from the Useful offsets thread:

Mateo wrote:

Editing the font

0xF8001 - 2byte pointer to Font Graphics
0xF8008 - Byte tells which bank font is in
0xF800A - 8D 1bpp 72 - 2Bpp

Ever wonder how Coolboyman made the font in Prism have a shadow behind it? Now you can too!
Simply repoint the font to a stretch of blank space, and insert it in TLP. You will want to change it to 2Bpp so the game will load it as a 4-colour graphic, instead of a 2-colour graphic as it does by default.

0xF8049 - 2byte Pointer to Border styles
0xF8055 - Byte tells which bank borders are in
0xF8057 - 8D 1bpp 72 - 2Bpp

These are the same as the font, but can be done independently. ie- you can have a 4-colour font, but still keep the normal 2-colour borders, or vice-versa.

Which means I probably am going to have to update the thread soon once we figure this out.

Last edited by Mateo (2012-09-30 19:04:22)

Offline

#9 2012-09-30 19:24:36

Sawakita
Administrator
Registered: 2010-10-16
Post 303/364

Re: [Gold] 2bpp Borders

Thanks Mateo, that makes sense now.

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.

What you're missing is to edit value loaded into BC to be twice as it is originally (0x30 -> 0x60), which is seemingly the number of bytes to copy.

Last edited by Sawakita (2012-09-30 19:30:52)

Offline

#10 2012-09-30 20:58:32

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

Re: [Gold] 2bpp Borders

Wow, that actually made sense.  Fixed the problem now, and thanks for posting the rest of the frames ASM code too, it helped me understand assembly a bit more!

All I had to do was change the instructions at 3E:4045 from:

ld   bc,0030

to

ld   bc,0060

in an assembly editor. 

(Mateo, change the Useful Offsets Thread to reflect this. :D )


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

Offline

#11 2012-09-30 21:03:50

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 1,610/3,508

Re: [Gold] 2bpp Borders

munchulax wrote:

(Mateo, change the Useful Offsets Thread to reflect this. :D )

Will do!

Offline

Board footer

Powered by FluxBB