Maidens of the Kaleidoscope

~Hakurei Shrine~ => Rika and Nitori's Garage Experiments => Topic started by: Fujiwara no Mokou on January 25, 2012, 03:59:25 AM

Title: Source Code to Touhou Danmakufu (revive)
Post by: Fujiwara no Mokou on January 25, 2012, 03:59:25 AM
nearly 2 years later...
I've talked to MKM, the guy who made the source code for danmakufu (or, at least the script engine for it).
It's surprisingly simple and powerful machine. It's written in C++ and the script engine consists of a virtual machine and a parser that takes the script as a text document and compiles it into bytecode for the machine to execute at runtime. The user-defined routines are stored in a pointer somewhere in the machine. The scripting language supports an abstract data type that, in c++, boils down to a union of primitive types.

I'm working on an improved version of game engine, it'll use the similar syntax to danmakufu. This guy knew what he was doing.
(http://img862.imageshack.us/img862/7812/96616503.jpg)

give me a private message if you're still interested in the source, I'll see if I can throw it out for you.
look here (http://www.shrinemaiden.org/forum/index.php/topic,11868.msg780598.html#msg780598)
Title: Re: Source Code to Touhou Danmakufu
Post by: Mеа on January 25, 2012, 06:19:26 AM
I think you've gotten a really nice find, good job. I'm sure people will be interested in this.
Just out of curiosity, this is the v0.12 I'm assuming?
Title: Re: Source Code to Touhou Danmakufu
Post by: Blargel on January 25, 2012, 07:09:36 AM
I was about to ask what dumbass bumped a dead thread to ask for the source again, but then I read that
THE SOURCE IS HERE!?

Also amazing is the fact that you found a two year old thread instead of making your own, but I'll ignore that in light of this glorious news.

EDIT: If it ain't obvious from that, I'm interested in the code too. If MKM didn't say anything about not distributing the source, I'd like a copy please.
Title: Re: Source Code to Touhou Danmakufu
Post by: Helepolis on January 25, 2012, 07:50:10 AM
The original topic starter is dead. I don't see how is able to PM you. Splitting this thread.

Edit:
I am curious though what can be made out of the source code in 0.12m and how that is going to be supreme/better than the newest danmakufu? The only thing that crosses my mind is perhaps some optimizations for people who spent a lot of time in the old engine and don't want to restart in the new one.

Title: Re: Source Code to Touhou Danmakufu (revive)
Post by: Momiji on January 25, 2012, 09:23:49 AM
Linux support please.   :ohdear:
Title: Re: Source Code to Touhou Danmakufu (revive)
Post by: Fujiwara no Mokou on January 25, 2012, 09:11:17 PM
The source code to danmakufu script engine. It is in C++.
I've taken the liberty of translating as much I can to english.

Note that this is just the engine. If you want to make a fully fledged shootemup from this, you must integrate the directx/opengl UI into the engine accordingly.
Get acquainted with the callback function format and make the script functions yourself (GetEnemyX/ SetVertexUV/XY/ CreateLaser01, etc)
ScriptEngine.hpp (http://pastebin.com/SpQZDB4M)
ScriptEngine.cpp (http://pastebin.com/Xd9PyUEc)
Sample.cpp (http://pastebin.com/CPk2Duhn)
script.txt (http://pastebin.com/QPNDdg5H)

I have high hopes for this community. Good luck.
Title: Re: Source Code to Touhou Danmakufu (revive)
Post by: Blargel on January 25, 2012, 11:11:15 PM
I've talked to MKM, the guy who made the source code for danmakufu (or, at least the script engine for it).

Note that this is just the engine. If you want to make a fully fledged shootemup from this, you must integrate the directx/opengl UI into the engine accordingly.

That was a bit misleading at first. In my excitement I thought we had the whole danmakufu engine but if we only have the script engine, we can't really do anything. Not unless we write a working game engine (bullets, players, enemies, bosses, collision detection, etc) to couple it with anyway. I don't think anyone here has the time to do that unfortunately.
Title: Re: Source Code to Touhou Danmakufu (revive)
Post by: Yukari-Chan on January 25, 2012, 11:27:26 PM
Wait, this is a script engine? I thought we can open Touhou Danmakufu without problems. Then I can edit title and add bgm :'D. Oh well, guess this will do


Aw ignore my first post, we have a source code and that's all that matters xD
Title: Re: Source Code to Touhou Danmakufu (revive)
Post by: Fujiwara no Mokou on August 26, 2012, 05:58:14 AM
Woo, I'm back. It's been a while since I've been here.
I've done a lot of research while I was away. The complete source code to Danmakufu is still in the shadow, and I think it'llalways stay that way, but I found something that may interest some devs.
Danmakufu's scripts take an already existing concepts of coroutines (http://en.wikipedia.org/wiki/Coroutine). Most notably, the tasks that run in parallel in each script entities, and even the entities themselves.
Danmakufu's ScriptEngine uses a FSM to get the job done by emulating threads. The tasks explicitly yield to the other threads. Well, in this case, it's better to call them something like fibers (http://en.wikipedia.org/wiki/Fiber_%28computer_science%29), because tasks yield themselves in the script rather than have a scheduler to yield them for you.
Danmakufu's implementation of it (at least, compared to hardcoded C OS-specific fibers) are actually quite heavy. Unfortunately C/C++ programming languages are sequential languages that assume the program runs on only one thread and thus is designed as such, but operating systems take advantage of ASM to save/restore the call stack and CPU registers to implement it anyway. In fact, there's a whole article about it I came across for Windows here (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682402%28v=vs.85%29.aspx). Anyway, I think these will be my last words on the subject, seeing as I went a bit off-topic. But hopefully this will help other devs with whatever game it is they're making. I know how irritating task-scheduling for entities to run parallel processes can be, and this has definitely become a popular paradigm for AI programming in games.
Title: Re: Source Code to Touhou Danmakufu (revive)
Post by: Kaze_Senshi on August 28, 2012, 10:00:44 PM
Hmmmm so will the Danmakufuu code become "open-source"? I was thinking if there is a way to create a Danmakufuu version playable via browser, using html5 or something like to create the images.