2021-05-25
每天摸鱼刷一刷github。
今天看到一个有意思的程序,cmatrix,黑客帝国动态背景
用法:
Usage: cmatrix -[abBcfhlsmVx] [-u delay] [-C color]
-a: Asynchronous scroll
-b: Bold characters on
-B: All bold characters (overrides -b)
-c: Use Japanese characters as seen in the original matrix. Requires appropriate fonts
-f: Force the linux $TERM type to be on
-l: Linux mode (uses matrix console font)
-L: Lock mode (can be closed from another terminal)
-o: Use old-style scrolling
-h: Print usage and exit
-n: No bold characters (overrides -b and -B, default)
-s: "Screensaver" mode, exits on first keystroke
-x: X window mode, use if your xterm is using mtx.pcf
-V: Print version information and exit
-u delay (0 - 10, default 4): Screen update delay
-C [color]: Use this color for matrix (default green)
-r: rainbow mode
-m: lambda mode
github页面:https://github.com/abishekvashok/cmatrix
运行的程序截图
程序需要pdcursers环境,于是下载pdcurses,压缩包打开,居然又是源码
还好readme.md比较容易理解,找到wincon/README.md看下,Windows需要gcc,borland c++,msvc++,watcom其中一种编译器编译。
everthing搜索了下,不知道什么时候学习ruby安装的程序包里面居然有gcc,还挺全乎,make,link,ld都有
目录加入环境变量,在wincon路径下make,没多多久,居然编译好了
但是结果都是一堆后缀a的文件,Windows明显不能运行啊,想来可能是图形库,dll调用下好了
再看readme文件,还有生成dll的命令 make -f Makefile.vc WIDE=Y DLL=Y
直接编译成了dll文件,这下拿着dll文件应该好搞了
再下一步下载cmarix代码,解压,make,居然又报错了,
cmatrix.c:32:10: fatal error: termios.h: No such file or directory
各种Google,第一个居然就是cmatrix的GitHub,https://github.com/abishekvashok/cmatrix/issues/94
原来无聊的人这么多。
有一个patch补丁文件,下载下载用patch 命令更新cmatix.c这个文件,再编译,提示缺少curses.h头文件,搜索了上下文代码直接扔mingw目录下的include文件夹了, 用gcc -DVERSION="2.0" -I/path/to/pdcurses/include/dir/ cmatrix.c /path/to/pdcurses.a 命令编译了下,直接出来了一个a.exe文件,gcc默认是这个文件,看来问题不大了。
运行提示缺少pdcurses.dll文件,直接找了编译过的dll文件,运行成功
截图如下
PDCursers(PDCursers)相关介绍
PDCurses是Public Domain Curses的缩写。它是一个开源跨平台的curses库。
curses是一个在Linux/Unix下广泛应用的图形函数库,作用是可以在终端内绘制简单的图形用户界面。
curses的名字起源于"cursor optimization",即光标优化。它最早由有美国伯克利大学的Bill Joy和Ken Arnold编写的,用来处理一个游戏rogue的屏幕显示。后来贝尔实验室的Mark Horton在System III Unix中重新编写了curses
现在几乎所有的Unix/Linux操作系统都带了curses函数库,curses也加入了对鼠标的支持,一些菜单和面板的处理。可以说,curses是Linux终端图形编程的不二选择(比如著名的文字编辑器 vi 就是基于curses编的)
事实上Linux中使用的很可能是ncurses(new curses)
参考资料