(shouting)

Anyone want to test an SMBX extension module?

wanna make a game, or anything else? seminal bloom!
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

Aww. Ok. :P Well, that would still be pretty nice. I'm hardly going to force you to do loads of work, especially since you've already made this in the first place.

I just had so many ideas that I couldn't go through with in ASMBXT due to the restrictive events system. And I wanted to go really over the top. :P
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

The easiest way others could help me is by figuring out some static memory locations either in ollydbg or the easier methods like using Cheat Engine, so basically RAM MAP building.

They are mostly around the 00B2xxxx area, here is what I have currently

Code: Select all

00B25068  .data     Label       pVkeyTable
00B250A0  .data     Label       pVkeyTable/
00B25134  .data     Label       bLevelEditing
00B253C4  .data     Label       pCopiedKeys//
00B253C6  .data     Label       CopyKey1
00B253C8  .data     Label       CopyKey2
00B253CA  .data     Label       CopyKey3
00B253CC  .data     Label       CopyKey4
00B253CE  .data     Label       CopyKey5
00B253D0  .data     Label       CopyKey6
00B253D2  .data     Label       CopyKey7
00B253D4  .data     Label       CopyKey8
00B253D6  .data     Label       CopyKey9
00B253D8  .data     Label       CopyKey10
00B253DA  .data     Label       CopyKey11
00B257D4  .data     Label       pSectionBoundaries
00B257F0  .data     Label       pSectionStuff
00B25956  .data     Label       UnkLayerMov
00B2595A  .data     Label       NPCCount
00B2595E  .data     Label       NumOfPlayers
00B259E8  .data     Label       pMobsList/
00B25A20  .data     Label       pPlayerObjList
00B25C34  .data     Label       pSpriteSettingsUnk
00B25D14  .data     Label       pSpriteNoCollisionTable
00B25E64  .data     Label       pSpriteSomethingTable
00B25EF0  .data     Label       pSpriteSettings4
00B25F0C  .data     Label       pSpriteSettings5
00B2B9E4  .data     Label       bRunGame
00B2C59C  .data     Label       bDeathState/
00B2C59E  .data     Label       LevelEndState
00B2C5A0  .data     Label       LevelEndTimer
00B2C5D4  .data     Label       Unknown
00B2C5EC  .data     Label       pSectionUnk
00B2C614  .data     Label       LevelEditor//
00B2C620  .data     Label       bTitleScreen/
00B2C62E  .data     Label       UnkDecTimer
00B2C66C  .data     Label       UnkEvents
00B2C670  .data     Label       TransitioningFrameCounter
00B2C67C  .data     Label       ActiveFrameCounter
00B2C680  .data     Label       FPActiveFrameCounter
00B2C690  .data     Label       DFPSubtractTickAmt
00B2C6B0  .data     Label       pLayers
00B2C6CC  .data     Label       pSomeText
00B2C6FC  .data     Label       SmallDemoHeight
00B2C706  .data     Label       BigDemoHeight
00B2C74C  .data     Label       BigDemoDUckHeight
00B2C87C  .data     Label       Unk
00B2C896  .data     Label       Unk
00B2C8B4  .data     Label       bOnlyPlayersActive
00B2C8BA  .data     Label       ConstantCoinStream/
00B2D72C  .data     Label       DFPTickCount
00B2D738  .data     Label       DFPLastTickAmt
00B2D740  .data     Label       bBattleMode
00B2D760  .data     Label       BattleModeRelated1
User avatar
SAJewers
ASMBXT Level Wrangler/A2XT Project Coordinator /AAT Level Designer
Posts: 4200
Joined: 11 years ago
Location: Nova Scotia

Re: Anyone want to test an SMBX extension module?

Post by SAJewers »

You've probably looked at this already, but does this help you at all? Someone Decompiled SMBX into source code. Mostly unseable/can't be recompiled, but it may help you.

http://nsmbxforums.prophpbb.com/topic2814.html
ImageImageImageImageImage | Image | Image
Sharenite | RetroAchievements | NameMC | IGDB
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

I remember that. I use it to get some clues when I have no idea what I'm looking at, but otherwise there's not a lot one can glean from it since all the variable names are mangled.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

SAJewers asked for some thingy so I've added some basic framework functions for accessing stuff during frames.

GetPlayer(int WhichPlayer) - This function traverses the player array for you and returns a pointer to the specified player's sprite object. One of the things you can do when you have a pointer to a sprite's data is check which keys that sprite is pressing, so in this framecode it's checking each frame for double taps of the down key.

PlayerPressingDown() and CyclePlayerRight() - These are just some (safe) helper functions for operation on a player object.

Code: Select all

void testCode() {
	PlayerMOB* demo = GetPlayer(1);
	if(demo == 0)
		return;

	if(PlayerPressingDown(demo)) {
		// If still holding down, return
		if(gFrames - 1 == gLastDownPress) {
			gLastDownPress = gFrames;
			return;
		}

		// Else, see if pressed down in the last 7 frames
		if(gFrames < gLastDownPress + 7) {
			CyclePlayerRight(demo);
		}
		gLastDownPress = gFrames;
	}
}
Too lazy to update the source right now but I don't think anyone but me is planning on doing much with this at the moment.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

Are you able to make it so that down is always pressed? That would be interesting for a sliding level.
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

Yeah actually, lol. ANything you can think of with manipulating these you can probably do:

Code: Select all

// - Player MOB Struct. size = 0x184 (388 bytes)
//
//+0x00		qw	= X position (absolute coordinates within level)
//+0x08		qw	= Y position (absolute coordinates within level)
//+0x10		qw	= height or hitbox related
//+0x18		qw	= width or hitbox related
//+0x20		qw	= X speed
//+0x28		qw	= Y speed

//+0x50		w	= Spinjump flag (-1 = true)
//+0x52		w	= Spinjump state counter

//+0xF0		w	= Player identity index (1 = demo, 2 = iris, 3 = princess, 5 = sheath)

/// - KEYS - 
//+0xF2		w	= U key pressing
//+0xF4		w	= D key pressing
//+0xF6		w	= L key pressing
//+0xF8		w	= R key pressing
//+0xFA		w	= J key pressing
//+0xFC		w	= SJ key pressing
//+0xFE		w	= X key pressing
//+0x100	w	= RN key pressing
//+0x102	w	= SEL key pressing
//+0x104	w	= STR key pressing

/// - STATES -
//+0x106	w	= Direction faced (-1 = left)
//+0x108	w	= Riding state
//+0x112	w	= Current powerup
//+0x122	w	= Powering up animation state (1 = up, 2 = down)

//+0x13C	w	= Player dead bool?
//+0x13E	w	= Player death animation timer
//
//+0x15A	w	= Current section
//
Still trying to figure out what the other fields are but a lot of them are pretty mysterious.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

Oooh, so you can stop the player turning around too? That's cool.

I need to make levels abusing those settings. :P
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

Yeah I know there's a whole shitload of static ram addresses in the 00B2xxxx range that would probably be super helpful if we knew what they did.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

Someone should put this somewhere http://www.youtube.com/watch?v=cIDGrIZl ... e=youtu.be

Also I'm making a "this thing" tutorial in case I get hit by a meteor
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

Part 1. Basics

LunaDLL is an extension module for smbx. It is a collection of customizable code that can be recompiled relatively easily. It allows you to manipulate smbx's memory while it is being run, the only limit to what can be done being what knowledge we have of the smbx memory layout. Not a whole lot is known right now other than the player object, meaning it's easy to do stuff to mario/demo.

Anyway, let's just assume some intrepid individual out there wants to compile their own version of the DLL with their custom levelcode in it. You're probably going to need some kind of programming experience to utilize this. Getting a C++ compiler to compile the source is a bit beyond the scope of this tutorial. There's free compilers and IDEs out there, including microsoft VS express. If you get MSVS express, you can use the solution (.sln) file to probably easily load and compile the DLL just by pushing F6.

DLL Package: http://www.gamearchaeology.com/LunaDllPackage.zip
- source.zip: This contains the source if you want to compile your own. Microsoft Visual Studio Express can open .sln files, and that'd be the easiest way.
- asmbxtEXT.exe: This is the old asmbxt executable with an added hook that calls the DLL.
- LunaDLL.dll: This is a precompiled dll which currently has code that only activates in one specific level (if you have SAJewers-QraestoliaCaverns.lvl, try double tapping down while playing it)

Anyway, if you can get your compiler to spit out your own LunaDll, then the hard part is over for you. You can just overwrite the old dll and your new code will be running in game.


Actually doing things

Step one would be having some idea of what you want to do. You could open PlayerMOB.h and check out some of the data you can fool around with in the player object. One of the first things you'll see is a bunch of memory addresses involving Peach's hover, so as an example, let's try making a gimmick around giving Peach an infinite amount of hover in our level.

Now the easiest way to test codes would be to just have them be active all the time rather than in specific levels. There is a place in the code and function for this very purpose. In Main.cpp you will see this near the bottom:

Code: Select all

// TEST CODE - This code will run every frame everywhere, making for easy testing
void TestFrameCode() {
Whatever you write here will run every frame, so this is where we'll put the code. So where the hell do you start?

Always remember rule #1: Everything is about manipulating the game's memory in order to convey the experience you want to the player. So with our infinite hover goal in mind, we need access to the memory that times how long Peach can hover. This is actually a part of the player object.

I've already included some basic framework for making things easier for me (and you) to manipulate the game's memory. The GetPlayer() function gives you a pointer to the player object.

Code: Select all

PlayerMOB* pDemo = GetPlayer(1);
If you took Java classes or something and don't like pointers, just think of a pointer like a handle or leash to an object. Let's dissect the line for the sake of clarity

Code: Select all

PlayerMOB* pDemo
This means "Make a PlayerMOB pointer(*) and name it pDemo (pointer to Demo)". Simply having a pointer isn't useful. We need it to point to the actual player object that smbx has in memory already, so...

Code: Select all

GetPlayer(1);
GetPlayer() is a function I've set up to traverse the player list for you. When you need to do something to the player, GetPlayer(1) returns a pointer to the specified player's memory (the 1 means player 1).

Put it together and it says "Make a PlayerMOB pointer(*) and name it pDemo, and also set it to point to the return value of GetPlayer(1)".


Now that you have an accurate pointer to the player object, you can pretty much do whatever madness you can imagine. I've set up another function named PlayerPressingJump() which returns either true or false if the player is pressing the jump button. You could also use some built in functions or poll the keyboard to figure out if a key is being pressed but, this is much faster and easier. Let's use that function to make a conditional branch and set Peach's hover timer.

Code: Select all

	if(PlayerPressingJump(pDemo)) {
		pDemo->PeachHoverTimer = 10;
	}
The function PlayerPressingJump() takes a pointer to a player and checks if that player is pressing jump. Our code here says that, if that is true, run the bracketed statements.

The bracketed statement is simply using our pointer to directly access Demo's memory and set one of its fields.

Code: Select all

pDemo->PeachHoverTimer = 10;
Set the PeachHoverTimer field of Demo's memory to 10. (in Java you use the dot . operator to access and object, but since this is C and you're trying to access an object by dereferencing a pointer, you use the -> operator)

(To see all the fields a PlayerMOB has to mess around with, check PlayerMOB.h, or sometimes visual studio will show you a list if it feels like it.)

Since the code we just made will run every frame everywhere, the timer will never be able to decrease below 10 so long as you hold the jump button, meaning our objective is fulfilled with only 3 lines of code.

Code: Select all

// TEST CODE - This code will run every frame everywhere, making for easy testing
void TestFrameCode() {
	PlayerMOB* pDemo = GetPlayer(1);

	if(PlayerPressingJump(pDemo)) {
		pDemo->PeachHoverTimer = 10;
	}
}
Push F6 and overwrite the old DLL in the game's folder alongside asmbxtEXT.exe and it should work.

That's the end of this part. If you don't have any programming experience in some language or the MSVS compiler already set up, then this was probably a very confusing and annoying tutorial that didn't help you at all. But maybe it gave you some ideas.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

Damn you C-Free. Why can't you read sln files? :P
I don't even know how to make it compile a dll.
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

lol. There are probably some command line options for all of that but hell if I know what they are. I'll be amused if anyone manages to do this.

By the way you might be interested in that I didn't mention that there is some layer framework completed. In layer.h there is a thing like GetPlayer() which you can use to get a layer and control it.

Code: Select all

LayerControl* MyLayer =  GetLayerControl(0);
MyLayer->xSpeed = -1.5;
0 is default layer, 3 is the first custom layer you make, etc. There's some odd behavior sometimes with layers though, so don't get too excited until I figure out why it does weird things. :P
Blaizer
Posts: 0
Joined: 11 years ago

Re: Anyone want to test an SMBX extension module?

Post by Blaizer »

I hope this stuff gets used! I'd love to see some crazy ASM stuff in SMBX.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

Yay! I managed to make a batch file compile the code into a working dll. I'll improve it and then maybe make some simple compiler program so anybody with g++ can compile the dll. ^^
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

Oh yeah, that would've been a good idea.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

Ok. Done:

Here's the full package with the new MakeDLL.exe:
https://dl.dropboxusercontent.com/u/490 ... unaDLL.zip

EDIT:
Maybe you should post something about this in the A2MBXT subforum.
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

How would I go about checking if the player is on the ground?
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

I recall there being a field in the player object for that, but maybe not. If I had to do it right this instant, I would say check the Y speed of the player. If it == 0, then they must be on the ground right? Not sure if that's accurate when you're on a moving layer though...

Also here is the latest player object info I gathered, not sure if it's in the latest source code. There's kind of a whole lot of stuff in it. Not sure if one of them helps decide if the player is on the ground

Code: Select all

// SMBX player structure (INCOMPLETE)
struct PlayerMOB {
	short	ToadDoubleJReady;
	short	SparklingEffect;
	short	UnknownCTRLLock1;
	short	UnknownCTRLLock2;
	short	QuicksandEffectTimer;
	short	OnSlipperyGround;

	short	IsAFairy;
	short	FairyAlreadyInvoked;
	short	FairyFramesLeft;			// +0x10
	short	SheathHasKey;
	short	SheathAttackCooldown;
	short	Hearts;

	short	PeachHoverAvailable;
	short	PressingHoverButton;
	short	PeachHoverTimer;
	short	Unused1;
	short	PeachHoverTrembleSpeed;		// +0x20
	short	PeachHoverTrembleDir;

	short	ItemPullupTimer;
	float	ItemPullupMomentumSave;

	short	Unused2;

	short	UnkClimbing1;
	short	UnkClimbing2;				// +0x30
	short	UnkClimbing3;

	short	WaterState;
	short	IsInWater;
	short	WaterStrokeTimer;

	short	UnknownHoverTimer;
	short	SlidingState;
	short	SlidingGroundPuffs;

	short	ClimbingState;				// +0x40

	short	UnknownTimer;
	short	UnknownFlag;
	short	UnknownPowerupState;
	short	SlopeRelated;

	short	TanookiStatueActive;
	short	TanookiMorphCooldown;
	short	TanookiActiveFrameCount;
	
	short	IsSpinjumping;				// +0x50
	short	SpinjumpStateCounter;
	short	SpinjumpLandDirection;		// (will face this direction when landing)

	short	CurrentKillCombo;
	short	GroundSlidingPuffsState;
	short	WarpNearby;					// (1 = pipe, 2 = instant, 3 = door)
	short	Unknown5C;
	short	Unknown5E;
	
	short	HasJumped;					// +0x60

	char	padding[0x58];	//pad to next

	double	CurYPos;					// offset +0x90
	double	CurXPos;
	double	Height;
	double	Width;
	double	CurXSpeed;
	double	CurYSpeed;

	short	Identity;

	short	UKeyState;
	short	DKeyState;
	short	LKeyState;
	short	RKeyState;
	short	JKeyState;
	short	SJKeyState;
	short	XKeyState;
	short	RNKeyState;
	short	SELKeyState;
	short	STRKeyState;

	short	FacingDirection;			// offset x106
	short	MountType;		

	char	padding6[0x74];
};
Last edited by kil3 10 years ago, edited 1 time in total.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

I guess I'll use the flag to check if they're on slippery ground.
And I can't use yspeed since it will be 0 at the peak of a jump too.
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

I dunno. Since the Y speed thing is floating point, it's highly unlikely it'll be exactly 0 I think, but maybe you're right. I'm just theorizing right now.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

Now I've got to figure out a way not to make the game lag by setting a layer's speed constantly while on the ground.
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
kil3
Posts: 0
Joined: 13 years ago

Re: Anyone want to test an SMBX extension module?

Post by kil3 »

Is it really lagging? All in all, that's a really fast operation.
User avatar
docopoper
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla non pharetra enim, nec maximus odio.
Posts: 78
Joined: 12 years ago
First name: Shane Farrell
Pronouns: they/he
Location: Ireland

Re: Anyone want to test an SMBX extension module?

Post by docopoper »

Oh, that's weird. I'm getting the lag even without running the extended exe. I guess it must be SMBX's fault.
The first thing I would do with infinite power would be to make myself a cave where I could look at my shadow forever.

Image <- Go team Yeah Doctor Shemp.!
Image <- That's everyone being nice to me. ^^

I made a game called Utter Confusion! Play it! :D
It's a lot of fun and has been incredibly popular at every indie game dev party I've brought it to.
Kytech
Posts: 0
Joined: 9 years ago

Re: Anyone want to test an SMBX extension module?

Post by Kytech »

How did you do this? I've been trying to decompile SMBX to add my own features but have had no luck. Congrats! I hope that you can continue making SMBX expansions. Maybe you could release the next SMBX version at this rate!
Post Reply