Slide 1

Slide 1 text

@giginet

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

ྩ࿨࣌୅ͷ ήʔϜϘʔΠ։ൃ

Slide 4

Slide 4 text

Game boy • 1989೥ൃച • Z80ϕʔεͷCPUʢශऑʣ Z80(CPU) https://ja.wikipedia.org/wiki/Z80

Slide 5

Slide 5 text

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:

Slide 6

Slide 6 text

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:

Slide 7

Slide 7 text

GBDK • GBDK(Game boy Development Kit) • http://gbdk.sourceforge.net/ • ήʔϜϘʔΠͷήʔϜΛCݴޠͰྑ͍ײ͡ʹ࡞Ε Δ΍ͭ • macOSͰಈ͘Α͏ʹforkͨ͠΍ͭ giginet/GBDK

Slide 8

Slide 8 text

#include #include 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; } ඳը ϝΠϯϧʔϓ ը૾σʔλ

Slide 9

Slide 9 text

GBDK $ lcc -o rom game.gb

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

0x00 0x01 0x10 0x11

Slide 15

Slide 15 text

0x00 0x01 0x10 0x11 8px 8px

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

8px 8px

Slide 18

Slide 18 text

unsigned char giginyan[] = {255, 255, 254, 254, 252, 253, 252, 253, 254, 253, 254, 253, 254, 253, 255, 254...

Slide 19

Slide 19 text

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::>(); }) .collect::>>(); 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

Slide 20

Slide 20 text

giginet/gb-sprite-generator $ cargo run ./assets >1 pixels.h

Slide 21

Slide 21 text

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};

Slide 22

Slide 22 text

SPRITES_8x8; // ϐΫηϧσʔλΛఆٛ set_sprite_data(0, 8, giginyan); set_sprite_tile(0, 0); // ը૾Λඳը move_sprite(0, 100, 100); SHOW_SPRITES;

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

mikeryan/ems-flasher $ ems-flasher --write rom.gb

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

❌ ❌

Slide 33

Slide 33 text

giginet/modern-gb

Slide 34

Slide 34 text

͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠