Binary files mcd_win/.DS_Store and mcd/.DS_Store differ diff -urNp mcd_win/Rakefile mcd/Rakefile --- mcd_win/Rakefile 1969-12-31 17:00:00.000000000 -0700 +++ mcd/Rakefile 2007-04-27 08:06:02.000000000 -0600 @@ -0,0 +1,116 @@ +# Build MCD for OS X +# Brian Palmer d@brian.codekitchen.net +# All modifications for OS X released under the same license as MCD + +task :default => [:run] + +PROGNAME = 'mcd' +APP = "#{PROGNAME}.app/Contents" + +RSRCS = "barrage sounds images resource #{PROGNAME}.icns" +DFLAGS = "-O -frelease -Iimport -Isrc -arch i386 -arch ppc" +FDIRS = ["#{ENV['HOME']}/Library/Frameworks", "/Library/Frameworks"] +SYSFRAMEWOKS = %w(Cocoa OpenGL GLUT) +FRAMEWORKS = %w(SDL SDL_Mixer SDL_image) +FLIBS = (FRAMEWORKS + SYSFRAMEWOKS).map { |f| "-framework #{f}" }.join(" ") + +FPATHS = FRAMEWORKS.map do |f| + nm = f + ".framework" + FDIRS.find { |d| File.exist?(d + "/" + nm) } + "/" + nm +end.join(" ") + +LIBS = "#{FLIBS} -lgphobos /Users/bpalmer/Programming/OSXlibs/SDLmain.o -lstdc++-static /Users/bpalmer/Programming/OSXlibs/libbulletml_d.a /Users/bpalmer/Programming/OSXlibs/libode.a -lobjc" + +LD_386="/usr/libexec/gcc/i686-apple-darwin8/4.0.1/collect2 -dynamic -arch i386 -arch_multiple -macosx_version_min 10.3 -multiply_defined suppress -weak_reference_mismatches non-weak -lcrt1.o /usr/lib/gcc/i686-apple-darwin8/4.0.1/crt3.o -L/usr/lib/gcc/i686-apple-darwin8/4.0.1 -L/usr/lib/gcc/i686-apple-darwin8/4.0.1 -L/usr/lib/gcc/i686-apple-darwin8/4.0.1/../../.. -lgcc_s.10.4 -lgcc -lm -lSystem" +LD_PPC="/usr/libexec/gcc/powerpc-apple-darwin8/4.0.1/collect2 -dynamic -arch ppc -arch_multiple -macosx_version_min 10.3 -multiply_defined suppress -weak_reference_mismatches non-weak -lcrt1.o /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/crt2.o -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1 -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1 -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/../../.. -lgcc_s.10.4 -lgcc -lm -lSystemStubs -lSystem" + +IMPORTS = %w(SDL_mixer SDL_video ode/common).map { |f| "import/#{f}.o" } +FILENAMES = Dir["src/abagames/**/*.d"].map { |fname| fname.sub(/\.d$/, '.o') } + IMPORTS + +rule '.o' => ['.d'] do |t| + sh "gdc #{DFLAGS} -c #{t.source} -o #{t.name}" +end + +task :build => PROGNAME +file PROGNAME => FILENAMES do + # TODO: not sure why SDL_mutex fails to link + objs = FILENAMES.join(' ') + sh "#{LD_386} #{objs} #{LIBS} -o #{PROGNAME}.386" + sh "#{LD_PPC} #{objs} #{LIBS} -o #{PROGNAME}.ppc" + sh "lipo -create -arch i386 #{PROGNAME}.386 -arch ppc #{PROGNAME}.ppc -output #{PROGNAME}" + sh "strip #{PROGNAME}" +end + +task :clean do + FILENAMES.each { |fname| sh("rm #{fname}") if File.exist?(fname) } +end + +task :run => PROGNAME do + exec "./#{PROGNAME}" +end + +PLIST =<<-PL + + + + + CFBundleGetInfoString + 0.11, Kenta Cho (ported by Brian Palmer) + CFBundleIconFile + mcd.icns + CFBundleIdentifier + jp.or.asahi-net.mu-cade + CFBundleName + mcd + + +PL + +task :app => PROGNAME do + sh "rm -rf #{APP}" if File.exist?("#{APP}") + sh "mkdir -p #{APP}" + sh "mkdir -p #{APP}/Frameworks #{APP}/MacOS #{APP}/Resources" + sh "cp #{PROGNAME} #{APP}/MacOS" + sh "cp -R #{FPATHS} #{APP}/Frameworks" + sh "cp -R #{RSRCS} #{APP}/Resources" + File.open("#{APP}/Info.plist", "wb") { |f| f.write PLIST } + sh "echo 'MuCade' #{APP}/PkgInfo" +end + +task :dmg => :app do + sh "hdiutil create -srcfolder mcd.app -ov -format UDBZ mcd.dmg" + sh "hdiutil internet-enable mcd.dmg" +end + +__END__ + +BASIC INSTRUCTIONS: + +Building MCD for OS X is a bit of a hassle, I'm afraid. + +- download and install SDL frameworks (SDL, SDL_image, SDL_mixer) + +- compil SDLmain.o from SDL 1.2 sources using: + +gcc SDLmain.m -arch ppc -arch i386 -I/Library/Frameworks/SDL.framework/Headers -c -o SDLmain.o + +- configure/make/make install ode-0.8 using this configure command: + +CFLAGS="-arch ppc -arch i386 -isysroot \ +/Developer/SDKs/MacOSX10.4u.sdk" \ +CXXFLAGS="-arch ppc -arch i386 -isysroot \ +/Developer/SDKs/MacOSX10.4u.sdk" ./configure \ +--disable-dependency-tracking --disable-double-precision --enable-release + +**IMPORTANT** I compiled ODE for single-precision FP math. If you compile for double-precision, you need to change import/ode/common.d line 71 to match. I've tried double-precision but ODE keeps setting positions to NaN as the result of collision detection, if anybody knows why or finds a fix please let me know. + +- build libbulletml_d using source from http://shinh.skr.jp/bulletss/ +(it's in the bulletml subdirectory, modify the 2 makefiles to use -arch ppc -arch i386, some other small fixes are necessary too) + +- apply patch to mcd source, some fixes were necessary to work around GCD behavior that differs from DMD behavior on Windows. + +- you need ruby and rake installed to use this Rakefile (my Makefile-fu is weak, anybody want to contribute a Makefile to remove this dependency?) You'll need to change some directories to match where you've installed stuff, as well. + +`rake` to build the executable +`rake app` to build the .app file +`rake dmg` to build a .dmg for distribution diff -urNp mcd_win/import/SDL.d mcd/import/SDL.d --- mcd_win/import/SDL.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/import/SDL.d 2007-04-26 08:32:04.000000000 -0600 @@ -20,18 +20,20 @@ slouken@devolution.com */ -import SDL_types; -import SDL_getenv; -import SDL_error; -import SDL_rwops; -import SDL_timer; -import SDL_audio; -import SDL_cdrom; -import SDL_joystick; -import SDL_events; -import SDL_video; -import SDL_byteorder; -import SDL_Version; +public import SDL_types; +public import SDL_getenv; +public import SDL_error; +public import SDL_rwops; +public import SDL_timer; +public import SDL_audio; +public import SDL_cdrom; +public import SDL_joystick; +public import SDL_events; +public import SDL_video; +public import SDL_byteorder; +public import SDL_Version; +public import SDL_Keysym; +public import SDL_mouse; extern(C): diff -urNp mcd_win/import/SDL_mixer.d mcd/import/SDL_mixer.d --- mcd_win/import/SDL_mixer.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/import/SDL_mixer.d 2007-04-26 08:47:05.000000000 -0600 @@ -104,9 +104,6 @@ extern (C) { /* Load a wave file or a music (.mod .s3m .it .xm) file */ Mix_Chunk * Mix_LoadWAV_RW(SDL_RWops *src, int freesrc); - Mix_Chunk * Mix_LoadWAV(char *file) { - return Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1); - } Mix_Music * Mix_LoadMUS(char *file); /* Load a wave file of the mixer format from a memory buffer */ @@ -439,9 +436,6 @@ extern (C) { If 'loops' is -1, loop inifinitely (~65000 times). Returns which channel was used to play the sound. */ - int Mix_PlayChannel(int channel, Mix_Chunk* chunk, int loops) { - return Mix_PlayChannelTimed(channel,chunk,loops,-1); - } int Mix_PlayMusic(Mix_Music *music, int loops); /* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */ @@ -533,3 +527,9 @@ extern (C) { } /* end of SDL_mixer.h ... */ +Mix_Chunk * Mix_LoadWAV(char *file) { + return Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1); +} +int Mix_PlayChannel(int channel, Mix_Chunk* chunk, int loops) { + return Mix_PlayChannelTimed(channel,chunk,loops,-1); +} diff -urNp mcd_win/import/ode/common.d mcd/import/ode/common.d --- mcd_win/import/ode/common.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/import/ode/common.d 2007-04-25 20:39:52.000000000 -0600 @@ -68,7 +68,7 @@ int dAASSERT(int a) { return 0; } /* floating point data type, vector, matrix and quaternion types */ -alias double dReal; +alias float dReal; /* round an integer up to a multiple of 4, except that 0 and 1 are unmodified @@ -119,8 +119,8 @@ char* dALLOCA16(int n) struct dxWorld; /* dynamics world */ struct dxSpace; /* collision space */ struct dxBody; /* rigid body (dynamics object) */ -struct dxGeom; /* geometry (collision object) */ -struct dxJoint; +struct dxGeom { }; /* geometry (collision object) */ +struct dxJoint { }; struct dxJointNode; struct dxJointGroup; diff -urNp mcd_win/import/ode/ode.d mcd/import/ode/ode.d --- mcd_win/import/ode/ode.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/import/ode/ode.d 2007-04-25 20:28:49.000000000 -0600 @@ -23,21 +23,21 @@ module ode.ode; /* include *everything* here */ -import ode.config; -import ode.compatibility; -import ode.common; -import ode.contact; -import ode.error; -import ode.memory; -import ode.odemath; -import ode.matrix; -import ode.timer; -import ode.rotation; -import ode.mass; -import ode.misc; -import ode.objects; +public import ode.config; +public import ode.compatibility; +public import ode.common; +public import ode.contact; +public import ode.error; +public import ode.memory; +public import ode.odemath; +public import ode.matrix; +public import ode.timer; +public import ode.rotation; +public import ode.mass; +public import ode.misc; +public import ode.objects; //import ode.odecpp; -import ode.collision_space; -import ode.collision; +public import ode.collision_space; +public import ode.collision; //import ode.odecpp_collision; -import ode.export_dif; +public import ode.export_dif; diff -urNp mcd_win/import/opengl.d mcd/import/opengl.d --- mcd_win/import/opengl.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/import/opengl.d 2007-04-25 20:44:03.000000000 -0600 @@ -2,7 +2,7 @@ version (Win32) { private import std.c.windows.windows; extern(Windows): } -version (linux) { +else { extern(C): } diff -urNp mcd_win/import/openglu.d mcd/import/openglu.d --- mcd_win/import/openglu.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/import/openglu.d 2007-04-25 20:44:08.000000000 -0600 @@ -3,7 +3,7 @@ import opengl; version (Win32) { extern(Windows): } -version (linux) { +else { extern(C): } Binary files mcd_win/libode.dylib and mcd/libode.dylib differ Binary files mcd_win/mcd.exe and mcd/mcd.exe differ Binary files mcd_win/mcd.icns and mcd/mcd.icns differ Binary files mcd_win/mcd.prf and mcd/mcd.prf differ diff -urNp mcd_win/src/abagames/mcd/barrage.d mcd/src/abagames/mcd/barrage.d --- mcd_win/src/abagames/mcd/barrage.d 2006-03-18 10:42:50.000000000 -0700 +++ mcd/src/abagames/mcd/barrage.d 2007-04-26 17:17:47.000000000 -0600 @@ -63,6 +63,7 @@ public class BarrageManager { public static void load() { char[][] dirs = listdir(BARRAGE_DIR_NAME); foreach (char[] dirName; dirs) { + parser[dirName] = null; char[][] files = listdir(BARRAGE_DIR_NAME ~ "/" ~ dirName); foreach (char[] fileName; files) { if (getExt(fileName) != "xml") diff -urNp mcd_win/src/abagames/mcd/boot.d mcd/src/abagames/mcd/boot.d --- mcd_win/src/abagames/mcd/boot.d 2006-03-18 11:36:00.000000000 -0700 +++ mcd/src/abagames/mcd/boot.d 2007-04-26 21:54:29.000000000 -0600 @@ -9,6 +9,8 @@ private import std.string; private import std.stream; private import std.math; private import std.c.stdlib; +import std.path; +import std.file; private import abagames.util.logger; private import abagames.util.tokenizer; private import abagames.util.sdl.mainloop; @@ -62,12 +64,24 @@ version (Win32_release) { gc_term(); return result; } +} version(darwin) { + // Do some crazy OS X voodoo + private extern (C) int _d_run_main(int argc, char **argv, void * p); + extern (C) int SDL_main(int argc, char** argv) { + return _d_run_main(argc, argv, &main); + } + public int main(char[][] args) { + char[] contents = args[0].getDirName().getDirName(); + if (contents.getDirName().getExt() == "app") + chdir(contents ~ "/Resources"); + return boot(args); + } } else { // Boot as the general executable. public int main(char[][] args) { return boot(args); } -} +} public int boot(char[][] args) { screen = new Screen; diff -urNp mcd_win/src/abagames/mcd/enemy.d mcd/src/abagames/mcd/enemy.d --- mcd_win/src/abagames/mcd/enemy.d 2006-03-18 10:42:50.000000000 -0700 +++ mcd/src/abagames/mcd/enemy.d 2007-04-25 20:29:32.000000000 -0600 @@ -537,7 +537,7 @@ public class EnemySpec { public void recordLinePoints(EnemyState state, LinePoint lp) { glPushMatrix(); Screen.glTranslate(state.pos); - glMultMatrixd(state.rot); + glMultMatrixd(cast(double*)state.rot); glScalef(state.sizeScale.x, state.sizeScale.y, state.sizeScale.z); lp.beginRecord(); shape.recordLinePoints(lp); diff -urNp mcd_win/src/abagames/mcd/particle.d mcd/src/abagames/mcd/particle.d --- mcd_win/src/abagames/mcd/particle.d 2006-02-23 06:27:48.000000000 -0700 +++ mcd/src/abagames/mcd/particle.d 2007-04-25 20:30:38.000000000 -0600 @@ -286,7 +286,7 @@ public class ConnectedParticle: Actor { glPushMatrix(); Screen.glTranslate(_pos); if (enableRotate) - glMultMatrixd(rot); + glMultMatrixd(cast(double *)rot); linePoint.beginRecord(); linePoint.record(0, 0, 0); linePoint.record((prevParticle.pos.x - _pos.x) * 2, diff -urNp mcd_win/src/abagames/mcd/shape.d mcd/src/abagames/mcd/shape.d --- mcd_win/src/abagames/mcd/shape.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/src/abagames/mcd/shape.d 2007-04-26 08:50:12.000000000 -0600 @@ -34,7 +34,7 @@ public class ShapeGroup: Shape { } public void setMass(OdeActor oa, Vector3 sizeScale = null, float massScale = 1) { - dMass m; + dMass m = void; dMassSetZero(&m); addMass(&m, sizeScale, massScale); oa.setMass(m); @@ -87,7 +87,7 @@ public abstract class ShapeBase: Shape { } public void addMass(dMass* m, Vector3 sizeScale = null, float massScale = 1) { - dMass sm; + dMass sm = void; if (sizeScale) { dMassSetBox(&sm, 1, size.x * sizeScale.x, size.y * sizeScale.y, size.z * sizeScale.z); dMassTranslate(&sm, pos.x * sizeScale.x, pos.y * sizeScale.y, pos.z * sizeScale.z); @@ -436,7 +436,7 @@ public class LinePoint { public void beginRecord() { posIdx = 0; - glGetFloatv(GL_MODELVIEW_MATRIX, m); + glGetFloatv(GL_MODELVIEW_MATRIX, cast(float *)m); } public void setPos(Vector3 p) { diff -urNp mcd_win/src/abagames/mcd/ship.d mcd/src/abagames/mcd/ship.d --- mcd_win/src/abagames/mcd/ship.d 2006-03-18 10:42:50.000000000 -0700 +++ mcd/src/abagames/mcd/ship.d 2007-04-26 08:49:58.000000000 -0600 @@ -432,7 +432,7 @@ public class Ship: OdeActor, BulletTarge public void recordLinePoints() { glPushMatrix(); Screen.glTranslate(_pos); - glMultMatrixd(rot); + glMultMatrixd(cast(double *)rot); linePoint.beginRecord(); shape.recordLinePoints(linePoint); linePoint.endRecord(); @@ -453,7 +453,7 @@ public class Ship: OdeActor, BulletTarge linePoint.draw(); glPushMatrix(); Screen.glTranslate(_pos); - glMultMatrixd(rot); + glMultMatrixd(cast(double *)rot); subShape.draw(); glPopMatrix(); } @@ -520,7 +520,7 @@ public class ShipTail: OdeActor { Ship ship; ParticlePool particles; ConnectedParticlePool connectedParticles; - dMass m; + dMass m = void; Shape shape; LinePoint linePoint; dJointID joint; @@ -643,7 +643,7 @@ public class ShipTail: OdeActor { public void recordLinePoints() { glPushMatrix(); Screen.glTranslate(_pos); - glMultMatrixd(rot); + glMultMatrixd(cast(double *)rot); glScalef(size.x, size.y, size.z); linePoint.beginRecord(); shape.recordLinePoints(linePoint); diff -urNp mcd_win/src/abagames/mcd/spec.d mcd/src/abagames/mcd/spec.d --- mcd_win/src/abagames/mcd/spec.d 2006-03-18 10:42:50.000000000 -0700 +++ mcd/src/abagames/mcd/spec.d 2007-04-25 20:33:35.000000000 -0600 @@ -210,7 +210,7 @@ public template CentMoveImpl() { if (state.isHead) { glPushMatrix(); Screen.glTranslate(state.pos); - glMultMatrixd(state.rot); + glMultMatrixd(cast(double *)state.rot); glScalef(state.sizeScale.x, state.sizeScale.y, state.sizeScale.z); subShape.draw(); glPopMatrix(); @@ -594,9 +594,9 @@ public class CentHeadRoll: CentHead { headBarrage = new CentBarrage; headBarrage.type = CentBarrage.BasicBarrageType.FRONT; float wr = rk * (size * 0.2f + rand.nextFloat(0.2f)); - float br = rk * rand.nextFloat(0.2f); + br = rk * rand.nextFloat(0.2f); float wrv = calcBarrageRank(wr); - float brv = calcBarrageRank(br); + brv = calcBarrageRank(br); if (wrv >= 0.2f) { headBarrage.wayMorphBml = WAY_MORPH_BML[rand.nextInt(WAY_MORPH_BML.length)]; headBarrage.wayMorphRank = wrv; @@ -615,8 +615,6 @@ public class CentHeadRoll: CentHead { calcForwardForceAndSlowVelocity(rk, size, ffs, svr); forwardForceScale = ffs; slowVelocityRatio = svr; - float sp; - int iv; calcBarrageSpeedAndInterval(rk, rk, sp, iv, 10, 60); headBarrage.speedRank = sp; headBarrage.interval = iv; diff -urNp mcd_win/src/abagames/util/rand.d mcd/src/abagames/util/rand.d --- mcd_win/src/abagames/util/rand.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/src/abagames/util/rand.d 2007-04-25 20:39:37.000000000 -0600 @@ -165,14 +165,14 @@ void init_by_array(uint init_key[], uint void next_state() { - uint *p=state; + uint *p=cast(uint *)state; /* if init_genrand() has not been called, */ /* a default initial seed is used */ if (initf==0) init_genrand(5489UL); left = N; - next = state; + next = cast(uint *)state; for (int j=N-M+1; --j; p++) *p = p[M] ^ TWIST(p[0], p[1]); diff -urNp mcd_win/src/abagames/util/sdl/texture.d mcd/src/abagames/util/sdl/texture.d --- mcd_win/src/abagames/util/sdl/texture.d 2006-02-19 12:57:26.000000000 -0700 +++ mcd/src/abagames/util/sdl/texture.d 2007-04-25 20:41:10.000000000 -0600 @@ -103,13 +103,13 @@ public class Texture { } glBindTexture(GL_TEXTURE_2D, num + ti); gluBuild2DMipmaps(GL_TEXTURE_2D, 4, panelWidth, panelHeight, - GL_RGBA, GL_UNSIGNED_BYTE, pixels); + GL_RGBA, GL_UNSIGNED_BYTE, cast(void *)pixels); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); if (maskColor != 0xffffffffu) { glBindTexture(GL_TEXTURE_2D, maskNum + ti); gluBuild2DMipmaps(GL_TEXTURE_2D, 4, panelWidth, panelHeight, - GL_RGBA, GL_UNSIGNED_BYTE, maskPixels); + GL_RGBA, GL_UNSIGNED_BYTE, cast(void *)maskPixels); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); } diff -urNp mcd_win/src/abagames/util/sdl/twinstickpad.d mcd/src/abagames/util/sdl/twinstickpad.d --- mcd_win/src/abagames/util/sdl/twinstickpad.d 2006-03-18 11:36:00.000000000 -0700 +++ mcd/src/abagames/util/sdl/twinstickpad.d 2007-04-25 20:41:42.000000000 -0600 @@ -12,6 +12,7 @@ private import SDL; private import abagames.util.vector; private import abagames.util.sdl.input; private import abagames.util.sdl.recordableinput; +private import SDL_Keyboard; /** * Twinstick and buttons input.