/* Isolated 640x225 graphics regression fixture. GPL-3.0-or-later. Built/run only by check_graphics.py, never included in the game disk. */ #include #include #include "graphics.h" unsigned char phase; static void wait_for_space(void) { while(inkey()!=' ') {} while(inkey()) {} } int main(void) { unsigned i; setHighSpeed(TRUE); if(!gfx_open()) {phase=99;printf("GFX OPEN FAILED\n");return 1;} gfx_set_palette(0,0);gfx_set_palette(1,63); gfx_set_palette(2,54);gfx_set_palette(3,39); gfx_clear(1); /* Each stripe straddles an 8 KiB physical bank boundary. */ for(i=1;i<5;++i) gfx_fill_rect((i*8192u%160u)*4-3,i*8192u/160u,9,1,2); gfx_fill_rect(638,223,9,9,0); gfx_plot(639,0,3);gfx_plot(0,224,3); /* Empty, out-of-range and invalid-color draws must be no-ops. */ gfx_fill_rect(100,100,0,12,3);gfx_fill_rect(100,100,12,0,3); gfx_fill_rect(640,0,3,3,3);gfx_fill_rect(0,225,3,3,3); gfx_fill_rect(10,10,9,9,4); if(!gfx_present()) {phase=98;return 1;} phase=1;wait_for_space(); /* A different image exercises the other page and many partial byte edges. */ gfx_clear(2); gfx_fill_rect(0,0,640,1,1);gfx_fill_rect(0,224,640,1,3); gfx_fill_rect(0,0,1,225,0);gfx_fill_rect(639,0,1,225,0); gfx_fill_rect(17,51,619,154,3);gfx_fill_rect(18,52,617,152,1); if(!gfx_present()) {phase=97;return 1;} phase=2;wait_for_space(); /* The hidden page still contains page1. Copy page2, edit two edges, and prove that the rest of page2 survives on this different physical page. */ if(!gfx_copy_front()) {phase=96;return 1;} gfx_fill_rect(1,1,2,1,3);gfx_plot(639,224,1); /* These hidden edits must not appear until the explicit presentation. */ phase=3;wait_for_space(); if(!gfx_present()) {phase=95;return 1;} phase=4;wait_for_space(); gfx_close();setHighSpeed(FALSE);phase=5; printf("GRAPHICS TEST COMPLETE\n");return 0; }