Banner
Views: 772,996,474
Time:
11 users online: Amine Retro, AntiDuck,  BeeKaaaay, DDCecil,  Falconpunch, GamecraftOriginal, gohkenytp111, GreenHammerBro,  Ninja Boy, placeholdertest, SonicChaser - Guests: 82 - Bots: 190Users: 40,597 (1,832 active)
Latest: Arreme
Tip: Read the F.A.Q. before/after registering.Not logged in.
[SOLVED] Remapping a sprite with a hex edit.
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - [SOLVED] Remapping a sprite with a hex edit.
Pages: « 1 »
I have been using Stear and yychr to remap sprites, and that has been working fine.

However, I am trying to figure how to remap sprites manually with a patch so that I can do it on a level by level basis using UberASM.

The problem is I keep running into walls trying to figure it out.

The info that I have found is the following:

1. The 'T' bit in YXPPCCCT dictates if the sprite is in SP1 and SP2 OR SP3 and SP4.

2. Tiles 00-7F: SP1 (SP3 if the "Use second graphics page" is checked)
Tiles 80-FF: SP2 (SP4 if the "Use second graphics page" is checked)

3. In the ROM map I have found addresses for tilemap info for various sprites. Ex. ($02B92D is Torpedo Ted's face)

My problem is that when I look at these addresses in a hex editor, I can't make any correlation between the values at these addresses and the tile's position in the sprite page.

Any help would be appreciated. I'm sure that I'm going about this wrong.


For what it's worth, it may be more helpful to look at the value in a disassembly rather than a hex editor. I have a commented version of banks 1-3 (which covers all of the sprites) over here that may help.

If you look near that address for the Torpedo Ted's face, you'll see it's not actually a table, but a single value:
Code
    LDA.b #$80                  ;$02B92C    |\\ Tile to use for the torpedo's head.

If you go to a level in LM with the Torpedo Ted graphics (e.g. 11), you'll see that the Ted is indeed at tile 0x80:



Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Yes. I have been told that using a sprite disassembly is the way to go. This is mainly a learning experiment for me. I really would like to understand this.

I still don't get it. I made the following patch:

Code
org $02B92C
db #$E2


According to Lunar Magic, The dolphin's head is #$E2. But in the game, Torpedo Ted's head is not a dolphin at all! It is a garbled mess.

What am I missing here?
You're close, but it looks like your org address is off by one byte. $02B92C is the location of the LDA opcode rather than the tile value for Torpedo Ted's face. The byte immediately following this is the correct location.

--------------------


So is this just not doable at runtime?

This is my UberASM:

Code
load:

	pushpc
	
	;Torpedo Ted (hand closed)
	org $029E66
	db #$CA
	;Torpedo Ted (hand open)
	org $029E6A
	db #$EA
	;Torpedo Ted (face)
	org $02B92D
	db #$C6
	;Torpedo Ted (propeller 1)
	org $02B937
	db #$C8
	;Torpedo Ted (propeller 2)
	org $02B93F
	db #$E6
	;Torpedo Ted (propeller 3)
	org $02B943
	db #$C8

	;Spiny1
	org $019BCE
	db #$CC
	;Spiny2
	org $019BCF
	db #$EC
	;Spiny3
	org $019BD0
	db #$CC
	
	pullpc


I get the following error:

105_uber.asm: error: empty assembled file.
Because UberASM is not magic. What you're doing instead is to change the tilemaps globally which is something you don't want. In fact, UberASM doesn't even process the code given it's notibly outside of freespace. The only way to apply local changes is to simply modify the graphics routine. That, or use a disassembly.

--------------------
Okay, my layout looks ugly.
Ok. I admit defeat. I will use disassemblies like literally everyone has been telling me to do.

I'm not having any problem inserting the sprites. They work as intended.

However, I do not see where in this .asm file I can edit the tilemapping.

Code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Torpedo Launcher disassembly, based on 1524's code, modified by Davros, optimized by
;; Blind Devil
;;
;; Description: A disassembly of SMW's sprite CA, which can spawn a configurable sprite.
;;
;; Note that spawned sprites other than Torpedo Teds won't behave properly - you will have
;; to workaround that, or modify sprite codes somehow to include a "being launched" behavior.
;;
;; Extra Bit options:
;; clear: spawn normal sprite
;; set: spawn custom sprite
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Sprite to spawn
!NormSpr = $44
!CustSpr = $BF

;Other defines
!ShowArm = 1		;change this to 0 if you don't want it to display the arm.
!IgnorePlayer = 1	;change this to 0 if you don't want the launcher to spawn sprites when the player is near.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite code JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                    
                    print "INIT ",pc        
                    print "MAIN ",pc
                    PHB                     
                    PHK                     
                    PLB                     
                    JSR SPRITE_CODE_START   
                    PLB                     
                    RTL      

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; main torpedo ted launcher code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SPRITE_CODE_START:
		LDA #$50		;if necessary, restore timer to 50

if !IgnorePlayer
		CLC			;clear carry - ignore mario
else
		SEC			;set carry - don't ignore mario
endif
		%ShooterMain()          ; \ check if time to shoot, return if not. (Y now contains new sprite index)
		BCS RETURN              ; /

		    LDA $1783|!Base2,x      ;load shooter extra bits
		    AND #$40                ;check if set
		    BNE SpawnCustom	    ;if set, spawn custom sprite.

                    LDA #$08                ; \ set sprite status for new sprite
                    STA !14C8,y             ; /
                    LDA #!NormSpr	    ; \ set sprite number for new sprite
                    STA !9E,y		    ; /
		    PHX
		    TYX
                    JSL $07F7D2|!BankB
		    PLX
		    BRA +		    ;branch ahead

SpawnCustom:
		    PHX
		    TYX
                    LDA #$01                ; \ set sprite status for new sprite
                    STA !14C8,x             ; /
                    LDA #!CustSpr	    ; \ set sprite number for new sprite
                    STA !7FAB9E,x	    ; /
                    JSL $07F7D2|!BankB	    ;  | ...and loads in new values for the 6 main sprite tables
                    JSL $0187A7|!BankB
                    LDA #$88                ; \ mark as initialized
                    STA !7FAB10,x           ; /
		    PLX

+
                    LDA $179B|!Base2,x      ; \ set x position for new sprite
                    STA !E4,y		    ;  |
                    LDA $17A3|!Base2,x	    ;  |
                    STA !14E0,y		    ; /
                    LDA $178B|!Base2,x	    ; \ set y position for new sprite
                    STA !D8,y		    ;  |
                    LDA $1793|!Base2,x	    ;  |
                    STA !14D4,y             ; /
                    PHX                     ; \ before: X must have index of sprite being generated
                    TYX                     ;  | routine clears *all* old sprite values...

                    %SubHorzPos()	    ;  |
                    TYA                     ;  |
                    STA !157C,x             ;  |

                    LDA #$30                ;  |
                    STA !1540,x             ;  |
                    PLX                     ;  |

if !ShowArm
		    JSR SUB_HAND
endif

RETURN:
		    RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; display hand for torpedo ted launcher
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if !ShowArm
SUB_HAND:           LDY #$07                ; \ find a free slot to display effect
FINDFREE:           LDA $170B|!Base2,y      ;  |
                    BEQ FOUNDONE            ;  |
                    DEY                     ;  |
                    BPL FINDFREE            ;  |
                    RTS                     ; / return if no slots open

FOUNDONE:           LDA #$08                ; \ set effect graphic to hand graphic
                    STA $170B|!Base2,y      ; /
                    LDA $179B|!Base2,x      ; \
                    CLC                     ;  |
                    ADC #$08                ;  |
                    STA $171F|!Base2,y      ;  |
                    LDA $17A3|!Base2,x      ;  |
                    ADC #$00                ;  |
                    STA $1733|!Base2,y      ;  |
                    LDA $178B|!Base2,x      ;  |
                    SEC                     ;  |
                    SBC #$09                ;  |
                    STA $1715|!Base2,y      ;  |
                    LDA $1793|!Base2,x      ;  |
                    SBC #$00                ;  |
                    STA $1729|!Base2,y      ;  |
                    LDA #$90                ;  |
                    STA $176F|!Base2,y      ;  |
		    LDA #$00		    ;  |
                    STA $1747|!Base2,y      ; /
                    RTS                     ; return
endif
that looks like the generator, rather than the actual sprite you need to edit

--------------------
~<3
Pages: « 1 »
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - [SOLVED] Remapping a sprite with a hex edit.

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2019 - SMW Central
Legal Information - Privacy Policy - Link To Us


Total queries: 9

Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Talkhaus
  • SMBX Community
  • GTx0
  • Super Luigi Bros
  • ROMhacking.net
  • MFGG
  • Gaming Reinvented