Skip to content

Commit

Permalink
#1 dispaly man and life in game
Browse files Browse the repository at this point in the history
  • Loading branch information
akatsuki105 committed May 12, 2020
1 parent b22bf7f commit 9f8e9b4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pkg/emulator/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (cpu *CPU) Render(screen *ebiten.Image) error {
}

// 背景描画 + CPU稼働
LCDC1 := [144]bool{}
for y := 0; y < iterY; y++ {

scrollX, scrollY = cpu.GPU.ReadScroll()
Expand Down Expand Up @@ -84,6 +85,10 @@ func (cpu *CPU) Render(screen *ebiten.Image) error {
}

LCDC = cpu.FetchMemory8(LCDCIO)
if y < height {
LCDC1[y] = ((LCDC >> 1) % 2) == 1
}

WY := uint(cpu.FetchMemory8(WYIO))
WX := uint(cpu.FetchMemory8(WXIO)) - 7

Expand Down Expand Up @@ -126,12 +131,14 @@ func (cpu *CPU) Render(screen *ebiten.Image) error {
// スプライト描画
for i := 0; i < 40; i++ {
Y := int(cpu.FetchMemory8(0xfe00 + 4*uint16(i)))
if LCDC>>1%2 == 1 && Y != 0 && Y < 160 {
if Y != 0 && Y < 160 {
Y -= 16
X := int(cpu.FetchMemory8(0xfe00+4*uint16(i)+1)) - 8
tileIndex := uint(cpu.FetchMemory8(0xfe00 + 4*uint16(i) + 2))
attr := cpu.FetchMemory8(0xfe00 + 4*uint16(i) + 3)
cpu.GPU.SetSPRTile(int(X), Y, tileIndex, attr, cpu.Cartridge.IsCGB)
if LCDC1[Y] {
X := int(cpu.FetchMemory8(0xfe00+4*uint16(i)+1)) - 8
tileIndex := uint(cpu.FetchMemory8(0xfe00 + 4*uint16(i) + 2))
attr := cpu.FetchMemory8(0xfe00 + 4*uint16(i) + 3)
cpu.GPU.SetSPRTile(int(X), Y, tileIndex, attr, cpu.Cartridge.IsCGB)
}
}
}

Expand Down

0 comments on commit 9f8e9b4

Please sign in to comment.