鱼C论坛

 找回密码
 立即注册
查看: 2629|回复: 4

[已解决]请问怎么在显示屏上显示正弦波,方波,三角波等波形

[复制链接]
发表于 2018-7-1 13:37:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
网上只有在特定仪器上显示波形的代码,但是没有直接在显屏上显示的。请问能不能写一份直接在显屏上显示波形的代码?
最佳答案
2018-7-2 14:31:15
老样子,汇编语言+C语言


我已经完成了画点函数,但是
我弄不到16位的数学函数库,所以这个程序使用其他程序生成的数据来画图

如果你不喜欢C语言或者有其他限制要必须全部使用汇编语言,那么你可以用人工翻译也可以机器翻译,把C语言翻译成汇编语言,这不是个问题,问题是没有16位的数学函数库
你需要继续我的研究,弄到这个16位的数学函数库,这样才能更方便的画图,要画正弦波,方波,三角波等这些波形,离不开数学函数


这是生成画图数据的程序,使用了 graphics.h
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <cstdio>

struct Point
{
        unsigned char x;
        unsigned char y;
};

void PutLine(struct Point *data)
{
        printf("\tdb %d, %d", data[0].x, data[0].y);
        for(int i = 1; i < 5; ++i)
        {
                printf(", %d, %d", data[i].x, data[i].y);
        }
        printf("\n");
}

void Put(int x, int y)
{
        static int count = 0;
        static struct Point data[10];

        data[count].x = x;
        data[count].y = y;
        ++count;
        if(5 <= count)
        {
                count = 0;
                PutLine(data);
        }
}

void DrawPoint(int x, int y, COLORREF color)
{
        putpixel(x, y, color);
        Put(x, y);
}

double D2R(double deg)
{
        return deg / 180.0 * 3.14159265;
}

void DrawCircle(int x, int y, int radius, COLORREF color)
{
        for(int i = 0; i < 360; ++i)
        {
                int offset_x = (int)(x + cos(D2R(i)) * radius);
                int offset_y = (int)(y + sin(D2R(i)) * radius);
                DrawPoint(offset_x, offset_y, color);
        }
}

// 画半圆
void DrawRound(int x, int y, int radius, int a, int b, COLORREF color)
{
        for(int i = a; i < b; ++i)
        {
                int offset_x = (int)(x + cos(D2R(i)) * radius);
                int offset_y = (int)(y + sin(D2R(i)) * radius);
                DrawPoint(offset_x, offset_y, color);
        }
}

int main()
{
        initgraph(600, 850);

        IMAGE image;
        loadimage(&image, L"test.bmp");
        putimage(0, 0, &image);

        const int x = 160;
        const int y = 100;
        const int radius = 90;
        const COLORREF color = RED;

        DrawCircle(x, y, radius, color);
        DrawRound(x - (radius / 2), y, radius / 2, 0, 180, color);
        DrawRound(x + (radius / 2), y, radius / 2, 180, 360, color);
        DrawCircle(x - (radius / 2), y, radius / 2 / 2, color);
        DrawCircle(x + (radius / 2), y, radius / 2 / 2, color);

        _getch();
        closegraph();
        return 0;
}

这是经过修改的,应该可以在你的平台运行的生成程序
#include <stdio.h>
#include <windows.h>
#include <math.h>

struct Point
{
        unsigned char x;
        unsigned char y;
};

void PutLine(struct Point *data)
{
        printf("\tdb %d, %d", data[0].x, data[0].y);
        for(int i = 1; i < 5; ++i)
        {
                printf(", %d, %d", data[i].x, data[i].y);
        }
        printf("\n");
}

void Put(int x, int y)
{
        static int count = 0;
        static struct Point data[10];

        data[count].x = x;
        data[count].y = y;
        ++count;
        if(5 <= count)
        {
                count = 0;
                PutLine(data);
        }
}

void DrawPoint(int x, int y, COLORREF color)
{
        //putpixel(x, y, color);
        Put(x, y);
}

double D2R(double deg)
{
        return deg / 180.0 * 3.14159265;
}

void DrawCircle(int x, int y, int radius, COLORREF color)
{
        for(int i = 0; i < 360; ++i)
        {
                int offset_x = (int)(x + cos(D2R(i)) * radius);
                int offset_y = (int)(y + sin(D2R(i)) * radius);
                DrawPoint(offset_x, offset_y, color);
        }
}

// 画半圆
void DrawRound(int x, int y, int radius, int a, int b, COLORREF color)
{
        for(int i = a; i < b; ++i)
        {
                int offset_x = (int)(x + cos(D2R(i)) * radius);
                int offset_y = (int)(y + sin(D2R(i)) * radius);
                DrawPoint(offset_x, offset_y, color);
        }
}

int main(void)
{
        const int x = 160;
        const int y = 100;
        const int radius = 90;
        const COLORREF color = 0;

        DrawCircle(x, y, radius, color);
        DrawRound(x - (radius / 2), y, radius / 2, 0, 180, color);
        DrawRound(x + (radius / 2), y, radius / 2, 180, 360, color);
        DrawCircle(x - (radius / 2), y, radius / 2 / 2, color);
        DrawCircle(x + (radius / 2), y, radius / 2 / 2, color);

        return 0;
}



下面是画图程序,使用汇编语言+C语言
assume cs:code, ds:data

; void far DrawPoint(int x, int y, unsigned char color)
extrn _DrawPoint:far

; void far DrawRectangle(int x1, int y1, int x2, int y2, unsigned char color)
extrn _DrawRectangle:far

; void far DrawGraphics(void far *data, int color)
extrn _DrawGraphics:far

stack segment
        db 1024 dup(?)
stack ends

data segment
graphics_data:
        db 250, 100, 249, 101, 249, 103, 249, 104, 249, 106
        db 249, 107, 249, 109, 249, 110, 249, 112, 248, 114
        db 248, 115, 248, 117, 248, 118, 247, 120, 247, 121
        db 246, 123, 246, 124, 246, 126, 245, 127, 245, 129
        db 244, 130, 244, 132, 243, 133, 242, 135, 242, 136
        db 241, 138, 240, 139, 240, 140, 239, 142, 238, 143
        db 237, 144, 237, 146, 236, 147, 235, 149, 234, 150
        db 233, 151, 232, 152, 231, 154, 230, 155, 229, 156
        db 228, 157, 227, 159, 226, 160, 225, 161, 224, 162
        db 223, 163, 222, 164, 221, 165, 220, 166, 219, 167
        db 217, 168, 216, 169, 215, 170, 214, 171, 212, 172
        db 211, 173, 210, 174, 209, 175, 207, 176, 206, 177
        db 205, 177, 203, 178, 202, 179, 200, 180, 199, 180
        db 198, 181, 196, 182, 195, 182, 193, 183, 192, 184
        db 190, 184, 189, 185, 187, 185, 186, 186, 184, 186
        db 183, 186, 181, 187, 180, 187, 178, 188, 177, 188
        db 175, 188, 174, 188, 172, 189, 170, 189, 169, 189
        db 167, 189, 166, 189, 164, 189, 163, 189, 161, 189
        db 160, 190, 158, 189, 156, 189, 155, 189, 153, 189
        db 152, 189, 150, 189, 149, 189, 147, 189, 145, 188
        db 144, 188, 142, 188, 141, 188, 139, 187, 138, 187
        db 136, 186, 135, 186, 133, 186, 132, 185, 130, 185
        db 129, 184, 127, 184, 126, 183, 124, 182, 123, 182
        db 121, 181, 120, 180, 119, 180, 117, 179, 116, 178
        db 115, 177, 113, 177, 112, 176, 110, 175, 109, 174
        db 108, 173, 107, 172, 105, 171, 104, 170, 103, 169
        db 102, 168, 100, 167, 99, 166, 98, 165, 97, 164
        db 96, 163, 95, 162, 94, 161, 93, 160, 92, 159
        db 91, 157, 90, 156, 89, 155, 88, 154, 87, 152
        db 86, 151, 85, 150, 84, 149, 83, 147, 82, 146
        db 82, 145, 81, 143, 80, 142, 79, 140, 79, 139
        db 78, 138, 77, 136, 77, 135, 76, 133, 75, 132
        db 75, 130, 74, 129, 74, 127, 73, 126, 73, 124
        db 73, 123, 72, 121, 72, 120, 71, 118, 71, 117
        db 71, 115, 71, 114, 70, 112, 70, 110, 70, 109
        db 70, 107, 70, 106, 70, 104, 70, 103, 70, 101
        db 70, 100, 70, 98, 70, 96, 70, 95, 70, 93
        db 70, 92, 70, 90, 70, 89, 70, 87, 71, 85
        db 71, 84, 71, 82, 71, 81, 72, 79, 72, 78
        db 73, 76, 73, 75, 73, 73, 74, 72, 74, 70
        db 75, 69, 75, 67, 76, 66, 77, 64, 77, 63
        db 78, 61, 79, 60, 79, 59, 80, 57, 81, 56
        db 82, 55, 82, 53, 83, 52, 84, 50, 85, 49
        db 86, 48, 87, 47, 88, 45, 89, 44, 90, 43
        db 91, 42, 92, 40, 93, 39, 94, 38, 95, 37
        db 96, 36, 97, 35, 98, 34, 99, 33, 100, 32
        db 102, 31, 103, 30, 104, 29, 105, 28, 107, 27
        db 108, 26, 109, 25, 110, 24, 112, 23, 113, 22
        db 114, 22, 116, 21, 117, 20, 119, 19, 120, 19
        db 121, 18, 123, 17, 124, 17, 126, 16, 127, 15
        db 129, 15, 130, 14, 132, 14, 133, 13, 135, 13
        db 136, 13, 138, 12, 139, 12, 141, 11, 142, 11
        db 144, 11, 145, 11, 147, 10, 149, 10, 150, 10
        db 152, 10, 153, 10, 155, 10, 156, 10, 158, 10
        db 159, 10, 161, 10, 163, 10, 164, 10, 166, 10
        db 167, 10, 169, 10, 170, 10, 172, 10, 174, 11
        db 175, 11, 177, 11, 178, 11, 180, 12, 181, 12
        db 183, 13, 184, 13, 186, 13, 187, 14, 189, 14
        db 190, 15, 192, 15, 193, 16, 195, 17, 196, 17
        db 198, 18, 199, 19, 200, 19, 202, 20, 203, 21
        db 204, 22, 206, 22, 207, 23, 209, 24, 210, 25
        db 211, 26, 212, 27, 214, 28, 215, 29, 216, 30
        db 217, 31, 219, 32, 220, 33, 221, 34, 222, 35
        db 223, 36, 224, 37, 225, 38, 226, 39, 227, 40
        db 228, 42, 229, 43, 230, 44, 231, 45, 232, 47
        db 233, 48, 234, 49, 235, 50, 236, 52, 237, 53
        db 237, 54, 238, 56, 239, 57, 240, 59, 240, 60
        db 241, 61, 242, 63, 242, 64, 243, 66, 244, 67
        db 244, 69, 245, 70, 245, 72, 246, 73, 246, 75
        db 246, 76, 247, 78, 247, 79, 248, 81, 248, 82
        db 248, 84, 248, 85, 249, 87, 249, 89, 249, 90
        db 249, 92, 249, 93, 249, 95, 249, 96, 249, 98
        db 160, 100, 159, 100, 159, 101, 159, 102, 159, 103
        db 159, 103, 159, 104, 159, 105, 159, 106, 159, 107
        db 159, 107, 159, 108, 159, 109, 158, 110, 158, 110
        db 158, 111, 158, 112, 158, 113, 157, 113, 157, 114
        db 157, 115, 157, 116, 156, 116, 156, 117, 156, 118
        db 155, 119, 155, 119, 155, 120, 154, 121, 154, 121
        db 153, 122, 153, 123, 153, 123, 152, 124, 152, 125
        db 151, 125, 151, 126, 150, 127, 150, 127, 149, 128
        db 149, 128, 148, 129, 148, 130, 147, 130, 147, 131
        db 146, 131, 146, 132, 145, 132, 145, 133, 144, 133
        db 143, 134, 143, 134, 142, 135, 142, 135, 141, 136
        db 140, 136, 140, 137, 139, 137, 138, 138, 138, 138
        db 137, 138, 136, 139, 136, 139, 135, 140, 134, 140
        db 134, 140, 133, 141, 132, 141, 131, 141, 131, 142
        db 130, 142, 129, 142, 128, 142, 128, 143, 127, 143
        db 126, 143, 125, 143, 125, 143, 124, 144, 123, 144
        db 122, 144, 122, 144, 121, 144, 120, 144, 119, 144
        db 118, 144, 118, 144, 117, 144, 116, 144, 115, 144
        db 115, 145, 114, 144, 113, 144, 112, 144, 111, 144
        db 111, 144, 110, 144, 109, 144, 108, 144, 107, 144
        db 107, 144, 106, 144, 105, 144, 104, 143, 104, 143
        db 103, 143, 102, 143, 101, 143, 101, 142, 100, 142
        db 99, 142, 98, 142, 98, 141, 97, 141, 96, 141
        db 95, 140, 95, 140, 94, 140, 93, 139, 93, 139
        db 92, 138, 91, 138, 91, 138, 90, 137, 89, 137
        db 89, 136, 88, 136, 87, 135, 87, 135, 86, 134
        db 86, 134, 85, 133, 84, 133, 84, 132, 83, 132
        db 83, 131, 82, 131, 82, 130, 81, 130, 81, 129
        db 80, 128, 80, 128, 79, 127, 79, 127, 78, 126
        db 78, 125, 77, 125, 77, 124, 76, 123, 76, 123
        db 76, 122, 75, 121, 75, 121, 74, 120, 74, 119
        db 74, 119, 73, 118, 73, 117, 73, 116, 72, 116
        db 72, 115, 72, 114, 72, 113, 71, 113, 71, 112
        db 71, 111, 71, 110, 71, 110, 70, 109, 70, 108
        db 70, 107, 70, 107, 70, 106, 70, 105, 70, 104
        db 70, 103, 70, 103, 70, 102, 70, 101, 70, 100
        db 160, 100, 160, 99, 160, 98, 160, 97, 160, 96
        db 160, 96, 160, 95, 160, 94, 160, 93, 160, 92
        db 160, 92, 160, 91, 160, 90, 161, 89, 161, 89
        db 161, 88, 161, 87, 161, 86, 162, 86, 162, 85
        db 162, 84, 162, 83, 163, 83, 163, 82, 163, 81
        db 164, 80, 164, 80, 164, 79, 165, 78, 165, 78
        db 166, 77, 166, 76, 166, 76, 167, 75, 167, 74
        db 168, 74, 168, 73, 169, 72, 169, 72, 170, 71
        db 170, 71, 171, 70, 171, 69, 172, 69, 172, 68
        db 173, 68, 173, 67, 174, 67, 174, 66, 175, 66
        db 176, 65, 176, 65, 177, 64, 177, 64, 178, 63
        db 179, 63, 179, 62, 180, 62, 181, 61, 181, 61
        db 182, 61, 183, 60, 183, 60, 184, 59, 185, 59
        db 185, 59, 186, 58, 187, 58, 188, 58, 188, 57
        db 189, 57, 190, 57, 191, 57, 191, 56, 192, 56
        db 193, 56, 194, 56, 194, 56, 195, 55, 196, 55
        db 197, 55, 197, 55, 198, 55, 199, 55, 200, 55
        db 201, 55, 201, 55, 202, 55, 203, 55, 204, 55
        db 204, 55, 205, 55, 206, 55, 207, 55, 208, 55
        db 208, 55, 209, 55, 210, 55, 211, 55, 212, 55
        db 212, 55, 213, 55, 214, 55, 215, 56, 215, 56
        db 216, 56, 217, 56, 218, 56, 218, 57, 219, 57
        db 220, 57, 221, 57, 221, 58, 222, 58, 223, 58
        db 224, 59, 224, 59, 225, 59, 226, 60, 226, 60
        db 227, 61, 228, 61, 228, 61, 229, 62, 230, 62
        db 230, 63, 231, 63, 232, 64, 232, 64, 233, 65
        db 233, 65, 234, 66, 235, 66, 235, 67, 236, 67
        db 236, 68, 237, 68, 237, 69, 238, 69, 238, 70
        db 239, 71, 239, 71, 240, 72, 240, 72, 241, 73
        db 241, 74, 242, 74, 242, 75, 243, 76, 243, 76
        db 243, 77, 244, 78, 244, 78, 245, 79, 245, 80
        db 245, 80, 246, 81, 246, 82, 246, 83, 247, 83
        db 247, 84, 247, 85, 247, 86, 248, 86, 248, 87
        db 248, 88, 248, 89, 248, 89, 249, 90, 249, 91
        db 249, 92, 249, 92, 249, 93, 249, 94, 249, 95
        db 249, 96, 249, 96, 249, 97, 249, 98, 249, 99
        db 137, 100, 136, 100, 136, 100, 136, 101, 136, 101
        db 136, 101, 136, 102, 136, 102, 136, 103, 136, 103
        db 136, 103, 136, 104, 136, 104, 136, 104, 136, 105
        db 136, 105, 136, 106, 136, 106, 135, 106, 135, 107
        db 135, 107, 135, 107, 135, 108, 135, 108, 135, 108
        db 134, 109, 134, 109, 134, 109, 134, 110, 134, 110
        db 134, 110, 133, 111, 133, 111, 133, 111, 133, 112
        db 133, 112, 132, 112, 132, 113, 132, 113, 132, 113
        db 131, 114, 131, 114, 131, 114, 131, 115, 130, 115
        db 130, 115, 130, 115, 130, 116, 129, 116, 129, 116
        db 129, 116, 128, 117, 128, 117, 128, 117, 127, 117
        db 127, 118, 127, 118, 126, 118, 126, 118, 126, 118
        db 126, 119, 125, 119, 125, 119, 124, 119, 124, 119
        db 124, 119, 123, 120, 123, 120, 123, 120, 122, 120
        db 122, 120, 122, 120, 121, 120, 121, 121, 121, 121
        db 120, 121, 120, 121, 119, 121, 119, 121, 119, 121
        db 118, 121, 118, 121, 118, 121, 117, 121, 117, 121
        db 116, 121, 116, 121, 116, 121, 115, 121, 115, 121
        db 115, 122, 114, 121, 114, 121, 113, 121, 113, 121
        db 113, 121, 112, 121, 112, 121, 111, 121, 111, 121
        db 111, 121, 110, 121, 110, 121, 110, 121, 109, 121
        db 109, 121, 108, 121, 108, 121, 108, 120, 107, 120
        db 107, 120, 107, 120, 106, 120, 106, 120, 106, 120
        db 105, 119, 105, 119, 105, 119, 104, 119, 104, 119
        db 104, 119, 103, 118, 103, 118, 103, 118, 102, 118
        db 102, 118, 102, 117, 101, 117, 101, 117, 101, 117
        db 100, 116, 100, 116, 100, 116, 99, 116, 99, 115
        db 99, 115, 99, 115, 98, 115, 98, 114, 98, 114
        db 98, 114, 97, 113, 97, 113, 97, 113, 97, 112
        db 96, 112, 96, 112, 96, 111, 96, 111, 96, 111
        db 95, 111, 95, 110, 95, 110, 95, 109, 95, 109
        db 95, 109, 94, 108, 94, 108, 94, 108, 94, 107
        db 94, 107, 94, 107, 94, 106, 93, 106, 93, 106
        db 93, 105, 93, 105, 93, 104, 93, 104, 93, 104
        db 93, 103, 93, 103, 93, 103, 93, 102, 93, 102
        db 93, 101, 93, 101, 93, 101, 93, 100, 93, 100
        db 93, 100, 93, 99, 93, 99, 93, 98, 93, 98
        db 93, 98, 93, 97, 93, 97, 93, 96, 93, 96
        db 93, 96, 93, 95, 93, 95, 93, 95, 93, 94
        db 93, 94, 93, 93, 93, 93, 94, 93, 94, 92
        db 94, 92, 94, 92, 94, 91, 94, 91, 94, 91
        db 95, 90, 95, 90, 95, 90, 95, 89, 95, 89
        db 95, 89, 96, 88, 96, 88, 96, 88, 96, 87
        db 96, 87, 97, 87, 97, 86, 97, 86, 97, 86
        db 98, 85, 98, 85, 98, 85, 98, 84, 99, 84
        db 99, 84, 99, 84, 99, 83, 100, 83, 100, 83
        db 100, 83, 101, 82, 101, 82, 101, 82, 102, 82
        db 102, 81, 102, 81, 103, 81, 103, 81, 103, 81
        db 103, 80, 104, 80, 104, 80, 105, 80, 105, 80
        db 105, 80, 106, 79, 106, 79, 106, 79, 107, 79
        db 107, 79, 107, 79, 108, 79, 108, 78, 108, 78
        db 109, 78, 109, 78, 110, 78, 110, 78, 110, 78
        db 111, 78, 111, 78, 111, 78, 112, 78, 112, 78
        db 113, 78, 113, 78, 113, 78, 114, 78, 114, 78
        db 114, 78, 115, 78, 115, 78, 116, 78, 116, 78
        db 116, 78, 117, 78, 117, 78, 118, 78, 118, 78
        db 118, 78, 119, 78, 119, 78, 119, 78, 120, 78
        db 120, 78, 121, 78, 121, 78, 121, 79, 122, 79
        db 122, 79, 122, 79, 123, 79, 123, 79, 123, 79
        db 124, 80, 124, 80, 124, 80, 125, 80, 125, 80
        db 125, 80, 126, 81, 126, 81, 126, 81, 127, 81
        db 127, 81, 127, 82, 128, 82, 128, 82, 128, 82
        db 129, 83, 129, 83, 129, 83, 130, 83, 130, 84
        db 130, 84, 130, 84, 131, 84, 131, 85, 131, 85
        db 131, 85, 132, 86, 132, 86, 132, 86, 132, 87
        db 133, 87, 133, 87, 133, 88, 133, 88, 133, 88
        db 134, 88, 134, 89, 134, 89, 134, 90, 134, 90
        db 134, 90, 135, 91, 135, 91, 135, 91, 135, 92
        db 135, 92, 135, 92, 135, 93, 136, 93, 136, 93
        db 136, 94, 136, 94, 136, 95, 136, 95, 136, 95
        db 136, 96, 136, 96, 136, 96, 136, 97, 136, 97
        db 136, 98, 136, 98, 136, 98, 136, 99, 136, 99
        db 227, 100, 226, 100, 226, 100, 226, 101, 226, 101
        db 226, 101, 226, 102, 226, 102, 226, 103, 226, 103
        db 226, 103, 226, 104, 226, 104, 226, 104, 226, 105
        db 226, 105, 226, 106, 226, 106, 225, 106, 225, 107
        db 225, 107, 225, 107, 225, 108, 225, 108, 225, 108
        db 224, 109, 224, 109, 224, 109, 224, 110, 224, 110
        db 224, 110, 223, 111, 223, 111, 223, 111, 223, 112
        db 223, 112, 222, 112, 222, 113, 222, 113, 222, 113
        db 221, 114, 221, 114, 221, 114, 221, 115, 220, 115
        db 220, 115, 220, 115, 220, 116, 219, 116, 219, 116
        db 219, 116, 218, 117, 218, 117, 218, 117, 217, 117
        db 217, 118, 217, 118, 216, 118, 216, 118, 216, 118
        db 216, 119, 215, 119, 215, 119, 214, 119, 214, 119
        db 214, 119, 213, 120, 213, 120, 213, 120, 212, 120
        db 212, 120, 212, 120, 211, 120, 211, 121, 211, 121
        db 210, 121, 210, 121, 209, 121, 209, 121, 209, 121
        db 208, 121, 208, 121, 208, 121, 207, 121, 207, 121
        db 206, 121, 206, 121, 206, 121, 205, 121, 205, 121
        db 205, 122, 204, 121, 204, 121, 203, 121, 203, 121
        db 203, 121, 202, 121, 202, 121, 201, 121, 201, 121
        db 201, 121, 200, 121, 200, 121, 200, 121, 199, 121
        db 199, 121, 198, 121, 198, 121, 198, 120, 197, 120
        db 197, 120, 197, 120, 196, 120, 196, 120, 196, 120
        db 195, 119, 195, 119, 195, 119, 194, 119, 194, 119
        db 194, 119, 193, 118, 193, 118, 193, 118, 192, 118
        db 192, 118, 192, 117, 191, 117, 191, 117, 191, 117
        db 190, 116, 190, 116, 190, 116, 189, 116, 189, 115
        db 189, 115, 189, 115, 188, 115, 188, 114, 188, 114
        db 188, 114, 187, 113, 187, 113, 187, 113, 187, 112
        db 186, 112, 186, 112, 186, 111, 186, 111, 186, 111
        db 185, 111, 185, 110, 185, 110, 185, 109, 185, 109
        db 185, 109, 184, 108, 184, 108, 184, 108, 184, 107
        db 184, 107, 184, 107, 184, 106, 183, 106, 183, 106
        db 183, 105, 183, 105, 183, 104, 183, 104, 183, 104
        db 183, 103, 183, 103, 183, 103, 183, 102, 183, 102
        db 183, 101, 183, 101, 183, 101, 183, 100, 183, 100
        db 183, 100, 183, 99, 183, 99, 183, 98, 183, 98
        db 183, 98, 183, 97, 183, 97, 183, 96, 183, 96
        db 183, 96, 183, 95, 183, 95, 183, 95, 183, 94
        db 183, 94, 183, 93, 183, 93, 184, 93, 184, 92
        db 184, 92, 184, 92, 184, 91, 184, 91, 184, 91
        db 185, 90, 185, 90, 185, 90, 185, 89, 185, 89
        db 185, 89, 186, 88, 186, 88, 186, 88, 186, 87
        db 186, 87, 187, 87, 187, 86, 187, 86, 187, 86
        db 188, 85, 188, 85, 188, 85, 188, 84, 189, 84
        db 189, 84, 189, 84, 189, 83, 190, 83, 190, 83
        db 190, 83, 191, 82, 191, 82, 191, 82, 192, 82
        db 192, 81, 192, 81, 193, 81, 193, 81, 193, 81
        db 193, 80, 194, 80, 194, 80, 195, 80, 195, 80
        db 195, 80, 196, 79, 196, 79, 196, 79, 197, 79
        db 197, 79, 197, 79, 198, 79, 198, 78, 198, 78
        db 199, 78, 199, 78, 200, 78, 200, 78, 200, 78
        db 201, 78, 201, 78, 201, 78, 202, 78, 202, 78
        db 203, 78, 203, 78, 203, 78, 204, 78, 204, 78
        db 204, 78, 205, 78, 205, 78, 206, 78, 206, 78
        db 206, 78, 207, 78, 207, 78, 208, 78, 208, 78
        db 208, 78, 209, 78, 209, 78, 209, 78, 210, 78
        db 210, 78, 211, 78, 211, 78, 211, 79, 212, 79
        db 212, 79, 212, 79, 213, 79, 213, 79, 213, 79
        db 214, 80, 214, 80, 214, 80, 215, 80, 215, 80
        db 215, 80, 216, 81, 216, 81, 216, 81, 217, 81
        db 217, 81, 217, 82, 218, 82, 218, 82, 218, 82
        db 219, 83, 219, 83, 219, 83, 220, 83, 220, 84
        db 220, 84, 220, 84, 221, 84, 221, 85, 221, 85
        db 221, 85, 222, 86, 222, 86, 222, 86, 222, 87
        db 223, 87, 223, 87, 223, 88, 223, 88, 223, 88
        db 224, 88, 224, 89, 224, 89, 224, 90, 224, 90
        db 224, 90, 225, 91, 225, 91, 225, 91, 225, 92
        db 225, 92, 225, 92, 225, 93, 226, 93, 226, 93
        db 226, 94, 226, 94, 226, 95, 226, 95, 226, 95
        db 226, 96, 226, 96, 226, 96, 226, 97, 226, 97
        db 226, 98, 226, 98, 226, 98, 226, 99, 226, 99
        db 0, 0
data ends

code segment
start:
        mov        ax, stack
        mov        ss, ax
        mov        sp, 1024
        mov        ax, data
        mov        ds, ax
        mov        es, ax
        
        call        EnterGraphicsMode
        
        mov        ax, 85
        push        ax
        push        es
        mov        ax, offset graphics_data
        push        ax
        call        _DrawGraphics
        add        sp, 6
        
        call        getchar
        call        LeaveGraphicsMode
        mov        ax, 4c00h
        int        21h

; 进入图形模式,320x200,256色
EnterGraphicsMode:
        mov        ax, 0013h
        int        10h
        ret

; 离开图像模式,回到文本模式,80x25,16色
LeaveGraphicsMode:
        mov        ax, 0003h
        int        10h
        ret

getchar:
        mov        ah, 0
        int        16h
        mov        ah, 0
        ret
code ends
end start
void far DrawPoint(int x, int y, unsigned char color)
{
        char far *const video = (char far *)0xA0000000;
        
        if((320 <= x) || (200 <= y))
                return;
        
        video[y * 320 + x] = color;
}

void far DrawRectangle(int x1, int y1, int x2, int y2, unsigned char color)
{
        int x;
        int y;
        
        for(y = y1; y < y2; ++y)
        {
                for(x = x1; x < x2; ++x)
                        DrawPoint(x, y, color);
        }
}

/* ************************************************************ */
struct Point
{
        unsigned char x;
        unsigned char y;
};

void far DrawGraphics(void far *data, int color)
{
        struct Point *circle = (struct Point *)data;

        while((circle->x != 0) && (circle->y != 0))
        {
                DrawPoint(circle->x, circle->y, color);
                ++circle;
        }
}
/* ************************************************************ */



下面是在我的环境下运行的生成程序
2.png

我还不会上色,下面是人工上色的,看起来还不错
1.png



下面是编译运行画图程序

这是tcc.bat
@echo off
set PATH=D:\TASM\BIN;%PATH%
D:\tc\tcc.exe -ID:\tc\INCLUDE -c %1
@echo on

你需要有tasm

编译Funs.c
3.png

编译并链接main.exe
4.png

运行画图程序
5.png

如果有数学函数库就更完美了,我实在弄不到这个
^_^
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-7-1 17:25:03 | 显示全部楼层
当然能啦,但你不会想用汇编写吧?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-7-2 14:31:15 | 显示全部楼层    本楼为最佳答案   
老样子,汇编语言+C语言


我已经完成了画点函数,但是
我弄不到16位的数学函数库,所以这个程序使用其他程序生成的数据来画图

如果你不喜欢C语言或者有其他限制要必须全部使用汇编语言,那么你可以用人工翻译也可以机器翻译,把C语言翻译成汇编语言,这不是个问题,问题是没有16位的数学函数库
你需要继续我的研究,弄到这个16位的数学函数库,这样才能更方便的画图,要画正弦波,方波,三角波等这些波形,离不开数学函数


这是生成画图数据的程序,使用了 graphics.h
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <cstdio>

struct Point
{
        unsigned char x;
        unsigned char y;
};

void PutLine(struct Point *data)
{
        printf("\tdb %d, %d", data[0].x, data[0].y);
        for(int i = 1; i < 5; ++i)
        {
                printf(", %d, %d", data[i].x, data[i].y);
        }
        printf("\n");
}

void Put(int x, int y)
{
        static int count = 0;
        static struct Point data[10];

        data[count].x = x;
        data[count].y = y;
        ++count;
        if(5 <= count)
        {
                count = 0;
                PutLine(data);
        }
}

void DrawPoint(int x, int y, COLORREF color)
{
        putpixel(x, y, color);
        Put(x, y);
}

double D2R(double deg)
{
        return deg / 180.0 * 3.14159265;
}

void DrawCircle(int x, int y, int radius, COLORREF color)
{
        for(int i = 0; i < 360; ++i)
        {
                int offset_x = (int)(x + cos(D2R(i)) * radius);
                int offset_y = (int)(y + sin(D2R(i)) * radius);
                DrawPoint(offset_x, offset_y, color);
        }
}

// 画半圆
void DrawRound(int x, int y, int radius, int a, int b, COLORREF color)
{
        for(int i = a; i < b; ++i)
        {
                int offset_x = (int)(x + cos(D2R(i)) * radius);
                int offset_y = (int)(y + sin(D2R(i)) * radius);
                DrawPoint(offset_x, offset_y, color);
        }
}

int main()
{
        initgraph(600, 850);

        IMAGE image;
        loadimage(&image, L"test.bmp");
        putimage(0, 0, &image);

        const int x = 160;
        const int y = 100;
        const int radius = 90;
        const COLORREF color = RED;

        DrawCircle(x, y, radius, color);
        DrawRound(x - (radius / 2), y, radius / 2, 0, 180, color);
        DrawRound(x + (radius / 2), y, radius / 2, 180, 360, color);
        DrawCircle(x - (radius / 2), y, radius / 2 / 2, color);
        DrawCircle(x + (radius / 2), y, radius / 2 / 2, color);

        _getch();
        closegraph();
        return 0;
}

这是经过修改的,应该可以在你的平台运行的生成程序
#include <stdio.h>
#include <windows.h>
#include <math.h>

struct Point
{
        unsigned char x;
        unsigned char y;
};

void PutLine(struct Point *data)
{
        printf("\tdb %d, %d", data[0].x, data[0].y);
        for(int i = 1; i < 5; ++i)
        {
                printf(", %d, %d", data[i].x, data[i].y);
        }
        printf("\n");
}

void Put(int x, int y)
{
        static int count = 0;
        static struct Point data[10];

        data[count].x = x;
        data[count].y = y;
        ++count;
        if(5 <= count)
        {
                count = 0;
                PutLine(data);
        }
}

void DrawPoint(int x, int y, COLORREF color)
{
        //putpixel(x, y, color);
        Put(x, y);
}

double D2R(double deg)
{
        return deg / 180.0 * 3.14159265;
}

void DrawCircle(int x, int y, int radius, COLORREF color)
{
        for(int i = 0; i < 360; ++i)
        {
                int offset_x = (int)(x + cos(D2R(i)) * radius);
                int offset_y = (int)(y + sin(D2R(i)) * radius);
                DrawPoint(offset_x, offset_y, color);
        }
}

// 画半圆
void DrawRound(int x, int y, int radius, int a, int b, COLORREF color)
{
        for(int i = a; i < b; ++i)
        {
                int offset_x = (int)(x + cos(D2R(i)) * radius);
                int offset_y = (int)(y + sin(D2R(i)) * radius);
                DrawPoint(offset_x, offset_y, color);
        }
}

int main(void)
{
        const int x = 160;
        const int y = 100;
        const int radius = 90;
        const COLORREF color = 0;

        DrawCircle(x, y, radius, color);
        DrawRound(x - (radius / 2), y, radius / 2, 0, 180, color);
        DrawRound(x + (radius / 2), y, radius / 2, 180, 360, color);
        DrawCircle(x - (radius / 2), y, radius / 2 / 2, color);
        DrawCircle(x + (radius / 2), y, radius / 2 / 2, color);

        return 0;
}



下面是画图程序,使用汇编语言+C语言
assume cs:code, ds:data

; void far DrawPoint(int x, int y, unsigned char color)
extrn _DrawPoint:far

; void far DrawRectangle(int x1, int y1, int x2, int y2, unsigned char color)
extrn _DrawRectangle:far

; void far DrawGraphics(void far *data, int color)
extrn _DrawGraphics:far

stack segment
        db 1024 dup(?)
stack ends

data segment
graphics_data:
        db 250, 100, 249, 101, 249, 103, 249, 104, 249, 106
        db 249, 107, 249, 109, 249, 110, 249, 112, 248, 114
        db 248, 115, 248, 117, 248, 118, 247, 120, 247, 121
        db 246, 123, 246, 124, 246, 126, 245, 127, 245, 129
        db 244, 130, 244, 132, 243, 133, 242, 135, 242, 136
        db 241, 138, 240, 139, 240, 140, 239, 142, 238, 143
        db 237, 144, 237, 146, 236, 147, 235, 149, 234, 150
        db 233, 151, 232, 152, 231, 154, 230, 155, 229, 156
        db 228, 157, 227, 159, 226, 160, 225, 161, 224, 162
        db 223, 163, 222, 164, 221, 165, 220, 166, 219, 167
        db 217, 168, 216, 169, 215, 170, 214, 171, 212, 172
        db 211, 173, 210, 174, 209, 175, 207, 176, 206, 177
        db 205, 177, 203, 178, 202, 179, 200, 180, 199, 180
        db 198, 181, 196, 182, 195, 182, 193, 183, 192, 184
        db 190, 184, 189, 185, 187, 185, 186, 186, 184, 186
        db 183, 186, 181, 187, 180, 187, 178, 188, 177, 188
        db 175, 188, 174, 188, 172, 189, 170, 189, 169, 189
        db 167, 189, 166, 189, 164, 189, 163, 189, 161, 189
        db 160, 190, 158, 189, 156, 189, 155, 189, 153, 189
        db 152, 189, 150, 189, 149, 189, 147, 189, 145, 188
        db 144, 188, 142, 188, 141, 188, 139, 187, 138, 187
        db 136, 186, 135, 186, 133, 186, 132, 185, 130, 185
        db 129, 184, 127, 184, 126, 183, 124, 182, 123, 182
        db 121, 181, 120, 180, 119, 180, 117, 179, 116, 178
        db 115, 177, 113, 177, 112, 176, 110, 175, 109, 174
        db 108, 173, 107, 172, 105, 171, 104, 170, 103, 169
        db 102, 168, 100, 167, 99, 166, 98, 165, 97, 164
        db 96, 163, 95, 162, 94, 161, 93, 160, 92, 159
        db 91, 157, 90, 156, 89, 155, 88, 154, 87, 152
        db 86, 151, 85, 150, 84, 149, 83, 147, 82, 146
        db 82, 145, 81, 143, 80, 142, 79, 140, 79, 139
        db 78, 138, 77, 136, 77, 135, 76, 133, 75, 132
        db 75, 130, 74, 129, 74, 127, 73, 126, 73, 124
        db 73, 123, 72, 121, 72, 120, 71, 118, 71, 117
        db 71, 115, 71, 114, 70, 112, 70, 110, 70, 109
        db 70, 107, 70, 106, 70, 104, 70, 103, 70, 101
        db 70, 100, 70, 98, 70, 96, 70, 95, 70, 93
        db 70, 92, 70, 90, 70, 89, 70, 87, 71, 85
        db 71, 84, 71, 82, 71, 81, 72, 79, 72, 78
        db 73, 76, 73, 75, 73, 73, 74, 72, 74, 70
        db 75, 69, 75, 67, 76, 66, 77, 64, 77, 63
        db 78, 61, 79, 60, 79, 59, 80, 57, 81, 56
        db 82, 55, 82, 53, 83, 52, 84, 50, 85, 49
        db 86, 48, 87, 47, 88, 45, 89, 44, 90, 43
        db 91, 42, 92, 40, 93, 39, 94, 38, 95, 37
        db 96, 36, 97, 35, 98, 34, 99, 33, 100, 32
        db 102, 31, 103, 30, 104, 29, 105, 28, 107, 27
        db 108, 26, 109, 25, 110, 24, 112, 23, 113, 22
        db 114, 22, 116, 21, 117, 20, 119, 19, 120, 19
        db 121, 18, 123, 17, 124, 17, 126, 16, 127, 15
        db 129, 15, 130, 14, 132, 14, 133, 13, 135, 13
        db 136, 13, 138, 12, 139, 12, 141, 11, 142, 11
        db 144, 11, 145, 11, 147, 10, 149, 10, 150, 10
        db 152, 10, 153, 10, 155, 10, 156, 10, 158, 10
        db 159, 10, 161, 10, 163, 10, 164, 10, 166, 10
        db 167, 10, 169, 10, 170, 10, 172, 10, 174, 11
        db 175, 11, 177, 11, 178, 11, 180, 12, 181, 12
        db 183, 13, 184, 13, 186, 13, 187, 14, 189, 14
        db 190, 15, 192, 15, 193, 16, 195, 17, 196, 17
        db 198, 18, 199, 19, 200, 19, 202, 20, 203, 21
        db 204, 22, 206, 22, 207, 23, 209, 24, 210, 25
        db 211, 26, 212, 27, 214, 28, 215, 29, 216, 30
        db 217, 31, 219, 32, 220, 33, 221, 34, 222, 35
        db 223, 36, 224, 37, 225, 38, 226, 39, 227, 40
        db 228, 42, 229, 43, 230, 44, 231, 45, 232, 47
        db 233, 48, 234, 49, 235, 50, 236, 52, 237, 53
        db 237, 54, 238, 56, 239, 57, 240, 59, 240, 60
        db 241, 61, 242, 63, 242, 64, 243, 66, 244, 67
        db 244, 69, 245, 70, 245, 72, 246, 73, 246, 75
        db 246, 76, 247, 78, 247, 79, 248, 81, 248, 82
        db 248, 84, 248, 85, 249, 87, 249, 89, 249, 90
        db 249, 92, 249, 93, 249, 95, 249, 96, 249, 98
        db 160, 100, 159, 100, 159, 101, 159, 102, 159, 103
        db 159, 103, 159, 104, 159, 105, 159, 106, 159, 107
        db 159, 107, 159, 108, 159, 109, 158, 110, 158, 110
        db 158, 111, 158, 112, 158, 113, 157, 113, 157, 114
        db 157, 115, 157, 116, 156, 116, 156, 117, 156, 118
        db 155, 119, 155, 119, 155, 120, 154, 121, 154, 121
        db 153, 122, 153, 123, 153, 123, 152, 124, 152, 125
        db 151, 125, 151, 126, 150, 127, 150, 127, 149, 128
        db 149, 128, 148, 129, 148, 130, 147, 130, 147, 131
        db 146, 131, 146, 132, 145, 132, 145, 133, 144, 133
        db 143, 134, 143, 134, 142, 135, 142, 135, 141, 136
        db 140, 136, 140, 137, 139, 137, 138, 138, 138, 138
        db 137, 138, 136, 139, 136, 139, 135, 140, 134, 140
        db 134, 140, 133, 141, 132, 141, 131, 141, 131, 142
        db 130, 142, 129, 142, 128, 142, 128, 143, 127, 143
        db 126, 143, 125, 143, 125, 143, 124, 144, 123, 144
        db 122, 144, 122, 144, 121, 144, 120, 144, 119, 144
        db 118, 144, 118, 144, 117, 144, 116, 144, 115, 144
        db 115, 145, 114, 144, 113, 144, 112, 144, 111, 144
        db 111, 144, 110, 144, 109, 144, 108, 144, 107, 144
        db 107, 144, 106, 144, 105, 144, 104, 143, 104, 143
        db 103, 143, 102, 143, 101, 143, 101, 142, 100, 142
        db 99, 142, 98, 142, 98, 141, 97, 141, 96, 141
        db 95, 140, 95, 140, 94, 140, 93, 139, 93, 139
        db 92, 138, 91, 138, 91, 138, 90, 137, 89, 137
        db 89, 136, 88, 136, 87, 135, 87, 135, 86, 134
        db 86, 134, 85, 133, 84, 133, 84, 132, 83, 132
        db 83, 131, 82, 131, 82, 130, 81, 130, 81, 129
        db 80, 128, 80, 128, 79, 127, 79, 127, 78, 126
        db 78, 125, 77, 125, 77, 124, 76, 123, 76, 123
        db 76, 122, 75, 121, 75, 121, 74, 120, 74, 119
        db 74, 119, 73, 118, 73, 117, 73, 116, 72, 116
        db 72, 115, 72, 114, 72, 113, 71, 113, 71, 112
        db 71, 111, 71, 110, 71, 110, 70, 109, 70, 108
        db 70, 107, 70, 107, 70, 106, 70, 105, 70, 104
        db 70, 103, 70, 103, 70, 102, 70, 101, 70, 100
        db 160, 100, 160, 99, 160, 98, 160, 97, 160, 96
        db 160, 96, 160, 95, 160, 94, 160, 93, 160, 92
        db 160, 92, 160, 91, 160, 90, 161, 89, 161, 89
        db 161, 88, 161, 87, 161, 86, 162, 86, 162, 85
        db 162, 84, 162, 83, 163, 83, 163, 82, 163, 81
        db 164, 80, 164, 80, 164, 79, 165, 78, 165, 78
        db 166, 77, 166, 76, 166, 76, 167, 75, 167, 74
        db 168, 74, 168, 73, 169, 72, 169, 72, 170, 71
        db 170, 71, 171, 70, 171, 69, 172, 69, 172, 68
        db 173, 68, 173, 67, 174, 67, 174, 66, 175, 66
        db 176, 65, 176, 65, 177, 64, 177, 64, 178, 63
        db 179, 63, 179, 62, 180, 62, 181, 61, 181, 61
        db 182, 61, 183, 60, 183, 60, 184, 59, 185, 59
        db 185, 59, 186, 58, 187, 58, 188, 58, 188, 57
        db 189, 57, 190, 57, 191, 57, 191, 56, 192, 56
        db 193, 56, 194, 56, 194, 56, 195, 55, 196, 55
        db 197, 55, 197, 55, 198, 55, 199, 55, 200, 55
        db 201, 55, 201, 55, 202, 55, 203, 55, 204, 55
        db 204, 55, 205, 55, 206, 55, 207, 55, 208, 55
        db 208, 55, 209, 55, 210, 55, 211, 55, 212, 55
        db 212, 55, 213, 55, 214, 55, 215, 56, 215, 56
        db 216, 56, 217, 56, 218, 56, 218, 57, 219, 57
        db 220, 57, 221, 57, 221, 58, 222, 58, 223, 58
        db 224, 59, 224, 59, 225, 59, 226, 60, 226, 60
        db 227, 61, 228, 61, 228, 61, 229, 62, 230, 62
        db 230, 63, 231, 63, 232, 64, 232, 64, 233, 65
        db 233, 65, 234, 66, 235, 66, 235, 67, 236, 67
        db 236, 68, 237, 68, 237, 69, 238, 69, 238, 70
        db 239, 71, 239, 71, 240, 72, 240, 72, 241, 73
        db 241, 74, 242, 74, 242, 75, 243, 76, 243, 76
        db 243, 77, 244, 78, 244, 78, 245, 79, 245, 80
        db 245, 80, 246, 81, 246, 82, 246, 83, 247, 83
        db 247, 84, 247, 85, 247, 86, 248, 86, 248, 87
        db 248, 88, 248, 89, 248, 89, 249, 90, 249, 91
        db 249, 92, 249, 92, 249, 93, 249, 94, 249, 95
        db 249, 96, 249, 96, 249, 97, 249, 98, 249, 99
        db 137, 100, 136, 100, 136, 100, 136, 101, 136, 101
        db 136, 101, 136, 102, 136, 102, 136, 103, 136, 103
        db 136, 103, 136, 104, 136, 104, 136, 104, 136, 105
        db 136, 105, 136, 106, 136, 106, 135, 106, 135, 107
        db 135, 107, 135, 107, 135, 108, 135, 108, 135, 108
        db 134, 109, 134, 109, 134, 109, 134, 110, 134, 110
        db 134, 110, 133, 111, 133, 111, 133, 111, 133, 112
        db 133, 112, 132, 112, 132, 113, 132, 113, 132, 113
        db 131, 114, 131, 114, 131, 114, 131, 115, 130, 115
        db 130, 115, 130, 115, 130, 116, 129, 116, 129, 116
        db 129, 116, 128, 117, 128, 117, 128, 117, 127, 117
        db 127, 118, 127, 118, 126, 118, 126, 118, 126, 118
        db 126, 119, 125, 119, 125, 119, 124, 119, 124, 119
        db 124, 119, 123, 120, 123, 120, 123, 120, 122, 120
        db 122, 120, 122, 120, 121, 120, 121, 121, 121, 121
        db 120, 121, 120, 121, 119, 121, 119, 121, 119, 121
        db 118, 121, 118, 121, 118, 121, 117, 121, 117, 121
        db 116, 121, 116, 121, 116, 121, 115, 121, 115, 121
        db 115, 122, 114, 121, 114, 121, 113, 121, 113, 121
        db 113, 121, 112, 121, 112, 121, 111, 121, 111, 121
        db 111, 121, 110, 121, 110, 121, 110, 121, 109, 121
        db 109, 121, 108, 121, 108, 121, 108, 120, 107, 120
        db 107, 120, 107, 120, 106, 120, 106, 120, 106, 120
        db 105, 119, 105, 119, 105, 119, 104, 119, 104, 119
        db 104, 119, 103, 118, 103, 118, 103, 118, 102, 118
        db 102, 118, 102, 117, 101, 117, 101, 117, 101, 117
        db 100, 116, 100, 116, 100, 116, 99, 116, 99, 115
        db 99, 115, 99, 115, 98, 115, 98, 114, 98, 114
        db 98, 114, 97, 113, 97, 113, 97, 113, 97, 112
        db 96, 112, 96, 112, 96, 111, 96, 111, 96, 111
        db 95, 111, 95, 110, 95, 110, 95, 109, 95, 109
        db 95, 109, 94, 108, 94, 108, 94, 108, 94, 107
        db 94, 107, 94, 107, 94, 106, 93, 106, 93, 106
        db 93, 105, 93, 105, 93, 104, 93, 104, 93, 104
        db 93, 103, 93, 103, 93, 103, 93, 102, 93, 102
        db 93, 101, 93, 101, 93, 101, 93, 100, 93, 100
        db 93, 100, 93, 99, 93, 99, 93, 98, 93, 98
        db 93, 98, 93, 97, 93, 97, 93, 96, 93, 96
        db 93, 96, 93, 95, 93, 95, 93, 95, 93, 94
        db 93, 94, 93, 93, 93, 93, 94, 93, 94, 92
        db 94, 92, 94, 92, 94, 91, 94, 91, 94, 91
        db 95, 90, 95, 90, 95, 90, 95, 89, 95, 89
        db 95, 89, 96, 88, 96, 88, 96, 88, 96, 87
        db 96, 87, 97, 87, 97, 86, 97, 86, 97, 86
        db 98, 85, 98, 85, 98, 85, 98, 84, 99, 84
        db 99, 84, 99, 84, 99, 83, 100, 83, 100, 83
        db 100, 83, 101, 82, 101, 82, 101, 82, 102, 82
        db 102, 81, 102, 81, 103, 81, 103, 81, 103, 81
        db 103, 80, 104, 80, 104, 80, 105, 80, 105, 80
        db 105, 80, 106, 79, 106, 79, 106, 79, 107, 79
        db 107, 79, 107, 79, 108, 79, 108, 78, 108, 78
        db 109, 78, 109, 78, 110, 78, 110, 78, 110, 78
        db 111, 78, 111, 78, 111, 78, 112, 78, 112, 78
        db 113, 78, 113, 78, 113, 78, 114, 78, 114, 78
        db 114, 78, 115, 78, 115, 78, 116, 78, 116, 78
        db 116, 78, 117, 78, 117, 78, 118, 78, 118, 78
        db 118, 78, 119, 78, 119, 78, 119, 78, 120, 78
        db 120, 78, 121, 78, 121, 78, 121, 79, 122, 79
        db 122, 79, 122, 79, 123, 79, 123, 79, 123, 79
        db 124, 80, 124, 80, 124, 80, 125, 80, 125, 80
        db 125, 80, 126, 81, 126, 81, 126, 81, 127, 81
        db 127, 81, 127, 82, 128, 82, 128, 82, 128, 82
        db 129, 83, 129, 83, 129, 83, 130, 83, 130, 84
        db 130, 84, 130, 84, 131, 84, 131, 85, 131, 85
        db 131, 85, 132, 86, 132, 86, 132, 86, 132, 87
        db 133, 87, 133, 87, 133, 88, 133, 88, 133, 88
        db 134, 88, 134, 89, 134, 89, 134, 90, 134, 90
        db 134, 90, 135, 91, 135, 91, 135, 91, 135, 92
        db 135, 92, 135, 92, 135, 93, 136, 93, 136, 93
        db 136, 94, 136, 94, 136, 95, 136, 95, 136, 95
        db 136, 96, 136, 96, 136, 96, 136, 97, 136, 97
        db 136, 98, 136, 98, 136, 98, 136, 99, 136, 99
        db 227, 100, 226, 100, 226, 100, 226, 101, 226, 101
        db 226, 101, 226, 102, 226, 102, 226, 103, 226, 103
        db 226, 103, 226, 104, 226, 104, 226, 104, 226, 105
        db 226, 105, 226, 106, 226, 106, 225, 106, 225, 107
        db 225, 107, 225, 107, 225, 108, 225, 108, 225, 108
        db 224, 109, 224, 109, 224, 109, 224, 110, 224, 110
        db 224, 110, 223, 111, 223, 111, 223, 111, 223, 112
        db 223, 112, 222, 112, 222, 113, 222, 113, 222, 113
        db 221, 114, 221, 114, 221, 114, 221, 115, 220, 115
        db 220, 115, 220, 115, 220, 116, 219, 116, 219, 116
        db 219, 116, 218, 117, 218, 117, 218, 117, 217, 117
        db 217, 118, 217, 118, 216, 118, 216, 118, 216, 118
        db 216, 119, 215, 119, 215, 119, 214, 119, 214, 119
        db 214, 119, 213, 120, 213, 120, 213, 120, 212, 120
        db 212, 120, 212, 120, 211, 120, 211, 121, 211, 121
        db 210, 121, 210, 121, 209, 121, 209, 121, 209, 121
        db 208, 121, 208, 121, 208, 121, 207, 121, 207, 121
        db 206, 121, 206, 121, 206, 121, 205, 121, 205, 121
        db 205, 122, 204, 121, 204, 121, 203, 121, 203, 121
        db 203, 121, 202, 121, 202, 121, 201, 121, 201, 121
        db 201, 121, 200, 121, 200, 121, 200, 121, 199, 121
        db 199, 121, 198, 121, 198, 121, 198, 120, 197, 120
        db 197, 120, 197, 120, 196, 120, 196, 120, 196, 120
        db 195, 119, 195, 119, 195, 119, 194, 119, 194, 119
        db 194, 119, 193, 118, 193, 118, 193, 118, 192, 118
        db 192, 118, 192, 117, 191, 117, 191, 117, 191, 117
        db 190, 116, 190, 116, 190, 116, 189, 116, 189, 115
        db 189, 115, 189, 115, 188, 115, 188, 114, 188, 114
        db 188, 114, 187, 113, 187, 113, 187, 113, 187, 112
        db 186, 112, 186, 112, 186, 111, 186, 111, 186, 111
        db 185, 111, 185, 110, 185, 110, 185, 109, 185, 109
        db 185, 109, 184, 108, 184, 108, 184, 108, 184, 107
        db 184, 107, 184, 107, 184, 106, 183, 106, 183, 106
        db 183, 105, 183, 105, 183, 104, 183, 104, 183, 104
        db 183, 103, 183, 103, 183, 103, 183, 102, 183, 102
        db 183, 101, 183, 101, 183, 101, 183, 100, 183, 100
        db 183, 100, 183, 99, 183, 99, 183, 98, 183, 98
        db 183, 98, 183, 97, 183, 97, 183, 96, 183, 96
        db 183, 96, 183, 95, 183, 95, 183, 95, 183, 94
        db 183, 94, 183, 93, 183, 93, 184, 93, 184, 92
        db 184, 92, 184, 92, 184, 91, 184, 91, 184, 91
        db 185, 90, 185, 90, 185, 90, 185, 89, 185, 89
        db 185, 89, 186, 88, 186, 88, 186, 88, 186, 87
        db 186, 87, 187, 87, 187, 86, 187, 86, 187, 86
        db 188, 85, 188, 85, 188, 85, 188, 84, 189, 84
        db 189, 84, 189, 84, 189, 83, 190, 83, 190, 83
        db 190, 83, 191, 82, 191, 82, 191, 82, 192, 82
        db 192, 81, 192, 81, 193, 81, 193, 81, 193, 81
        db 193, 80, 194, 80, 194, 80, 195, 80, 195, 80
        db 195, 80, 196, 79, 196, 79, 196, 79, 197, 79
        db 197, 79, 197, 79, 198, 79, 198, 78, 198, 78
        db 199, 78, 199, 78, 200, 78, 200, 78, 200, 78
        db 201, 78, 201, 78, 201, 78, 202, 78, 202, 78
        db 203, 78, 203, 78, 203, 78, 204, 78, 204, 78
        db 204, 78, 205, 78, 205, 78, 206, 78, 206, 78
        db 206, 78, 207, 78, 207, 78, 208, 78, 208, 78
        db 208, 78, 209, 78, 209, 78, 209, 78, 210, 78
        db 210, 78, 211, 78, 211, 78, 211, 79, 212, 79
        db 212, 79, 212, 79, 213, 79, 213, 79, 213, 79
        db 214, 80, 214, 80, 214, 80, 215, 80, 215, 80
        db 215, 80, 216, 81, 216, 81, 216, 81, 217, 81
        db 217, 81, 217, 82, 218, 82, 218, 82, 218, 82
        db 219, 83, 219, 83, 219, 83, 220, 83, 220, 84
        db 220, 84, 220, 84, 221, 84, 221, 85, 221, 85
        db 221, 85, 222, 86, 222, 86, 222, 86, 222, 87
        db 223, 87, 223, 87, 223, 88, 223, 88, 223, 88
        db 224, 88, 224, 89, 224, 89, 224, 90, 224, 90
        db 224, 90, 225, 91, 225, 91, 225, 91, 225, 92
        db 225, 92, 225, 92, 225, 93, 226, 93, 226, 93
        db 226, 94, 226, 94, 226, 95, 226, 95, 226, 95
        db 226, 96, 226, 96, 226, 96, 226, 97, 226, 97
        db 226, 98, 226, 98, 226, 98, 226, 99, 226, 99
        db 0, 0
data ends

code segment
start:
        mov        ax, stack
        mov        ss, ax
        mov        sp, 1024
        mov        ax, data
        mov        ds, ax
        mov        es, ax
        
        call        EnterGraphicsMode
        
        mov        ax, 85
        push        ax
        push        es
        mov        ax, offset graphics_data
        push        ax
        call        _DrawGraphics
        add        sp, 6
        
        call        getchar
        call        LeaveGraphicsMode
        mov        ax, 4c00h
        int        21h

; 进入图形模式,320x200,256色
EnterGraphicsMode:
        mov        ax, 0013h
        int        10h
        ret

; 离开图像模式,回到文本模式,80x25,16色
LeaveGraphicsMode:
        mov        ax, 0003h
        int        10h
        ret

getchar:
        mov        ah, 0
        int        16h
        mov        ah, 0
        ret
code ends
end start
void far DrawPoint(int x, int y, unsigned char color)
{
        char far *const video = (char far *)0xA0000000;
        
        if((320 <= x) || (200 <= y))
                return;
        
        video[y * 320 + x] = color;
}

void far DrawRectangle(int x1, int y1, int x2, int y2, unsigned char color)
{
        int x;
        int y;
        
        for(y = y1; y < y2; ++y)
        {
                for(x = x1; x < x2; ++x)
                        DrawPoint(x, y, color);
        }
}

/* ************************************************************ */
struct Point
{
        unsigned char x;
        unsigned char y;
};

void far DrawGraphics(void far *data, int color)
{
        struct Point *circle = (struct Point *)data;

        while((circle->x != 0) && (circle->y != 0))
        {
                DrawPoint(circle->x, circle->y, color);
                ++circle;
        }
}
/* ************************************************************ */



下面是在我的环境下运行的生成程序
2.png

我还不会上色,下面是人工上色的,看起来还不错
1.png



下面是编译运行画图程序

这是tcc.bat
@echo off
set PATH=D:\TASM\BIN;%PATH%
D:\tc\tcc.exe -ID:\tc\INCLUDE -c %1
@echo on

你需要有tasm

编译Funs.c
3.png

编译并链接main.exe
4.png

运行画图程序
5.png

如果有数学函数库就更完美了,我实在弄不到这个
^_^
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-7-2 14:52:22 | 显示全部楼层
刚刚想起来,这个程序好像不需要tasm,我好像把那段代码删了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-7-4 17:17:11 | 显示全部楼层
学习一下,谢谢大佬
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-28 09:10

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表