Before the basics: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
(→‎Background: Ulf and Bean are having an argument on IRC as to what a 'divider' is.)
(added a new section to page where i discuss expectations and important considerations to keep in mind while developing for the NES.)
 
(5 intermediate revisions by one other user not shown)
Line 10: Line 10:
*[[wikipedia:Computer|Computer]] (it's not just a PC)
*[[wikipedia:Computer|Computer]] (it's not just a PC)
*[[wikipedia:Bit|Bit]]
*[[wikipedia:Bit|Bit]]
**[[wikipedia:Boolean logic|Boolean logic]]
**[[wikipedia:Boolean algebra|Boolean logic]]
**[[wikipedia:Introduction to Boolean algebra|Introduction to Boolean algebra]]
*[[wikipedia:Binary number|Binary number]]
**[[wikipedia:Logic gate|Logic gate]]
**[[wikipedia:Linear feedback shift register|Linear feedback shift register]]
**[[wikipedia:Ring counter|Ring counter]]
*[[wikipedia:Binary numeral system|Binary numeral system]]
**[[wikipedia:Byte|Byte]]
**[[wikipedia:Byte|Byte]]
**[[wikipedia:Arithmetic logic unit|Arithmetic logic unit]]
**[[wikipedia:Arithmetic logic unit|Arithmetic logic unit]]
Line 21: Line 17:
*[[wikipedia:Random-access memory|Random-access memory]] (RAM)
*[[wikipedia:Random-access memory|Random-access memory]] (RAM)
*[[wikipedia:Read-only memory|Read-only memory]] (ROM)
*[[wikipedia:Read-only memory|Read-only memory]] (ROM)
*[[wikipedia:Bus (computing)|Bus]]
**[[wikipedia:Bank switching|Bank switching]]
*[[wikipedia:Integrated circuit|Integrated circuit]] (IC)
**[[wikipedia:7400 series|7400 series]]
*[[wikipedia:Central processing unit|Central processing unit]] (CPU)
*[[wikipedia:Central processing unit|Central processing unit]] (CPU)
**[[wikipedia:MOS Technology 6502|MOS Technology 6502]]
**[[wikipedia:MOS Technology 6502|MOS Technology 6502]]
Line 35: Line 27:
**[[wikipedia:Source code|Source code]]
**[[wikipedia:Source code|Source code]]
**[[wikipedia:Object file|Object file]]
**[[wikipedia:Object file|Object file]]
**[[wikipedia:Compiler|Compiler]]
**[[wikipedia:Parallel computing|Parallel computing]]
**[[wikipedia:Parallel computing|Parallel computing]]
**[[wikipedia:Thread (computer science)|Thread]]
**[[wikipedia:Thread (computing)|Thread]]
*[[wikipedia:Input/output|Input/output]] (I/O)
*[[wikipedia:Input/output|Input/output]] (I/O)
**[[wikipedia:Memory-mapped I/O|Memory-mapped I/O]]
**[[wikipedia:Memory-mapped I/O|Memory-mapped I/O]]
Line 43: Line 34:
**[[wikipedia:Interrupt|Interrupt]]
**[[wikipedia:Interrupt|Interrupt]]
**[[wikipedia:Serial Peripheral Interface Bus|Serial Peripheral Interface Bus]] (SPI)
**[[wikipedia:Serial Peripheral Interface Bus|Serial Peripheral Interface Bus]] (SPI)
*[[wikipedia:Digital signal|Digital signal]]
**[[wikipedia:Digital audio|Digital audio]]
**[[wikipedia:Signal generator|Signal generator]]
**[[wikipedia:Delta modulation|Delta modulation]]
**[[wikipedia:Frequency divider#Digital dividers|Digital frequency divider]]
*[[wikipedia:Raster graphics|Raster graphics]]
*[[wikipedia:Raster graphics|Raster graphics]]
**[[wikipedia:Pixel|Pixel]]
**[[wikipedia:Pixel|Pixel]]
**[[wikipedia:Raster scan|Raster scan]]
**[[wikipedia:Raster scan|Raster scan]]
**[[wikipedia:Bitmap|Bitmap]]
**[[wikipedia:Bitmap|Bitmap]]
**[[wikipedia:Planar (computer graphics)|Planar bitmap]]
**[[wikipedia:Progressive scan|Progressive scan]]
**[[wikipedia:Progressive scan|Progressive scan]]
**[[wikipedia:Vertical blanking interval|Vertical blanking interval]] (vblank)
**[[wikipedia:Vertical blanking interval|Vertical blanking interval]] (vblank)
**[[wikipedia:Text mode|Text mode]]
**[[wikipedia:Text mode|Text mode]]
**[[wikipedia:Text user interface|Text user interface]]
**[[wikipedia:Text-based user interface|Text-based user interface]]
**[[wikipedia:ASCII art|ASCII art]]
**[[wikipedia:ASCII art|ASCII art]]
**[[wikipedia:Scrolling|Scrolling]]
**[[wikipedia:Sprite (computer graphics)|Sprite]]
**[[wikipedia:Sprite (computer graphics)|Sprite]]
**[[wikipedia:Display list|Display list]]
*[[wikipedia:Command-line interface|Command-line interface]]
*[[wikipedia:Command-line interface|Command-line interface]]
**[[wikipedia:COMMAND.COM|MS-DOS Prompt]]
**[[wikipedia:Shell (computing)|Shell]]
**[[wikipedia:Command Prompt|Windows Command Prompt]]
**[[wikipedia:cmd.exe|Windows Command Prompt]]
**[[wikipedia:Batch file|Batch file]]
**[[wikipedia:Batch file|Batch file]]
**[[wikipedia:Plug-in (computing)|Plug-in]]
**[[wikipedia:Plug-in (computing)|Plug-in]]
**[[wikipedia:Filename extension|Filename extension]]
**[[wikipedia:Filename extension|Filename extension]]
**[[wikipedia:ZIP (file format)|ZIP]]
**[[wikipedia:Zip (file format)|Zip file]]
**[[wikipedia:Environment variable|Environment variable]]
**[[wikipedia:Environment variable|Environment variable]]
=== More advanced topics ===
It has been suggested that understanding these topics is not necessary to program low-complexity games in assembly language without sound, such as a workalike of Magnavox Odyssey tennis. They are held here for forthcoming sorting into a separate page.
*Games larger than one screen
**[[wikipedia:Scrolling|Scrolling]]
*Audio
**[[wikipedia:Digital signal|Digital signal]]
**[[wikipedia:Digital audio|Digital audio]]
**[[wikipedia:Signal generator|Signal generator]]
**[[wikipedia:Delta modulation|Delta modulation]]
**[[wikipedia:Frequency divider#Digital dividers|Digital frequency divider]] (also [[wikia:c:electronicmusic:Pulse divider|on Wikia]])
*Mapper
**[[wikipedia:Logic gate|Logic gate]]
**[[wikipedia:Linear feedback shift register|Linear feedback shift register]]
**[[wikipedia:Ring counter|Ring counter]]
**[[wikipedia:Bus (computing)|Bus]]
**[[wikipedia:Bank switching|Bank switching]]
**[[wikipedia:Integrated circuit|Integrated circuit]] (IC)
**[[wikipedia:7400 series|7400 series]]
*High-level languages
**[[wikipedia:Compiler|Compiler]]


== Introducing the NES ==
== Introducing the NES ==
Line 89: Line 98:
*(optional) Bank switching hardware for the ROMs
*(optional) Bank switching hardware for the ROMs
*(optional) Logic to generate interrupts
*(optional) Logic to generate interrupts
== Important Considerations ==
The NES is not an easy system to develop games for anybody who does not have a good information and knowledge about the low-level workings of a computer. Developing games for NES can be tricky for developers who are used to tools like Unreal Engine, Unity, Godot, and game libraries and frameworks like Raylib, OpenGL, etc.
A few of such (at first) hard-to-grasp concepts and difficulties that one might face during their journey are:
*Memory-mapped I/O, memory mirroring, incomplete address decoding and mapping and mappers can be confusing to understand and deal with, at first.
*Issues like race conditions can pop up during the journey, such as not being able to write to video memory while the PPU is busy rendering the screen (you have to wait until the Vertical Blanking interval begins, of which the PPU can notify using an interrupt).
*One cannot have "pre-initialized" global variables unless coded manually (due to program residing entirely in the ROM).
If you do not have a good programming knowledge, then you should firstly consider getting programming experience. Knowledge of the 6502 assembly language is important and knowledge and experience in C programming language is extremely helpful, as it is often used and compiled and linked together with the 6502 assembly.
Not understanding concepts clearly such as memory-management and not having enough technical knowledge about the hardware can give one a hard time developing tools or games on the NES, such as if you don't understand the memory-range of the hardware and you allocate memory outside the range of what hardware can access, you might get bugs and problems popping up in your code. Hence, having a good grasp of assembly is essential as it allows you to gain experience to the memory mappings of the hardware and management of the same.
And most importantly, '''one should not expect much from the NES hardware''', it has a 1.7 MHz processor compared to a modern processor like Intel i5-13400 processor which runs at 2.5 GHz. The PPU on the NES spends exactly ''1 clock cycle per pixel''. Another important thing is that '''PPU and CPU do not share any memory''', both have their own buses.
== External links ==
*[https://skilldrick.github.io/easy6502/ Easy 6502]

Latest revision as of 11:11, 13 December 2023

Background

A digital computer, such as a PC or NES, is filled with millions of tiny switches that can be turned on or off. Some switches store information for short time; these are called memory. Other switches calculate things based on the output of other switches; these are called logic. Each switch can be on or off, representing true or false, or the numbers 1 or 0. Multiple switches grouped together can represent larger values. A CPU reads machine code from a memory and treats it as instructions to perform arithmetic and logic operations on other values in memory or to perform input and output. Some of the input and output involve user interaction: the user gives commands to the computer, and the computer displays the result.

If you're confused, now is the opportunity to become familiar with the following basic concepts from computer engineering and computer science. These articles from Wikipedia are in English, and many have been translated into other languages.

More advanced topics

It has been suggested that understanding these topics is not necessary to program low-complexity games in assembly language without sound, such as a workalike of Magnavox Odyssey tennis. They are held here for forthcoming sorting into a separate page.

Introducing the NES

The Nintendo Entertainment System has the following components:

  • 2A03 CPU IC made by Ricoh
    • CPU based on the MOS Technology 6502 8-bit microprocessor
    • serial input for game controllers
    • audio output comprising four tone generators and a delta modulation playback device
  • 2 KiB of RAM for use by the CPU
  • 2C02 PPU (picture processing unit)
    • tile-based background image
    • 64 sprites (individually moving objects)
    • 25 colors out of 53
    • 256x240 pixel progressive picture generator
    • NTSC color encoder
  • 2 KiB of RAM for use by the PPU

Cartridges have the following components:

  • 16 KiB or more PRG ROM, for use by the CPU
  • 8 KiB or more CHR ROM or CHR RAM, for use by the PPU (and in some cases by the CPU)
  • (optional) Bank switching hardware for the ROMs
  • (optional) Logic to generate interrupts

Important Considerations

The NES is not an easy system to develop games for anybody who does not have a good information and knowledge about the low-level workings of a computer. Developing games for NES can be tricky for developers who are used to tools like Unreal Engine, Unity, Godot, and game libraries and frameworks like Raylib, OpenGL, etc.

A few of such (at first) hard-to-grasp concepts and difficulties that one might face during their journey are:

  • Memory-mapped I/O, memory mirroring, incomplete address decoding and mapping and mappers can be confusing to understand and deal with, at first.
  • Issues like race conditions can pop up during the journey, such as not being able to write to video memory while the PPU is busy rendering the screen (you have to wait until the Vertical Blanking interval begins, of which the PPU can notify using an interrupt).
  • One cannot have "pre-initialized" global variables unless coded manually (due to program residing entirely in the ROM).

If you do not have a good programming knowledge, then you should firstly consider getting programming experience. Knowledge of the 6502 assembly language is important and knowledge and experience in C programming language is extremely helpful, as it is often used and compiled and linked together with the 6502 assembly.

Not understanding concepts clearly such as memory-management and not having enough technical knowledge about the hardware can give one a hard time developing tools or games on the NES, such as if you don't understand the memory-range of the hardware and you allocate memory outside the range of what hardware can access, you might get bugs and problems popping up in your code. Hence, having a good grasp of assembly is essential as it allows you to gain experience to the memory mappings of the hardware and management of the same.

And most importantly, one should not expect much from the NES hardware, it has a 1.7 MHz processor compared to a modern processor like Intel i5-13400 processor which runs at 2.5 GHz. The PPU on the NES spends exactly 1 clock cycle per pixel. Another important thing is that PPU and CPU do not share any memory, both have their own buses.

External links