Upgrade to Pro — share decks privately, control downloads, hide ads and more …

👾 令和時代のゲームボーイ開発

giginet
September 07, 2019

👾 令和時代のゲームボーイ開発

giginet

September 07, 2019
Tweet

More Decks by giginet

Other Decks in Programming

Transcript

  1. update_game:: ld HL, READ_INPUT ld A, [HL] cp $00 jr

    nz, .continue_update_1 call read_joypad .continue_update_1: call pipes_update call player_update call player_set_position call pipes_set_position ld HL, FADE_IN_ACTIVE ld A, [HL] cp $00 jr z, .call_fade_in cp $02 jr z, .call_fade_out jr .call_parallax .call_fade_in: call fade_in jr .call_parallax .call_fade_out:
  2. update_game:: ld HL, READ_INPUT ld A, [HL] cp $00 jr

    nz, .continue_update_1 call read_joypad .continue_update_1: call pipes_update call player_update call player_set_position call pipes_set_position ld HL, FADE_IN_ACTIVE ld A, [HL] cp $00 jr z, .call_fade_in cp $02 jr z, .call_fade_out jr .call_parallax .call_fade_in: call fade_in jr .call_parallax .call_fade_out:
  3. #include <gb/gb.h> #include <stdio.h> unsigned char pixels[] = {255, 255,

    195, 189, 189, 195, 189, 195, 189, 195, 189, 195, 195, 189, 255, 255}; int main() { int x = 100, y = 100; SPRITES_8x8; set_sprite_data(0, 8, pixels); set_sprite_tile(0, 0); move_sprite(0, x, y); SHOW_SPRITES; while(1) { if(joypad() & J_RIGHT) move_sprite(0, ++x, y); if(joypad() & J_LEFT) move_sprite(0, --x, y); if(joypad() & J_UP) move_sprite(0, x, --y); if(joypad() & J_DOWN) move_sprite(0, x, ++y); delay(10); } return 0; } ඳը ϝΠϯϧʔϓ ը૾σʔλ
  4. giginet/docker-gbdk $ docker pull giginet/gbdk $ docker run -it --rm

    -v `pwd`:/gbdk giginet/gbdk /opt/gbdk/bin/lcc -o / gbdk/rom.gb /gbdk/game.c $ open rom.gb
  5. 0x00 0x01 0x10 0x11 00 11 11 01 11 01

    11 01 0b01111111 0x7f 0x6a 0b01101010 0 1 1 1 1 1 1 1 0 1 1 0 1 0 1 0
  6. unsigned char giginyan[] = {255, 255, 254, 254, 252, 253,

    252, 253, 254, 253, 254, 253, 254, 253, 255, 254...
  7. use image::RgbaImage; use std::vec; use crate::sprite::{Sprite, Pixel}; use crate::chopper::Chopper; fn

    load_sprite(image: &RgbaImage) -> Sprite { let width = image.width(); let height = image.height(); let pixels = (0..width).map( |x| { return (0..height).map( |y| { let raw_pixel = image.get_pixel(x, y); return Pixel::from_raw(raw_pixel.data); }) .collect::<Vec<Pixel>>(); }) .collect::<Vec<Vec<Pixel>>>(); return Sprite { pixels: pixels }; } fn squash(chunk: &Vec<&Pixel>) -> [u8; 2] { fn clamp(i: u8) -> u8 { if i > 0 { return 1; } return 0; giginet/gb-sprite-generator
  8. giginet/gb-sprite-generator unsigned char player[] = {255, 255, 254, 254, 252,

    253, 252, 253, 254, 253, 254, 253, 254, 253, 255, 254... unsigned char bullet[] = {255, 255, 195, 189, 189, 195, 189, 195, 189, 195, 189, 195, 195, 189, 255, 255};