+ memset((void*)&gpu_unai, 0, sizeof(gpu_unai));
+ gpu_unai.vram = (u16*)gpu.vram;
+
+ // Original standalone gpu_unai initialized TextureWindow[]. I added the
+ // same behavior here, since it seems unsafe to leave [2],[3] unset when
+ // using HLE and Rearmed gpu_neon sets this similarly on init. -senquack
+ gpu_unai.TextureWindow[0] = 0;
+ gpu_unai.TextureWindow[1] = 0;
+ gpu_unai.TextureWindow[2] = 255;
+ gpu_unai.TextureWindow[3] = 255;
+ //senquack - new vars must be updated whenever texture window is changed:
+ // (used for polygon-drawing in gpu_inner.h, gpu_raster_polygon.h)
+ const u32 fb = FIXED_BITS; // # of fractional fixed-pt bits of u4/v4
+ gpu_unai.u_msk = (((u32)gpu_unai.TextureWindow[2]) << fb) | ((1 << fb) - 1);
+ gpu_unai.v_msk = (((u32)gpu_unai.TextureWindow[3]) << fb) | ((1 << fb) - 1);
+
+ // Configuration options
+ gpu_unai.config = gpu_unai_config_ext;
+ //senquack - disabled, not sure this is needed and would require modifying
+ // sprite-span functions, perhaps unnecessarily. No Abe Oddysey hack was
+ // present in latest PCSX4ALL sources we were using.
+ //gpu_unai.config.enableAbbeyHack = gpu_unai_config_ext.abe_hack;
+ gpu_unai.ilace_mask = gpu_unai.config.ilace_force;
+
+#ifdef GPU_UNAI_USE_INT_DIV_MULTINV
+ // s_invTable
+ for(int i=1;i<=(1<<TABLE_BITS);++i)
+ {
+ double v = 1.0 / double(i);
+#ifdef GPU_TABLE_10_BITS
+ v *= double(0xffffffff>>1);
+#else
+ v *= double(0x80000000);
+#endif
+ s_invTable[i-1]=s32(v);
+ }
+#endif
+
+ SetupLightLUT();
+ SetupDitheringConstants();
+
+ if (gpu_unai.config.scale_hires) {
+ map_downscale_buffer();
+ }
+
+ return 0;
+}
+
+void renderer_finish(void)
+{
+ unmap_downscale_buffer();
+}
+
+void renderer_notify_res_change(void)
+{
+ if (PixelSkipEnabled()) {
+ // Set blit_mask for high horizontal resolutions. This allows skipping
+ // rendering pixels that would never get displayed on low-resolution
+ // platforms that use simple pixel-dropping scaler.
+
+ switch (gpu.screen.hres)
+ {
+ case 512: gpu_unai.blit_mask = 0xa4; break; // GPU_BlitWWSWWSWS
+ case 640: gpu_unai.blit_mask = 0xaa; break; // GPU_BlitWS
+ default: gpu_unai.blit_mask = 0; break;
+ }
+ } else {
+ gpu_unai.blit_mask = 0;
+ }
+
+ if (LineSkipEnabled()) {
+ // Set rendering line-skip (only render every other line in high-res
+ // 480 vertical mode, or, optionally, force it for all video modes)
+
+ if (gpu.screen.vres == 480) {
+ if (gpu_unai.config.ilace_force) {
+ gpu_unai.ilace_mask = 3; // Only need 1/4 of lines
+ } else {
+ gpu_unai.ilace_mask = 1; // Only need 1/2 of lines
+ }
+ } else {
+ // Vert resolution changed from 480 to lower one
+ gpu_unai.ilace_mask = gpu_unai.config.ilace_force;
+ }
+ } else {
+ gpu_unai.ilace_mask = 0;
+ }
+
+ /*
+ printf("res change hres: %d vres: %d depth: %d ilace_mask: %d\n",
+ gpu.screen.hres, gpu.screen.vres, (gpu.status & PSX_GPU_STATUS_RGB24) ? 24 : 15,
+ gpu_unai.ilace_mask);
+ */