Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2014-08-11 13:51:30

halcyon
Member
Registered: 2013-10-14
Post 9/11

[Red] Skipping the Decompression

I'm working on a hack of Red and I want to add some extra Pokemon sprites to the game. I decided that I don't want to use any tools to handle compression (I rather learn something than be spoon-fed) and there isn't any reason to learn the compression algorithm, as I can always increase the size of the ROM if I need to.

What I have done so far:

1. I have modified the game so that the last byte in a Pokemon's base stats is the bank that the sprite is located in.

2. I have added the uncompressed front and back sprites of Bulbasaur, Charmander and Squirtle to bank 2D.

3. Thanks to this thread about backsprites that after the sprite is decompressed it is load to a space in SRAM that is begins at $A188. Then I have to use CopyData or FarCopyData to move the sprite to VRAM 9000 or 9310.

Can't I just write a routine that will take the rom bank and pointer to a sprite and load the sprite directly to the appropriate VRAM location? Copy the sprite from its ROM location to $9000 or $9310 and then to $8000? And how does the game know when to stop loading the sprite (I'm assuming that this is all loaded one byte at a time)?

Last edited by halcyon (2014-08-11 15:20:12)

Offline

#2 2014-08-21 00:00:14

halcyon
Member
Registered: 2013-10-14
Post 10/11

Re: [Red] Skipping the Decompression

Sorry to double post, but I'm still having some problems with this and I want to bump this thread.

I've made some headway on this. I have replaced the UncompressMonSprite routine with the following routine:

ld a,$0a
ld [$0000],a     ;enable SRAM
ld a,[$d0c2]     ;get sprite dimensions
cp a,$55          ;get sprite size in bytes that corresponds to the dimensions
ld bc,$0190
jr z,$1640
cp a,$66
ld bc,$0240
jr z,$1640
ld bc,$0310
ld a,[$d0c3]     ;loads pointer of the sprite that will be copied into a:hl into hl
ld l,a
ld a,[$d0c4]
ld h,a
ld de,$a188     ;gets location to copy to
ld a,[$d0d3]    ;bank to copy sprite from
call $009d (FarCopyData)
ret

The result is still an unintelligible mess. I've debugged the code, and I know that it successfully copies the sprite data from a:hl to $a188. I know that from here the image is centered and loaded to the appropriate VRAM location, but something in between is going wrong. Does anyone know what that is?

EDIT: Apparently sprites are normally decompressed into 2 1bpp 'chunks' rather than into a 2bpp sprite, so I need to skip the merging ($16ea) and write directly to VRAM. I have since added more to the above code:

;After the 2bpp sprite is loaded into $a188

ld hl,$9000 ;prepares for CopyVideoData
ld c,$31     
xor a,a
ld b,a
ld de,$a188
jp $1848    ;CopyVideoData

In LoadMonFrontSprite ($1665), a ret command has been placed immediately after what used to be UncompressMonSprite. Now the game just crashes upon trying to load Pokemon sprites.

I'm really quite shocked that no one has anything to say on this.

EDIT2:

Success!

success_zps2ece5d07.png

Last edited by halcyon (2014-08-23 16:38:11)

Offline

Board footer

Powered by FluxBB