c++ and c#

Topics: Compiler, Using Cosmos (Developing your own OS, projects, etc)
Nov 7, 2012 at 10:14 PM
Edited Nov 7, 2012 at 11:55 PM

Can you use both c++ and c#? Because there are some useful features in c++ that would help me with my video driver(memcpy and _asm).

Developer
Nov 8, 2012 at 3:19 AM

No, it is not possible, it is however easily possible to do both of those things in C# with no real issues, see Buffer.BlockCopy for memcpy (may need to be plugged, should be done as a high-speed memcpy implementation though), and the _asm statements are doable as plugged methods.

Nov 8, 2012 at 8:58 PM

how would I do (reinterpret_cast<byte *>(0xb800)) to get the video memory?

Developer
Nov 8, 2012 at 9:05 PM

byte* vidMem = (byte*)(IntPtr)0xB800;

Not sure if the IntPtr cast is needed, but it should work perfectly with it.

Coordinator
Nov 8, 2012 at 9:07 PM

Have a look at the TextScreen class. It uses the 0xB8000 memory range. All except specific instructions can be done using normal c#. In drivers try to stay away from direct memory usage but try to use the managed memory classes.

Op 8 nov. 2012 22:58 schreef "jpal" <notifications@codeplex.com> het volgende:

From: jpal

how would I do (reinterpret_cast<byte *>(0xb800)) to get the video memory?

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Nov 8, 2012 at 9:16 PM

Can I use Buffer.ByteCopy with a byte*?

Coordinator
Nov 8, 2012 at 9:17 PM

Did you try?
If it doesn't work try some other overload. (Pointers can be easily converted)

Op 8 nov. 2012 23:16 schreef "jpal" <notifications@codeplex.com> het volgende:

From: jpal

Can I use Buffer.ByteCopy with a byte*?

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Nov 8, 2012 at 9:21 PM
Edited Nov 8, 2012 at 9:26 PM

(byte[]) does not work. How do I do this? I have the variables mem(byte[]) and vm(byte*). vm is the video memory, and mem is the back buffer. I am using  Buffer.BLockCopy(mem, 0, vm, 0, mem.Length).

Developer
Nov 9, 2012 at 1:51 AM

provided there is a byte* overload for buffer block copy (I know there's one somewhere, I've used it before), then you can do:

fixed (byte* memPtr = mem)
{
    Buffer.BlockCopy(memPtr, 0, vm, 0, mem.Length);
}


Nov 9, 2012 at 11:29 AM

I cant find an overload

Coordinator
Nov 9, 2012 at 11:33 AM
There doesn't seem to be one...

What memory area are you trying to copy? Try to acquire the memory by using byte[], and then use unsafe code. Then you can use Marshal..


On Fri, Nov 9, 2012 at 1:29 PM, jpal <notifications@codeplex.com> wrote:

From: jpal

I cant find an overload

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Nov 9, 2012 at 3:07 PM

I am trying to write to 0xa0000 for my video driver.