Classic Computer Magazine Archive ANTIC VOL. 2, NO. 11 / FEBRUARY 1984



Color within the lines


System Requirement: 16K, Assembler Editor

Here is a useful and instructive assembly language program that draws areas and fills them with color. I assume that you have the necessary tools: the Assembler Editor cartridge, the Technical User Notes, and a book on the instruction set for the 6502 chip.

This program sets up a full screen in Graphics 3, and then fills a box in the upper left portion of the screen. I've included lots of extra stuff for you to experiment with. The program is meant to be illustrative, and does not necessarily reflect good programming practices.

To start the program, we open a channel (IOCB #6) to the screen. Lines 86 and 88 enter the value of a color and put it in the register for Playfield 1. Lines 90 and 96 put the data value of Playfield 1 in ATACHR (see "Appendix H" of the Technical User Notes). Lines 98-108 plot points to DRAWTO. Line 112 sets the command byte for drawing; line 116 lets the handler subroutine execute the command. Lines 118-134 complete the drawing of the box.

ROWCRS and COLCRS should end at the lower left corner of the figure. Then, in lines 136 + 138, we put the current cursor in the upper left corner. In lines 140-150 we set up the fill color, set the fill command byte, and fill the figure using the handler. Finally, in line 152, the image is held on the screen with an endless loop.

Listing: DRAWFILL.ASM Download / View