アミガやC64のジョイスチックを使い倒そう!!


[ Follow Ups ] [ Tree BBS(current) ] [ wwwborard(legacy) ] [ Home ]

Posted by PICkey Hama on January 20, 2001 at 19:42:47:

君の持っているJOYは他にも使い道がありますよ!
(無理やりAMIGAネタにしてゴメンネ)

http://www.efd.lth.se/~e96rg/mc/video/tetris.html
先ずはこのアドレスに飛んで、何がいいたいか確認
この手の話題が好きな方は全部読んでくだしゃんせ。

機械翻訳(この手の翻訳は得意なんです。私の辞書)


Created:
Created:

1998-07-12
1998-07-12

Last modified:
最終変更 :

2000-12-18
2000-12-18

VIDEO TETRIS A video game with software generated video signal !
ソフトウェアを持つ VIDEO TETRIS A テレビゲームは、ビデオシグナルを生み出した !

Introduction I have made the game Tetris using a PIC16F84 running @ 12MHz.
私が @ 12MHz 走る PIC16F84 を使うゲーム Tetris にした導入。

Tetris is an old Russian computer game where you should try to fit in block into a play-field, quite simple but really fun.
Tetris は、あなたがプレーフィールド、かなりの単体にブロックに適合しようとするべきである古いロシアのコンピュータゲームである、しかし、実際、…楽しみ。

In my version, the video signal is generated in software.
私のバージョンにおいて、ビデオシグナルは、ソフトウェアにおいて生まれる。

The only hardware used for the video generation is two resistors forming a 2-bit DA converter.
ビデオ世代のために使われる唯一のハードウェアは、 2 ビット DA コンバータを形成する 2 台の抵抗器である。

Usually the video signal is generated in video games is created with a dedicated video chips, reading the image data from a graphics memory.
通常、ビデオシグナルは、テレビゲームにおいて生まれる…作成される…に関して…グラフィックスメモリからイメージデータを読み取って、専用のビデオが欠ける。

In this project the video signal is calculated in real-time by the microprocessor as the electron beam sweeps over the screen.
このプロジェクトにおいて、ビデオシグナルは、マイクロプロセッサによってスクリーン上のエレクトロンビーム掃引としてリアルタイムに計算される。

How to play the game The first screen is where you select how you want to play by moving the joystick:
いかにゲーム The first スクリーンをプレイするかは、どのようにあなたがジョイスティックを動かすことによってプレイすることを望んても、あなたがどこを選択するかである :

DOWN:
下りなさい :

Human vs. Human (H-H), LEFT:
置き去りにされる人間対人間の (H-H) :

Human vs. Computer (H-C) or RIGHT:
人間、対コンピュータ (H-C) 、または、右 :

Computer vs. Computer (C-C).
コンピュータ、対コンピュータ (C-C) 。

Start with FIRE.
火で始まりなさい。

Unfortunately it is impossible to beat the computer, since there was not enough room to make the computer beatable.
不幸にも、コンピュータを打つことができる状態にする十分な余地がなかったので、コンピュータを打つことは、不可能である。

That makes the computer vs. computer game to play forever until someone reset the game using the reset switch.
だれかがリセットスイッチを使うゲームをリセットするまで、それは、永久にプレイするために、コンピュータ、対コンピュータゲームを作る。

You start serving by pressing fire, it is also possible to change direction and speed of the ball using fire.
あなたは、火をプレスすることによって務め始める、…ボールの方向、及び、スピードを変えることは、同じく可能である…火を使う。

The player who has the serve will get points.
サーブを持つプレーヤーは、ポイントを得るであろう。

If the player with the serve miss the ball, then the serve goes over to the other player.
サーブを持つプレーヤーがボールを逃すならば、それから、そのサーブは、もう一方のプレーヤーに行く。

When someone wins a game over picture will show and tell who won.
だれかが勝つとき、絵上のゲームは、誰が勝ったかを示して、告げるであろう。

The software With a processor performing 3MIPS, it is not easy to make a video signal in software.
ソフトウェア With … 3MIPS を遂行するプロセッサ、…ビデオを作ることは、容易ではない…ソフトウェアにおいて合図する。

Each instruction performed takes 1/3 us.
行われた各命令は、 1/3 を我々であると考える。

Each scan-line on the screen takes 64us, where 52us are visible, so it gives 52*3=156 visible clock cycles per line.
スクリーン上の各スキャン‐ラインは、 64us をとる、…どこで 52us が見えるか、…従って、それは、ラインにつき 52*3=156 の明白な clock サイクルを与える。

Maximum resolution that can be obtained is 156 pixels in x-axis if the software is setting one pixel per clock (using for example only bcf and bsf), but more is needed to make a game, like loops and such.
ループのように、…そのソフトウェアが clock ( 例えば bcf のみ、及び、 bsf を使うこと ) につき 1 ピクセルをセットしているならば、獲得され得る最大の解像度は、 x 軸において 156 ピクセルである。しかし、ゲームを起こすのに更に必要とされる、そして、〜ほど。

A loop quantifies the time to 3-clock pieces, giving a resolution of 52 pixels.
52 ピクセルの決定を与えて、ループは、時間を 3 ‐ clock 部分に定量化する。

(One could obtain a kind of 156pixels resolution with one or two offset nops, but the code to select this would eat to many clock cycles to do any good).
( 1 つが 1 、 2 オフセット nops と共に一種の 156pixels 解像度を獲得するであろう。しかし、あらゆる利益をするためにこれを選択するためのコードが多くの clock サイクルに食べるであろう ) 。

However Tetris is quite simple, the resoluton is quite low, and there is no motion, the blocks of pixels are just turned on and off.
しかしながら、 Tetris は、全く簡単で、 resoluton は、全く低く、そして、運動がない、…ピクセルのブロックは、単に断続的に向けられる。

The most demanding part of the game is to show the score at the bottom of the screen, it is shown in the bottom of the screen.
それは、スクリーンの底においてゲームの最も要求の多い部分がスクリーンの底でスコアを示すことであることを示される。

It obtains higher resolution by loading the PORTB with the bitmap for the number and shift it out one pixel per clock cycle.
それは、数、及び、シフトのためのビットマップを PORTB にロードすることによって更に高い解像度を獲得する…それ…離れたところを、… clock につき 1 ピクセルは、循環する。

So far I've only talked about the graphic generation.
今までのところ、私は、グラフィック世代についてただ話した。

But there is more to it to get a video signal.
しかし、ビデオシグナルを得るために、更に多くがそれにある。

All scan-lines first have a 4us-sync pulse, then black for 8us, then the 52us graphic comes.
全てのスキャン‐ラインは、最初に 8us のためにそれから黒い 4us ‐同期化パルスを持っており、そして、 52us グラフィックは、起こる。

These horizontal sync-pulses makes the TV understand when a scan-line starts, but there is needed to send information about when a new picture starts too, it is called vertical sync, and is a special pattern that tells the TV that a new image is coming.
これらの水平の同期化‐パルス…テレビにスキャン‐ラインがスタートするとき、理解させる、しかし、そこで、…新しいピクチャがスタートするとき、情報を周囲に送るのに必要とされる…同様に、それは、垂直の同期化と呼ばれ、そして、特別なパターンである…それは、話す…新しいイメージがそうであるテレビは、来つつある。

There are two kinds of vertical sync, because the image is divided into two part images, showing even and odd lines, to get less flickering.
2 種類の垂直の同期化がある、なぜなら、そのイメージが 2 パートイメージに分割されるからだ、現れる…他の事はもちろん、そして、余分のライン、…あまり明滅しなく始めるために。

In Tetris, the two images are identical, so the game is not using the full y-resolution possible, but it doesn't matter because it is way better than the x-resolution anyway, making the x-resolution the biggest problem.
Tetris において、 x ‐解像度を最も大きい問題にして、 2 つのイメージは、同じである。従って、そのゲームは、可能な限りの十分な y ‐決議案を使っていない、しかし、それが x ‐解像度よりいずれにせよ更によく方法であるので、それは、問題とならない。

The game-field is kept in memory as a 32byte array, 16x16 bits, where one bit is one pixel-block on the screen.
ゲーム‐フィールドは、 32byte アレイとしてのメモリ、 16x16 ビットの中に保存される。そこで、 1 ビットは、スクリーン上で 1 ピクセル‐ブロックである。

The area to the upper left is for showing the next block, and by making it a part of the game field it is possible to use the same block-drawing routines as for the game, and thereby saving memory.
左上へのエリアは、次のブロックを示すためのものであり、そして、それをゲームフィールドの一部にすることによって、ゲームに関しては同じブロック‐図ルーチンを使うことは、可能で、そして、それによってメモリをセーブしている。

Each frame, the falling block is first removed from the game-field, and then tests are performed if the block can move, as the player wants it to.
各フレーム、…落下しているブロックは、最初の隔った from である…そのブロックが動くことができるならば、ゲーム‐フィールド、そして、テストは、遂行される、…そのプレーヤーがそれを必要とするので、…に。

Then the block is drawn back to the screen at the new position.
そして、そのブロックは、新しいポジションのスクリーンに引き戻される。

When a block is to be tested, put or removed, it first must be generated.
ブロックがテストされる、もしくは置かれる、もしくは取り除かれることであるとき、それは、最初に生成されなければならない。

To generate a block means compressing it from the compressed data, rotating it and then store the relative coordinates of the block in the block array.
ブロックを生成することは、圧縮されたデータからそれを圧縮することを意味する ( それ、そして、ブロックにおけるブロックの相対的な座標が配置するストアを回転させて ) 。

The block data is compressed in relative coordinates.
ブロックデータは、相対的座標において圧縮される。

In compressed format, each coordinate is stored in two bits for both x and y, where the two bits can represent the numbers ?1,0,1,2.
圧縮されたフォーマットにおいて、各座標は、 x と、 y の両方のための 2 ビットで格納される、そして、そこで、 2 ビットは、番号 ?1,0,1,2 を示すことができる。

These values need to be uncompressed to 4*2 byte sized values representing the coordinates in two’s complement format.
これらの値は、 two's 補数フォーマットにおいて座標を表す 4*2 バイトサイズで分類された値に圧縮されない必要がある。

Depending of the angle the block should have, the coordinates might need to be mirrored or/and swapped.
そのブロックが持つべきである角度の依存する、…調和する…映されて、スワップされる必要があるであろう。

When the block have been created it can easily be put, removed or tested.
とき…ブロック…作成された…それは、容易に置かれる、除去される、もしくは、テストされ得る。

The test routine checks if there is any pixels set on the block positions where the block should be put.
テストルーチンは、そのブロックが置かれるべきであるブロックポジションにセットされたピクセルがあるかどうかをチェックする。

If pixels are set, then the block can’t be put there.
ピクセルがセットされるならば、それから、ブロック can't は、そこに置かれる。

New blocks are selected at random, where the random number is a counter that increases for every frame, making the random number dependent of how long it takes for the player to place the block, making a quite good random number.
新しいブロックは、任意に選択される、…どこで乱数がカウンタであるか…それは、全てのフレームのために増加する、…それが場所にプレーヤーのためにどのくらいかかるかのうちで従属している乱数をブロックにする、…全く良い乱数を作る。

The game stuff, like checking joystick and move stuff around, is taken care of in the first scan-lines, when no graphics is drawn.
チェックジョイスティック、及び、動きが詰めるように、グラフィックスが描かれないとき、ゲームものは、最初のスキャン‐ラインにおいて世話をされる。

During the time before the play-field is shown, there is a little bit of free time to play the music, but there is not time to play it on all lines, and that make the music sound distorted.
時間の間、プレーフィールドが示される、音楽を演奏するわずかなフリー時間がある、しかし、全て上でそれをプレイする時間がない前に、ライン、及び、それは、音楽音を歪められた状態にする。

The music is stored in the data eeprom, and stored in a compressed one byte format,where one byte contains length and note.
その音楽は、データ eeprom に格納され、そして、圧縮された 1 バイトフォーマットに格納される。そこで、 1 バイトは、長さ、及び、ノートを含む。

The note's frequency is looked up in a table, and so is the length too.
ノートの周波数は、テーブルにおいて調べられ、そして、そのように同様にその長さである。

(The frequencies are based on the line frequency so they are not exactly the correct frequencies) The speed of the game is increasing constantly and music-speed increases as the game speed increases.
( それらの周波数がライン周波数に基づいている。従って、それらが必ずしも正しい周波数ではない ) ゲームのスピードは、絶えず増加しており、そして、ゲームスピードが増加するので、音楽‐スピードは、増加する。

Making this kind of software is mostly a clock-cycle-counting project, all timings are quite critical, so whatever paths the execution-flow of the program takes, it must take the same number of clock cycles.
この種類のソフトウェアを作るのは、たいてい clock-cycle-counting プロジェクトである。全てのタイミングは、全く重要である。従って、どんなプログラムの実行‐流れが道をとっても、それは、 clock サイクルの同じ数を収容しなければならない。

This is quite hard, and I've not managed to do this on all lines, so the image is a little bit bent in some places.
これは、全く堅く、そして、私は、どうにか全てのライン上でこれをしなかった。従って、そのイメージは、少しいくらかの場所で曲げられる。

(Most analog TV-sets fix this, but on some digital projectors it is more visible)
( 大部分のアナログテレビがこれを固定する。しかし、いくらかのディジタルプロジェクタ上でそれが更に見える )

The hardware The hardware is quite simple because everything is made in software.
全てがソフトウェアにおいて作られるので、ハードウェア The ハードウェアは、全く簡単である。

Two resistors, forming a DA converter together with the input impedance of the TV, generate the video signal.
テレビの入力インピーダンスと共に DA コンバータを形成する、 2 台の抵抗器は、ビデオシグナルを生成する。

This can generate the levels 0v (sync), 0.3v (black), 0.7v (gray), and 1.0v (white).
これは、レベル 0v ( 同期化 ) 、 0.3v ( 黒 ) 、 0.7v ( グレー ) 、及び、 1.0v ( 白 ) を生成し得る。

To be able to handle the variation of input resistance of different audio equipment, two resistors are used to make a 1-bit DA to generate the audio.
異なるオーディオ装置の入力抵抗の変化を扱うことができるために、 2 台の抵抗器は、オーディオを生成するために、 1 ビット DA を作るために使われる。

When generating the video, the PORTB is used as a shift register to get one pixel per instruction when high-resolution text is shown on the screen.
ビデオを生成しているとき、 PORTB は、高解像度テキストがスクリーン上で示されるとき、命令につき 1 ピクセルを得るためのシフトレジスタとして使われる。

Shifting a port requires the port to be set as output if a whole byte is to be shifted out.
ポートを変えることは、全てのバイトが外へ移されるべきであるならば、出力としてセットされるのにポートを必要とする。

First, this seems like a problem, the whole port can't be used for anything else than video generation, but that is not quite correct.
最初に、これは、問題、全ポートがビデオ世代より他の何のためにも使われることができないように思われる。しかし、それは、全く正しいとは限らない。

A port can be used as an input when not used as a shift register, so in Tetris PORTB it is used for joystick input when not used as a shift register.
ポートは、入力として使われ得る…ない…シフトレジスタとして使われる、…従って、 Tetris PORTB において、それは、ジョイスティック入力のために使われる…ない…シフトレジスタとして使われる。

The digital joystick is a switch to ground, so all needed to connect it to the PIC is a couple of pull up resistors, and that is available inside the PIC.
ディジタルジョイスティックは、接地するために、スイッチである。従って、それを PIC とつなぐのに必要とされる全ては、抵抗器の上方で索引力のカップルであり、そして、それは、 PIC の中で利用可能である。

Unfortunately it is not that simple, if a pin on a port is grounded when used as an output, the output buffer of the pic would burn up, so this is solved by adding one extra 1k resistor on each pin to limit the current.
不幸にも、出力として使われて、映画の出力バッファが燃焼するであろうとき、ポート上のピンが地上に置かれるならば、それは、その単体ではない。従って、これは、電流を制限するために、各ピン上で 1 台の余分の 1k 抵抗器を加えることによって解決される。

What about those pull up resistors?
それらに関する何が、抵抗器を引きあげるか ?

There are 10k pull up resistors built into the PIC that can be switched on and off.
10k がある…断続的に変わることができる PIC に組み込まれた抵抗器を引きあげる。

However, using them would be a too strong pull up, so the 1k current limiting resistor (plus bad switches in the joystick) can't pull the input low enough.
しかしながら、それらを使うのは、あまりにも強い引きであろう。従って、抵抗器 ( ジョイスティックにおける正の悪いスイッチ ) を制限する 1k 電流は、十分に入力を低い所に引くことができるとは限らない。

Therefor an external 100k resistor pull up network is added.
そのために、…外部の 100k 抵抗器…止まる…ネットワークは、加えられる。

The power supply part of the circuit is quite simple, it uses a standard 7805 to get a 5v supply.
サーキットの電源部分は、全く簡単である、… 5v 供給を得ることは、標準 7805 を使う。

The input can be 8-18 volt, DC or AC (Thanks to the diode at the power input)
その入力は、 8-18 ボルト、 DC 、または、 AC ( パワー入力のダイオードに対する謝意 ) であり得る

Schematic over the hardware.
ハードウェア上の図式。

Over-clocking a PIC16X84 To get enough processing power to generate the video signal, a little bit higher clock frequency was needed.
オーバー‐クロッキング… PIC16X84 To …十分に着く…ビデオシグナルを生成する力を処理して、少し高い clock 周波数が必要とされた。

The clock frequency should be a multiple of 4Mhz to make it easier to generate the correct timing.
clock 周波数は、正しいタイミングを生成するのを更に容易にするために、 4Mhz の倍数であるべきである。

The PIC16X84s are available in a 4MHz version and a 10MHz version, but the 10Mhz version was quite expensive when I started to make this project, so I tried to over-clock it, and it worked without problems, well, almost anyway.
PIC16X84s は、 4MHz バージョン、及び、 10MHz バージョンにおいて利用可能である。しかし、私がこのプロジェクトを作り始めたとき、 10Mhz バージョンは、全く高価であった、従って、私は、それ、及び、それがほとんどいずれにせよ問題 ( よく ) なしで働かせたオーバー‐ clock へ試みた。

The 16C84 became unerasable after a while when over-clocked, but the 16F84 seemed to work without problems, I've had them running for hundreds of hours without problems.
過度の‐時間を計られたとき、 16C84 は、しばらくして unerasable になった。しかし、 16F84 は、問題なしで機能するように思われた、…私…それらに問題なしの数百もの時間のために走らせた。

(But I wouldn't recommend you to use a over-clocked PIC in a commercial project).
( しかし、私は、商業プロジェクトに過度の‐時間を計られた PIC を使うようにあなたに勧めないであろう ) 。

Some people claims that the 4Mhz and the 10Mhz versions are the same chip with different text on the package, it would explain why the chip can be over-clocked more than 3 times, but I don't know.
4Mhz 、及び、 10Mhz バージョンが同じであるといういくらかの人々要求は、パッケージ上の異なるテキストによって欠ける。それは、なぜそのチップが 3 回以上過度の‐時間を計られ得るかを説明するであろう。しかし、私は、知らない。

Info about video signals.
ビデオについての情報は、合図する。

There is not much complete info about video signals, there are some but not many with complete info, the best I've seen so far is the documentation to Marcelo Maggi's pattern generator circuit.
ビデオシグナルについてのあまり完全な情報がない、…いくらかがある、しかし、完全な情報を持つ多く、…最も良い…私は、見た…そこまで Marcelo Maggi のパターンジェネレータサーキットへのドキュメンテーションである。

The information page I've written about video generation is actually quite good too =) Two quite good sites about technical info are Basic Video in the MOVING PICTURES Television Production Handbook and the Conventional Analog Television - An Introduction by Professor Kelin J. Kuhn.
私がビデオ世代について書いた情報ページは、同様に実際に全く良い… = ) Two …技術的情報に関する全く良いサイトは、 MOVING PICTURES Television Production Handbook 、及び、 Conventional Analog Television で Basic Video である - 教授 Kelin J. Kuhn による Introduction 。

Also remember to check out my Pong using the same hardware as tetris.
同じく忘れずに tetris と同じハードウェアを使う私の Pong をチェックしなさい。

Another interesting thing is that I'm no longer the only one who has done this kind of game, David B. Thomas has also made a Pong game using a PIC, but he used a PIC16C711
別の興味深いものは、私がもはやこの種類のゲームをした唯一の人ではないことである。デビッド B. トーマスは、 PIC を使う Pong ゲームを同じく起こした。しかし、彼は、 PIC16C711 を使った

Download Schematics, layouts, source-code and hex-files are available in Tetris.Zip (106kB) it contains both PAL and NTSC versions, make sure you put the appropriate version into your chip.
ダウンロード Schematics 、レイアウト、ソースコード、及び、ヘキサ‐ファイルは、それが含む Tetris.Zip ( 106kB ) で利用可能である… PAL と、 NTSC バージョンの両方は、あなたが適切なバージョンをあなたのチップに入れたことを確保する。

Emulator Andrew Toone has created an Emulator that emulates a pic with any hardware connected to it.
Emulator Andrew Toone は、それとつながっていたあらゆるハードウェアに関する映画と競う Emulator を作成した。

It is wrtitten in Java and the hardware is emulated by using plugins.
それは、 Java の wrtitten であり、そして、そのハードウェアは、プラグインを使うことによって競われる。

Andrew has created a TV-plugin that works with my games, thanks to this you don't have to build anything to try them =)
これのおかげでは、アンドリューは、私のゲームを使って働くテレビ‐プラグインを作成した…あなたがそれらを試みるための何でも造る必要はない… = )

Problems?
問題 ?

If you have questions about the games, make sure to check out the video game FAQ (Frequently Asked Questions) before you ask me.
あなたにゲームに関する質問があるならば、必ずあなたが私に尋ねる前に、テレビゲーム FAQ ( Frequently Asked Questions ) をチェックするようにしなさい。

Legal stuff.
法律上のもの。

Video Tetris c Rickard Gunee.
Video Tetris c Rickard Gunee 。

You may do what ever you want with the contents of this page as long as you refer to the original author (by name and link to authors homepage), don't do it for profit and don't hurt or harm anyone or anything with it.
あなたは、行うかもしれない…あなたがオリジナルの著者 ( 著者ホームページへの名前、そして、リンクによって ) に言及する限り、あなたがこのページの内容によっていったい何を必要とするか、…利益のためにそれをしない、そして、それと共にだれも、及び、何も傷つけない、及び害さない。

The author can not be held responsible for any damage caused by the information on this page.
その著者は、このページに関する情報によって引き起こされた全くダメージに関して責任がある状態に保たれることができない。

Click here to get back to my micro controller project page.
私のマイクロコントローラプロジェクトページに戻るために、ここをクリックしなさい。


以上




Follow Ups: