Commit | Line | Data |
---|---|---|
ef79bbde P |
1 | /***************************************************************************\r |
2 | dma.c - description\r | |
3 | -------------------\r | |
4 | begin : Wed May 15 2002\r | |
5 | copyright : (C) 2002 by Pete Bernert\r | |
6 | email : BlackDove@addcom.de\r | |
7 | ***************************************************************************/\r | |
8 | /***************************************************************************\r | |
9 | * *\r | |
10 | * This program is free software; you can redistribute it and/or modify *\r | |
11 | * it under the terms of the GNU General Public License as published by *\r | |
12 | * the Free Software Foundation; either version 2 of the License, or *\r | |
13 | * (at your option) any later version. See also the license.txt file for *\r | |
14 | * additional informations. *\r | |
15 | * *\r | |
16 | ***************************************************************************/\r | |
17 | \r | |
18 | #include "stdafx.h"\r | |
19 | \r | |
20 | #define _IN_DMA\r | |
21 | \r | |
22 | #include "externals.h"\r | |
23 | \r | |
24 | ////////////////////////////////////////////////////////////////////////\r | |
25 | // READ DMA (one value)\r | |
26 | ////////////////////////////////////////////////////////////////////////\r | |
27 | \r | |
28 | unsigned short CALLBACK SPUreadDMA(void)\r | |
29 | {\r | |
5514a050 | 30 | unsigned short s = *(unsigned short *)(spu.spuMemC + spu.spuAddr);\r |
31 | spu.spuAddr += 2;\r | |
32 | spu.spuAddr &= 0x7fffe;\r | |
ef79bbde | 33 | \r |
ef79bbde P |
34 | return s;\r |
35 | }\r | |
36 | \r | |
37 | ////////////////////////////////////////////////////////////////////////\r | |
38 | // READ DMA (many values)\r | |
39 | ////////////////////////////////////////////////////////////////////////\r | |
40 | \r | |
650adfd2 | 41 | void CALLBACK SPUreadDMAMem(unsigned short *pusPSXMem, int iSize,\r |
42 | unsigned int cycles)\r | |
ef79bbde P |
43 | {\r |
44 | int i;\r | |
45 | \r | |
63a4f6b6 | 46 | do_samples_if_needed(cycles, 1);\r |
650adfd2 | 47 | \r |
ef79bbde P |
48 | for(i=0;i<iSize;i++)\r |
49 | {\r | |
5514a050 | 50 | *pusPSXMem++ = *(unsigned short *)(spu.spuMemC + spu.spuAddr);\r |
51 | spu.spuAddr += 2;\r | |
52 | spu.spuAddr &= 0x7fffe;\r | |
ef79bbde | 53 | }\r |
ef79bbde P |
54 | }\r |
55 | \r | |
56 | ////////////////////////////////////////////////////////////////////////\r | |
57 | ////////////////////////////////////////////////////////////////////////\r | |
58 | ////////////////////////////////////////////////////////////////////////\r | |
59 | \r | |
60 | // to investigate: do sound data updates by writedma affect spu\r | |
61 | // irqs? Will an irq be triggered, if new data is written to\r | |
62 | // the memory irq address?\r | |
63 | \r | |
64 | ////////////////////////////////////////////////////////////////////////\r | |
65 | // WRITE DMA (one value)\r | |
66 | ////////////////////////////////////////////////////////////////////////\r | |
67 | \r | |
68 | void CALLBACK SPUwriteDMA(unsigned short val)\r | |
69 | {\r | |
5514a050 | 70 | *(unsigned short *)(spu.spuMemC + spu.spuAddr) = val;\r |
ef79bbde | 71 | \r |
5514a050 | 72 | spu.spuAddr += 2;\r |
73 | spu.spuAddr &= 0x7fffe;\r | |
0c1151fe | 74 | spu.bMemDirty = 1;\r |
ef79bbde P |
75 | }\r |
76 | \r | |
77 | ////////////////////////////////////////////////////////////////////////\r | |
78 | // WRITE DMA (many values)\r | |
79 | ////////////////////////////////////////////////////////////////////////\r | |
80 | \r | |
650adfd2 | 81 | void CALLBACK SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize,\r |
82 | unsigned int cycles)\r | |
ef79bbde P |
83 | {\r |
84 | int i;\r | |
fb552464 | 85 | \r |
63a4f6b6 | 86 | do_samples_if_needed(cycles, 1);\r |
0c1151fe | 87 | spu.bMemDirty = 1;\r |
fb552464 | 88 | \r |
3154bfab | 89 | if(spu.spuAddr + iSize*2 < 0x80000)\r |
fb552464 | 90 | {\r |
5514a050 | 91 | memcpy(spu.spuMemC + spu.spuAddr, pusPSXMem, iSize*2);\r |
3154bfab | 92 | spu.spuAddr += iSize*2;\r |
fb552464 | 93 | return;\r |
94 | }\r | |
ef79bbde P |
95 | \r |
96 | for(i=0;i<iSize;i++)\r | |
97 | {\r | |
5514a050 | 98 | *(unsigned short *)(spu.spuMemC + spu.spuAddr) = *pusPSXMem++;\r |
99 | spu.spuAddr += 2;\r | |
100 | spu.spuAddr &= 0x7fffe;\r | |
ef79bbde | 101 | }\r |
ef79bbde P |
102 | }\r |
103 | \r | |
104 | ////////////////////////////////////////////////////////////////////////\r |