aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/visualboyadvance.rb
blob: 94bdf42c2b52f2bfb83ba9b37257597938c4a8ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
require 'formula'

class Visualboyadvance < Formula
  url "http://downloads.sourceforge.net/project/vba/VisualBoyAdvance/1.7.2/VisualBoyAdvance-src-1.7.2.tar.gz"
  homepage 'http://vba.ngemu.com/' # This homepage is sketchy
  md5 'cc02339e3fd8efd9f23121b0a2f81fd8'

  depends_on 'pkg-config' => :build
  depends_on 'sdl'

  fails_with_llvm "Video scalers don't link with LLVM."

  def patches; DATA; end

  def install
    ENV.x11 # for libpng

    system "./configure", "--disable-dependency-tracking", "--disable-debug",
                          "--prefix=#{prefix}",
                          # Use straight C, and don't get fancy
                          "--enable-c-core",
                          "--without-mmx",
                          # Use SDL and don't bother testing for it
                          "--enable-sdl",
                          "--disable-sdltest"
    system "make"
    system "make install"
  end
end

__END__
diff --git a/src/System.h b/src/System.h
index 2cc6d49..74d12cc 100644
--- a/src/System.h
+++ b/src/System.h
@@ -46,6 +46,12 @@ typedef signed __int64 s64;
 typedef signed long long s64;
 #endif
 
+#ifdef __APPLE__
+typedef u64 memptr;
+#else
+typedef u32 memptr;
+#endif
+
 struct EmulatedSystem {
   // main emulation function
   void (*emuMain)(int);
diff --git a/src/prof/prof.cpp b/src/prof/prof.cpp
index 3ef7894..bd3c982 100644
--- a/src/prof/prof.cpp
+++ b/src/prof/prof.cpp
@@ -80,6 +80,18 @@ static char hist_dimension_abbrev = 's';
 /* see profil(2) where this is describe (incorrectly) */
 #define  SCALE_1_TO_1 0x10000L
 
+void profPut64(char *b, u64 v)
+{
+  b[0] = v & 255;
+  b[1] = (v >> 8) & 255;
+  b[2] = (v >> 16) & 255;
+  b[3] = (v >> 24) & 255;
+  b[4] = (v >> 32) & 255;
+  b[5] = (v >> 40) & 255;
+  b[6] = (v >> 48) & 255;
+  b[7] = (v >> 56) & 255;
+}
+
 void profPut32(char *b, u32 v)
 {
   b[0] = v & 255;
@@ -111,6 +123,21 @@ int profWrite32(FILE *f, u32 v)
   return 0;
 }
 
+#ifdef __APPLE__
+int profWrite64(FILE *f, u64 v)
+{
+  char buf[8];
+
+  profPut64(buf, v);
+  if(fwrite(buf, 1, 8, f) != 8)
+    return 1;
+  return 0;
+}
+#define profWriteMemptr profWrite64
+#else
+#define profWriteMemptr profWrite32
+#endif
+
 int profWrite(FILE *f, char *buf, unsigned int n)
 {
   if(fwrite(buf, 1, n, f) != n)
@@ -266,7 +293,7 @@ void profCleanup()
     for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) {
       if(profWrite8(fd, GMON_TAG_CG_ARC) ||
          profWrite32(fd, (u32)frompc) ||
-         profWrite32(fd, (u32)tos[toindex].selfpc) ||
+         profWriteMemptr(fd, (memptr)tos[toindex].selfpc) ||
          profWrite32(fd, tos[toindex].count)) {
         systemMessage(0, "mcount: arc");
         fclose(fd);
diff --git a/src/sdl/debugger.cpp b/src/sdl/debugger.cpp
index 1657a9e..4d89d99 100644
--- a/src/sdl/debugger.cpp
+++ b/src/sdl/debugger.cpp
@@ -946,13 +946,13 @@ void debuggerBreakArm(int n, char **args)
     debuggerUsage("ba");
 }
 
-void debuggerBreakOnWrite(u32 *mem, u32 oldvalue, u32 value, int size)
+void debuggerBreakOnWrite(memptr *mem, u32 oldvalue, u32 value, int size)
 {
-  u32 address = 0;
-  if(mem >= (u32*)&workRAM[0] && mem <= (u32*)&workRAM[0x3ffff])
-    address = 0x2000000 + ((u32)mem - (u32)&workRAM[0]);
+  memptr address = 0;
+  if(mem >= (memptr*)&workRAM[0] && mem <= (memptr*)&workRAM[0x3ffff])
+    address = 0x2000000 + ((memptr)mem - (memptr)&workRAM[0]);
   else
-    address = 0x3000000 + ((u32)mem - (u32)&internalRAM[0]);
+    address = 0x3000000 + ((memptr)mem - (memptr)&internalRAM[0]);
 
   if(size == 2)
     printf("Breakpoint (on write) address %08x old:%08x new:%08x\n",