├── .gitignore ├── LICENSE ├── README.md ├── manual ├── license.txt ├── readme.txt ├── vmbasic.txt ├── vmbeta.txt └── vmdevc.pdf └── vmbasic ├── EasyGl.h ├── i_math.c ├── i_math.h ├── iacciden.cpp ├── iacciden.h ├── ibitmap.h ├── ibitmapc.cpp ├── ibitmapc.h ├── icanvas.cpp ├── icanvas.h ├── idxdraw.cpp ├── idxdraw.h ├── ifstream.cpp ├── ifstream.h ├── igdibmp.cpp ├── igdibmp.h ├── iini.cpp ├── iini.h ├── ikeybord.h ├── imagine.dsp ├── imagine.dsw ├── imapps ├── console │ ├── vmbasic.cpp │ └── vmbeta.cpp ├── vmbeta │ ├── Res │ │ ├── IconMain.TGA │ │ └── IconMain.ico │ ├── Terminal.h │ ├── VmBeta.cpp │ ├── VmBeta.dsp │ ├── VmBeta.dsw │ ├── VmBeta.opt │ ├── VmBetaV.cpp │ ├── VmBetaV.h │ ├── VmWin.cpp │ ├── VmWin.h │ ├── VmbetaWin.txt │ ├── resource.aps │ ├── resource.h │ └── resource.rc └── vmbide │ ├── AboutForm.cpp │ ├── AboutForm.dfm │ ├── AboutForm.h │ ├── AsmForm.cpp │ ├── AsmForm.dfm │ ├── AsmForm.h │ ├── Basic.htm │ ├── DOS │ ├── alex1.bas │ ├── alex2.bas │ ├── alex3.bas │ ├── alex4.bas │ ├── vmbasic.cpp │ ├── vmbeta.cpp │ ├── vmbeta.txt │ ├── vmdemo.vms │ └── 说明.txt │ ├── Examples │ ├── Fire.bas │ ├── Fire.vms │ ├── Game1.TGA │ ├── Game2.TGA │ ├── Game3.TGA │ ├── alex1.bas │ ├── alex2.bas │ ├── alex3.bas │ ├── alex4.bas │ ├── alex4.vms │ ├── hello.bas │ └── vmdemo.vms │ ├── Help │ ├── IconMain.GIF │ ├── Look.gif │ ├── Look.tga │ ├── Look2.GIF │ ├── Look3.GIF │ ├── butten4.jpg │ └── button1.jpg │ ├── IDEForm.cpp │ ├── IDEForm.dfm │ ├── IDEForm.h │ ├── Readme.htm │ ├── StdLib.VBL │ ├── ToolForm.cpp │ ├── ToolForm.dfm │ ├── ToolForm.h │ ├── VmBIDE.bpr │ ├── VmBIDE.cpp │ ├── VmBIDE.ini │ ├── VmBIDE.res │ ├── VmBasic.cpp │ ├── VmBasic.h │ ├── res │ ├── Icon1.ico │ ├── Icon10.ico │ ├── Icon11.ico │ ├── Icon12.ico │ ├── Icon13.ico │ ├── Icon14.ico │ ├── Icon15.ico │ ├── Icon16.ico │ ├── Icon17.ico │ ├── Icon18.ico │ ├── Icon19.ico │ ├── Icon2.ico │ ├── Icon20.ico │ ├── Icon21.ico │ ├── Icon22.ico │ ├── Icon23.ico │ ├── Icon3.ico │ ├── Icon4.ico │ ├── Icon5.ico │ ├── Icon6.ico │ ├── Icon7.ico │ ├── Icon8.ico │ ├── Icon9.ico │ ├── IconList.bmp │ ├── IconMain.ico │ ├── Pic1.BMP │ ├── Pic2.BMP │ ├── PicAuthor.bmp │ ├── PicMain.BMP │ ├── PicR.BMP │ ├── PicR.cur │ ├── PicW.BMP │ ├── PicW.cur │ └── Thumbs.db │ ├── tools │ ├── Basic.htm │ ├── DOS │ │ ├── alex1.bas │ │ ├── alex2.bas │ │ ├── alex3.bas │ │ ├── alex4.bas │ │ ├── demo1.vms │ │ ├── vmbasic.cpp │ │ ├── vmbeta.cpp │ │ ├── vmbeta.txt │ │ └── 说明.txt │ ├── Examples │ │ ├── Fire.bas │ │ ├── Game1.TGA │ │ ├── Game2.TGA │ │ ├── Game3.TGA │ │ ├── alex1.bas │ │ ├── alex2.bas │ │ ├── alex3.bas │ │ ├── alex4.bas │ │ ├── hello.bas │ │ └── vmdemo.vms │ ├── Help │ │ ├── IconMain.GIF │ │ ├── Look.gif │ │ ├── Look.tga │ │ ├── Look2.GIF │ │ ├── Look3.GIF │ │ ├── butten4.jpg │ │ └── button1.jpg │ ├── Readme.htm │ ├── StdLib.VBL │ ├── VmBIDE.ini │ ├── hello.bas │ └── vmbeta.txt │ └── vmbeta.txt ├── iplatfrm.cpp ├── iplatfrm.h ├── iscreen.h ├── istream.h ├── istring.h ├── itemplat.h ├── ivector.h ├── ivms.h ├── ivmsbeta.cpp ├── ivmsbeta.h ├── ivmsca.cpp ├── ivmsca.h ├── ivmscc.h ├── ivmscexp.cpp ├── ivmscs.cpp ├── ivmscv.cpp ├── license.txt └── readme.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Linwei 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VmBasic 2 | 3 | 2001-2002 期间开发的虚拟机/编译器开源项目代码和资料: 4 | 5 | - 关于虚拟机及其编译器的说明 6 | - VmBasic 开发/调试环境的介绍及说明 7 | - 关于其他 8 | 9 | 所有资料可以通过下面地址下载: 10 | 11 | [下载可执行](https://www.skywind.me/resource/vmbeta.zip) [源程序下载](https://www.skywind.me/resource/skywind/vmbsrc.zip) [设计说明书](https://www.skywind.me/maker/VmBasicDesign.pdf) 12 | 13 | 14 | ### 关于虚拟机及其编译器的说明 15 | 16 | 记得 3DS/MAX 里面实现了一个类似 BASIC 的脚本,Animator 里面实现了一个类 C 的脚本语言,Autodesk 公司的软件对于脚本支持的很出色,好的脚本引擎在乎平台无关性、高效性和扩充性,一个脚本引擎的需要对一个好程序来说非常迫切,于是半年前我写了一款虚拟机,最近又实现了一个类 Basic 的脚本编译器,特性说明: 17 | 18 | 1) 高效性和独立于平台:由于虚拟机运行是解释二进制的字节码因此速度明显快于每次运行及时解释的脚本语言,比如 Perl 和 PHP,而虚拟机的核心程序代码也经过数个 C++编译器和平台的测试,可以毫无修改的编译运行于多个操作系统。 19 | 2) 充分的开放:通过虚拟机的端口 I/O 技术,要对它进行扩充变得十分容易,VmBeta 指令通过输出/输入的方法向用户自己的程序进行通讯,用户通过处理输出输入消息来达到功能的扩充,使它符合你产品的需要,具体的虚拟机实现和设计说明参考文档 `vmbeta.txt` 。 20 | 3) 可设安全级别:通过可设置安全级别,对程序运行状态进行监控。 21 | 22 | 通过半年的修改我自己觉得虚拟机够高效开放,就是 vmbasic 编译器写的没有多高的水准:完全没有对生成代码做优化,弄出许多繁琐的中间代码,不过还是明显快于及时解释语言,通过测试速度大概是 DOS 自带的 QBASIC 程序的三倍左右(可以通过目录下的几个算法程序来实验)。 23 | 24 | 为了检验其效率和扩充性,我将虚拟机程序扩充了一些作图功能写成了 Windows 版本的,然后用 vmbasic 编写了一个空战小游戏,虽然由于一开始我太相信 GDI 而没有选择 DDraw,且编译器要生成 1/2 左右的重复性代码,但是仍可以从游戏中看出效率来(可以用 vmbide.exe 打开 fire.bas 运行),关于编译程序 VmBasic 的更详细说明见 basic.htm 25 | 26 | 程序说明:压缩档包括虚拟机运行程序 (vmbeta.exe),VmBasic 调试开发平台 (vmbide.exe),四个算法例子 (alex1-4.bas),一个射击游戏例子 (fire.bas) 及其图片,说明帮助文档若干。。。 27 | 28 | ### VmBasic开发/调试环境介绍及说明 29 | 30 | 右边的图是完整的开发环境左边是语句帮助,中间是代码编写区,下面是编译的错误和过程记录,系统热键说明: 31 | 32 | 1) F8 编译成 VMS 文件 33 | 2) F9 编译并运行程序 34 | 3) F1 对 VmBasic 的帮助 35 | 4) Shift+F1 帮助 IDE 36 | 37 | ![](https://skywind3000.github.io/images/p/vmbasic/vmbasic1.gif) 38 | 39 | 另外点击运行图表左边的图表可以查看编译出来的虚拟机汇编代码。点击工具目录,可以做一系列设置:虚拟机程序设置,预连接库设置,开发环境设置等,都是简单的东西。 40 | 41 | 用 VmBasic 编写的射击小游戏:必须 Windows 版的虚拟机程序运行(扩充了 GDI 图形功能) 42 | 43 | ![](https://skywind3000.github.io/images/p/vmbasic/vmbasic3.gif) 44 | 45 | 显示查看虚拟机汇编: 46 | 47 | ![](https://skywind3000.github.io/images/p/vmbasic/vmbasic2.gif) 48 | 49 | ### 关于其他 50 | 51 | 半年前在论坛上面看见过一些师兄们关于编译的争论,忽然有所感悟,那时刚好写了虚拟机,于是就决定为它写款语言,本来考虑写类 C 或者类 Pascal 的,但是想着 Basic 用起来简单,而且分析起来似乎也简单,后来我才发现虽然没有 C 的编译难写但由于 Basic 经历了长时间的发展,语法变化很大,总的来说没有同意的规范,模块表示也不明确,就连 IF 语句都有好多种版本,所以一个支持函数/过程的 Basic 编译器我觉得比 Pascal 难写的多。目录 DOS 下有 DOS 环境的编译器和虚拟机,可以用来编译运行非扩展的 vmbasic 程序:alex1-4.bas,可以在 IDE 的工具->设置里面设定虚拟机的运行程序。 52 | 53 | 这是个引擎的演示版本,毕竟好的东西都不是一个人整出来的,我也会在学校不断的学习,非常欢迎来信讨论相关技术,和游戏/图形程式设计,如果你觉得这套引擎对你有价值,可以写信给我,如果你对相关的东西很感兴趣,也可以写信给我。 54 | 55 | ## Credit 56 | 57 | 欢迎关注: 58 | 59 | - 我的博客:https://skywind.me/blog 60 | - 我的推特:https://x.com/skywind3000 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /manual/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/manual/license.txt -------------------------------------------------------------------------------- /manual/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/manual/readme.txt -------------------------------------------------------------------------------- /manual/vmbasic.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/manual/vmbasic.txt -------------------------------------------------------------------------------- /manual/vmbeta.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/manual/vmbeta.txt -------------------------------------------------------------------------------- /manual/vmdevc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/manual/vmdevc.pdf -------------------------------------------------------------------------------- /vmbasic/EasyGl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/EasyGl.h -------------------------------------------------------------------------------- /vmbasic/i_math.c: -------------------------------------------------------------------------------- 1 | #include "i_math.h" 2 | 3 | void i_normalize_vector(float *vect3) 4 | { 5 | float length=i_vect_length(vect3); 6 | length=(length==0)?1:(1/length); 7 | vect3[0]*=length; 8 | vect3[1]*=length; 9 | vect3[2]*=length; 10 | } 11 | 12 | void i_cross_product(const float *x,const float *y,float *z) 13 | { 14 | float t1,t2,t3; 15 | t1=x[1]*y[2]-x[2]*y[1]; 16 | t2=x[2]*y[0]-x[0]*y[2]; 17 | t3=x[0]*y[1]-x[1]*y[0]; 18 | z[0]=t1; 19 | z[1]=t2; 20 | z[2]=t3; 21 | } 22 | 23 | static iMatrix IdentityMatrix = 24 | { 25 | 1.0, 0, 0, 0 , 26 | 0, 1.0, 0, 0 , 27 | 0, 0, 1.0, 0 , 28 | 0, 0, 0, 1.0 , 29 | }; 30 | 31 | void i_vector_product(const float *v1,const iMatrix *m,float *v2) 32 | { 33 | float vect[3]={ v1[0], v1[1], v1[2] }; 34 | v2[0] = vect[0] * m->_11 + vect[1] * m->_21 + vect[2] * m->_31 + m->_41; 35 | v2[1] = vect[0] * m->_12 + vect[1] * m->_22 + vect[2] * m->_32 + m->_42; 36 | v2[2] = vect[0] * m->_13 + vect[1] * m->_23 + vect[2] * m->_33 + m->_43; 37 | } 38 | 39 | void i_matrix_add(const iMatrix *m1,const iMatrix *m2,iMatrix *out) 40 | { 41 | out->_11=m1->_11+m2->_11; out->_12=m1->_12+m2->_12; 42 | out->_13=m1->_13+m2->_13; out->_14=m1->_14+m2->_14; 43 | out->_21=m1->_21+m2->_21; out->_22=m1->_22+m2->_22; 44 | out->_23=m1->_23+m2->_23; out->_24=m1->_24+m2->_24; 45 | out->_31=m1->_31+m2->_31; out->_32=m1->_32+m2->_32; 46 | out->_33=m1->_33+m2->_33; out->_34=m1->_34+m2->_34; 47 | out->_41=m1->_41+m2->_41; out->_42=m1->_42+m2->_42; 48 | out->_43=m1->_43+m2->_43; out->_44=m1->_44+m2->_44; 49 | } 50 | 51 | void i_matrix_sub(const iMatrix *m1,const iMatrix *m2,iMatrix *out) 52 | { 53 | out->_11=m1->_11-m2->_11; out->_12=m1->_12-m2->_12; 54 | out->_13=m1->_13-m2->_13; out->_14=m1->_14-m2->_14; 55 | out->_21=m1->_21-m2->_21; out->_22=m1->_22-m2->_22; 56 | out->_23=m1->_23-m2->_23; out->_24=m1->_24-m2->_24; 57 | out->_31=m1->_31-m2->_31; out->_32=m1->_32-m2->_32; 58 | out->_33=m1->_33-m2->_33; out->_34=m1->_34-m2->_34; 59 | out->_41=m1->_41-m2->_41; out->_42=m1->_42-m2->_42; 60 | out->_43=m1->_43-m2->_43; out->_44=m1->_44-m2->_44; 61 | } 62 | 63 | void i_matrix_mul(const iMatrix *m1,const iMatrix *m2,iMatrix *out) 64 | { 65 | iMatrix temp; 66 | int i,j; 67 | if (m1==out) { temp=*m1; m1=&temp; } 68 | else if (m2==out) { temp=*m2; m2=&temp; } 69 | for (i=0;i<4;i++) 70 | for (j=0;j<4;j++) 71 | out->v[j][i]=(m1->v[j][0]*m2->v[0][i])+ 72 | (m1->v[j][1]*m2->v[1][i])+ 73 | (m1->v[j][2]*m2->v[2][i])+ 74 | (m1->v[j][3]*m2->v[3][i]); 75 | } 76 | 77 | void i_translation_matrix(iMatrix *m,const float *pos) 78 | { 79 | *m=IdentityMatrix; 80 | m->_41=pos[0]; 81 | m->_42=pos[1]; 82 | m->_43=pos[2]; 83 | } 84 | 85 | void i_scaling_matrix(iMatrix *m,const float *pos) 86 | { 87 | *m = IdentityMatrix; 88 | m->_11 = pos[0]; 89 | m->_22 = pos[1]; 90 | m->_33 = pos[2]; 91 | } 92 | 93 | void i_vectrotation_matrix(iMatrix *m,const float *vv,const float a) 94 | { 95 | float vect[3]={ vv[0],vv[1],vv[2] }; 96 | float w,x,y,z; // quaternion 97 | float qsin = (float)sin(a/2.0); 98 | float qcos = (float)cos(a/2.0); 99 | i_normalize_vector(vect); 100 | w = qcos; // x*x+y*y+z*z+w*w=1 101 | x = vect[0] * qsin; 102 | y = vect[1] * qsin; 103 | z = vect[2] * qsin; 104 | m->_11 = 1 - 2 * y * y - 2 * z * z; 105 | m->_21 = 2 * x * y - 2 * w * z; 106 | m->_31 = 2 * x * z + 2 * w * y; 107 | m->_12 = 2 * x * y + 2 * w * z; 108 | m->_22 = 1 - 2 * x * x - 2 * z * z; 109 | m->_32 = 2 * y * z - 2 * w * x; 110 | m->_13 = 2 * x * z - 2 * w * y; 111 | m->_23 = 2 * y * z + 2 * w * x; 112 | m->_33 = 1 - 2 * x * x - 2 * y * y; 113 | m->_14 = m->_24 = m->_34 = 0; 114 | m->_41 = m->_42 = m->_43 = 0; 115 | m->_44 = 1; 116 | } 117 | 118 | void i_matrix_identity(iMatrix *out) 119 | { 120 | if (out) *out = IdentityMatrix; 121 | } 122 | 123 | iMatrix* i_lookat(iMatrix *pOut,const float *pEye,const float *pAt,const float *pUp) 124 | { 125 | float XAxis[3]; 126 | float YAxis[3]; 127 | float ZAxis[3]; 128 | 129 | ZAxis[0]=pAt[0]-pEye[0]; 130 | ZAxis[1]=pAt[1]-pEye[1]; 131 | ZAxis[2]=pAt[2]-pEye[2]; 132 | 133 | i_normalize_vector(ZAxis); 134 | 135 | i_cross_product(pUp,ZAxis,XAxis); 136 | i_normalize_vector(XAxis); 137 | i_cross_product(ZAxis,XAxis,YAxis); 138 | 139 | pOut->_11 = XAxis[0]; 140 | pOut->_21 = XAxis[1]; 141 | pOut->_31 = XAxis[2]; 142 | pOut->_41 = -(XAxis[0]*pEye[0]+XAxis[1]*pEye[1]+XAxis[2]*pEye[2]); 143 | pOut->_12 = YAxis[0]; 144 | pOut->_22 = YAxis[1]; 145 | pOut->_32 = YAxis[2]; 146 | pOut->_42 = -(YAxis[0]*pEye[0]+YAxis[1]*pEye[1]+YAxis[2]*pEye[2]); 147 | pOut->_13 = ZAxis[0]; 148 | pOut->_23 = ZAxis[1]; 149 | pOut->_33 = ZAxis[2]; 150 | pOut->_43 = -(ZAxis[0]*pEye[0]+ZAxis[1]*pEye[1]+ZAxis[2]*pEye[2]); 151 | pOut->_14 = 0.0f; 152 | pOut->_24 = 0.0f; 153 | pOut->_34 = 0.0f; 154 | pOut->_44 = 1.0f; 155 | 156 | return pOut; 157 | } 158 | -------------------------------------------------------------------------------- /vmbasic/i_math.h: -------------------------------------------------------------------------------- 1 | /*====================================================================== 2 | // 3 | // i_math.h 4 | // 5 | // NOTE: Written by Linwei 6 | // 7 | //======================================================================*/ 8 | 9 | 10 | #ifndef __I_MATH_H__ 11 | #define __I_MATH_H__ 12 | 13 | 14 | typedef struct iMATRIX 15 | { 16 | union { 17 | struct { 18 | float _11, _12, _13, _14; 19 | float _21, _22, _23, _24; 20 | float _31, _32, _33, _34; 21 | float _41, _42, _43, _44; 22 | }; 23 | float v[4][4]; 24 | }; 25 | } iMatrix; 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | #define i_dot_product(x,y) ((x[0]*y[0])+(x[1]*y[1])+(x[2]*y[2])) 34 | #define i_vect_length(x) ((float)sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2])) 35 | 36 | void i_normalize_vector(float *vect3); 37 | void i_cross_product(const float *x,const float *y,float *z); 38 | void i_vector_product(const float *v1,const iMatrix *m,float *v2); 39 | void i_matrix_add(const iMatrix *m1,const iMatrix *m2,iMatrix *out); 40 | void i_matrix_sub(const iMatrix *m1,const iMatrix *m2,iMatrix *out); 41 | void i_matrix_mul(const iMatrix *m1,const iMatrix *m2,iMatrix *out); 42 | void i_matrix_identity(iMatrix *out); 43 | void i_translation_matrix(iMatrix *m,const float *pos); 44 | void i_scaling_matrix(iMatrix *m,const float *pos); 45 | void i_vectrotation_matrix(iMatrix *m,const float *v,const float a); 46 | 47 | /* in the result: Z Axis is point into screen Y Axis is point up X Axis is point right */ 48 | iMatrix* i_lookat(iMatrix *pOut,const float *pEye,const float *pAt,const float *pUp); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /vmbasic/iacciden.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/iacciden.cpp -------------------------------------------------------------------------------- /vmbasic/iacciden.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/iacciden.h -------------------------------------------------------------------------------- /vmbasic/ibitmap.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * ibitmap.h 4 | * 5 | * the definition of the bitmap, by linwei Feb.6 2002 6 | * 7 | **********************************************************************/ 8 | 9 | #ifndef __IBITMAP_H__ 10 | #define __IBITMAP_H__ 11 | 12 | 13 | /********************************************************************** 14 | * Definition of struct IBITMAP 15 | **********************************************************************/ 16 | 17 | struct IBITMAP 18 | { 19 | unsigned long bmWidth; /* Width of the bitmap */ 20 | unsigned long bmHeight; /* Height of the bitmap */ 21 | unsigned long bmDepth; /* Color depth of bitmap */ 22 | unsigned long bmPitch; /* Pitch, same as linear size */ 23 | unsigned long bmCode; /* Code for mode */ 24 | unsigned long bmInfo1; /* additional data 1 */ 25 | unsigned long bmInfo2; /* additional data 2 */ 26 | void *bmPixel; /* pixels data in bitmap */ 27 | void *bmData; /* additional pointer */ 28 | void**bmLines; /* pointer to each line in bitmap */ 29 | }; 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /vmbasic/ibitmapc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ibitmapc.cpp -------------------------------------------------------------------------------- /vmbasic/ibitmapc.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // ibitmap.h 4 | // 5 | // NOTE: by Linwei on 7-3-2002 6 | // 7 | //====================================================================== 8 | 9 | 10 | #ifndef __I_BITMAPC_H__ 11 | #define __I_BITMAPC_H__ 12 | 13 | #define IBITMAP_BLT_COLORKEY 1 14 | #define IBITMAP_BLT_CLIP 2 15 | 16 | #include "istream.h" 17 | 18 | class IBitmap 19 | { 20 | protected: 21 | int bmHeight; 22 | int bmWidth; 23 | int bmColorDepth; 24 | int bmLinearSize; 25 | char *bmPixel; 26 | int ClassCode; 27 | private: 28 | static void TransferN(char *dest,int x,int y,int LinearSize1,char *source,int left,int top,int w,int h,int LinearSize2,int pixelbyte); 29 | static void TransferX(char *dest,int x,int y,int LinearSize1,char *source,int left,int top,int w,int h,int LinearSize2,int pixelbyte,int colorkey); 30 | static void (*lpTransferN)(char *, int, int, int, char *, int, int, int, int, int, int); 31 | static void (*lpTransferX)(char *, int, int, int, char *, int, int, int, int, int, int, int); 32 | int LoadTGAStream(Istream *stream); 33 | int LoadBMPStream(Istream *stream); 34 | protected: 35 | int clip(int DestWidth,int DestHeight,int SrcWidth,int SrcHeight,int *xx,int *yy,int *myLeft,int *myTop,int *myRight,int *myBottom); 36 | int BlitSoft(int x,int y,IBitmap* bitmap,int left,int top,int w,int h,int colorkey,int mode); 37 | public: 38 | IBitmap(); 39 | virtual ~IBitmap(); 40 | 41 | virtual int Create(int width,int height,int colordepth); 42 | virtual int Release(); 43 | virtual int LoadFromStream(Istream *stream,int type); 44 | int GetClassCode(); 45 | int GetH(); 46 | int GetW(); 47 | int GetDepth(); 48 | virtual int Blit(int x,int y,IBitmap* bitmap,int left,int top,int w,int h,int mode,void *data); 49 | virtual void *Lock(int *LinearSize); 50 | virtual int Unlock(); 51 | virtual void Options(int mode, void *lptr); 52 | }; 53 | 54 | #endif 55 | 56 | 57 | -------------------------------------------------------------------------------- /vmbasic/icanvas.cpp: -------------------------------------------------------------------------------- 1 | #include "icanvas.h" 2 | #include "ifstream.h" 3 | #include 4 | #include 5 | 6 | void ICanvas::Fill(IColor c) 7 | { 8 | short c16; 9 | int x,y,c32; 10 | if (!Scanlines) return; 11 | switch (canBpp) 12 | { 13 | case 8: 14 | memset(*Scanlines,IColor8(c),canHeight*canLinearSize); 15 | break; 16 | case 15: 17 | c16=IColor15(c); 18 | case 16: 19 | if (canBpp==16) c16=IColor16(c); 20 | for (y=0;y=canWidth||y>=canHeight||*Scanlines==NULL) return; 40 | 41 | switch (canBpp) 42 | { 43 | case 8: 44 | Pixels8[y][x]=((c.r>>6)<<5)|((c.g>>5)<<3)|(c.b>>6); 45 | break; 46 | case 15: 47 | Pixels16[y][x]=IColor15(c); 48 | break; 49 | case 16: 50 | Pixels16[y][x]=IColor16(c); 51 | break; 52 | case 24: 53 | Pixels24[y][x]=c; 54 | break; 55 | case 32: 56 | char *b; 57 | b=(char*)&Pixels32[y][x]; 58 | *(IColor*)b=c; 59 | b[3]=0; 60 | break; 61 | } 62 | } 63 | void ICanvas::PixelBit(int x,int y,int c) 64 | { 65 | if (x<0||y<0||x>=canWidth||y>=canHeight||*Scanlines==NULL) return; 66 | switch (canBpp) 67 | { 68 | case 8: Pixels8[y][x]=(unsigned char)c; break; 69 | case 15: Pixels16[y][x]=(unsigned short)c; break; 70 | case 16: Pixels16[y][x]=(unsigned short)c; break; 71 | case 24: Pixels24[y][x]=*((IColor*)&c); break; 72 | case 32: Pixels32[y][x]=*((IColorA*)&c); break; 73 | } 74 | } 75 | 76 | IColor ICanvas::GetPixel(int x,int y) 77 | { 78 | static IColor c={0,0,0}; 79 | short t; 80 | if (x<0||y<0||x>=canWidth||y>=canHeight) return c; 81 | switch (canBpp) 82 | { 83 | case 8: 84 | c.r=Pixels8[y][x]; 85 | break; 86 | case 15: 87 | t=Pixels16[y][x]; 88 | c.r=(t&0x7c00)>>10; 89 | c.g=(t&0x03e0)>>5; 90 | c.b=(t&0x001f); 91 | break; 92 | case 16: 93 | t=Pixels16[y][x]; 94 | c.r=(t&0xf800)>>11; 95 | c.g=(t&0x07e0)>>5; 96 | c.b=(t&0x001f); 97 | break; 98 | case 24: 99 | c=Pixels24[y][x]; 100 | break; 101 | case 32: 102 | char *b; 103 | b=(char*)&Pixels32[y][x]; 104 | c=*(IColor*)b; 105 | break; 106 | } 107 | return c; 108 | } 109 | int ICanvas::GetPixelBit(int x,int y) 110 | { 111 | int t; 112 | IColor c; 113 | if (x<0||y<0||x>=canWidth||y>=canHeight) return 0; 114 | switch (canBpp) 115 | { 116 | case 8: t=Pixels8[y][x]; break; 117 | case 15: t=Pixels16[y][x]; break; 118 | case 16: t=Pixels16[y][x]; break; 119 | case 24: c=Pixels24[y][x]; t=c.r; t=(t<<16)|(*((unsigned short*)&c)); break; 120 | case 32: t=*((int*)&Pixels32[y][x]); break; 121 | } 122 | return t; 123 | } 124 | int ICanvas::ColorBit(IColor c) 125 | { 126 | int color; 127 | if (canBpp==8) color=IColor8(c); 128 | else if (canBpp==15) color=IColor15(c); 129 | else if (canBpp==16) color=IColor16(c); 130 | else color=*(int*)&c; 131 | return color; 132 | } 133 | void ICanvas::Rectangle(int left,int top,int right,int bottom) 134 | { 135 | int color=WorkColor; 136 | for (int x=left;xcolors[i].r),1); 165 | fs.Read(&(pal->colors[i].g),1); 166 | fs.Read(&(pal->colors[i].b),1); 167 | } 168 | fs.Close(); 169 | return 0; 170 | } 171 | fs.Read(&FileHeader,14); 172 | if (FileHeader[0]!=0x42 || FileHeader[1]!=0x4d) { 173 | fs.Close(); 174 | return -2; 175 | } 176 | int PalCount=((*(long*)&FileHeader[10])-54)/4; 177 | fs.Seek(54,ISTREAM_START); 178 | for (int i=0;icolors[i].r=ra.r; 182 | pal->colors[i].g=ra.g; 183 | pal->colors[i].b=ra.b; 184 | } 185 | fs.Close(); 186 | return 0; 187 | } 188 | 189 | IColorTable ICanvas::PalWin={ /* { b,g,r } */ 190 | 0, 0, 0 , 64, 0, 0 , 128, 0, 0 , 255, 0, 0 , 0, 32, 0 , 191 | 64, 32, 0 , 128, 32, 0 , 255, 32, 0 , 0, 64, 0 , 64, 64, 0 , 192 | 128, 64, 0 , 255, 64, 0 , 0, 96, 0 , 64, 96, 0 , 128, 96, 0 , 193 | 255, 96, 0 , 0,128, 0 , 64,128, 0 , 128,128, 0 , 255,128, 0 , 194 | 0,160, 0 , 64,160, 0 , 128,160, 0 , 255,160, 0 , 0,192, 0 , 195 | 64,192, 0 , 128,192, 0 , 255,192, 0 , 0,255, 0 , 64,255, 0 , 196 | 128,255, 0 , 255,255, 0 , 0, 0, 32 , 64, 0, 32 , 128, 0, 32 , 197 | 255, 0, 32 , 0, 32, 32 , 64, 32, 32 , 128, 32, 32 , 255, 32, 32 , 198 | 0, 64, 32 , 64, 64, 32 , 128, 64, 32 , 255, 64, 32 , 0, 96, 32 , 199 | 64, 96, 32 , 128, 96, 32 , 255, 96, 32 , 0,128, 32 , 64,128, 32 , 200 | 128,128, 32 , 255,128, 32 , 0,160, 32 , 64,160, 32 , 128,160, 32 , 201 | 255,160, 32 , 0,192, 32 , 64,192, 32 , 128,192, 32 , 255,192, 32 , 202 | 0,255, 32 , 64,255, 32 , 128,255, 32 , 255,255, 32 , 0, 0, 64 , 203 | 64, 0, 64 , 128, 0, 64 , 255, 0, 64 , 0, 32, 64 , 64, 32, 64 , 204 | 128, 32, 64 , 255, 32, 64 , 0, 64, 64 , 64, 64, 64 , 128, 64, 64 , 205 | 255, 64, 64 , 0, 96, 64 , 64, 96, 64 , 128, 96, 64 , 255, 96, 64 , 206 | 0,128, 64 , 64,128, 64 , 128,128, 64 , 255,128, 64 , 0,160, 64 , 207 | 64,160, 64 , 128,160, 64 , 255,160, 64 , 0,192, 64 , 64,192, 64 , 208 | 128,192, 64 , 255,192, 64 , 0,255, 64 , 64,255, 64 , 128,255, 64 , 209 | 255,255, 64 , 0, 0, 96 , 64, 0, 96 , 128, 0, 96 , 255, 0, 96 , 210 | 0, 32, 96 , 64, 32, 96 , 128, 32, 96 , 255, 32, 96 , 0, 64, 96 , 211 | 64, 64, 96 , 128, 64, 96 , 255, 64, 96 , 0, 96, 96 , 64, 96, 96 , 212 | 128, 96, 96 , 255, 96, 96 , 0,128, 96 , 64,128, 96 , 128,128, 96 , 213 | 255,128, 96 , 0,160, 96 , 64,160, 96 , 128,160, 96 , 255,160, 96 , 214 | 0,192, 96 , 64,192, 96 , 128,192, 96 , 255,192, 96 , 0,255, 96 , 215 | 64,255, 96 , 128,255, 96 , 255,255, 96 , 0, 0,128 , 64, 0,128 , 216 | 128, 0,128 , 255, 0,128 , 0, 32,128 , 64, 32,128 , 128, 32,128 , 217 | 255, 32,128 , 0, 64,128 , 64, 64,128 , 128, 64,128 , 255, 64,128 , 218 | 0, 96,128 , 64, 96,128 , 128, 96,128 , 255, 96,128 , 0,128,128 , 219 | 64,128,128 , 128,128,128 , 255,128,128 , 0,160,128 , 64,160,128 , 220 | 128,160,128 , 255,160,128 , 0,192,128 , 64,192,128 , 128,192,128 , 221 | 255,192,128 , 0,255,128 , 64,255,128 , 128,255,128 , 255,255,128 , 222 | 0, 0,160 , 64, 0,160 , 128, 0,160 , 255, 0,160 , 0, 32,160 , 223 | 64, 32,160 , 128, 32,160 , 255, 32,160 , 0, 64,160 , 64, 64,160 , 224 | 128, 64,160 , 255, 64,160 , 0, 96,160 , 64, 96,160 , 128, 96,160 , 225 | 255, 96,160 , 0,128,160 , 64,128,160 , 128,128,160 , 255,128,160 , 226 | 0,160,160 , 64,160,160 , 128,160,160 , 255,160,160 , 0,192,160 , 227 | 64,192,160 , 128,192,160 , 255,192,160 , 0,255,160 , 64,255,160 , 228 | 128,255,160 , 255,255,160 , 0, 0,192 , 64, 0,192 , 128, 0,192 , 229 | 255, 0,192 , 0, 32,192 , 64, 32,192 , 128, 32,192 , 255, 32,192 , 230 | 0, 64,192 , 64, 64,192 , 128, 64,192 , 255, 64,192 , 0, 96,192 , 231 | 64, 96,192 , 128, 96,192 , 255, 96,192 , 0,128,192 , 64,128,192 , 232 | 128,128,192 , 255,128,192 , 0,160,192 , 64,160,192 , 128,160,192 , 233 | 255,160,192 , 0,192,192 , 64,192,192 , 128,192,192 , 255,192,192 , 234 | 0,255,192 , 64,255,192 , 128,255,192 , 255,255,192 , 0, 0,255 , 235 | 64, 0,255 , 128, 0,255 , 255, 0,255 , 0, 32,255 , 64, 32,255 , 236 | 128, 32,255 , 255, 32,255 , 0, 64,255 , 64, 64,255 , 128, 64,255 , 237 | 255, 64,255 , 0, 96,255 , 64, 96,255 , 128, 96,255 , 255, 96,255 , 238 | 0,128,255 , 64,128,255 , 128,128,255 , 255,128,255 , 0,160,255 , 239 | 64,160,255 , 128,160,255 , 255,160,255 , 0,192,255 , 64,192,255 , 240 | 128,192,255 , 255,192,255 , 0,255,255 , 64,255,255 , 128,255,255 , 241 | 255,255,255 }; 242 | 243 | int ICanvas::PalMatch(IColorTable* pal,short r,short g,short b) 244 | { 245 | int l=0; 246 | for (int j=1024,i=0;i<256;i++) { 247 | int k=abs(pal->colors[i].r-r)+ 248 | abs(pal->colors[i].g-g)+ 249 | abs(pal->colors[i].b-b); 250 | if (kx2) { x=x1; x1=x2; x2=x; } 263 | for (x=x1;x<=x2;x++) PixelBit(x,y1,c); 264 | return; 265 | } 266 | if (x1==x2) 267 | { 268 | if (y1>y2) { y=y2; y2=y1; y1=y; } 269 | for (y=y1;y<=y2;y++) PixelBit(x1,y,c); 270 | return; 271 | } 272 | 273 | if ( abs(y2-y1) <= abs(x2-x1) ) 274 | { 275 | if ( (y2x2) ) 276 | { 277 | x=x2; y=y2; x2=x1; y2=y1; x1=x; y1=y; 278 | } 279 | if ( y2>=y1 && x2>=x1 ) 280 | { 281 | x=x2-x1; y=y2-y1; 282 | p=2*y; n=2*x-2*y; tn=x; 283 | while (x1<=x2) { 284 | if (tn>=0) tn-=p; 285 | else tn+=n, y1++; 286 | PixelBit(x1,y1,c); 287 | x1++; 288 | } 289 | } else { 290 | x=x2-x1; y=y2-y1; 291 | p=-2*y; n=2*x+2*y; tn=x; 292 | while (x1<=x2) { 293 | if (tn>=0) tn-=p; 294 | else tn+=n, y1--; 295 | PixelBit(x1,y1,c); 296 | x1++; 297 | } 298 | } 299 | } else { 300 | x=x1; x1=y2; y2=x; y=y1; y1=x2; x2=y; 301 | if ( (y2x2) ) 302 | { 303 | x=x2; y=y2; x2=x1; x1=x; y2=y1; y1=y; 304 | } 305 | if ( y2>=y1 && x2>=x1 ) 306 | { 307 | x=x2-x1; y=y2-y1; 308 | p=2*y; n=2*x-2*y; tn=x; 309 | while (x1<=x2) { 310 | if (tn>=0) tn-=p; 311 | else tn+=n, y1++; 312 | PixelBit(y1,x1,c); 313 | x1++; 314 | } 315 | } else { 316 | x=x2-x1; y=y2-y1; 317 | p=-2*y; n=2*x+2*y; tn=x; 318 | while (x1<=x2) { 319 | if (tn>=0) tn-=p; 320 | else { tn+=n; y1--; } 321 | PixelBit(y1,x1,c); 322 | x1++; 323 | } 324 | } 325 | } 326 | } 327 | 328 | void ICanvas::Circle(int x0,int y0,int r,int FillMode) 329 | { 330 | int cx=0, cy=r, df=1-r,d_e=3,d_se=-2*r+5, 331 | x,y,xmax,tn; 332 | int color=WorkColor; 333 | 334 | switch (FillMode) 335 | { 336 | case 0: 337 | y=r; x=0; xmax=(int)((double)r*sin(3.1415926/4) + 0.5); 338 | tn=(1-r*2); 339 | while (x=0) { 341 | tn+=( 6 + ((x-y)<<2) ); 342 | y--; 343 | } else tn+=( (x<<2) + 2 ); 344 | PixelBit(x0+y,y0+x,color); 345 | PixelBit(x0+x,y0+y,color); 346 | PixelBit(x0-x,y0+y,color); 347 | PixelBit(x0-y,y0+x,color); 348 | PixelBit(x0-y,y0-x,color); 349 | PixelBit(x0-x,y0-y,color); 350 | PixelBit(x0+x,y0-y,color); 351 | PixelBit(x0+y,y0-x,color); 352 | x++; 353 | } 354 | break; 355 | case 1: 356 | do { 357 | Line(x0-cy,y0-cx,x0-cy+(cy<<1),y0-cx); 358 | if (cx) Line(x0-cy,y0+cx,x0-cy+(cy<<1),y0+cx); 359 | if (df<0) { df+=d_e; d_e+=2; d_se+=2; } 360 | else { 361 | if (cx!=cy) { 362 | Line(x0-cx,y0-cy,x0+cy+(cx<<1),y0-cy); 363 | if (cy) Line(x0-cx,y0+cy,x0+cy+(cx<<1),y0+cy); 364 | } 365 | df+=d_se; d_e+=2; d_se+=4; 366 | cy--; 367 | } 368 | cx++; 369 | } while(cx<=cy); 370 | break; 371 | } 372 | } 373 | -------------------------------------------------------------------------------- /vmbasic/icanvas.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // icanvas.h 4 | // 5 | // NOTE: by Linwei on 7-6-2002 6 | // 7 | //====================================================================== 8 | 9 | #ifndef __I_CANVAS_H__ 10 | #define __I_CANVAS_H__ 11 | 12 | #include "ibitmapc.h" 13 | 14 | struct IColor { unsigned char b,g,r; }; 15 | struct IColorA { unsigned char b,g,r,a; }; 16 | struct IColorTable { IColor colors[256]; }; 17 | 18 | class ICanvas 19 | { 20 | protected: 21 | char bshr,gshr,gshl,rshr,rshl,Gap; 22 | int Mask; 23 | int canWidth; 24 | int canHeight; 25 | int canBpp; 26 | int canLinearSize; 27 | void **Scanlines; 28 | unsigned char **Pixels8; 29 | unsigned short **Pixels16; 30 | IColor **Pixels24; 31 | IColorA **Pixels32; 32 | protected: 33 | int WorkColor; 34 | static IColorTable PalWin; 35 | public: 36 | ICanvas(): Scanlines(0) {} 37 | virtual void Fill(IColor c); 38 | virtual void Pixel(int x,int y,IColor c); 39 | virtual IColor GetPixel(int x,int y); 40 | virtual void SetColor(IColor c) { WorkColor=ColorBit(c); } 41 | void SetColor(int c) { WorkColor=c; } 42 | void PixelBit(int x,int y,int c); 43 | int GetPixelBit(int x,int y); 44 | int ColorBit(IColor c); 45 | void Rectangle(int left,int top,int right,int bottom); 46 | void FillRactangle(int left,int top,int right,int bottom); 47 | void Line(int x1,int y1,int x2,int y2); 48 | void Circle(int x,int y,int r,int FillMode=0); 49 | int LoadPal(char *PalFile,IColorTable* pal); 50 | int LoadPalWin(IColorTable* pal) { *pal=PalWin; return 0; } 51 | int PalMatch(IColorTable* pal,short r,short g,short b); 52 | void* LockLine(int line) { return Scanlines[line]; } 53 | }; 54 | 55 | inline int IColorRGB(int r,int g,int b) { return (r<<16)|(g<<8)|(b); } 56 | inline int IColor8(IColor c) { return ((c.r>>5)<<5)|((c.g>>5)<<2)|(c.b>>6); } 57 | inline int IColor15(IColor c) { return ((int)(c.r>>3)<<10)|((int)(c.g>>3)<<5)|(c.b>>3); } 58 | inline int IColor16(IColor c) { return ((int)(c.r>>3)<<11)|((int)(c.g>>2)<<5)|(c.b>>3); } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /vmbasic/idxdraw.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/idxdraw.cpp -------------------------------------------------------------------------------- /vmbasic/idxdraw.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // idxdraw.h 4 | // 5 | // NOTE: by Linwei on 3-13-2003 6 | // 7 | //====================================================================== 8 | 9 | #ifndef __I_DXDRAW_H__ 10 | #define __I_DXDRAW_H__ 11 | 12 | #ifndef _WIN32 13 | #error This file can only be compiled under windows !! 14 | #endif 15 | 16 | #include "ibitmapc.h" 17 | #include "icanvas.h" 18 | #include "iscreen.h" 19 | 20 | #include 21 | #include 22 | 23 | #if DIRECTDRAW_VERSION < 0x500 24 | #error The version of DirectDraw must be 5.00 or higher 25 | #endif 26 | 27 | class iDDSurface; 28 | 29 | ////////////////////////////////////////////////////////////////////////////////// 30 | // iDDScreen Class 31 | ////////////////////////////////////////////////////////////////////////////////// 32 | class iDDScreen : public iScreen 33 | { 34 | public: 35 | iDDScreen(); 36 | virtual ~iDDScreen(); 37 | 38 | BOOL CreateFullScreen(void *hWnd, DWORD Width, DWORD Height, DWORD BPP, BOOL bVGA = FALSE); 39 | BOOL CreateWindowed(void *hWnd, int Width, int Height); 40 | BOOL ReleaseScreen(); 41 | void Restore(); 42 | void ScreenView() { Flip(); } 43 | HRESULT Flip(); 44 | 45 | iDDSurface* GetFrontSurface() { return m_lpDDSFront; } 46 | iDDSurface* GetBackSurface() { return m_lpDDSBack; } 47 | int GetDesktopBpp(); 48 | int GetScreenWidth() { return m_dwPixelWidth; } 49 | int GetScreenHeight() { return m_dwPixelHeight; } 50 | int GetScreenBPP() { return m_BPP; } 51 | char *GetErrorMsg(HRESULT DDRVAL); 52 | LPDIRECTDRAW2 lpGetDD() { return m_lpDD; } 53 | protected: 54 | int CreateDirectDraw(); 55 | protected: 56 | LPDIRECTDRAW2 m_lpDD; 57 | 58 | iDDSurface* m_lpDDSFront; 59 | iDDSurface* m_lpDDSBack; 60 | 61 | LPDIRECTDRAWSURFACE m_ZBuffer; 62 | LPDIRECTDRAWPALETTE m_lpDDPalette; 63 | LPDIRECTDRAWCLIPPER m_lpClipper; 64 | 65 | DWORD m_dwPixelWidth; 66 | DWORD m_dwPixelHeight; 67 | DWORD m_BPP; 68 | void* m_hWnd; 69 | 70 | BOOL m_bFullScreen; 71 | }; 72 | 73 | ////////////////////////////////////////////////////////////////////////////////// 74 | // iDDSurface Class 75 | ////////////////////////////////////////////////////////////////////////////////// 76 | class iDDSurface : public IBitmap, public ICanvas 77 | { 78 | public: 79 | iDDSurface(); 80 | virtual ~iDDSurface(); 81 | 82 | int CreateDDSurface(iDDScreen *Screen,DDSURFACEDESC *ddsd,void *DATA); 83 | int Create(int width,int height,int colordepth); 84 | int Release(); 85 | int SetScreen(iDDScreen *Screen) { this->Screen = Screen; return 0; } 86 | 87 | void *Lock(int* LinearSize); 88 | int Unlock(); 89 | 90 | void SetColorKey(DWORD ColorKey); 91 | int GetColorKey() { return ColorKey; } 92 | virtual int Blit(int x,int y,IBitmap *bitmap,int left,int top,int w,int h,int mode,void *data); 93 | 94 | LPDIRECTDRAWSURFACE lpGetDDS() { return m_lpDDS; } 95 | int CreateBackSurface(iDDSurface *Front); 96 | protected: 97 | DWORD ColorKey; 98 | int DDrawBlit(int x,int y,iDDSurface* bitmap,int left,int top,int w,int h,int mode,void *data); 99 | protected: 100 | HDC m_DC; 101 | int m_ColorKey; 102 | bool isLocked; 103 | 104 | RECT SrcRect; 105 | RECT DestRect; 106 | HFONT m_Font; 107 | DDSURFACEDESC m_DDSD; 108 | LPDIRECTDRAWSURFACE m_lpDDS; 109 | iDDScreen *Screen; 110 | }; 111 | 112 | #endif 113 | 114 | -------------------------------------------------------------------------------- /vmbasic/ifstream.cpp: -------------------------------------------------------------------------------- 1 | #include "ifstream.h" 2 | #include 3 | #include 4 | 5 | /////////////////////////////////////////////////////////////////////////// 6 | Ixstream::Ixstream() 7 | { 8 | BindStream=0; 9 | Mode=0; 10 | } 11 | 12 | Istream* Ixstream::GetBind() 13 | { 14 | return BindStream; 15 | } 16 | int Ixstream::Bind(Istream *stream) 17 | { 18 | BindStream=stream; 19 | return 0; 20 | } 21 | int Ixstream::Eof() 22 | { 23 | if (BindStream) return BindStream->Eof(); 24 | return DoEof(); 25 | } 26 | int Ixstream::Seek(long Pos,int mode) 27 | { 28 | if (BindStream) return BindStream->Seek(Pos,mode); 29 | return DoSeek(Pos,mode); 30 | } 31 | int Ixstream::Read(void *buffer,long size) 32 | { 33 | if (BindStream) return BindStream->Read(buffer,size); 34 | return DoRead(buffer,size); 35 | } 36 | int Ixstream::Write(void *buffer,long size) 37 | { 38 | if (BindStream) return BindStream->Write(buffer,size); 39 | return DoWrite(buffer,size); 40 | } 41 | int Ixstream::GetCh() 42 | { 43 | if (BindStream) return BindStream->GetCh(); 44 | return DoGetCh(); 45 | } 46 | int Ixstream::PutCh(int c) 47 | { 48 | if (BindStream) return BindStream->PutCh(c); 49 | return DoPutCh(c); 50 | } 51 | int Ixstream::GetPos() 52 | { 53 | if (BindStream) return BindStream->GetPos(); 54 | return DoGetPos(); 55 | } 56 | void Ixstream::VarArg(char *format,...) 57 | { 58 | static char buf[1000]; 59 | va_list argptr; 60 | va_start(argptr,format); 61 | vsprintf(buf,format,argptr); 62 | va_end(argptr); 63 | Write(buf,strlen(buf)); 64 | } 65 | Ixstream& Ixstream::operator<<(char *s) 66 | { 67 | Write(s,strlen(s)); 68 | return *this; 69 | } 70 | /////////////////////////////////////////////////////////////////////////// 71 | int Ifstream::Exist(char *filename) 72 | { 73 | FILE *fp; 74 | if ((fp=fopen(filename,"rb"))==NULL) return 0; 75 | fclose(fp); 76 | return 1; 77 | } 78 | 79 | int Ifstream::Open(char *filename,int mode) 80 | { 81 | int BINARY=(mode&ISTREAM_BINARY); 82 | char *m; 83 | Close(); 84 | if (!filename) { stdio=1; Mode=mode; return 0; } 85 | if (BINARY) mode^=ISTREAM_BINARY; 86 | if (mode==ISTREAM_READ) { 87 | if (BINARY) m="rb"; else m="r"; 88 | f=fopen(filename,m); 89 | } else if (mode==ISTREAM_WRITE) { 90 | if (BINARY) m="wb"; else m="w"; 91 | f=fopen(filename,m); 92 | } else if (mode==(ISTREAM_READ|ISTREAM_WRITE)) { 93 | if (Exist(filename)) { 94 | if (BINARY) m="rb+"; else m="r+"; 95 | } else { 96 | if (BINARY) m="wb+"; else m="w+"; 97 | } 98 | f=fopen(filename,m); 99 | } else if (mode==ISTREAM_APPEND) { 100 | if (BINARY) m="ab+"; else m="a+"; 101 | f=fopen(filename,m); 102 | } else if (mode==log) { 103 | FileName.SetLength(0); 104 | FileName.AutoSize(1); 105 | for (int i=0;filename[i];i++) FileName[i]=filename[i]; 106 | FileName[FileName.GetLength()]=0; 107 | FileName.AutoSize(0); 108 | Mode=mode; 109 | return 0; 110 | } 111 | if (!f) return -1; 112 | Mode=mode; 113 | return 0; 114 | } 115 | 116 | int Ifstream::Close() 117 | { 118 | if (f) fclose(f); 119 | f=NULL; 120 | stdio=0; 121 | FileName.SetLength(0); 122 | FileName.AutoSize(0); 123 | return 0; 124 | } 125 | 126 | Ifstream::Ifstream() 127 | { 128 | f=NULL; 129 | stdio=0; 130 | } 131 | 132 | Ifstream::Ifstream(char *filename,int mode) 133 | { 134 | f=NULL; 135 | stdio=0; 136 | Open(filename,mode); 137 | } 138 | 139 | Ifstream::~Ifstream() 140 | { 141 | Close(); 142 | } 143 | 144 | int Ifstream::DoSeek(long pos,int mode) 145 | { 146 | switch (mode) 147 | { 148 | case ISTREAM_START: mode=SEEK_SET; break; 149 | case ISTREAM_CURRENT: mode=SEEK_CUR; break; 150 | case ISTREAM_END: mode=SEEK_END; break; 151 | } 152 | if (!f) return -1; 153 | return fseek(f,pos,mode); 154 | } 155 | 156 | int Ifstream::DoRead(void *buffer,long size) 157 | { 158 | if (stdio) { 159 | for (int i=0;i=text.GetLength()) return 1; 225 | return 0; 226 | } 227 | 228 | int Imstream::DoRead(void *buffer,long size) 229 | { 230 | if (pos>=text.GetLength()) return 0; 231 | size=(pos+size<=text.GetLength())?size:(text.GetLength()-pos); 232 | memcpy(buffer,&text[pos],size); 233 | pos+=size; 234 | return size; 235 | } 236 | int Imstream::DoWrite(void *buffer,long size) 237 | { 238 | if (text.SetLength(pos+size)) return 0; 239 | memcpy(&text[pos],buffer,size); 240 | pos+=size; 241 | return size; 242 | } 243 | int Imstream::DoSeek(long p,int mode) 244 | { 245 | switch (mode) 246 | { 247 | case ISTREAM_START: pos=p; break; 248 | case ISTREAM_CURRENT: pos+=p; break; 249 | case ISTREAM_END: pos=text.GetLength()+p; break; 250 | } 251 | return 0; 252 | } 253 | int Imstream::DoGetPos() 254 | { 255 | return pos; 256 | } 257 | int Imstream::DoGetCh() 258 | { 259 | if (pos>=text.GetLength()) return -1; 260 | return text[pos++]; 261 | } 262 | int Imstream::DoPutCh(int ch) 263 | { 264 | text[pos++]=ch; 265 | return 0; 266 | } 267 | char *Imstream::Lock() 268 | { 269 | return &text[0]; 270 | } 271 | void Imstream::Unlock() 272 | { 273 | } 274 | Imstream::Imstream(char* str) 275 | { 276 | pos=0; 277 | text.SetLength(0); 278 | text.AutoSize(1); 279 | Write(str, strlen(str)); 280 | } 281 | Imstream::Imstream() 282 | { 283 | pos=0; 284 | text.SetLength(0); 285 | text.AutoSize(1); 286 | } 287 | Imstream::Imstream(void *buffer,int len) 288 | { 289 | pos=0; 290 | text.SetLength(0); 291 | text.AutoSize(1); 292 | Write(buffer,len); 293 | } 294 | void Imstream::Clear() 295 | { 296 | text.SetLength(0); 297 | pos=0; 298 | } 299 | char& Imstream::operator[](int i) 300 | { 301 | return text[i]; 302 | } 303 | 304 | -------------------------------------------------------------------------------- /vmbasic/ifstream.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ifstream.h -------------------------------------------------------------------------------- /vmbasic/igdibmp.cpp: -------------------------------------------------------------------------------- 1 | #include "igdibmp.h" 2 | #include 3 | #include 4 | 5 | IGDIBitmap::IGDIBitmap() 6 | { 7 | ClassCode=1; 8 | ZeroMemory(&bmInfo,sizeof(bmInfo)); 9 | bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); 10 | bmInfo.bmiHeader.biPlanes=1; 11 | Scanlines=NULL; hDC=NULL; Handle=NULL; 12 | bshr=0; rshr=0; Gap=0; gshl=0; 13 | gshr=0; rshl=0; Mask=0; 14 | } 15 | 16 | IGDIBitmap::~IGDIBitmap() 17 | { 18 | Release(); 19 | } 20 | 21 | int IGDIBitmap::Blit(int x,int y,IBitmap* bitmap,int left,int top,int w,int h,int mode,void *data) 22 | { 23 | int retcode=0; 24 | 25 | if (bitmap==NULL) return -1; 26 | 27 | if (bitmap->GetClassCode()==ClassCode) { 28 | if (mode >= 0 && bitmap->GetDepth() == bmColorDepth) 29 | IBitmap::Blit(x,y,bitmap,left,top,w,h,mode,data); 30 | else 31 | BitBlt(hDC,x,y,w,h,((IGDIBitmap*)bitmap)->GetDC(),left,top,SRCCOPY); 32 | } else { 33 | retcode=IBitmap::Blit(x,y,bitmap,left,top,w,h,mode,data); 34 | } 35 | return retcode; 36 | } 37 | 38 | void IGDIBitmap::BlitDC(HDC dc,int x,int y,int w,int h) 39 | { 40 | if (dc!=0&&w==bmWidth&&h==bmHeight) BitBlt(dc,x,y,w,h,hDC,0,0,SRCCOPY); 41 | else StretchBlt(dc,x,y,w,h,hDC,0,0,bmWidth,bmHeight,SRCCOPY); 42 | } 43 | int IGDIBitmap::Create(int width,int height,int colordepth) 44 | { 45 | Release(); 46 | SetInterface(NULL,width,height,colordepth,0); 47 | Handle=CreateDIBSection(0,(BITMAPINFO*)&bmInfo,0,(void**)&bmPixel,NULL,0); 48 | if (!Handle) return -1; 49 | hDC=CreateCompatibleDC(0); 50 | if (!hDC) { Release(); return -3; } 51 | SelectObject(hDC,Handle); 52 | InitPixels(bmPixel); 53 | 54 | return 0; 55 | } 56 | 57 | int IGDIBitmap::Release() 58 | { 59 | if (hDC) DeleteDC(hDC); 60 | if (Handle) DeleteObject(Handle); 61 | if (Scanlines) delete []Scanlines; 62 | hDC=NULL; 63 | Handle=NULL; 64 | Scanlines=NULL; 65 | bmPixel=NULL; 66 | IBitmap::Release(); 67 | return 0; 68 | } 69 | 70 | int IGDIBitmap::SetInterface(char *Bits,int Width,int Height,int fBpp,int fMask) 71 | { 72 | if (fBpp==0) { //default Bpp is current screen 73 | HDC sDC=::GetDC(0); 74 | fBpp=GetDeviceCaps(sDC,BITSPIXEL); 75 | ReleaseDC(0,sDC); 76 | } 77 | if (fMask==0) { 78 | if (fBpp==16) fMask=Get16Mask(); else 79 | if (fBpp==32) fMask=888; 80 | } 81 | bmColorDepth=fBpp; 82 | int Bpp=bmColorDepth; 83 | bmLinearSize=((Width*(fBpp>>3)+3)>>2)<<2; 84 | 85 | bmWidth=Width; 86 | bmHeight=Height; 87 | BWidth=((Width*fBpp+31)>>5)<<2; 88 | bmInfo.bmiHeader.biHeight=-abs(Height); 89 | bmInfo.bmiHeader.biWidth=Width; 90 | bmInfo.bmiHeader.biSizeImage=BWidth*Height; 91 | 92 | if (Bpp<8) Gap=BWidth-(Width/(8/Bpp)); else 93 | if (Bpp>8) Gap=BWidth-(Width*(Bpp/8)); 94 | else Gap=BWidth-Width; 95 | 96 | Mask=fMask; 97 | int rMask,gMask,bMask; 98 | 99 | if((Bpp==16)||(Bpp==32)) { 100 | bmInfo.bmiHeader.biCompression=BI_BITFIELDS; 101 | if (fMask==555) { 102 | rMask=31<<10; 103 | gMask=31<<5; 104 | bMask=31; 105 | } else if (fMask==565) { 106 | rMask=31<<11; 107 | gMask=63<<5; 108 | bMask=31; 109 | } else if (fMask==888) { 110 | bMask=255<<16; 111 | gMask=255<<8; 112 | rMask=255; 113 | } 114 | } else bmInfo.bmiHeader.biCompression=BI_RGB; 115 | bmInfo.r=rMask; 116 | bmInfo.g=gMask; 117 | bmInfo.b=bMask; 118 | bmInfo.bmiHeader.biBitCount=Bpp; 119 | if (Bits!=NULL) return InitPixels(Bits); 120 | return 0; 121 | } 122 | 123 | int IGDIBitmap::InitPixels(void *fBits) 124 | { 125 | int x,i; 126 | bmPixel=(char*)fBits; 127 | Scanlines=new void*[bmHeight]; 128 | if (!Scanlines) return -2; 129 | for (i=0,x=0;i>6)<<5)|((c.g>>5)<<3)|(c.b>>6),bmHeight*bmLinearSize); 164 | break; 165 | case 15: 166 | c16=IColor15(c); 167 | case 16: 168 | if (bmColorDepth==16) c16=IColor16(c); 169 | for (y=0;y=bmWidth||y>=bmHeight||bmPixel==NULL) return; 189 | switch (bmColorDepth) 190 | { 191 | case 8: 192 | Pixels8[y][x]=((c.r>>6)<<5)|((c.g>>5)<<3)|(c.b>>6); 193 | break; 194 | case 15: 195 | Pixels16[y][x]=IColor15(c); 196 | break; 197 | case 16: 198 | Pixels16[y][x]=IColor16(c); 199 | break; 200 | case 24: 201 | Pixels24[y][x]=c; 202 | break; 203 | case 32: 204 | char *b; 205 | b=(char*)&Pixels32[y][x]; 206 | *(IColor*)b=c; 207 | b[3]=0; 208 | break; 209 | } 210 | } 211 | 212 | IColor IGDIBitmap::GetPixel(int x,int y) 213 | { 214 | static IColor c={0,0,0}; 215 | short t; 216 | if (x<0||y<0||x>=bmWidth||y>=bmHeight) return c; 217 | switch (bmColorDepth) 218 | { 219 | case 8: 220 | c.r=Pixels8[y][x]; 221 | break; 222 | case 15: 223 | t=Pixels16[y][x]; 224 | c.r=(t&0x7c00)>>10; 225 | c.g=(t&0x03e0)>>5; 226 | c.b=(t&0x001f); 227 | break; 228 | case 16: 229 | t=Pixels16[y][x]; 230 | c.r=(t&0xf800)>>11; 231 | c.g=(t&0x07e0)>>5; 232 | c.b=(t&0x001f); 233 | break; 234 | case 24: 235 | c=Pixels24[y][x]; 236 | break; 237 | case 32: 238 | char *b; 239 | b=(char*)&Pixels32[y][x]; 240 | c=*(IColor*)b; 241 | break; 242 | } 243 | return c; 244 | } 245 | 246 | int IGDIBitmap::LoadFromStream(Istream* stream,int type) 247 | { 248 | int ret=IBitmap::LoadFromStream(stream,type); 249 | if (ret==0) { 250 | int i,j; 251 | int LinearSize; 252 | if (bmColorDepth==24) { 253 | char *data=(char*)Lock(&LinearSize),k; 254 | for (j=0;j 22 | 23 | class IGDIBitmap:public IBitmap,public ICanvas 24 | { 25 | private: 26 | HDC hDC; 27 | HBITMAP Handle; 28 | struct BITMAPINFOX 29 | { 30 | BITMAPINFOHEADER bmiHeader; 31 | long r,g,b,e; 32 | }; 33 | BITMAPINFOX bmInfo; 34 | int BWidth; 35 | int SetInterface(char *Bits,int Width,int Height,int Bpp,int fMask); 36 | int Get16Mask(); 37 | int InitPixels(void *fBits); 38 | public: 39 | IGDIBitmap(); 40 | virtual ~IGDIBitmap(); 41 | 42 | virtual int Blit(int x,int y,IBitmap* bitmap,int left,int top,int w,int h,int mode,void *data); 43 | virtual int LoadFromStream(Istream* stream,int type); 44 | void BlitDC(HDC dc,int x,int y,int w,int h); 45 | int Create(int width,int height,int colordepth); 46 | int Release(); 47 | HDC GetDC(); 48 | void Fill(IColor c); 49 | void Pixel(int x,int y,IColor c); 50 | IColor GetPixel(int x,int y); 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /vmbasic/iini.cpp: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // iini.cpp 4 | // 5 | // NOTE: INI file operation 6 | // By Lin Wei 15/4/2002 7 | // 8 | //====================================================================== 9 | 10 | 11 | #include "iini.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef IS_SPACEX 19 | #undef IS_SPACEX 20 | #endif 21 | 22 | #define IS_SPACEX(x) ((x==' ')||(x=='\t')||(x=='\r')||(x=='\n')) 23 | 24 | int IIni::Startup() 25 | { 26 | IniText=NULL; 27 | Items=NULL; 28 | FileName=NULL; 29 | TextLen=0; 30 | ItemNum=0; 31 | return 0; 32 | } 33 | IIni::IIni() 34 | { 35 | Startup(); 36 | } 37 | IIni::~IIni() 38 | { 39 | Close(); 40 | } 41 | IIni::IIni(char *filename) 42 | { 43 | Startup(); 44 | Open(filename); 45 | } 46 | int IIni::Save(char *filename) 47 | { 48 | FILE *f; 49 | if (!filename) filename=FileName; 50 | if (filename&&Items&&IniText) 51 | { 52 | f=fopen(filename,"w"); 53 | if (f) 54 | { 55 | fwrite(IniText,TextLen,1,f); 56 | fclose(f); 57 | } 58 | } 59 | return 0; 60 | } 61 | int IIni::Close() 62 | { 63 | if (IniText) delete IniText; 64 | if (Items) delete Items; 65 | if (FileName) delete FileName; 66 | IniText=NULL; 67 | Items=NULL; 68 | FileName=NULL; 69 | TextLen=0; 70 | ItemNum=0; 71 | return 0; 72 | } 73 | int IIni::Open(char *filename) 74 | { 75 | FILE *f; 76 | int ch,i; 77 | 78 | Close(); 79 | FileName=new char[strlen(filename)+1]; 80 | if (!FileName) return -1; 81 | strcpy(FileName,filename); 82 | if ((f=fopen(filename,"r"))==NULL) 83 | if ((f=fopen(filename,"w+"))==NULL) { 84 | delete FileName; 85 | FileName=NULL; 86 | return -2; 87 | } 88 | fseek(f,0,SEEK_END); 89 | TextLen=ftell(f); 90 | fseek(f,0,SEEK_SET); 91 | IniText=new char[TextLen+10]; 92 | memset(IniText,0,TextLen+10); 93 | if (!IniText) 94 | { 95 | delete FileName; 96 | FileName=NULL; 97 | fclose(f); 98 | return -3; 99 | } 100 | for (i=0;!feof(f);) { 101 | ch=fgetc(f); 102 | if (ch!='\r'&&ch>=0) IniText[i++]=(char)ch; 103 | } 104 | TextLen=i; 105 | fclose(f); 106 | if (UpdateItem()) { 107 | Close(); 108 | return -4; 109 | } 110 | return 0; 111 | } 112 | int IIni::SkipMemo(int pos) 113 | { 114 | 115 | if (!IniText) return 0; 116 | while (IS_SPACEX(IniText[pos])&&pos=0) while (IniText[k]!='='&&IniText[k]!='\n'&&i=0)?(k+1):-1; 177 | } 178 | 179 | int IIni::ReadInt(char *item,char *string) 180 | { 181 | int index,len; 182 | char *data,*p; 183 | index=FindData(item,string,&len); 184 | if (index<0) return -1; 185 | data=new char[len+1]; 186 | if (!data) return -1; 187 | memcpy(data,&IniText[index],len); 188 | data[len]=0; 189 | p = data; 190 | if (p[0]=='0'&&(p[1]=='x'||p[1]=='X')) 191 | sscanf(p + 2, "%x", &index); 192 | else 193 | index=atoi(data); 194 | delete data; 195 | return index; 196 | } 197 | 198 | char *IIni::ReadText(char *item,char *string,char *buffer,int len) 199 | { 200 | static char line[1024]; 201 | int index,tlen; 202 | if (!buffer||len<1) buffer=line,len=1024; 203 | len--; line[0]=0; 204 | index=FindData(item,string,&tlen); 205 | if (index<0) return buffer; 206 | len=(len0) if (IniText[itempos-1]=='\n') itempos--; 228 | sprintf(buff+itempos,"%s[%s]\n",(itempos)?"\n":"",item); 229 | delete IniText; 230 | IniText=buff; 231 | TextLen=itempos+len1+3+((itempos)?1:0); 232 | if (UpdateItem()) return -2; 233 | } 234 | base=FindItem(item); 235 | if (base<0) return -3; 236 | itempos=FindData(item,name,&size); 237 | if (itempos<0) 238 | { 239 | if (Items[base+1]!=-1) itempos=Items[base+1]; 240 | else itempos=TextLen; 241 | buff=new char[TextLen+len2+len3+10]; 242 | if (!buff) return -1; 243 | memcpy(buff,IniText,itempos); 244 | base=itempos; 245 | if (itempos>0) if (IniText[itempos-1]=='\n') itempos--; 246 | sprintf(buff+itempos,"\n%s=%s",name,string); 247 | memcpy(buff+itempos+len2+len3+2,IniText+itempos,TextLen-base); 248 | delete IniText; 249 | IniText=buff; 250 | TextLen=itempos+len2+len3+2+TextLen-base; 251 | if (UpdateItem()) return -3; 252 | } else { 253 | buff=new char[TextLen+len3-size+10]; 254 | if (!buff) return -1; 255 | memcpy(buff,IniText,itempos); 256 | sprintf(buff+itempos,"%s",string); 257 | memcpy(buff+itempos+len3,IniText+itempos+size,TextLen-itempos-size); 258 | delete IniText; 259 | IniText=buff; 260 | TextLen=TextLen+len3-size; 261 | if (UpdateItem()) return -4; 262 | } 263 | return 0; 264 | } 265 | 266 | int IIni::Write(char *item,char *name,int value) 267 | { 268 | char line[20]; 269 | sprintf(line,"%d",value); 270 | return Write(item,name,line); 271 | } 272 | 273 | int IIni::ItemCount() 274 | { 275 | return ItemNum; 276 | } 277 | 278 | char* IIni::ItemName(int index, char *buffer, int len) 279 | { 280 | static char line[1024]; 281 | int pos,i,n; 282 | if (!buffer||len<1) buffer=line,len=1024; 283 | len--; line[0]=0; 284 | if (index<0||index>=ItemNum) return buffer; 285 | pos=Items[index]+1; 286 | if (pos<0) return buffer; 287 | for (i=pos,n=0;IniText[i]!='\n'&&IniText[i]!=']'&&i 0 && IS_SPACEX(p[len - 1]); len--); 303 | for (int i = 0; i <= len; i++) 304 | string[i] = p[i]; 305 | string[len] = 0; 306 | return string; 307 | } 308 | 309 | -------------------------------------------------------------------------------- /vmbasic/iini.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // iini.h 4 | // 5 | // NOTE: INI file operation 6 | // By Lin Wei 15/4/2002 7 | // 8 | //====================================================================== 9 | 10 | #ifndef __I_LWINDOWS_H__ 11 | #define __I_LWINDOWS_H__ 12 | 13 | #ifndef __cplusplus 14 | #error This file can only be compiled with a C++ compiler !! 15 | #endif 16 | 17 | class IIni 18 | { 19 | private: 20 | char *IniText; 21 | int TextLen; 22 | int ItemNum; 23 | int *Items; 24 | char *FileName; 25 | int SkipMemo(int pos); 26 | int UpdateItem(); 27 | int FindItem(char *item); 28 | int FindData(char *item,char *name,int *len); 29 | int Startup(); 30 | 31 | public: 32 | ~IIni(); 33 | IIni(); 34 | IIni(char *filename); 35 | int Open(char *filename); 36 | int Close(); 37 | int Save(char *filename=0); 38 | 39 | int ItemCount(); 40 | char*ItemName(int index, char *text, int len); 41 | 42 | int ReadInt(char *section,char *name); 43 | char*ReadText(char *section,char *name,char *buffer,int len); 44 | int Write(char *section,char *name,char *string); 45 | int Write(char *section,char *name,int value); 46 | 47 | char*StringChop(char *string); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /vmbasic/ikeybord.h: -------------------------------------------------------------------------------- 1 | #ifndef __I_KEYBOARD_H__ 2 | #define __I_KEYBOARD_H__ 3 | 4 | #ifndef __cplusplus 5 | #error This file can only be compiled with a C++ compiler !! 6 | #endif 7 | 8 | class IKeyBuffer 9 | { 10 | protected: 11 | int KeyP1,KeyP2; 12 | int Block; 13 | char KeyBuffer[1024]; 14 | int KeyStatus[256]; 15 | public: 16 | IKeyBuffer(int n=0) 17 | { 18 | int i; 19 | KeyP1=0; 20 | KeyP2=0; 21 | Block=(n)?n:32; 22 | Block=(Block>1024)?Block:1024; 23 | for (i=0;i<256;i++) KeyStatus[i]=0; 24 | } 25 | int GetCh() 26 | { 27 | int c; 28 | if (KeyP1==KeyP2) return -1; 29 | KeyP2=(KeyP2+1)%Block; 30 | c=KeyBuffer[KeyP2]; 31 | return c; 32 | } 33 | int UnGetCh(char c) 34 | { 35 | int newp=(KeyP1+1)%Block; 36 | if (newp==KeyP2) return -1; 37 | KeyBuffer[newp]=c; 38 | KeyP1=newp; 39 | return 0; 40 | } 41 | int Clear() { KeyP1=KeyP2=0; return 0; } 42 | int Count() { return (KeyP1+Block-KeyP2)%Block; } 43 | int& operator[](int i) { return KeyStatus[(DWORD)i&255]; } 44 | }; 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /vmbasic/imagine.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="imagine" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=imagine - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "imagine.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "imagine.mak" CFG="imagine - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "imagine - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "imagine - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "imagine - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "objs\release" 41 | # PROP Intermediate_Dir "objs\release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD BASE RSC /l 0x804 /d "NDEBUG" 46 | # ADD RSC /l 0x804 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo /NODEFAULTLIB 53 | 54 | !ELSEIF "$(CFG)" == "imagine - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "objs\debug" 64 | # PROP Intermediate_Dir "objs\debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x804 /d "_DEBUG" 69 | # ADD RSC /l 0x804 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "imagine - Win32 Release" 82 | # Name "imagine - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=.\i_math.c 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=.\iacciden.cpp 93 | # End Source File 94 | # Begin Source File 95 | 96 | SOURCE=.\ibitmapc.cpp 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=.\icanvas.cpp 101 | # End Source File 102 | # Begin Source File 103 | 104 | SOURCE=.\idxdraw.cpp 105 | # End Source File 106 | # Begin Source File 107 | 108 | SOURCE=.\ifstream.cpp 109 | # End Source File 110 | # Begin Source File 111 | 112 | SOURCE=.\igdibmp.cpp 113 | # End Source File 114 | # Begin Source File 115 | 116 | SOURCE=.\iini.cpp 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE=.\iplatfrm.cpp 121 | # End Source File 122 | # Begin Source File 123 | 124 | SOURCE=.\ivmsbeta.cpp 125 | # End Source File 126 | # Begin Source File 127 | 128 | SOURCE=.\ivmsca.cpp 129 | # End Source File 130 | # Begin Source File 131 | 132 | SOURCE=.\ivmscexp.cpp 133 | # End Source File 134 | # Begin Source File 135 | 136 | SOURCE=.\ivmscs.cpp 137 | # End Source File 138 | # Begin Source File 139 | 140 | SOURCE=.\ivmscv.cpp 141 | # End Source File 142 | # End Group 143 | # Begin Group "Header Files" 144 | 145 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 146 | # Begin Source File 147 | 148 | SOURCE=.\EasyGl.h 149 | # End Source File 150 | # Begin Source File 151 | 152 | SOURCE=.\i_math.h 153 | # End Source File 154 | # Begin Source File 155 | 156 | SOURCE=.\iacciden.h 157 | # End Source File 158 | # Begin Source File 159 | 160 | SOURCE=.\ibitmap.h 161 | # End Source File 162 | # Begin Source File 163 | 164 | SOURCE=.\ibitmapc.h 165 | # End Source File 166 | # Begin Source File 167 | 168 | SOURCE=.\icanvas.h 169 | # End Source File 170 | # Begin Source File 171 | 172 | SOURCE=.\idxdraw.h 173 | # End Source File 174 | # Begin Source File 175 | 176 | SOURCE=.\ifstream.h 177 | # End Source File 178 | # Begin Source File 179 | 180 | SOURCE=.\igdibmp.h 181 | # End Source File 182 | # Begin Source File 183 | 184 | SOURCE=.\iini.h 185 | # End Source File 186 | # Begin Source File 187 | 188 | SOURCE=.\ikeybord.h 189 | # End Source File 190 | # Begin Source File 191 | 192 | SOURCE=.\iplatfrm.h 193 | # End Source File 194 | # Begin Source File 195 | 196 | SOURCE=.\iscreen.h 197 | # End Source File 198 | # Begin Source File 199 | 200 | SOURCE=.\istream.h 201 | # End Source File 202 | # Begin Source File 203 | 204 | SOURCE=.\istring.h 205 | # End Source File 206 | # Begin Source File 207 | 208 | SOURCE=.\itemplat.h 209 | # End Source File 210 | # Begin Source File 211 | 212 | SOURCE=.\ivector.h 213 | # End Source File 214 | # Begin Source File 215 | 216 | SOURCE=.\ivms.h 217 | # End Source File 218 | # Begin Source File 219 | 220 | SOURCE=.\ivmsbeta.h 221 | # End Source File 222 | # Begin Source File 223 | 224 | SOURCE=.\ivmsca.h 225 | # End Source File 226 | # Begin Source File 227 | 228 | SOURCE=.\ivmscc.h 229 | # End Source File 230 | # End Group 231 | # End Target 232 | # End Project 233 | -------------------------------------------------------------------------------- /vmbasic/imagine.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "imagine"=".\imagine.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /vmbasic/imapps/console/vmbasic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/console/vmbasic.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/console/vmbeta.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/console/vmbeta.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/Res/IconMain.TGA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbeta/Res/IconMain.TGA -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/Res/IconMain.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbeta/Res/IconMain.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/Terminal.h: -------------------------------------------------------------------------------- 1 | #ifndef TERMINAL_H 2 | #define TERMINAL_H 3 | 4 | #include "VmWin.h" 5 | #include "..\..\itemplat.h" 6 | #include "..\..\ifstream.h" 7 | 8 | class Terminal 9 | { 10 | public: 11 | IDataArray Text; 12 | protected: 13 | HWND hWnd; 14 | int MaxLine,Tp; 15 | int TabSpace; 16 | void DoPutCh(int c) { 17 | if (c=='\n'||c=='\r') { Text[Tp++]='\r'; Text[Tp++]='\n'; } else 18 | //if (c=='\r') { for (;Tp>0&&Text[Tp-1]!='\n';Tp--); Text[Tp]=' '; } else 19 | if (c==8) { if (Text[Tp-1]!='\n'&&Tp>0) Text[--Tp]=' '; } else 20 | if (c=='\t') { 21 | int i,ntp; 22 | for (i=Tp;i>=0&&Text[i]!='\n';i--); 23 | ntp=i+(((Tp-i)/TabSpace)+1)*TabSpace; 24 | for (;Tp<=ntp;Tp++) Text[Tp]=' '; 25 | } else Text[Tp++]=c; 26 | } 27 | int GetCh() 28 | { 29 | int c; 30 | do { 31 | c=KeyBuffer.GetCh(); 32 | WinMessage(); 33 | } while (c<0); 34 | return c; 35 | } 36 | public: 37 | Terminal() { Clear(); MaxLine=1000; TabSpace=10; } 38 | void SetWindow(HWND hWnd) { this->hWnd=hWnd; } 39 | void Clear() 40 | { 41 | Text.SetLength(0); 42 | Text.SetAutoAlloc(1); 43 | Tp=0; 44 | } 45 | void Puts(char *s) { 46 | int len=strlen(s),i,sp=Tp; 47 | Text.SetLength(Tp+len); 48 | for (i=0;i &text) { 65 | int i=0,ch; 66 | text.SetLength(0); 67 | text.SetAutoAlloc(1); 68 | for (ch=0;ch!='\r'&&ch!='\n';) { 69 | ch=GetCh(); 70 | if (ch==8) { if (i>0) { i--; PutCh(ch); } } 71 | else { if (ch=='\r') ch='\n'; text[i++]=ch; PutCh(ch); } 72 | } 73 | text[i++]=0; 74 | text.SetLength(i); 75 | } 76 | int ReadKey() 77 | { 78 | int ch=GetCh(); 79 | PutCh(ch); 80 | return 0; 81 | } 82 | }; 83 | 84 | class TermStream:public Ixstream 85 | { 86 | protected: 87 | Terminal tty; 88 | int DoEof() { return 0; } 89 | int DoRead(void *buffer,long size) { 90 | IDataArray t; 91 | tty.Gets(t); 92 | strncpy((char*)buffer,&t[0],size-1); 93 | ((char*)buffer)[size]=0; 94 | return 0; 95 | } 96 | int DoWrite(void *buffer,long size) { 97 | tty.Puts((char*)buffer); 98 | return 0; 99 | } 100 | int DoSeek(long Pos,int mode) { return Pos+mode; } 101 | int DoGetPos() { return 0; } 102 | int DoPutCh(int ch) { tty.PutCh(ch); return 0; } 103 | int DoGetCh() { return tty.ReadKey(); } 104 | public: 105 | void SetWindow(HWND hWnd) { tty.SetWindow(hWnd); } 106 | }; 107 | 108 | #endif 109 | 110 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/VmBeta.cpp: -------------------------------------------------------------------------------- 1 | #include "VmWin.h" 2 | #include "Terminal.h" 3 | 4 | HWND InitWindow(HINSTANCE); 5 | HWND hWnd; 6 | IKeyBuffer KeyBuffer; 7 | TermStream tty; 8 | 9 | int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) 10 | { 11 | if ((hWnd=InitWindow(hInstance))==NULL) return -1; 12 | ShowWindow(hWnd, SW_NORMAL); 13 | tty.SetWindow(GetDlgItem(hWnd,IDC_TERMINAL)); 14 | isout.Bind(&tty); 15 | iserr.Bind(&tty); 16 | isin.Bind(&tty); 17 | VmWin WinVm; 18 | return WinVm.Run(lpCmdLine); 19 | } 20 | 21 | LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM); 22 | HINSTANCE hInstance; 23 | 24 | HWND InitWindow(HINSTANCE hInstance) 25 | { 26 | HWND hwnd; 27 | WNDCLASSEX wincl; 28 | wincl.hInstance = hInstance; 29 | wincl.lpszClassName = "VmBetaWin"; 30 | wincl.lpfnWndProc = WinProc; 31 | wincl.style = CS_DBLCLKS; 32 | wincl.cbSize = sizeof(WNDCLASSEX); 33 | wincl.hIcon = LoadIcon(hInstance,(LPCTSTR)IDI_ICON1); 34 | wincl.hIconSm = LoadIcon(hInstance,(LPCTSTR)IDI_ICON1); 35 | wincl.hCursor = LoadCursor(NULL, IDC_ARROW); 36 | wincl.lpszMenuName = NULL; 37 | wincl.cbClsExtra = 0; 38 | wincl.cbWndExtra = 0; 39 | wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); 40 | if(!RegisterClassEx(&wincl)) return 0; 41 | hwnd = CreateWindowEx(0,"VmBetaWin", 42 | "VmBeta Terminal v1.1b",WS_OVERLAPPEDWINDOW, 43 | CW_USEDEFAULT,CW_USEDEFAULT, 44 | 544,375,HWND_DESKTOP,NULL,hInstance,NULL); 45 | ::hInstance=hInstance; 46 | return hwnd; 47 | } 48 | #include 49 | #include 50 | LRESULT CALLBACK WinProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) 51 | { 52 | static char line[90]="KEY= "; 53 | static int Font=(int)GetStockObject(DEFAULT_GUI_FONT),i; 54 | switch (message) 55 | { 56 | case WM_CREATE: 57 | CreateWindow("EDIT", "", 58 | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | 59 | ES_WANTRETURN, 60 | CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 61 | hWnd, (HMENU)IDC_TERMINAL, hInstance, NULL); 62 | SendDlgItemMessage(hWnd, IDC_TERMINAL, WM_SETFONT,(WPARAM)Font, MAKELPARAM(TRUE, 0)); 63 | for (i=0;i<256;i++) KeyBuffer[i]=0; 64 | break; 65 | case WM_CLOSE: 66 | if (MessageBox(hWnd,"The action will terminate the program, continue ?","Warning",MB_YESNO)!=IDYES) break; 67 | DestroyWindow(hWnd); 68 | exit(0); 69 | break; 70 | case WM_SIZE: 71 | if (wParam != SIZE_MINIMIZED) 72 | MoveWindow(GetDlgItem(hWnd,IDC_TERMINAL),0,0, 73 | LOWORD(lParam),HIWORD(lParam), TRUE); 74 | break; 75 | case WM_KEYDOWN: 76 | KeyBuffer[wParam]=1; 77 | break; 78 | case WM_KEYUP: 79 | KeyBuffer[wParam]=0; 80 | break; 81 | case WM_CHAR: 82 | KeyBuffer.UnGetCh(wParam); 83 | break; 84 | case WM_COMMAND: 85 | switch (LOWORD(wParam)) 86 | { 87 | case IDC_TERMINAL: 88 | if (HIWORD(wParam)==WM_KEYDOWN) SetFocus(hWnd); 89 | return true; 90 | } 91 | break; 92 | case WM_DESTROY: 93 | PostQuitMessage(0); 94 | break; 95 | default: 96 | return DefWindowProc(hWnd,message,wParam,lParam); 97 | } 98 | return 0; 99 | } 100 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/VmBeta.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="VmBeta" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Application" 0x0101 6 | 7 | CFG=VmBeta - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "VmBeta.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "VmBeta.mak" CFG="VmBeta - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "VmBeta - Win32 Release" (based on "Win32 (x86) Application") 21 | !MESSAGE "VmBeta - Win32 Debug" (based on "Win32 (x86) Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "VmBeta - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "Release" 42 | # PROP Intermediate_Dir "Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c 46 | # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0x804 /d "NDEBUG" 50 | # ADD RSC /l 0x804 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 56 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /machine:I386 57 | 58 | !ELSEIF "$(CFG)" == "VmBeta - Win32 Debug" 59 | 60 | # PROP BASE Use_MFC 0 61 | # PROP BASE Use_Debug_Libraries 1 62 | # PROP BASE Output_Dir "Debug" 63 | # PROP BASE Intermediate_Dir "Debug" 64 | # PROP BASE Target_Dir "" 65 | # PROP Use_MFC 0 66 | # PROP Use_Debug_Libraries 1 67 | # PROP Output_Dir "Debug" 68 | # PROP Intermediate_Dir "Debug" 69 | # PROP Target_Dir "" 70 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c 71 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c 72 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 73 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 74 | # ADD BASE RSC /l 0x804 /d "_DEBUG" 75 | # ADD RSC /l 0x804 /d "_DEBUG" 76 | BSC32=bscmake.exe 77 | # ADD BASE BSC32 /nologo 78 | # ADD BSC32 /nologo 79 | LINK32=link.exe 80 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 81 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept 82 | 83 | !ENDIF 84 | 85 | # Begin Target 86 | 87 | # Name "VmBeta - Win32 Release" 88 | # Name "VmBeta - Win32 Debug" 89 | # Begin Group "Source Files" 90 | 91 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 92 | # Begin Group "VmSource" 93 | 94 | # PROP Default_Filter "" 95 | # Begin Source File 96 | 97 | SOURCE=..\..\iacciden.cpp 98 | # End Source File 99 | # Begin Source File 100 | 101 | SOURCE=..\..\ibitmapc.cpp 102 | # End Source File 103 | # Begin Source File 104 | 105 | SOURCE=..\..\icanvas.cpp 106 | # End Source File 107 | # Begin Source File 108 | 109 | SOURCE=..\..\ifstream.cpp 110 | # End Source File 111 | # Begin Source File 112 | 113 | SOURCE=..\..\igdibmp.cpp 114 | # End Source File 115 | # Begin Source File 116 | 117 | SOURCE=..\..\iplatfrm.cpp 118 | # End Source File 119 | # Begin Source File 120 | 121 | SOURCE=..\..\ivmsbeta.cpp 122 | # End Source File 123 | # Begin Source File 124 | 125 | SOURCE=..\..\ivmsca.cpp 126 | # End Source File 127 | # End Group 128 | # Begin Source File 129 | 130 | SOURCE=.\VmBeta.cpp 131 | # End Source File 132 | # Begin Source File 133 | 134 | SOURCE=.\VmBetaV.cpp 135 | # End Source File 136 | # Begin Source File 137 | 138 | SOURCE=.\VmWin.cpp 139 | # End Source File 140 | # End Group 141 | # Begin Group "Header Files" 142 | 143 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 144 | # Begin Group "VmHeader" 145 | 146 | # PROP Default_Filter "" 147 | # Begin Source File 148 | 149 | SOURCE=..\..\iacciden.h 150 | # End Source File 151 | # Begin Source File 152 | 153 | SOURCE=..\..\ibitmap.h 154 | # End Source File 155 | # Begin Source File 156 | 157 | SOURCE=..\..\ibitmapc.h 158 | # End Source File 159 | # Begin Source File 160 | 161 | SOURCE=..\..\icanvas.h 162 | # End Source File 163 | # Begin Source File 164 | 165 | SOURCE=..\..\ifstream.h 166 | # End Source File 167 | # Begin Source File 168 | 169 | SOURCE=..\..\igdibmp.h 170 | # End Source File 171 | # Begin Source File 172 | 173 | SOURCE=..\..\iini.h 174 | # End Source File 175 | # Begin Source File 176 | 177 | SOURCE=..\..\ikeybord.h 178 | # End Source File 179 | # Begin Source File 180 | 181 | SOURCE=..\..\iplatfrm.h 182 | # End Source File 183 | # Begin Source File 184 | 185 | SOURCE=..\..\istream.h 186 | # End Source File 187 | # Begin Source File 188 | 189 | SOURCE=..\..\istring.h 190 | # End Source File 191 | # Begin Source File 192 | 193 | SOURCE=..\..\itemplat.h 194 | # End Source File 195 | # Begin Source File 196 | 197 | SOURCE=..\..\ivms.h 198 | # End Source File 199 | # Begin Source File 200 | 201 | SOURCE=..\..\ivmsbeta.h 202 | # End Source File 203 | # Begin Source File 204 | 205 | SOURCE=..\..\ivmsca.h 206 | # End Source File 207 | # End Group 208 | # Begin Source File 209 | 210 | SOURCE=.\resource.h 211 | # End Source File 212 | # Begin Source File 213 | 214 | SOURCE=.\Terminal.h 215 | # End Source File 216 | # Begin Source File 217 | 218 | SOURCE=.\VmBetaV.h 219 | # End Source File 220 | # Begin Source File 221 | 222 | SOURCE=.\VmWin.h 223 | # End Source File 224 | # End Group 225 | # Begin Group "Resource Files" 226 | 227 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 228 | # Begin Source File 229 | 230 | SOURCE=.\Res\IconMain.ico 231 | # End Source File 232 | # Begin Source File 233 | 234 | SOURCE=.\resource.rc 235 | # End Source File 236 | # End Group 237 | # End Target 238 | # End Project 239 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/VmBeta.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "VmBeta"=".\VmBeta.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/VmBeta.opt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbeta/VmBeta.opt -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/VmBetaV.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbeta/VmBetaV.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/VmBetaV.h: -------------------------------------------------------------------------------- 1 | #ifndef VMBETA_H 2 | #define VMBETA_H 3 | 4 | #include "..\..\ivmsbeta.h" 5 | #include "..\..\igdibmp.h" 6 | 7 | class IVMBetaV:public IVMBeta 8 | { 9 | protected: 10 | ILister bmList; 11 | void fnCreateBmp(); 12 | void fnReleaseBmp(); 13 | void fnLoadBmp(); 14 | void fnBlitBmp(); 15 | void fnShowBmp(); 16 | void fnPixelBmp(); 17 | void fnGetPixelBmp(); 18 | void fnFillBmp(); 19 | void fnPlayMidi(); 20 | void fnStopMidi(); 21 | public: 22 | int RunFlag; 23 | IVMBetaV(); 24 | virtual ~IVMBetaV(); 25 | virtual void VmError(vdword error); 26 | virtual void VmOut(vdword port,vdword value); 27 | virtual void Excute(); 28 | virtual void VmReset() { bmList.Clear(); IVMBeta::VmReset(); } 29 | int GetStatus() { return VmStatus; } 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/VmWin.cpp: -------------------------------------------------------------------------------- 1 | #include "VmWin.h" 2 | #include "Terminal.h" 3 | #include "VmBetaV.h" 4 | #include "..\..\ivmsca.h" 5 | 6 | extern TermStream tty; 7 | 8 | int VmWin::Run(char *line) 9 | { 10 | extern HWND hWnd; 11 | CmdLine=line; 12 | int i=0,len=CmdLine.GetLength(); 13 | while (line[i]==' '&&i=0;i--) if (name[i]=='\\'||name[i]=='/') break; 62 | if (i>=0) i=i+1; 63 | else i=0; 64 | path=""; 65 | main=""; 66 | ext=""; 67 | for (j=0;j=i;j--) if (name[j]=='.') break; 69 | if (j 5 | #include "..\..\ikeybord.h" 6 | #include "..\..\istring.h" 7 | #include "resource.h" 8 | #include "VmBetaV.h" 9 | 10 | #define IDC_TERMINAL 1001 11 | 12 | extern IKeyBuffer KeyBuffer; 13 | 14 | HRESULT WinMessage(); 15 | int MsgPrint(char *fmt,...); 16 | 17 | class VmWin 18 | { 19 | protected: 20 | iString CmdLine; 21 | iString FileName; 22 | IVMBetaV vmbeta; 23 | void logo(); 24 | void SplitFileName(char *name,iString &path,iString &main,iString &ext); 25 | public: 26 | int Run(char *CmdLine); 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/VmbetaWin.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbeta/VmbetaWin.txt -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/resource.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbeta/resource.aps -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by resource.rc 4 | // 5 | #define IDI_ICON1 105 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 109 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1002 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbeta/resource.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Developer Studio generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // Chinese (P.R.C.) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED 21 | #pragma code_page(936) 22 | #endif //_WIN32 23 | 24 | #ifdef APSTUDIO_INVOKED 25 | ///////////////////////////////////////////////////////////////////////////// 26 | // 27 | // TEXTINCLUDE 28 | // 29 | 30 | 1 TEXTINCLUDE DISCARDABLE 31 | BEGIN 32 | "resource.h\0" 33 | END 34 | 35 | 2 TEXTINCLUDE DISCARDABLE 36 | BEGIN 37 | "#include ""afxres.h""\r\n" 38 | "\0" 39 | END 40 | 41 | 3 TEXTINCLUDE DISCARDABLE 42 | BEGIN 43 | "\r\n" 44 | "\0" 45 | END 46 | 47 | #endif // APSTUDIO_INVOKED 48 | 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | // 52 | // Icon 53 | // 54 | 55 | // Icon with lowest ID value placed first to ensure application icon 56 | // remains consistent on all systems. 57 | IDI_ICON1 ICON DISCARDABLE "Res\\IconMain.ico" 58 | #endif // Chinese (P.R.C.) resources 59 | ///////////////////////////////////////////////////////////////////////////// 60 | 61 | 62 | 63 | #ifndef APSTUDIO_INVOKED 64 | ///////////////////////////////////////////////////////////////////////////// 65 | // 66 | // Generated from the TEXTINCLUDE 3 resource. 67 | // 68 | 69 | 70 | ///////////////////////////////////////////////////////////////////////////// 71 | #endif // not APSTUDIO_INVOKED 72 | 73 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/AboutForm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "AboutForm.h" 7 | //--------------------------------------------------------------------------- 8 | #pragma package(smart_init) 9 | #pragma resource "*.dfm" 10 | TFormAbout *FormAbout; 11 | //--------------------------------------------------------------------------- 12 | __fastcall TFormAbout::TFormAbout(TComponent* Owner) 13 | : TForm(Owner) 14 | { 15 | } 16 | //--------------------------------------------------------------------------- 17 | void __fastcall TFormAbout::BitBtn1Click(TObject *Sender) 18 | { 19 | Close(); 20 | } 21 | //--------------------------------------------------------------------------- 22 | 23 | 24 | 25 | void __fastcall TFormAbout::Label3Click(TObject *Sender) 26 | { 27 | ShellExecute(this->Handle,"open","http://www.joynb.com","","",SW_SHOWNORMAL); 28 | } 29 | //--------------------------------------------------------------------------- 30 | 31 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/AboutForm.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/AboutForm.dfm -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/AboutForm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef AboutFormH 4 | #define AboutFormH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | //--------------------------------------------------------------------------- 14 | class TFormAbout : public TForm 15 | { 16 | __published: // IDE-managed Components 17 | TPanel *Panel1; 18 | TImage *Image1; 19 | TLabel *Label1; 20 | TLabel *Label2; 21 | TLabel *Label3; 22 | TMemo *Memo1; 23 | TPanel *Panel2; 24 | TBitBtn *BitBtn1; 25 | TImage *Image2; 26 | TLabel *Label4; 27 | void __fastcall BitBtn1Click(TObject *Sender); 28 | void __fastcall Label3Click(TObject *Sender); 29 | private: // User declarations 30 | public: // User declarations 31 | __fastcall TFormAbout(TComponent* Owner); 32 | }; 33 | //--------------------------------------------------------------------------- 34 | extern PACKAGE TFormAbout *FormAbout; 35 | //--------------------------------------------------------------------------- 36 | #endif 37 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/AsmForm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "AsmForm.h" 7 | //--------------------------------------------------------------------------- 8 | #pragma package(smart_init) 9 | #pragma resource "*.dfm" 10 | TFormAsm *FormAsm; 11 | //--------------------------------------------------------------------------- 12 | __fastcall TFormAsm::TFormAsm(TComponent* Owner) 13 | : TForm(Owner) 14 | { 15 | } 16 | //--------------------------------------------------------------------------- 17 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/AsmForm.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/AsmForm.dfm -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/AsmForm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef AsmFormH 4 | #define AsmFormH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | //--------------------------------------------------------------------------- 12 | class TFormAsm : public TForm 13 | { 14 | __published: // IDE-managed Components 15 | TRichEdit *Memo1; 16 | private: // User declarations 17 | public: // User declarations 18 | __fastcall TFormAsm(TComponent* Owner); 19 | }; 20 | //--------------------------------------------------------------------------- 21 | extern PACKAGE TFormAsm *FormAsm; 22 | //--------------------------------------------------------------------------- 23 | #endif 24 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Basic.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Basic.htm -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/alex1.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/DOS/alex1.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/alex2.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/DOS/alex2.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/alex3.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/DOS/alex3.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/alex4.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/DOS/alex4.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/vmbasic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/DOS/vmbasic.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/vmbeta.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/DOS/vmbeta.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/vmbeta.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/DOS/vmbeta.txt -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/vmdemo.vms: -------------------------------------------------------------------------------- 1 | ; demo.vms 2 | 3 | .stack 8192 4 | 5 | start: ; 0 6 | out 2,string1 7 | out 10,0 8 | ld dword r0,r3 9 | cmp int r0,1 ; 14 10 | jpc b error ; 1e 11 | push r0 ; 24 12 | call fun1 ; 29 13 | cal dword add rs,4 ; 2e 14 | out 2,string2 ; 38 11f 15 | out 0,r0 ; 42 16 | exit 17 | error: ; 4d 18 | out 0,0 19 | exit 20 | fun1: ; 58 21 | push rb ; 58 22 | ld dword rb,rs ; 5d 23 | ld dword r0,rb ; 67 24 | cal dword add r0,12 ; 71 25 | ld dword r0,[r0] ; 7b 26 | cmp int r0,1 ; 85 27 | jpc a jmp1 ; 8f 28 | jmp jmp2 ; 95 29 | jmp1: ; 9a 30 | push r0 ; 9a 31 | cal int sub r0,1 ; 9f 32 | push r0 ; a9 33 | call fun1 ; ae 34 | cal dword add rs,4 ; b3 35 | ld dword r1,r0 ; bd 36 | pop r0 ; c7 37 | cal int mul r0,r1 ; cc 38 | jmp2: ; d6 39 | ld dword rs,rb ; d6 40 | pop rb ; e0 41 | ret ; e5 42 | data string1 byte "This program is use to work out n!=?",$a,"please input n=",0 ; e6 43 | data string2 byte "the result is ",0 ; 11f 44 | end 45 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/DOS/说明.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/DOS/说明.txt -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/Fire.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/Fire.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/Fire.vms: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/Fire.vms -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/Game1.TGA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/Game1.TGA -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/Game2.TGA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/Game2.TGA -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/Game3.TGA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/Game3.TGA -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/alex1.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/alex1.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/alex2.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/alex2.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/alex3.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/alex3.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/alex4.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Examples/alex4.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/alex4.vms: -------------------------------------------------------------------------------- 1 | CALL LABEL0 ; For initialization 2 | 3 | ;================ MAIN PROG ================== 4 | ; 5 | ; Flush stack: 1 [1] 6 | PUSH 38 7 | POP r3 8 | ; 9 | LD int r0,VINT_KEY_UP 10 | LD int [r0],r3 11 | ; 12 | ; Flush stack: 1 [1] 13 | PUSH 40 14 | POP r3 15 | ; 16 | LD int r0,VINT_KEY_DOWN 17 | LD int [r0],r3 18 | ; 19 | ; Flush stack: 1 [1] 20 | PUSH 37 21 | POP r3 22 | ; 23 | LD int r0,VINT_KEY_LEFT 24 | LD int [r0],r3 25 | ; 26 | ; Flush stack: 1 [1] 27 | PUSH 39 28 | POP r3 29 | ; 30 | LD int r0,VINT_KEY_RIGHT 31 | LD int [r0],r3 32 | ; 33 | ; Flush stack: 1 [1] 34 | PUSH 32 35 | POP r3 36 | ; 37 | LD int r0,VINT_KEY_SPACE 38 | LD int [r0],r3 39 | ; 40 | ; Flush stack: 1 [1] 41 | PUSH 27 42 | POP r3 43 | ; 44 | LD int r0,VINT_KEY_ESCAPE 45 | LD int [r0],r3 46 | ; 47 | ; Flush stack: 1 [1] 48 | PUSH 13 49 | POP r3 50 | ; 51 | LD int r0,VINT_KEY_ENTER 52 | LD int [r0],r3 53 | ; 54 | ; Flush stack: 1 [1] 55 | PUSH 0 56 | POP r3 57 | ; 58 | LD int r0,VINT_MAX 59 | LD int [r0],r3 60 | ; 61 | ; Flush stack: 16 C [2] 62 | PUSH [CSTRING_49] 63 | POP r2 64 | IN r3,2 65 | IN r2,5 66 | PUSH r3 67 | POP r3 68 | ; 69 | OUT 2,r3 70 | IN r3,8 71 | OUT 4,10 72 | ; 73 | ; Flush stack: 1 [1] 74 | PUSH 0 75 | POP r3 76 | ; 77 | PUSH r3 78 | CALL FINT_SEARCH 79 | CAL int ADD rs,4 80 | EXIT 81 | 82 | ;================ FUNCTIONS ================== 83 | ;(FFLO_SIN) Function 84 | ;parcount=1 85 | FFLO_SIN: 86 | PUSH rb 87 | LD int rb,rs 88 | CAL int ADD rs,-4 89 | ; This is a comment line 90 | ; 91 | ; Flush stack: 17 [1] 92 | LD int r0,rb 93 | CAL int ADD r0,12 94 | PUSH [r0] 95 | POP r3 96 | ; 97 | LD int r0,VFLO_STATIC_FLOAT 98 | LD int [r0],r3 99 | LD int r3,[VFLO_STATIC_FLOAT] ;Inline VAsm 100 | IN [VFLO_STATIC_FLOAT],16 ;Inline VAsm 101 | ; 102 | ; Flush stack: 17 [1] 103 | PUSH [VFLO_STATIC_FLOAT] 104 | POP r3 105 | ; 106 | LD int r0,rb 107 | CAL int ADD r0,0 108 | LD int [r0],r3 109 | FFLO_SIN_EXIT: 110 | LD int r3,[rb] 111 | LD int rs,rb 112 | POP rb 113 | RET 114 | ; END FUN FFLO_SIN 115 | 116 | ;(FFLO_COS) Function 117 | ;parcount=1 118 | FFLO_COS: 119 | PUSH rb 120 | LD int rb,rs 121 | CAL int ADD rs,-4 122 | ; This is a comment line 123 | ; 124 | ; Flush stack: 17 [1] 125 | LD int r0,rb 126 | CAL int ADD r0,12 127 | PUSH [r0] 128 | POP r3 129 | ; 130 | LD int r0,VFLO_STATIC_FLOAT 131 | LD int [r0],r3 132 | LD int r3,[VFLO_STATIC_FLOAT] ;Inline VAsm 133 | IN [VFLO_STATIC_FLOAT],17 ;Inline VAsm 134 | ; 135 | ; Flush stack: 17 [1] 136 | PUSH [VFLO_STATIC_FLOAT] 137 | POP r3 138 | ; 139 | LD int r0,rb 140 | CAL int ADD r0,0 141 | LD int [r0],r3 142 | FFLO_COS_EXIT: 143 | LD int r3,[rb] 144 | LD int rs,rb 145 | POP rb 146 | RET 147 | ; END FUN FFLO_COS 148 | 149 | ;(FFLO_TAN) Function 150 | ;parcount=1 151 | FFLO_TAN: 152 | PUSH rb 153 | LD int rb,rs 154 | CAL int ADD rs,-4 155 | ; This is a comment line 156 | ; 157 | ; Flush stack: 17 [1] 158 | LD int r0,rb 159 | CAL int ADD r0,12 160 | PUSH [r0] 161 | POP r3 162 | ; 163 | LD int r0,VFLO_STATIC_FLOAT 164 | LD int [r0],r3 165 | LD int r3,[VFLO_STATIC_FLOAT] ;Inline VAsm 166 | IN [VFLO_STATIC_FLOAT],18 ;Inline VAsm 167 | ; 168 | ; Flush stack: 17 [1] 169 | PUSH [VFLO_STATIC_FLOAT] 170 | POP r3 171 | ; 172 | LD int r0,rb 173 | CAL int ADD r0,0 174 | LD int [r0],r3 175 | FFLO_TAN_EXIT: 176 | LD int r3,[rb] 177 | LD int rs,rb 178 | POP rb 179 | RET 180 | ; END FUN FFLO_TAN 181 | 182 | ;(FFLO_SQR) Function 183 | ;parcount=1 184 | FFLO_SQR: 185 | PUSH rb 186 | LD int rb,rs 187 | CAL int ADD rs,-4 188 | ; This is a comment line 189 | ; 190 | ; Flush stack: 17 [1] 191 | LD int r0,rb 192 | CAL int ADD r0,12 193 | PUSH [r0] 194 | POP r3 195 | ; 196 | LD int r0,VFLO_STATIC_FLOAT 197 | LD int [r0],r3 198 | LD int r3,[VFLO_STATIC_FLOAT] ;Inline VAsm 199 | IN [VFLO_STATIC_FLOAT],19 ;Inline VAsm 200 | ; 201 | ; Flush stack: 17 [1] 202 | PUSH [VFLO_STATIC_FLOAT] 203 | POP r3 204 | ; 205 | LD int r0,rb 206 | CAL int ADD r0,0 207 | LD int [r0],r3 208 | FFLO_SQR_EXIT: 209 | LD int r3,[rb] 210 | LD int rs,rb 211 | POP rb 212 | RET 213 | ; END FUN FFLO_SQR 214 | 215 | ;(FFLO_ABS) Function 216 | ;parcount=1 217 | FFLO_ABS: 218 | PUSH rb 219 | LD int rb,rs 220 | CAL int ADD rs,-4 221 | ; This is a comment line 222 | ; 223 | ; Flush stack: 17 [1] 224 | LD int r0,rb 225 | CAL int ADD r0,12 226 | PUSH [r0] 227 | POP r3 228 | ; 229 | LD int r0,VFLO_STATIC_FLOAT 230 | LD int [r0],r3 231 | LD int r3,[VFLO_STATIC_FLOAT] ;Inline VAsm 232 | IN [VFLO_STATIC_FLOAT],21 ;Inline VAsm 233 | ; 234 | ; Flush stack: 17 [1] 235 | PUSH [VFLO_STATIC_FLOAT] 236 | POP r3 237 | ; 238 | LD int r0,rb 239 | CAL int ADD r0,0 240 | LD int [r0],r3 241 | FFLO_ABS_EXIT: 242 | LD int r3,[rb] 243 | LD int rs,rb 244 | POP rb 245 | RET 246 | ; END FUN FFLO_ABS 247 | 248 | ;(FINT_ABS) Function 249 | ;parcount=1 250 | FINT_ABS: 251 | PUSH rb 252 | LD int rb,rs 253 | CAL int ADD rs,-4 254 | ; This is a comment line 255 | ; If code 256 | ; 257 | ; Flush stack: 16 1 < [3] 258 | LD int r0,rb 259 | CAL int ADD r0,12 260 | PUSH [r0] 261 | PUSH 0 262 | POP r1 263 | POP r0 264 | CMP int r0,r1 265 | JPC AE LABEL5 266 | PUSH 1 267 | JMP LABEL6 268 | LABEL5: 269 | PUSH 0 270 | LABEL6: 271 | POP r3 272 | ; 273 | CMP int r3,0 274 | JPC Z LABEL3 275 | ; 276 | ; Flush stack: 16 ^ [2] 277 | LD int r0,rb 278 | CAL int ADD r0,12 279 | PUSH [r0] 280 | POP r1 281 | LD int r0,0 282 | CAL int SUB r0,r1 283 | PUSH r0 284 | POP r3 285 | ; 286 | LD int r0,rb 287 | CAL int ADD r0,0 288 | LD int [r0],r3 289 | JMP LABEL4 290 | LABEL3: ; Else 291 | ; 292 | ; Flush stack: 16 [1] 293 | LD int r0,rb 294 | CAL int ADD r0,12 295 | PUSH [r0] 296 | POP r3 297 | ; 298 | LD int r0,rb 299 | CAL int ADD r0,0 300 | LD int [r0],r3 301 | LABEL4: ; End of If 302 | FINT_ABS_EXIT: 303 | LD int r3,[rb] 304 | LD int rs,rb 305 | POP rb 306 | RET 307 | ; END FUN FINT_ABS 308 | 309 | ;(FSTR_CHR) Function 310 | ;parcount=1 311 | FSTR_CHR: 312 | PUSH rb 313 | LD int rb,rs 314 | CAL int ADD rs,-4 315 | LD int r0,rb 316 | CAL int ADD r0,0 317 | IN [r0],2 318 | ; This is a comment line 319 | ; 320 | ; Flush stack: 16 C [2] 321 | PUSH [CSTRING_7] 322 | POP r2 323 | IN r3,2 324 | IN r2,5 325 | PUSH r3 326 | POP r3 327 | ; 328 | LD int r0,VSTR_STATIC_STR 329 | LD int r2,r3 330 | LD int r3,[r0] 331 | IN r3,5 332 | LD int r3,r2 333 | IN r3,8 334 | ; 335 | ; Flush stack: 16 [1] 336 | LD int r0,rb 337 | CAL int ADD r0,12 338 | PUSH [r0] 339 | POP r3 340 | ; 341 | LD int r0,VINT_STATIC_INT 342 | LD int [r0],r3 343 | LD int r3,[VSTR_STATIC_STR] ;Inline VAsm 344 | LD int r2,0 ;Inline VAsm 345 | LD int r1,[VINT_STATIC_INT] ;Inline VAsm 346 | IN r1,13 ;Inline VAsm 347 | ; 348 | ; Flush stack: 16 C [2] 349 | PUSH [VSTR_STATIC_STR] 350 | POP r2 351 | IN r3,2 352 | IN r2,5 353 | PUSH r3 354 | POP r3 355 | ; 356 | LD int r0,rb 357 | CAL int ADD r0,0 358 | LD int r2,r3 359 | LD int r3,[r0] 360 | IN r3,5 361 | LD int r3,r2 362 | IN r3,8 363 | FSTR_CHR_EXIT: 364 | LD int r3,[rb] 365 | LD int rs,rb 366 | POP rb 367 | RET 368 | ; END FUN FSTR_CHR 369 | 370 | ;(FINT_FTIMER) Function 371 | ;parcount=0 372 | FINT_FTIMER: 373 | PUSH rb 374 | LD int rb,rs 375 | CAL int ADD rs,-4 376 | ; This is a comment line 377 | IN [VINT_STATIC_INT],15 ;Inline VAsm 378 | ; 379 | ; Flush stack: 16 [1] 380 | PUSH [VINT_STATIC_INT] 381 | POP r3 382 | ; 383 | LD int r0,rb 384 | CAL int ADD r0,0 385 | LD int [r0],r3 386 | FINT_FTIMER_EXIT: 387 | LD int r3,[rb] 388 | LD int rs,rb 389 | POP rb 390 | RET 391 | ; END FUN FINT_FTIMER 392 | 393 | ;(FINT_NEWCANVAS) Function 394 | ;parcount=2 395 | FINT_NEWCANVAS: 396 | PUSH rb 397 | LD int rb,rs 398 | CAL int ADD rs,-4 399 | ; This is a comment line 400 | ; 401 | ; Flush stack: 16 [1] 402 | LD int r0,rb 403 | CAL int ADD r0,16 404 | PUSH [r0] 405 | POP r3 406 | ; 407 | LD int r0,VINT_STATIC_INT1 408 | LD int [r0],r3 409 | ; 410 | ; Flush stack: 16 [1] 411 | LD int r0,rb 412 | CAL int ADD r0,12 413 | PUSH [r0] 414 | POP r3 415 | ; 416 | LD int r0,VINT_STATIC_INT2 417 | LD int [r0],r3 418 | LD int r2,[VINT_STATIC_INT1] ;Inline VAsm 419 | LD int r3,[VINT_STATIC_INT2] ;Inline VAsm 420 | OUT 50,0 ;Inline VAsm 421 | LD int [VINT_STATIC_INT1],r3 ;Inline VAsm 422 | ; 423 | ; Flush stack: 16 [1] 424 | PUSH [VINT_STATIC_INT1] 425 | POP r3 426 | ; 427 | LD int r0,rb 428 | CAL int ADD r0,0 429 | LD int [r0],r3 430 | FINT_NEWCANVAS_EXIT: 431 | LD int r3,[rb] 432 | LD int rs,rb 433 | POP rb 434 | RET 435 | ; END FUN FINT_NEWCANVAS 436 | 437 | ;(FINT_FREECANVAS) Function 438 | ;parcount=1 439 | FINT_FREECANVAS: 440 | PUSH rb 441 | LD int rb,rs 442 | CAL int ADD rs,-4 443 | ; This is a comment line 444 | ; 445 | ; Flush stack: 16 [1] 446 | LD int r0,rb 447 | CAL int ADD r0,12 448 | PUSH [r0] 449 | POP r3 450 | ; 451 | LD int r0,VINT_STATIC_INT 452 | LD int [r0],r3 453 | LD int r3,[VINT_STATIC_INT] ;Inline VAsm 454 | OUT 51,0 ;Inline VAsm 455 | FINT_FREECANVAS_EXIT: 456 | LD int r3,[rb] 457 | LD int rs,rb 458 | POP rb 459 | RET 460 | ; END FUN FINT_FREECANVAS 461 | 462 | ;(FINT_BLITCANVAS) Function 463 | ;parcount=9 464 | FINT_BLITCANVAS: 465 | PUSH rb 466 | LD int rb,rs 467 | CAL int ADD rs,-4 468 | ; This is a comment line 469 | LD int r0,VINT_STATIC_INT 470 | PUSH r0 471 | LD int r0,rb 472 | CAL int ADD r0,12 473 | POP r1 474 | LD int [r1],r0 475 | LD int r3,[VINT_STATIC_INT] ;Inline VAsm 476 | OUT 53,0 ;Inline VAsm 477 | FINT_BLITCANVAS_EXIT: 478 | LD int r3,[rb] 479 | LD int rs,rb 480 | POP rb 481 | RET 482 | ; END FUN FINT_BLITCANVAS 483 | 484 | ;(FINT_LOADCANVAS) Function 485 | ;parcount=1 486 | FINT_LOADCANVAS: 487 | PUSH rb 488 | LD int rb,rs 489 | CAL int ADD rs,-4 490 | ; This is a comment line 491 | LD int r0,VINT_STATIC_INT 492 | PUSH r0 493 | LD int r0,rb 494 | CAL int ADD r0,12 495 | POP r1 496 | LD int [r1],r0 497 | LD int r2,[VINT_STATIC_INT] ;Inline VAsm 498 | LD int r3,[r2] ;Inline VAsm 499 | OUT 52,0 ;Inline VAsm 500 | LD int [VINT_STATIC_INT],r3 ;Inline VAsm 501 | ; 502 | ; Flush stack: 16 [1] 503 | PUSH [VINT_STATIC_INT] 504 | POP r3 505 | ; 506 | LD int r0,rb 507 | CAL int ADD r0,0 508 | LD int [r0],r3 509 | FINT_LOADCANVAS_EXIT: 510 | LD int r0,rb 511 | CAL int ADD r0,12 512 | LD int r3,[r0] 513 | IN r3,8 514 | LD int r3,[rb] 515 | LD int rs,rb 516 | POP rb 517 | RET 518 | ; END FUN FINT_LOADCANVAS 519 | 520 | ;(FINT_SHOWCANVAS) Function 521 | ;parcount=1 522 | FINT_SHOWCANVAS: 523 | PUSH rb 524 | LD int rb,rs 525 | CAL int ADD rs,-4 526 | ; This is a comment line 527 | ; 528 | ; Flush stack: 16 [1] 529 | LD int r0,rb 530 | CAL int ADD r0,12 531 | PUSH [r0] 532 | POP r3 533 | ; 534 | LD int r0,VINT_STATIC_INT 535 | LD int [r0],r3 536 | LD int r3,[VINT_STATIC_INT] ;Inline VAsm 537 | OUT 54,0 ;Inline VAsm 538 | FINT_SHOWCANVAS_EXIT: 539 | LD int r3,[rb] 540 | LD int rs,rb 541 | POP rb 542 | RET 543 | ; END FUN FINT_SHOWCANVAS 544 | 545 | ;(FINT_PIXEL) Function 546 | ;parcount=4 547 | FINT_PIXEL: 548 | PUSH rb 549 | LD int rb,rs 550 | CAL int ADD rs,-4 551 | ; This is a comment line 552 | LD int r0,VINT_STATIC_INT 553 | PUSH r0 554 | LD int r0,rb 555 | CAL int ADD r0,12 556 | POP r1 557 | LD int [r1],r0 558 | LD int r3,[VINT_STATIC_INT] ;Inline VAsm 559 | OUT 55,0 ;Inline VAsm 560 | FINT_PIXEL_EXIT: 561 | LD int r3,[rb] 562 | LD int rs,rb 563 | POP rb 564 | RET 565 | ; END FUN FINT_PIXEL 566 | 567 | ;(FINT_READPIXEL) Function 568 | ;parcount=3 569 | FINT_READPIXEL: 570 | PUSH rb 571 | LD int rb,rs 572 | CAL int ADD rs,-4 573 | ; This is a comment line 574 | LD int r0,VINT_STATIC_INT 575 | PUSH r0 576 | LD int r0,rb 577 | CAL int ADD r0,12 578 | POP r1 579 | LD int [r1],r0 580 | LD int r3,[VINT_STATIC_INT] ;Inline VAsm 581 | OUT 56,0 ;Inline VAsm 582 | LD int [VINT_STATIC_INT],r3 ;Inline VAsm 583 | ; 584 | ; Flush stack: 16 [1] 585 | PUSH [VINT_STATIC_INT] 586 | POP r3 587 | ; 588 | LD int r0,rb 589 | CAL int ADD r0,0 590 | LD int [r0],r3 591 | FINT_READPIXEL_EXIT: 592 | LD int r3,[rb] 593 | LD int rs,rb 594 | POP rb 595 | RET 596 | ; END FUN FINT_READPIXEL 597 | 598 | ;(FINT_KEYPRESS) Function 599 | ;parcount=1 600 | FINT_KEYPRESS: 601 | PUSH rb 602 | LD int rb,rs 603 | CAL int ADD rs,-4 604 | ; This is a comment line 605 | ; 606 | ; Flush stack: 16 [1] 607 | LD int r0,rb 608 | CAL int ADD r0,12 609 | PUSH [r0] 610 | POP r3 611 | ; 612 | LD int r0,VINT_STATIC_INT 613 | LD int [r0],r3 614 | LD int r3,[VINT_STATIC_INT] ;Inline VAsm 615 | OUT 60,0 ;Inline VAsm 616 | LD int [VINT_STATIC_INT],r3 ;Inline VAsm 617 | ; 618 | ; Flush stack: 16 [1] 619 | PUSH [VINT_STATIC_INT] 620 | POP r3 621 | ; 622 | LD int r0,rb 623 | CAL int ADD r0,0 624 | LD int [r0],r3 625 | FINT_KEYPRESS_EXIT: 626 | LD int r3,[rb] 627 | LD int rs,rb 628 | POP rb 629 | RET 630 | ; END FUN FINT_KEYPRESS 631 | 632 | ;(FINT_FILLCANVAS) Function 633 | ;parcount=6 634 | FINT_FILLCANVAS: 635 | PUSH rb 636 | LD int rb,rs 637 | CAL int ADD rs,-4 638 | ; This is a comment line 639 | LD int r0,VINT_STATIC_INT 640 | PUSH r0 641 | LD int r0,rb 642 | CAL int ADD r0,12 643 | POP r1 644 | LD int [r1],r0 645 | LD int r3,[VINT_STATIC_INT] ;Inline VAsm 646 | OUT 57,0 ;Inline VAsm 647 | FINT_FILLCANVAS_EXIT: 648 | LD int r3,[rb] 649 | LD int rs,rb 650 | POP rb 651 | RET 652 | ; END FUN FINT_FILLCANVAS 653 | 654 | ;(FINT_CLOSEGRAPH) Function 655 | ;parcount=0 656 | FINT_CLOSEGRAPH: 657 | PUSH rb 658 | LD int rb,rs 659 | CAL int ADD rs,-4 660 | ; This is a comment line 661 | OUT 58,0 ;Inline VAsm 662 | FINT_CLOSEGRAPH_EXIT: 663 | LD int r3,[rb] 664 | LD int rs,rb 665 | POP rb 666 | RET 667 | ; END FUN FINT_CLOSEGRAPH 668 | 669 | ;(FINT_RANDOM) Function 670 | ;parcount=1 671 | FINT_RANDOM: 672 | PUSH rb 673 | LD int rb,rs 674 | CAL int ADD rs,-4 675 | ; This is a comment line 676 | ; 677 | ; Flush stack: 16 [1] 678 | LD int r0,rb 679 | CAL int ADD r0,12 680 | PUSH [r0] 681 | POP r3 682 | ; 683 | LD int r0,VINT_STATIC_INT 684 | LD int [r0],r3 685 | LD int r3,[VINT_STATIC_INT] ;Inline VAsm 686 | OUT 59,0 ;Inline VAsm 687 | LD int [VINT_STATIC_INT],r3 ;Inline VAsm 688 | ; 689 | ; Flush stack: 16 [1] 690 | PUSH [VINT_STATIC_INT] 691 | POP r3 692 | ; 693 | LD int r0,rb 694 | CAL int ADD r0,0 695 | LD int [r0],r3 696 | FINT_RANDOM_EXIT: 697 | LD int r3,[rb] 698 | LD int rs,rb 699 | POP rb 700 | RET 701 | ; END FUN FINT_RANDOM 702 | 703 | ;(FINT_SEARCH) Function 704 | ;parcount=1 705 | FINT_SEARCH: 706 | PUSH rb 707 | LD int rb,rs 708 | CAL int ADD rs,-12 709 | ; This is a comment line 710 | ; 711 | ; Flush stack: 16 [1] 712 | LD int r0,rb 713 | CAL int ADD r0,12 714 | PUSH [r0] 715 | POP r3 716 | ; 717 | PUSH r3 718 | ; 719 | ; Flush stack: 1 [1] 720 | PUSH 0 721 | POP r3 722 | ; 723 | POP r1 724 | CMP dword r1,8 725 | JPC B LABEL8 726 | LD int r1,7 727 | LABEL8: 728 | LD int r0,VINT_A 729 | CAL int MUL r1,4 730 | CAL int ADD r0,r1 731 | LD int [r0],r3 732 | LABEL9: ; While code 733 | ; 734 | ; Flush stack: 16 16 1 < [4] 735 | LD int r0,rb 736 | CAL int ADD r0,12 737 | PUSH [r0] 738 | POP r3 739 | CMP dword r3,8 740 | JPC B LABEL11 741 | LD int r3,7 742 | LABEL11: 743 | LD int r0,VINT_A 744 | CAL int MUL r3,4 745 | CAL int ADD r0,r3 746 | PUSH [r0] 747 | PUSH 8 748 | POP r1 749 | POP r0 750 | CMP int r0,r1 751 | JPC AE LABEL12 752 | PUSH 1 753 | JMP LABEL13 754 | LABEL12: 755 | PUSH 0 756 | LABEL13: 757 | POP r3 758 | ; 759 | CMP int r3,0 760 | JPC Z LABEL10 761 | ; 762 | ; Flush stack: 1 [1] 763 | PUSH 1 764 | POP r3 765 | ; 766 | LD int r0,rb 767 | CAL int ADD r0,-4 768 | LD int [r0],r3 769 | ; If code 770 | ; 771 | ; Flush stack: 16 1 > [3] 772 | LD int r0,rb 773 | CAL int ADD r0,12 774 | PUSH [r0] 775 | PUSH 0 776 | POP r1 777 | POP r0 778 | CMP int r0,r1 779 | JPC BE LABEL16 780 | PUSH 1 781 | JMP LABEL17 782 | LABEL16: 783 | PUSH 0 784 | LABEL17: 785 | POP r3 786 | ; 787 | CMP int r3,0 788 | JPC Z LABEL14 789 | ; 790 | ; Flush stack: 1 [1] 791 | PUSH 0 792 | POP r3 793 | ; 794 | LD int r0,rb 795 | CAL int ADD r0,-8 796 | LD int [r0],r3 797 | LABEL18: ; While code 798 | ; 799 | ; Flush stack: 16 16 < [3] 800 | LD int r0,rb 801 | CAL int ADD r0,-8 802 | PUSH [r0] 803 | LD int r0,rb 804 | CAL int ADD r0,12 805 | PUSH [r0] 806 | POP r1 807 | POP r0 808 | CMP int r0,r1 809 | JPC AE LABEL20 810 | PUSH 1 811 | JMP LABEL21 812 | LABEL20: 813 | PUSH 0 814 | LABEL21: 815 | POP r3 816 | ; 817 | CMP int r3,0 818 | JPC Z LABEL19 819 | ; If code 820 | ; 821 | ; Flush stack: 16 16 16 16 = [5] 822 | LD int r0,rb 823 | CAL int ADD r0,12 824 | PUSH [r0] 825 | POP r3 826 | CMP dword r3,8 827 | JPC B LABEL24 828 | LD int r3,7 829 | LABEL24: 830 | LD int r0,VINT_A 831 | CAL int MUL r3,4 832 | CAL int ADD r0,r3 833 | PUSH [r0] 834 | LD int r0,rb 835 | CAL int ADD r0,-8 836 | PUSH [r0] 837 | POP r3 838 | CMP dword r3,8 839 | JPC B LABEL25 840 | LD int r3,7 841 | LABEL25: 842 | LD int r0,VINT_A 843 | CAL int MUL r3,4 844 | CAL int ADD r0,r3 845 | PUSH [r0] 846 | POP r1 847 | POP r0 848 | CMP int r0,r1 849 | JPC NZ LABEL26 850 | PUSH 1 851 | JMP LABEL27 852 | LABEL26: 853 | PUSH 0 854 | LABEL27: 855 | POP r3 856 | ; 857 | CMP int r3,0 858 | JPC Z LABEL22 859 | ; 860 | ; Flush stack: 1 ^ [2] 861 | PUSH 1 862 | POP r1 863 | LD int r0,0 864 | CAL int SUB r0,r1 865 | PUSH r0 866 | POP r3 867 | ; 868 | LD int r0,rb 869 | CAL int ADD r0,-4 870 | LD int [r0],r3 871 | JMP LABEL23 872 | LABEL22: ; Else 873 | LABEL23: ; End of If 874 | ; If code 875 | ; 876 | ; Flush stack: 16 16 16 16 - 16 16 - = 16 16 16 16 - 16 16 - = | [19] 877 | LD int r0,rb 878 | CAL int ADD r0,12 879 | PUSH [r0] 880 | POP r3 881 | CMP dword r3,8 882 | JPC B LABEL30 883 | LD int r3,7 884 | LABEL30: 885 | LD int r0,VINT_A 886 | CAL int MUL r3,4 887 | CAL int ADD r0,r3 888 | PUSH [r0] 889 | LD int r0,rb 890 | CAL int ADD r0,-8 891 | PUSH [r0] 892 | POP r3 893 | CMP dword r3,8 894 | JPC B LABEL31 895 | LD int r3,7 896 | LABEL31: 897 | LD int r0,VINT_A 898 | CAL int MUL r3,4 899 | CAL int ADD r0,r3 900 | PUSH [r0] 901 | POP r1 902 | POP r0 903 | CAL int SUB r0,r1 904 | PUSH r0 905 | LD int r0,rb 906 | CAL int ADD r0,12 907 | PUSH [r0] 908 | LD int r0,rb 909 | CAL int ADD r0,-8 910 | PUSH [r0] 911 | POP r1 912 | POP r0 913 | CAL int SUB r0,r1 914 | PUSH r0 915 | POP r1 916 | POP r0 917 | CMP int r0,r1 918 | JPC NZ LABEL32 919 | PUSH 1 920 | JMP LABEL33 921 | LABEL32: 922 | PUSH 0 923 | LABEL33: 924 | LD int r0,rb 925 | CAL int ADD r0,-8 926 | PUSH [r0] 927 | POP r3 928 | CMP dword r3,8 929 | JPC B LABEL34 930 | LD int r3,7 931 | LABEL34: 932 | LD int r0,VINT_A 933 | CAL int MUL r3,4 934 | CAL int ADD r0,r3 935 | PUSH [r0] 936 | LD int r0,rb 937 | CAL int ADD r0,12 938 | PUSH [r0] 939 | POP r3 940 | CMP dword r3,8 941 | JPC B LABEL35 942 | LD int r3,7 943 | LABEL35: 944 | LD int r0,VINT_A 945 | CAL int MUL r3,4 946 | CAL int ADD r0,r3 947 | PUSH [r0] 948 | POP r1 949 | POP r0 950 | CAL int SUB r0,r1 951 | PUSH r0 952 | LD int r0,rb 953 | CAL int ADD r0,12 954 | PUSH [r0] 955 | LD int r0,rb 956 | CAL int ADD r0,-8 957 | PUSH [r0] 958 | POP r1 959 | POP r0 960 | CAL int SUB r0,r1 961 | PUSH r0 962 | POP r1 963 | POP r0 964 | CMP int r0,r1 965 | JPC NZ LABEL36 966 | PUSH 1 967 | JMP LABEL37 968 | LABEL36: 969 | PUSH 0 970 | LABEL37: 971 | POP r1 972 | POP r0 973 | CAL int ADD r0,r1 974 | PUSH r0 975 | POP r3 976 | ; 977 | CMP int r3,0 978 | JPC Z LABEL28 979 | ; 980 | ; Flush stack: 1 ^ [2] 981 | PUSH 2 982 | POP r1 983 | LD int r0,0 984 | CAL int SUB r0,r1 985 | PUSH r0 986 | POP r3 987 | ; 988 | LD int r0,rb 989 | CAL int ADD r0,-4 990 | LD int [r0],r3 991 | JMP LABEL29 992 | LABEL28: ; Else 993 | LABEL29: ; End of If 994 | ; 995 | ; Flush stack: 16 1 + [3] 996 | LD int r0,rb 997 | CAL int ADD r0,-8 998 | PUSH [r0] 999 | PUSH 1 1000 | POP r1 1001 | POP r0 1002 | CAL int ADD r0,r1 1003 | PUSH r0 1004 | POP r3 1005 | ; 1006 | LD int r0,rb 1007 | CAL int ADD r0,-8 1008 | LD int [r0],r3 1009 | JMP LABEL18 1010 | LABEL19: ; End of While 1011 | JMP LABEL15 1012 | LABEL14: ; Else 1013 | LABEL15: ; End of If 1014 | ; If code 1015 | ; 1016 | ; Flush stack: 16 1 > [3] 1017 | LD int r0,rb 1018 | CAL int ADD r0,-4 1019 | PUSH [r0] 1020 | PUSH 0 1021 | POP r1 1022 | POP r0 1023 | CMP int r0,r1 1024 | JPC BE LABEL40 1025 | PUSH 1 1026 | JMP LABEL41 1027 | LABEL40: 1028 | PUSH 0 1029 | LABEL41: 1030 | POP r3 1031 | ; 1032 | CMP int r3,0 1033 | JPC Z LABEL38 1034 | ; If code 1035 | ; 1036 | ; Flush stack: 16 1 = [3] 1037 | LD int r0,rb 1038 | CAL int ADD r0,12 1039 | PUSH [r0] 1040 | PUSH 7 1041 | POP r1 1042 | POP r0 1043 | CMP int r0,r1 1044 | JPC NZ LABEL44 1045 | PUSH 1 1046 | JMP LABEL45 1047 | LABEL44: 1048 | PUSH 0 1049 | LABEL45: 1050 | POP r3 1051 | ; 1052 | CMP int r3,0 1053 | JPC Z LABEL42 1054 | ; 1055 | ; Flush stack: 16 1 + [3] 1056 | PUSH [VINT_MAX] 1057 | PUSH 1 1058 | POP r1 1059 | POP r0 1060 | CAL int ADD r0,r1 1061 | PUSH r0 1062 | POP r3 1063 | ; 1064 | LD int r0,VINT_MAX 1065 | LD int [r0],r3 1066 | ; 1067 | ; Flush stack: 16 C [2] 1068 | PUSH [CSTRING_46] 1069 | POP r2 1070 | IN r3,2 1071 | IN r2,5 1072 | PUSH r3 1073 | POP r3 1074 | ; 1075 | OUT 2,r3 1076 | IN r3,8 1077 | ; 1078 | ; Flush stack: 16 [1] 1079 | PUSH [VINT_MAX] 1080 | POP r3 1081 | ; 1082 | OUT 3,r3 1083 | OUT 4,10 1084 | JMP LABEL43 1085 | LABEL42: ; Else 1086 | ; 1087 | ; Flush stack: 16 1 + [3] 1088 | LD int r0,rb 1089 | CAL int ADD r0,12 1090 | PUSH [r0] 1091 | PUSH 1 1092 | POP r1 1093 | POP r0 1094 | CAL int ADD r0,r1 1095 | PUSH r0 1096 | POP r3 1097 | ; 1098 | PUSH r3 1099 | CALL FINT_SEARCH 1100 | CAL int ADD rs,4 1101 | LABEL43: ; End of If 1102 | JMP LABEL39 1103 | LABEL38: ; Else 1104 | LABEL39: ; End of If 1105 | ; 1106 | ; Flush stack: 16 [1] 1107 | LD int r0,rb 1108 | CAL int ADD r0,12 1109 | PUSH [r0] 1110 | POP r3 1111 | ; 1112 | PUSH r3 1113 | ; 1114 | ; Flush stack: 16 16 1 + [4] 1115 | LD int r0,rb 1116 | CAL int ADD r0,12 1117 | PUSH [r0] 1118 | POP r3 1119 | CMP dword r3,8 1120 | JPC B LABEL47 1121 | LD int r3,7 1122 | LABEL47: 1123 | LD int r0,VINT_A 1124 | CAL int MUL r3,4 1125 | CAL int ADD r0,r3 1126 | PUSH [r0] 1127 | PUSH 1 1128 | POP r1 1129 | POP r0 1130 | CAL int ADD r0,r1 1131 | PUSH r0 1132 | POP r3 1133 | ; 1134 | POP r1 1135 | CMP dword r1,8 1136 | JPC B LABEL48 1137 | LD int r1,7 1138 | LABEL48: 1139 | LD int r0,VINT_A 1140 | CAL int MUL r1,4 1141 | CAL int ADD r0,r1 1142 | LD int [r0],r3 1143 | JMP LABEL9 1144 | LABEL10: ; End of While 1145 | FINT_SEARCH_EXIT: 1146 | LD int r3,[rb] 1147 | LD int rs,rb 1148 | POP rb 1149 | RET 1150 | ; END FUN FINT_SEARCH 1151 | 1152 | 1153 | ;================ Init Code ================== 1154 | LABEL0: 1155 | IN [VSTR_STATIC_STR],2 1156 | LD dword [CSTRING_7],CS_CSTRING_7 1157 | LD dword [CSTRING_46],CS_CSTRING_46 1158 | LD dword [CSTRING_49],CS_CSTRING_49 1159 | RET 1160 | LABEL1: 1161 | EXIT 1162 | 1163 | ; Declaration: 1164 | LABEL2: 1165 | DATA VFLO_STATIC_FLOAT dword 0 1166 | DATA VSTR_STATIC_STR dword 0 1167 | DATA VINT_STATIC_INT dword 0 1168 | DATA CSTRING_7 dword 0 1169 | DATA CS_CSTRING_7 char " ",0 1170 | DATA VINT_STATIC_INT1 dword 0 1171 | DATA VINT_STATIC_INT2 dword 0 1172 | DATA VINT_KEY_UP dword 0 1173 | DATA VINT_KEY_DOWN dword 0 1174 | DATA VINT_KEY_LEFT dword 0 1175 | DATA VINT_KEY_RIGHT dword 0 1176 | DATA VINT_KEY_SPACE dword 0 1177 | DATA VINT_KEY_ESCAPE dword 0 1178 | DATA VINT_KEY_ENTER dword 0 1179 | DATA VINT_A dword 0 1180 | .BLOCK 32 0 1181 | DATA VINT_MAX dword 0 1182 | DATA CSTRING_46 dword 0 1183 | DATA CS_CSTRING_46 char "FIND ",0 1184 | DATA CSTRING_49 dword 0 1185 | DATA CS_CSTRING_49 char "HELLO",0 1186 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/hello.bas: -------------------------------------------------------------------------------- 1 | PRINT "Hello, World !!" 2 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Examples/vmdemo.vms: -------------------------------------------------------------------------------- 1 | ; demo.vms 2 | 3 | .stack 8192 4 | 5 | start: ; 0 6 | out 2,string1 7 | out 10,0 8 | ld dword r0,r3 9 | cmp int r0,1 ; 14 10 | jpc b error ; 1e 11 | push r0 ; 24 12 | call fun1 ; 29 13 | cal dword add rs,4 ; 2e 14 | out 2,string2 ; 38 11f 15 | out 0,r0 ; 42 16 | exit 17 | error: ; 4d 18 | out 0,0 19 | exit 20 | fun1: ; 58 21 | push rb ; 58 22 | ld dword rb,rs ; 5d 23 | ld dword r0,rb ; 67 24 | cal dword add r0,12 ; 71 25 | ld dword r0,[r0] ; 7b 26 | cmp int r0,1 ; 85 27 | jpc a jmp1 ; 8f 28 | jmp jmp2 ; 95 29 | jmp1: ; 9a 30 | push r0 ; 9a 31 | cal int sub r0,1 ; 9f 32 | push r0 ; a9 33 | call fun1 ; ae 34 | cal dword add rs,4 ; b3 35 | ld dword r1,r0 ; bd 36 | pop r0 ; c7 37 | cal int mul r0,r1 ; cc 38 | jmp2: ; d6 39 | ld dword rs,rb ; d6 40 | pop rb ; e0 41 | ret ; e5 42 | data string1 byte "This program is use to work out n!=?",$a,"please input n=",0 ; e6 43 | data string2 byte "the result is ",0 ; 11f 44 | end 45 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Help/IconMain.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Help/IconMain.GIF -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Help/Look.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Help/Look.gif -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Help/Look.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Help/Look.tga -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Help/Look2.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Help/Look2.GIF -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Help/Look3.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Help/Look3.GIF -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Help/butten4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Help/butten4.jpg -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Help/button1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Help/button1.jpg -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/IDEForm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/IDEForm.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/IDEForm.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/IDEForm.dfm -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/IDEForm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef IDEFormH 4 | #define IDEFormH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "VmBasic.h" 19 | #include 20 | #include 21 | //--------------------------------------------------------------------------- 22 | class TFormIDE : public TForm 23 | { 24 | __published: // IDE-managed Components 25 | TMainMenu *MainMenu1; 26 | TMenuItem *F1; 27 | TMenuItem *O1; 28 | TMenuItem *S1; 29 | TMenuItem *N1; 30 | TMenuItem *R1; 31 | TMenuItem *C1; 32 | TMenuItem *R2; 33 | TMenuItem *E1; 34 | TMenuItem *H1; 35 | TMenuItem *BASICB1; 36 | TMenuItem *IDEI1; 37 | TMenuItem *A1; 38 | TSplitter *Splitter1; 39 | TToolBar *ToolBar1; 40 | TSplitter *Splitter2; 41 | TStatusBar *StatusBar1; 42 | TPanel *Panel1; 43 | TTreeView *CmdTree; 44 | TToolButton *ToolButton1; 45 | TImageList *ImageList1; 46 | TToolButton *ToolButton2; 47 | TToolButton *ToolButton3; 48 | TToolButton *ToolButton4; 49 | TToolButton *ToolButton5; 50 | TMenuItem *A2; 51 | TOpenDialog *OpenBasic; 52 | TSaveDialog *SaveBasic; 53 | TSaveDialog *SaveExe; 54 | TMenuItem *A3; 55 | TMenuItem *N2; 56 | TMenuItem *N3; 57 | TMenuItem *N4; 58 | TMenuItem *N5; 59 | TToolButton *ToolButton6; 60 | TToolButton *ToolButton8; 61 | TToolButton *ToolButton9; 62 | TMenuItem *T1; 63 | TMenuItem *N6; 64 | TActionList *ActionList1; 65 | TEditCopy *EditCopy; 66 | TEditCut *EditCut; 67 | TEditDelete *EditDelete; 68 | TEditPaste *EditPaste; 69 | TEditSelectAll *EditSelectAll; 70 | TEditUndo *EditUndo; 71 | TAction *ActionNew; 72 | TAction *ActionOpenFile; 73 | TAction *ActionSaveFile; 74 | TAction *ActionSaveAs; 75 | TAction *ActionShowAsm; 76 | TAction *ActionRun; 77 | TAction *ActionCompile; 78 | TMenuItem *E2; 79 | TMenuItem *Undo; 80 | TMenuItem *N7; 81 | TMenuItem *Cut1; 82 | TMenuItem *Copy1; 83 | TMenuItem *Paste1; 84 | TMemo *VmMsg; 85 | TToolButton *ToolButton10; 86 | TToolButton *ToolButton11; 87 | TToolButton *ToolButton12; 88 | TToolButton *ToolButton13; 89 | TMenuItem *VMS1; 90 | TAction *ActionVms; 91 | TAction *ActionExport; 92 | TOpenDialog *OpenVms; 93 | TAction *ActionSetting; 94 | TAction *ActionHelp; 95 | TAction *ActionHelpIDE; 96 | TAction *ActionAbout; 97 | TAction *ActionSite; 98 | TMenuItem *S2; 99 | TToolButton *ToolButton7; 100 | TRichEdit *VmText; 101 | void __fastcall FormCreate(TObject *Sender); 102 | void __fastcall VmTextChange(TObject *Sender); 103 | void __fastcall FormClose(TObject *Sender, TCloseAction &Action); 104 | void __fastcall R2Click(TObject *Sender); 105 | void __fastcall VmTextKeyUp(TObject *Sender, WORD &Key, 106 | TShiftState Shift); 107 | void __fastcall VmTextMouseUp(TObject *Sender, TMouseButton Button, 108 | TShiftState Shift, int X, int Y); 109 | void __fastcall VmTextEnter(TObject *Sender); 110 | void __fastcall ActionNewExecute(TObject *Sender); 111 | void __fastcall ActionOpenFileExecute(TObject *Sender); 112 | void __fastcall ActionSaveFileExecute(TObject *Sender); 113 | void __fastcall ActionSaveAsExecute(TObject *Sender); 114 | void __fastcall ActionRunExecute(TObject *Sender); 115 | void __fastcall ActionShowAsmExecute(TObject *Sender); 116 | void __fastcall ActionCompileExecute(TObject *Sender); 117 | void __fastcall EditCopyExecute(TObject *Sender); 118 | void __fastcall EditCutExecute(TObject *Sender); 119 | void __fastcall EditPasteExecute(TObject *Sender); 120 | void __fastcall EditUndoExecute(TObject *Sender); 121 | void __fastcall FormActivate(TObject *Sender); 122 | void __fastcall ToolButton9Click(TObject *Sender); 123 | void __fastcall ActionVmsExecute(TObject *Sender); 124 | void __fastcall ActionSettingExecute(TObject *Sender); 125 | void __fastcall VmTextKeyPress(TObject *Sender, char &Key); 126 | void __fastcall VmTextMouseDown(TObject *Sender, 127 | TMouseButton Button, TShiftState Shift, int X, int Y); 128 | void __fastcall ActionHelpExecute(TObject *Sender); 129 | void __fastcall ActionHelpIDEExecute(TObject *Sender); 130 | void __fastcall ActionAboutExecute(TObject *Sender); 131 | void __fastcall ActionSiteExecute(TObject *Sender); 132 | void __fastcall FormDestroy(TObject *Sender); 133 | void __fastcall N1Click(TObject *Sender); 134 | private: // User declarations 135 | AnsiString FileName; 136 | AnsiString RootDir; 137 | IVmBasic VmBasic; 138 | ILogStream LogText; 139 | int Modified; 140 | int NewFile(); 141 | void SetFile(char *name); 142 | void ShowPos(); 143 | public: // User declarations 144 | __fastcall TFormIDE(TComponent* Owner); 145 | }; 146 | //--------------------------------------------------------------------------- 147 | extern PACKAGE TFormIDE *FormIDE; 148 | //--------------------------------------------------------------------------- 149 | #endif 150 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/Readme.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/Readme.htm -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/StdLib.VBL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/StdLib.VBL -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/ToolForm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "ToolForm.h" 7 | #include "IDEForm.h" 8 | #include "AsmForm.h" 9 | //--------------------------------------------------------------------------- 10 | #pragma package(smart_init) 11 | #pragma link "CGRID" 12 | #pragma resource "*.dfm" 13 | TFormTool *FormTool; 14 | //--------------------------------------------------------------------------- 15 | __fastcall TFormTool::TFormTool(TComponent* Owner) 16 | : TForm(Owner) 17 | { 18 | NameVmbeta=""; 19 | NameLib=""; 20 | ShowColor(); 21 | } 22 | void TFormTool::ShowColor() 23 | { 24 | Edit3->Font->Color=Color1; 25 | Edit4->Font->Color=Color2; 26 | } 27 | //--------------------------------------------------------------------------- 28 | void __fastcall TFormTool::BitBtn3Click(TObject *Sender) 29 | { 30 | if (OpenVmbeta->Execute()) { 31 | Edit1->Text=OpenVmbeta->FileName; 32 | } 33 | } 34 | //--------------------------------------------------------------------------- 35 | void __fastcall TFormTool::BitBtn4Click(TObject *Sender) 36 | { 37 | if (OpenLib->Execute()) { 38 | Edit2->Text=OpenLib->FileName; 39 | } 40 | } 41 | //--------------------------------------------------------------------------- 42 | void __fastcall TFormTool::BitBtn2Click(TObject *Sender) 43 | { 44 | Close(); 45 | } 46 | //--------------------------------------------------------------------------- 47 | void __fastcall TFormTool::BitBtn1Click(TObject *Sender) 48 | { 49 | extern TFormIDE *FormIDE; 50 | extern TFormAsm *FormAsm; 51 | NameVmbeta=Edit1->Text; 52 | NameLib=Edit2->Text; 53 | FormIDE->VmText->Font->Color=Color1; 54 | FormAsm->Memo1->Font->Color=Color2; 55 | Close(); 56 | } 57 | //--------------------------------------------------------------------------- 58 | void __fastcall TFormTool::CColorGrid1Change(TObject *Sender) 59 | { 60 | Color1=CColorGrid1->ForegroundColor; 61 | Color2=CColorGrid1->BackgroundColor; 62 | ShowColor(); 63 | } 64 | //--------------------------------------------------------------------------- 65 | void __fastcall TFormTool::FormActivate(TObject *Sender) 66 | { 67 | extern TFormIDE *FormIDE; 68 | extern TFormAsm *FormAsm; 69 | Color1=FormIDE->VmText->Font->Color; 70 | Color2=FormAsm->Memo1->Font->Color; 71 | Edit1->Text=NameVmbeta; 72 | Edit2->Text=NameLib; 73 | ShowColor(); 74 | } 75 | //--------------------------------------------------------------------------- 76 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/ToolForm.dfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/ToolForm.dfm -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/ToolForm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef ToolFormH 4 | #define ToolFormH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "CGRID.h" 13 | #include 14 | //--------------------------------------------------------------------------- 15 | class TFormTool : public TForm 16 | { 17 | __published: // IDE-managed Components 18 | TGroupBox *GroupBox1; 19 | TGroupBox *GroupBox2; 20 | TPanel *Panel1; 21 | TPanel *Panel2; 22 | TBitBtn *BitBtn1; 23 | TBitBtn *BitBtn2; 24 | TCColorGrid *CColorGrid1; 25 | TColorDialog *ColorDialog1; 26 | TOpenDialog *OpenLib; 27 | TOpenDialog *OpenVmbeta; 28 | TEdit *Edit1; 29 | TLabel *Label1; 30 | TPanel *Panel3; 31 | TPanel *Panel4; 32 | TEdit *Edit2; 33 | TLabel *Label2; 34 | TBitBtn *BitBtn3; 35 | TBitBtn *BitBtn4; 36 | TLabel *Label3; 37 | TLabel *Label4; 38 | TEdit *Edit3; 39 | TEdit *Edit4; 40 | void __fastcall BitBtn3Click(TObject *Sender); 41 | void __fastcall BitBtn4Click(TObject *Sender); 42 | void __fastcall BitBtn2Click(TObject *Sender); 43 | void __fastcall BitBtn1Click(TObject *Sender); 44 | void __fastcall CColorGrid1Change(TObject *Sender); 45 | void __fastcall FormActivate(TObject *Sender); 46 | private: // User declarations 47 | void ShowColor(); 48 | public: // User declarations 49 | AnsiString NameVmbeta; 50 | AnsiString NameLib; 51 | TColor Color1; 52 | TColor Color2; 53 | __fastcall TFormTool(TComponent* Owner); 54 | }; 55 | //--------------------------------------------------------------------------- 56 | extern PACKAGE TFormTool *FormTool; 57 | //--------------------------------------------------------------------------- 58 | #endif 59 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/VmBIDE.bpr: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | [Version Info] 55 | IncludeVerInfo=0 56 | AutoIncBuild=0 57 | MajorVer=1 58 | MinorVer=0 59 | Release=0 60 | Build=0 61 | Debug=0 62 | PreRelease=0 63 | Special=0 64 | Private=0 65 | DLL=0 66 | Locale=2052 67 | CodePage=936 68 | 69 | [Version Info Keys] 70 | CompanyName= 71 | FileDescription= 72 | FileVersion=1.0.0.0 73 | InternalName= 74 | LegalCopyright= 75 | LegalTrademarks= 76 | OriginalFilename= 77 | ProductName= 78 | ProductVersion=1.0.0.0 79 | Comments= 80 | 81 | [HistoryLists\hlIncludePath] 82 | Count=7 83 | Item0=..\..;..\..\..\Imagine;res;..\..\..\..\..\Borland\CBuilder5\Projects;$(BCB)\include;$(BCB)\include\vcl 84 | Item1=..\..;res;..\..\..\..\..\Borland\CBuilder5\Projects;$(BCB)\include;$(BCB)\include\vcl 85 | Item2=..\..\..\Imagine;res;..\..\..\..\..\Borland\CBuilder5\Projects;$(BCB)\include;$(BCB)\include\vcl 86 | Item3=..\..;res;..\..\..\..\..\Borland\CBuilder5\Projects;..\..\..\Imagine;$(BCB)\include;$(BCB)\include\vcl 87 | Item4=res;..\..\..\..\..\Borland\CBuilder5\Projects;..\..;$(BCB)\include;$(BCB)\include\vcl 88 | Item5=$(BCB)\include;$(BCB)\include\vcl 89 | Item6=..\ivmcc;$(BCB)\include;$(BCB)\include\vcl 90 | 91 | [HistoryLists\hlLibraryPath] 92 | Count=7 93 | Item0=..\..;..\..\..\Imagine;res;..\..\..\..\..\Borland\CBuilder5\Projects;$(BCB)\lib\obj;$(BCB)\lib 94 | Item1=..\..;res;..\..\..\..\..\Borland\CBuilder5\Projects;$(BCB)\lib\obj;$(BCB)\lib 95 | Item2=..\..\..\Imagine;res;..\..\..\..\..\Borland\CBuilder5\Projects;$(BCB)\lib\obj;$(BCB)\lib 96 | Item3=..\..;res;..\..\..\..\..\Borland\CBuilder5\Projects;..\..\..\Imagine;$(BCB)\lib\obj;$(BCB)\lib 97 | Item4=res;..\..\..\..\..\Borland\CBuilder5\Projects;..\..;$(BCB)\lib\obj;$(BCB)\lib 98 | Item5=$(BCB)\lib\obj;$(BCB)\lib 99 | Item6=..\ivmcc;$(BCB)\lib\obj;$(BCB)\lib 100 | 101 | [HistoryLists\hlDebugSourcePath] 102 | Count=1 103 | Item0=$(BCB)\source\vcl 104 | 105 | [HistoryLists\hlConditionals] 106 | Count=1 107 | Item0=_DEBUG 108 | 109 | [HistoryLists\hlIntOutputDir] 110 | Count=2 111 | Item0=object 112 | Item1=.\object 113 | 114 | [Debugging] 115 | DebugSourceDirs=$(BCB)\source\vcl 116 | 117 | [Parameters] 118 | RunParams= 119 | HostApplication= 120 | RemoteHost= 121 | RemotePath= 122 | RemoteDebug=0 123 | 124 | [Compiler] 125 | ShowInfoMsgs=0 126 | LinkDebugVcl=0 127 | LinkCGLIB=0 128 | 129 | [CORBA] 130 | AddServerUnit=1 131 | AddClientUnit=1 132 | PrecompiledHeaders=1 133 | 134 | [Language] 135 | ActiveLang= 136 | ProjectLang= 137 | RootDir= 138 | 139 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/VmBIDE.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | USERES("VmBIDE.res"); 6 | USEFORM("IDEForm.cpp", FormIDE); 7 | USEUNIT("..\..\ivmscv.cpp"); 8 | USEUNIT("..\..\ifstream.cpp"); 9 | USEUNIT("..\..\iini.cpp"); 10 | USEUNIT("..\..\iplatfrm.cpp"); 11 | USEUNIT("..\..\ivmscexp.cpp"); 12 | USEUNIT("..\..\ivmscs.cpp"); 13 | USEUNIT("..\..\iacciden.cpp"); 14 | USEUNIT("VmBasic.cpp"); 15 | USEFORM("AsmForm.cpp", FormAsm); 16 | USEFORM("ToolForm.cpp", FormTool); 17 | USEFORM("AboutForm.cpp", FormAbout); 18 | //--------------------------------------------------------------------------- 19 | WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) 20 | { 21 | try 22 | { 23 | Application->Initialize(); 24 | Application->Title = "VmBasic IDE"; 25 | Application->CreateForm(__classid(TFormIDE), &FormIDE); 26 | Application->CreateForm(__classid(TFormAsm), &FormAsm); 27 | Application->CreateForm(__classid(TFormTool), &FormTool); 28 | Application->CreateForm(__classid(TFormAbout), &FormAbout); 29 | Application->Run(); 30 | } 31 | catch (Exception &exception) 32 | { 33 | Application->ShowException(&exception); 34 | } 35 | return 0; 36 | } 37 | //--------------------------------------------------------------------------- 38 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/VmBIDE.ini: -------------------------------------------------------------------------------- 1 | [IDE] 2 | VMBETA=vmbeta.exe 3 | STDLIB=StdLib.VBL 4 | TEXTCOLOR=8421376 5 | ASMCOLOR=8421504 -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/VmBIDE.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/VmBIDE.res -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/VmBasic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/VmBasic.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/VmBasic.h: -------------------------------------------------------------------------------- 1 | #ifndef _VMBASIC_H_ 2 | #define _VMBASIC_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "..\..\ivmscc.h" 18 | 19 | class IVmBasic 20 | { 21 | protected: 22 | iString StartDir; 23 | IVMBetaScript VmBSC; 24 | iString VmbetaName; 25 | iString VmlibName; 26 | Imstream LogText; 27 | Imstream VmCode; 28 | Imstream VmBasic; 29 | int TextColor; 30 | int AsmColor; 31 | void SplitFileName(char *name,iString &path,iString &main,iString &ext); 32 | public: 33 | HWND hWnd; 34 | IVmBasic() { iserr.Bind(&LogText); } 35 | void LoadConfig(); 36 | void SaveConfig(); 37 | int Compile(); 38 | void SaveVm(char *FileName); 39 | void ShowAsm(TStream *stream); 40 | void RunProg(char *FileName); 41 | void RunVms(char *VmsFile); 42 | void Config(); 43 | }; 44 | 45 | class ILogStream:public Ixstream 46 | { 47 | protected: 48 | TMemo *VmLog; 49 | virtual int DoEof() { return 0; } 50 | virtual int DoRead(void *buffer,long size) { return size; } 51 | virtual int DoWrite(void *buffer,long size) { VmLog->Lines->Add((char*)buffer); return size; } 52 | virtual int DoSeek(long Pos,int mode) { return 0; } 53 | virtual int DoGetPos() { return 0; } 54 | virtual int DoPutCh(int ch) { VmLog->Lines->Text+=(char)ch; return 0; } 55 | virtual int DoGetCh() { VmLog->Lines->Text=""; return 0; } 56 | public: 57 | void Startup(TMemo *log) { VmLog=log; } 58 | void Clear() { VmLog->Lines->Text=""; } 59 | }; 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon1.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon10.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon10.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon11.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon11.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon12.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon12.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon13.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon13.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon14.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon14.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon15.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon15.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon16.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon17.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon17.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon18.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon18.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon19.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon19.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon2.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon20.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon20.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon21.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon21.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon22.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon22.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon23.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon23.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon3.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon3.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon4.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon5.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon5.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon6.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon6.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon7.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon7.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon8.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon8.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Icon9.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Icon9.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/IconList.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/IconList.bmp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/IconMain.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/IconMain.ico -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Pic1.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Pic1.BMP -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Pic2.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Pic2.BMP -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/PicAuthor.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/PicAuthor.bmp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/PicMain.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/PicMain.BMP -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/PicR.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/PicR.BMP -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/PicR.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/PicR.cur -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/PicW.BMP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/PicW.BMP -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/PicW.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/PicW.cur -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/res/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/res/Thumbs.db -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Basic.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Basic.htm -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/alex1.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/DOS/alex1.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/alex2.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/DOS/alex2.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/alex3.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/DOS/alex3.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/alex4.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/DOS/alex4.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/demo1.vms: -------------------------------------------------------------------------------- 1 | ; demo.vms 2 | 3 | .stack 8192 4 | 5 | start: ; 0 6 | out 2,string1 7 | out 10,0 8 | ld dword r0,r3 9 | cmp int r0,1 ; 14 10 | jpc b error ; 1e 11 | push r0 ; 24 12 | call fun1 ; 29 13 | cal dword add rs,4 ; 2e 14 | out 2,string2 ; 38 11f 15 | out 0,r0 ; 42 16 | exit 17 | error: ; 4d 18 | out 0,0 19 | exit 20 | fun1: ; 58 21 | push rb ; 58 22 | ld dword rb,rs ; 5d 23 | ld dword r0,rb ; 67 24 | cal dword add r0,12 ; 71 25 | ld dword r0,[r0] ; 7b 26 | cmp int r0,1 ; 85 27 | jpc a jmp1 ; 8f 28 | jmp jmp2 ; 95 29 | jmp1: ; 9a 30 | push r0 ; 9a 31 | cal int sub r0,1 ; 9f 32 | push r0 ; a9 33 | call fun1 ; ae 34 | cal dword add rs,4 ; b3 35 | ld dword r1,r0 ; bd 36 | pop r0 ; c7 37 | cal int mul r0,r1 ; cc 38 | jmp2: ; d6 39 | ld dword rs,rb ; d6 40 | pop rb ; e0 41 | ret ; e5 42 | data string1 byte "This program is use to work out n!=?",$a,"please input n=",0 ; e6 43 | data string2 byte "the result is ",0 ; 11f 44 | end 45 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/vmbasic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/DOS/vmbasic.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/vmbeta.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/DOS/vmbeta.cpp -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/vmbeta.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/DOS/vmbeta.txt -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/DOS/说明.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/DOS/说明.txt -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/Fire.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Examples/Fire.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/Game1.TGA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Examples/Game1.TGA -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/Game2.TGA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Examples/Game2.TGA -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/Game3.TGA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Examples/Game3.TGA -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/alex1.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Examples/alex1.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/alex2.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Examples/alex2.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/alex3.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Examples/alex3.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/alex4.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Examples/alex4.bas -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/hello.bas: -------------------------------------------------------------------------------- 1 | PRINT "Hello, World !!" 2 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Examples/vmdemo.vms: -------------------------------------------------------------------------------- 1 | ; demo.vms 2 | 3 | .stack 8192 4 | 5 | start: ; 0 6 | out 2,string1 7 | out 10,0 8 | ld dword r0,r3 9 | cmp int r0,1 ; 14 10 | jpc b error ; 1e 11 | push r0 ; 24 12 | call fun1 ; 29 13 | cal dword add rs,4 ; 2e 14 | out 2,string2 ; 38 11f 15 | out 0,r0 ; 42 16 | exit 17 | error: ; 4d 18 | out 0,0 19 | exit 20 | fun1: ; 58 21 | push rb ; 58 22 | ld dword rb,rs ; 5d 23 | ld dword r0,rb ; 67 24 | cal dword add r0,12 ; 71 25 | ld dword r0,[r0] ; 7b 26 | cmp int r0,1 ; 85 27 | jpc a jmp1 ; 8f 28 | jmp jmp2 ; 95 29 | jmp1: ; 9a 30 | push r0 ; 9a 31 | cal int sub r0,1 ; 9f 32 | push r0 ; a9 33 | call fun1 ; ae 34 | cal dword add rs,4 ; b3 35 | ld dword r1,r0 ; bd 36 | pop r0 ; c7 37 | cal int mul r0,r1 ; cc 38 | jmp2: ; d6 39 | ld dword rs,rb ; d6 40 | pop rb ; e0 41 | ret ; e5 42 | data string1 byte "This program is use to work out n!=?",$a,"please input n=",0 ; e6 43 | data string2 byte "the result is ",0 ; 11f 44 | end 45 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Help/IconMain.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Help/IconMain.GIF -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Help/Look.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Help/Look.gif -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Help/Look.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Help/Look.tga -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Help/Look2.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Help/Look2.GIF -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Help/Look3.GIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Help/Look3.GIF -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Help/butten4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Help/butten4.jpg -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Help/button1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Help/button1.jpg -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/Readme.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/Readme.htm -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/StdLib.VBL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/StdLib.VBL -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/VmBIDE.ini: -------------------------------------------------------------------------------- 1 | 2 | [IDE] 3 | VMBETA=VmBeta.Exe 4 | STDLIB=StdLib.VBL 5 | TEXTCOLOR=8421376 6 | ASMCOLOR=8421504 -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/hello.bas: -------------------------------------------------------------------------------- 1 | PRINT "Hello, World !!" 2 | -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/tools/vmbeta.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/tools/vmbeta.txt -------------------------------------------------------------------------------- /vmbasic/imapps/vmbide/vmbeta.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/imapps/vmbide/vmbeta.txt -------------------------------------------------------------------------------- /vmbasic/iplatfrm.cpp: -------------------------------------------------------------------------------- 1 | #include "iplatfrm.h" 2 | 3 | #if defined(WIN32) 4 | 5 | long _i_timer() 6 | { 7 | return clock(); 8 | } 9 | 10 | #elif defined(__unix) 11 | 12 | long _i_timer() 13 | { 14 | static struct timezone tz={ 0,0 }; 15 | struct timeval time; 16 | gettimeofday(&time,&tz); 17 | return (time.tv_sec*1000+time.tv_usec/1000); 18 | } 19 | 20 | #else 21 | 22 | long _i_timer() 23 | { 24 | return (clock()*1000)/CLK_TCK; 25 | } 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /vmbasic/iplatfrm.h: -------------------------------------------------------------------------------- 1 | #ifndef __I_PLATFORM_ 2 | 3 | #include "ifstream.h" 4 | 5 | #if defined(WIN32) 6 | #define __I_PLATFORM_ "WIN32" 7 | #include 8 | #include 9 | 10 | long _i_timer(); 11 | 12 | 13 | #elif defined(__unix) 14 | 15 | #define __I_PLATFORM_ "UNIX" 16 | 17 | #include 18 | 19 | long _i_timer(); 20 | 21 | #else 22 | 23 | #define __I_PLATFORM_ "UNKNOW" 24 | 25 | #include 26 | 27 | long _i_timer(); 28 | 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /vmbasic/iscreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __I_SCREEN_H__ 2 | #define __I_SCREEN_H__ 3 | 4 | class iScreen 5 | { 6 | public: 7 | virtual void ScreenView() = 0; 8 | }; 9 | 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /vmbasic/istream.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/istream.h -------------------------------------------------------------------------------- /vmbasic/istring.h: -------------------------------------------------------------------------------- 1 | //====================================================================== 2 | // 3 | // istring.h 4 | // 5 | // NOTE: by Linwei on 3-12-2002 6 | // 7 | //====================================================================== 8 | 9 | 10 | 11 | #ifndef __I_STRING_H__ 12 | #define __I_STRING_H__ 13 | 14 | #ifndef __cplusplus 15 | #error This file can only be compiled with a C++ compiler !! 16 | #endif 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "ivector.h" 23 | 24 | class iString 25 | { 26 | protected: 27 | int StrLen; 28 | int BlockLength; 29 | char *StrBuf; 30 | char Nil; 31 | void SetupBuf() { StrLen=0; StrBuf=NULL; BlockLength=64; AdjustLength(1); Nil=0; } 32 | void ReleaseBuf() { if (StrBuf) delete []StrBuf; StrBuf=NULL; StrLen=0; } 33 | int GetBlock(int Length) { return (Length+63)/64; } 34 | int AdjustLength(int NewLength) { 35 | int BlockCount=GetBlock(StrLen),NewCount=GetBlock(NewLength+3); 36 | char *NewBuf; 37 | if (BlockCount==NewCount) { StrLen=NewLength; return 0; } 38 | NewBuf=new char[BlockLength*NewCount]; 39 | if (!NewBuf) return -1; 40 | if (StrBuf) { 41 | strncpy(NewBuf,StrBuf,(StrLenStrLen||StrLen==0||endpos>StrLen) return -1; 67 | NewLength=StrLen-(endpos-startpos)+len; 68 | LeftLen=StrLen-endpos; 69 | if (AdjustLength(NewLength)) return -2; 70 | memmove(StrBuf+startpos+len,StrBuf+endpos,LeftLen); 71 | memcpy(StrBuf+startpos,s,len); 72 | StrBuf[NewLength]=0; 73 | return 0; 74 | } 75 | //iString(iString &s1,char *s2,int l) { iString::iString(); StrCpy(s1.GetString(),s1.GetLength()); StrCat(s2,l); } 76 | public: 77 | virtual ~iString() { ReleaseBuf(); } 78 | iString() { SetupBuf(); } 79 | iString(char ch) { SetupBuf(); Set(ch); } 80 | iString(char *string) { SetupBuf(); Set(string); } 81 | iString(iString &s) { SetupBuf(); Set(s); } 82 | 83 | int GetLength() { return StrLen; } 84 | char *GetString() { static char d[2]; d[0]=0; return (StrBuf)?StrBuf:d; } 85 | 86 | void Set(char ch) { char d[2]; d[0]=ch; d[1]=0; StrCpy(d,2); } 87 | void Set(char *s) { StrCpy(s,strlen(s)); } 88 | void Set(iString &s) { StrCpy(s.GetString(),s.GetLength()); } 89 | iString &Append(char ch) { StrCat(ch); return *this; } 90 | iString &Append(char *text) { StrCat(text,strlen(text)); return *this; } 91 | iString &Append(iString &s) { StrCat(s.GetString(),s.GetLength()); return *this; } 92 | int Insert(int pos,char ch) { char d[2]; d[0]=ch; d[1]=0; return Replace(pos,pos,d,1); } 93 | int Insert(int pos,char *s) { return Replace(pos,pos,s,strlen(s)); } 94 | int Insert(int pos,iString &s) { return Replace(pos,pos,s.GetString(),s.GetLength()); } 95 | 96 | int operator ==(char *s) { return (strcmp(StrBuf,s))?0:1; } 97 | int operator ==(iString&s) { return (strcmp(StrBuf,s.GetString()))?0:1; } 98 | int operator !=(char *s) { return (strcmp(StrBuf,s))?1:0; } 99 | int operator !=(iString&s) { return (strcmp(StrBuf,s.GetString()))?1:0; } 100 | char& operator[](int id) { return (id>=0&&id<=StrLen)?StrBuf[id]:Nil; } 101 | iString& operator=(char ch) { Set(ch); return *this; } 102 | iString& operator=(char *s) { Set(s); return *this; } 103 | iString& operator=(iString &s) { Set(s); return *this; } 104 | iString& operator+=(char ch) { Append(ch); return *this; } 105 | iString& operator+=(char *s) { Append(s); return *this; } 106 | iString& operator+=(iString &s) { Append(s); return *this; } 107 | 108 | /****** special functions *******/ 109 | void VarArg(char *format,...) { char buf[1000]; va_list argptr; va_start(argptr,format);vsprintf(buf,format,argptr);va_end(argptr); Set(buf); } 110 | void ToLowCase() { for (int i=0;i='A'&&StrBuf[i]<='Z') StrBuf[i]+=('a'-'A'); } 111 | void ToHiCase() { for (int i=0;i='a'&&StrBuf[i]<='z') StrBuf[i]-=('a'-'A'); } 112 | void Split(char *Splitters, int SplitterCount, IVector &Result) { 113 | iString line(""); 114 | Result.SetLength(0); 115 | for (int i=0;i 3 | #include 4 | 5 | ///////////////////////////////////////////////////////////////////// 6 | int IVMBeta::VmCreate(int size,vbyte *data,vdword *VmRegs) 7 | { 8 | if (VirtualMem) { 9 | vbyte *nvm=new vbyte[size]; 10 | if (!size) return -1; 11 | memcpy(nvm,VirtualMem,(VmSize<(unsigned)size)?VmSize:size); 12 | delete []VirtualMem; 13 | VirtualMem=nvm; 14 | VmSize=size; 15 | } else { 16 | VirtualMem=new vbyte[size]; 17 | if (!VirtualMem) return -1; 18 | memset(VirtualMem,0,size); 19 | VmSize=size; 20 | } 21 | VmStrings=new ILister; 22 | if (!VmStrings) { VmRelease(); return -1; } 23 | memset(&VmStartup,0,sizeof(VmStartup)); 24 | if (data) memcpy(VirtualMem,data,size); 25 | if (VmRegs) memcpy(&VmStartup,VmRegs,sizeof(VmStartup)); 26 | VmReset(); 27 | return 0; 28 | } 29 | 30 | void IVMBeta::VmRelease() 31 | { 32 | if (VirtualMem) delete []VirtualMem; 33 | if (VmStrings) delete VmStrings; 34 | VirtualMem=NULL; 35 | VmStrings=NULL; 36 | VmSize=0; 37 | } 38 | void IVMBeta::VmReset() 39 | { 40 | VmRegs=VmStartup; 41 | VmStatus=0; 42 | if (!VirtualMem) return; 43 | if (!VmStrings) return; 44 | VmStrings->Clear(); 45 | VmStrings->Alloc(); 46 | } 47 | IVMBeta::IVMBeta() 48 | { 49 | VirtualMem=0; 50 | VmStrings=0; 51 | VmSize=0; 52 | VmStatus=0; 53 | } 54 | IVMBeta::~IVMBeta() 55 | { 56 | VmRelease(); 57 | } 58 | 59 | void IVMBeta::Process() 60 | { 61 | vbyte opr; 62 | vbyte mode; 63 | vbyte *code=VirtualMem; 64 | vdword ip=VmRegs.RP; 65 | vdword minsp=0; 66 | vdword maxsize=VmSize-1; 67 | vbyte type1,type2; 68 | vdword *regs=&VmRegs.RP; 69 | vbyte *data1,*data2; 70 | vbyte oprlen=0; 71 | short i; 72 | 73 | opr=code[ip]&0xf0; 74 | mode=code[ip]&0x0f; 75 | VmStatus=0; 76 | switch (opr) 77 | { 78 | case 0x00: oprlen=1; break; /* NOOP OPERATOR */ 79 | case 0x10: /* LD OPERATOR */ 80 | oprlen=10; 81 | type1=((code[ip+1]>>2)&3); type2=(code[ip+1]&3); 82 | data1=code+ip+2; data2=data1+4; 83 | if (type1==0) data1=(vbyte*)&(regs[*data1]); 84 | else if (type1==1) data1=code+regs[*data1]; 85 | else if (type1==2) { VmError(1001); break; } 86 | else if (type1==3) data1=code+*(vdword*)data1; 87 | if (type2==0) data2=(vbyte*)&(regs[*data2]); 88 | else if (type2==1) data2=code+regs[*data2]; 89 | else if (type2==3) data2=code+*(vdword*)data2; 90 | if (mode==2) *(vbyte*)data1=*(vbyte*)data2; 91 | else if (mode==1) *(vword*)data1=*(vword*)data2; 92 | else *(vdword*)data1=*(vdword*)data2; 93 | break; 94 | case 0x20: /* PUSH OPERATOR */ 95 | oprlen=5; 96 | data1=code+ip+1; 97 | if (mode==0x0f) { /* PUSH ALL */ 98 | for (i=0;i<8;i++) { 99 | if (VmRegs.RS=maxsize) { VmError(1002); break; } 100 | *(vdword*)(code+VmRegs.RS)=regs[i]; 101 | VmRegs.RS-=4; 102 | } 103 | } else { 104 | if (VmRegs.RS=maxsize) { VmError(1002); break; } 105 | if (mode==0) data1=(vbyte*)&(regs[*data1]); 106 | else if (mode==1) data1=code+regs[*data1]; 107 | else if (mode==3) data1=code+*(vdword*)data1; 108 | *(vdword*)(code+VmRegs.RS)=*(vdword*)data1; 109 | VmRegs.RS-=4; 110 | } 111 | break; 112 | case 0x30: /* POP OPERATOR */ 113 | oprlen=5; 114 | data1=code+ip+1; 115 | if (mode==0x0f) { /* POP ALL */ 116 | for (i=7;i>=0;i--) { 117 | VmRegs.RS+=4; 118 | if (VmRegs.RS>=maxsize) { VmError(1002); break; } 119 | regs[i]=*(vdword*)(code+VmRegs.RS); 120 | } 121 | } else { 122 | VmRegs.RS+=4; 123 | if (VmRegs.RS>=maxsize) { VmError(1002); break; } 124 | if (mode==0) data1=(vbyte*)&(regs[*data1]); 125 | else if (mode==1) data1=code+regs[*data1]; 126 | else if (mode==2) { VmError(1001); break; } 127 | else if (mode==3) data1=code+*(vdword*)data1; 128 | *(vdword*)data1=*(vdword*)(code+VmRegs.RS); 129 | } 130 | break; 131 | case 0x40: /* IN OPERATOR */ 132 | oprlen=10; 133 | type1=((code[ip+1]>>2)&3); type2=(code[ip+1]&3); 134 | data1=code+ip+2; data2=data1+4; 135 | if (type1==0) data1=(vbyte*)&(regs[*data1]); 136 | else if (type1==1) data1=code+regs[*data1]; 137 | else if (type1==2) { VmError(1001); break; } 138 | else if (type1==3) data1=code+*(vdword*)data1; 139 | if (type2==0) data2=(vbyte*)&(regs[*data2]); 140 | else if (type2==1) data2=code+regs[*data2]; 141 | else if (type2==3) data2=code+*(vdword*)data2; 142 | *(vdword*)data1=VmIn(*(vdword*)data2); 143 | break; 144 | case 0x50: /* OUT OPERATOR */ 145 | oprlen=10; 146 | type1=((code[ip+1]>>2)&3); type2=(code[ip+1]&3); 147 | data1=code+ip+2; data2=data1+4; 148 | if (type1==0) data1=(vbyte*)&(regs[*data1]); 149 | else if (type1==1) data1=code+regs[*data1]; 150 | else if (type1==3) data1=code+*(vdword*)data1; 151 | if (type2==0) data2=(vbyte*)&(regs[*data2]); 152 | else if (type2==1) data2=code+regs[*data2]; 153 | else if (type2==3) data2=code+*(vdword*)data2; 154 | VmOut(*(vdword*)data1,*(vdword*)data2); 155 | break; 156 | case 0x60: /* JMP OPERATOR */ 157 | oprlen=5; 158 | data1=code+ip+1; 159 | if (mode==0) data1=(vbyte*)&(regs[*data1]); 160 | else if (mode==1) data1=code+regs[*data1]; 161 | else if (mode==3) data1=code+*(vdword*)data1; 162 | VmRegs.RP=*(vdword*)data1; 163 | if (VmRegs.RP>=maxsize) { VmError(1003); break; } 164 | oprlen=0; 165 | break; 166 | case 0x70: /* JPC OPERATOR */ 167 | oprlen=6; 168 | data1=code+ip+2; 169 | if (code[ip+1]==0) data1=(vbyte*)&(regs[*data1]); 170 | else if (code[ip+1]==1) data1=code+regs[*data1]; 171 | else if (code[ip+1]==3) data1=code+*(vdword*)data1; 172 | if (VmRegs.RF&(code[ip]&7)) VmRegs.RP=*(vdword*)data1, oprlen=0; 173 | if (VmRegs.RP>=maxsize) { VmError(1003); break; } 174 | break; 175 | case 0x80: /* CALL OPERATOR */ 176 | oprlen=5; 177 | data1=code+ip+1; 178 | if (mode==0) data1=(vbyte*)&(regs[*data1]); 179 | else if (mode==1) data1=code+regs[*data1]; 180 | else if (mode==3) data1=code+*(vdword*)data1; 181 | *(vdword*)&code[VmRegs.RS]=VmRegs.RP+oprlen; 182 | VmRegs.RS-=4; 183 | if (VmRegs.RS=maxsize) VmError(1005); 184 | VmRegs.RP=*(vdword*)data1; 185 | if (VmRegs.RP>=maxsize) { VmError(1005); break; } 186 | oprlen=0; 187 | break; 188 | case 0x90: /* RET OPERATOR */ 189 | oprlen=5; 190 | VmRegs.RS+=4; 191 | if (VmRegs.RS>=maxsize) VmError(1006); 192 | VmRegs.RP=*(vdword*)&code[VmRegs.RS]; 193 | if (VmRegs.RP>=maxsize) { VmError(1007); break; } 194 | oprlen=0; 195 | break; 196 | case 0xA0: /* CMP OPERATOR */ 197 | oprlen=10; 198 | i=0; 199 | type1=((code[ip+1]>>2)&3); type2=(code[ip+1]&3); 200 | data1=code+ip+2; data2=data1+4; 201 | if (type1==0) data1=(vbyte*)&(regs[*data1]); 202 | else if (type1==1) data1=code+regs[*data1]; 203 | else if (type1==3) data1=code+*(vdword*)data1; 204 | if (type2==0) data2=(vbyte*)&(regs[*data2]); 205 | else if (type2==1) data2=code+regs[*data2]; 206 | else if (type2==3) data2=code+*(vdword*)data2; 207 | if (mode==0) { 208 | if (*(vdword*)data1==*(vdword*)data2) i=1; 209 | if (*(vdword*)data1>*(vdword*)data2) i+=4; 210 | if (*(vdword*)data1<*(vdword*)data2) i+=2; 211 | } else if (mode==1) { 212 | if (*(vword*)data1==*(vword*)data2) i=1; 213 | if (*(vword*)data1>*(vword*)data2) i+=4; 214 | if (*(vword*)data1<*(vword*)data2) i+=2; 215 | } else if (mode==2) { 216 | if (*(vbyte*)data1==*(vbyte*)data2) i=1; 217 | if (*(vbyte*)data1>*(vbyte*)data2) i+=4; 218 | if (*(vbyte*)data1<*(vbyte*)data2) i+=2; 219 | } else if (mode==3) { 220 | if (*(vfloat*)data1==*(vfloat*)data2) i=1; 221 | if (*(vfloat*)data1>*(vfloat*)data2) i+=4; 222 | if (*(vfloat*)data1<*(vfloat*)data2) i+=2; 223 | } else if (mode==4) { 224 | if (*(vint*)data1==*(vint*)data2) i=1; 225 | if (*(vint*)data1>*(vint*)data2) i+=4; 226 | if (*(vint*)data1<*(vint*)data2) i+=2; 227 | } 228 | VmRegs.RF=(VmRegs.RF&(0xffffffff-7))|i; 229 | break; 230 | case 0xB0: /* CAL OPERATOR */ 231 | oprlen=10; 232 | i=code[ip+1]>>4; 233 | type1=((code[ip+1]>>2)&3); type2=(code[ip+1]&3); 234 | data1=code+ip+2; data2=data1+4; 235 | if (type1==0) data1=(vbyte*)&(regs[*data1]); 236 | else if (type1==1) data1=code+regs[*data1]; 237 | else if (type1==2) { VmError(1010); break; } 238 | else if (type1==3) data1=code+*(vdword*)data1; 239 | if (type2==0) data2=(vbyte*)&(regs[*data2]); 240 | else if (type2==1) data2=code+regs[*data2]; 241 | else if (type2==3) data2=code+*(vdword*)data2; 242 | if (mode==0) { 243 | if (i==0) *(vdword*)data1+=*(vdword*)data2; else 244 | if (i==1) *(vdword*)data1-=*(vdword*)data2; else 245 | if (i==2) *(vdword*)data1*=*(vdword*)data2; else { 246 | if (*(vdword*)data2==0) { VmError(1); break; } 247 | if (i==3) *(vdword*)data1/=*(vdword*)data2; else 248 | if (i==4) *(vdword*)data1%=*(vdword*)data2; 249 | } 250 | } else if (mode==1) { 251 | if (i==0) *(vword*)data1+=*(vword*)data2; else 252 | if (i==1) *(vword*)data1-=*(vword*)data2; else 253 | if (i==2) *(vword*)data1*=*(vword*)data2; else { 254 | if (*(vword*)data2==0) { VmError(1); break; } 255 | if (i==3) *(vword*)data1/=*(vword*)data2; 256 | if (i==4) *(vword*)data1%=*(vword*)data2; 257 | } 258 | } else if (mode==2) { 259 | if (i==0) *(vbyte*)data1+=*(vbyte*)data2; else 260 | if (i==1) *(vbyte*)data1-=*(vbyte*)data2; else 261 | if (i==2) *(vbyte*)data1*=*(vbyte*)data2; else { 262 | if (*(vbyte*)data2==0) { VmError(1); break; } 263 | if (i==3) *(vbyte*)data1/=*(vbyte*)data2; else 264 | if (i==4) *(vbyte*)data1%=*(vbyte*)data2; 265 | } 266 | } else if (mode==3) { 267 | if (i==0) *(vfloat*)data1+=*(vfloat*)data2; else 268 | if (i==1) *(vfloat*)data1-=*(vfloat*)data2; else 269 | if (i==2) *(vfloat*)data1*=*(vfloat*)data2; else { 270 | if (*(vfloat*)data2==0) { VmError(1); break; } 271 | if (i==3) *(vfloat*)data1/=*(vfloat*)data2; 272 | else { VmError(2); break; } 273 | } 274 | } else if (mode==4) { 275 | if (i==0) *(vint*)data1+=*(vint*)data2; else 276 | if (i==1) *(vint*)data1-=*(vint*)data2; else 277 | if (i==2) *(vint*)data1*=*(vint*)data2; else { 278 | if (*(vint*)data2==0) { VmError(1); break; } 279 | if (i==3) *(vint*)data1/=*(vint*)data2; else 280 | if (i==4) *(vint*)data1%=*(vint*)data2; 281 | } 282 | } 283 | break; 284 | case 0xF0: /* EXIT OPERATOR */ 285 | oprlen=1; 286 | VmStatus=1; 287 | break; 288 | } 289 | if (VmRegs.RP==ip) VmRegs.RP+=oprlen; 290 | } 291 | 292 | void IVMBeta::Excute() 293 | { 294 | VmReset(); 295 | while (VmStatus==0) Process(); 296 | } 297 | ///////////////////////////////////////////////////////////////////// 298 | #include 299 | #include 300 | 301 | vdword IVMBeta::VmIn(vdword port) 302 | { 303 | long i=VmRegs.R3; 304 | long j=VmRegs.R2; 305 | float f; 306 | char *text,*textp; 307 | switch (port) 308 | { 309 | case 0: i=(int)(*(float*)&VmRegs.R3); break; 310 | case 1: f=(float)i; i=*(long*)&f; break; 311 | case 2: i=VmStrings->Alloc()*(-1);(*VmStrings)[-i]->Set(""); break; 312 | case 3: text=VmIOString(i); if (!text) { VmError(103); break; } 313 | sscanf(text,"%ld",&i); break; 314 | case 4: if (j>=0) { VmError(104); break; } 315 | (*VmStrings)[-j]->VarArg("%ld",(long)VmRegs.R3); 316 | break; 317 | case 5: text=VmIOString(j); if (i>=0||!text) { VmError(105); break; } 318 | (*VmStrings)[-i]->Set(text); break; 319 | case 6: text=VmIOString(j); if (i>=0||!text) { VmError(106); break; } 320 | (*VmStrings)[-i]->Append(text); break; 321 | case 7: text=VmIOString(i); if (!text) { VmError(107); break; } 322 | i=strlen(text); break; 323 | case 8: VmStrings->Release(-i); break; 324 | case 9: text=VmIOString(i); textp=VmIOString(j); 325 | if (text==NULL||textp==NULL) { i=-1; break; } 326 | i=strcmp(text,textp); break; 327 | case 0x0a: if (j>=0) { VmError(104); break; } 328 | (*VmStrings)[-j]->VarArg("%f",(float)VmRegs.R3); 329 | break; 330 | case 0x0b: text=VmIOString(i); if (!text) { VmError(103); break; } 331 | sscanf(text,"%f",&i); break; 332 | case 0x0c: text=VmIOString(i); if (text==NULL) { i=-1; break; } 333 | i=text[j]; break; 334 | case 0x0d: text=VmIOString(i); if (text==NULL) { i=-1; break; } 335 | if (j<0||j>=(long)strlen(text)) break; 336 | text[j]=(char)VmRegs.R1; 337 | break; 338 | case 0x0e: i=0x10000L; break; 339 | case 0x0f: i=clock()*1000/(long)CLK_TCK; break; 340 | case 0x10: f=*(float*)&i; f=(float)sin(f); i=*(long*)&f; break; 341 | case 0x11: f=*(float*)&i; f=(float)cos(f); i=*(long*)&f; break; 342 | case 0x12: f=*(float*)&i; f=(float)tan(f); i=*(long*)&f; break; 343 | case 0x13: f=*(float*)&i; f=(float)sqrt(f); i=*(long*)&f; break; 344 | case 0x14: i=((i>=0)?(i):(-i)); break; 345 | case 0x15: f=*(float*)&i; f=((f>=0)?(f):(-f)); i=*(long*)&f; break; 346 | } 347 | return i; 348 | } 349 | 350 | #include "ifstream.h" 351 | void IVMBeta::VmError(vdword error) 352 | { 353 | VmStatus=1002; 354 | iserr.VarArg("[Vm Error]: %d at RP=%lxh\r\n",error,VmRegs.RP); 355 | } 356 | char *IVMBeta::VmIOString(int id) 357 | { 358 | char *text; 359 | VmStrings->Error=0; 360 | if (id==0) return NULL; 361 | if (id<0) { 362 | text=(*VmStrings)[-id]->GetString(); 363 | if (VmStrings->Error) return NULL; 364 | } else { 365 | if (id>(int)VmSize) return NULL; 366 | text=(char*)VirtualMem+id; 367 | } 368 | return text; 369 | } 370 | void IVMBeta::VmOut(vdword port,vdword value) 371 | { 372 | int ivalue=*(int*)&value; 373 | static char line[256]; 374 | 375 | switch (port) 376 | { 377 | case 0x00: isout.VarArg("%ld\r\n",value); break; 378 | case 0x01: case 2: 379 | char *text; if (ivalue>0) text=(char*)VirtualMem+value; 380 | else if (ivalue<0) text=(*VmStrings)[-ivalue]->GetString(); 381 | else { VmError(202); break; } 382 | isout.VarArg("%s%s",text,(port==2)?"":"\r\n"); 383 | break; 384 | case 0x03: isout.VarArg("%ld",value); break; 385 | case 0x04: isout.VarArg("%c",value); break; 386 | case 0x05: isout.VarArg("%f",*(float*)&value); break; 387 | case 0x0A: gets(line); sscanf(line,"%ld",&VmRegs.R3); break; 388 | case 0x0B: gets(line); (*VmStrings)[-(long)VmRegs.R3]->Set(line); break; 389 | case 0x0C: gets(line); sscanf(line,"%f",&VmRegs.R3); break; 390 | } 391 | } 392 | 393 | -------------------------------------------------------------------------------- /vmbasic/ivmsbeta.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ivmsbeta.h -------------------------------------------------------------------------------- /vmbasic/ivmsca.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ivmsca.cpp -------------------------------------------------------------------------------- /vmbasic/ivmsca.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ivmsca.h -------------------------------------------------------------------------------- /vmbasic/ivmscc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ivmscc.h -------------------------------------------------------------------------------- /vmbasic/ivmscexp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ivmscexp.cpp -------------------------------------------------------------------------------- /vmbasic/ivmscs.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ivmscs.cpp -------------------------------------------------------------------------------- /vmbasic/ivmscv.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/ivmscv.cpp -------------------------------------------------------------------------------- /vmbasic/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/license.txt -------------------------------------------------------------------------------- /vmbasic/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skywind3000/VmBasic/e010676025fd2f953adbb691e97827258b34e654/vmbasic/readme.txt --------------------------------------------------------------------------------