C:写入视频公羊
我正在尝试制作一个可以用特定颜色将字符串写入视频内存的函数。但是,我无法使它起作用。要编写单个字符,我会这样做:
*(char *)0xb8000 = 'O'; //Prints the letter O at the first position in video memory
*(char *)0xb8001 = 'O'; //Adds it some colors (Haven't figured how to write a byte here)
但是我需要用一个变量写入,所以我尝试了一下,但是它什么也没打印。
int currentAddressVRAM = 0xb8000;
*(char *)currentAddressVRAM = 'O';
currentAddressVRAM++;
*(char *)currentAddressVRAM = 'O';
currentAddressVRAM++;
我该怎么做?我在做什么错?
编辑: 我也尝试过,它什么也没印刷:
char *currentAddressVRAM = (char *)0xb8000;
*currentAddressVRAM = 'O';
currentAddressVRAM++;
*currentAddressVRAM = 'O';
currentAddressVRAM++;
I am trying to make a function that would write strings to video memory with a specific color. However, I am unable to make it work. To write single characters, i would do this:
*(char *)0xb8000 = 'O'; //Prints the letter O at the first position in video memory
*(char *)0xb8001 = 'O'; //Adds it some colors (Haven't figured how to write a byte here)
But I need to write with a variable, so I tried this but it just prints nothing.
int currentAddressVRAM = 0xb8000;
*(char *)currentAddressVRAM = 'O';
currentAddressVRAM++;
*(char *)currentAddressVRAM = 'O';
currentAddressVRAM++;
How would I do this? What am I doing wrong?
Edit:
I tried this too and it just printed nothing:
char *currentAddressVRAM = (char *)0xb8000;
*currentAddressVRAM = 'O';
currentAddressVRAM++;
*currentAddressVRAM = 'O';
currentAddressVRAM++;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了最终如何做!
感谢您的所有有用的评论,它可以帮助我找到解决问题的解决方案。
这是我的代码:
唯一的问题是我不知道如何在功能的使用之间保存当前地址。如果有人知道,请告诉我!
I found out how to do it finally!
Thanks for all of your helpful comments, it help me find the solution to my problem.
Here is my code :
The only problem with this is that I don't know how to save the current address between the uses of the function. If somebody knows, please let me know!