Language…
7 users online: Cappaque, HengShao, liz_bean, Mithrillionaire, RPG Hacker, underway, Xulon - Guests: 1,382 - Bots: 139
Users: 70,922 (2,288 active)
Latest user: Zemious

Posts by Hammerbrother24

Hammerbrother24's Profile → Posts

hi i am new to rom hacking and using lx5 custom power ups if there away i can make this not be destoryed by ice flower super ball and electric flower here the code any ideas or so it just cant be destroyed

Code
;~@sa1 <-- DO NOT REMOVE THIS LINE!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Yoshi's Island Dizzy Dandy (Rolling Flower)
; Programmed by SMWEdit
;
; Uses first extra bit: If extra bit is set, flower wont kill enemies when it rolls over them
;
; You will need to patch SMKDan's dsx.asm to your ROM with xkas
; this sprite, like all other dynamic sprites, uses the last 4 rows of sp4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

!SPRITEKILLSND = $37	; sound effect when flower kills sprite
!POOFSND = $01		; sound effect for disappearing (1DF9)
!YRANGE = $60		; you can change this, this is the distance in pixels to activate

!ACTSTATUS = $D8		; 0=waiting,1=falling,2=rolling
!OFFSET = $329A
!FLIPXY = $3284

!SPRXTMP = $04		; 2 bytes
!XDISTTMP = $08		; 2 bytes

!NUMBER_OF_WAIT_FRAMES = $32	; \ do not change these unless you have studied
!NUMBER_OF_ROLL_FRAMES = $10	; / the code and know exactly what you're doing

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; INIT and MAIN JSL targets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

print "INIT ",pc
%SubHorzPos()	; \
TYA			;  | face mario initially
STA $3334,x		; /
RTL		

print "MAIN ",pc			
PHB
PHK				
PLB				
JSR SPRITE_ROUTINE	
PLB
RTL     


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SPRITE_ROUTINE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SPEED_TABLE:	db $20,$E0		; speeds (right, left)

RETURN1:		RTS

SPRITE_ROUTINE:	JSR SUB_GFX
LDA $3242,x		; RETURN if sprite status != 8
CMP #$08
BNE RETURN1
LDA $9D			; RETURN if sprites locked
BNE RETURN1
%SubOffScreen()        

LDA !ACTSTATUS,x		; \  if not in rolling
CMP #$02		;  | mode then don't
BNE NOT_ROLLING		; /  execute next code
LDA !OFFSET,x		;				  \
CMP #!NUMBER_OF_WAIT_FRAMES+!NUMBER_OF_ROLL_FRAMES-1	;  | update roll
BEQ RRESET		;				   | frame offset
INC !OFFSET,x		;				   |
BRA AFTERROLLUPDATE	;				   |
RRESET:		
LDA #!NUMBER_OF_WAIT_FRAMES	;			   |
STA !OFFSET,x		;				  /
LDA !FLIPXY,x		; \  rotate sprite
EOR #%00000001		;  | 180 degrees for
STA !FLIPXY,x		; /  next time around
AFTERROLLUPDATE:
LDY $3334,x
LDA SPEED_TABLE,y	;  | move
STA $B6,x		; /
LDA $334A,x		; \  don't execute following
AND #%00000011		;  | code unless flower is
BEQ NO_POOF		; /  touching a wall
LDA #$00		; \  kill sprite,
LDY $7578,x		;  | but allow
PHX
TYX
STA $418A00,x
PLX        		;  | sprite to
STZ $3242,x		; /  reload again
LDA #!POOFSND		; \ play disappear
STA $7DF9		; / sound effect
JSL $07FC3B
NO_POOF:

LDA $400040,x
AND #$04
BNE NOT_ROLLING
JSR KILLSPRITES		; call sprite killer routine
NOT_ROLLING:

LDA !ACTSTATUS,x		; \  if not in falling
CMP #$01		;  | mode then don't
BNE NOT_FALLING		; /  execute next code
LDA $334A,x		; \  if not on ground
AND #%00000100		;  | then don't execute
BEQ NOT_ON_GND		; /  next code
LDA #$02		; \ set status
STA !ACTSTATUS,x		; / to rolling
LDA #!NUMBER_OF_WAIT_FRAMES	; \ set starting
STA !OFFSET,x		;	  / offset for rolling
NOT_ON_GND:
JSR KILLSPRITES		; call sprite killer routine
NOT_FALLING:

LDA !ACTSTATUS,x		; \  if not in waiting
;CMP #$00		;  | mode then don't
BNE NOT_WAITING		; /  execute next code
STZ $9E,x
STZ $B6,x
LDA !OFFSET,x		;	 \
CMP #!NUMBER_OF_WAIT_FRAMES-1	; | update sprite's
BEQ WRESET		;	  | offset in the
INC !OFFSET,x		;	  | set of FRAMES
BRA AFTERWAITUPDATE	;	  |
WRESET:		STZ !OFFSET,x		;	 /
AFTERWAITUPDATE:
LDA $322C,x		; \  store sprite X
STA !SPRXTMP		;  | position into
LDA $326E,x		;  | scratch RAM for use
STA !SPRXTMP+1		; /  with next routine
%SubHorzPos()	; \ decide what H side mario is on
BEQ AFTERSPRITE		; / so to get positive # distance
BEFORESPRITE:	PHP			; \
REP #%00100000		;  | mario is before sprite
LDA !SPRXTMP		;  | so take sprite's position
SEC			;  | and subtract mario's
SBC $94			;  | position to get the
STA !XDISTTMP		;  | X distance
PLP			; /
BRA AFTERXCALC		; don't execute following code
AFTERSPRITE:	PHP			; \
REP #%00100000		;  | mario is after
LDA $94			;  | sprite so X
SEC			;  | distance =
SBC !SPRXTMP		;  | mario - sprite
STA !XDISTTMP		;  |
PLP			; /
AFTERXCALC:
LDA !XDISTTMP+1		; \  don't fall if
CMP #$01		;  | more than one
BCS NO_FALL		; /  screen away
LDA !XDISTTMP		; \  do not fall if
CMP #!YRANGE+1		;  | low byte is >
BCS NO_FALL		; /  than range given
LDA #$01		; \ set fall
STA !ACTSTATUS,x		; / mode
NO_FALL:
NOT_WAITING:

JSL $01802A		; update position based on speed values
JSL $01803A     
RETURN:		RTS

SUB_SMOKE:	LDA $3216,x		; \
CMP $1C			;  | don't generate
LDA $3258,x		;  | if off screen
SBC $1D			;  | vertically
BNE ENDSMOKE		; /
LDA $322C,x		; \
CMP $1A			;  | don't generate
LDA $326E,x		;  | if off screen
SBC $1B			;  | horizontally
BNE ENDSMOKE		; /
LDY #$03		; \
FINDFREE:	LDA $77C0,y		;  | find a free
BEQ FOUNDONE		;  | slot to
DEY			;  | display effect
BPL FINDFREE		;  | for smoke
BRA ENDSMOKE		; /
FOUNDONE:	LDA #$01		; \ set effect graphic to smoke graphic
STA $77C0,y		; /
LDA $322C,x 		; \ set x position for smoke
STA $77C8,y		; /
LDA $3216,x		; \ set y position for smoke
STA $77C4,y		; /
LDA #$10		; \ set time to show smoke
STA $77CC,y		; /
ENDSMOKE:	RTS

KILLSPRITES:
LDY #$0C		; load number of times to go through loop
KILL_LOOP:	CPY #$00		; \ zero? if so,
BEQ END_KILL_LOOP	; / end loop
DEY			; decrease # of times left+get index
STX $06			; \  if sprite is
CPY $06			;  | this sprite
BEQ KILL_LOOP		; /  then ignore it
LDA $3242,y		; \  if sprite is not
CMP #$08		;  | in a "tangible"
BCC KILL_LOOP		; /  mode, don't kill
LDA $7616,y		; \  if sprite doesn't
AND #%00000010		;  | interact with stars/cape/fire/bricks
BNE KILL_LOOP		; /  don't continue
JSL $03B69F		; \
PHX			;  | if sprite is
TYX			;  | not touching
JSL $03B6E5		;  | this sprite
PLX			;  | don't continue
JSL $03B72B		;  |
BCC KILL_LOOP		; /
LDA #!SPRITEKILLSND	; \ play kill
STA $7DFC		; / sound
LDA $75D0,y		; \  force sprite
ORA #%10000000		;  | to disappear
STA $75D0,y		; /  in smoke
LDA #$02		; \ set sprite into
STA $3242,y		; / death mode (status=2)
END_KILL_LOOP:
RTS


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GRAPHICS ROUTINE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
!TILESDRAWN = $08	; \ scratch RAM
!TEMP_FOR_TILE = $03	; / addresses

FRAMES:		db $00,$01,$01,$02,$03,$10,$11,$12,$13,$20,$21,$22,$23,$30,$23,$22
db $21,$20,$13,$12,$11,$10,$03,$02,$01,$01,$00,$31,$31,$32,$33,$40
db $41,$42,$43,$50,$51,$52,$53,$52,$51,$50,$43,$42,$41,$40,$33,$32
db $31,$31

db $60,$61,$62,$63,$70,$71,$72,$73,$80,$81,$82,$83,$90,$91,$92,$93

FLWR_TILES:	db $00,$02,$20,$22
FLWR_XPOS:	db $F8,$08,$F8,$08
FLWR_YPOS:	db $F8,$F8,$08,$08

SUB_GFX:		
%GetDrawInfo()
LDA $3334,x		; \  store direction
EOR !FLIPXY,x		;  | to scratch RAM
STA $02			; /
LDA !FLIPXY,x		; \  store Y
EOR #%00000001		;  | flip
STA $04			; /
STZ !TILESDRAWN		; zero tiles drawn
JSR DRAW_FLWR		; draw flower
JSR SETTILES		; set tiles / don't draw offscreen
ENDSUB:		RTS

DRAW_FLWR:	LDA !OFFSET,x		; \
PHY			;  | set frame according
TAY			;  | to offset
LDA FRAMES,y		;  |
PLY			; /
SETFRM:		JSR GETSLOT		; call routine to get a slot
BEQ ENDSUB		; if none left, end
STA !TEMP_FOR_TILE	; store tile into scratch RAM

PHX			; back up X
LDX #$00		; load X with zero
TILELP:		CPX #$04		; end of loop?
BNE NORETFRML		; if not, then don't end
JMP RETFRML		; if so, then JMP to end (BRA is out of range)
NORETFRML:
LDA $00			; get sprite's X position
PHY			; \
LDY $02			;  | offset by
BNE NO_FLIP_F		;  | this tile's
SEC			;  | X position
SBC FLWR_XPOS,x		;  | (add or
BRA END_FLIP_F		;  | subtract
NO_FLIP_F:	CLC			;  | depending on
ADC FLWR_XPOS,x		;  | direction)
END_FLIP_F:	PLY			; /
STA $6300,y		; set tile's X position
LDA $01			; get sprite's Y position
PHY			; \
LDY $04			;  | offset by
BNE NO_FLIP_F2		;  | this tile's
SEC			;  | Y position
SBC FLWR_YPOS,x		;  | (add or
BRA END_FLIP_F2		;  | subtract
NO_FLIP_F2:	CLC			;  | depending on
ADC FLWR_YPOS,x		;  | direction)
END_FLIP_F2:	PLY			; /
STA $6301,y		; set tile's Y position
LDA !TEMP_FOR_TILE	; load tile # from scratch RAM
CLC			; \ shift tile right/down
ADC FLWR_TILES,x	; / according to which part
STA $6302,y		; set tile #
PHX			; back up X (index to tile data)
LDX $75E9		; load X with index to sprite
LDA $33B8,x		; load palette info
PHX			; \
LDX $02			;  | flip the tile
BNE NO_FLIP_FLWR	;  | if the sprite
ORA #%01000000		;  | is flipped
NO_FLIP_FLWR:	PLX			; /
PHX			; \
LDX $04			;  | flip the tile
BNE NO_FLIP_FLWR2	;  | if the sprite
ORA #%10000000		;  | is flipped V
NO_FLIP_FLWR2:	PLX			; /
ORA $64			; add in priority bits
STA $6303,y		; set extra info
PLX			; load backed up X
INC !TILESDRAWN		; another tile was drawn
INY #4
INX			; next tile to draw
JMP TILELP		; loop (BRA is out of range)
RETFRML:		PLX			; load backed up X
ENDFLWR:		RTS

SETTILES:	LDA !TILESDRAWN		; \ don't reserve
BEQ NODRAW		; / if no tiles
LDY #$02		; #$02 means 16x16
DEC A			; A = # tiles - 1
JSL $01B7B3		; don't draw if offscreen
NODRAW:		RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Dynamic sprite routine
; Programmed mainly by SMKDan, but based on some of my code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

!TEMP = $09

!SLOTPTR = $6660		;16bit pointer for source GFX
!SLOTBANK = $6662	;bank
!SLOTDEST = $6663	;VRAM address
!SLOTSUSED = $66FE	;how many SLOTS have been used

!MAXSLOTS = $04		;maximum selected SLOTS

SLOTS: db $CC,$C8,$C4,$C0	;avaliable SLOTS.  Any more transfers and it's overflowing by a dangerous amount.

GETSLOT:
PHY		;preserve OAM index
PHA		;preserve frame
LDA !SLOTSUSED	;test if slotsused == maximum allowed
CMP #!MAXSLOTS
BEQ NONEFREE

PLA		;pop frame
REP #$20	;16bit A
AND.w #$00FF	;wipe high
XBA		;<< 8
LSR A		;>> 1 = << 7
STA !TEMP	;back to scratch
PEA SPRITEGFX	;push 16bit address, since i'm not sure how else i'm going to get the address of the label itself in TRASM
PLA		;pull 16bit address
CLC
ADC !TEMP	;add frame offset	
STA !SLOTPTR	;store to pointer to be used at transfer time
SEP #$20	;8bit store
PHB		;push db...
PLA		;pull to A...
STA !SLOTBANK	;store bank to 24bit pointer

LDY !SLOTSUSED	;calculate VRAM address + tile number
LDA SLOTS,y	;get tile# in VRAM
PHA		;preserve for eventual pull
SEC
SBC #$C0	;starts at C0h, they start at C0 in tilemap
REP #$20	;16bit math
AND.w #$00FF	;wipe high byte
ASL #5
CLC
ADC #$0B44	;add 0B44, base address of buffer	
STA !SLOTDEST	;destination address in the buffer

JSR DMABUFFER	;ROM -> RAM copy

SEP #$20	;8bit A	
INC !SLOTSUSED	;one extra slot has been used

PLA		;RETURN starting tile number
PLY
RTS

NONEFREE:
PLA
PLY
LDA #$00	;zero on no free SLOTS
RTS

;;;;;;;;;;;;;;;;
;Tansfer routine
;;;;;;;;;;;;;;;;

;DMA ROM -> RAM ROUTINE

DMABUFFER:
;set destination RAM address
REP #$20
LDY #$C4
STY $2230
LDA.w !SLOTDEST
ADC #$74BC
STA $2235	;16bit RAM dest
        
         	;set 7F as bank

;common DMA settings
         	;1 reg only
        	;to 2180, RAM write/read
         

;first line
LDA !SLOTPTR
STA $2232	;low 16bits
LDY !SLOTBANK
STY $2234	;bank
LDY #$80	;128 bytes
STZ $2238
STY $2238
LDY #$41
STY $2237

LDY $318C
BEQ $FB
LDY #$00
STY $318C
STY $2230	;transfer

;second line
LDY #$C4
STY $2230
LDA.w !SLOTDEST	;update buffer dest
CLC
ADC #$0200	;512 byte rule for sprites
STA !SLOTDEST	;updated base
ADC #$74BC
STA $2235	;updated RAM address

LDA !SLOTPTR	;update source address
CLC
ADC #$0200	;512 bytes, next row
STA !SLOTPTR
STA $2232	;low 16bits
LDY !SLOTBANK
STY $2234	;bank
LDY #$80
STZ $2238
STY $2238
LDY #$41
STY $2237

LDY $318C
BEQ $FB
LDY #$00
STY $318C
STY $2230	;transfer

;third line
LDY #$C4
STY $2230
LDA.w !SLOTDEST	;update buffer dest
CLC
ADC #$0200	;512 byte rule for sprites
STA !SLOTDEST	;updated base
ADC #$74BC
STA $2235	;updated RAM address

LDA !SLOTPTR	;update
CLC
ADC #$0200
STA !SLOTPTR
STA $2232
LDY !SLOTBANK
STY $2234
LDY #$80
STZ $2238
STY $2238
LDY #$41
STY $2237

LDY $318C
BEQ $FB
LDY #$00
STY $318C
STY $2230	;transfer

;fourth line
LDY #$C4
STY $2230
LDA.w !SLOTDEST	;update buffer dest
CLC
ADC #$0200	;512 byte rule for sprites
STA !SLOTDEST	;updated base
ADC #$74BC
STA $2235	;updated RAM address

LDA !SLOTPTR
CLC
ADC #$0200
STA !SLOTPTR
STA $2232
LDY !SLOTBANK
STY $2234
LDY #$80
STZ $2238
STY $2238
LDY #$41
STY $2237

LDY $318C
BEQ $FB
LDY #$00
STY $318C
STY $2230

SEP #$20	;8bit A
RTS		;all done, RETURN

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SPRITEGFX:
INCBIN dizzydandy.bin		;included graphics file


Mod edit: No need to post the whole source code like this! Either put a link to the sprite or at the very least put it in a collabsible or code block which should narrow it down.
(restricted)
Thank's bud i figured it out sorry i am new to rom hacking