#include "xbus.h" #include #include sbit NOSRAM = 0xB0; /* error pin is P3.0 */ sbit SRAM = 0xB2; /* noerror pin is P3.2 */ sbit DONE = 0xB3; /* noerror pin is P3.3 */ void PCReset(); void SRAMTest(); void EndProg (); void BoxColorCycle(); void DrawBox(int width,int height,int ulx,int uly, unsigned char color); void main() { PCReset(); XInit(); SRAMTest(); BoxColorCycle(); EndProg(); } void PCReset() { IE = 0x00; /* no interrupts */ P0 = 0xff; /* tristate (not pull down) the port */ P1 = 0xff; /* tristate (not pull down) the port */ P2 = 0xff; /* tristate (not pull down) the port */ P3 = 0xff; /* tristate (not pull down) the port */ } // Test the 32K of SRAM by writing and reading back void SRAMTest() { unsigned long errors = 0; unsigned char value; long address; NOSRAM = 0; SRAM = 0; DONE = 0; for(address=0;address<0x8000;address++) { value = (unsigned char)address; XWrite((unsigned int)address,value); } for(address=0;address<0x8000;address++) { value = XRead((unsigned int)address); if (value != (unsigned char)address) { errors++; } } if (errors == 0) { /* There were no errors in the SRAM */ SRAM = 1; } else { /* There were errors in the SRAM */ NOSRAM = 1; } // XWrite(0xfff0,(unsigned char)errors); // XWrite(0xfff1,(unsigned char)(errors>>8)); // XWrite(0xfff2,(unsigned char)(errors>>16)); // XWrite(0xfff3,(unsigned char)(errors>>24)); DONE = 1; } void EndProg () { while (1) {} } void BoxColorCycle() { unsigned char startcolor = 0; unsigned char panvalue = 0; unsigned int width,height,ulx,uly; long address; unsigned char value = 0; /* this routine was designed for the 512x128 8bit mode */ /* clear the screen */ for(address=0;address<0x8000;address++) { XWrite((unsigned int)address,value); } /* draw boxes and color cycle forever */ /* we don't have access to the color map so we must do */ /* the color cycling by redrawing with a new color */ /* only cycle colors 1-63 so background stays black */ while (1) { startcolor++; if (startcolor >= 64) { startcolor = 1; /* assign the next value to the pan register */ panvalue++; if (panvalue > 7) panvalue = 0; XWrite(0xffff,panvalue); } ulx = (rand()>>5)%240; uly = (rand()>>5)%124; width = (rand()>>5)%240 + 2; if (ulx + width > 240) width = 240 - ulx; height = (rand()>>5)%120 + 2; if (uly + height > 120) height = 120 - uly; DrawBox(width,height,ulx,uly,startcolor); } } void DrawBox(int width,int height,int ulx,int uly, unsigned char color) { unsigned int x,y,address; /* this addressing is only for 512xVVVx8bpp */ for(y=uly;y<=(uly+height);y++) for(x=ulx;x<=(ulx+width);x++) { address = x+(y*256); XWrite(address,color); } }