OTHER CONTRIBUTIONS: TEST CARD

A test card, also known as a test pattern or start-up/closedown test, is a television test signal, typically broadcast at times when the transmitter is active but no program is being broadcast. They are electronically generated test patterns, used for calibrating or troubleshooting the video output.

source compile sandbox issues? back to examples

SOURCE CODE ()

OPTION EXPLICIT

BITMAP ENABLE (16)
COLOR BORDER BLACK
CLS BLACK

POSITIVE CONST cardColor = WHITE
POSITIVE CONST cardWidth = SCREEN WIDTH / 10
POSITIVE CONST cardHeight = SCREEN HEIGHT / 10
POSITIVE CONST verticalLines = ( SCREEN WIDTH / cardWidth ) + 1
POSITIVE CONST cardXMax = verticalLines - 1
POSITIVE CONST horizontalLines = ( SCREEN HEIGHT / cardHeight ) + 1
POSITIVE CONST cardYMax = horizontalLines - 1
POSITIVE CONST cardEffectiveWidth = cardWidth - 2
POSITIVE CONST cardEffectiveHeight = cardHeight - 2

' DIM colors(16) = #{ _
' 			BLACK, WHITE, BROWN, LAVENDER, LIGHT BLUE, LIGHT GREEN, LIGHT RED, OLIVE GREEN, _
' 			PEACH, PINK, VIOLET, DARK BLUE, TAN, MAGENTA, TURQUOISE, YELLOW GREEN _
' 		 }

' DIM primary(16) = #{ _
' 			DARK RED, RED, LIGHT RED, DARK BLUE, BLUE, LIGHT BLUE, WHITE, BLACK, _
' 			DARK GREEN, GREEN, LIGHT GREEN, WHITE, TAN, TURQUOISE, YELLOW GREEN, WHITE _
' 		 }

DIM primary2(16) = #{ _
			DARK RED, RED, LIGHT RED, DARK BLUE, BLUE, LIGHT BLUE, WHITE, BLACK, _
			DARK GREEN, GREEN, LIGHT GREEN, WHITE, BROWN, LAVENDER, OLIVE GREEN, WHITE _
		 }

PROCEDURE drawLines

	DIM lineIndex AS BYTE

	FOR lineIndex = 1 TO ( horizontalLines - 1 )
		LINE 0, lineIndex * cardHeight TO (SCREEN WIDTH - 1), lineIndex * cardHeight, cardColor
	NEXT lineIndex

	FOR lineIndex = 1 TO ( verticalLines - 1 )
		LINE lineIndex * cardWidth, 0 TO lineIndex * cardWidth, (SCREEN HEIGHT - 1),  cardColor
	NEXT lineIndex

END PROCEDURE

PROCEDURE drawColors

	' SHARED colors, primary, primary2
	SHARED primary2

	DIM colorIndex AS BYTE
	DIM cardX1 AS POSITION
	DIM cardY1 AS POSITION
	DIM cardX2 AS POSITION
	DIM cardY2 AS POSITION

	cardX1 = cardWidth + 1
	cardY1 = 1
	cardX2 = cardX1 + cardEffectiveWidth
	cardY2 = cardY1 + cardEffectiveHeight

	FOR colorIndex = 0 TO UBOUND( primary2 ) - 1

		IF colorIndex = 8 THEN
			cardX1 = cardWidth + 1
			cardX2 = cardX1 + cardEffectiveWidth
			ADD cardY1, cardHeight
			ADD cardY2, cardHeight
		ENDIF

		IF colorIndex = 0 OR colorIndex = 8 THEN
			LOCATE 0, ( cardY1 / FONT HEIGHT ) + 1 : PRINT " COLORS "
		ENDIF

		BAR cardX1, cardY1 TO cardX2, cardY2, primary2( colorIndex )
		ADD cardX1, cardWidth
		ADD cardX2, cardWidth

	NEXT

END PROCEDURE

PROCEDURE drawGreys

	DIM cardX1 AS POSITION
	DIM cardY1 AS POSITION
	DIM cardX2 AS POSITION
	DIM cardY2 AS POSITION

	cardY1 = 3*cardHeight + 1
	cardX1 = 2*cardWidth + 1
	cardY2 = cardY1 + cardHeight - 2
	cardX2 = cardX1 + cardEffectiveWidth

	LOCATE 0, ( cardY1 / FONT HEIGHT ) + 1 : PRINT " GREY"
	BAR cardX1, cardY1 TO cardX2, cardY2, DARK GREY
	ADD cardX1, cardWidth
	ADD cardX2, cardWidth

	BAR cardX1, cardY1 TO cardX2, cardY2, GREY
	ADD cardX1, cardWidth
	ADD cardX2, cardWidth

	BAR cardX1, cardY1 TO cardX2, cardY2, LIGHT GREY
	ADD cardX1, cardWidth
	ADD cardX2, cardWidth

	cardX1 = 3*cardWidth + 1
	cardX2 = cardX1 + cardEffectiveWidth
	ADD cardY1, cardHeight
	ADD cardY2, cardHeight

	LOCATE 0, ( cardY1 / FONT HEIGHT ) + 1 : PRINT " WHITE"
	BAR cardX1, cardY1 TO cardX2, cardY2, DARK WHITE
	ADD cardX1, cardWidth
	ADD cardX2, cardWidth

	BAR cardX1, cardY1 TO cardX2, cardY2, WHITE
	ADD cardX1, cardWidth
	ADD cardX2, cardWidth

	BAR cardX1, cardY1 TO cardX2, cardY2, LIGHT WHITE
	ADD cardX1, cardWidth
	ADD cardX2, cardWidth

END PROCEDURE

PROCEDURE drawMonoscope

	CIRCLE SCREEN WIDTH / 2, SCREEN HEIGHT / 2, MIN( SCREEN WIDTH / 2, SCREEN HEIGHT / 2 ), cardColor

END PROCEDURE

drawLines[]
drawColors[]
drawGreys[]
drawMonoscope[]

How to compile and run the example

The instructions here refer to compiling the example from the command line. For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile each single example with just one click.



Are instructions for your specific home computer / console missing? First of all, check if your computer is supported by clicking here. If so, since ugBASIC is a language which does not provide abstractions, it is possible that this example will not work on your target. If you think this is an issue, please click here.

Amstrad CPC 464, Amstrad CPC 6128, Amstrad CPC 664

In order to compile the example, type this command on the command line:

Linux

ugbc.cpc -O dsk -o contrib_testcard.dsk contrib_testcard.bas

Windows

ugbc.cpc.exe -O dsk -o contrib_testcard.dsk contrib_testcard.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

Commodore 128 (CPU 8502)

In order to compile the example, type this command on the command line:

Linux

ugbc.c128 -O prg -o contrib_testcard.prg contrib_testcard.bas

Windows

ugbc.c128.exe -O prg -o contrib_testcard.prg contrib_testcard.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

Commodore 64, Commodore Executive 64

In order to compile the example, type this command on the command line:

Linux

ugbc.c64 -O prg -o contrib_testcard.prg contrib_testcard.bas

Windows

ugbc.c64.exe -O prg -o contrib_testcard.prg contrib_testcard.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

MSX

In order to compile the example, type this command on the command line:

Linux

ugbc.msx1 -O rom -o contrib_testcard.rom contrib_testcard.bas

Windows

ugbc.msx1.exe -O rom -o contrib_testcard.rom contrib_testcard.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

Olivetti Prodest PC128, Thomson MO6

In order to compile the example, type this command on the command line:

Linux

ugbc.pc128op -O k7 -o contrib_testcard.k7 contrib_testcard.bas

Windows

ugbc.pc128op.exe -O k7 -o contrib_testcard.k7 contrib_testcard.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

TRS-80 Color Computer 3

In order to compile the example, type this command on the command line:

Linux

ugbc.coco3 -O bin -o contrib_testcard.bin contrib_testcard.bas

Windows

ugbc.coco3.exe -O bin -o contrib_testcard.bin contrib_testcard.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

Any problem?

If you have found a problem trying to run this example, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO EXAMPLES