| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 2 |
| 经验 | |
| 最后登录 | 2019-4-8 |
| 在线时间 | 249 小时 |
- 梦石
- 0
- 星屑
- 163
- 在线时间
- 249 小时
- 注册时间
- 2014-7-18
- 回帖
- 26
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 M.Winderic. 于 2015-7-16 21:44 编辑
329 Mega point pre second on gt755m, 其实没比rgss 3 Mega point pre second on i4200m 快多少还多出个DX11的累赘,
【看不懂的可以认为是每秒把IMacRentia屏幕旋转18次】
因此说RGSS真心好用就是不开源……
坑爹的EB,
拿好下面两段代码之后就可以制作冒牌RGSS了
nothing at all
C语言全家都叫慢版汇编,233的[pre lang="cpp" file="dgs"]#include "stdafx.h"
#include "rgsssic.h"
#include <iostream>
#include <cmath>
#include "amp.h"
#include "amp_math.h"
using namespace concurrency;
using namespace concurrency::fast_math;
void AMP_MARTIX(long x2, long y2, float rad, float zox, float zoy, long ox, long oy,
long w, int m, float *x1, float *y1)restrict(amp) {
*x1 = (cos(rad)*x2 + sin(rad)*y2) / zox * 100.0f + ox;
*y1 = (-sin(rad)*x2 + cos(rad)*y2) / zoy * 100.0f + oy;
if (m == 1) { *x1 = w - *x1; }
}
void AMP_BLT(float x, float y, int stx, int sty, array_view<unsigned int, 2> vbmp, array_view<unsigned int, 2> vvma,int b) restrict(amp) {
index<2> vb((int)ceil(y),(int)ceil(x));
index<2> va(sty,stx);
// uint32_t t = (((int)ceil(y) << 16) + ((int)ceil(x) << 8));
vvma[va] = vbmp[vb];// 0xff0000ff|t;
}
#ifdef RUBYGAMESLIGHTSCRIPTINGSYSTEMUNIVERSALLIBRARY_EXPORTS
#define RGSSSUL_API extern "C" __declspec(dllexport)
#else
#define RGSSSUL_API extern "C" __declspec(dllimport)
#endif
#ifdef _WIN64
typedef long long CASTERISK;
#else
typedef long CASTERISK;
#endif
#define M_PI 3.14159265358979323846
RGSSSUL_API int LibRGSSS_DrawGLScene_p_i(int *);
int LibRGSSS_DrawGLScene_p_i(int *cmd)
{
// 中继指针
char *c = NULL;
CASTERISK *l = NULL;
double *d = NULL;
// 从这里开始进行所有的绘制
int config = *cmd;
bool d3d = false, d2d = false, cqc = false;
(int*)cmd++;
d3d = ((config & 0b10000000000000000000000000000000) == 0b10000000000000000000000000000000);
d2d = ((config & 0b01000000000000000000000000000000) == 0b01000000000000000000000000000000);
cqc = ((config & 0b00100000000000000000000000000000) == 0b00100000000000000000000000000000);
if (d3d)
{
// 清除屏幕和深度缓存
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// 重置当前的模型观察矩阵
glLoadIdentity();
}
if (d2d)
{
// 清除屏幕缓存
glClear(GL_COLOR_BUFFER_BIT);
// 重置当前的模型观察矩阵
glLoadIdentity();
GLbyte * vma;
char * vmb;
vma = *(GLbyte**)cmd;l = (CASTERISK *)cmd;l++;cmd = (int *)l;l = NULL;
vmb = *(char**)cmd;l = (CASTERISK *)cmd;l++;cmd = (int *)l;l = NULL;
int aaaaa = 0;
// std::cout << &aaaaa << std::endl;
// std::cout << "[VMA]" << (int)*(int*)vma << std::endl;
// std::cout << "[VMB]" << (int)*(int*)vmb << std::endl;
long vw = 0, vh = 0;
vw = *cmd;cmd++;
vh = *cmd;cmd++;
// ARY USI VMA
unsigned int * ary_usi_vma = (unsigned int *)vma;
array_view<unsigned int, 2> vvma((int)vh, (int)vw, ary_usi_vma);
unsigned int * ary_usi_vmb = (unsigned int *)vmb;
array_view<unsigned int, 2> vvmb((int)vh, (int)vw, ary_usi_vmb);
// GPU MEM SET SYN
// parallel_for_each(vvma.extent, [vvma, vvmb](index<2>idx) restrict(amp) {vvma[idx] = 0;vvmb[idx] = 0;});
// std::cout << "[D2D]" << vw << "x" << vh;
// 绘制 Sprite 数组,'s'开头引导精灵
while (*(char*)cmd == 's')
{
// std::cout << "(sprite)";
c = (char *)cmd;c++;cmd = (int *)c;c = NULL;
long x = 0, y = 0, ox = 0, oy = 0, w = 0, h = 0, sx = 0, sy = 0, sw = 0, sh = 0;
x = *cmd;cmd++;
ox = *cmd;cmd++;
y = *cmd;cmd++;
oy = *cmd;cmd++;
w = *cmd;cmd++;
h = *cmd;cmd++;
int b = 0;
b = (int)*cmd;(int*)cmd++;
double zox = 0.0, zoy = 0.0, an = 0.0;
zox = (double)*(double*)cmd;d = (double *)cmd;d++;cmd = (int *)d;d = NULL;
zoy = (double)*(double*)cmd;d = (double *)cmd;d++;cmd = (int *)d;d = NULL;
an = (double)*(double*)cmd;d = (double *)cmd;d++;cmd = (int *)d;d = NULL;
int m;
m = (int)*(int*)cmd;(int*)cmd++;
sx = *cmd;cmd++;
sy = *cmd;cmd++;
sw = *cmd;cmd++;
sh = *cmd;cmd++;
// std::cout << x << "-" << ox << "," << y << "-" << oy << "|" <<
// w << ',' << h << '|' << b << '|' <<
// zox << ',' << zoy << '|' << an << '|' << m;
if (*(char*)cmd == 'b')
{
// std::cout << "(bitmap)" << cqc << "|";
c = (char *)cmd;c++;cmd = (int *)c;c = NULL;
if (cqc)
{
char * bmp = (char *)*(char **)cmd;
l = (CASTERISK *)cmd;l++;cmd = (int *)l;l = NULL;
// std::cout << (CASTERISK)bmp << "|";
// 获取收敛环
double ring[4][3];
ring[0][0] = cos(an)*ox*zox / 100.0 - sin(an)*oy*zoy / 100.0;
ring[0][1] = cos(an)*oy*zoy / 100.0 + sin(an)*ox*zox / 100.0;
ring[0][2] = sqrt(ring[0][0] * ring[0][0] + ring[0][1] * ring[0][1]);
ring[1][0] = cos(an)*(w - ox)*zox / 100.0 - sin(an)*oy*zoy / 100.0;
ring[1][1] = cos(an)*oy*zoy / 100.0 + sin(an)*(w - ox)*zox / 100.0;
ring[1][2] = sqrt(ring[1][0] * ring[1][0] + ring[1][1] * ring[1][1]);
ring[2][0] = cos(an)*(w - ox)*zox / 100.0 - sin(an)*(h - oy)*zoy / 100.0;
ring[2][1] = cos(an)*(h - oy)*zoy / 100.0 + sin(an)*(w - ox)*zox / 100.0;
ring[2][2] = sqrt(ring[2][0] * ring[2][0] + ring[2][1] * ring[2][1]);
ring[3][0] = cos(an)*ox*zox / 100.0 - sin(an)*(h - oy)*zoy / 100.0;
ring[3][1] = cos(an)*(h - oy)*zoy / 100.0 + sin(an)*ox*zox / 100.0;
ring[3][2] = sqrt(ring[3][0] * ring[3][0] + ring[3][1] * ring[3][1]);
double d = 0.0;
if (ring[0][2] > d) { d = ring[0][2]; }
if (ring[1][2] > d) { d = ring[1][2]; }
if (ring[2][2] > d) { d = ring[2][2]; }
if (ring[3][2] > d) { d = ring[3][2]; }
// std::cout << d << std::endl;
// std::cout << std::endl;
unsigned int * ary_usi_bmp = (unsigned int *)bmp;
array_view<unsigned int, 2> iterator((int)(2.0*ceil(d)), (int)(2.0*ceil(d)));
array_view<unsigned int, 2> vbmp(h, w, ary_usi_bmp);
parallel_for_each(iterator.extent, [b,d,x,y,zox,zoy,w,h,m,ox,oy,an,vvma,vbmp,vw,vh](index<2>idx)restrict(amp) {
float ixa, ixb;
AMP_MARTIX((long)(idx[1] - d), (long)(idx[0] - d), (float)an, (float)zox, (float)zoy, ox, oy, w, m, &ixa, &ixb);
// AMP_BLT(ixa, ixb, idx[0], idx[1],vbmp,vvma);
long p = x - (long)d + idx[1], q = y - (long)d + idx[0];
if (ixa < w&&ixa >= 0 && ixb < h&&ixb >= 0 && p>=0 && q>=0 && p<=vw &&q<=vh ) {
// AMP_BLT(0, 0, ixa, ixb, vbmp, vvma);
// AMP_BLT(ixa, ixb, idx[0], idx[1], vbmp, vvma);
AMP_BLT(ixa, ixb, p, vh - q, vbmp, vvma,b);
}
});
}
else
{
char * bmp = (char *)*(char **)cmd;
l = (CASTERISK *)cmd;l++;cmd = (int *)l;l = NULL;
// std::cout << (CASTERISK)bmp << "|";
// std::cout << std::endl;
}
}
else
{
MessageBox(NULL, TEXT("ERROR:0x10000001\nBadMemoryFormat"), RGSSSIC_name, MB_OK);
}
}
vvma.synchronize();
// unsigned int * cvvc = (unsigned int *)vma;
// for (int a = 0; a < vh;a++) {
// for (int b = 0; b < vw;b++) {
// if (b % 2 == 1)
// (unsigned int)*(cvvc+a*vw + b) = 0xffffffff;
// }
// }
glDrawPixels(vw, vh, GL_RGBA, GL_UNSIGNED_BYTE, vma);
}
return 0;
}
[/pre]
顺便说一句,ruby这样玩就可以玩坏[pre lang="cpp" file="rgsss"]int _tmain(int argc, _TCHAR* argv[])
{
// 加载 Ruby DLL
HINSTANCE rbDll;
rb_init ruby_init;
#ifdef _WIN64
rbDll = LoadLibrary(TEXT("./bin/x64-msvcrt-ruby210.dll"));
#else
rbDll = LoadLibrary(TEXT("./bin/msvcrt-ruby210.dll"));
#endif
if (rbDll)
{
ruby_init = (rb_init)GetProcAddress(rbDll, "ruby_init");
if (ruby_init)
{
ruby_init();
rb_eval_string_protect ruby_eval_string_protect;
ruby_eval_string_protect = (rb_eval_string_protect)GetProcAddress(rbDll, "rb_eval_string_protect");
if (ruby_eval_string_protect)
{
int status = -1;
ruby_eval_string_protect("require './lib/scripts'", &status);
if (status)
{
ruby_eval_string_protect("print $!", &status);
}
}
}
rb_finalize ruby_finalize;
ruby_finalize = (rb_finalize)GetProcAddress(rbDll, "ruby_finalize");
if (ruby_finalize)
{
ruby_finalize();
}
// 释放已经加载的DLL模块
FreeLibrary(rbDll);
}
return 0;
}[/pre]
如果Kernel写不出来的话就洗洗睡了吧
[pre lang="ruby" file="kernel"]# -*- ruby -*-
$LOAD_PATH.push File.expand_path './lib/ruby/2.1.0/i386-mingw32'
$LOAD_PATH.push File.expand_path './lib/ruby/2.1.0'
$LOAD_PATH.push File.expand_path './lib/ruby/site_ruby/2.1.0'
require 'Win32API'
module HCl
VERSION_KERNEL = 0x00000001
module Universal_Library
LIBRARY =
[
"LibGL_ResizeViewport_ii_v",
"LibPNG_GetPNGData_pppp_i",
"LibPNG_GetPNGInfo_pppp_i",
"LibRGSSS_AllocateExternalVM_pp_i",
"LibRGSSS_CreateGLWindow_piipi_i",
"LibRGSSS_DisposeExternalVM_p_i",
"LibRGSSS_DrawGLScene_p_i",
"LibRGSSS_GetVersion_v_i",
"LibRGSSS_KillGLWindow_v_i",
"LibRGSSS_MemsetVM_pip_i",
"LibRGSSS_PeekMessage_i_i",
"LibRGSSS_SwapBuffers_v_i",
]
def Universal_Library.load_library
@library = {}
libx86 = (Config::X86 == Config::X86_64 ? 'x64-' : '')
LIBRARY.each {|f|
lib, func, arg, res, = f.split("_")
@library[func] = Win32API.new("./bin/"+libx86+"msvcrt-rgsssul101", f, arg, res)
}
end
def Universal_Library.library
@library
end
def Universal_Library.function(f)
return @library[f]
end
end
module System
Universal_Library.load_library
def System.boot
Universal_Library.function("CreateGLWindow").call(System.enc_lpwstr_vs(Config::Title),
Config::Width,Config::Height,Config::ColorBit,Config::Fullscreen)
end
def System.terminate
Universal_Library.function("KillGLWindow").call
end
def System.update
System.exchange_status
end
def System.exchange_status
Universal_Library.function("PeekMessage").call(0)
end
def System.load_script
@script = File.read(Config::Script)
end
def System.run_script
# eval
end
def System.allocate_mem(size)
vm = Config::CASTERISK.clone
Universal_Library.function("AllocateExternalVM").call(size,vm)
return vm
end
def System.free_mem(vm)
Universal_Library.function("DisposeExternalVM").call(vm)
return vm
end
def System.enc_lpwstr_vs(s)
return (s+Config::CINT.clone).unpack("U*").pack("v*")
end
def System.dec_lpwstr_vs(s)
return s.unpack("v*").pack("U*").gsub(/\u0000*\Z/,'')
end
def System.time_stamp
[Time.now.to_f].pack("d").unpack("Q")[0]
end
def System.memset(p,i,s)
Universal_Library.function("MemsetVM").call(p,i,s)
end
end
class Bitmap
attr_accessor :binary
attr_accessor :width
attr_accessor :height
def initialize(a,b=nil)
@binary = Config::CASTERISK.clone
@disposed = false
if b == nil
path = a
w,h,s = Config::CINT.clone,Config::CINT.clone,Config::CINT.clone
Universal_Library.function("GetPNGInfo").call(System.enc_lpwstr_vs(path),w,h,s)
@width, @height = (w+h).unpack("l*")
@filesize = s
@binary = System.allocate_mem(@filesize)
Universal_Library.function("GetPNGData").call(System.enc_lpwstr_vs(path),w,h,@binary)
@width, @height = (w+h).unpack("l*")
else
@width = a
@height = b
@binary = System.allocate_mem([4*a*b].pack("l"))
end
end
def dispose
System.free_mem(@binary) unless @disposed
end
def clear
System.memset(@binary,0,[4*@width*@height].pack("l"))
end
end
module Graphics
STDBitmap = Bitmap.new(8,8)
@frame_count = 0
@adjust_frame_rate = false
@sprites = {}
@bitmap_cache = {}
@vma = Bitmap.new(Config::Width,Config::Height)
@vmb = Bitmap.new(Config::Width,Config::Height)
def Graphics.main_viewport
return nil
end
def Graphics.update
@vma.clear
@vmb.clear
ini = 0b11100000000000000000000000000000
# DDA
# 32M
# DDP
cmd = [ini].pack('i') + @vma.binary + @vmb.binary + [Config::Width,Config::Height].pack("ll")
if Config::Kernel_D3D
end
if Config::Kernel_D2D
cache = ""
@sprites.values.each do |v|
v.sort{|x,y|
(x.z<=>y.z) == 0 ? (x.y<=>y.y) == 0 ? x.time_stamp<=>y.time_stamp : x.y<=>y.y : x.z<=>y.z
}.each { |w|
if w.visible
cache.concat 's'
cache.concat [w.x,w.ox,w.y,w.oy,w.bitmap.width,w.bitmap.height,w.blend_type,
w.zoom_x,w.zoom_y,w.angle,w.mirror].pack('llllllidddi')
cache.concat w.src_rect.pac
cache.concat 'b'
cache.concat w.bitmap.binary
end
}
end
cmd.concat cache
end
Universal_Library.function("DrawGLScene").call(cmd)
Universal_Library.function("SwapBuffers").call
@frame_count += 1
end
def Graphics.freeze
end
def Graphics.transition(duration = 8, filename = nil, vague = 40)
end
def Graphics.frame_reset
end
def Graphics.frame_rate
end
def Graphics.frame_count
@frame_count
end
def Graphics.add_sprite(sprite, viewport)
@sprites[viewport] = [] if @sprites[viewport].nil?
@sprites[viewport].push sprite
end
def Graphics.delete_sprite(sprite)
end
def Graphics.snap
end
end
end
require "./lib/rbscripts/io.rb"
require "./lib/rbscripts/color.rb"
require "./lib/rbscripts/sprite.rb"
require "./lib/rbscripts/rect.rb"
[/pre]
|
|