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