Banner
The Old-School Level Design Contest ends in
9 DAYS, 19 HOURS, 53 MINUTES AND 57 SECONDS
Views: 892,294,766
Time:
20 users online: AmazingChest,  brickblock369, chickaDEE Magazine, cozyduck, Dark Prince, Darkguii, Dr.Moe, Hat Kid, Jeritiel, Koopster, le4che, Magikey, Mariotag1, Paul2003, RPG Hacker, simon.caio, SJandCharlieTheCat,  Tahixham, Vitor Vilela, Yagami - Guests: 59 - Bots: 130 Users: 50,064 (2,328 active)
Latest: gratianne
Tip: Pressing Ctrl + Del in Lunar Magic will delete all objects, sprites, and screen exits from the current level.
Not logged in.
No More Sprite Tile Limits
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - No More Sprite Tile Limits
Pages: « 1 2 3 4 » Link - Thread Closed
http://rafb.net/p/JpDMq557.html

I was bored and decided to perform some optimizations on smwedit's code. Assuming this is called up to 16 times per frame (more?) you need to make this as fast as possible. I'm sure there's other ways to make this faster but SMW is not the game I hack so oh well.

The biggest optimization you'll notice is the loop-unrolling. Loops can be very costly the longer they have to run in order to complete. My "loop" mechanism takes 3 cycles on failure whereas his takes 6. Also the lots of NOPs every call is a big no-no, I can't emphasize that enough. Why complain about having a slow CPU when you're wasting time with it? That's 2 cycles a NOP, which adds up!
I don't know why, but that's glitching all sprites for me... also, here's one major correction:
Code
    LDA $07F000,x		;  |
    PLX			;  |
    STA $15EA,x		;
    
    RTS

should be:
Code
    LDA $07F000,x		;  |
    PLX			;  |
    STA $15EA,x		;
    
    RTL

(notice the RTL)

EDIT: the problem with your code is you test every offset, but the interval should be 4
Code
SearchAlgorithm:
    
    %bulkSpeedup($FC-15)
    %bulkSpeedup($EC-15)
    %bulkSpeedup($DC-15)
    %bulkSpeedup($BC-15)
    %bulkSpeedup($AC-15)
    %bulkSpeedup($9C-15)
    %bulkSpeedup($8C-15)
    %bulkSpeedup($7C-15)
    %bulkSpeedup($6C-15)
    %bulkSpeedup($5C-15)
    %bulkSpeedup($4C-15) ; covers $3D through $4C
    %speedup($3C)
;    %speedup($3B)
;    %speedup($3A)
;    %speedup($39)
    %speedup($38)
;    %speedup($37)
;    %speedup($36)
;    %speedup($35)
    %speedup($34)
;    %speedup($33)
;    %speedup($32)
;    %speedup($31)
    %speedup($30)

Code
macro bulkSpeedup(arg)

    %speedup(<arg>+15)
;    %speedup(<arg>+14)
;    %speedup(<arg>+13)
;    %speedup(<arg>+12)
    %speedup(<arg>+11)
;    %speedup(<arg>+10)
;    %speedup(<arg>+9)
;    %speedup(<arg>+8)
    %speedup(<arg>+7)
;    %speedup(<arg>+6)
;    %speedup(<arg>+5)
;    %speedup(<arg>+4)
    %speedup(<arg>+3)
;    %speedup(<arg>+2)
;    %speedup(<arg>+1)
;    %speedup(<arg>+0)
    
endmacro


EDIT2: but there's still the problem with sprites not changing frames, and the venus fire traps rocketing out of the pipes. also, my YI piranha plant won't open its mouth

EDIT3: actually, I think the sprites stay in their INIT state for some reason, even if the level does not use SP header 10

EDIT4: it doesn't happen in all sprites, but it's either something that has to do with INIT or something with timers

EDIT5: it was the timers, you left 1 too many NOP's in there so it overwrote some of the timer decrementing code (yay! no more skyrocketing venuses!)

EDIT6: some final fixes...
after "BEQ ?notFound" put "LDA.b #<offset>" (the .b seems to be necessary)
remove the "TYA" after ".foundSlot"
remove the long %speedup(*)'s at the end (not bulkspeedups) and put %bulkSpeedup($3C-15)
fair enough, all I did was test to make sure it compiled, not that it was logically sound ;).

you should still see a speed improvement, especially in the worst case scenario.
yes, there is a major speed improvement!

here, this code works, I think I fixed all the glitches
Code
<xmp>header
lorom

!foundSlot = PickOAMSlot_foundSlot

macro speedup(offset)
		LDA $02FD+<offset>	; get Y position of PREVIOUS tile in OAM
		CMP #$F0		; F0 means it's free (Y=F0 means it can't be seen)
		BEQ ?notFound		; \  if last isn't free
		LDA.b #<offset>		;  | (and this is), then
		JMP !foundSlot		; /  this is the index
?notFound:
endmacro

macro bulkSpeedup(arg)
		%speedup(<arg>+12)
		%speedup(<arg>+8)
		%speedup(<arg>+4)
		%speedup(<arg>)
endmacro

org $0180D2

SpriteOAMHook:            
		BRA .cutToTheChase	; skip the NOP's
		NOP			; \
		NOP			;  | use NOP
		NOP			;  | to take
		NOP			;  | up space
		NOP			;  | to overwrite
		NOP			;  | old code
		NOP			;  |
		NOP			;  |
		NOP			;  |
		NOP			;  |
		NOP			;  |
		NOP			;  |
		NOP			; /
.cutToTheChase	JSL PickOAMSlot		; JSL to new code

org $168000	; POINT THIS TO SOME FREE SPACE!!!!!!!!!!!!!

PickOAMSlot:
		LDA $1692		; \  if sprite header
		CMP #$10		;  | setting is not 10,
		BNE .default		; /  use the old code
.notLastSpr	LDA $14C8,x		; \ it's not necessary to get an index
		BEQ .return		; / if this sprite doesn't exist
		LDA $9E,x		; \  give yoshi
		CMP #$35		;  | the first
		BEQ .yoshi		; /  two tiles
		JMP SearchAlgorithm	; search for a slot
.foundSlot	STA $15EA,x		; set the index
.return		RTL			

.yoshi		LDA #$28		; \ Yoshi always gets
		STA $15EA,x		; / first 2 tiles (28,2C)
		RTL

.default	PHX			; \
		TXA			;  | for when not using
		LDX $1692		;  | custom OAM pointer
		CLC			;  | routine, this is
		ADC $07F0B4,x		;  | the original SMW
		TAX			;  | code.
		LDA $07F000,x		;  |
		PLX			;  |
		STA $15EA,x		; /
		RTL
    
SearchAlgorithm:
		%bulkSpeedup($F0)	; \
		%bulkSpeedup($E0)	;  | pre-defined
		%bulkSpeedup($D0)	;  | macros with
		%bulkSpeedup($B0)	;  | code for each
		%bulkSpeedup($A0)	;  | individual
		%bulkSpeedup($90)	;  | slot check
		%bulkSpeedup($80)	;  |
		%bulkSpeedup($70)	;  |
		%bulkSpeedup($60)	;  |
		%bulkSpeedup($50)	;  |
		%bulkSpeedup($40)	;  |
		%speedup($3C)		;  |
		%speedup($38)		;  |
		%speedup($34)		; /
		LDA #$30		; \ if none of the above yield which slot,
		JMP !foundSlot		; / then use the slot at the beginning</xmp>


EDIT: neatened up code a little
Unexpected end tag (</xmp>) at 2424, expected </pre>
So we use that code and it will fix the glitches?
Meaning its almost ready for public release???

--------------------
Your layout has been removed.
Did you take a look at what Boing said about it making AddMusic stop working? I hope that is fixed before it's released.
I think the addmusic bug occurs when you don't correctly point to free space, because where you point it to might for some reason interfere with where addmusic wants to put data. I don't really work with custom music, so I don't really know for sure, but this is my best guess.

Ichigo Says:

smwedit, you never seize to amaze me


UB slot 1
UB slot 2
UB slot 3
:D This will be good in my hack... Banzi Bill Shooter ;)

wow this is so great! i cant even express how cool this is!

--------------------
Kawaii !!


The Metal Information Center

How do I get this patched rom to open up in LM? It required a header, and now it still doesn't accept it. "Wrong game title or wrong format"

And the only thing that happened was that the filename was in captial letters, and I had fixed it. Perhaps I added the header wrong?
--------------------
Thanks to Wraith for the layout.
Will be glad to test hacks. PM me hack information and download links.
Userbars:


make sure it modifies the ROM. if it creates a new ROM file, then that file isn't the patched ROM.
The Metal Information Center

The only change I noticed was that the rom increased in size from 0.5 MB to 0.7 MB, but if the test.smc was with the zip file (which requires a header), then the rom I'm using has just been modified. However, if I increase the size (in order to add a header) and add a header, LM still rejects it with the above problem.

I used SNESTOOL, and all "four" headers don't work, and I applied them separately. I could add it via hex, but I don't know what values to put in so it has one.

Edit: Any other programs used to add headers? SNESTOOL changes the type by making the filename and type captial letters...

Edit2: Should I try the xkas Simple version instead? Maybe that'll fix the problem...

Edit3: Used it all this time...I'll try the regular version...
--------------------
Thanks to Wraith for the layout.
Will be glad to test hacks. PM me hack information and download links.
Userbars:


xkas... simple version? you mean xas (avoid using xas)?

Most people use xkas v.06 as it is the most full featured and stable build. v.10 is new (very very recent) and experimental and the syntax is somewhat different.
The Metal Information Center

I can't seem to figure out what's wrong. The rom has been modified because the file size was increased. And it needed a header, and LM still doesn't accept it. Is there another program that adds headers?

EDIT: I've used both, same results.
--------------------
Thanks to Wraith for the layout.
Will be glad to test hacks. PM me hack information and download links.
Userbars:


Did you point the free space? That's caused me many problems when I've forgotten to do that.
The Metal Information Center

Originally posted by smwedit
Did you point the free space? That's caused me many problems when I've forgotten to do that.


How would you do that? Anything to solve this problem, because this patch sounds very useful...
--------------------
Thanks to Wraith for the layout.
Will be glad to test hacks. PM me hack information and download links.
Userbars:


And dynamic sprites glitch with use of this patch?

--------------------
Your layout has been removed.
no... I actually released a dynamic sprite that needs this patch, the YI ball 'n' chain.
Line error: line 15: invalid code or command [header lorom !foundSlot =
PickOAMSLot_foundSlot macro speedup(offset) LDA $02FD+(offset)]

How do I fix this?
Pages: « 1 2 3 4 » Link - Thread Closed
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - No More Sprite Tile Limits

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2021 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy
  • sm64romhacks