Jump to content

Super Tilt Bro. for NES

Recommended Posts

Technical highlight: Real time online gaming with the NES

Super Tilt Bro. is not a retro-game. It always tried to be a modern game on retro hardware, and modern games are playable online!

We "simply" put a WiFi chipset in the cartridge, and let's rock! New millennium, here we come!

A prototype of the WiFi cartridge by @BrokeStudio.

Challenges of online gaming

Writing a game to be played online is not an easy task. At any time, we have to ensure that both players see the same scene. When the game is fast-paced, some milliseconds of ping can make a big difference.

Let's assume Alice is playing against Bob. Bob unleashed his super-attack, and Alice dodged it on the last frame, EPIC! But, there is a ping of 20 milliseconds between Alice and Bob's houses (typical), and a frame lasts 16 milliseconds. Alice did actually dodge on time, so her game shows her character ready for a deadly counter-strike. Now, the information of Alice's epic dodge took 20 milliseconds to reach Bob's home, so Bob sees that Alice dodged too late, taking heavy damage. That's a typical case of desynchronization: the two players see a completely different outcome of their fight.

Alice and Bob's different timelines. Everybody wins!

The rollback netcode

Super Tilt Bro. is based on a rollback netcode. It does not wait to know opponent's inputs, it guesses it. When inputs finally come, the game discovers if its guess was right or wrong. A right guess is good. If the guess was wrong, the game rollbacks it's scene taking real inputs instead of guessed ones.

What does it mean for the epic fight between Alice and Bob? Alice still dodges on time, her game shows it without problem. Bob's game begins to guess that Alice did not dodge (that was an epic dodge like we rarely see), so it begins to show the attack hitting. Then, less than 20 milliseconds after, the information arrives. The game rollbacks, Alice was never hit. There will typically be one frame of flicker (Alice is hit one frame, has dodged the next), but finally both players see the same action, and can continue to fight.

The rollback engine, casually rewriting the past.

The guessing algorithm is super simple. It always guesses that nothing changed, no button was released nor pressed. For a game running at 60 FPS, even for a nervous player doing six inputs per second, this simple algorithm is right 90% of the time.

Adding some input lag

Another trick is to delay inputs while sending them immediately over the network. Let's say we artificially delay all inputs by four frames. If an input takes less than four frames to be transmitted from a player to another, rollback is not even necessary.

Getting back to the game between Alice and Bob, but with an input lag of four frames. When Alice inputs the dodge on the last possible frame, it has no immediate effect, so she is hit hard. One or two frames later, Bob receives the network packet with the dodge input, it has not yet had any effect. Both players see the same action: Alice took the hit. It is less epic, but at least everybody sees the same thing and there is no visual glitch.

Input-lag: glitch-less, but frustrating at times.

Of course, both approaches can be used together. That's what Super Tilt Bro. does. There is a little bit of input lag, which should be sufficient in most cases. In case of a latency spike the input lag may not be enough, the rollback code saves the day ensuring minimal glitch. In a nutshell, rollback makes your opponent teleport at the beginning of a move, input lag makes your character slow to react, a balance between both has to be found.

Some other implementations

All that is good, now you know how the Super Tilt Bro.'s netcode mitigates internet's latency. Most game developers just never openly discuss their netcode, while it is extremely interesting to see different approaches. Here are some known ones.

Super Smash Bros, the direct inspiration for Super Tilt Bro. does not do the same thing. There is no rollback at all in the original series, instead the game slows down or even freezes waiting for inputs. It can be easily seen by playing on an unstable connection, the game will regularly freeze. To limit the impact of these slow downs, the input lag seems dynamic. (Yes, sorry for that "seem", most available info is reverse engineered or outright guessed.) We know for sure that Super Smash Bros Brawl rates your connection and attributes it an input lag that can vary from 3 frames for the best to 15 frames for the worst. People trying to measure input lag in Super Smash Bros Ultimate failed with online mode, the input lag was too varying. Maybe Ultimate is adjusting dynamically input lag for each player during the game.

The approach of avoiding rollbacks and freezing the game has its benefits and drawbacks. First, it is really easy to implement, the only special case to handle is to wait for the needed information to be available. As a side effect, it requires very little overhead for the CPU and memory. The game engine does not have to be able to rollback from a previous point in time, the game can just run forward, forgetting anything that happened on previous frames. The effect on laggy connections is a freeze, while with a rollback netcode characters may teleport around on laggy connections. It is a matter of preference, a freeze is more "understandable", while a slight teleport is more smooth to play. The biggest problem is competitive play. Even at a moderate level, players train their combo, learning to execute moves with very precise timing (even frame-perfect sometimes). If the game slows down, freezes or changes the input lag in the middle of a frame-perfect combo, it messes it up, making it fail while player's execution is perfect. Finally, freezes must be avoided, it is not an option. So the player cannot be offered the choice to configure its input lag, it has to be conservative.

Another well-known solution is GGPO. It is a standalone rollback netcode made to be used by developers on their own game. It is especially popular in arcade emulation, and is the solution of choice of Skull Girls (which is known to have a good netcode.) GGPO is a rollback engine, their documentation does not mention input lag, but Skull Girls allows it to be configured to a fixed number of frames. This way the player can balance himself between more rollbacks or more input lag.

It is a lot like the Super Tilt Bro.'s netcode. The good thing is that input lag is fixed and constant for an entire game. You can still perform your frame-perfect combos. The biggest problem is when there is a big latency spike, characters will teleport around for a while until the game successfully re-synchronize itself with the other player. This kind of action is really confusing for the player. Also, the game engine has to take save-states and manage it to be able to rollback, putting pressure on the CPU and memory.

All these modern implementations have something in common: they are peer-to-peer. Avoiding packets to transit by a server noticeably reduces latency. That's a really cool solution. Super Tilt Bro., however, is server based, let's see why.

Super Tilt Bro.'s game server

We saw that peer-to-peer is the best model for online versus fighting. Super Tilt Bro. does not have this luxury. We also saw that rollback netcodes are costly for the CPU as the game has to be able to rollback, and the RAM because it has to store its old states. The NES runs with a 8-bit CPU at 1.5 Mhz and 2 KB of RAM. It is really far from modern systems. Implementing the rollback system entirely on the NES would be very limiting, most resources would be allocated to it at the expense of gameplay. The server is here to help.

Remember Alice and Bob? With the Super Tilt Bro.'s protocol, when Alice presses a button the game only sends the state of the gamepad and a timestamp to the server. The server knows the game, it is able to simulate frames, and compute the game's state at any point. Based on this knowledge and Alice's input, the server computes the state of the game at the frame of Alice's input, then sends all that to Bob. Bob receives the timestamp, Alice's input and a full game state. If input lag did its work, the game state can be ignored. If a rollback is needed, Bob's NES can use the state received from the server. Bob's NES does not have to manage a list of game states, the server generates it when needed, removing almost all pressure on the limited NES memory.

The server can also help with CPU budget. Let's say there is always a minimum of two frames of delay between Alice and Bob. When receiving Alice's input, instead of computing the state at the time of the input, the server can compute the state two frames after. The server is actually predicting the future, avoiding Bob's NES to do it itself. Of course a full rollback engine has to also be implemented in the server, but can help a lot with big latencies. Currently, Super Tilt Bro. is able to rollback only three frames of gameplay before running out of time. The server doing the rollback for one or two frames can help a lot.

UDP vs TCP... And web browsers

There are two big, omnipresent protocols on the internet: UDP and TCP. TCP is the most common one, it allows a computer to connect to another and send data. In TCP land, we don't lose data, and data is received in the same order as it was sent. Most of the internet is constructed on TCP, it is simple to use. UDP is a more lightweight protocol. In UDP's world, when we send a packet, the only sure thing is that we sent it. The packet may be randomly lost, or arrive before a packet sent earlier. So, TCP is a better protocol, right? No. Sadly, TCP's magic has a cost.

In Super Tilt Bro.'s protocol we don't care a lot about lost packets. A message from the server to a client contains a full game state. A recent message completely invalidates any older one. If we use TCP and lose a message, it will be re-emitted before the receiver processes any other message. If we send two messages in a row, only the most recent one is useful to Super Tilt Bro. If the useful one is physically arrived but the useless one is lost, the useful one will be delayed until the useless one is re-emitted. During development, we tested a simple ping implementation using TCP and voluntarily losing 10% of packets. With UDP, it resulted in 10% packet loss, without impact on the ping (around 20 ms in our test setup). With TCP, it resulted in 0% of messages lost (that's the TCP magic), but ping value sometimes reaching three full seconds.

Imagine having your input delayed by three seconds because a useless packet was lost? No way!

If you played the game, you probably noticed that it is available in an HTML5 NES emulator on the itch.io page. As innocent as it seems, that's actually a big deal. Web browsers don't let web pages send UDP packets. Super Tilt Bro. protocol is based on UDP and needs it. The solution was to use WebRTC, a modern protocol made for visio conferences. That's what your favorite Google Meet, Skype online, Facebook visio uses. Hijacking a video conference protocol to use it for gaming is a large topic. I may or may not write a devlog entry on the subject, for now I'll let you with the real-time twitter thread of my fight against internet's security: https://twitter.com/RogerBidon/status/1259171335135211523

See you!

Implementing modern network capabilities for a NES game was an epic journey... And it is far from over! This made it to the ALPHA stage. It is not complete, and I am in dire need for feedback.

You can test it yourself: https://sgadrat.itch.io/super-tilt-bro

Join the Discord to find a rival and/or send your feedback: https://discord.gg/qkxHkfx

Hope this little piece of internet knowledge can help somebody out there. Do not hesitate to reach me for more details, nothing is secret. Super Tilt Bro. is an open source software. It is made to make the internet a better place, not to keep its secrets!

Edited by RogerBidon
  • Like 2
Link to post
Share on other sites
  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Did you notice that all Nintendo systems coming after the N64 have their own version of Super Smash Bros? It is a shame that this (wonderful) experience is not ported to earlier systems! Super Ti

Hey, some news from the project: there is a prototype for online versus. I am interested in it since @Broke Studio revealed his plans to develop a mapper with an integrated WiFi chipset. Actually

Technical highlight: Real time online gaming with the NES Super Tilt Bro. is not a retro-game. It always tried to be a modern game on retro hardware, and modern games are playable online! We

Posted Images

Little update on how's the project is going.

As often, I went quiet for a long time. I was re-implementing the music engine from scratch. I had nothing fancy to share. The new engine is in its infancy, but already has some interesting features:

  • Able to play Famitracker files with effects (Fxx, Gxx, Dxx, Sxx, Axx, Qxx, Rxx, 1xx, 2xx, 3xx, and 4xx for now)
  • Speed and code size comparable to ggsound and famitone (if not better, always debatable)
  • Data a little heavier than ggsound/famitone, but still better than Famitracker's driver

I made my own engine to prepare for my idea of dynamic music. When the music adapts itself to what happens. The engine will be able to seamlessly switch between calm or nervous versions of the same track depending on the actual action of the game. Anyway, I will write a technical highlight on what is already implemented, I am sure it has enough technicalities to write a big wall of text.

Also, I had to take a little break to make a new trailer, hope you will enjoy it.

It was made by a good friend of mine that is starting to take freelance jobs in motion design. If you have similar needs, you may contact her 😉

  • Like 2
Link to post
Share on other sites
  • 3 months later...

Technical highlight: rollback netcode on the NES, the gory details

Hey folks! Ready for a really technical one?

Super Tilt Bro. ALPHA 5 just hit the public, and with it the ability to play online with any character on any stage. Time to take a step back, see how the netcode works, and what where the biggest challenges.

As you know it from reading the precedent technical highlight (or at least the illustrated part), Super Tilt Bro. Implements a rollback netcode on the NES. It means that the game is always smooth, when the messages from the other NES take time to transit, the game just predicts it and continue. Sometimes it happens that the prediction was wrong, the game has to revert predicted frames, and re-compute the real ones.

How the protocol works

Rollback netcodes are notoriously hard to implement. Browsing the internet, you will see very long posts explaining that the Switch is not powerful enough to do it. How the heck can it run on the NES?! (Spoiler: of course, by cheating!)

A very big pain point in traditional implementation of such a netcode is the memory management. The game has to keep a list of its previous states to be able to rollback from any of them. With only 2 KB of very slow memory, Super Tilt Bro. has to avoid it. The solution is to make the server smarter.

When you press a button, a message is sent to the server. This message is tiny, it contains just the button pressed and a timestamp. In turn, the server computes the state of the game when you pressed the button, so it can send an enhanced message to the other NES. The enhanced message contains the button pressed, a timestamp, and the state of the game at this point. The NES receiving such a message now has everything at hand. It just replaces its current state by the received one, and rollback enough frames to compensate for transit time.

The good point of this approach is that memory management on the NES is completely removed. Of course, there are drawbacks. The server must be smart, it actually has to incorporate an emulator to compute game's state. Worst, there is no way to switch to a peer-to-peer protocol. Time will tell if this rollback netcode is better than peer-to-peer input-lag netcodes.

Introducing the main foo: the CPU

Now the NES has an old state received from the server, and must simulate missing frames. It has to be speedy. We don't want to see characters moving in fast-motion to catch-up, that would destroy the timing of player's inputs, and make them miss combos. The goal is to rollback immediately, so the game is at the same point in time it was before the message's reception. We have exactly 20 milliseconds to do it without missing a video frame (on PAL.)

The first thing to do is to be able to simulate a frame in “rollback mode”. In this mode, nothing has to be displayed, so the engine can safely skip placing sprites on the screen, updating the background, and anything visual.

That done, simulating a frame in rollback mode take 25% of the 20 milliseconds. It would be enough to rollback four frames, and compensate 80 milliseconds of ping, if the rest of the game did not take 60% of the time. Notably, it has to simulate a frame in normal mode, to show sprites and other visual effects. All in all, it allows for almost no rollback.

Next step is to optimize everything that is done multiple times per frame. Collision detection is where we get the biggest gains. It was an old code, mostly implemented while learning 6502, and is run for both players, for each platform, multiple times. With this code rewrote, it is finally possible to play online even on complex stages.

Another big win is the optimization of the animation code. While in rollback we don't care about animating sprites on screen, in Super Tilt Bro. hitboxes are stored in animation data. Parsing all meta-sprites to extract an hitbox is time-consuming. Here the trick is to always put hitboxes at the beginning of such data, and stop reading there. Plus some low level optimization, it is always good to take.

Optimizing gave space to rollback around three frames. The work is not over 🙂

We are not yet fast enough to compensate big latencies. Thankfully, the server is smart. It can itself predict frames, and does just that to compensate for the minimal latency ever seen between players. That way, the NES just has to handle the variable part of it. Let's say your ping oscillate between 100 and 140 milliseconds, the server will predict for 100 ms, so in the worst case the NES will have to predict only two frames.

What's next?

First and foremost, this code needs to be battle tested. For sure, it is not yet perfect. The only solution is to try it, play with it, and report anything strange. The more it is used, the more we can find issues. Super Tilt Bro. needs you! Please bring some friends, play together, and send your feedback. It really helps! Your journey begins here: https://sgadrat.itch.io/super-tilt-bro

If the online mode should work, it is still very light. There is only a very simple matchmaking available, and the user interface is the ugliest you can imagine. I guess I will now focus on the things around the netcode, beginning with a ranking system. Wouldn't it be nice to go to the official ranking page and find that you are the best player in the world?

  • Wow! 1
Link to post
Share on other sites
  • 4 weeks later...


Technical highlight: C compilers for 6502 benchmark: A new hope!

Adding a C compiler in your game's toolchain is not an easy task. Each have their own strength, and weakness. You may want speed, ease of use, compliance to the standard, freedom, or anything. We'll try to compare some compilers, maybe it will help you.

While choosing a compiler to enter my game's toolchain, the speed was the least of the concerns but discussions invariably derived to the subject. This article will mainly focus on this question: what compiler produces blazing fast code?

Some code samples will be compared, each time with an explanation about the code, and why it may be useful to benchmark it.

That done, I'll talk about my experience with each compiler. Their strong points, their weaknesses. This part is necessarily subjective, I'll try my best to be factual.

Finally, a short "how to choose a compiler" guide will conclude the article. Hope it helps.

Let's go!

Introducing contenders

cc65 is the most used compiler. It comes with an extensive toolsuite, is actively maintained, and has a big community of users. However, it is known to be slow... We'll see 🙂

vbcc is the cool kids' compiler. Less used than the king, it has the reputation of generating largely better code.

KickC is the young promising project. Is it a toy for nerds or a real option?

6502-gcc is the mysterious one. Nobody really masters it, the project seems dead, installation instructions are cryptic, ... We'll dig in its dark secrets!

6502-gcc has two interesting optimization flags:

  • "-O3" optimize for speed
  • "-Os" optimize for code size

Run length decoding

This benchmark comes from real life. It is a function prototyped in C for Super Tilt Bro. before being converted to assembly for performance. Data used are also the original ones.

The function parses a compressed blob to extract some random bytes from it. It is pure loop logic, burning many cycles reading the memory.

Red is execution time, blue is generated code's size.

First thing first, cc65 lives by its reputation of sluggishness there. It is a complete KO. Code generated is big and slow.

The winner is 6502-gcc, by a fair bit. KickC has a slight advantage over vbcc.

Fun fact: the more popular the compiler, the worst it perform in this test.


Here is the super common task of copying bytes in the memory. It is important to compare compiler on what our programs will spend the most time.

The bench comes in two flavors:

  • The normal one directly copies bytes with a for-loop
    • the compiler knows both addresses and number of bytes to copy, food for optimization
  • The no-inline is "memcpy-like" function, copying at most 256 bytes at once, not inlineable
    • the compiler knows nothing, it has to implement a generic copy function

All graphs are sorted: slower on the left, speedier on the right

cc65 is still on the last spot.

KickC confirms to be slightly better than vbcc. Note KickC absence from the no-inline version: KickC seems to always work with the full source, so no way to forbid an inlining.

6502-gcc takes a hit. Worst, extensive tests showed that results are highly varying when changing little things to the code.

Also, did you noticed how "-O3" poo'd itself in the inline scenario? gcc (the "real" one as well as 6502-gcc) works in two steps: the fronted optimizes C code, then the backend translates it to machine code. The fronted of 6502-gcc is the regular one, it does wonders, then comes the backend. The 6502 backend is seriously lacking love, and it is showing here: the fronted detected that the code is equivalent to a "memcpy", and told "copy 200 bytes from $0400 to $0200" to the backend. The backend was expected to implement it the most optimal way, instead it just called the standard "memcpy" function, which is far from optimal for an 8bit CPU.

RPG engine

This bench is voluntarily made to take advantage 6502-gcc strength: its fronted.

It is an RPG engine with lots of abstraction. There are structs, functions making the player strike, functions for hitting monsters, the player is wielding a weapon, ...

The benched function, initialize the game's state, play one turn, then return. So while there are functions updating structures, adding attack points, and subtracting hit points, the finality is just to set the memory in a particular state.


cc65... it becomes redundant. Ok, this test is definitely not for cc65 which refuse to do high-level optimization. This benchmark actually tests the quality of the high-level optimize.

KickC is a better vbcc performance-wise. That's a trend.

6502-gcc doesn't disappoint. It's frontend is world-class, and nails it perfectly. The generated code is a short list of "lda <constant> : sta <memory>", with even redundant LDAs pruned.

Code tailored for cc65

Did you read Ilmenit's great essay "Advanced optimizations in CC65"? Here it is: https://github.com/ilmenit/CC65-Advanced-Optimizations

Let's save cc65! Here we bench a code especially tailored for cc65, made by an expert. Should do it, yes?

The code itself is comparable to the RPG benchmark: it is a uselessly abstracted RPG engine. The difference: it loops 100 times and print characters on screen each time (so, no way to reduce it to a list of LDA+STA, computations will be done.) Then, Ilmenit applies various optimizations to make it really fast.

We'll bench two versions: the first one, without any optimization, and the last one, fully optimized.


KickC disapeared, and vbcc is half absent!

KickC had just too many limitations to compile the code: notably it refuses to output any runtime modulo or division.

vbcc generated an infinite loop on the unoptimized code, and suffered my lack of experience when integrating it in the benchmarking tool (hence the lacking code size.)

6502-gcc exhibited a bad bug (or once again my lack of experience), it puts global variables in random segments. The assembly generated had to be fixed by hand. [Edit: the bug is fixed now, 6502-gcc works without manual intervention.]

So, even before watching graphs: cc65 is the winner! It compiled this code!

Interestingly 6502-gcc does not perform on the unoptimized version. After all what has been said about its magic high-level optimizations! The problem here is that it was not allowed to inline functions. In C, when you declare a function without preceding it by "static", it has to be accessible to other compilation units, it must be there and fully usable: passing parameters on stack and all that. Of course, cc65 don't inline anyway so it is of little difference to it.

On the optimized version vbcc seems to be lacking, and cc65 is slightly better than 6502-gcc. The code has been optimized by hand to be straightforward to compile, so the compilers have not a lot of freedom to improve things.

What about this "???" entry? If you didn't read "Advanced optimizations in CC65" by now (shame on you!), you don't know how the optimized code is a mess to read. All available tricks have been used, even the author does not recommend going so far in real life.

The "???" is "6502-gcc -Os" on a version with only two of the 12 optimizations plus the use of "static" keyword. The resulting code is a lot like the unoptimized code, and the performance penalty is almost gone. That's why I think high level optimizations are what matter: it allows writing in C, without caring much of the assembly generated. Let low levels tricks to the compiler, focus on the logic.

Aside of performance

Ok, performance-wise it seems that cc65 is seriously lacking, vbcc and KickC are almost on par, and 6502-gcc varies from excellent to trash.

Actually, performance should not matter a lot when choosing a C compiler. Be sure to learn the assembly language, and you'll be able to get perfs where it is needed. Here is a summary of pros and cons of each compiler.


  • Rock-solid and battle-tested, it will not let you down.
  • Active development
  • Great resources available to learn
  • One of the most complete toolsuite out there


  • Performances (seriously, that's its only dark point)


  • Acceptable performances
  • Active user base
  • Extensive documentation
  • Complete suite of tools (assembler, linker, versatile config files, ...)


  • Terrible licensing (like, I will recommend avoiding it just for that)
  • Buggy


  • Good performances
  • Hard to integrate with other tools (made to compile an entire project)
  • Active development (and a good base, may the future be bright!)


  • Compliance with C standard very partial (even "const" is badly supported)
  • Compiling is slow
  • Terrible compilation errors (at times, you just have a stack-trace)


  • 100% compliance with the C standard
  • God-tier high-level optimizations
  • Generates assembly for ca65 (taking advantage of the cc65's toolsuite)
  • Human readable and on-point warnings and compilation errors.


  • Development inactive
  • Buggy
  • Variable quality of the generated code

Ok, but which one to choose for my project?

As always, it depends! Who are you?

Are you an experienced developer accustomed to a particular one? Stay on it. You already learned to master your tool, others bring little benefit.

It is your first C project for the 6502? Go for cc65, it is the most mature, and you'll find help.

You want high-level optimizations, and something that just work? KickC is made for you.

You want high-level optimizations, to rely on fine-prints of the C standard, and are ready to build your own toolchain? 6502-gcc is the way.

No, I won't recommend vbcc. It's licensing is terrible: it is closed source and you cannot use it for "commercial purpose" (without definition of it, nor if it applies to generated executables.) Also, it incorporates various tools and libraries with various licenses. If you want to do things "the right way", you will have to check at least three licenses to know if you can do what you have in mind.

Last word

Benchmarks are a nice tool to see the general picture, but never can be perfect. Especially these, it was my first experience with most of those compilers, and I may have had some details wrong. If you want to play by yourself, the tool used is available here: https://github.com/sgadrat/6502-compilers-bench it takes C files, and output speed metrics as well as the generated assembler.

Hope this little research can help somebody out there. Remember, in retro-development, the most important is to have fun!


Edited by RogerBidon
  • Like 1
Link to post
Share on other sites

As the author of the 6502-gcc compiler port -- thank you for including my work in your benchmark comparison! I don't have a lot of time to work on it at the moment but I love to see people getting some use out of it! I'm a bit puzzled as to why the memcpy test came out so bad. The libtinyc version of memcpy (if that's what's being used) is hand-written and I don't think THAT terrible...

  • Love 1
Link to post
Share on other sites

Wooo! Hello Itszor, I did not find a way to reach you online, very humbled that you are reaching me! I wanted to thank you for your work on 6502-gcc, I use it for non time-critical parts of my game, and really love it! Thank you. Since I tried it, I am advocating for it on any opportunity.

About memcpy

For the memcpy, the thing is the compiled code uses an 8 bits counter, and don't return the original address. So even the perfectly written memcpy can be beaten. Also, it is on the inlineable version that "gcc -O3" called memcpy instead of  writing optimized code for the case.

Compiled code is there: https://github.com/sgadrat/6502-compilers-bench/blob/master/code_samples/memcpy/memcpy_8bit_c_style_static.c
Perfect asm (without unrolling): https://github.com/sgadrat/6502-compilers-bench/blob/master/code_samples/memcpy/memcpy_8bit_asm_static.s (just noticed it is buggy and copies from $401 to $201, anyway that's the idea)

ASM output by gcc:

    ; frame size 0, pretend size 0, outgoing size 0
        lda #$c8
        sta _r4
        lda #$00
        sta _r5
        sta _r2
        lda #$04
        sta _r3
        lda #$00
        sta _r0
        lda #$02
        sta _r1
        jsr memcpy


About the variables in random segments

This code:

int g_var;
int const g_const = 5;
int g_var2;

void benched_routine() {
    g_var = 5;

Compiles to (gcc -O3):

		.segment "CODE"
		.export benched_routine
	; frame size 0, pretend size 0, outgoing size 0
		lda #$05
		sta g_var
		lda #$00
		sta g_var+1
		.global g_var2
		.res 2
		.export g_const
		.segment "RODATA"
		.word	$0005
		.global g_var
		.res 2

g_var2 is in "CODE" segment, while g_var is in "RODATA", while both should ideally be in "BSS" or at least in "DATA".

Note for my game I don't use global variables, so I discovered it while doing these benchs. This is the first bug I encounter while using 6502-gcc everyday.

The best would be to make it a github issue I guess. I wanted to take some time to search if there is an easy fix to make a pull-request instead of an issue (but you now... time... so rare a resource)

Edited by RogerBidon
Adding useless note on parenthesis
Link to post
Share on other sites

Thank you for taking the time to write up those problems! I think both should be fixable - I'll try to find time to do it soonish. (If you find more problems, feel free to create github issues on the gcc-6502-bits repo. I don't check it all the time but I'll see them eventually!).



  • Thanks 1
Link to post
Share on other sites
  • 4 weeks later...

Hey! First time I share a release note here. I guess you homebrew players also are in the brewery, it may be of interest. Skim-read it, and see what's new.

I will post such release note with each future version. Do not hesitate to give feedback on the content or the format.

Super Tilt Bro. 2.0-alpha6: Worldwide ranking!

What's new in the game?

Ranked play

You can now choose between “Casual” or “Ranked” mode. Casual plays just like before, while in ranked, your have a Match Making Rating (MMR). Winning a match gives you MMR points, while losing takes your MMR lower.

A worldwide leaderboard is available on the brand new official website: https://super-tilt-bro.com/leaderboard.html

Come, the top spot is waiting you!

Private game

You can ensure to be matched with your friend in this mode. Simply share a password to be matched together.

Starting a private game

Longer hitstun

When you receive a hit, there is a small time on which your character blinks and you cannot do anything. It is essential for combos, which consist of repeatedly hitting your opponent while in hitstun to maintain them in this state. Also kill moves, which send the opponent far away, rely on it to avoid the momentum being cancelled by a special move.

Hitstun duration has been slightly increased, it is now 1.5 times what it was. Before that, there was literally no true combo in the game. So, now Sinbad has more efficient combos, and Kiki's strong strikes are more dangerous.

Kiki's moveset change

Originally, Kiki's down-special put a wall bellow her while neutral-special was a counter strike. These moves swapped input, down-special is now the counter strike while neutral-special creates a platform.

It is a simple fix, as the platform is Kiki's main recovery move, and it is unintuitive to press “down” to avoid falling.

Kiki's counter strike revamp

The counter strike has now more active frames, and more end-lag frames. Moreover, if down in the air, it slows Kiki's fall. The counter strike is still active at frame one.

Kiki's new counter strike

More active frames means your timing may be a bit less precise to pull it effectively. More end-lag, on the other hand, make it is easier to punish Kiki for missing it.

The slow fall forces Kiki to setup a proper bait. The sudden change in momentum may make the opponent miss a strike, leaving Kiki vulnerable. It also lessens the risk being KO-ed by falling too low while in end-lag.

What's new under the hood?

New servers

Originally, there was only one server per region. This server handled the matchmaking and the games.

Now there is a new login server, which handles user accounts, a ranking server that computes MMR and a website. This architecture has been intentionally split in tiny very specific servers. Very specific servers are easier to debug and operate than big ones.

It also allows for a future migration to cloud hosting, theoretically if we split the matchmaking from the game server, we could spawn as many game servers as needed to serve all players at any time. Spawnable game servers would have another advantage: the end of region server, just spawn the server near the player. Of course, all that is just wishful thinking for now but better be ready, it costs nothing.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Welcome to VGS!

    Play, Make, Collect.

    Here at VGS all kinds of gamers are welcome, and that includes you!

    Join the conversation!

  • Similar Content

    • By OwlLicks
      Howdy VGS,
      I'm about ready to start aggressively searching eBay for the games missing from my library. I'm missing a few heavy hitters, but I'm more focused on getting some of the uncommon but not too pricey ones knocked out first. If you have any of these, let me know and I'd be happy to work out a fair price. I don't have too many spare games to trade at the moment.
      Advanced Dungeons & Dragons: DragonStrike
      Advanced Dungeons & Dragons: Hillsfar
      Alfred Chicken
      Arkista's Ring

      Casino Kid II

      Dusty Diamond's All-Star Softball
      Indiana Jones and the Last Crusade (Ubisoft)
      Jimmy Connors Tennis
      Motor City Patrol
      Nobunaga's Ambition II
      Race America (Alex DeMeo's)
      Tecmo Cup: Soccer Game
      Tetris (Tengen)
      Times of Lore
      Toxic Crusaders
      Ultima: Warriors of Destiny
      Uncharted Waters
    • By austin532
      Here is a list of CIB, Loose, and misc stuff I have for sale, for offer, or trade. Let me know if you are interested or need pictures. I am negotiable on prices so don't be afraid to ask.🙂


      Bases Loaded - $15
      Dick Tracy - $40
      Vegas Dream - $15

      Goal! (Very Nice) - $8
      NES Nintendo Brand Controller - $9
      NES Nintendo Brand Zapper (Gray) - $6



      Madden '93 - $10 (Good)
      Super Smash TV - $50 (VG)

      Donkey Kong Country - $20
      Donkey Kong Country 2 - $25
      Madden 98 - $5
      Mario Paint w/ Mouse - $40
      Super Mario World - $25
      The Legend of Zelda A Link to the Past - $40

      Official Nintendo Brand Super Nintendo Controller - $25

      Super Nintendo Manuals:

      Donkey Kong Country - $9
      Donkey Kong Country 2 - $9
      Mario Paint - $3
      Super Mario World - $6
      Super Nintendo Mouse - $5
      Super Nintendo System - $5



      Wii - FS/FT/FO


      Bomberman Max Blue Champion GBC - $15
      Caesars Palace GB - $9
      Dragon Warrior I & II GBC - $50
      Dragon Warrior Monsters GBC - $50
      Game & Watch Gallery 2 GBC - $15
      Game & Watch Gallery 3 GBC - $15
      Mario Tennis GBC - $20
      Mega Man Xtreme GBC - $40
      Monster Truck Madness GBA - $6
      Pocket Bomberman GBC - $15
      Pokemon Blue GB - $70
      Pokemon Gold GB - $70
      Pokemon Yellow GB - $70
      Star Wars Episode 1 Racer GBC - $15
      The Legend of Zelda Oracle of Ages GBC - $70

      GB/GBC Instruction Manuals:

      Bomberman Max Blue Champion - $5
      Game & Watch Gallery 3 - $5
      Gameboy Camera - $5
      Gameboy Color - $5
      Pocket Bomberman - $4
      Star Wars Episode I Racer - $5
      The Legend of Zelda Oracle of Ages - $20

      Official RF Adapter (New in Box) - $10

      Playstation 1 System with AC/AV Cables (SCPH-5501 w/ PU-18 Board) - $40


      Final Fantasy X-2 CIB (Mint) - $10


      Evolution - $25
      Marvel vs. Capcom 2 - $250
      Power Stone 2 - $200
      Ready 2 Rumble Boxing - $25

      Official Sega Brand Red Controller w/ Red VMU - $60
      Official Sega Brand Green Controller w/ Green VMU - $60
      Official Sega Brand Blue Controller w/ Blue VMU - $50

      Gameshark CDX w/ VMU - $40

      Nintendo Powers:

      November/December 1988
      March/April 1990
      May/June 1990
      Volume 27
      Volume 46
      Volume 51
      Volume 44
      Volume 75
      Volume 106
      Volume 108
      Volume 111
      Volume 112
      Volume 113
      Volume 116
      Volume 117
      Volume 118
      Volume 119
      Volume 120
      Volume 121
      Volume 122
      Volume 123
      Volume 124
      Volume 125
      Volume 126
      Volume 127
      Volume 128
      Volume 129
      Volume 158

      Top Secret Passwords Player's Guide - $10
    • By RetroGE
      I have a little over 600 unique NES carts, 600 unique Famicom, and 130+ Famicom Disk Games.  I keep track of these in Excel and I'm working a unified workbook, where I have 3 tabs (NES, Famicom, and Famicom Disk System) and a column on each noting the name for Famicom/NES variants (US centric).  Anyone have a good starting point for personal use?  I'm fully aware of the complexities that would popup in creating a grand unified database that can be used as a definitive reference.  This is not my end goal. 
      For Famicom I'd like Japanese title using Kanji, Japanese title using English Alphabet, Unique ID (e.g. Super Mario Bros 2 is FMC-SMB), Release date, Publisher, Developer (if available), and if it was released on NES that title as well.  
      For Famicom I have a master list with Famicom and the Disk System mixed together but no Kanji and only about 100 NES titles filled in from my personal collection.  I'm happy to share if anyone needs but it's not really set up for others to view.
       If anyone is interested in seeing a comparison of Famicom and NES releases, of the same title, you can see my hashtags on instagram: #NESVsFamicomArt and #NESVsFamicomBoxArt
    • By RetroX85
      Böbl homebrew working on NES cartridge 🙂  very cool on original hardware.
      Morphcat Games 👍

    • By alexkidd401
      Looking to trade with anyone that is up for it. Can send detailed individual pics upon request. I will be updating over the next couple of days so please check back when you get the chance. Thanks for checking my stuff out!

      Codename S.T.E.A.M
      Golden Sun Dark Dawn
      Luigi’s Mansion: Dark Moon
      Mario & Luigi’s Bowser’s Inside Story + Bowser Jr.’s Journey
      Pokémon Ultra Sun
      Super Mario 3D Land
      Super Mario Maker 3DS
      Yokai Watch

      FIFA Soccer
      Ys: Memories of Celceta

      Legend of Zelda: Breath of the Wild
      Pokken Tournament
      Tokyo Mirage Sessions #FE

      Ace Combat 7
      FIFA 19
      Forza Horizon (International Version)
      Just Dance 2020
      NHL 19
      Sims 4 Bundle
      XCOM 2

      Catherine: Full Body
      Just Dance 2017
      Just Dance 2019
      Ni no Kuni II Revenant Kingdom
      Tales of Vesperia

      Bayonetta 2
      Bloodstained: Ritual of the Night
      Disney Tsum Tsum Festival
      Final Fantasy X/X2 HD Remaster
      Fortnite: Deep Freeze Bundle
      Hollow Knight
      Moving Out
      New Super Lucky’s Tale
      Ni No Kuni: Wrath of the White Witch
      Octopath Traveler
      Pokémon Let’s Go, Pikachu
      Resident Evil Triple Pack
      Snack World: The Dungeon Crawl Gold
      Super Dragon Ball Heroes World Mission
      Umihara Kawasaki Fresh!
      Animal Crossing Special Edition Nintendo Switch Console
      Super Mario Anniversary Nintendo Switch Console
      Super Mario Odyssey + Nintendo Switch Pro Controller Bundle
      Nintendo Switch Lite case

      Batman: Return Of The Joker
      Battle Of Olympus
      Blaster Master
      Castlevania II: Simon’s Quest
      Clash At Demonhead
      Dr Jekyll and Mr Hyde
      Dr. Mario
      Dragon Warrior II
      Dragon Warrior III
      Duck Tales
      Game Genie
      Godzilla 2
      Gradius [5 Screw]
      Indiana Jones and The Temple Of Doom
      Journey To Silius
      Kid Icarus
      Mega Man 3
      Mega Man 3
      Mega Man 6
      Mike Tyson's Punch-out!!
      Ninja Gaiden
      Pac-Mania (Tengen)
      Pro Wrestling [5 Screw]
      Super Mario Bros [5 Screw]
      Super Mario Bros 3
      R.B.I. Baseball 3 (Tengen) 
      Journey To Silius
      Monster Party
      Deadly Towers
      Fester's Quest
      Freedom Force
      Hogan's Alley
      Ice Hockey
      Kings Of The Beach
      Kung Fu Heroes
      Legacy of the Wizard
      Legend of Kage
      Operation Wolf
      RC Pro-AM
      Super Mario Bros 3
      Swords and Serpents
      Tecmo Bowl
      Top Players Tennis

      Big Sky Trooper
      Donkey Kong Country
      Donkey Kong Country 2
      Donkey Kong Country 3 [Player's Choice]
      F-Zero [Player's Choice]
      Final Fantasy II
      Final Fantasy Mystic Quest
      Illusion of Gaia
      Killer Instinct
      Lion King
      Mario Paint
      Mega Man X
      Mortal Kombat 3
      NBA Jam
      Out of This World
      Q*bert 3
      Romance of the Three Kingdoms IV: Wall of Fire
      Soul Blazer
      Star Fox
      Street Fighter II Turbo
      Super Bomberman 2
      Super Castlevania IV
      Super Ghouls 'N Ghosts
      Super James Pond
      Super Mario All-stars & Super Mario World    
      Super Mario Kart
      Super Mario RPG    
      Super Mario World    
      Super Mario World 2 Yoshi's Island
      Super Metroid
      Super R-Type    
      Super Star Wars
      Super Star Wars Empire Strikes Back    
      Super Star Wars Return of the Jedi
      Teenage Mutant Ninja Turtles Tournament Fighters
      UN Squadron    
      Utopia The Creation of a Nation    
      Wing Commander    
      Wizardry V Heart of the Maelstrom
      Young Merlin    
      Ys III Wanderers from Ys
      Zelda Link to the Past

      007 GoldenEye
      007 World Is Not Enough
      1080 Snowboarding
      Army Men Air Combat
      Chopper Attack
      Conker's Bad Fur Day
      Cruis'n USA
      Dark Rift    
      Deadly Arts
      Destruction Derby 64    
      Donkey Kong 64
      Elmo's Number Journey
      Expansion Pak
      Fighting Force 64
      Hybrid Heaven
      Jet Force Gemini
      Killer Instinct Gold    
      Mace Dark Age
      Magical Tetris Challenge
      Mario Kart 64
      Mario Tennis
      Mega Man 64
      Mischief Makers    
      Mortal Kombat 4
      Mortal Kombat Trilogy
      N64 Memory Card    
      NBA Hang Time    
      NFL Blitz    
      Namco Museum
      Nightmare Creatures
      Perfect Dark
      Quest 64    
      Rainbow Six
      Ready 2 Rumble Boxing Round 2
      Resident Evil 2
      Ridge Racer 64
      San Francisco Rush
      Shadowgate 64
      South Park Chef's Luv Shack
      Star Fox 64
      Star Wars Rogue Squadron
      Star Wars Shadows of the Empire
      Super Mario 64
      Super Smash Bros.
      Tony Hawk
      Tony Hawk 2
      WCW Backstage Assault
      WWF Wrestlemania 2000
      Winback Covert Operations
      Zelda Majora's Mask

      Biofreaks CIB 
      Body Harvest CIB
      Castlevania Legacy of Darkness (Cart and box only)
      Conker's Bad Fur Day CIB
      Forsaken 64 CIB
      Jet Force Gemini CIB
      Star Wars Shadows of the Empire CIB
      Super Mario 64 (Cart and box only)
      Turok 2 Seeds of Evil CIB
      Turok 3 CB (Cart, poster and box only) 
      XG2 Extreme-G 2 (Cart and box only)
      Yoshi's Story (Box Only)

      **Note** A majority of the boxed N64 games are former rentals. Can send detailed pics. Just give me a shout if so.
      Croc 2
      Donkey Kong Land
      Donkey Kong Land II
      Dr. Mario
      Final Fantasy Legend II
      Legend of Zelda Link’s Awakening DX
      Legend of Zelda Oracle of Ages
      Legend of Zelda Oracle of Seasons
      Mario & Luigi Superstar Saga
      Mario Golf Advance Tour
      Metroid Fusion
      Metroid II
      Metroid Zero Mission
      Pokémon Red
      Pokémon Sapphire
      Pokémon Yellow
      Radar Mission
      Super Mario Advance
      Super Mario Bros Deluxe
      Super Mario Land 2
      Super Mario World Super Mario Advance 2
      Super Puzzle Fighter II
      Super R.C. Pro AM
      Torpedo Range
      Wario Land II
      Yu-Gi-oh 7 Trials to Glory
      Animal Crossing Wild World
      Cooking Mama
      Elite Beat Agents
      Grand Theft Auto Chinatown Wars
      Gunpey DS
      Hotel Dusk Room 215
      Kirby Super Star Ultra
      Legend of Zelda Majora’s Mask
      Legend of Zelda Phantom Hourglass
      Mario Kart 7
      Mario Kart DS
      My Japanese Coach
      New Super Mario Bros
      Pokémon Diamond
      Pokémon Heartgold
      Pokémon Rangers
      Pokémon X
      Professor Layton Diabolical Box
      Sonic Classic Collection
      PlayStation 1 Memory Card
      Hot Shots Golf World International PSVita
      Gameboy Advance Gamecube cord
      Gameboy Fanny Pack
      Nintendo Fanny Pack
       Mario Clash (Box Only)
        Donkey Kong Land 2 (CIB)
        Indiana Jones and the Last Crusade (CB)
      Justice League Injustice For All (CIB)
      Masters of the Universe He-Man: Power of Grayskull (CIB)

      Cubic Ninja
      Dragon Quest VIII Journey of the Cursed King
      Fire Emblem Conquest (Japanese Version)
      Kirby Super Star Ultra
      Legend of Zelda Majora’s Mask
      Legend of Zelda Ocarina of Time 3D
      Legend of Zelda Phantom Hourglass
      Lunar Knights
      Metroid Prime Hunters
      Monster Hunter Generations
      Pokémon Mystery Dungeon Explorers of Time
      Pokémon Pearl
      Pokémon Platinum
      Pokémon SoulSilver
      Pokémon Ultra Moon
      Professor Layton and the Diabolical Box
      Rune Factory 4
      Super Mario 3D Land

      Final Fantasy X2 Remastered (Asia Release)
      Gravity Rush
      Little Deviants
      Persona 4 Golden (Asia Release)
      Rayman Legends
      Reality Fighters
      Senran Kagura Estival Versus (Asia Release)
      Uncharted Golden Abyss
      Wipeout 2048
      Ys Memory of Celceta

      Richard Scarry's BusyTown
      Altered Beast
      Beavis and Butthead    
      Contra Hard Corps
      Earthworm Jim
      Garfield Caught in the Act
      NBA Jam
      QuackShot Starring Donald Duck    
      Sonic the Hedgehog [Not for Resale]
      Teenage Mutant Ninja Turtles Hyperstone Heist
        NFL Quarterback Club
        Shadow Squadron

  • Create New...