Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
blog:commodore_c65_dtv_programming [2023/01/25 15:09] – [Basic DTV Functions] john | blog:commodore_c65_dtv_programming [2023/01/25 17:21] (current) – [Extended DTV Functions] john | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== DTV (and C64) Programming - Using the CC65 toolchain ====== | ====== DTV (and C64) Programming - Using the CC65 toolchain ====== | ||
+ | ~~TOC_HERE 2-5~~ | ||
+ | |||
+ | From [[https:// | ||
+ | |||
+ | > The C64 Direct-to-TV, | ||
+ | > joystick), with 30 built-in games. The design is similar to the Atari Classics 10-in-1 TV Game. The circuitry of the C64DTV was designed by Jeri Ellsworth, a computer chip designer who | ||
+ | > had previously designed the C-One. | ||
+ | |||
+ | These are my notes on programming for the C64 DTV and making use of some of the extended functionality of the hardware from within C, rather than 6502 assembly. I hope you find these useful - whilst I came to the DTV more than a decade after its popularity peaked, I've found it a very capable little system! | ||
+ | |||
+ | {{: | ||
===== Basic use of CC65 ===== | ===== Basic use of CC65 ===== | ||
Line 205: | Line 216: | ||
---- | ---- | ||
+ | |||
+ | ==== Extended DTV Functions ==== | ||
+ | |||
+ | These functions raise the DTV above a simple C64 clone and add substantially improved functionality to the system: increased colours, digital sound and a dedicated image blitter. | ||
=== Enabling 320x200 Linear Framebuffer === | === Enabling 320x200 Linear Framebuffer === | ||
Line 460: | Line 475: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | == Bugs == | ||
+ | |||
+ | I've seemingly found a bug which manifests when making sequential DMA calls in a tight loop and the transfer length is 182 bytes or greater. | ||
+ | |||
+ | You can successfully DMA copy quite a large region in a single operation and there are no side-effects, | ||
+ | |||
+ | {{: | ||
+ | |||
+ | The colour bars in the image should be continuous for the entire screen width, but they glitch at two points. | ||
+ | The above example was generated by the following pseudocode: | ||
+ | |||
+ | < | ||
+ | screen = FRAMEBUFFER_LOCATION; | ||
+ | for (line = 0; line < SCREEN_HEIGHT; | ||
+ | memset(line_buffer, | ||
+ | dtv_DMA(& | ||
+ | colour++; | ||
+ | screen += SCREEN_WIDTH; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | If you reduce the transfer size to 181 bytes you do not get the glitching, and if you have a // | ||
+ | |||
+ | ---- | ||
=== Blitter Operation === | === Blitter Operation === | ||
+ | |||
+ | One of the big features of the DTV2 & 3 is the addition of [[https:// | ||
+ | |||
+ | The Blitter documentation is extensive, with dozens of different registers to set and configure. However, in most circumstances you will want to copy one solid block of pixels to another area (either on-screen or off - the blitter works over the entire 0-2048kb memory region, but //not// ROM). | ||
+ | |||
+ | Here I show a variation of the blitter command to transfer w x h pixels from src to dest. | ||
+ | |||
+ | * **src**: address of the upper-left pixel of a rectangular block of source pixels | ||
+ | * **dst**: address of the upper-left pixel of the destination area. | ||
+ | * **w**: width of the source area to copy in pixels | ||
+ | * **h**: number of lines of the source area to copy | ||
+ | |||
+ | The source area is OR-ed with the destination and transparency in the source area is honoured (source pixels with value //0// will //not// overwrite pixels in the destination). | ||
**dtv_Blit()** | **dtv_Blit()** | ||
Line 533: | Line 586: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | Here's an example of the blitter function in operation, copying a **100x100** rectangle of pixels from the source position of **1,1** to the destination at **219, | ||
+ | |||
+ | This is the source image - a basic set of colour bars: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Using dtv_Blit() we copy from 1,1 to 219,100 a 100x100 rectangle in OR mode: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Notice that the transparent (aka //black//) pixels in the source region are preserved when copying to the destination, | ||
+ | |||
+ | == Bugs == | ||
+ | |||
+ | However, there is a problem. On the **DTV2** systems (the initial PAL models), the blitter is partially bugged and transparent copies result int a vertical banding effect: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Therefore, //without mitigation//, |