Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: Drawing graphics Reply to this message
Posted byJan_Klaassen
Posted on04/02/04 11:51 AM



> 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.

Direct3D can be a bit of a pain, but not for that reason (dynamic textures require special care). You'll want to draw to a buffer and then transfer that to a DirectX surface later anyway, so it won't make any difference for your drawing code if you use DirectDraw or Direct3D. If you want something that's simple and works on pretty much any hardware, go for DirectDraw3. Unless you need something that requires using Direct3D, it's not worth the hassle.

> 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.

It's worse, you'll need to have cycle-accurate synchronisation, and you'll need to have it for all emulated chips, not just video. Even some games rely on bugs in the VIC-II chip, so enjoy. :)

> 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.

A temporary buffer of some kind, as you've surmised.

> 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.

No, aside from PC's not using sprites, there's details like the hardware collision detection the VIC-II chip has. Also there are countless games that re-use the sprites to get more than 8 on the screen (on C64, sprites eat memory cycles from the 6510 as well, you'll need to take that into account).



-
Entire Thread
Subject  Posted byPosted On
*Drawing graphics  GeSUB03/29/04 00:15 AM
.*Can't believe nobody's said SDL *nt* SDL pwns u  MooglyGuy04/06/04 09:26 AM
..Re: Drawing graphics  Jan_Klaassen04/02/04 11:51 AM
.*Re: Drawing graphics  GeSUB03/29/04 04:33 PM
.*Re: Drawing graphics  finaldave03/29/04 08:06 AM
.*Re: Drawing graphics  galibert03/29/04 06:07 AM
..*Re: Drawing graphics  R. Belmont03/31/04 10:44 PM
...*Re: Drawing graphics  smf04/07/04 07:12 AM
.*Re: Drawing graphics  Bart T.03/29/04 00:30 AM