Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2016-04-04 23:33:24

Picrodus
New member
Registered: 2015-03-22
Post 4/9

Sprite Bank Repointing Problems

Hi skeetendo. I am working on a hack of pokemon yellow and am trying to insert asm code. I am doing this because I am trying to be able to repoint pokemon sprites to different banks when weither they cannot fit over the original sprite or there is not enough free space in the bank to repoint to.

I'm trying to use this code and tried to compile it in Gameboy Assembler Plus:

ld a, [$CF91] ; get Pokemon id
ld b, a ; store Pokemon id
cp $B6 ; check if id = Kabutops fossil
ld a, $0B ; store bank of fossil sprite
jr z, $11 ; jump forward 0x11 bytes if z-flag is set (if id = Kabutops fossil)
ld a, b ; restore id into a
cp $B7 ; check if id = Aerodactyl fossil
ld a, $0D ; store bank of fossil sprite
jr z, $0A ; jump forward 0xA bytes if z-flag is set (if id = Aerodactyl fossil)
ld a, b ; restore id into a
cp $B8 ; check if id = Ghost
ld a, $0D ; store bank of ghost sprite
jr z, $03 ; jump forward 0x3 bytes if z-flag is set (if id = Ghost)
ld a, [$D0D3] ; load bank from last byte of current Pokemon's base stats
jp [$24FD] ; end


But then I get an error saying assemble failed with 12 errors and that there are unknown opcodes on all 15 lines.

So first of all, I do not know how to fix this. And even if I did I wouldn't know how or where to insert the custom ASM into the rom. But I would know how to repoint the sprite data using the routine.

Any help would be appreciated. Thank you.

Last edited by Picrodus (2016-04-04 23:34:41)

Offline

#2 2016-04-06 08:15:18

Miksy91
Member
Registered: 2010-10-16
Post 2,249/2,305

Re: Sprite Bank Repointing Problems

You could try debugging the game and find out that way how the sprites are currently loaded and so modify the routine once you have found the position where you could write your own code. Taking a look at pokered disassembly might help as well unless sprites are loaded in a different way in RB than in Yellow.

Also in case you can't insert the code using assembler plus, write it using Gameboy Asm Editor (found in romhacking.net) instead.

Offline

#3 2016-04-08 09:01:08

Picrodus
New member
Registered: 2015-03-22
Post 7/9

Re: Sprite Bank Repointing Problems

Hi Miksy, thanks for the suggestions. I found the code written in assembly at  ROM0 1413.

I think I have figured out how to insert code, however, I believe the offsets for the ASM to execute must be off.

Original Code:

Pokémon R/B      Pokémon Yellow

ld a, [$CF91]      ld a,[$CF90]
ld b, a                ld b, a
cp a, $15            cp a, $B6
ld a, $01             ld a, $0B
jr z, $25              jr z, $143B
ld a, b                 ld a, b
cp a, $B6            cp a, $1F
ld a, $0B             ld a, $09
jr z, $1E              jr c, $143B
ld a, b                 ld a, b
cp a, $1F             cp a, $4A
ld a, $09              ld a, $0A
jr c, $17               jr c, $143B
ld a, b                  ld a, b
cp a, $4A             cp a, $74
ld a, $0A              ld a, $0B
jr c, $10               jr c, $143B   
ld a, b                  ld a, b
cp a, $74             cp a, $99     
ld a, $0B              ld a, $0C
jr c, $09               jr c, $143B
ld a, b                  ld a, $0D
cp $99                 jp $23F8   
ld a, $0C     
jr c, $02     
ld a, $0D     
jp $24FD


It seems that the ASM code for loading sprites is different in Yellow. The code to swap to in my first post came from this thread: https://hax.iimarck.us/topic/2253/

So I know the code is good for Red and Blue because it was done by experienced hackers. My problem is that I am having difficulties transferring it over to Yellow. Because if I do not figure this out, I will soon run out of room to repoint custom sprites to in the ROM banks.

Offline

#4 2016-04-08 15:29:00

Miksy91
Member
Registered: 2010-10-16
Post 2,250/2,305

Re: Sprite Bank Repointing Problems

Alright,

Well, what you could basically do is simply to stop execution of the game with BGB's debugger at 00:1413 (by setting a breakpoint to that address), enter a battle, and the game should stop execution. Once you have done that, look with BGB's memory viewer, where the base stats of the pokemon (whose ID matches the value in address $CF90) are loaded into (if it works the same way it does in RB), and if the last byte of the base stats in ram is unused in Yellow as well, just use the address of that byte instead of $D0D3 in the code.
Once you have done that, you need to explicitly write that rom bank value for every in-game pokemon to their base stats and it should work.

If doing this is "impossible" (= that data is not loaded into ram at the moment, or the last byte is actually used in one way or another), you need to use some other way to get around this problem.

Last edited by Miksy91 (2016-04-08 15:30:14)

Offline

Board footer

Powered by FluxBB