Position: Index > Unclassified >

PIC micro Tetris game

2017-08-15 05:04  
Declaration:We aim to transmit more information by carrying articles . We will delete it soon, if we are involved in the problems of article content ,copyright or other problems.

 

tetris PIC micro Tetris game

This article is a PIC micro Tetris game to introduce the principle. To more effectively grasp this principle, the proposal combine text read schematics. The  circuit is simple but effective. Figure: softw1are and a processor executes 3 mips, is not an easy one video signal softw1are. The maximum available resolution of 156 pixels in the x-axis is set if softw1are one pixel per clock (using examples only boost and water purifier), but more is needed to make a game like loops and such. A cycle time of 3 clocks member quantized to a resolution of 52 pixels. (One might get kind 156 pixel resolution with an offset or tw1o air operations, but it will eat a lot of code selection clock cycles to do anything good). There tw1o-type vertical-synchronization because the image is divided into tw1o part of the image, even and odd display lines, get less flicker. In Tetris, tw1o image is the same, so the game does not use the full resolution may do is y, but it is not important, because it is the ratio of x resolution anyway, so that x resolution the biggest problem. This venue is kept in memory for 32 byte array, 16 × 16-Bit, one is a block of pixels on the screen. This area is the upper left corner to display the next block, and make it a part of the game can use the same fields in the block drawing program As for the game, thus saving memory. Each frame is the first building block to withdraw race scene, and then test execution if the block can be moved, as a player want it. Piece to be attracted back to the screen of the new location. When a block can be tested, the or deleted, it must first be generated. Means to generate a block of data from the compressed compress it, rotate it, and then stores the relative coordinates of the block of the array block. The compressed data blocks in the relative coordinate. In the compression format, each coordinate position is stored in tw1o two x and y, tw1o bit can represent numbers 1,0,1,2. These values ??need to be compressed to 4 * 2 byte size values ??represents coordinates tw1o supplement form. Different corners should have, coordinates may need to mirror and / or exchange. When the block has been created it can be easily put, removed or tested. Test program checks if there are any location provided on the pixel block should block. If the pixel set, and then the block can not be placed there. New blocks are randomly selected, there is a counter, a random number to increase each frame, making the random number depends how long it allows players to place the block, make a good random numbers. Game things, like checking the joystick and moving things, is to take care of the first scan line, when no picture is you draw. Playing field in the time before the show, there is a little free time to play music, but no time to play it at all lines, making the music sound distorted. Music data stored in eepm, and a byte stored in a compressed format, a byte contains the length. The frequency of this note is a table lookup, so is the length too. (Frequency based on the line frequency that they are not exactly the correct frequency) is increasing the speed of the game and increase the speed of the music makes this softw1are mostly one clock cycle count program, all the time, so no matter very critical path program execution necessary, it must take the same number of clock cycles.
The hardware is very simple, because everything softw1are. tw1o resistors form a digital to analog converter with the input impedance of the TV, the video signal is generated. This can generate a level of 0 v (synchronous), 0.3 v (black), 0.7 v (gray), and then it 1.0 v (white). Changes in resistance can handle different input audio devices, make use of one bit DA tw1o resistor generates audio. When generating the video, PORTB as a shift register to get a pixel / instruction displayed on the screen when the resolution text. Will require ports to be output to a port if a whole byte is shifted. First, it seems to be a problem, the entire port can not be used for any other than the video generation, but this is not entirely correct. One port can be used as an input when not used as a shift register, so Tetris PORTB when not used for joystick input shift register. Digital lever is switched to ground, so all you need to connect to the picture is a pair of pull-up resistor. If a needle in a port is grounded when used as an output, the output buffer will burn up the picture, so this is solved by adding an extra 1 k resistor to limit the current at each pin. Those pull-up resistor? Have 10 k pull up resistor built into the picture, you can turn on and off. However, the use they will be too strong a pull, so 1 k-limiting resistor (plus bad switch on the joystick) can not pull the input low enough. Therefore, the external pull netw1ork 100 k resistor is added. Power supply circuit is very simple, it uses a standard 7805, get a 5 v supply. Enter at 8-- 18 V DC or AC.

videogame schem PIC micro Tetris game