Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2013-04-27 03:38:45

ShaneM
Member
From: United States (USA)
Registered: 2013-03-11
Post 21/287
Website

Z80 Question to Assist my PKMN GREEN Hack - Concerning OAM

Before you answer, please READ this:

This is a serious topic, so please refrain from negative comments and lets be professional about this. If you do not know Z80 at all that's fine, I will make a separate thread to comment on my upcoming hack, but not here. If you leave senseless comments, well, how would that look after me writing this?

On to the OAM question:

How does one find OAM for this in a disassemble?

Here are pics specifically for what:

English
0d96eed6-0404-4140-971d-9797961d377e_zpsd303fa80.jpg

Japanese
ba3af468-258a-43e0-abc9-3c2f142bf3c2_zpscc38b5e1.jpg


I have found this in the disassemble:

; calculates the OAM data for all currently visible sprites and writes it to $c300
PrepareOAMData: ; 4b0f (1:4b0f)
    ld a, [$cfcb]
    dec a
    jr z, .asm_4b1e
    cp $ff
    ret nz
    ld [$cfcb], a
    jp ResetLCD_OAM
.asm_4b1e
    xor a
    ld [$FF00+$90], a
.asm_4b21
    ld [$FF00+$8f], a
    ld d, $c1
    ld a, [$FF00+$8f]
    ld e, a
    ld a, [de]         ; c1x0
    and a
    jp z, .asm_4bad
    inc e
    inc e
    ld a, [de]         ; c1x2 read combined orientation and animation info
    ld [$d5cd], a
    cp $ff
    jr nz, .spriteVisible   ; $ff -> offscreen, don't draw
    call Func_4bd1
    jr .asm_4bad

Also:

ld d, $c3                ; $c300+x is buffer for OAM data
.spriteTilesLoop             ; loops 4 times for the 4 tiles a sprite consists of
    ld a, [$FF00+$92]        ; temp for sprite Y position
    add $10                  ; Y=16 is top of screen (Y=0 is invisible)
    add [hl]                 ; add Y offset from table
    ld [de], a               ; write new sprite OAM Y position
    inc hl
    ld a, [$FF00+$91]        ; temp for sprite X position
    add $8                   ; X=8 is left of screen (X=0 is invisible)
    add [hl]                 ; add X offset from table
    inc e
    ld [de], a               ; write new sprite OAM X position
    inc e
    ld a, [bc]               ; read pattern number offset (accomodates orientation (offset 0,4 or 8) and animation (offset 0 or $80))
    inc bc
    push bc
    ld b, a
    ld a, [$d5cd]            ; temp copy of c1x2
    swap a                   ; high nybble determines sprite used (0 is always player sprite, next are some npcs)
    and $f
    cp $b                    ; sprites $a and $b have no orientation or animation and therefore only 4 tiles
    jr nz, .calcTileOffset   ; (instead of 12), so tile b's offset is a special case
    ld a, $7c                ; = $a * 12 + 4
    jr .doneCalcTileOffset

This is how OAM's are loaded routine-wise, but I cannot even locate the trainer's sprite OAM routine found on the Title Screen in my disassemble. I have tried to trace it in RAM using BGB's debugger at $FE00, no luck. If somebody knows what the label for this is in the disassemble, or understands how the OAM works, please share, as I would like to finish my localized Green into English.

The X/Y Axis appear to be in Little Endian, while the attribute and Tile no. aren't. In the disassemble by iiMarkus I am at line 11543. Thanks.

@Comet I could really use some of your wisdom here if you can share anything. :)


I'm back. I'll try not to get as frustrated with stupid questions. People on my naughty list:

*Pokemon_Master
*Noizy
*lipun
*Spambots

Offline

#2 2013-04-27 17:51:42

ShaneM
Member
From: United States (USA)
Registered: 2013-03-11
Post 22/287
Website

Re: Z80 Question to Assist my PKMN GREEN Hack - Concerning OAM

I hear hacking GB's OAM is one of the most difficult things to do... let me rephrase my question: has anybody on here successfully hacked OAM? How did you do it? Be serious, please.


I'm back. I'll try not to get as frustrated with stupid questions. People on my naughty list:

*Pokemon_Master
*Noizy
*lipun
*Spambots

Offline

Board footer

Powered by FluxBB