当前位置:网站首页>How does FC game console work?

How does FC game console work?

2020-11-09 00:28:00 shzwork

(NES PPU)

Do a simple calculation :

The resolution of the 256x240 = 61440, That is, there are so many pixels on the screen .( Ignore NTSC Loss of system 16 That's ok ,PAL The system is 256x240)

If we only show black and white , That is, every pixel is black or white , So a single pixel bit That's all right. , At such a high resolution , Total needs 1 * 61440 / 8 / 1024 = 7.5KB, If you do this directly, the black and white dots can't fit the host video memory , At that time, the better computers were just about the same .
Let's say we use the very common 256 color , namely 8 Binary bits , A byte store , The whole picture 61440 / 1024 = 60KB, This is in FC Time is something that no ordinary machine can do directly .

To show color , At that time, different machines had various techniques , It can be said that the eight immortals cross the sea and show their magical powers .FC The first method used is called Color Cell, say concretely :

  1. Divide the whole image into many 8x8 Small cell ( Or call it tile)
  2. Every cell At most there is 4 Color

such , Each pixel only uses 2bit To store colors , And then to the total 32x30 = 960 individual cell Redistribute color coding , Indicates which colors are available .

 

Take a chestnut , We know the devil city (Castlevania, 1986) start :( The picture is from [dustmop.io blog]

 

The smallest lattice in the graph ( All the light lines cut out ) That is, a cell or tile, four tile Form a block( It's just a bright line ). In the picture, we use 10 Color . You can't find any more than 4 Colored cell.

 

 

Let's see another one. I'm the top one :

 

Encoding cell The table will be stored in video memory called name table In the region , Just now the opening area code of demon city is shaped as shown in the figure below :

 

FC The second brilliant thing is the advanced scrolling technology , because PPU There are two inside ( After the mirror image, there are four )name table To store cell Table information , We can always pre store more than the display , After the player or program triggers the scrolling operation , By sending two registers PPUSCROLL and PPUCTRL Write relevant information , You can move the game lens .

 

stay FC Previous hosts , Scrolling almost always covers the whole screen , It's expensive .FC At the same time, it makes the action 、 Shooting games have been greatly developed .

 

The last part is the movement in the game Sprite, Stored in a specific built-in memory area of the graphics card , Usually a single size is 8x8 or 8x16, Most of the protagonists we see are many Sprite Put together , such as Mario It's actually 4 individual Sprite Spell out , Just make sure it doesn't fall apart in the program .

 

Sprite Is displayed over the background , No matter how the background is set , stay PPU Conduct Sprite After detection, the corresponding bit will be set to Sprite The color of .


Last ,btw, Basically all FC/NES Development materials can be found in NES dev And its appendages wiki Found on the , It's just that without the relevant professional knowledge, it may be more difficult to gnaw .
Chinese people's 《 Nintendo game programming 》 Generally speaking, the book is more detailed , However, many key points are vague , And spent a lot of time teaching how to write code . It's good for the layman , It's basically useless for professionals . what's more , The book says little about Rationale Things that are , For real learning, it's disastrous .

 

http://nesdev.com/NESDoc.pdf
The basic principles are written in this document . The core is CPU(Central Processing Unit) and PPU(Picture Processing Unit),PPU It's a wonderful design .

 

Github There are various versions of NES Simulator source code , Through this code, you can understand more clearly NES Operation process :

 
FC Made with a Ricoh 8 Bit 2A03 NMOS processor ( be based on 6502 a central processor , But there is a lack of BCD Pattern )[1],PAL The operating frequency of standard model is 1.773447MHz,NTSC The operating frequency of standard model is 1.7897725MHz, Main memory and display memory are 2KB.
FC Image controller developed by Ricoh (PPU), Yes 2KB Video memory of , The palette shows 48 Color and 5 A gray scale . One screen can show 64 A character (sprites) , The role format is 8x8 or 8x16 Pixel , One scan line shows at most 8 A character , Although this limit can be exceeded , But it causes the character to blink . The background can only show one scroll , The resolution of the picture is 256x240 , But because NTSC System limitations , Can't show top and bottom 8 Scanning lines , So the resolution remains 256x224.
Architecturally ,FC There's a pseudo sound processor (pseudo-Audiom Processing Unit,pAPU), In real hardware , This processor is integrated into 2A03 NMOS In the processor [2].pAPU Built in 2 It's almost the same (nearly-identical) The rectangular wave channel of ,1 Three triangular channels ,1 Noise channels and 1 Audio sample playback channels (DCM, Delta modulation mode )[2]. among 3 There are analog channels for playing music ,1 A murmur channel shows a special sound effect ( Explosions , Gunfire, etc ), The audio sample playback channel can be used to represent continuous background sound .
FC There is a reset switch on the mainframe 、1 A power switch 、1 Game card slots 、2 One with a cross direction key 2 Key handle ( Game controller ), On the main handle “ choice ” and “ Start ” Button . There is a power interface on the back of the host 、RF RF output interface 、 Video image output interface 、 Audio out connector . There is also an expansion port ahead , Used to connect the light gun 、 Additional external devices such as continuous transmitter handle .
FC Games are usually stored in the form of read-only memory in a game card that can be plugged into the host slot , Capacity is LA series 24K,LB series 40K,LC series 48K,LD series 64K,LE series 80K,LF series 128K,LG series 160K,LH series 256K, Teka series and all in one cassette tape, etc . There are also some with batteries to keep game progress .
1986 year 2 month 21 Japan , Nintendo also launched a FC Disk drive , Can be in FC Host through the converter to use a dedicated floppy drive to read and write games , The capacity of the floppy disk is 112KB.

版权声明
本文为[shzwork]所创,转载请带上原文链接,感谢