NES Programming with 6502 Assembly

NES Programming with 6502 Assembly

English | MP4 | AVC 1920×1080 | AAC 44KHz 2ch | 144 Lessons (27h 55m) | 6.16 GB

Learn the basics of Assembly 6502 and computer architecture programming games for the Nintendo Entertainment System

What you’ll learn

This course is a complete immersion into the world of the Nintendo Entertainment System. We will learn how to program games for the NES using 6502 assembly while exploring the building blocks of computer architecture. The rudimentary hardware of the NES is a perfect sandbox for us to learn important concepts of low-level programming.

At the end of the course, you’ll have a working knowledge of 6502 assembly language, a comprehensive understanding of the NES hardware, and a toy homebrew game project that we’ll code together from scratch. We’ll start with small examples and proceed to glue everything together in a final project that demonstrates how a simple NES game works.

The tools you’ll need

We’ll use a simple code editor, an assembler called CA65, and a NES emulator called FCEUX. All these tools are cross-platform, so you’ll be able to follow along on either Windows, macOS, or Linux!

Is this course for you?

This is a self-contained course with no formal prerequisites. However, you will probably get the most out of it if you already know the basics of coding (if-else, loops, functions).

If you like retro game development and want to learn more about computer architecture and low-level programming, then this course is definitely for you!

Table of Contents

1 Motivations & Learning Outcomes
2 How to Take this Course
3 Placing the NES in History
4 NES Hardware (Console)
5 Opening the NES Cabinet
6 NES Hardware (Cartridge)
7 Binary Numbers
8 Hexadecimal Numbers
9 6502 CPU Pinout
10 6502 CPU Registers
11 6502 CPU Status Flags
12 The Assembler Flow
13 Popular 6502 Instructions
14 CA65 Assembler
15 Installing CA65 on macOS
16 Installing CA65 on Linux
17 Installing CA65 on Windows
18 iNES Header
19 Our First Assembly Code
20 Assembler & Linker
21 FCEUX Emulator
22 Our First Assembly Bug
23 Addressing Modes
24 6502 Warmup Exercises
25 6502 Warmup Exercises (Solution)
26 Makefiles
27 CPU Memory Map
28 Clearing RAM Addresses
29 NES Graphics & the PPU
30 Picture Frame & VBlank
31 PPU Memory Map
32 Background Color
33 NES Initialization Code
34 Include Files
35 Resetting PPU Address Latch
36 Sending Multiple Bytes to the PPU
37 Unnamed Labels & Subroutines
38 Editing CHR Tiles
39 Loading Nametable Tiles
40 Nametable Attributes
41 Loading Attribute Bytes
42 Creating Dynamic Macros
43 Declaring Variables
44 Measuring Game Seconds
45 Pointers
46 Loading a Full Nametable
47 Full Nametable Code
48 Exercise: Displaying Text
49 Displaying Text
50 Other Tile Editor Apps
51 NES Sprites
52 Hello Mario
53 OAM Decay
54 Hiding Sprites Off-Screen
55 Sprite Flickering
56 Include Nametable Files
57 Exercise: Hello Goomba
58 Hello Goomba
59 Bitwise Instructions
60 Controller Architecture
61 Controller Input Routine
62 Implementing Controller Input
63 Checking Button Presses
64 Moving Sprites with Button Presses
65 Button Constants
66 Integer & Fractional Position
67 Velocity & Acceleration
68 Signed Velocity
69 Intercalating Animation Frames
70 Multiple of Powers of Two
71 Mirroring & Scrolling
72 Horizontal Background Scrolling
73 Swapping Nametables
74 Bitshifting Operations
75 Load Background Dynamically
76 A Method for Dynamic Scrolling
77 Starting the Atlântico Code
78 Drawing Column of Tiles Off-Screen
79 Loading Initial Nametable Tiles
80 Loading Attributes Off-Screen
81 Scroll Split Screen
82 Sprite-0 Hit Implementation
83 Separating Game Logic & NMI
84 Running Game Logic Once Per Frame
85 Saving Registers in the Stack
86 Counting Game Loop Passes
87 Macro to Push & Pull Registers
88 A Discussion on Buffering
89 Array of Actors
90 Adding & Removing Actors
91 A Routine to Add Actors
92 Coding the Routine to Add Actors
93 Template to Loop Actors Array
94 Rendering Actors
95 Updating Actor Position
96 Limiting One Missile Per Button Press
97 Deleting Actors
98 Relative vs. Absolute Jumps
99 Spawning Submarines
100 Spawning Airplanes
101 Random Numbers using LFSR
102 8-Bit LFSR Example
103 Random Airplane Position
104 Adjusting Airplane Position
105 Sprite Collision Check
106 Missile-Airplane Collision
107 Check Point Inside Bounding Box
108 BCD Representation
109 Routine to Increment Score
110 Buffering Background Tiles
111 Increment Score on Airplane Hit
112 Background Collision Check
113 CHR Bank Switching
114 Game States
115 Title Screen State
116 Title Screen Nametable
117 Title Screen Menu Items
118 Drawing Menu Item Arrow
119 Exercise: Menu Item Palette Selection
120 Menu Item Palette Selection
121 RLE Compression
122 A Python Script to Encode RLE
123 A Routine to Decode RLE Data
124 Title Screen RLE Decoding
125 APU
126 Introduction to FamiStudio
127 Square Channel Ports
128 Triangle, Noise, and DMC Ports
129 Musical Notes & Period
130 Using a Sound Engine
131 FamiStudio Sound Engine
132 Some Notes on Chords & Voicing
133 Playing FamiStudio Music Code
134 Playing Missile Sound Effect
135 Playing Explosion Sound Effect
136 Fixing Button Press/Release Bug
137 Fixing VRAM Buffering Address
138 Clipping Tiles Left & Right
139 Calculating Tile Screen (-1,0,+1)
140 Removing Actors Off Screen
141 Fixing Explosion SFX Bug
142 Developing NES Games with C
143 C NESLib Examples
144 Conclusion & Next Steps

Homepage