0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ゲームボーイ画面描画

0
Posted at

目的

8080の機械語を学ぶ為にゲームボーイ(全く同じではないですが)で色々な処理を書いて実験します。

アセンブリでGameBoyのコードを書く環境を導入

ゲームボーイの仕様

8×8のタイル(16バイト)を用意して、タイル番号を指定して描画します。

タイルの中身を置くVRAM : $8000
タイル番号を置くVRAM : $9800

コード

タイル1に縞を登録し、画面左上に描画します。
任天堂の商標以外の場所全体にタイル番号0が指定されているようで、タイル0の中身を変更すると全体に描画された為、タイル1を使いました。
タイル1はNindendNの左側が登録されているようで、左上だけでなくNの左上も縞になりました。

截图 2026-09-04 20-11-57
rgbasm -o hello.o hello.asm && \
rgblink -o hello.gb hello.o && \
rgbfix -v -p 0xFF hello.gb && \
../SameBoy-master/build/bin/SDL/sameboy hello.gb
main.asm
SECTION "Entry", ROM0[$0100]
    jp start

SECTION "Main", ROM0[$0150]

start:
    di
    ld sp, $FFFE
    
    ; 画面描画停止
    xor a, 0
    ldh[$FF40], a
    
    ; 真っ黒のタイルを1つ作る
    ;ld hl, $8000 ; タイルVRAM
    ld hl, $8000 + 1 * 16 ; 2つめの領域にタイルを作る
    ld b, 16 ; (8*8 1pixel=2bit)
.fill
    ld [hl],$AA
    inc hl
    dec b
    jr nz, .fill
    
    ld hl, $9800 ; タイルを置くVRAM
    ld [hl],1    ; タイル1
    
    ; パレット
    ld a, %11100100 ; 4色(11 10 01 00)を設定
    ld [$FF47], a
    
    ; 画面描画再開: BG有効
    ld a, %10010001
    ldh [$FF40], a


hang:
    jr hang

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?