Language…
22 users online: Alex No, Anas, Angel Miranda,  Anorakun, B2De, Blaagon, brickblock369, crocodileman94,  DeppySlide, E-man38, Faro, GRAVITORBOX, HeitorPorfirio2006, Heraga, Israelcv12cv, janklorde, Kaurrs,  Maarfy,  MarioFanGamer, RodMon OP, Romano338, yoshi9429 - Guests: 98 - Bots: 275
Users: 56,286 (2,255 active)
Latest user: Avadar Shadowsong

UberASM Code Library

Welcome to the UberASM Code Library Thread. Here you can post/submit them to your liking.

Just a quick note for those who are new to this and would like to use this. There are two methods to use UberASM:
==================
1.
-The patch UberASM is the patch needed to put the codings in. Please read the Readme.txt file that comes with the patch for more information.
-The latest version of Asar is required for patching alone.

2.
-The latest version of UberASM Tool. Please click the green hyperlink for more information on this.
==================

Now a quick note for those who would like to use/contribute to this:
==================
-Generators from the Sprites section may be eligible for conversion to UberASM.
-For uploading purposes, DO NOT use anything that deletes links after a certain amount of time. Use a permanent file bin, or post your code here.
-When applying a code, Make sure you check if the type of patch is activated. Open 'asar_patch.asm' and find something like this:
Code
;Hihack list
!level     = !false
!OW        = !false
!nmi       = !false
!statusbar = !false
!global    = !false
!sprite    = !false
!gamemode  = !false

;Change '!false' to '!true' if you're going to use that kind of patch.
;If it's not being used, it's best to leave it as '!false'.

-Here is also a list of Game Modes, that may come in handy.
-Here is also ALL Freeram values I took notes of.
==================
_________________________________________________________________

(Currently hosting: 30 UberASM Codes)


NEW
(Gamemode 07/08)
"Press Start" by TheBiob
FreeRAM Required: No
This UberASM code let's you have "Press Start" (Or really any text) blinking on your title screen (Requires this in the same folder to work. Save this as a .txt file and name it "ascii-28.txt").

NEW
Death by Tight Spaces v1.2 by Ruberjig
FreeRAM Required: Yes
This patch causes Mario to die if he is squashed within the floor/platform and the ceiling. This also prevents Mario walking upright in tight spaces. Now requires freeram to work properly, enabling this routine usable anywhere.

NEW
No More "Over the Level" Patch by Ruberjig
FreeRAM Required: No
This prevents Mario from being able to go offscreen above the level. Perfect for those who were tired of players being able to cheat their way through levels.

NEW
Alternate Music Patch v1.2 by Ruberjig
FreeRAM Required: Yes
This patch allows you to have two choices of music during level load. It plays whatever "Song 1" is by default, and "Song 2" when Select is held during the level load. Fixed bugs involving P-switch music and keyhole sequences.

Long Fall Patch by Ruberjig
FreeRAM Required: Yes
This patch triggers a custom timer when the player is in the air/falling, allowing various custom code.

Consecutive Enemies Fix Patch by Ruberjig
FreeRAM Required: No
This stops the "enemies jumped in a row" counter from increasing when you swim or climb, preventing 1up farming.

Slope Pose Patch by Ruberjig
FreeRAM Required: No
This gives Mario custom poses when he is sliding on a different types of slopes, and coming off of it. He also faces in the direction he is sliding as well.

Dash Patch v1.2 by Ruberjig
FreeRAM Required: Yes
Holding the L or R buttons, then letting either one go allows you to quickly dash at running speed. By default, it works on the ground, and while swimming. There is also a setting to allow midair dashes.

AddmusicK's Sound Effects Echo Fix by Kipernal
FreeRAM Required: No
This is supposed to fix a bug for the sound effects.

Alternate Cape Patch v1.5 by Ruberjig
FreeRAM Required: Yes
This is an alternative to the Cape Powerup System. Holding the Up-button and jumping makes you fly without having to run. Holding the down-button and jumping
allows you to pound the ground instantly.
**NOTE: Duck-jump as Caped Mario is also disabled when this is applied.

Alternate P-Balloon Patch v1.1 by Ruberjig
FreeRAM Required: No
Holding the Up-button after jumping makes you able to float left or right in the air as if you had the P-Balloon. You fall down slowly, and if you let go of the jump button, you'll fall completely.

(Under moderation)

Auto Scroll Stop/Start by lolcats439
FreeRAM Required: No
When all enemies on the screen are killed, this will scroll to the next screen, stop, and repeat.

Reversed Walking Controls by Cynook/LDA
FreeRAM Required: No
This simply reverses/swaps the left and right buttons.

SMB2 Vertical Wrap by Magus
FreeRAM Required: No
This code will force a vertical level to not scroll horizontally and make Mario and other sprites to wrap from a side of the screen to the other one, like in SMB2 and SMB3.

(Under moderation)

"Floor" Generator by Chdata/Ladida
FreeRAM Required: No
This is a code that prevents mario from swimming under the bottom of the level, complete with support for anti-breaking swimming under blocks placed at the very bottom row in Lunar Magic.

Riding Yoshi Custom Trigger by Decimating DJ/Siredav
FreeRAM Required: No
This code creates a flag that indicates if Mario is riding Yoshi.

Disable Death Scroll by Ruberjig
FreeRAM Required: No
This makes it so that when the player dies, the screen doesn't scroll vertically anymore.

Climbing Net Punch Disable by Final Theory
FreeRAM Required: No
This disables the ability to punch on the climbing net objects.
(Also frees up RAM values $149D and $149E)

"Fixed" Crouch Jump by Ruberjig
FreeRAM Required: No
This makes the player upright after jumping, even when ducking. Perfect for those who think crouching in mid-air looked weird.
Fixed link.

Disable Pause During P-Switch Timer by Ruberjig
FreeRAM Required: No
This disables the pause button while the P-switch is active.

Non-existant Player by Ruberjig
FreeRAM Required: No
Makes Mario invisible and disableS all controls.

"Fixed" Low Gravity by Ruberjig
FreeRAM Required: No
Sets a slightly more accurate low gravity function in the current level.

Automatic Power Swapping Gimmick by Ruberjig
FreeRAM Required: No
Creates a gimmick that automatically swaps Mario's powerup time after time.

Autoscrolling Layer 2 by Ruberjig
FreeRAM Required: No
Causes Layer 2 (BG) to automatically scroll left. You can also set it to scroll right.

SMB1 Styled Scrolling Pack by GreenHammerBro
FreeRAM Required: No
This patch makes the level scrolling like in SMB1. There is also a vertical version included.

Automatic Walking by Nesquik Bunny
FreeRAM Required: No
This will let Mario walk automatically. He will turn in the opposite direction when he hits a wall or object. Can also be set to disable jumping and spin-jumping too since they can be annoying with auto-walk sometimes.

(Gamemode_E)
Save Game Trigger by LX5
FreeRAM Required: No
This allows the player to save the game at anytime on the overworld by pressing Select.

(Gamemode_init_14)
Perfect Sprite Initial Facing Fix by GreenHammerBro
FreeRAM Required: No
This uberasm code fixes a bug in smw that if you go to another (sub)level, the sprite's init facing in the next level will use mario's last x position in the previous level.

Translucent Layer 1 in Vertical Levels by imamelia
FreeRAM Required: No
This allows you to have the same translucency effect as Level Modes 1E and 1F in a vertical level.

Layer 4 by MolSno
FreeRAM Required: No
Allows the addition of a fourth background layer.

--------------------------------------------------------
Feel free to comment, submit, or report any bugs.

**Moderators/Staff are allowed to edit this post however if necessary. This thread/post will also be updated when needed.
Sticking this, as we can do lot of things by just using uberASM's code/game_mode/init/main codes without having to do an entire patch.

Feel free to submit your codes here.
GitHub - Twitter - YouTube - SnesLab Discord
Wow, sticky?


The idea is pretty cool, but it's really confusing to use. It keeps launching me in random directions.

And you might want to add code to handle when your are on wall triangles.
the people who watch hentai as an anime, and not just as a porn, are the superior race
Just dug this up from my old Mario & Luigi: Starlight Island Adventure WIP thread. It'll allow you to have the same translucency effect as Level Modes 1E and 1F in a vertical level. This is to be inserted into LevelInit and was created by imamelia, so it might be good to give him credit.

Code
;for non-Layer 2 levels
LDA #$21
STA $40


Code
;for Layer 2 levels
LDA #$22
STA $40

Quintesson Judge: Silence, or you will be held in contempt of this court!
Hot Rod: I have nothing but contempt for this court!
- Transformers the Movie (1986)
This could be useful:

LDA $15
AND #$03
BEQ .Return
LDA $15
EOR #$03
STA $15
.Return
RTS


It reverses Mario's controls, like walking right will make you walk left, etc. Put this in level_code.
Cool, but

Code
LDA $15
BIT #$03
BEQ .Return
EOR #$03
STA $15
.Return:
RTS

Is more efficient.
the people who watch hentai as an anime, and not just as a porn, are the superior race
Since I've gotten a few PMs asking me about this, I figure I might as well share my Mode 0 code.

levelinit:
Code
STZ $3E
LDA #$51 : STA $2109
LDA #$59 : STA $210A
LDA #$24 : STA $210C
	
LDA #$11 : STA $212C
LDA #$0E : STA $212D
	
REP #$20 : LDA $20 : SEP #$20
STA $2112 : XBA : STA $2112
	
REP #$20 : LDA $24 : SEP #$20
STA $2114 : XBA : STA $2114
RTS

This should give you 4 layers to work with. The level's layer 3 tilemap (the one you can edit in Lunar Magic) will be used for both layers 3 and 4. The top half will be layer 3 and the bottom half will be layer 4. Keep in mind that you'll have to convert all of your graphics for layers 1-4 to 2bpp.

Also I included main/subscreen designations because I believe there were originally issues with sprite priority when I first implemented this.

The last two blocks of code are there to initialize the vertical positions of layers 3 and 4 to match the vertical position of layer 2. Feel free to remove it if you don't want them to have the same vertical positions.

Also, in case you want to control the scrolling in each layer, here's something to go in level_code:
Code
; Layer 2 V-Scroll = Layer 1 V-Scroll
REP #$20 : LDA $1C : SEP #$20
STA $2110 : XBA : STA $2110
	
; Layer 3 V-Scroll = Layer 2 V-Scroll
REP #$20 : LDA $20 : SEP #$20
STA $2112 : XBA : STA $2112

; Layer 4 H-Scroll = Layer 3 H-Scroll / 4
REP #$20 : LDA $22 : LSR A : LSR A : SEP #$20
STA $2113 : XBA : STA $2113
	
; Layer 4 V-Scroll = Layer 3 V-Scroll
REP #$20 : LDA $24 : SEP #$20
STA $2114 : XBA : STA $2114
RTS
Oh, neat. Are there any other restrictions when using that besides the obvious limitation of the graphics being 2bpp? Is there anything else you can do with it other than just having an extra background layer (and I do mean background layer, since Mode 0 doesn't have a priority bit like Mode 1 does), thereby having either 2 or 3 backgrounds rather than 1 or 2 depending on whether or not Layer 2 is set to be a foreground layer?

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

I'm working on a hack! Check it out here.
Originally posted by imamelia
Oh, neat. Are there any other restrictions when using that besides the obvious limitation of the graphics being 2bpp? Is there anything else you can do with it other than just having an extra background layer (and I do mean background layer, since Mode 0 doesn't have a priority bit like Mode 1 does), thereby having either 2 or 3 backgrounds rather than 1 or 2 depending on whether or not Layer 2 is set to be a foreground layer?

I don't think there are necessarily any other limits besides the graphics being 2bpp. Although if you want to have the status bar you're going to have to use a sprite status bar of some kind. In my case I created my own kind of status bar for the level I used it in and I quickly found sprite graphics to be a hot commodity, but I don't know if that will be a problem for everyone.

As for your second question, having an extra background layer is the only purpose I could think of. However there may be other things you could do with it that I haven't thought of.
null
I do art commissions cheap! PM here or DM via Discord for more details.

**Layout by Erik557


I need mention thank you for those who have posted their codes. More codes are added to the first post.
I do art commissions cheap! PM here or DM via Discord for more details.

**Layout by Erik557


Um, the link to the uberasm file is broken, probably due to an update to fix a bug with the gamemode and gamemode init. Here is an up to date version link.

Anyway, I made a sprite initial facing fix that is better than alcaro.

Edit: Wait, This should able to fit in a thread:
Code
;Perfect Sprite initial facing fix, By GreenHammerBro

;This uberasm code fixes a bug in smw that if you go to another (sub)level,
;the sprite's init facing in the next level will use mario's last x position
;in the previous level.

;Unlike Alcaro's patch, this one is guaranteed it will always work.

;Insert this code in "gamemode_init_14" (level mode init, not to be confused
;with regular gamemode 13 (level load, that is, runs multiple frames during
;fading)).

if !SA1
	;Sa-1 stuff:
	!NumbOfSprSlots	= 22
	!SprTbl_E4	= $322C		;>Sprite x pos, lo byte
	!SprTbl_14E0	= $326E		;>Sprite x pos, hi byte
	!SprTbl_157C	= $3334		;>Sprite horiz facing 0 = R, 1 = L
else
	;Non-sa-1 stuff:
	!NumbOfSprSlots = 12
	!SprTbl_E4	= $E4		;>Sprite x pos, lo byte
	!SprTbl_14E0	= $14E0		;>Sprite x pos, hi byte
	!SprTbl_157C	= $157C		;>Sprite horiz facing 0 = R, 1 = L
endif

FixFacing:
	LDX.b #!NumbOfSprSlots-1	;>Start loop.
.SlotLoop
	STZ !SprTbl_157C,x		;>Starts out as going right.
	LDA !SprTbl_14E0,x		;\Transfer sprite high byte
	XBA				;/to high byte of A
	LDA !SprTbl_E4,x		;>Load the low byte position
	REP #$20
	CMP $94				;>Compare with the player's x position (low and high)
	SEP #$20
	BMI .SprOnLeft			;>If sprite is left of player, leave $157C as zero
;SprOnRight
	INC !SprTbl_157C,x		;>Otherwise, make $157C = 1 to go left.
.SprOnLeft
	DEX				;>Next slot
	BPL .SlotLoop			;>If slot is 0 or positive, loop.
	RTS

Note that other sprites like message box sprite also gets effected.
Give thanks to RPG hacker for working on Asar.
null
I do art commissions cheap! PM here or DM via Discord for more details.

**Layout by Erik557


I can't believe how few codes and posts there are here. I know that there are tons of patches though. I know that some patches can be converted to level asm code, but I also know other patches are much harder to convert.

There should be like hundreds of codes here that anyone can apply to a specific level.

Well anyway, someone helped me code this. It makes it so that the x and y buttons are disabled while climbing on a chain fence.

The reason for this was because I wanted to have vines which allowed diagonal movement so I used a vine tile with the fence property act as setting.

Code
BIT $74
		BPL +
		LDA #$40
		TRB $16
		TRB $18
	+	RTS


But the code is like 99% perfect. If you jump and punch at the same time sometimes you will see a punch on the vine. Buts its pretty close so yeah.
I know I shouldn't ask here, but is there a code that will disable L/R scrolling for 1 screen?
(and possibly make a sound?)
Originally posted by Cynook
I know I shouldn't ask here, but is there a code that will disable L/R scrolling for 1 screen?
(and possibly make a sound?)


Maybe this bit of screen code from the ASM code library can help you out.
I do art commissions cheap! PM here or DM via Discord for more details.

**Layout by Erik557


I'm not sure who wanted a code to trigger the save prompt while on overworld (I don't seem able to find the post anymore), but this code is fully working:

Code
gamemode_E:
	LDA $1B87
	BNE .return	;do not trigger if it is displayed already

	LDA $13D9          
	CMP #$03	;is mario on a level tile?
	BNE .return

	LDA $16
	AND #$20	;check if select is pressed
	BEQ .return

	PHB
	REP #$30
	LDX.w #$1EA2
	LDY.w #$1F49	;move data to sram buffer
	LDA.w #140
	MVN $7E,$7E
	SEP #$30
	PLB 
	
	LDA #$05
	STA $1B87	;initialize save prompt
.return
	RTS
It was me, thanks for posting that.
My version didn't work, because the buffer part was missing.
My Youtube channel

Currently working on:
Project C

Finished project:
Are you sure that code is written right? It's not working on my end...
I do art commissions cheap! PM here or DM via Discord for more details.

**Layout by Erik557


Yeah, I tested it again and it works.

Be sure that you are using the newest version of uberASM. At some point gamemode_code and gamemode_init_code were swapped and you may have that version.