per-line scrolling test
[mdlife] / src / dma.S
1         .text
2
3 #include "hwregs.h"
4 #include "vdp.inc"
5
6
7         | dma_systovram(vmem_addr, src, count)
8         .globl dma_systovram
9 dma_systovram:
10         vdp_setreg VDP_REG_MODE2, VDP_M2_INIT + VDP_M2_DISP + VDP_M2_DMA
11
12         | set source address
13         move.l 8(%sp), %d0
14         lsr.l #1, %d0
15         move.l %d0, %d1
16         vdp_setreg_reg VDP_REG_DMASRCL, %d0
17         lsr.w #8, %d1
18         vdp_setreg_reg VDP_REG_DMASRCM, %d1
19         swap %d0
20         vdp_setreg_reg VDP_REG_DMASRCH, %d0
21         | set count (in words)
22         move.w 14(%sp), %d0
23         move.w %d0, %d1
24         vdp_setreg_reg VDP_REG_DMACNTL, %d0
25         lsr.w #8, %d1
26         vdp_setreg_reg VDP_REG_DMACNTH, %d1
27         | set the destination address.
28         move.w 6(%sp), %d0
29         move.w %d0, %d1
30         and.w #0x3fff, %d0
31         or.w #(VDP_VRAM_DMA >> 16), %d0
32         move.w %d0, VDP_CTL_PORT
33         | 2 upper bits and rest of the type flags
34         rol.w #2, %d1
35         and.w #3, %d1
36         or.w #(VDP_VRAM_DMA & 0xf0), %d1
37         | last word needs to come from RAM, so we push it on the stack
38         move.w %d1, -(%sp)
39         move.w (%sp)+, VDP_CTL_PORT
40
41         | after DMA ends the cpu can continue, turn DMA off
42         vdp_setreg VDP_REG_MODE2, VDP_M2_INIT + VDP_M2_DISP
43         rts
44
45 | vi:ft=gas68k: