Language…
10 users online: Cristian Cardoso, howardadam1126, Isikoro, lean4, marvisjj, Oskise, RenkoV2,  Segment1Zone2, SpacePea, Zavok - Guests: 259 - Bots: 293
Users: 64,795 (2,377 active)
Latest user: mathew

Effect tool help

  • Pages:
  • 1
  • 2
I know how to use HDMA gradiants, but are they recommended to be used as standard sprites or as generators? Plus, I have problems with wave effects, when I insert them in my hack, the background is not moving, and when I insert a vertical wave effect, it glitches.
I really need help with this.
Gotta aim fast.
Personally I've had great results with making the HDMA level ASM. You just have to change the lines that say...

Code
.InitCode:
and...
Code
.MainCode:

to...

Code
INIT:
and...
Code
MAIN:



You'll also have to change the lines that say...

Code
RTS
to...
Code
RTL
Originally posted by Hunter-
Personally I've had great results with making the HDMA level ASM. You just have to change the lines that say...

Code
.InitCode:
and...
Code
.MainCode:

to...

Code
INIT:
and...
Code
MAIN:



You'll also have to change the lines that say...

Code
RTS
to...
Code
RTL

Are all these codes applicable to wave effects ?
Gotta aim fast.
All of the changes are necessary.
Okay, I'll try it, thanks, the only one thing I want to know is: is it recommended to use these effects as standard sprites or as generators?
Gotta aim fast.
It's not working, when I change

Code
RTS 

into

Code
RTL


The game crashes.
is there another solution for this?
Gotta aim fast.


How are you inserting the code? If you're inserting it through UberASM, are you using the tool?

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Nope, I'm using sprite tool.
Gotta aim fast.
I tried using it with uber asm, but it's not working. And I want to use the wave effects with sprite tool, but when I do so, the game crashes, do I need to add something in the .asm file?
Gotta aim fast.


We'll need to see the actual code you are inserting right now to provide accurate information.

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Here's the modified code that I tried to use:

Code
; To be inserted as generator with SpriteTool (as number D0 - FF).

print "INIT ",pc
print "MAIN ",pc
PHB : PHK : PLB
JSR Sprite
PLB
RTL


Sprite:

.INIT:                  ;\  This section is to be used in the INIT code of levelASM
   REP #$20             ; | 
   LDA #$1002           ; | Use Mode 02 on register 2110
   STA $4330            ; | 4330 = Mode, 4331 = Register
   LDA #$9E00           ; | Address of HDMA table
   STA $4332            ; | 4332 = Low-Byte of table, 4333 = High-Byte of table
   SEP #$20             ; | 
   LDA.b #$7F           ; | Address of HDMA table, get bank byte
   STA $4334            ; | 4334 = Bank-Byte of table
   LDA #$08             ; | 
   TSB $0D9F            ; | Enable HDMA channel 3
   RTS                  ;/  End HDMA setup	  	

;The Table takes up 226 bytes of the free RAM
;It ranges from $7F9E00 - $7F9EE1 (both addresses included)

.MAIN:                  ;\  This section is to be used in the MAIN code of levelASM
   LDY #$00             ; | Y will be the loop counter.
   LDX #$00             ; | X the index for writing the table to the RAM
   LDA $13              ; | Speed of waves
   LSR #1               ; | Slowing down A
   STA $00              ;/  Save for later use.

   PHB : PHK : PLB      ;\  Preservev bank
.Loop:                  ; | Jump back if not finished writing table
   LDA #$03             ; | Set scanline height
   STA $7F9E00,x        ; | for each wave
   TYA                  ; | Transfer Y to A, to calculate next index
   ADC $00              ; | Add frame counter
   AND #$0F             ; | 
   PHY                  ; | Preserve loop counter
   TAY                  ;/  Get the index in Y

   LDA.w .WaveTable,y   ;\  Load in wave value
   LSR                  ; | Half only
   CLC                  ; | Clear Carry for addition
   ADC $20              ; | Add value to layer Y position (low byte)
   STA $7F9E01,x        ; | store to HDMA table (low byte)
   LDA $21              ; | Get high byte of X position
   ADC #$00             ; | Add value to layer X position (low byte)
   STA $7F9E02,x        ;/  store to HDMA table (high byte)

   PLY                  ;\  Pull original loop counter
   CPY #$4A             ; | Compare if we have written enough HDMA entries.
   BPL .End             ; | If bigger, end HDMA
   INX                  ; | Increase X, so that in the next loop, it writes the new table data...
   INX                  ; | ... at the end of the old one instead of overwritting it.
   INX                  ; | 
   INY                  ; | Increase loop counter
   BRA .Loop            ;/  Repeat loop

.End:                   ;\  Jump here when at the end of HDMA
   PHK                  ; | Pull back data bank.
   LDA #$00             ; | End HDMA by writting 00...
   STA $7F9E03,x        ; | ...at the end of the table.
   RTL                  ;/  

.WaveTable:             ;\  
   db $00               ; | 
   db $01               ; | 
   db $02               ; | 
   db $03               ; | 
   db $04               ; | 
   db $05               ; | 
   db $06               ; | 
   db $07               ; | 
   db $07               ; | 
   db $06               ; | 
   db $05               ; | 
   db $04               ; | 
   db $03               ; | 
   db $02               ; | 
   db $01               ; | 
   db $00               ;/  

Gotta aim fast.
You're only running .INIT but not .MAIN. Remember: A HDMA code has got at least a initial code to set up the HDMA and for dynamic HDMA (such as parallax or waves), there also is a main code. What you're supposed to do is to call INIT in the sprite init code (i.e. below print "INIT ",pc) and the main code in the main code (i.e. below print "MAIN ",pc). The resulting code would look like this:
print "INIT ",pc
JSR Sprite_INIT

print "MAIN ",pc
JSR Sprite_MAIN
LDX $15E9
RTL

Why Sprite_INIT and Sprite_MAIN? Because .INIT and .MAIN are declared as sublabels i.e. they have a parent (in this case Sprite). Calling them directly is only possible if you move Sprite to the top. The data bank stuff at the top are redundant since the main code already has the data bank stuff. The LDX $15E9 exists because the main code modifies the X register and restoring it is necessary as the game doesn't restore the sprite index afterwards.
It is still not working, and the game still crashes when replacing RTS with RTL, here's the code that I inserted:
Code
; To be inserted as generator with SpriteTool (as number D0 - FF).

print "INIT ",pc
print "MAIN ",pc
PHB : PHK : PLB
JSR Sprite
PLB
RTL


Sprite:

.JSR Sprite_INIT:       ;\  This section is to be used in the INIT code of levelASM
   REP #$20             ; | 
   LDA #$1002           ; | Use Mode 02 on register 2110
   STA $4330            ; | 4330 = Mode, 4331 = Register
   LDA #$9E00           ; | Address of HDMA table
   STA $4332            ; | 4332 = Low-Byte of table, 4333 = High-Byte of table
   SEP #$20             ; | 
   LDA.b #$7F           ; | Address of HDMA table, get bank byte
   STA $4334            ; | 4334 = Bank-Byte of table
   LDA #$08             ; | 
   TSB $0D9F            ; | Enable HDMA channel 3
   RTL                  ;/  End HDMA setup	  	

;The Table takes up 226 bytes of the free RAM
;It ranges from $7F9E00 - $7F9EE1 (both addresses included)

.JSR Sprite_MAIN:       ;\  This section is to be used in the MAIN code of levelASM
   LDY #$00             ; | Y will be the loop counter.
   LDX #$15E9           ; | X the index for writing the table to the RAM
   LDA $13              ; | Speed of waves
   LSR #1               ; | Slowing down A
   STA $00              ;/  Save for later use.

   PHB : PHK : PLB      ;\  Preservev bank
.Loop:                  ; | Jump back if not finished writing table
   LDA #$03             ; | Set scanline height
   STA $7F9E00,x        ; | for each wave
   TYA                  ; | Transfer Y to A, to calculate next index
   ADC $00              ; | Add frame counter
   AND #$0F             ; | 
   PHY                  ; | Preserve loop counter
   TAY                  ;/  Get the index in Y

   LDA.w .WaveTable,y   ;\  Load in wave value
   LSR                  ; | Half only
   CLC                  ; | Clear Carry for addition
   ADC $20              ; | Add value to layer Y position (low byte)
   STA $7F9E01,x        ; | store to HDMA table (low byte)
   LDA $21              ; | Get high byte of X position
   ADC #$00             ; | Add value to layer X position (low byte)
   STA $7F9E02,x        ;/  store to HDMA table (high byte)

   PLY                  ;\  Pull original loop counter
   CPY #$4A             ; | Compare if we have written enough HDMA entries.
   BPL .End             ; | If bigger, end HDMA
   INX                  ; | Increase X, so that in the next loop, it writes the new table data...
   INX                  ; | ... at the end of the old one instead of overwritting it.
   INX                  ; | 
   INY                  ; | Increase loop counter
   BRA .Loop            ;/  Repeat loop

.End:                   ;\  Jump here when at the end of HDMA
   PHK                  ; | Pull back data bank.
   LDA #$00             ; | End HDMA by writting 00...
   STA $7F9E03,x        ; | ...at the end of the table.
   RTL                  ;/  

.WaveTable:             ;\  
   db $00               ; | 
   db $01               ; | 
   db $02               ; | 
   db $03               ; | 
   db $04               ; | 
   db $05               ; | 
   db $06               ; | 
   db $07               ; | 
   db $07               ; | 
   db $06               ; | 
   db $05               ; | 
   db $04               ; | 
   db $03               ; | 
   db $02               ; | 
   db $01               ; | 
   db $00               ;/  

Gotta aim fast.
All you were supposed to do is to replace
Code
print "INIT ",pc
print "MAIN ",pc
PHB : PHK : PLB
JSR Sprite
PLB
RTL

with
Code
print "INIT ",pc
JSR Sprite_INIT

print "MAIN ",pc
JSR Sprite_MAIN
LDX $15E9
RTL


Granted, it was a bit of a misunderstanding but only because I wasn't aware that Effect Tool generates generator code too.

However, there is another thing to note: Make sure to insert this effect as a regular sprite as generators don't have any init code.


Edit: Or I thought to complicated: You just had to remove the first RTS in the old code. That will run the HDMA initialisation again but it's pretty much harmless.
Even when I removed the first RTS and replaced RTS with RTL in the main code, the game still crashes. what should I do about it?
Gotta aim fast.
I tried the lastest version of Effect tool, and tried to insert the wave effect with uberasm, and it works perfectly now. Thank you and sorry for the trouble.
Gotta aim fast.
Originally posted by MegaSonic1999
I tried the lastest version of Effect tool, and tried to insert the wave effect with uberasm, and it works perfectly now. Thank you and sorry for the trouble.

In your defense: It has been submitted relatively recently.
A little problem with the wave effects: when opening a message box, then close it, the wave effect stops. How to fix this?
Gotta aim fast.


There's a small hex edit regarding that, at $05B129/$05B296:

Code
org $05B129
	NOP #3

org $05B296
	db $0C

honestly this should probably just be made into its own patch

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Do I need to insert it with asar, or add it to the wave code?
Gotta aim fast.
  • Pages:
  • 1
  • 2