有一天遇到了有个朋友介绍了一个wdosX, 真是牛,看样子,用delphi写个windows 3.2 应该不成问题,
原来 PE32文件只不过是windows下的角本,哇靠,wdosx作者就是牛,虚拟个DOS系统吧,看看这个例子就明白了(重回DOS时代)
program testdd;
{$APPTYPE CONSOLE}
uses SysUtils, Crt, Dos;
type DWORD = LongWord;
const CR = #13#10; { 回车符 } A000 = $a0000; { 显示内存基地址指针 }
var c, x, y: Word; { 颜色合成变量 }
{ 颜色合成过程 }procedure SetRGB(c, r, g, b: Byte);begin { 直接修改颜色寄存器 } Port[$3c8] := c; Port[$3c9] := r; Port[$3c9] := g; Port[$3c9] := b;end;
{ 主程序 }begin Port[$60] := 0; { 键盘缓冲区清空 } Write(CR + 'FIRE Emulation Program Version 1.00'); Write(CR + 'Copyright (C) 1997-2000, Phoenix2000.'); Write(CR + 'Orginal Code from TMT Pascal DirectX Sample.'); Write(CR + CR + 'Compiler: Borland Delphi 5.0 + WDOSX 0.96 DOS Extender.'); Write(CR + 'Note that this program is running in DOS Protected Mode.'); Write(CR + 'Compiled on: 2001-01-07 22:50'); Write(CR + CR + 'Press any key to start...'); repeat until Port[$60] < $80; { 判断键盘是否被按下 } Port[$60] := 0; { 键盘缓冲区清空 } Randomize; { 初始化随机数发生器 } asm mov ax, 13h { 设置显示模式为 13H 模式,即 X-MODE 模式} int 10h { 调用显示模式修改中断 } end; for x := 1 to 32 do begin { 设置颜色表 } SetRGB(x, x * 2 - 1, 0, 0); SetRGB(x + 32, 63, x * 2 - 1, 0); SetRGB(x + 64, 63, 63, x * 2 - 1); SetRGB(x + 96, 63, 63, 63); end; repeat x := 0; repeat y := 1; repeat c := (Mem[A000 + y * 320 + x] + Mem[A000 + y * 320 + x + 2] + Mem[A000 + y * 320 + x - 2] + Mem[A000 + (y + 2) * 320 + x + 2]) shr 2; if c <> 0 then Dec(c); MemW[A000 + (y - 2) * 320 + x] := (c shl 8) + c; MemW[A000 + (y - 1) * 320 + x] := (c shl 8) + c; Inc(y, 2); until y > 202; Dec(y, 2); Mem[A000 + y * 320 + x] := Random(2) * 160; Inc(x, 2); until x >= 320; until Port[$60] < $80; { 判断键盘是否被按下 } asm mov ax, 3 { 返回到文本模式 } int 10h { 调用显示模式修改中断 } end; Write(CR + 'Program Finished.' + CR + CR + 'Thank you!' + CR);end.
用的delphi2005编译时,发现dos.pas编译不过哟,因为:absolute with memory addresses will work in Delphi 2..5, but not in Delphi 6/7. Of course the given address must be a linear address. For example the Delphi version of the TP code var shiftstate:byte absolute $0000:$0417 (or $0040:$0017) should be var shiftstate:byte absolute $417 (the linear address for memory below 1M is calculated like segment*16+offset. Okay, that was a bad example, since the segment was zero :-)
所以,我就这样改,那以后是不是得用mem^[]访问?
type pmembyte = ^tmembyte; tmembyte = array[0..$7ffffffe] of byte;var mem: pmembyte = pmembyte($0);//absolute 0;
最后是那些 verr dword ptr [edx+38] jnz @@00verr是读写检验指令,把dword换成 word,不知对不对
