Language…
6 users online: Cristian Cardoso, fsvgm777, JezJitzu, KoJi, playagmes169, stormitive - Guests: 239 - Bots: 353
Users: 64,795 (2,377 active)
Latest user: mathew

Transforming a sprite



I downloaded Iceguy's Ultimate n00b Boss for use in my hack.

Problem is, it's 32×32, and since I want my boss to be a human, it should be 16×32 (like Mario).

Is there a way to transform the sprite so that it's 16×32?


St. Clair Publications: Where good girls just want to have fun this Christmas!

Other places you can find me: LiveJournal | Last.FM

Yeah. First, change the sprite clipping (in the .cfg file, it's the second byte of the six that are together) to 01 instead of 16. You can use a .cfg editor for this if you like. Second, you'll need to change the sprite's graphics routine. It's kind of long:

Code
PROPERTIES:          
	db $40,$00
TILEMAP:
	db !TopLeft,!TopRight,!BottomLeft,!BottomRight,!WalkTopLeft,!WalkTopRight,!WalkBottomLeft,!WalkBottomRight
        db !TopLeft,!TopRight,!BottomLeft,!BottomRight,!WalkTopLeft,!WalkTopRight,!WalkBottomLeft,!WalkBottomRight
TILEMAP2:
	db !TopLeft2,!TopRight2,!BottomLeft2,!BottomRight2,!WalkTopLeft2,!WalkTopRight2,!WalkBottomLeft2,!WalkBottomRight2
        db !TopLeft2,!TopRight2,!BottomLeft2,!BottomRight2,!WalkTopLeft2,!WalkTopRight2,!WalkBottomLeft2,!WalkBottomRight2
TILEMAP3:
	db !TopLeft3,!TopRight3,!BottomLeft3,!BottomRight3,!WalkTopLeft3,!WalkTopRight3,!WalkBottomLeft3,!WalkBottomRight3
        db !TopLeft3,!TopRight3,!BottomLeft3,!BottomRight3,!WalkTopLeft3,!WalkTopRight3,!WalkBottomLeft3,!WalkBottomRight3
VERT_DISP:          
	db $F0,$F0,$00,$00,$F0,$F0,$00,$00
        db $F0,$F0,$00,$00,$F0,$F0,$00,$00         
HORIZ_DISP:  
	db $F8,$08,$F8,$08,$F8,$08,$F8,$08
	db $08,$F8,$08,$F8,$08,$F8,$08,$F8
Graphics:
	LDA !InvTimer
	CMP #$02
	BCS SkipGFX ; Completely skip if invisible.
	BRA Positive
SkipGFX:
	JMP SkipGFX2
Positive:
	JSR GET_DRAW_INFO
	LDA $1602,x
	STA $03 ; Animation frames -> $03.
	
	LDA $157C,x
	STA $02 ; Direction -> $02.
	BNE NoAdd
	LDA $03
	CLC
	ADC #$08 ; Add displacement if going left.
	STA $03
NoAdd:
	PHX ; Push sprite index.
	LDX #$03 ; Get # of times to go through loop.
Loop2:
	PHX 	; Push it for later..
	TXA
	ORA $03
FaceLeft:
	TAX
	LDA $00
	CLC
	ADC HORIZ_DISP,x ; Apply X displacement ..
	STA $0300,y

	LDA $01
	CLC
	ADC VERT_DISP,x ; .. and Y displacement.
	STA $0301,y

	LDA !InvTimer+9		;\
	ASL A			; |
	PHX			; | Animations involve a pointer.
	TAX			; |
	JMP (PtrPtr,x)		;/
;NOTE - Pointer is used to easily display frames (for future updates)
PtrPtr:
	dw AnimationFrameA 	; 00 ; Normal animation frames (A)
	dw AnimationFrameB 	; 01 ; Normal animation frames (B)
	dw AnimationFrameC 	; 02 ; Normal animation frames (C)
	;dw AnimationExFrame 	; 03 ; Throwing bone/hammer frame

AnimationFrameA:
	PLX
	LDA TILEMAP,x
	BRA DoGfx
AnimationFrameB:
	PLX
	LDA TILEMAP2,x
	BRA DoGfx
AnimationFrameC:
	PLX
	LDA TILEMAP3,x
	BRA DoGfx
DoGfx:
	STA $0302,y

	LDX $02 ; X is already preserved, so no need to push it again.
	LDA PROPERTIES,x
	LDX $15E9
	ORA $15F6,x
	ORA $64 ; Add in property byte.
	STA $0303,y

	LDA #!DoFlash ; Skip flashing if we're not allowed.
	CMP #$01
	BNE NoFlashing

	LDA !Flash,x
	BEQ NoFlashing ; Sprite flashes when jumped on.
	LDA $14
	AND #$07 ; 7 frames ..
	TAX ; -> X.
	LDA $0303,y
	AND #$F1
	ORA FlashTable,x
	STA $0303,y
NoFlashing:

	PLX ; Pull #$03.

	INY
	INY
	INY
	INY
	DEX ; Decrease it for every 16x16 tile drawn.
	BPL Loop2

	PLX
	LDY #$02
	LDA #$03
	JSL $01B7B3
SkipGFX2:	
	RTS


You need to make it draw only 2 tiles instead of 4. I'd change the graphics routine to this:

Code
TILEMAP:
	db !Top,!Bottom,!WalkTop,!WalkBottom
TILEMAP2:
	db !Top2,!Bottom2,!WalkTop2,!WalkBottom2
TILEMAP3:
	db !Top3,!Bottom3,!WalkTop3,!WalkBottom3
VERT_DISP:          
	db $F0,$F0,$00,$00       

Graphics:
	LDA !InvTimer
	CMP #$02
	BCS SkipGFX ; Completely skip if invisible.
	BRA Positive
SkipGFX:
	JMP SkipGFX2
Positive:
	JSR GET_DRAW_INFO
	LDA $1602,x
	STA $03 ; Animation frames -> $03.
	
	LDA $157C,x
	STA $02 ; Direction -> $02.
	PHX ; Push sprite index.
	LDX #$01 ; Get # of times to go through loop.
Loop2:
	PHX 	; Push it for later..
	TXA
	ORA $03
FaceLeft:
	TAX
	LDA $00
	STA $0300,y

	LDA $01
	CLC
	ADC VERT_DISP,x ; .. and Y displacement.
	STA $0301,y

	LDA !InvTimer+9		;\
	ASL A			; |
	PHX			; | Animations involve a pointer.
	TAX			; |
	JMP (PtrPtr,x)		;/
;NOTE - Pointer is used to easily display frames (for future updates)
PtrPtr:
	dw AnimationFrameA 	; 00 ; Normal animation frames (A)
	dw AnimationFrameB 	; 01 ; Normal animation frames (B)
	dw AnimationFrameC 	; 02 ; Normal animation frames (C)
	;dw AnimationExFrame 	; 03 ; Throwing bone/hammer frame

AnimationFrameA:
	PLX
	LDA TILEMAP,x
	BRA DoGfx
AnimationFrameB:
	PLX
	LDA TILEMAP2,x
	BRA DoGfx
AnimationFrameC:
	PLX
	LDA TILEMAP3,x
	BRA DoGfx
DoGfx:
	STA $0302,y

	LDX $15E9
	ORA $15F6,x
	ORA $64 ; Add in property byte.
	STA $0303,y

	LDA #!DoFlash ; Skip flashing if we're not allowed.
	CMP #$01
	BNE NoFlashing

	LDA !Flash,x
	BEQ NoFlashing ; Sprite flashes when jumped on.
	LDA $14
	AND #$07 ; 7 frames ..
	TAX ; -> X.
	LDA $0303,y
	AND #$F1
	ORA FlashTable,x
	STA $0303,y
NoFlashing:

	PLX ; Pull #$03.

	INY
	INY
	INY
	INY
	DEX ; Decrease it for every 16x16 tile drawn.
	BPL Loop2

	PLX
	LDY #$02
	LDA #$01
	JSL $01B7B3
SkipGFX2:	
	RTS


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

I'm working on a hack! Check it out here. Progress: 64/95 levels.


Okay then. Thanks! #w{=)}

I had tried editing the graphics routine before, but I didn't know you also had to edit a value in the .CFG file. D:

Hopefully, with this advice, I can now get my hack ready for C3! #w{=3}


St. Clair Publications: Where good girls just want to have fun this Christmas!

Other places you can find me: LiveJournal | Last.FM



UPDATE on November 16, 2010:

The ASM code you gave me caused many graphical glitches to my boss, and all attempts I made to fix it caused the boss to be rendered with no animation and with the wrong frames.

After a LOT of effort, I decided to revert the code back to what it was for a 32×32 sprite, and as I type this, I have succeeded in creating a proper 16×32 sprite simply by removing CDC and ADC HORIZ_DISP,x under FaceLeft.

Problem is, this causes !TopRight, !BottomRight, !WalkTopRight, and !WalkBottomRight to all be rendered on top of their left counterparts. I want these to disappear, but haven't figured out how to do so, so I'm just simply changing the "right" frames to use the same graphics as the "left" frames.

I sure wish Iceguy himself could offer some input... |-O


St. Clair Publications: Where good girls just want to have fun this Christmas!

Other places you can find me: LiveJournal | Last.FM