Principles:
1. Access the VGA palette registers to get/set the palette:
OUT &H3C8, Loops
OUT &H3C9, ASC(MID$(Change$, Loops * 3 + 1, 1)) - 35
OUT &H3C9, ASC(MID$(Change$, Loops * 3 + 2, 1)) - 35
OUT &H3C9, ASC(MID$(Change$, Loops * 3 + 3, 1)) - 35
2. Understand the BMP file format.
3. Use the error diffusion algorithm with dithering to draw true-color images. Generally, books on "Computer Graphics" all explain the error diffusion algorithm. The key is this line:
IF PixelBlue >= PixelArray(PixelArraySearch, 1) - ColorDif AND PixelBlue = PixelArray(PixelArraySearch, 2) - ColorDif AND PixelGreen = PixelArray(PixelArraySearch, 3) - ColorDif AND PixelRed = (ColorPalette(Loops, 3) - Movement) AND PixelBlue = (ColorPalette(Loops, 2) - Movement) AND PixelGreen = (ColorPalette(Loops, 1) - Movement) AND PixelRed 3 THEN
What do these things have to do with assembly?
The most important things in learning assembly are learning computer architecture and instruction optimization.
But to write actual programs, what you mainly need is this knowledge:
1. Hardware interface programming. For example, this program accesses VGA registers (you can use the in and out instructions in assembly; QB just turns them into functions)
2. Understand file formats, and know how data is stored, so you can process it
3. To write graphics code, there are professional "Computer Graphics" books you can refer to; algorithm issues are unrelated to the programming language in the first place
As long as you learn those three things above, you can write this kind of program in any programming language. By that point, assembly optimization becomes necessary.
Recommended: "Graphics Programming Black Book (Michael Abrash's Graphics Programming Black Book)," a comprehensive introduction to how to write graphics programs under DOS (2D and 3D) and assembly optimization (real-time rendering):
http://www.netyi.net/Resource/933a25cf-fa0e-4dab-b9d7-e58a0ea8f52e.aspx
[
Last edited by zyl910 on 2006-6-4 at 20:40 ]