Page 1 of 33

ASM: Request, help and general discussion

Posted: 27 May 2010, 05:55
by Kil2
Ask here if you need asm advice. Some kind soul might even do it for you.
Here you can request help, advice, or even just generally discuss the ASM, level or otherwise, that will be added to the game.

Image

SMW ram map: http://www.smwcentral.net/?p=map&type=ram

^ You can use this to get ideas. Any of these values can be modified during your level for whatever wacky effect you can imagine. A lot of it is even simple enough to bang out a quick levelasm code in 30 seconds.

Image

Note: Deme will be making a list of what's already been inserted.

Image

How to insert Levelasm in 1 easy step

1.0) Go here viewtopic.php?f=9&t=1228 and download Ersanio's level ASM + INIT (Chdata's A2MT version)
1.1) Dump all the files in your main folder
1.2) Go to start menu > accessories > command prompt, and copy that into the same folder
1.3) Open the level.asm file and change !freespace = $xxxxxxxx to some freespace. $938E00 is free in an expanded rom I checked. $21FE00 was free last time I checked the base rom.
1.4) Get xkas from somewhere and dump it in the main folder
1.5) Open levelcodes.asm and copy your levelasm code to the corresponding level
1.6) Open the command prompt in the folder and type [xkas level.asm ROMNAME.smc]
1.7) That's it.

Or refer to this video in which I successfully patch levelasm onto a clean rom http://www.youtube.com/watch?v=jk1Hsl-Hbts

Re: ASM Help Thread

Posted: 27 May 2010, 08:35
by Cup
Oh wow, thank you for offering yourself as a resource. I really appreciate the help. I'm want to get rolling with this so I hope you don't mind if I forgo further thanks and pleasantries and get right into things.

I've started reading through the basic ASM guides linked from SMWC and got myself "Hex Workshop" as a hex editor, but I'm having a hard time playing with anything the guides don't specifically tell me to do.

I was able to follow instructions to do something simple like make it so you lose coins instead of lives, but when I tried playing around with speed I got nowhere. It may be that I can't even find the correct location. I was able to find where mario loses a life by using "goto offset" and typing in 52d8, so I tried 007b for the speed and it took me somewhere, but changing the values that read 7F and 80 I noticed no change in anything. This may be something you can help clear up right away.

Looking at the code line as it reads in Hex Workshop:
(something like this)

000021320 96 14 F0 0A 4A 4A 49 FF 1A 18 69 0B 80 DA E6 19 A9 00 85 71 64 9D 60 A9 7F 85

Assuming these are all important numbers, is there anything in there that jumps out to your seasoned eye, so that you could tell me what it is... the fact that both 80 and 7F show up seems to indicate that I'm in the right place, but when I change these numbers, I get nothing.

I was reading up on Schwa's guide, about branching and conditions. I assume this is what you were referring to when you said "conditionals." If so it would make sense I couldn't make any changes because it seems centered around my next problem...

I'm not sure how to implement "A" style commands (LDA, STA etc). The example I was supposed to copy was to create a .bin with the following code: A0 01 A9 30 8D 93 16 60, but I don't know how to do that... I'm playing around with map 16 right now as well, since this example wants me to use blocktool, which I've never done before, though it seems pretty straightforward.

I think most of my problems stem from me not knowing how to use Hex Workshop. I'm looking through their help page, but I'm finding it difficult to locate the information I need. Is Hex Workshop what I should be using for mario hacks? It seems like a great program but I think I could learn more from you if I use the same program you do so there aren't two layers of confusion to every question I ask.

Wow, that's a lot of confusion there. I'll try to keep posts to one question at a time in the future so things are easier, I also assume as I get past the "getting started" phase, I'll be able to express my troubles in a more efficient way (meaning, i need to learn the language). Thank you again for starting this thread. Hopefully I'll be able to make some progress.

Edit-haha also due to something I changed, the game crashes whenever I pick up a feather. That's hilarious. Not gonna lie, this is pretty fun.

Re: ASM Help Thread

Posted: 27 May 2010, 16:53
by Kil2
Well, no one's going to get very far writing code in a plain hex editor. They're using LevelASM for this project, which is a premade hack that can run code in your level without affecting anything else. Instead of hex edits, write levelasm code using "Ersanio's LevelASM + INIT" which you can get on smwc.

Here's an example of some code that would run during level 105 that would make you move left and right differently http://pastebin.com/LNeiaYsm

Basically hex editing is great when you need to do something like change a single value somewhere, say, what sound effect plays when peach calls for help. Not so much for writing code. It's even more useless in a collab hack where everyone has to use the same rom.

Re: ASM Help Thread

Posted: 27 May 2010, 20:55
by Cup
This makes things so much simpler you wouldn't believe.

I learned how to patch with xkas, so at least some progress here, but when I tried applying Levelcode.asm to test Ersanio's demo ASM of 105 the rom refuses to load. It sticks at the black screen before the nintendo icon shows up. Everything other patch of pre-written asm works find so I'm running into a dead end as far as trouble shooting goes.

It's kind of lame because it's slowing down my own code writing experiments but I'm am having a blast playing with SMWC's patches. So it's not a total loss.

Also xkas seems amazing. I was reading about it on byuu's forum and I have a hard time wrapping my head around how it works, but it's damn interesting.

Re: ASM Help Thread

Posted: 27 May 2010, 21:02
by Kil2
Yeah I forgot to mention, you have to change the freespace pointer in level.asm. By patching without pointing to some free space you kinda destroyed your ROM. First get a backup and then do this:

1. Open rom in LM and make some change. Move a tile, delete an enemy sprite, etc
2. Save it
3. Open the level.asm and find

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Defines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	!FreeSpace 	=
4. Make it !FreeSpace = $938E00 (this SHOULD be free on a blank ROM)
5. Now you can patch levelasm with xkas.

Then just write the code in the levelcode.asm file. Whenever you want to change the code/update/test stuff, just patch level.asm again and reload the rom.

Re: ASM Help Thread

Posted: 27 May 2010, 21:07
by yoshicookiezeus
Kil2 wrote:4. Make it !FreeSpace = $938E00 (this SHOULD be free on a blank ROM)
Didn't we establish that levelASM doesn't work with freespace above $400200? And besides, just saving a level in Lunar Magic only expands the ROM to 1MB, so I don't think that address would even be valid.

Re: ASM Help Thread

Posted: 27 May 2010, 21:49
by VideoGuy
This may sound stupid, but do definitions not work with SpriteTool or something?

When I put

Code: Select all

ACTIVATED_FLAG = $1534,x
at the top of my file, and then do something like

Code: Select all

LDA ACTIVATED_FLAG			; Load Activated Flag
CMP #00						; 0 = Not Activated, 1 = Activated
BEQ CheckIfActivated		; Check if Sprite Should be Activated
it doesn't work. Is there something I'm missing, or am I just doing something wrong?

Re: ASM Help Thread

Posted: 27 May 2010, 22:02
by yoshicookiezeus
As far as I know, there is no assembler that can interpret definitions that way. The ,x should be placed in the code itself, not in the definition.

Re: ASM Help Thread

Posted: 27 May 2010, 22:18
by Kil2
yoshicookiezeus wrote:
Kil2 wrote:4. Make it !FreeSpace = $938E00 (this SHOULD be free on a blank ROM)
Didn't we establish that levelASM doesn't work with freespace above $400200? And besides, just saving a level in Lunar Magic only expands the ROM to 1MB, so I don't think that address would even be valid.
You're thinking of the SNES address. In the rom file, $938E00 should be empty. $938E00 is something around $09:9000 in SNES mapping, a perfectly normal empty area in an expanded 1MB rom. Anyway, this is exactly how I just patched levelasm to an empty rom, so it should work.

Re: ASM Help Thread

Posted: 27 May 2010, 22:19
by Kil2
VideoGuy wrote:This may sound stupid, but do definitions not work with SpriteTool or something?

When I put

Code: Select all

ACTIVATED_FLAG = $1534,x
at the top of my file, and then do something like

Code: Select all

LDA ACTIVATED_FLAG			; Load Activated Flag
CMP #00						; 0 = Not Activated, 1 = Activated
BEQ CheckIfActivated		; Check if Sprite Should be Activated
it doesn't work. Is there something I'm missing, or am I just doing something wrong?
By the way, sprite tool uses TRASM instead of xkas by default which is weird and crappy, so some problems may arise from that.

Re: ASM Help Thread

Posted: 28 May 2010, 02:46
by Chdata
$80:8000

is the exact same thing as

$00:8000

As

$96:8000

is the exact same thing as

$16:8000

Using the $80+ mapping makes codes run slightly faster, because $16 is only a mirror of $96, and $96 is the actual bank so if you're doing stuff directly instead of using a mirror it's apparently faster.

But if you do this you can't expand past 4mb although it's unlikely that anyone would need to do that anyways.

Re: ASM Help Thread

Posted: 28 May 2010, 03:20
by Kil2
Did someone want a runman code? Sounds easy to be honest.

Re: ASM Help Thread

Posted: 28 May 2010, 03:25
by tatanga
Well, I had several ideas in mind. Chdata is helping me with some levelasm for making it so the goal tape sprite disappears when the time expires but you don't die. I have some other ideas though:

Have a runman sprite run through the stage that you chase (similar to the world 2 castle of asmt)

Have runman style player controls

If you want to help it would be greatly appreciated.

Re: ASM Help Thread

Posted: 28 May 2010, 03:27
by Kil2
Sure, can you describe exactly what you need from the runman controls? From what I recall, you're constantly running in either direction and you bounce off walls. What else?

For running on water, you could just use map16 to make water that acts like solid tiles.

Re: ASM Help Thread

Posted: 28 May 2010, 03:32
by tatanga
I'm pretty sure that's about it. I've already added the affect of bouncing up when you fall into a pit by using custom blocks. I guess you could make it so that if you get to running speed you can smash through enemies too, if that isn't too hard.

Re: ASM Help Thread

Posted: 28 May 2010, 03:36
by Kil2
Alright the movement should be easy then. Enemy interaction is something that each enemy sprite does on its own so I don't know how possible that'll be with just levelasm.

Re: ASM Help Thread

Posted: 28 May 2010, 03:39
by tatanga
Well that's already a lot more authentic than I had before so that should be good enough!

Re: ASM Help Thread

Posted: 28 May 2010, 04:26
by Kil2
Can you change direction whenever you want in runman, like just push left and start running left? I'm noticing that by holding left or right and jumping you can kinda walljump up walls, which will probably break your level.

Re: ASM Help Thread

Posted: 28 May 2010, 11:21
by tatanga
Fortunately, that doesn't break my level at all, I don't think. I can't think of any walls I have in my level that aren't intended to be made up, since the level design is loosely based off of an actual runman level.

Re: ASM Help Thread

Posted: 28 May 2010, 12:19
by Machoman
In runman you can only change direction by hitting a wall.

And oh, I need help with one thing.

How do I make horizontal exit enabled pipes in Map16? What should I make the blocks act like.
(I need horizontal from right and left)

Re: ASM Help Thread

Posted: 28 May 2010, 12:24
by yoshicookiezeus
Have the bottom tile of the pipe act 13F.

Re: ASM Help Thread

Posted: 28 May 2010, 12:43
by Machoman
yoshicookiezeus wrote:Have the bottom tile of the pipe act 13F.
Ah thank you!

Re: ASM Help Thread

Posted: 28 May 2010, 14:53
by tatanga
Machoman wrote:In runman you can only change direction by hitting a wall.

And oh, I need help with one thing.

How do I make horizontal exit enabled pipes in Map16? What should I make the blocks act like.
(I need horizontal from right and left)
Umm have you played runman? You can change direction quite easily, actually. The direction is not set in stone at all unless you hold the zoom button.

Re: ASM Help Thread

Posted: 28 May 2010, 15:30
by Kil2
Well then the levelasm's done. If you need one where you can't change direction unless you hit a wall I can easily get that going too.

Code: Select all

level7:
	!MAXRSPEED = #$31
	!MAXLSPEED = #$CF

		LDA $15
		AND #$01
		BEQ +
		STZ $1FFF
		BRA MOVE007
	+	LDA $15
		AND #$02
		BEQ MOVE007
		LDA #$01
		STA $1FFF
MOVE007:		
		LDA $1FFF
		BNE LEFT007

		LDA !MAXRSPEED
	 	STA $7B
		JMP CHECKBOUNCE007

LEFT007:

		LDA !MAXLSPEED
	 	STA $7B

CHECKBOUNCE007:
		LDA $77
		AND #$02
		BEQ +
		STZ $1FFF
		STZ $7B

	+	LDA $77
		AND #$01
		BEQ RETURN007
		LDA #$01
		STA $1FFF
		STZ $7B

RETURN007:		
		RTS
You can adjust the running speed with !MAXRSPEED = #$31 !MAXLSPEED = #$CF to suit your needs. You probably want to adjust them in sync, so if you increase maxrspeed by 2 to #$33, you should decrease maxlspeed by 2 to #$CD.

Re: ASM Help Thread

Posted: 28 May 2010, 15:40
by tatanga
Thanks a lot! I'll test it out right now...