Author Topic: Plotting Sine wave by directly accessing video memory  (Read 14228 times)

Offline S Mahen

  • Jr. Member
  • *
  • Posts: 21
Plotting Sine wave by directly accessing video memory
« on: December 08, 2016, 09:52:53 AM »
I am looking for help to plot sine waveform by directly accessing video memory.

I am using 80387 instructions and 64-bit syscall for programming.

Please help

Offline soulvomit

  • Jr. Member
  • *
  • Posts: 31
Re: Plotting Sine wave by directly accessing video memory
« Reply #1 on: December 08, 2016, 11:57:35 AM »
http://www.techcrashcourse.com/2015/08/c-program-draw-sine-graph-wave-graphics.html

There is an fsin instruction which should help implement this in nasm. http://x86.renejeschke.de/html/file_module_x86_id_114.html

What do you mean  by "directly accessing video memory"?

What OS are you working under?

Offline S Mahen

  • Jr. Member
  • *
  • Posts: 21
Re: Plotting Sine wave by directly accessing video memory
« Reply #2 on: December 08, 2016, 12:07:29 PM »
I am using 64 bit Ubuntu and writing program using ALP.

Accessing video memory means the video RAM address to plot the point.

Offline soulvomit

  • Jr. Member
  • *
  • Posts: 31
Re: Plotting Sine wave by directly accessing video memory
« Reply #3 on: December 08, 2016, 12:17:10 PM »
Accessing video memory means the video RAM address to plot the point.

What are you hoping to accomplish by directly accessing "video RAM addresses"?

I don't know much about linux, but on windows you are not allowed to directly access the frame buffer. All drawing to the screen must be done in a window object via its internal frame buffer. SetPixel() for example, only works within a window. https://msdn.microsoft.com/en-us/library/windows/desktop/dd145078(v=vs.85).aspx   

I don't know what the linux equivalent to SetPixel() is.
« Last Edit: December 08, 2016, 12:19:44 PM by soulvomit »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Plotting Sine wave by directly accessing video memory
« Reply #4 on: December 08, 2016, 03:53:45 PM »
Linux will allow you access to the "framebuffer device". It has to be enabled on bootup. If you see the Penguin when you boot, you've got it. I don't think it is, strictly speaking, "direct video memory". As I recall, it was not a practical means to do graphics.

A "protected mode" operating system is protected from US. You might be better off with DOS or "bare metal"... or bite the bullet and learn Xwindows. (no advantage to doing Xwindows from asm, but it can of course be done).

Best,
Frank


Offline S Mahen

  • Jr. Member
  • *
  • Posts: 21
Re: Plotting Sine wave by directly accessing video memory
« Reply #5 on: December 10, 2016, 11:34:00 PM »
Thank you Frank.

I think INT 10H is the option in DOS to change display mode and draw pixel.

Please share some sample code to draw sine wave.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Plotting Sine wave by directly accessing video memory
« Reply #6 on: December 11, 2016, 02:06:32 AM »
Well, I only remember a little of this. Haven't got DosBox installed and I'm not in the mood to reboot to DOS right now, so I can't try this stuff and rememner what it does. I'll just toss it out here. There are comments, but it's still pretty cryptic, I'm afraid.

Int 10h is the BIOS interrupt for screen/graphics/cursor stuff. You want to use it (ah=0) to change mode. The putpixel (ah=0Ch) is slower than a gut-shot wolf bitch with nine suckling pups dragging a number nine trap uphill in a snowstorm. "sinwav1" uses it, but "ripple" uses a much faster "putpixel". As I recall, "ripple" does multiple sine waves intended to look like ripples on water. Version 2 adds a "moon" to reflect off the ripples. Based on something Ross Simpson showed me (in Pascal, originally). I don't know now how much of the code is his and how much is mine. As I recall...

Best,
Frank


Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Plotting Sine wave by directly accessing video memory
« Reply #7 on: December 11, 2016, 02:11:05 AM »
Ahhh, the forum is messin' with me again... Maybe this is gonna work, maybe later...