;  Title - 8 Colors
;  By    - Adam Trionfo
;
;  About this Program
;  ------------------ 
;
;  Displays eight pixels starting at $4000 (top left-hand corner).
;
;  This program could not have been written without using
;  Mike White's "Astro BASIC 4x2 Multicart Loader" and
;  and the "Nutting Manual" as a reference.
;
;  Revisions:
;       1.2 - August 12, 2013
;             - Fixed to work with recent versions of MESS Emulator
;               and on real machines.  Changed Interrupt Mode
;               from $18 to $08 (screen interrupts only).
;             - Changed source name from "Screen Display" to "8 Colors"
;             - Menu now displays "8 COLORS" instead of "TEST"
;             - Described the Colors setup on screen
;             - Added some additional comments
;       1.1 - November 20, 2003  
;                - Made compatible with HVGLIB.H
;       1.0 - March 22, 2002
;                - First Public Release
;
;  Assembling this Program
;  -----------------------
;     This file will assemble with ZMAC 1.3 (a little
;  known, freely distributable Z-80 assembler (with C
;  source), that was written in 1978.  ZMAC can be
;  compiled under most any OS, so try it out.
;  
;  To assemble Z-80 source code using ZMAC:
;  
;       zmac -i -m -o <outfile> -x <listfile> <filename>
; 
;  For example, to assemble this Astrocade Z-80 program:
;    
;       zmac -i -m -o 8colors.bin -x 8colors.lst 8colors.asm

INCLUDE "HVGLIB.H"      ; Home Video Game Library Header

        ORG    FIRSTC   ; First byte of Cartridge

        DB     "U"      ; User Cartridge Sentinel

;  Menu Selection Choice #1
        DW     MENUST   ; Next Menu Link
        DW     PRGNAM   ; Address of Program Name text
        DW     PRGST    ; Jump here if selected
 
; Program Start
PRGST:  DI                ; Disable interrupts

        SYSTEM (INTPC)    ; Start System Interpreter 

        DO     (SETOUT)   ; Set Display Ports
        DB     88*2       ; Vertical Blanking Line (Line 88) 
        DB     1          ; Left/Right Color Boundary (Left of Pixel 4) 
        DB     00001000B  ; Set Bit 3 of INterrupt MODe (Screen Interrupts Only)

        DO     (COLSET)   ; Set Color Registers
        DW     COLTAB     ; Color Table

        DO     (FILL)     ; Screen Fill
        DW     $4000      ; Destination
        DW     4000D      ; Bytes to move
        DB     $00        ; Fill with zeros

;  Place colors like this:
;
;  |COL0L|COL1L|COL2L|COL3L|COL0R|COL1R|COL2R|COL3R|
;  +-----+-----+-----+-----+-----+-----+-----+-----+
; 
;   White Light Med   Gray Darker Dark Darkest Black
;         Gray  Gray       Gray   Gray Gray
;
        DO     (MOVE)     ; Move Bytes
        DW     $4000      ; Destination
        DW     2D         ; Bytes to move (two)
        DW     TOMOVE     ; Source Address

        EXIT              ; Exit System Interpreter

        EI                ; Enable interrupts 

LOOP:   NOP               ; Endless loop
        JP     LOOP       ; End of program

;  Program Data

;  Color Table
;        
COLTAB: DB     $04        ; COL3L (COLor 3 Left)  -  
        DB     $05        ; COL2L (COLor 2 Left)  - 
        DB     $06        ; COL1L (COLor 1 Left)  -  
        DB     $07        ; COL0L (COLor 0 Left)  - White
        DB     $00        ; COL3R (COLor 3 Right) - Black
        DB     $01        ; COL2R (COLor 2 Right) -
        DB     $02        ; COL1R (COLor 1 Right) -
        DB     $03        ; COL0R (COLor 0 Right) -

; Program Name
PRGNAM: DB     "8 COLORS",$00

; Bytes to move.  Four pixels in Left and Right Color Boundary
TOMOVE: DB     00011011B  ; Four pixels, Colors 0, 1, 2, 3
        DB     00011011B  ; Four pixels, Colors 0, 1, 2, 3

; End of Program
