Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bios.h>
- /*
- * Graphic library for DOS
- * By Caiwan / Industrial Revolutioners
- *
- */
- typedef unsigned char uchar;
- typedef unsigned short ushort;
- typedef unsigned int uint;
- // sets 13h video mode (320x200)
- void initgraph(){
- asm{
- mov ax, 13h
- int 10h
- }
- }
- // sets 10h default mode to text
- void closegraph(){
- asm{
- mov ax, 10h
- int 10h
- }
- }
- //puts a pixel to a VRAM offset
- void putpixel(ushort offs, uchar p){
- if (offs >= 320*200) return;
- asm {
- mov di, offs
- mov ax, 0xA000
- mov es, ax
- xor cx, cx
- xor ax, ax
- mov al, p
- stosb
- }
- }
- //puts a pixel to a specified xy coord
- void putpixel(ushort x, ushort y, uchar p){
- putpixel (320*y+x, p);
- }
- //sets a palette token to a specified RGB color
- void setpalette(uchar p, uchar r, uchar g, uchar b) {
- asm {
- xor bx, bx
- xor dx, dx
- xor cx, cx
- mov bl, p
- mov dh, r
- mov cl, g
- mov ch, b
- mov ax, 1010h
- int 10h
- }
- }
- /*
- * MAIN FUNCTION
- *
- */
- #include <math.h>
- int main(){
- // init graph
- initgraph();
- // generate a grazscale palette
- for (uchar i=0; i<255; i++){
- setpalette (i, i >> 2, i >> 1, i);
- }
- ushort kesz = 0;
- float t = 0.0f;
- do {
- float k = 1.5f*(1.1f+sin(t));
- float ca = cos(.5*k+t);
- float sa = sin(.5*k+t);
- for (ushort x = 0; x<320; x++)
- for(ushort y = 0; y<200; y++){
- float _x = ((float)x-160) * k;
- float _y = ((float)y-100) * k;
- float __x = ca * _x - sa * _y;
- float __y = sa * _x + ca * _y;
- uchar xx = (uchar)__x;
- uchar yy = (uchar)__y;
- uchar tx = xx^yy;
- putpixel(x, y, tx);
- }
- t += 0.1f;
- kesz = !_bios_keybrd(_KEYBRD_READY);
- } while (kesz);
- // release graphics and get back to DOS
- closegraph();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement