Language…
6 users online: DanMario24YT, JPhanto,  K.T.B., Majink12, Maw, Rhubarb44230 - Guests: 236 - Bots: 358
Users: 64,795 (2,378 active)
Latest user: mathew

Official Hex/ASM/Etc. Help Thread

  • Pages:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 418
  • 419
  • 420
Hey there, any of you know that wavy HDMA code?

..Uhm it makes the screen ripple? Thanks.
Puffy1406:

INIT:
Quote
REP #$20 ; 16 bit A
LDA #$0F42 ; one reg write twice, indirect
STA $4340 ; $210F - layer 2 horizontal scroll register
LDA #$B600 ; low and high bytes of source address
STA $4342 ;
SEP #$20 ; 8 bit A
LDA #$7F ; set bank
STA $4344 ;
STA $4347 ; set indirect bank too
LDA #$10 ; enable channel 4
TSB $0D9F ;


LDA #$00 ; setup indirect addressing
STA $00 ; target address: $7FB600
LDA #$B6
STA $01
LDA #$7F
STA $02

LDX #$09 ; loop 10 (decimal) times

LVL6_LOOP6:

LDY #$17 ; loop 24 (decimal) times
LVL6_LOOP7:
LDA LVL6_HDMA4,y;
STA [$00],y ; upload table to RAM
DEY
BPL LVL6_LOOP7

REP #$20 ; 16 bit A
LDA $00 ; load low/high byte of target address
CLC
ADC #$0018 ; add 18
STA $00 ; store back
SEP #$20 ; 8 bit A

DEX
BPL LVL6_LOOP6 ; loop again if needed

LDA #$00 ; add in terminator byte
STA [$00]
RTS


MAIN:
Quote
REP #$20 ; 16 bit A

LDX #$0E ; update scroll values
LVL6_LOOP8:
LDA $1E ; layer 2 x
CLC
ADC LVL6_HDMA2,x; add in offset
STA $7FB710,x ; store to HDMA table
DEX
DEX
BPL LVL6_LOOP8 ; loop 8 times

SEP #$20 ; 8 bit A

LDX #$15 ; reset these scanline counts
LDA #$04
LVL6_8:
STA $7FB600,x
DEX
DEX
DEX
BPL LVL6_8

STZ $00 ; set this scratch to 00

LDA $14 ; frame counter
LSR ; /2
AND #$03 ; mod 4
CLC
ADC $20 ; add in layer 2 y
LVL6_7:
CMP #$04 ; check if below 4
BCC LVL6_6 ; continue if so
SBC #$04 ; subtract 4 until it is
INC $00 ; increment scratch
BRA LVL6_7 ; loop
LVL6_6:
SEC ;
SBC #$04 ; flip
EOR #$FF
INC A
STA $01 ; store to scratch for later

LDA $14 ; frame counter
LSR ; /8
LSR
LSR
CLC
ADC $00 ; add in additional from layer 2's y
AND #$07 ; mod 8
STA $00 ; store to scratch
ASL ; x3
CLC
ADC $00
TAX ; stick in x
LDA $01 ; get scanline count
STA $7FB600,x ; set scanline count
STX $4342 ; set table offset

RTS


LVL6_HDMA2: ; holds how much to offset layer 2's horizontal scrolling by. 2 byte width
db $00,$00,$FF,$FF,$FE,$FF,$FF,$FF,$00,$00,$01,$00,$02,$00,$01,$00


LVL6_HDMA4: ; holds initial HDMA settings for layer 2
db $04,$10,$B7 ; first byte = scanline count, second byte = low byte of address, third = high byte
db $04,$12,$B7
db $04,$14,$B7
db $04,$16,$B7
db $04,$18,$B7
db $04,$1A,$B7
db $04,$1C,$B7
db $04,$1E,$B7
I change my layout every 4-5 months
Any chance of getting that to affect FG as well?

I added this to the code, tho it just made a translucent blue sheet over the level.

Code
LDA #$3F	; enable color math on everything
STA $40
LDA #$00	; use background color instead of subscreen layers
STA $44
LDA #$1F	; Put all layers on the main screen
STA $212C	
LDA #$00	; No layers on subscreen
STA $212D


.. And if someone could explain why adding this code didn't work. I found this code in the comprehensive HDMA guide. It's suppose to force HDMA; over all other layers.
Yeah that was my code. For some reason i can't get it to work either, i used it in a previous demo of my hack and it worked fine. I have no idea what i did to get layer 2 affected.
.. Well if anyone else has any ideas then just say so I guess ,_ ,
I have heard from some(read: two) people that it is possible to "free up" palettes 2 and 3 on the overworld for use via some hex edit. Since I have used up palettes 4-7 and I do not wish to use second half of these palettes for layer 2, I would very much like to use palettes 2 and 3; what is this hex edit?
</exceptionally good english>

Also, on the subject of overworld palettes, I want to change the Mario palette(the one you control). Where the heck does the game host that data?
There was a signature here.


It's gone now.
Okay. What ASM code do I need to use to make my Layer 3 BG scroll twice as slow as Layer 2? All of the conventional code makes my BG disappear. Apparently a simple REP LDA Layer2X LSR STA Layer3X LDA Layer2Y LSR STA Layer2Y SEP doesn't work. I'm pretty sure it's something in CGADSUB.
Still here, I guess. Despite all odds.


How I can do this?:
http://www.youtube.com/watch?v=jPX_9RiSv1A
I want to do the fireball knockback effect, but I don´t know how.
NOTE: In the description, Sonikku says I have to edit the fireballs with
a Hex Editor, but I don´t which are the directions that I have to edit, and the RAM Adress(es) for the knockback effect.







Currently doing: Level 2

I'm trying to make a custom block, but I'm just getting into ASM, so I'm experimenting with the blocks that come with BTSD. I've been trying to edit the "gensprite.asm" block to make something like a Mushroom block, just for learning purposes, but I'm having some issues.
First, I set the sprite number to $74, for the Mushroom. I also set the x speed to $05. However, the block spawned the Mushroom in a location to the right of the block! I tried setting XDISP to $00, or even just $0010 (the default is $0020), but it always freezes. The most interesting thing is that the sprite is generated in the right location, but the game freezes shortly after. What gives?
Though it's hard to tell exactly what's wrong since you didn't provide the code you're using, it looks like you're putting "$" instead of "#$" when you're making a value. "$" leads to an address, and "#$" is a number that goes into an address.

Example: You say you're using "$74" to load the value of a Mushroom sprite. However, since you're using "$", you're loading whatever value is currently present in address 74, which is the flag for "Mario is climbing". If you were to use #$74, you'd be loading the value of a Mushroom (though you still need to load that value into the right address).

Also, the game might be freezing because of missing JMPs. These JMPs should be present at the beginning of your code:

Code
JMP MarioBelow : JMP MarioAbove : JMP MarioSide : JMP SpriteV : JMP SpriteH : JMP MarioCape : JMP MarioFireBall


MarioBelow is when Mario hits the block from below, SpriteV is when a sprite hits the top or bottom of the block, etc. These will work like BRA lines, so you need to put MarioBelow: above the code you want to run when Mario hits the block from below for example. Without these, blocks can crash the game, even if the rest of the code is correct.

Now for my question! :D

I'm trying to make a block that changes the music in a level, but I can't get the block to work with custom music. Here's the critical part of the code:

Code
LDA #$25 ;Music #
STA $1DFB ;Change level music


What do I need to do in order to get it to work with custom music?
Userbar

View my YouTube channel here!
View my website here!
Well, the music has to be in the same bank. (4 songs in one) If they are, take the music number, and keep subtracting 4 until it is between 20 and 23. If not, then, well, there's nothing you can really do.
Unless you use this with Romi's addmusic with the song number in A... (code by Kil)
Code
		TAX		; hold song # in X

		STA $0DDA	;\ this stuff is required by romi's addmusic		
		STA $1DFB	;|
		LDA #$11	;|	
		STA $0100	;/	

		STZ $4200	; disable NMI

		LDA $13BF	;\ stuff required by romi's addmusic
		PHA		;|
		STZ $13BF	;|
		LDA $0DAE	;|	
		PHA		;|	
		LDA $0DAF	;|	
		PHA		;/	
		
		PHK		; We push our return address onto the stack
		PER RETURNADDR-1	

		TDC		;\
		PHA		;| set bank 0
		PLB		;/

		TXA		; get song # back in A
		JML [$9741]	; We use the addmusic hijack as
				; a pointer to jump to the hack

RETURNADDR:
				; it loads the song and returns here to the
				; return address we pushed					
		PLA		; now just pull all this stuff back
		STA $0DAF	
		PLA		
		STA $0DAE		

		LDA #$14		
		STA $0100		

		PLA
		STA $13BF


		LDA #$81		
		STA $4200	; reenable NMI

Note that there will be lag when loading the song.
Originally posted by I8Strudel
Though it's hard to tell exactly what's wrong since you didn't provide the code you're using, it looks like you're putting "$" instead of "#$" when you're making a value. "$" leads to an address, and "#$" is a number that goes into an address.

Example: You say you're using "$74" to load the value of a Mushroom sprite. However, since you're using "$", you're loading whatever value is currently present in address 74, which is the flag for "Mario is climbing". If you were to use #$74, you'd be loading the value of a Mushroom (though you still need to load that value into the right address).


Thanks for the help, but that's not what appears to be the issue. I agree, it's strange, but adding/removing the "#" doesn't change a thing. Here's the code:
Code
;generates a sprite when touched by Mario with the below parameters
;by smkdan
;Act like whatever
JMP MarioBelow : JMP MarioAbove : JMP MarioSide : JMP SpriteV : JMP SpriteH : JMP MarioCape : JMP MarioFireBall
;don't touch those

;NOTE:
;If you want to spawn a stationary shell, select a shelled koopa of the color you like and set INITSTAT to 09

!SPRITENUMBER = $00	;sprite # to generate
!ISCUSTOM = $00		;set to 01 to generate custom or 00 for standard
!INITSTAT = $01		;change only if the note told you so

!XDISP = $0020		;value added to block position on generation
!YDISP = $FFE0
!XSPD = $00		;speed values
!YSPD = $00

Return_l:
	RTL

MarioAbove: 
MarioSide: 
	RTL
MarioBelow:
	PHY		;preserve Y
	JSL $02A9DE	;grab sprite slot
	BMI Return_l	;return if none avaliable
	TYX		;into X

	LDA #!INITSTAT	;set to initial status
	STA $14C8,x	;status

	LDA #!ISCUSTOM	;if custom set different type table
	BNE Custom

;Standard:
	LDA #!SPRITENUMBER	;sprite to generate
	STA $9E,x		;sprite type
	JSL $07F7D2		;clear
	BRA SkipCustom
  
Custom:
	LDA #!SPRITENUMBER
	STA $7FAB9E,x	;custom sprite type table
	JSL $07F7D2	;clear
	JSL $0187A7	;load tables
        LDA #$88		;set as custom sprite
        STA $7FAB10,X
		
SkipCustom:
	REP #$20	;apply xdisp
	LDA $9A
	CLC
	ADC #!XDISP
	SEP #$20
	STA $E4,x
	XBA
	STA $14E0,x

	REP #$20	;apply ydisp
	LDA $98
	CLC
	ADC #!YDISP
	SEP #$20
	STA $D8,x
	XBA
	STA $14D4,x

	LDA #!XSPD	;store speeds
	STA $B6,x
	LDA #!YSPD
	STA $AA,x

	LDA #$02	;erase self
	STA $9C
	JSL $00BEB0	;generate blank block

SpriteV: 
SpriteH:
MarioCape: 
MarioFireBall:
	PLY		;restore Y
	RTL


That is "gensprite.asm", included with BTSD. I have edited SPRITENUMBER to equal $74, and that generates a Mushroom, despite lacking a "#" sign. I also changed XSPD to $05, and again, that works. But changing XDISP to $00, $0000, or even #$0000, always glitches the game. What gives?
Code
SpriteV: 
SpriteH:
MarioCape: 
MarioFireBall:
	PLY		;restore Y
	RTL


You're pulling without pushing, resulting in the WRONG return address that RTL uses. Instead, change it to this:

Code
	PLY		;restore Y
SpriteV: 
SpriteH:
MarioCape: 
MarioFireBall:
	RTL
Thanks a lot, MarioEdit! That part of the code wasn't mine, so I wonder why it was like that. Also, any idea why it worked with $0020 and nothing below that? I did figure out why the "#" wasn't needed, kinda stupid on my part.
Now, is there a way to make the mushroom come out of the block just like it does in-game? Is there a disassembly for blocks?

Thanks again!
you can use Jagfillit's ? Block if you want it to come out like the original did (Note: DOES NOT WORK WITH FEATHERS)
I change my layout every 4-5 months
ok, im having a little problem with a block im making. here is the block's code. what it's supposed to do is Disable and Always press certain buttons depending on On/Off Status and it checks a random frame then it will switch the On/Off Status. it works good with disabling and pressing but it seems to only switch to Off for 1 frame then switches back to On very quick. could someone find the problem?
I change my layout every 4-5 months
It might be because the code is being executed more than once. Put this somewhere and see if it fixes it:

LDA #$20 ; push mario down so it doesnt get executed again
STA $7D
i found out the problem anyway, it was because i was setting it to act like 25 which makes it get executed more than once so i change it to 130 and it fixed it. well onto making more blocks
I change my layout every 4-5 months
Are there any decent random number generation routines out there? I've officially decided that SMW's normal one ($01ACF9) is a piece of crap.

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

I'm working on a hack! Check it out here. Progress: 64/95 levels.
I'd make one myself by slapping together some random values that often change ($13, $14, $0DBF, $0F30, $2137/$213C/$213D, etc) with random ADCs/SBCs/EORs, and randomly TAX it and add in random tables like $00,x and $06825E,x.
Example:
Code
GetRand:
PLA : PHA;even if it's always called from the same spot, it can't hurt
PHX;just in case
TAX : SBC $06825E,x;add in some garbage so it won't be so sequential
SBC $13 : SBC $14 : ADC $0F30 : EOR $0DBF;get some random numbers (the lack of CLC/SEC is intentional)
TAX : EOR $068636,x;another random table
ADC $2137 : SBC $213C : EOR $213D : ADC $213C : ADC $213D
;throw in the current pixel being drawn by the PPU, in case this routine is called many times per frame
TAX : ADC $00,x;and finally add in a random ram address
PLX : RTS;and return

<blm> zsnes users are the flatearthers of emulation
  • Pages:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 418
  • 419
  • 420