diff --git a/src/crab/dma.cr b/src/crab/dma.cr index ecc4eb0..e5ef70f 100644 --- a/src/crab/dma.cr +++ b/src/crab/dma.cr @@ -91,7 +91,6 @@ class DMA end end - # todo: vdma def trigger_hdma : Nil 4.times do |channel| dmacnt_h = @dmacnt_h[channel] @@ -99,6 +98,13 @@ class DMA end end + def trigger_vdma : Nil + 4.times do |channel| + dmacnt_h = @dmacnt_h[channel] + trigger channel if dmacnt_h.enable && dmacnt_h.start_timing == StartTiming::VBlank.value + end + end + # todo: maybe abstract these various triggers def trigger_fifo(fifo_channel : Int) : Nil dmacnt_h = @dmacnt_h[fifo_channel + 1] diff --git a/src/crab/ppu.cr b/src/crab/ppu.cr index 2c1e6e5..bc0b9dc 100644 --- a/src/crab/ppu.cr +++ b/src/crab/ppu.cr @@ -64,6 +64,7 @@ class PPU @dispstat.vblank = false elsif @vcount == 160 @dispstat.vblank = true + @gba.dma.trigger_vdma @gba.interrupts.reg_if.vblank = true if @dispstat.vblank_irq_enable @bgref.each_with_index { |bgrefs, bg_num| bgrefs.each_with_index { |bgref, ref_num| @bgref_int[bg_num][ref_num] = bgref.num } } draw