1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-18 21:07:28 +00:00
C02/x16/testvera.c02

337 lines
9.4 KiB
Plaintext
Raw Normal View History

2019-09-29 01:59:58 +00:00
/************************************
* TESTVERA - Test All Vera Modules *
************************************/
2019-09-23 23:57:03 +00:00
//Specify System Header using -H option
#include <stddef.h02>
#include <stdlib.h02>
#include <intlib.h02>
#include <stdio.h02>
#include <stdiox.h02>
2019-09-25 19:56:26 +00:00
#include <memory.h02>
2019-09-23 23:57:03 +00:00
#include <nybble.h02>
2019-09-29 01:59:58 +00:00
#include "include/veramem.h02" //Vera Memory Access
#include "include/veradsp.h02" //Vera Display Controller
#include "include/veraclr.h02" //Vera Color Palette
#include "include/veralyr.h02" //Vera Layer Control
2019-09-23 23:57:03 +00:00
#include "include/vera.h02"
2019-09-25 19:56:26 +00:00
const char abcdef = {1,2,3,4,5,6};
char buffer[255]; //Buffer for getmem
2019-09-23 23:57:03 +00:00
char hscale,vscale; //Video Scaling
2019-09-25 19:56:26 +00:00
char hrzvrt[5]; //Horizontal and Vertical Register Contents
2019-09-23 23:57:03 +00:00
char index; //Color Palette Index
char mode,mono,field; //Video Output Mode, Monochrome Flag, Current Field
char red,green,blue; //Color Components
2019-09-25 19:56:26 +00:00
char enabld; //Layer Enabled
2019-09-23 23:57:03 +00:00
char i,j,k,l;
2019-09-25 19:56:26 +00:00
int color,colour;
2019-09-23 23:57:03 +00:00
int hstart,hstop; //Horizontal Start and Stop
int vstart,vstop; //Vertical Start and Stop
int irqlin; //IRQ Line#
2019-09-25 19:56:26 +00:00
/* Layer 0/1 */
2019-09-29 01:59:58 +00:00
const char msizel = {32,64,128,0};
const char msizeh = { 0, 0, 0,1};
const char tsizel = {8,16};
2019-09-25 19:56:26 +00:00
char layer; //Layer Number
char layer0[9]; //Layer 0 Register Contents
char layer1[9]; //Layer 1 Register Contents
2019-09-29 01:59:58 +00:00
char height,width; //Map/Tile Height, Width Specifiers
char tsize; //Tile Size in Pixels
int msize; //Map Size in Pixeks
2019-09-25 19:56:26 +00:00
int mbase0,mbase1; //Map Base, Layer 0 and 1
int tbase0,tbase1; //Tile Base, Layer 0 and 1
int mbaddr,tbaddr; //Map and Tile Base Address
int hscrl0,hscrl1; //Horizontal Scroll, Layer 0 and 1
int vscrl0,vscrl1; //Vertical Scroll, Layer 0 and 1
2019-09-23 23:57:03 +00:00
char aa,xx,yy;
2019-09-25 19:56:26 +00:00
void failed() {
putln(" FAILED");
}
2019-09-23 23:57:03 +00:00
void passed() {
putln(" PASSED");
2019-09-25 19:56:26 +00:00
//newlin();
}
void prtadr() {
aa, yy, xx = getadr();
puts("ADDRESS=");
prbyte(aa); prbyte(yy); prbyte(xx); newlin();
2019-09-23 23:57:03 +00:00
}
void prtayx(aa,yy,xx) {prhex(aa); prhex(yy); prhex(xx); putspc(); putspc();}
void prttmp() {
printf(temp0, "TEMP0=$%h%n");
printf(temp1, "TEMP1=$%h%n");
printf(temp2, "TEMP2=$%h%n");
printf(temp3, "TEMP3=$%h%n");
}
void prtscl() {
printf(hscale, "HSCALE=%h, ");
printf(vscale, "VSCALE=%h%n");
}
void prtvid() {
select (mode) {
case 0: puts("DISABLED");
case 1: puts("VGA");
case 2: puts("NTSC");
case 3: puts("RGB");
default: puts("UNDEFINED");
}
if (mono) puts(" MONOCHROME"); else puts(" COLOR");
puts(", ");
if (field) puts("ODD"); else puts("EVEN");
putln(" FIELD");
}
void xerror() {
2019-09-29 01:59:58 +00:00
putln(" ERROR ENCOUNTERED");
2019-09-23 23:57:03 +00:00
goto exit;
}
main:
newlin();
2019-09-25 19:56:26 +00:00
puts("TESTING GETMEM() AND SETMEM()");
setadr($20,&0); setmem(@abcdef,&abcdef);
setadr($20,&0); getmem(@abcdef,&buffer);
setdst(&abcdef); if (memcmp(@abcdef,&buffer)) xerror();
passed();
puts("TESTING GETVID() AND SETVID()");
2019-09-23 23:57:03 +00:00
for (i=0;i<4;i++) {
for (j=1;j:+;j--) {
//inline $ff;
setvid(i,j);
mode,mono,field = getvid();
//prtvid();
if (mode<>i or mono&j<>j) xerror();
}
}
passed();
2019-09-25 19:56:26 +00:00
puts("TESTING GETBDR() AND SETBDR()");
2019-09-23 23:57:03 +00:00
i = 0;
do {
setbdr(i);
index = getbdr();
if (index<>i) xerror();
//printf(index, "BORDER=%h%n");
i++;
} while(i);
passed();
2019-09-25 19:56:26 +00:00
puts("TESTING GETSCL() AND SETSCL()");
2019-09-29 01:59:58 +00:00
i=1;
2019-09-23 23:57:03 +00:00
do {
j=1;
do {
2019-09-29 01:59:58 +00:00
setscl(i,j); hscale,vscale = getscl();
2019-09-23 23:57:03 +00:00
if (hscale<>i or vscale<>j) xerror("ERROR IN GETSCL()/SETSCL()");
j<<;
} while (j);
i<<;
} while (i);
passed();
2019-09-25 19:56:26 +00:00
//putln("SAVING START AND STOP REGISTERS");
setadr($1F, &$0004); getmem(5, &hrzvrt);
//for (i=0;i<5;i++) printf(hrzvrt[i], "%h "); newlin();
puts("TESTING GETHSR() AND SETHSR()");
sethsr(&$024C);
hstart = gethsr();
//setdst(hstart);printf("HSTART=%w%n");
if (>hstart<>$02 or <hstart<>$4C) xerror(); else passed();
puts("TESTING GETHSP() AND SETHSP()");
sethsp(&$025D); hstop = gethsp();
//setdst(hstop);printf("HSTOP=%w%n");
if (>hstop<>$02 or <hstop<>$5D) xerror(); else passed();
puts("TESTING GETVSR() AND SETVSR()");
setvsr(&$016E); vstart = getvsr();
//setdst(vstart);printf("VSTART=%w%n");
if (>vstart<>$01 or <vstart<>$6E) xerror(); else passed();
puts("TESTING GETVSP() AND SETVSP()");
setvsp(&$017F); vstop = getvsp();
//setdst(vstop);printf("VSTOP=%w%n");
if (>vstop<>$01 or <vstop<>$7F) xerror(); else passed();
2019-09-23 23:57:03 +00:00
2019-09-25 19:56:26 +00:00
//putln("RESTORING START AND STOP REGISTERS");
setadr($1F, &$0004); setmem(5, &hrzvrt);
puts("TESTING GETIRL() AND SETIRL()");
2019-09-23 23:57:03 +00:00
for (i=0;i<2;i++) {
j=0;
do {
setiql(0,i,j);
irqlin = getiql();
//setdst(); printf("IRQ LINE=%w%n");
if (>irqlin<>i or <irqlin<>j) xerror();
j++;
} while (j);
}
passed();
2019-09-29 01:59:58 +00:00
/*************************************************************************/
2019-09-25 19:56:26 +00:00
puts("TESTING RGBCLR() AND CLRRGB()");
2019-09-23 23:57:03 +00:00
for (red=0;red<16;red++) {
for (green=0;green<16;green++) {
for (blue=0;blue<16;blue++) {
//prtayx(red,green,blue);
2019-09-25 19:56:26 +00:00
color = rgbclr(red,green,blue);
//putwrd(color); putspc();
2019-09-23 23:57:03 +00:00
i,j,k = clrrgb();
//prtayx(i,j,k);
if (i<>red or j<>green or blue<>k) xerror();
}
}
//if (anykey()==#ESCKEY) goto exit;
}
passed();
2019-09-25 19:56:26 +00:00
puts("TESTING GETCLR() AND SETCLR()");
2019-09-23 23:57:03 +00:00
for (i=16; i<32; i++) {
//puthex(i); putspc();
2019-09-25 19:56:26 +00:00
color = getclr(i);
//putwrd(color); putspc();
if (i&15<>>color or nybdup(i)<><color) xerror();
2019-09-23 23:57:03 +00:00
//if (i&7==7) newlin();
}
2019-09-25 19:56:26 +00:00
//passed();
2019-09-23 23:57:03 +00:00
2019-09-25 19:56:26 +00:00
//puts("TESTING SETCLR()");
2019-09-23 23:57:03 +00:00
for (i=128; i<144; i++) {
//puthex(i); putspc();
red = i+8&15;
green = 144-i;
blue = i&15;
//prhex(red); prhex(green); prhex(blue); putspc(); putspc();
2019-09-25 19:56:26 +00:00
color = rgbclr(red,green,blue);
setclr(i,color);
colour = getclr(i);
//putwrd(colour); putspc();
if (<colour<><color or >colour<>>color) xerror();
2019-09-23 23:57:03 +00:00
//if (i&7==7) newlin();
}
passed();
2019-09-29 01:59:58 +00:00
/*************************************************************************/
2019-09-25 19:56:26 +00:00
//putln("SAVING LAYER REGISTERS");
setadr($1F,&$2000); getmem(@layer0,&layer0);
setadr($1F,&$3000); getmem(@layer1,&layer1);
2019-09-29 01:59:58 +00:00
printf("TESTING GETENB() AND SETENB()");
setenb(0,$00); if (getenb(0)<>$00) xerror();
setenb(0,$FF); if (getenb(0)<>$FF) xerror();
setenb(1,$00); if (getenb(1)<>$00) xerror();
setenb(1,$FF); if (getenb(1)<>$FF) xerror();
passed();
printf("TESTING GETMOD() AND SETMOD()");
for (i=0;i<2;i++) {for (j=0;j<8;j++) {
setmod(i,j); if (getmod(i)<>j) goto reslyr; //xerror();
} }
passed();
printf("TESTING GETMSZ() AND SETMSZ()");
for (i=0;i<2;i++) {for (j=0;j<4;j++) {for (k=0;k<4;k++) {
//printf(j,"%nJ=%h, "); printf(k,"K=%h");
setmsz(i,j,k); width, height = getmsz(i);
//printf(width," WIDTH=%h, "); printf(height,"HEIGHT=%h");
if (width<>j or height<>k) xerror();
}}}
passed();
printf("TESTING GETTSZ() AND SETTSZ()");
for (i=0;i<2;i++) {for (j=0;j<2;j++) {for (k=0;k<2;k++) {
//printf(j,"%nJ=%h, "); printf(k,"K=%h");
settsz(i,j,k); width, height = gettsz(i);
//printf(width," WIDTH=%h, "); printf(height,"HEIGHT=%h");
if (width<>j or height<>k) xerror();
}}}
passed();
printf("TESTING MAPSIZ() AND TILSIZ()");
for (i=0; i<@msizel; i++) {
msize = mapsiz(i);
//printf(i,"%nMAP SIZE %h = "); setdst(msize); printf("$%w PIXELS");
if (<msize<>msizel[i] or >msize<>msizeh[i]) xerror();
}
for (i=0; i<@tsizel; i++) {
tsize = tilsiz(i);
//printf(i,"%nTILE SIZE %h = "); printf(tsize, "$%h PIXELS");
if (tsize<>tsizel[i]) xerror();
}
passed();
printf("TESTING GETMBS() AND SETMBS()");
2019-09-25 19:56:26 +00:00
setmbs(0,&$1234); mbase0 = getmbs(0);
setmbs(1,&$5678); mbase1 = getmbs(1);
//setdst(mbase0); printf("%nMBASE0=$%w, "); setdst(mbase1); printf("MBASE1=$%w%n");
if (>mbase0<>$12 or <mbase0<>$34) xerror();
if (>mbase1<>$56 or <mbase1<>$78) xerror();
passed();
2019-09-29 01:59:58 +00:00
printf("TESTING GETTBS() AND SETTBS()");
2019-09-25 19:56:26 +00:00
settbs(0,&$90AB); tbase0 = gettbs(0);
settbs(1,&$CDEF); tbase1 = gettbs(1);
//setdst(tbase0); printf("%nTBASE0=$%w, "); setdst(tbase1); printf("TBASE1=$%w%n");
if (>tbase0<>$90 or <tbase0<>$AB) xerror();
if (>tbase1<>$CD or <tbase1<>$EF) xerror();
passed();
2019-09-29 01:59:58 +00:00
printf("TESTING GETMBA() AND GETTBA()");
2019-09-25 19:56:26 +00:00
i,j,k = getmba(0); if (i<>$00 or j<>$48 or k<>$D0) xerror();
i,j,k = getmba(1); if (i<>$01 or j<>$59 or k<>$E0) xerror();
i,j,k = gettba(0); if (i<>$02 or j<>$42 or k<>$AC) xerror();
i,j,k = gettba(1); if (i<>$03 or j<>$37 or k<>$BC) xerror();
passed();
2019-09-29 01:59:58 +00:00
printf("TESTING GETHSC() AND SETHSC()");
2019-09-25 19:56:26 +00:00
sethsc(0,&$1357); hscrl0 = gethsc(0);
sethsc(1,&$2468); hscrl1 = gethsc(1);
//setdst(hscrl0); printf("%nHSCRL0=$%w, "); setdst(hscrl1); printf("HSCRL1=$%w%n");
if (>hscrl0<>$13 or <hscrl0<>$57) xerror();
if (>hscrl1<>$24 or <hscrl1<>$68) xerror();
passed();
2019-09-29 01:59:58 +00:00
printf("TESTING GETVSC() AND SETVSC()");
2019-09-25 19:56:26 +00:00
setvsc(0,&$9BDF); vscrl0 = getvsc(0);
setvsc(1,&$0ACE); vscrl1 = getvsc(1);
//setdst(vscrl0); printf("%nVSCRL0=$%w, "); setdst(hscrl1); printf("VSCRL1=$%w%n");
if (>vscrl0<>$9B or <vscrl0<>$DF) xerror();
if (>vscrl1<>$0A or <vscrl1<>$CE) xerror();
passed();
2019-09-29 01:59:58 +00:00
printf("TESTING GETBPO() AND SETBPO()");
i = 0; do {
setbpo(0,i); if (getbpo(0)<>i) xerror();
setbpo(1,i); if (getbpo(1)<>i) xerror();
i = i + 16;
} while (i);
passed();
reslyr:
2019-09-25 19:56:26 +00:00
setadr($1F, &$2000); setmem(@layer0, &layer0);
setadr($1F, &$3000); setmem(@layer1, &layer1);
2019-09-23 23:57:03 +00:00
goto exit;
2019-09-25 19:56:26 +00:00