Code Monkey home page Code Monkey logo

gb-photo's Introduction

Photo!

The latest release version may be downloaded here.

This project requires the reflashable Game Boy Camera cart. PCB's and build instructions may be found here. Additionnaly, a generic flashable cartridge is necessary to remote control the camera via serial cable.

This project is a homebrew enhancing the capabilities of the Game Boy Camera by allowing access to all the possible parameters of the sensor and improving the printing speed and the camera ergonomics in general. This project is compatible with all known models of Game Boy printer and Game Boy printer emulator. The project features Game Boy And Game Boy Color versions.

The save format used here is retro-compatible with any version of the Game Boy Camera rom. This means that you can switch between roms while keeping the same save without loosing your precious images and data.

Photo! with its serial remote controller

Showcase

User Manual

After booting, the user has access to Camera Mode, for taking pictures, to Image Gallery to view and print pictures and to Settings for tuning general parameters. To use the remote controller feature, just plug a serial cable connected to a Game Boy playing the photo-remote.gb or .gbc rom.

Camera Mode

Mode menu

  • The Auto Mode is a mode that mimics the behavior of the stock Game Boy Camera, it modifies automatically the Exposure time, and sets the Gain, Sensor Voltage Out and Edge enhancement mode according to rules assessed by datalogging the MAC-GBD/sensor protocol. All other camera registers used are fixed.
  • The Assisted Mode uses the same strategy than Auto Mode with a manual setting of the exposure time.
  • The Manual Mode allows modifying all the parameters of the camera sensor that can be sent to the MAC-GBD.

Trigger menu

  • A Button is the most simple action: press A once to get an Action.
  • Timer launch a remote timer between 1 and 99 seconds and trigger an Action.
  • Repeat allows triggering an Action repetitively, it is cumulative with Timer.

Timer and Repeat can be cancelled by pressing B button.

Action menu

  • Save just saves image in one of the 30 memory slots of the Camera save ram. If memory is full, it will play an error sound.
  • Print sends the image with the chosen border directly to the printer without saving.
  • Save & Print cumulates the two features but continues to print if the memory slots are all occupied.
  • Transfer allows fast transmission of one image to the pico-gb-printer.

The Transfer protocol is very similar to standard printing. Only two packets are used, and the Game Boy does not expect receiving anything in response, we just send the raw image data as quick as possible. First, the Game Boy sends the standard printer INIT packet, and then sends the new 0x10 packet that is the same as DATA, but the data length is always 3584 bytes (16x14 tiles) and CRC bytes are always 0. On CGB the transfer rate is 32KB/s, on the DMG the transfer rate is 1KB/s.

Restore Default menu

  • Allows to come back to factory settings, in particular if situation is becoming messy in Manual Mode.

Image Gallery

  • Info displays a thumbnail and the camera registers used. It allows printing these informations too.
  • Print prints the current displayed image with the chosen border at a clock frequency of 8 kHz (1kB/s) or 256 kHz (32 kB/s) in Fast Printing mode (GBC only).
  • Print All prints all the images in memory with the chosen border at a clock frequency of 8 kHz (1kB/s) or 256 kHz (32 kB/s) in Fast Printing mode (GBC only).
  • Transfer prints the current displayed image without border at a clock frequency of 256 kHz (32kB/s) by default. This mode is supported by the pico-gb-printer. Compatible with Game Boy Color only !
  • Transfer All prints all the images in memory without border and with a clock frequency of 256 kHz (32kB/s). This mode is supported by the pico-gb-printer. Compatible with Game Boy Color only !
  • Delete declares the memory slot of the displayed image as free (without erasing data).
  • Delete All declares all the memory slots as free (without erasing data).
  • Undelete All declares all the memory slots as containing an image (whatever the slots content).

Settings

  • Frame allows selecting no frame, normal frame or wild frames.
  • Fast Printing allows switching all print mode from 8 kHz (1 kB/s) to 256 kHz (32 kB/s) by default. Compatible witn Game Boy Color only !. This mode is currently supported by the pico-gb-printer and the BitBoy.
  • Alt. SGB borders allows switching between two Super Game Boy borders.

About

Just the hall of fames.

Some technical considerations

The Mitsubishi M64282FP artificial retina is one of the first mass produced CMOS light sensor. This kind of sensor is known for its good behavior in low light conditions and low power consumption. Basically each pixel of the sensor converts the quantity of photons received during an exposure time into a voltage. The sensor is able to perform some basic arithmetics on the voltage values before transfering them to an analog output (inversion, offsetting, 2D operations, multiplication, etc.). This sensor contains 128x128 pixels but only 123 lines returns image information as the first 5 lines are just composed of masked pixels uses to measure the voltage response of sensor in full darkness. The sensor documentation is notorious for being crappy and some informations are deduced from the much better documentation of the Mitsubishi M64283FP sensor which is an upgrade.

Effect of the main adressable parameters

The M64282FP working parameters are set by 8 bytes (plus their 3-bits addresses) containing various registers. The MAC-GBD itself, mapper of the Game Boy Camera, can only receive 5 bytes of data to tune the sensor so 3 equivalent-bytes of data are not modifiable on the Game Boy Camera (more precisely P, M and X, 3x8 bits, registers also called Filtering Kernels are never modified). The mapping between sensor registers and MAC-GBD registers is given as comment in the project code. Here is a detailed description of the registers that can be modified:

  • The Exposure Time (registers C, 16 bits) is the time that each pixel of the sensor will receive photons and convert the integral photon quantity to voltage. The longer the exposure time, the higher the output voltage, the higher the signal to noise ratio, but the higher the motion blur. Sensor can saturate for too long exposure time/too high flux of photons. This sensor allows exposure time from 16 µseconds to 1.044 seconds. Exposure times below 256 µseconds lead to strong vertical artifacts. Using varying exposure time creates vertical (low exposure times) and horizontal (high exposure times) artifacts which are intrinsic to the sensor. The total voltage range between dark and saturated sensor is about 2 volts.
  • The Sensor Gain (register G, 5 bits) is a multiplier applied between the quantity of photons received and the output voltage. To make an analogy with film camera, gain is similar to the ISOs of the film. However calculating the real corresponding ISOs for each gain value is out of reach with the current documentation of the sensor. Like film cameras, high gains (ISOs) and low exposure times gives noisy images, low gains (ISOs) and high exposure times gives smooth images. The gain used in the Game Boy camera rom varies very little compared to what the sensor is able to in Manual Mode.
  • The Sensor Voltage Out (register O, 6 bits) is a fine bias applied to the output pin. It allows increasing the sensor dynamic. Basically this voltage should exactly compensate the voltage reading of dark pixels so that the sensor output is 0 volts in total darkness. Game Boy Camera just uses it as a supplementary degree of freedom.
  • The Sensor Voltage Reference (register V, 3 bits) is a crude voltage bias applied to the output. It is not modified by the Game Boy Camera (and set by default to 1.5 volts). It typically allows to have a match between the min/max output voltage and the min/max input voltage allowed by the external ADC converter used with the sensor. The M64282FP is able to automatically set the the voltage reading of dark pixels at the Sensor Voltage Reference via the Sensor Zero Point register Z.
  • The Inverse Output (register I, 1 bit) performs an hardware negative image.
  • The Edge enhancement is performed by playing on the Sensor Edge Operation (register VH, 2 bits), the Sensor Edge Ratio (register E, 4 bits) and the Sensor Edge Exclusive (register N, 1 bit). It drastically improves the sharpness of the sensor image which is natively very soft without this feature.

Surprisingly, the Contrast is not modified by the sensor itself but is set by the MAC-GBD by sending dithering matrices derived from Bayer matrices.

Remote control packet format

The packet format is very simple and consist of one byte.

0bS0IPXXXX  
    S - stop, I - identifier, P - parity, XXXX - 4 Button or D-Pad bits
    Stop bit is always 1.
    Identifier is 1 for upper (buttons) and 0 for lower (D-Pad)
    Parity bit is 1 when the count of 1's in XXXX bits is odd, 0 when even.

Sender is a master device for the game boy.

Fast compiling guide for Windows users

Basic requirement: 20 minutes without any disturbance.

Download GBDK-2020 from here under the GBDK Build and Package link and unzip it into the desired directory.

Download Cygwin built for Windows from here. Install it with the additional make package from Devel category.

Download and install Python 3 built for Windows from here.

Download and install Git built for Windows from here.

Download a Python script from here, then run from Cygwin in the directory where get-pip.py is placed:

python get-pip.py
python -m pip install --upgrade pip

Then install Pillow and wave libraries:

python -m pip install --upgrade Pillow
python -m pip install --upgrade wave

Now from the Cygwin terminal, clone this git repository to its desired destination (default is /home/USER), but may be any:

git clone https://github.com/untoxa/gb-photo

Create a GBDK_HOME environment variable which targets your GBDK-2020 folder in the Windows system settings, close and reopen Cygwin.

Run make from the Cygwin terminal in the project folder containing the Makefile:

make

Your roms will be in ./build folders, enjoy !

Resources

Author contribution

gb-photo's People

Contributors

bbbbbr avatar hatchman avatar herrzatacke avatar neorame avatar raphael-boichot avatar untoxa 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.