Code Monkey home page Code Monkey logo

sh_img2gb's Introduction

img2gb.sh

渡された画像(解像度160x144)を、
その画像を表示するゲームボーイのROMへ変換するシェルスクリプトです。

このような画像を、
元画像

このように表示するゲームボーイのROMファイルへ変換します。
エミュレータ上での実行の様子

実機でも動作確認済みです。
実機上での実行の様子

使い方

このリポジトリをクローンするか、ダウンロードし、
以下のようにコマンドを実行することで、ROMファイルを生成できます。

$ ./img2gb.sh 画像ファイル名 生成するROMファイル名

例)

$ ./img2gb.sh sample/daisy.png daisy.gb

※ 画像の解像度はあらかじめ160x144(ゲームボーイの画面解像度)にしておいてください。

※ 全てシェルスクリプトで作っているので時間がかかります。
  だいたい1分ほどお待ちください。(Intel Core i7 CPU @ 1.80GHzの環境にて)

動作環境

Debian GNU/Linux 9 (stretch) の環境で動作確認しています。

ただ、全てシェルスクリプトで作っており、
echoddを駆使してゲームボーイのROMヘッダやLR35902(ゲームボーイのCPU)の
機械語バイナリを生成しているので、
bashが動くような環境ではどこでも動くかと思います。

ただ、画像の変換処理にImageMagickconvertコマンドを使用していますので、
無い場合はインストールしておいてください。

UbuntuやDebianなど、APTが使える環境の場合は以下のコマンドでインストールできます。

$ sudo apt install imagemagick

注意事項

お遊び程度にご利用ください

シェルスクリプトで作ってみた程度のものなので、一応動作するものは生成しますが、
同様のもっとちゃんとしたものはブラウザ上で使えるものがあったりします。

ただ、ある意味シェルスクリプトでアセンブラも作っているようなものなので、
ゲームボーイのROMの解析や、CPU命令の勉強の参考にはなるかもしれません。

convertの減色処理は甘いです

この元画像が
元画像2

こんな風になったりします。
元画像2のエミュレータ上での実行の様子

ImageMagickを使用した画像変換はtool/img22bpptiles.shで行っていますので、
この中のconvertコマンドの引数などを調整するともう少し良くなるかもしれません。

カートリッジヘッダのGlobal Checksumは未設定です

エミュレータによっては「ヘッダのチェックサムがおかしい」と
警告などが出るかもしれませんが、無視して実行してください。

ROMのヘッダ情報の中の「Global Checksum(アドレス:014E-014F)」という領域が未設定であるためで、
この領域は実機で参照していないらしく、実際に未設定でも実機で動作しているため、
簡単のために設定していません。

sh_img2gb's People

Contributors

cupnes avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.