Matt Hughson Profile picture
Dec 20, 2022 9 tweets 5 min read Read on X
Here's a fun problem to solve when making NES games, that you might not even realize is a problem! #nesdev

Sprites on the NES are actually drawn in "screen space" and wrap around at the edges. But obviously in many games, this makes no sense! Here's how to solve it 🧵
The sprites are drawn in a range of 0-255 on the x-axis (0-239 on the y-axis), and have no concept of a "camera", or the level. It is up to the dev to draw them in a location on screen that makes sense, relative to the game's camera.
It is also up to the dev to make sure that objects that are "off camera" do not get drawn.

But this can be tricky because "objects" are actually multiple 8x8 sprites drawn together to form a larger object.
There are times when an object is only *partially* on-camera (and partially off-camera) and we need to ensure that those partial parts, off-camera, do not get drawn, on a *sprite-by-sprite basis*.

This is technically a little tricky but very fixable!
However, once we fix that issue, a more complex problem presents itself. Take a look! 👀

The problem: what to do when a single sprite is half on screen and half off screen. If we draw it, in this example, it will actually show up on the far right.

The solution is kind of ugly!
This NES actually has a built in feature to handle this, but probably not in the way you might expected. A game can set a flag to completely disable rendering sprites on the left 8 pixels of the screen. This "fixes" the issue by removing the glaring "pop" as a sprite vanishes.
That looks smoother, but it still looks weird having the object seem to slide out of existence. To improve this, we can also turn off rendering off the background for that same area of the screen. This creates the illusion that the entire left column of the screen are unused.
And here is the final result!
So to recap, the solution is to:

1) Cull off-screen sprites.
2) Disable rendering on the left 8 pixels of the screen to avoid sprites *popping* in and out.

3) Rest easy knowing that many of your favorite games did this too! 😉

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Matt Hughson

Matt Hughson Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @matthughson

Jan 15, 2023
Implementing scrolling on the NES is difficult. Because of that, I've been thinking about what different platformer games have done, and which battles I want to fight with my #nesdev game.

I'll document all the different *types* of scrolling I can think of in this thread.
::Full 8-Way Scrolling (Blaster Master)::

Levels extend in all directions with a maze-like layout, not favoring any one direction in particular. Levels are much larger than can fit in nametable, and employ level streaming.
::Limited 8-Way Scrolling (Mario 3)::

SMB 3 has some levels with 8 way scrolling, but are still designed with a bias towards horizontal movement. Up/Down is reserved for "hidden objects" and "secrets".

Camera is designed to only scroll up if player is doing a highjump/flying.
Read 11 tweets
Dec 20, 2022
Did you know: 🤔

The infamous "sprite flicker" you see on the NES, is not actually a built-in hardware feature.

This flicker needed to be hand-coded into every game!

But why!? 🧵👇
The flicker is an attempt to avoid a limitation of the NES:

The NES can only display 8 sprites per horizontal line of the screen.

Source: nesrocks.com/blog/nes-graph…
The NES's default behavior is to *stop drawing sprites* once that 8 sprite limit it reached. This is what *that* looks like.

Notice that the purple character on the left just completely vanishes. You can imagine why games avoided this.

(The 4 skeletons use 8 sprites total)
Read 5 tweets
Dec 2, 2022
Here's a quick look at the TOP 5 games from this year's #nesdevcompo!

All games are free to play, and there are many more great games beyond these 5! 🧵👇
5th Place 🏆 @miau6502
miau6502.itch.io/crowborg

From the one of the developers behind Micro Mages, Böbl, Space Gulls and more!

A really original take on rogue-like where you can only move using a grappling hook. Clever enemy designs make this one stand out for me.
4th Place 🏆 Fiskbit
fiskbit.itch.io/irritating-ship

Pilot a ship through a zero-G obstacle course. A mix of Asteroids & Irritating Stick. Probably the most complete "game experience" in the competition!
Read 7 tweets
Nov 28, 2022
Got the day off work, and kids are in school! Time to go ham on this project, and turn *this* (side scroller) into *this* (top down rpg-like world map). #nesdev
Bringin' in the lil' guy! Image
Believe it or not, this is actually *progress*! Graphics data for the top down character is being properly swapped in (replacing the side scroller graphics).

Just the animation data hasn't bee updated!👍
Read 37 tweets
Aug 23, 2022
My top 5 NES homebrew at the moment!

#5 "NEScape!" (2019) by @atonofglaciers
#4 "Spacegulls" (2021) by @morphcat
#3 "Anguna: Scourge of the Goblin King" (2021) by @nathantolbert
Read 6 tweets
Jul 3, 2021
This debate between @davidscottjaffe and @hard8_times has been on my brain since I listened to it and I wanted to capture some thoughts on Game Streaming and what I heard. 🧵

Disclaimer: I work on Gears at Microsoft, but I'm not involved w/Cloud Gaming or GamePass.
1. There is a huge difference between what *I/YOU* want, and what "most people" want. Compartmentalize your personal preferences and think about what the vast majority of people value.
I think the success of Mobile Gaming, <$400 TVs, and Netflix, proves that most people are ok with sub-par audio/visuals/input. Even if they would PREFER HD, when Streaming comes to a $25 HDMI stick, *most people* will take that over a $500 console.
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(