 |
|
 |
|
| Sprite/Block/HDMA/ASM Code Library |
|
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - Sprite/Block/HDMA/ASM Code Library |
|
Pages: 1 ... 4 5 6 7 8 9 10  |
Thread Closed |
|
|
| Posted on 2010-10-09 10:01:25 PM |
Link |
|
|
huh, well, heres it uploaded from my files
|
|
| Posted on 2010-12-03 08:18:52 AM |
Link |
|
While trying to solve a problem Wiimeiser had with one of his blocks, I noticed that you need this code instead if you're trying to make a block shatter when a sprite touches it:
LDA $0A ;\
AND #$F0 ;| Update the position
STA $9A ;| of the block
LDA $0B ;| so it doesn't shatter
STA $9B ;| where the players at
LDA $0C ;|
AND #$F0 ;|
STA $98 ;|
LDA $0D ;|
STA $99 ;/
LDA #$02 ; Replace block with blank tile
STA $9C
JSL $00BEB0
PHB
LDA #$02
PHA
PLB
LDA #$00 ;set to 0 for normal explosion, 1 for rainbow (throw blocks)
JSR $028663 ;breaking effect
PLB
|
|
| Posted on 2010-12-03 01:29:23 PM |
Link |
|
Here is a generic, customizable, and versatile GFX routine I made. It has two parts. The first part is the setup for the routine, which should look like this:
CodePEA.w .Label-$01 ; push the real return address
JSR SubGFX ;
dw HorizDisp1,VertDisp1,Tilemap1,TileProps1,TileSize1 : db !TilesToDraw1
dw HorizDisp2,VertDisp2,Tilemap2,TileProps2,TileSize2 : db !TilesToDraw2
;...
.Label
The pointer table in the middle should have 11 bytes per row in that format: horizontal displacement, vertical displacement, tilemap, tile properties, tile size, and a single byte indicating the number of tiles to draw. (Put $00 for 1 tile, etc.) The table should have as many rows as the sprite has animation frames. The second part is the actual GFX routine, and it looks like this:
CodeSubGFX:
REP #$20 ;
PLA ; pull back the program bank value of the next byte after the JSR
INC ;
STA $08 ; and save it
SEP #$20 ;
JSL !GetDrawInfo ; or JSR if you're not using shared subroutines
LDA $1602,x ; $1602,x is assumed to contain the sprite's current animation frame
STA $4202 ; multiplicand A: current animation frame
LDA #$0B ; multiplicand B: 0B, or 11 in decimal - each table contains 11 bytes
STA $4203 ;
REP #$20 ;
LDA $08 ;
STA $02 ;
TYX ; OAM index -> X
LDY $4216 ; load the value from the frame table (I could put this in 16-bit, but this allows for 23 frames anyway)
LDA ($02),y ; bytes 1 and 2 -> $06
STA $06 ; $06 = pointer to horizontal displacement table
INY ;
INY ;
LDA ($02),y ; bytes 3 and 4 -> $08
STA $08 ; $08 = pointer to vertical displacement table
INY ;
INY ;
LDA ($02),y ; bytes 5 and 6 -> $0A
STA $0A ; $0A = pointer to tilemap table
INY ;
INY ;
LDA ($02),y ; bytes 7 and 8 -> $0C
STA $0C ; $0C = pointer to tile properties table
INY ;
INY ;
LDA ($02),y ; bytes 9 and 10 -> $0E
STA $0E ; $0E = pointer to tile size table
INY ;
INY ;
SEP #$20 ;
LDA ($02),y ; byte 11 -> $05
STA $05 ; $05 = number of tiles to draw
TAY ; starting index into Y
.GFXLoop
LDA $00 ; base X position
CLC ;
ADC ($06),y ; plus horizontal displacement
STA $0300,x ; into first OAM slot
LDA $01 ; base Y position
CLC ;
ADC ($08),y ; plus vertical displacement
STA $0301,x ; into second OAM slot
LDA ($0A),y ; tile number
STA $0302,x ; into third OAM slot
LDA ($0C),y ; tile properties (YX--CCCT)
ORA $64 ; plus sprite priority settings
STA $0303,x ; into fourth OAM slot
PHX ; preserve OAM index
TXA ;
LSR #2 ; OAM index / 4
TAX ;
LDA ($0E),y ; tile size
STA $0460,x ; into tile size OAM slot
PLX ;
INX #4 ; increment the OAM index by 4
DEY ; decrement the pointer index
BPL .GFXLoop ; if positive, there are more tiles to draw
LDX $15E9 ; sprite index back into X
LDA $05 ; $05 holds the number of tiles to draw
LDY #$FF ; we already set the tile size, so use FF here
JSL $81B7B3 ; finish the write to OAM
RTS ;
The second part does not need to be changed, but it does assume that $1602,x contains the sprite's current animation frame. I haven't tested it thoroughly, but this routine should work with any sprite drawing any combination of tiles on any animation frame.
Mod edit: Disabled layout to lower table stretch.
|
| Last edited on 2010-12-03 01:35:45 PM by Alcaro. |
|
| Posted on 2010-12-14 12:11:35 PM |
Link |
|
This is a disassembly of the Volcano Lotus's fireball, extended sprite 0C. It includes several subroutines used by all or most extended sprites.
Code; $029B51
VolcanoLotusFire: ;
LDY ExSprOAMIndex,x ;
LDA $171F,x ;
SEC ;
SBC $1A ;
STA $00 ;
LDA $1733,x ;
SBC $1B ;
BNE EraseExSpr ;
LDA $1715,x ;
SEC ;
SBC $1C ;
STA $01 ;
LDA $1729,x ;
SBC $1D ;
BEQ .Continue ;
BMI NoDraw ;
BPL EraseExSpr ;
.Continue ;
LDA $00 ;
STA $0200,y ;
LDA $01 ;
CMP #$F0 ;
BCS NoDraw ;
STA $0201,y ;
LDA #$09 ;
ORA $64 ;
STA $0203,y ;
LDA $14 ;
LSR ;
EOR $15E9 ;
LSR ;
LSR ;
LDA #$A6 ;
BCC SetTileNum ;
LDA #$B6 ;
SetTileNum: ;
STA $0202,y ;
TYA ;
LSR ;
LSR ;
TAY ;
LDA #$00 ;
STA $0420,y ;
NoDraw: ;
LDA $9D ;
BNE Return00 ;
JSR ExSprPlayerInteract ; $02A3F6
JSR ExSprUpdateYPos ; $02B554
JSR ExSprUpdateXPos ; $02B560
LDA $13 ;
AND #$03 ;
BNE NoAccel ;
LDA $173D,x ;
CMP #$18 ;
BPL NoAccel ;
INC $173D,x ;
NoAccel: ;
LDA $173D,x ;
BMI Return00 ;
TXA ;
ASL ;
ASL ;
ASL ;
ADC $13 ;
LDY #$08 ;
AND #$08 ;
BNE SetXSpeed ;
LDY #$F8 ;
SetXSpeed: ;
TYA ;
STA $1747,x ;
Return00: ;
RTS ;
EraseExSpr: ;
STZ $170B,x ;
RTS ;
ExSprOAMIndex:
db $90,$94,$98,$9C,$A0,$A4,$A8,$AC
ExSprPlayerInteract:
LDA $13F9 ;
EOR $1779,x ;
BNE ReturnEPI ;
JSL $03B664 ;
JSR GetExSprClipping ;
JSL $03B72B ;
BCC ReturnEPI ;
LDA $170B,x ;
CMP #$0A ;
BNE NotSmileyCoin ;
SmileyCoinInteraction: ;
JSL $05B34A ;
INC $18E3 ;
STZ $170B,x ;
LDY #$03 ;
.Loop ;
LDA $17C0,y ;
BEQ .FoundSmokeSlot ;
DEY ;
BPL .Loop ;
INY ;
.FoundSmokeSlot ;
LDA #$05 ;
STA $17C0,y ;
LDA $171F,x ;
STA $17C8,y ;
LDA $1715,x ;
STA $17C4,y ;
LDA #$0A ;
STA $17CC,y ;
ExtendedSprShowScore: ;
JSL $02AD34 ;
LDA #$05 ;
STA $16E1,y ;
LDA $1715,x ;
STA $16E7,y ;
LDA $1729,x ;
STA $16F9,y ;
LDA $171F,x ;
STA $16ED,y ;
LDA $1733,x ;
STA $16F3,y ;
LDA #$30 ;
STA $16FF,y ;
LDA #$00 ;
STA $1705,y ;
ReturnEPI: ;
RTS ;
NotSmileyCoin: ;
LDA $1490 ;
BNE InvincibleToExSpr ;
LDA $187A ;
BEQ ExSprHurtPlayer ;
PHX ;
LDX $18DF ;
LDA #$10 ;
STA $163D,x ;
LDA #$03 ;
STA $1DFA ;
LDA #$13 ;
STA $1DFC ;
LDA #$02 ;
STA $C1,x ;
STZ $187A ;
STZ $0DC1 ;
LDA #$C0 ;
STA $7D ;
STZ $7B ;
LDY $157B,x ;
LDA YoshiRunXSpeed,y ;
STA $B5,x ;
STZ $1593,x ;
STZ $151B,x ;
STZ $18AE ;
LDA #$30 ;
STA $1497 ;
PLX ;
RTS ;
ExSprHurtPlayer:
JSL $00F5B7 ;
RTS ;
InvincibleToExSpr: ;
LDA $170B,x ;
CMP #$04 ;
BEQ .SkipShift ;
LDA $171F,x ;
SEC ;
SBC #$04 ;
STA $171F,x ;
LDA $1733,x ;
SBC #$00 ;
STA $1733,x ;
LDA $1715,x ;
SEC ;
SBC #$04 ;
STA $1715,x ;
LDA $1729,x ;
SBC #$00 ;
STA $1729,x ;
.SkipShift ;
LDA #$07 ;
STA $176F,x ;
LDA #$01 ;
STA $170B,x ;
RTS ;
YoshiRunXSpeed: ;
db $10,$F0 ;
ExSprOAMIndex:
db $90,$94,$98,$9C,$A0,$A4,$A8,$AC
ExSprClipXOffset:
db $17,$60,$03,$03,$04,$03,$04,$00
db $00,$00,$04,$03
ExSprClipYOffset:
db $03,$03,$03,$03,$04,$03,$04,$00
db $00,$00,$02,$03
ExSprClipWidth:
db $03,$03,$01,$01,$08,$01,$08,$00
db $00,$0F,$08,$01
ExSprClipHeight:
db $01,$01,$01,$01,$08,$01,$08,$00
db $00,$0F,$0C,$01
UnknownData02A517:
db $01,$01
GetExSprClipping:
LDY $170B,x ;
LDA $171F,x ;
CLC ;
ADC ExSprClipXOffset,y ;
STA $04 ;
LDA $1733,x ;
ADC #$00 ;
STA $0A ;
LDA ExSprClipWidth,y ;
STA $06 ;
LDA $1715,x ;
CLC ;
ADC ExSprClipYOffset,y ;
STA $05 ;
LDA $1729,x ;
ADC #$00 ;
STA $0B ;
LDA ExSprClipHeight,y ;
STA $07 ;
RTS ;
ExSprUpdateYPos:
TXA ;
CLC ;
ADC #$0A ;
TAX ;
JSR ExSprUpdateXPos ;
LDX $15E9 ;
RTS ;
ExSprUpdateXPos:
LDA $173D,x ;
ASL #4 ;
CLC ;
ADC $1751,x ;
STA $1751,x ;
PHP ;
LDY #$00 ;
LDA $173D,x ;
LSR #4 ;
CMP #$08 ;
BCC $03 ;
ORA #$F0 ;
DEY ;
PLP ;
ADC $1715,x ;
STA $1715,x ;
TYA ;
ADC $1729,x ;
STA $1729,x ;
RTS ;
I'm hoping to disassemble some more extended sprites, and maybe even some cluster sprites. They could provide insight.
|
|
|
|
| Posted on 2011-05-17 10:20:18 AM |
Link |
|
no one has posted here in a while so i guess i can add a couple macros that come in handy.
Codemacro ezmvn(src,dest,bytes)
ldx.w #<src>
ldy.w #<dest>
lda.w #<bytes>
db $54
db <dest>/65536,<src>/65536
endmacro
this is how you use the MVN opcode. <src> and <dest> are 3 bytes, <bytes>, is 2.
example:
%ezmvn($138008,$7FB000,$0040) ;this will move $40 bytes from $138008 to $7FB000.
note: must be 16bit AXY, add REP #$30 to beginning/SEP #$30 at end of macro if you want.
Codemacro color(value)
lda.b #<value>
sta $2122
lda.b #<value>/256
sta $2122
endmacro
for when you want to change a color. example: %color($7FFF) ;store 'white' color
obviously, <value> is 2 bytes.
|
| Last edited on 2011-05-17 10:21:53 AM by Ixtab. |
|
|
|
| Posted on 2011-05-17 02:22:43 PM |
Link |
|
Actually,
1) I'm pretty sure that routine has been posted in this thread before;
2) That one has TRASM syntax (and TRASM is crap);
3) It's more like a generic Map16-changing routine;
4) To use that in anything but a custom block, you'd need to set up the tile position in $98-$9B.
But in any case, yeah, for the most part, any codes you happen to have that could be useful to people can be posted here.
|
|
| Posted on 2011-05-17 02:23:22 PM |
Link |
|
|
table stretch! why did you leave the debugger-log in the comments? and why trasm?
|
|
| Posted on 2011-05-17 02:30:57 PM |
Link |
|
Originally posted by imamelia1) I'm pretty sure that routine has been posted in this thread before;
Correct.
Quote2) That one has TRASM syntax (and TRASM is crap);
Correct and correct.
Quote3) It's more like a generic Map16-changing routine;
Correct.
Quote4) To use that in anything but a custom block, you'd need to set up the tile position in $98-$9B.
Not sure about this, but it seems correct.
Originally posted by Ixtabtable stretch!
Fixed.
Quotewhy did you leave the debugger-log in the comments?
Maybe he was too lazy to remove it.
My guess is that whatever strange disassembler he used likes TRASM format.
|
|
| Posted on 2011-05-17 02:56:41 PM |
Link |
|
|
Maybe it came from one of Davros's sprites?
|
|
| Posted on 2011-05-17 04:23:54 PM |
Link |
|
This will make a sprite solid.
|
|
| Posted on 2011-05-26 08:45:19 PM |
Link |
|
Here are some macros I made for transferring data to VRAM and CGRAM, as well as ones for transferring data from VRAM and CGRAM to normal RAM (although certain address, notably the second halves of banks 70-73, do not work properly).
Codemacro WriteToVRAM(srcbank, srcaddr, destaddr, datasize)
PHP
REP #$20 ; 16-bit A
SEP #$10 ; 8-bit XY
LDY #$80 ;
STY $2115 ; increment after reading the high byte of the VRAM data write ($2119)
LDA <destaddr> ;
STA $2116 ; VRAM address
LDA #$1801 ;
STA $4320 ; 2 regs write once, $2118
LDA <srcaddr> ;
STA $4322 ; set the lower two bytes of the source address
LDY.b <srcbank> ;
STY $4324 ;
LDA <datasize> ; number of bytes to transfer
STA $4325 ;
LDY #$04 ; DMA channel 2 (TSB $420B messes stuff up...I wonder why?)
STY $420B ;
PLP ;
endmacro
macro WriteFromVRAM(destbank, destaddr, srcaddr, datasize)
PHP
REP #$20 ; 16-bit A
SEP #$10 ; 8-bit XY
LDY #$80 ;
STY $2115 ; increment after reading the high byte of the VRAM data read ($213A)
LDA <srcaddr> ;
STA $2116 ; VRAM address
LDA $2139 ; "dummy read"
LDA #$3981 ;
STA $4320 ; 2 regs write once, $2139
LDA <destaddr> ;
STA $4322 ; set the lower two bytes of the destination address
LDY.b <destbank> ;
STY $4324 ;
LDA <datasize> ; number of bytes to transfer
STA $4325 ;
LDY #$04 ; DMA channel 2 (TSB $420B messes stuff up...I wonder why?)
STY $420B ;
PLP ;
endmacro
macro WriteToCGRAM(srcbank, srcaddr, destaddr, datasize)
PHP
REP #$20 ; 16-bit A
SEP #$10 ; 8-bit XY
LDY <destaddr> ;
STY $2121 ;
LDA #$2202 ;
STA $4320 ; 1 reg write twice, $2122
LDA <srcaddr> ;
STA $4322 ; set the lower two bytes of the destination address
LDY.b <srcbank> ;
STY $4324 ;
LDA <datasize> ; number of bytes to transfer
STA $4325 ;
LDY #$04 ; DMA channel 2
STY $420B ;
PLP ;
endmacro
macro WriteFromCGRAM(srcaddr, destbank, destaddr, datasize)
PHP
REP #$20 ; 16-bit A
SEP #$10 ; 8-bit XY
LDY <srcaddr> ;
STY $2121 ;
LDA #$3B82 ;
STA $4320 ; 1 reg write (read) twice, $213B
LDA <destaddr> ;
STA $4322 ; set the lower two bytes of the destination address
LDY.b <destbank> ;
STY $4324 ;
LDA <datasize> ; number of bytes to transfer
STA $4325 ;
LDY #$04 ; DMA channel 2
STY $420B ;
PLP ;
endmacro
They should work (at least, they did for me).
|
| Last edited on 2011-06-01 03:53:48 PM by imamelia. |
|
| Posted on 2011-06-17 04:12:43 AM |
Link |
|
I would like to request a giant flying t-rex boss that wears a jetpack and spits ficus plants at you. The plants' name is Gertrude (she is a hive-mind), and her individual plant pieces cast dynamic shadows via mode seven and the super fx.
Ficus plants come from the family Moraceae and the order Urticales, thus they are found in only tropical or subtropical climates. the Order Urticales consists of flowering plants, so the sprites should be budding blooming or wilting based on the season in which the rom is loaded.
For reference, I have included images of both a ficus plant and a t-rex.
here is the image of the ficus plant...

...and here is the image of the t-rex.

thank you
|
|
| Posted on 2011-06-17 08:00:53 AM |
Link |
|
Originally posted by jesusrequest
This is no request thread. I can't even tell if you're being serious because you're literally asking for the impossible. Don't even think of requesting this in the requests section because it's too complicated.
|
|
| Posted on 2011-06-17 07:32:57 PM |
Link |
|
Originally posted by ErsanioOriginally posted by jesusrequest
This is no request thread. I can't even tell if you're being serious because you're literally asking for the impossible. Don't even think of requesting this in the requests section because it's too complicated.
I TRIED!!!! the request thread won't let me post large pictures! I even had my dad type in the html for me and It wouldn't work!
can YOUR dad help me do the html on the boss request page?
|
|
| Posted on 2011-06-17 08:29:19 PM |
Link |
|
|
He's quite obviously not being serious.
|
|
| Posted on 2011-06-22 11:31:17 PM |
Link |
|
Originally posted by jesuswords
here's your code
Codeheader
lorom
org $1337
wup:
BRK
BRK
BRK
BRK
BRK
BRK
BRK
BRK
BRK
STP
STP
STP
STP
BRL wup
|
| Last edited on 2011-06-22 11:31:36 PM by Medic. |
|
| Posted on 2011-06-27 11:30:09 PM |
Link |
|
Originally posted by UMAOriginally posted by jesuswords
here's your code
Codeheader
lorom
org $1337
wup:
BRK
BRK
BRK
BRK
BRK
BRK
BRK
BRK
BRK
STP
STP
STP
STP
BRL wup
I disagree, this is much more accurate coding:
CodeLDA #$Impossible_Request
CMP #$jesus'_request ;Checks if request is possible.
BNE Make_a_request_then ;If request does not equal impossible, then branch.
RTL
Make_a_request_then:
LDA #$Request_Section
STA #$Current_webpage ; Sets current webpage to http://www.smwcentral.net/?p=requests
LDA #$Make_a_request
STA #$Current_webpage ; Sets current webpage to requesting page.
LDA #$Experienced_user
STA #$Request ; Wait for someone with experience to take your request.
LDA #$Passed_moderation
STA #$Request
RTL
That should do it.
|
|
| Posted on 2011-06-29 06:35:00 PM |
Link |
|
Originally posted by darkbonesI disagree, this is much more accurate coding:
Code
LDA #$Impossible_Request
CMP #$jesus'_request ;Checks if request is possible.
BNE Make_a_request_then ;If request does not equal impossible, then branch.
RTL
Make_a_request_then:
LDA #$Request_Section
STA #$Current_webpage ; Sets current webpage to http://www.smwcentral.net/?p=requests
LDA #$Make_a_request
STA #$Current_webpage ; Sets current webpage to requesting page.
LDA #$Experienced_user
STA #$Request ; Wait for someone with experience to take your request.
LDA #$Passed_moderation
STA #$Request
RTL
That should do it.

EDIT: and i finally leveled up.
|
| Last edited on 2011-06-29 06:35:47 PM by Ruberjig. |
|
|
Pages: 1 ... 4 5 6 7 8 9 10  |
Thread Closed |
|
|
|
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - Sprite/Block/HDMA/ASM Code Library |
|
|
 |
|
 |
The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.
Copyright © 2005 - 2013 - SMW Central Legal Information - Link To UsTotal queries: 29
|
|
|
|