News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Donkey Kong Country map screen sprite  (Read 2812 times)

Raccoon Sam

  • Jr. Member
  • **
  • Posts: 58
  • Left is Right and Right is Wrong
    • View Profile
    • Twitter
Donkey Kong Country map screen sprite
« on: March 20, 2017, 07:17:26 am »
In Donkey Kong Country, as you progress, the ship of the final boss starts approaching, inching closer to the island with every world you beat. The ship itself is a sprite.

I am working on a hack and this is one of the only few things I can't figure out. How do I change the position (and the graphics/OAM attributes) of these ship sprites?

I can run NO$SNS and Geiger's SNES9X debugger, if that helps.
« Last Edit: March 23, 2017, 11:55:31 am by Raccoon Sam »

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6927
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Donkey Kong Country map screen sprite
« Reply #1 on: March 20, 2017, 03:14:12 pm »
I never noticed that before. :o
"My watch says 30 chickens" Google, 2018

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Donkey Kong Country map screen sprite
« Reply #2 on: March 20, 2017, 09:17:54 pm »
Used a combination of bsnes plus 073.3a (oam debugger) and geiger (trace log).

Messy notes below:
Spoiler:
Code: [Select]
$80/E601 D0 23       BNE $23    [$E626]      A:0000 X:03B4 Y:0004 P:envmxdIZC
$80/E603 A5 4C       LDA $4C    [$00:004C]   A:0000 X:03B4 Y:0004 P:envmxdIZC
$80/E605 99 11 0D    STA $0D11,y[$80:0D15]   A:1818 X:03B4 Y:0004 P:envmxdIzC
$80/E608 A9 02 00    LDA #$0002              A:1818 X:03B4 Y:0004 P:envmxdIzC
$80/E60B 99 45 0D    STA $0D45,y[$80:0D49]   A:0002 X:03B4 Y:0004 P:envmxdIzC
$80/E60E A9 2C 00    LDA #$002C              A:0002 X:03B4 Y:0004 P:envmxdIzC
$80/E611 99 19 0B    STA $0B19,y[$80:0B1D]   A:002C X:03B4 Y:0004 P:envmxdIzC
$80/E614 A9 74 01    LDA #$0174              A:002C X:03B4 Y:0004 P:envmxdIzC
$80/E617 99 C1 0B    STA $0BC1,y[$80:0BC5]   A:0174 X:03B4 Y:0004 P:envmxdIzC
$80/E61A A9 00 00    LDA #$0000              A:0174 X:03B4 Y:0004 P:envmxdIzC
$80/E61D 99 8D 0B    STA $0B8D,y[$80:0B91]   A:0000 X:03B4 Y:0004 P:envmxdIZC

==> ship oam attribute
$80/E620 A9 E0 20    LDA #$20E0              A:0000 X:03B4 Y:0004 P:envmxdIZC
$80/E623 99 69 0C    STA $0C69,y[$80:0C6D]   A:20E0 X:03B4 Y:0004 P:envmxdIzC

$80/E626 A9 00 02    LDA #$0200              A:20E0 X:03B4 Y:0004 P:envmxdIzC
$80/E629 8D 1A 05    STA $051A  [$80:051A]   A:0200 X:03B4 Y:0004 P:envmxdIzC
$80/E62C A9 02 00    LDA #$0002              A:0200 X:03B4 Y:0004 P:envmxdIzC
$80/E62F 8D 1B 05    STA $051B  [$80:051B]   A:0002 X:03B4 Y:0004 P:envmxdIzC
$80/E632 64 28       STZ $28    [$00:0028]   A:0002 X:03B4 Y:0004 P:envmxdIzC


Code: [Select]
ship oam in ram
bbabbf sta $00,x     [000228] A:001b X:0228 Y:0008 S:01f8 D:0000 DB:bb nvMxdIZC V:  7 H:311 F:55
bbabbf sta $00,x     [00022c] A:0023 X:022c Y:000a S:01f8 D:0000 DB:bb nvMxdIZC V:  8 H:147 F:55
bbabbf sta $00,x     [000230] A:0021 X:0230 Y:000c S:01f8 D:0000 DB:bb nvMxdIZC V:  8 H:315 F:55
bbabbf sta $00,x     [000234] A:0021 X:0234 Y:000e S:01f8 D:0000 DB:bb nvMxdIZC V:  9 H:151 F:55
bbabbf sta $00,x     [000238] A:0028 X:0238 Y:0010 S:01f8 D:0000 DB:bb nvMxdIZC V:  9 H:319 F:55



Code: [Select]
===> some type of ptr table
$BB/A890 BF 9C CC BB LDA $BBCC9C,x[$BB:DF50] A:12B4 X:12B4 Y:0002 P:envmxdIzc
$BB/A894 85 5A       STA $5A    [$00:005A]   A:FB70 X:12B4 Y:0002 P:eNvmxdIzc
$BB/A896 1A          INC A                   A:FB70 X:12B4 Y:0002 P:eNvmxdIzc
$BB/A897 85 5E       STA $5E    [$00:005E]   A:FB71 X:12B4 Y:0002 P:eNvmxdIzc

$BB/A899 BF 9E CC BB LDA $BBCC9E,x[$BB:DF52] A:FB71 X:12B4 Y:0002 P:eNvmxdIzc
$BB/A89D 85 5C       STA $5C    [$00:005C]   A:00D9 X:12B4 Y:0002 P:envmxdIzc
$BB/A89F 85 60       STA $60    [$00:0060]   A:00D9 X:12B4 Y:0002 P:envmxdIzc



Code: [Select]
$BB/A944 20 DF AA    JSR $AADF  [$BB:AADF]   A:0050 X:12B4 Y:0002 P:envmxdIzC
bba947 bra $a98a     [bba98a] A:00e0 X:023c Y:0012 S:01fa D:0000 DB:bb NvmxdIzc V: 10 H:151 F:42

===> subroutine

$BB/AADF A0 00 00    LDY #$0000              A:0050 X:12B4 Y:0002 P:envmxdIzC
$BB/AAE2 B7 5A       LDA [$5A],y[$D9:FB70]   A:0050 X:12B4 Y:0000 P:envmxdIZC
$BB/AAE4 85 50       STA $50    [$00:0050]   A:0001 X:12B4 Y:0000 P:envmxdIzC
$BB/AAE6 A0 02 00    LDY #$0002              A:0001 X:12B4 Y:0000 P:envmxdIzC
$BB/AAE9 B7 5A       LDA [$5A],y[$D9:FB72]   A:0001 X:12B4 Y:0002 P:envmxdIzC
$BB/AAEB 85 52       STA $52    [$00:0052]   A:0000 X:12B4 Y:0002 P:envmxdIZC
$BB/AAED A0 04 00    LDY #$0004              A:0000 X:12B4 Y:0002 P:envmxdIZC
$BB/AAF0 B7 5A       LDA [$5A],y[$D9:FB74]   A:0000 X:12B4 Y:0004 P:envmxdIzC
$BB/AAF2 85 54       STA $54    [$00:0054]   A:0200 X:12B4 Y:0004 P:envmxdIzC
$BB/AAF4 A0 06 00    LDY #$0006              A:0200 X:12B4 Y:0004 P:envmxdIzC
$BB/AAF7 B7 5A       LDA [$5A],y[$D9:FB76]   A:0200 X:12B4 Y:0006 P:envmxdIzC
$BB/AAF9 85 56       STA $56    [$00:0056]   A:0210 X:12B4 Y:0006 P:envmxdIzC

..

main oam x,y area - actual data for ship
bbab9a dec $51       [000051] A:20e0 X:022c Y:000a S:01f8 D:0000 DB:bb nvMxdIzC V:  8 H: 40 F:42
bbab9c bmi $abef     [bbabef] A:20e0 X:022c Y:000a S:01f8 D:0000 DB:bb nvMxdIzC V:  8 H: 49 F:42

bbab9e lda [$5e],y   [f7fe63] A:20e0 X:022c Y:000a S:01f8 D:0000 DB:bb nvMxdIzC V:  8 H: 52 F:42
bbaba0 rep #$20               A:2053 X:022c Y:000a S:01f8 D:0000 DB:bb nvMxdIzC V:  8 H: 62 F:42
bbaba2 and #$00ff             A:2053 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H: 67 F:42
bbaba5 clc                    A:0053 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H: 71 F:42
bbaba6 adc $92       [000092] A:0053 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzc V:  8 H: 74 F:42
bbaba8 cmp #$00f0             A:006f X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzc V:  8 H: 81 F:42
bbabab bcs $abe7     [bbabe7] A:006f X:022c Y:000a S:01f8 D:0000 DB:bb NvmxdIzc V:  8 H: 86 F:42
bbabad sbc #$000f             A:006f X:022c Y:000a S:01f8 D:0000 DB:bb NvmxdIzc V:  8 H: 89 F:42
bbabb0 sta $01,x     [00022d] A:005f X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H: 93 F:42

bbabb2 lda [$5a],y   [f7fe62] A:005f X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:102 F:42
bbabb4 and #$00ff             A:5378 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:114 F:42
bbabb7 clc                    A:0078 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:118 F:42
bbabb8 adc $90       [000090] A:0078 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzc V:  8 H:121 F:42
bbabba bit #$0100             A:0023 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:128 F:42
bbabbd sep #$20               A:0023 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIZC V:  8 H:133 F:42
bbabbf sta $00,x     [00022c] A:0023 X:022c Y:000a S:01f8 D:0000 DB:bb nvMxdIZC V:  8 H:147 F:42
bbabc1 beq $abdd     [bbabdd] A:0023 X:022c Y:000a S:01f8 D:0000 DB:bb nvMxdIZC V:  8 H:154 F:42
..

bbabdd rep #$20               A:0023 X:022c Y:000a S:01f8 D:0000 DB:bb nvMxdIZC V:  8 H:158 F:42
bbabdf lda $4e       [00004e] A:0023 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIZC V:  8 H:163 F:42
bbabe1 sta $02,x     [00022e] A:20e1 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:170 F:42
bbabe3 inx                    A:20e1 X:022c Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:178 F:42
bbabe4 inx                    A:20e1 X:022d Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:181 F:42
bbabe5 inx                    A:20e1 X:022e Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:184 F:42
bbabe6 inx                    A:20e1 X:022f Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:187 F:42
bbabe7 inc $4e       [00004e] A:20e1 X:0230 Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:190 F:42
bbabe9 sep #$20               A:20e1 X:0230 Y:000a S:01f8 D:0000 DB:bb nvmxdIzC V:  8 H:203 F:42
bbabeb iny                    A:20e1 X:0230 Y:000a S:01f8 D:0000 DB:bb nvMxdIzC V:  8 H:207 F:42
bbabec iny                    A:20e1 X:0230 Y:000b S:01f8 D:0000 DB:bb nvMxdIzC V:  8 H:210 F:42
bbabed bra $ab9a     [bbab9a] A:20e1 X:0230 Y:000c S:01f8 D:0000 DB:bb nvMxdIzC V:  8 H:213 F:42


F7:FE58 = data for stage2 ship  (1st time visible)
00 05 00 00
00 05 00 00

5 x,y tile data:
70 61
78 53
76 5a
76 62
7d 60

It does some x,y delta on these values from somewhere. Hope that's enough to get you started.

Raccoon Sam

  • Jr. Member
  • **
  • Posts: 58
  • Left is Right and Right is Wrong
    • View Profile
    • Twitter
Re: Donkey Kong Country map screen sprite
« Reply #3 on: March 21, 2017, 03:12:25 am »
Thanks so much!


salvadorc17

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Donkey Kong Country map screen sprite
« Reply #4 on: March 21, 2017, 04:23:09 pm »
I am working on a hack and this is one of the only few things I can't figure out. How do I change the position (and the graphics/OAM attributes) of these ship sprites?


Cool youre working on hack for this game, do you have used editor for levels?

Raccoon Sam

  • Jr. Member
  • **
  • Posts: 58
  • Left is Right and Right is Wrong
    • View Profile
    • Twitter
Re: Donkey Kong Country map screen sprite
« Reply #5 on: March 21, 2017, 06:06:13 pm »
Cool youre working on hack for this game, do you have used editor for levels?
I've done some small fixes with dkEdit (via WINE) but I've written most of the tools on my own (and used a hex editor a lot) because the level format is dead simple and I only have a Mac and I can't run DKCRE.
I've still got to figure out a few things about the bananas, a certain map screen problem and some stuff about the camera coordinates but you should expect a release in a month or so I guess.

EDIT:
Gah, still a bit lost. Those five byte groups do make the X and Y coordinates of the individual tiles, but they're only single byte and can be from $00 to $FF. I've laid out the coordinate bounds of the tiles in blue and the game map area in white.

Therefore, even if I set the tiles' X to $FF, I can only reach the right edge of the blue area.

I'm not very good with Assembly, so I really don't know what to do. Am I supposed to put a read breakpoint to 0x37FE60 (the first tile's X byte) and ... do something?
« Last Edit: March 21, 2017, 08:10:40 pm by Raccoon Sam »

Bregalad

  • Hero Member
  • *****
  • Posts: 2648
    • View Profile
Re: Donkey Kong Country map screen sprite
« Reply #6 on: March 22, 2017, 04:22:50 pm »
I never noticed that before. :o
Neither did I !

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Donkey Kong Country map screen sprite
« Reply #7 on: March 22, 2017, 09:13:36 pm »
Updated notes.

Code: [Select]
$80/E608 A9 02 00    LDA #$0002              A:1818 X:03B4 Y:0004 P:envmxdIzC
$80/E60B 99 45 0D    STA $0D45,y[$80:0D49]   A:0002 X:03B4 Y:0004 P:envmxdIzC

x-delta  [ex. 5c = ship +48 pixels right]
$80/E60E A9 2C 00    LDA #$002C              A:0002 X:03B4 Y:0004 P:envmxdIzC
$80/E611 99 19 0B    STA $0B19,y[$80:0B1D]   A:002C X:03B4 Y:0004 P:envmxdIzC

y-delta  [ex. 01b4 = ship +64 pixels upward]
$80/E614 A9 74 01    LDA #$0174              A:002C X:03B4 Y:0004 P:envmxdIzC
$80/E617 99 C1 0B    STA $0BC1,y[$80:0BC5]   A:0174 X:03B4 Y:0004 P:envmxdIzC

$80/E61A A9 00 00    LDA #$0000              A:0174 X:03B4 Y:0004 P:envmxdIzC
$80/E61D 99 8D 0B    STA $0B8D,y[$80:0B91]   A:0000 X:03B4 Y:0004 P:envmxdIZC

ship oam attribute
$80/E620 A9 E0 20    LDA #$20E0              A:0000 X:03B4 Y:0004 P:envmxdIZC
$80/E623 99 69 0C    STA $0C69,y[$80:0C6D]   A:20E0 X:03B4 Y:0004 P:envmxdIzC

That should help you move that sprite around.

Putting a code breakpoint @ BBAAE2 might help you get the x,y values for other ship sprites.

Raccoon Sam

  • Jr. Member
  • **
  • Posts: 58
  • Left is Right and Right is Wrong
    • View Profile
    • Twitter
Re: Donkey Kong Country map screen sprite
« Reply #8 on: March 23, 2017, 11:55:14 am »
It appears that there are no other x/y values – the same coordinate values are used for all ships.
So now everything seems to work perfectly. Thank you again!!