c62d2810 |
1 | /* FCE Ultra - NES/Famicom Emulator |
2 | * |
3 | * Copyright notice for this file: |
4 | * Copyright (C) 2002 Ben Parnell |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
20 | |
21 | #include <stdlib.h> |
22 | |
23 | #include "types.h" |
24 | #include "version.h" |
25 | #include "memory.h" |
26 | #include "general.h" |
27 | #include "svga.h" |
28 | |
29 | void *FCEU_malloc(uint32 size) |
30 | { |
31 | void *ret; |
32 | ret=malloc(size); |
33 | if(!ret) |
34 | FCEU_PrintError(MSG_ERRAM); |
35 | return ret; |
36 | } |
37 | |
38 | void FCEU_free(void *ptr) // Might do something with this and FCEU_malloc later... |
39 | { |
40 | free(ptr); |
41 | } |
42 | |
5232c20c |
43 | |
44 | |
c62d2810 |
45 | void FASTAPASS(3) FCEU_memmove(void *d, void *s, uint32 l) |
46 | { |
47 | uint32 x; |
48 | int t; |
49 | |
50 | /* Type really doesn't matter. */ |
51 | t=(int)d; |
52 | t|=(int)s; |
53 | t|=(int)l; |
54 | |
55 | if(t&3) // Not 4-byte aligned and/or length is not a multiple of 4. |
5232c20c |
56 | { |
57 | uint8 *tmpd, *tmps; |
58 | |
59 | tmpd = d; |
60 | tmps = s; |
61 | |
c62d2810 |
62 | for(x=l;x;x--) // This could be optimized further, though(more tests could be performed). |
63 | { |
5232c20c |
64 | *tmpd=*tmps; |
65 | tmpd++; |
66 | tmps++; |
67 | } |
c62d2810 |
68 | } |
69 | else |
5232c20c |
70 | { |
71 | uint32 *tmpd, *tmps; |
72 | |
73 | tmpd = d; |
74 | tmps = s; |
75 | |
c62d2810 |
76 | for(x=l>>2;x;x--) |
77 | { |
5232c20c |
78 | *tmpd=*tmps; |
79 | tmpd++; |
80 | tmps++; |
c62d2810 |
81 | } |
82 | } |
5232c20c |
83 | } |
84 | |