split memories away from Pico
[picodrive.git] / pico / cd / gfx_dma.c
1 /*
2  * PicoDrive
3  * (C) notaz, 2007
4  *
5  * This work is licensed under the terms of MAME license.
6  * See COPYING file in the top-level directory.
7  */
8
9 #include "../pico_int.h"
10
11 #include "cell_map.c"
12
13 #ifndef UTYPES_DEFINED
14 typedef unsigned short u16;
15 #endif
16
17 // check: Heart of the alien, jaguar xj 220
18 PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, unsigned char inc)
19 {
20   unsigned char *base;
21   unsigned int asrc, a2;
22   u16 *r;
23
24   base = Pico_mcd->word_ram1M[Pico_mcd->s68k_regs[3]&1];
25
26   switch (Pico.video.type)
27   {
28     case 1: // vram
29       r = PicoMem.vram;
30       for(; len; len--)
31       {
32         asrc = cell_map(source >> 2) << 2;
33         asrc |= source & 2;
34         // if(a&1) d=(d<<8)|(d>>8); // ??
35         r[a>>1] = *(u16 *)(base + asrc);
36         source += 2;
37         // AutoIncrement
38         a=(u16)(a+inc);
39       }
40       Pico.est.rendstatus |= PDRAW_SPRITES_MOVED;
41       break;
42
43     case 3: // cram
44       Pico.m.dirtyPal = 1;
45       r = PicoMem.cram;
46       for(a2=a&0x7f; len; len--)
47       {
48         asrc = cell_map(source >> 2) << 2;
49         asrc |= source & 2;
50         r[a2>>1] = *(u16 *)(base + asrc);
51         source += 2;
52         // AutoIncrement
53         a2+=inc;
54         // good dest?
55         if(a2 >= 0x80) break;
56       }
57       a=(a&0xff00)|a2;
58       break;
59
60     case 5: // vsram[a&0x003f]=d;
61       r = PicoMem.vsram;
62       for(a2=a&0x7f; len; len--)
63       {
64         asrc = cell_map(source >> 2) << 2;
65         asrc |= source & 2;
66         r[a2>>1] = *(u16 *)(base + asrc);
67         source += 2;
68         // AutoIncrement
69         a2+=inc;
70         // good dest?
71         if(a2 >= 0x80) break;
72       }
73       a=(a&0xff00)|a2;
74       break;
75   }
76   // remember addr
77   Pico.video.addr=(u16)a;
78 }
79