> I'm about to start programming a Commodore 64 emulator but before I begin, I'd> like to ask a few questions regarding the graphics part of it. But before I ask> my questions, let me give you some background info on what I know.> > - Assembly for the 6502/6510 cpu.> - VIC II, 6526 CIA architecture (internal registers)> - Still working on reviewing the SID chip> > As for my programming knowledge, I've done quite a bit of work with VB 6 but my> language of choice is C/C . I've also done quite a bit of programming for the> Directx API (version 7-9) especially Direct3D.> > Now to my questions:> > 1) Which is preferred for displaying the graphics when using the DirectX API?> DirectDraw or Direct3D? I'm asking because Direct3D doesn't really seem suited> for direct pixel manipulation which I believe is whats needed for drawing the> screen.

In Direct3D you could make a texture the size of the screen, lock the texture write the screen into it, and then draw a Quad the size of the screen. This is how I'm doing stuff on the XBox as well, albeit with swizzled textures, and it seems to work nice. It's also how other XBox emulators work.Or I think you can lock Surface's in the same way as DirectDraw though I haven't tried this yet.

On PC, DirectDraw might be preferable, because of the compatiblity (95, 98, NT, 2000, XP all have DirectX 3.0)

> 2) Is the screen drawn all at once or one scanline at a time? I would think it> needs to be drawn one scanline at a time for it to be accurate. I say this> because the C64 uses raster interrupts that can modify the screen in real time.

See OG's reply - he has it right> > 3) If drawing the screen using scanlines is the preferred method, what's the> fastest way to achieve this. I'd hate to lock and unlock the back buffer many> times as the scanline is drawn. This would be way to slow in Direct3D or> DirectDraw. Am I better off drawing the scanlines in a temporary array (virtual> screen) and then paint it to the screen at once? What's the best approach to> this.

Yes, that's what I do, I use a temporary buffer and then copy it to a DirectDraw Surface when it's done. I prefer this method rather than Locking before the start of a frame and Unlocking after the frame, or locking each scanline, because if the emulator crashes during a Lock/Unlock pair it tends to lock up some systems (especially on older versions of Windows)

Also you sometimes have to alpha blend a video image, so it can be faster than reading out of video memory

> > 4) And what about the 8 sprites the C64 supports. Is this a matter of just> making PC sprites that mimic the C64's sprites.

You'd typically do the sprites in software to be honest> > I'd appreciate any info you guys could give me.> > Thanks>