diff --git a/.gitignore b/.gitignore index 3e94626..d46afd3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ .DS_Store *.bak +*.a *.o *.bin *.wsc *~ +seal-hack/src/mp testserial wonderswan *.orig diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f7d40b6 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +all: + make -C seal-hack + make -C oswan + +clean: + make -C seal-hack clean + make -C oswan clean diff --git a/oswan/Makefile b/oswan/Makefile index 3d718e4..365cd60 100644 --- a/oswan/Makefile +++ b/oswan/Makefile @@ -16,12 +16,14 @@ OBJS = $(wonderswan_CXX_SRCS:.cpp=.o) all: wonderswan -CXX = clang++ -CXXFLAGS = -g -O2 `sdl-config --cflags` -arch i386 -OPTIONS = -D_REENTRANT -I. -I../seal-hack/include +CXX = g++ +CXXFLAGS = -g -O2 `sdl-config --cflags` -Wall -Werror -std=c++98 -Wno-write-strings +#-arch i386 +OPTIONS = -D_REENTRANT -I. -I../seal-hack/src/ LIBRARY_PATH = -L../seal-hack/lib/SDL -LIBS = -g $(LIBRARY_PATH) `sdl-config --libs` -arch i386 +LIBS = -g $(LIBRARY_PATH) `sdl-config --libs` +#-arch i386 ALLCFLAGS = $(CFLAGS) $(CEXTRA) $(OPTIONS) $(ALLFLAGS) ALLCXXFLAGS=$(CXXFLAGS) $(CXXEXTRA) $(OPTIONS) $(ALLFLAGS) diff --git a/oswan/source/2xSaI.cpp b/oswan/source/2xSaI.cpp index 006b254..eafef77 100644 --- a/oswan/source/2xSaI.cpp +++ b/oswan/source/2xSaI.cpp @@ -299,7 +299,7 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, { u8 *dP; u16 *bP; - u16 *xP; + //u16 *xP; u32 inc_bP; { diff --git a/oswan/source/SDLptc.h b/oswan/source/SDLptc.h index d432a84..5233b7c 100644 --- a/oswan/source/SDLptc.h +++ b/oswan/source/SDLptc.h @@ -102,7 +102,7 @@ public: nupdates = 0; is_console = 1; } - ~Surface() { + virtual ~Surface() { if ( ! is_console ) { SDL_FreeSurface(surface); } diff --git a/oswan/source/audio.cpp b/oswan/source/audio.cpp index a55af2c..8c73276 100644 --- a/oswan/source/audio.cpp +++ b/oswan/source/audio.cpp @@ -12,8 +12,8 @@ //////////////////////////////////////////////////////////////////////////////// // alternate the commenting of the following defines to get audio port tracing -#define dbgprintf // -//#define dbgprintf printf +#define dbgprintf(...) +//#define dbgprintf(...) printf(...) #include #include @@ -234,11 +234,13 @@ void ws_audio_port_write(Uint32 port, Uint8 value) ws_audio_set_channel_frequency(3,i); break; case 0x88: - dbgprintf("0x88 <- 0x%2x\n", value); fflush(stdout); + dbgprintf("0x88 <- 0x%2x\n", value); + // fflush(stdout); ws_audio_set_channel_pan(0,(value&0xF0)>>4,value&0x0F); break; case 0x89: - dbgprintf("0x89 <- 0x%2x\n", value); fflush(stdout); + dbgprintf("0x89 <- 0x%2x\n", value); + // fflush(stdout); ws_audio_set_channel_pan(1,(value&0xF0)>>4,value&0x0F); break; case 0x8A: @@ -256,7 +258,8 @@ void ws_audio_port_write(Uint32 port, Uint8 value) SwpTime=(((unsigned int)value)+1)<<5; break; case 0x8E: - dbgprintf("0x8E <- 0x%2x = %d %d %d %d %d %d %d %d \n", value, value & 0x80 ? 1 : 0, value & 0x40 ? 1 : 0, value & 0x20 ? 1 : 0, value & 0x10 ? 1 : 0, value & 8 ? 1 : 0, value & 4 ? 1 : 0, value & 2 ? 1 : 0, value & 1), fflush(stdout); /* ctl */ + dbgprintf("0x8E <- 0x%2x = %d %d %d %d %d %d %d %d \n", value, value & 0x80 ? 1 : 0, value & 0x40 ? 1 : 0, value & 0x20 ? 1 : 0, value & 0x10 ? 1 : 0, value & 8 ? 1 : 0, value & 4 ? 1 : 0, value & 2 ? 1 : 0, value & 1); + //fflush(stdout); /* ctl */ if (value & 0x10) { ws_audio_set_channel_pdata(5,value&0x07); @@ -269,7 +272,8 @@ void ws_audio_port_write(Uint32 port, Uint8 value) WaveMap=((unsigned int)value)<<6; break; case 0x90: - dbgprintf("0x90 <- 0x%2x = %d %d %d %d %d %d %d %d \n", value, value & 0x80 ? 1 : 0, value & 0x40 ? 1 : 0, value & 0x20 ? 1 : 0, value & 0x10 ? 1 : 0, value & 8 ? 1 : 0, value & 4 ? 1 : 0, value & 2 ? 1 : 0, value & 1), fflush(stdout); /* ctl */ + dbgprintf("0x90 <- 0x%2x = %d %d %d %d %d %d %d %d \n", value, value & 0x80 ? 1 : 0, value & 0x40 ? 1 : 0, value & 0x20 ? 1 : 0, value & 0x10 ? 1 : 0, value & 8 ? 1 : 0, value & 4 ? 1 : 0, value & 2 ? 1 : 0, value & 1); + //fflush(stdout); /* ctl */ if (value&0x01) { @@ -515,9 +519,10 @@ int ws_audio_seal_init(void) AGetAudioDevCaps(nDevId, &caps); fprintf(log_get(),"audio: %2d. %s\n", nDevId, caps.szProductName); } + /* open audio device */ //info.nDeviceId = AUDIO_DEVICE_MAPPER; - info.nDeviceId = 1; + info.nDeviceId = 0; info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO; // | AUDIO_MIXER_BASS; info.nSampleRate = 44100; if ((rc = AOpenAudio(&info)) != AUDIO_ERROR_NONE) @@ -664,7 +669,7 @@ void ws_audio_seal_done(void) ADestroyAudioData(&ws_audio_sweep_wave); // release pcm channels - for (i=0;i<6;i++) + for (i=0;i<4;i++) ADestroyAudioVoice(ws_audio_pcm_voice[i]); // release noise channel @@ -1091,9 +1096,9 @@ void ws_audio_set_pcm(int Data) //////////////////////////////////////////////////////////////////////////////// void ws_audio_flash_pcm(void) { - int result; - void *ptr1,*ptr2; - DWORD len1,len2; + //int result; + //void *ptr1,*ptr2; + DWORD len1; //,len2; const DWORD WrPos[16]= { @@ -1104,6 +1109,10 @@ void ws_audio_flash_pcm(void) }; len1=BUFSIZEP; + + if (ws_audio_noise_wave.lpData == NULL) + return; + memcpy(&ws_audio_noise_wave.lpData[WrPos[PcmWrPos]], PDataP, len1); AWriteAudioData(&ws_audio_noise_wave, 0, ws_audio_noise_wave.dwLength); @@ -1317,11 +1326,11 @@ void ws_audio_readState(int fp) //////////////////////////////////////////////////////////////////////////////// void ws_audio_writeState(int fp) { - long lpdwPosition; - long lpdwFrequency; - unsigned int lpnVolume; - unsigned int lpnPanning; - int lpnStatus; + int32_t lpdwPosition; + int32_t lpdwFrequency; + uint16_t lpnVolume; + uint16_t lpnPanning; + int8_t lpnStatus; write(fp,&PCMPos,sizeof(DWORD)); write(fp,&TickZ,sizeof(DWORD)); diff --git a/oswan/source/filters/filter_partA.h b/oswan/source/filters/filter_partA.h index 1dc04f5..659879e 100644 --- a/oswan/source/filters/filter_partA.h +++ b/oswan/source/filters/filter_partA.h @@ -1,8 +1,9 @@ - Sint32 startTime, endTime, totalFrames; - Uint32 nNormalLast=0; - Sint32 nNormalFrac=0; - Sint32 nTime=0,nCount=0; int i=0; + //Sint32 startTime, endTime, totalFrames; + //Uint32 nNormalLast=0; + //Sint32 nNormalFrac=0; + //Sint32 nTime=0, + Sint32 nCount=0; int i=0; double dTime = 0.0, dNormalLast = 0.0, dTemp; Sint32 surfacePitch; diff --git a/oswan/source/filters/filter_partB.h b/oswan/source/filters/filter_partB.h index 51860c0..4936663 100644 --- a/oswan/source/filters/filter_partB.h +++ b/oswan/source/filters/filter_partB.h @@ -8,10 +8,10 @@ console.option("windowed output"); console.option("fixed window"); console.option("center window"); - totalFrames=0; - startTime=clock(); - nNormalLast=0;// Last value of timeGetTime() - nNormalFrac=0; // Extra fraction we did + //totalFrames=0; + //startTime=clock(); + //nNormalLast=0;// Last value of timeGetTime() + //nNormalFrac=0; // Extra fraction we did //nNormalLast=timeGetTime(); // hopefully, we only care about time delta, not time of day... //nNormalLast = SDL_GetTicks(); diff --git a/oswan/source/filters/filter_partC.h b/oswan/source/filters/filter_partC.h index 830bb79..4026006 100644 --- a/oswan/source/filters/filter_partC.h +++ b/oswan/source/filters/filter_partC.h @@ -47,7 +47,7 @@ strcpy(old_rom_path,ws_rom_path); //gui_open(); #ifndef GUI_OPEN_WARNED -#warning XXX something ought to take place here... +//#warning XXX something ought to take place here... #define GUI_OPEN_WARNED #endif app_terminate = 1; diff --git a/oswan/source/filters/filter_partD.h b/oswan/source/filters/filter_partD.h index a89be85..793ac9d 100644 --- a/oswan/source/filters/filter_partD.h +++ b/oswan/source/filters/filter_partD.h @@ -6,5 +6,5 @@ while (!ws_executeLine(backbuffer,0)); while (!ws_executeLine(backbuffer,1)); - totalFrames++; + //totalFrames++; diff --git a/oswan/source/filters/filter_partE.h b/oswan/source/filters/filter_partE.h index 0d5a91b..2b27c2c 100644 --- a/oswan/source/filters/filter_partE.h +++ b/oswan/source/filters/filter_partE.h @@ -1,4 +1,4 @@ - endTime=clock(); - float fps=totalFrames/(((float)(endTime-startTime))/(float)CLOCKS_PER_SEC); + //endTime=clock(); + //float fps=totalFrames/(((float)(endTime-startTime))/(float)CLOCKS_PER_SEC); console.close(); delete surface; diff --git a/oswan/source/gpu.cpp b/oswan/source/gpu.cpp index 3880558..ee19bec 100644 --- a/oswan/source/gpu.cpp +++ b/oswan/source/gpu.cpp @@ -759,14 +759,22 @@ void ws_gpu_renderScanline(int16 *framebuffer) uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; } // render the last clipped tile @@ -835,25 +843,41 @@ void ws_gpu_renderScanline(int16 *framebuffer) if ((tileInfo>>9)&0x04) { - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; } else { - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; } } @@ -937,9 +961,9 @@ void ws_gpu_renderScanline(int16 *framebuffer) if (ws_ioRam[0x00]&0x02) { int ws_fgWindow_x0=ws_ioRam[0x08]; - int ws_fgWindow_y0=ws_ioRam[0x09]; + //int ws_fgWindow_y0=ws_ioRam[0x09]; int ws_fgWindow_x1=ws_ioRam[0x0a]; - int ws_fgWindow_y1=ws_ioRam[0x0b]; + //int ws_fgWindow_y1=ws_ioRam[0x0b]; int ws_fgScroll_x=ws_ioRam[0x12]; int ws_fgScroll_y=ws_ioRam[0x13]; @@ -998,14 +1022,22 @@ void ws_gpu_renderScanline(int16 *framebuffer) int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; } // render the last clipped tile @@ -1073,25 +1105,41 @@ void ws_gpu_renderScanline(int16 *framebuffer) if ((tileInfo>>9)&0x04) { - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; } else { - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; + *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; } } @@ -1170,14 +1218,22 @@ void ws_gpu_renderScanline(int16 *framebuffer) - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; } // render the last clipped tile @@ -1235,14 +1291,22 @@ void ws_gpu_renderScanline(int16 *framebuffer) int16 *ws_paletteAlias=&ws_palette[((tileInfo>>9)&0x0f)<<2]; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; } // render the last clipped tile @@ -1309,14 +1373,22 @@ void ws_gpu_renderScanline(int16 *framebuffer) - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; + scanlinePtr++; ws_tileRow++; column++; } // render the last clipped tile @@ -1372,14 +1444,22 @@ void ws_gpu_renderScanline(int16 *framebuffer) uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); int16 *ws_paletteAlias=&ws_palette[((tileInfo>>9)&0x0f)<<2]; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; + if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; + scanlinePtr++; ws_tileRow++; column++; } // render the last clipped tile diff --git a/oswan/source/gpu.cpp.orig b/oswan/source/gpu.cpp.orig deleted file mode 100644 index 41c2360..0000000 --- a/oswan/source/gpu.cpp.orig +++ /dev/null @@ -1,1580 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// GPU -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// 7.04.2002: Fixed sprites order -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// - -//#define STATISTICS - -#include -#include -#include -#include -#include -#include -#include "log.h" -#include "rom.h" -#include "./nec/nec.h" -#include "io.h" -#include "gpu.h" - -#ifdef STATISTICS - #include "ticker.h" -#endif -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -extern uint8 *internalRam; - -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -#ifdef STATISTICS - long ws_4_shades_tiles_cache_update_time=0; - long ws_4_colors_tiles_cache_update_time=0; - long ws_16_colors_packed_tiles_cache_update_time=0; - long ws_16_colors_layered_tiles_cache_update_time=0; - - long ws_4_shades_tiles_cache_update_number=0; - long ws_4_colors_tiles_cache_update_number=0; - long ws_16_colors_packed_tiles_cache_update_number=0; - long ws_16_colors_layered_tiles_cache_update_number=0; - - long ws_background_color_rendering_time=0; - long ws_background_rendering_time=0; - long ws_foreground_rendering_time=0; - long ws_priority_0_sprites_rendering_time=0; - long ws_priority_1_sprites_rendering_time=0; -#endif -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -#define RGB555(R,G,B) ((((int)(R))<<10)|(((int)(G))<<5)|((int)(B))) - -uint8 ws_gpu_operatingInColor; -uint8 ws_videoMode; -uint8 ws_gpu_scanline=0; -int16 ws_palette[16*4]; -int8 ws_paletteColors[8]; -int16 wsc_palette[16*16]; -int16 ws_shades[16]; -int ws_gpu_forceColorSystemBool=0; -int ws_gpu_forceMonoSystemBool=0; - - - -// white -#define SHADE_COLOR_RED 1.00 -#define SHADE_COLOR_GREEN 1.00 -#define SHADE_COLOR_BLUE 1.00 - -int16 ws_colour_scheme_default[16]={ - RGB555(SHADE_COLOR_RED*30,SHADE_COLOR_GREEN*30,SHADE_COLOR_BLUE*30), - RGB555(SHADE_COLOR_RED*28,SHADE_COLOR_GREEN*28,SHADE_COLOR_BLUE*28), - RGB555(SHADE_COLOR_RED*26,SHADE_COLOR_GREEN*26,SHADE_COLOR_BLUE*26), - RGB555(SHADE_COLOR_RED*24,SHADE_COLOR_GREEN*24,SHADE_COLOR_BLUE*24), - RGB555(SHADE_COLOR_RED*22,SHADE_COLOR_GREEN*22,SHADE_COLOR_BLUE*22), - RGB555(SHADE_COLOR_RED*20,SHADE_COLOR_GREEN*20,SHADE_COLOR_BLUE*20), - RGB555(SHADE_COLOR_RED*18,SHADE_COLOR_GREEN*18,SHADE_COLOR_BLUE*18), - RGB555(SHADE_COLOR_RED*16,SHADE_COLOR_GREEN*16,SHADE_COLOR_BLUE*16), - RGB555(SHADE_COLOR_RED*14,SHADE_COLOR_GREEN*14,SHADE_COLOR_BLUE*14), - RGB555(SHADE_COLOR_RED*12,SHADE_COLOR_GREEN*12,SHADE_COLOR_BLUE*12), - RGB555(SHADE_COLOR_RED*10,SHADE_COLOR_GREEN*10,SHADE_COLOR_BLUE*10), - RGB555(SHADE_COLOR_RED*8,SHADE_COLOR_GREEN*8,SHADE_COLOR_BLUE*8), - RGB555(SHADE_COLOR_RED*6,SHADE_COLOR_GREEN*6,SHADE_COLOR_BLUE*6), - RGB555(SHADE_COLOR_RED*4,SHADE_COLOR_GREEN*4,SHADE_COLOR_BLUE*4), - RGB555(SHADE_COLOR_RED*2,SHADE_COLOR_GREEN*2,SHADE_COLOR_BLUE*2), - RGB555(SHADE_COLOR_RED*0,SHADE_COLOR_GREEN*0,SHADE_COLOR_BLUE*0) - }; -// green -#undef SHADE_COLOR_RED -#undef SHADE_COLOR_GREEN -#undef SHADE_COLOR_BLUE -#define SHADE_COLOR_RED 0.20 -#define SHADE_COLOR_GREEN 0.90 -#define SHADE_COLOR_BLUE 0.20 - -int16 ws_colour_scheme_green[16]={ - RGB555(SHADE_COLOR_RED*30,SHADE_COLOR_GREEN*30,SHADE_COLOR_BLUE*30), - RGB555(SHADE_COLOR_RED*28,SHADE_COLOR_GREEN*28,SHADE_COLOR_BLUE*28), - RGB555(SHADE_COLOR_RED*26,SHADE_COLOR_GREEN*26,SHADE_COLOR_BLUE*26), - RGB555(SHADE_COLOR_RED*24,SHADE_COLOR_GREEN*24,SHADE_COLOR_BLUE*24), - RGB555(SHADE_COLOR_RED*22,SHADE_COLOR_GREEN*22,SHADE_COLOR_BLUE*22), - RGB555(SHADE_COLOR_RED*20,SHADE_COLOR_GREEN*20,SHADE_COLOR_BLUE*20), - RGB555(SHADE_COLOR_RED*18,SHADE_COLOR_GREEN*18,SHADE_COLOR_BLUE*18), - RGB555(SHADE_COLOR_RED*16,SHADE_COLOR_GREEN*16,SHADE_COLOR_BLUE*16), - RGB555(SHADE_COLOR_RED*14,SHADE_COLOR_GREEN*14,SHADE_COLOR_BLUE*14), - RGB555(SHADE_COLOR_RED*12,SHADE_COLOR_GREEN*12,SHADE_COLOR_BLUE*12), - RGB555(SHADE_COLOR_RED*10,SHADE_COLOR_GREEN*10,SHADE_COLOR_BLUE*10), - RGB555(SHADE_COLOR_RED*8,SHADE_COLOR_GREEN*8,SHADE_COLOR_BLUE*8), - RGB555(SHADE_COLOR_RED*6,SHADE_COLOR_GREEN*6,SHADE_COLOR_BLUE*6), - RGB555(SHADE_COLOR_RED*4,SHADE_COLOR_GREEN*4,SHADE_COLOR_BLUE*4), - RGB555(SHADE_COLOR_RED*2,SHADE_COLOR_GREEN*2,SHADE_COLOR_BLUE*2), - RGB555(SHADE_COLOR_RED*0,SHADE_COLOR_GREEN*0,SHADE_COLOR_BLUE*0) - }; -// amber -#undef SHADE_COLOR_RED -#undef SHADE_COLOR_GREEN -#undef SHADE_COLOR_BLUE -#define SHADE_COLOR_RED 1.00 -#define SHADE_COLOR_GREEN 0.61 -#define SHADE_COLOR_BLUE 0.00 - -int16 ws_colour_scheme_amber[16]={ - RGB555(SHADE_COLOR_RED*30,SHADE_COLOR_GREEN*30,SHADE_COLOR_BLUE*30), - RGB555(SHADE_COLOR_RED*28,SHADE_COLOR_GREEN*28,SHADE_COLOR_BLUE*28), - RGB555(SHADE_COLOR_RED*26,SHADE_COLOR_GREEN*26,SHADE_COLOR_BLUE*26), - RGB555(SHADE_COLOR_RED*24,SHADE_COLOR_GREEN*24,SHADE_COLOR_BLUE*24), - RGB555(SHADE_COLOR_RED*22,SHADE_COLOR_GREEN*22,SHADE_COLOR_BLUE*22), - RGB555(SHADE_COLOR_RED*20,SHADE_COLOR_GREEN*20,SHADE_COLOR_BLUE*20), - RGB555(SHADE_COLOR_RED*18,SHADE_COLOR_GREEN*18,SHADE_COLOR_BLUE*18), - RGB555(SHADE_COLOR_RED*16,SHADE_COLOR_GREEN*16,SHADE_COLOR_BLUE*16), - RGB555(SHADE_COLOR_RED*14,SHADE_COLOR_GREEN*14,SHADE_COLOR_BLUE*14), - RGB555(SHADE_COLOR_RED*12,SHADE_COLOR_GREEN*12,SHADE_COLOR_BLUE*12), - RGB555(SHADE_COLOR_RED*10,SHADE_COLOR_GREEN*10,SHADE_COLOR_BLUE*10), - RGB555(SHADE_COLOR_RED*8,SHADE_COLOR_GREEN*8,SHADE_COLOR_BLUE*8), - RGB555(SHADE_COLOR_RED*6,SHADE_COLOR_GREEN*6,SHADE_COLOR_BLUE*6), - RGB555(SHADE_COLOR_RED*4,SHADE_COLOR_GREEN*4,SHADE_COLOR_BLUE*4), - RGB555(SHADE_COLOR_RED*2,SHADE_COLOR_GREEN*2,SHADE_COLOR_BLUE*2), - RGB555(SHADE_COLOR_RED*0,SHADE_COLOR_GREEN*0,SHADE_COLOR_BLUE*0) - }; - -uint8 *ws_tile_cache; -uint8 *ws_hflipped_tile_cache; - -uint8 *wsc_tile_cache; -uint8 *wsc_hflipped_tile_cache; - -uint8 *ws_modified_tile; -uint8 *wsc_modified_tile; - -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_set_colour_scheme(int scheme) -{ - switch (scheme) - { - case COLOUR_SCHEME_DEFAULT: memcpy(ws_shades,ws_colour_scheme_default,16*sizeof(int16)); break; - case COLOUR_SCHEME_AMBER : memcpy(ws_shades,ws_colour_scheme_amber,16*sizeof(int16)); break; - case COLOUR_SCHEME_GREEN : memcpy(ws_shades,ws_colour_scheme_green,16*sizeof(int16)); break; - } -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_forceColorSystem(void) -{ - ws_gpu_forceColorSystemBool=1; - ws_gpu_forceMonoSystemBool=0; - ws_gpu_operatingInColor=1; -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_forceMonoSystem(void) -{ - ws_gpu_forceColorSystemBool=0; - ws_gpu_forceMonoSystemBool=1; - ws_gpu_operatingInColor=0; -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_init(void) -{ - ws_tile_cache = (uint8*)malloc(512*8*8); - wsc_tile_cache = (uint8*)malloc(1024*8*8); - - ws_hflipped_tile_cache = (uint8*)malloc(512*8*8); - wsc_hflipped_tile_cache = (uint8*)malloc(1024*8*8); - - ws_modified_tile = (uint8*)malloc(512); - wsc_modified_tile = (uint8*)malloc(1024); - - memset(ws_tile_cache,0x00,512*8*8); - memset(wsc_tile_cache,0x00,1024*8*8); - - memset(ws_hflipped_tile_cache,0x00,512*8*8); - memset(wsc_hflipped_tile_cache,0x00,1024*8*8); - - memset(ws_modified_tile,0x01,512); - memset(wsc_modified_tile,0x01,1024); - - ws_gpu_forceColorSystemBool=0; - ws_gpu_forceMonoSystemBool=0; -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_done(void) -{ - free(ws_tile_cache); - free(wsc_tile_cache); - free(ws_hflipped_tile_cache); - free(wsc_hflipped_tile_cache); - free(ws_modified_tile); - free(wsc_modified_tile); -#ifdef STATISTICS - printf("Statistics:\n"); - printf("\tcache:\n"); - if (ws_4_shades_tiles_cache_update_number) - printf("\t\t4 shades tiles update time : %i\n",ws_4_shades_tiles_cache_update_time/ws_4_shades_tiles_cache_update_number); - if (ws_4_colors_tiles_cache_update_number) - printf("\t\t4 colors tiles update time : %i\n",ws_4_colors_tiles_cache_update_time/ws_4_colors_tiles_cache_update_number); - if (ws_16_colors_packed_tiles_cache_update_number) - printf("\t\t16 colors packed tiles update time : %i\n",ws_16_colors_packed_tiles_cache_update_time/ws_16_colors_packed_tiles_cache_update_number); - if (ws_16_colors_layered_tiles_cache_update_number) - printf("\t\t16 colors layered tiles update time: %i\n",ws_16_colors_layered_tiles_cache_update_time/ws_16_colors_layered_tiles_cache_update_number); - - printf("\tscanline rendering:\n"); - long total= ws_background_color_rendering_time+ws_background_rendering_time+ - ws_foreground_rendering_time+ws_priority_0_sprites_rendering_time+ - ws_priority_1_sprites_rendering_time; - printf("\t\tbackground color : %4i (%3i %%)\n",ws_background_color_rendering_time,(ws_background_color_rendering_time*100)/total); - printf("\t\tbackground : %4i (%3i %%)\n",ws_background_rendering_time,(ws_background_rendering_time*100)/total); - printf("\t\tforeground : %4i (%3i %%)\n",ws_foreground_rendering_time,(ws_foreground_rendering_time*100)/total); - printf("\t\tpriority 0 sprites : %4i (%3i %%)\n",ws_priority_0_sprites_rendering_time,(ws_priority_0_sprites_rendering_time*100)/total); - printf("\t\tpriority 1 sprites : %4i (%3i %%)\n",ws_priority_1_sprites_rendering_time,(ws_priority_1_sprites_rendering_time*100)/total); -#endif -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_changeVideoMode(uint8 value) -{ - if (ws_videoMode!=(value>>5)) - { - ws_videoMode=value>>5; - if (ws_videoMode==4) - ws_videoMode=2; - - // mark all tiles dirty - memset(wsc_modified_tile,0x01,1024); - memset(ws_modified_tile,0x01,512); - } -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_reset(void) -{ - memset(wsc_modified_tile,0x01,1024); - memset(ws_modified_tile,0x01,512); - ws_gpu_scanline=0; - ws_gpu_changeVideoMode(2); -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_clearCache(void) -{ - memset(wsc_modified_tile,0x01,1024); - memset(ws_modified_tile,0x01,512); -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -uint8 *ws_tileCache_getTileRow(uint32 tileIndex, uint32 line, - uint32 vFlip, uint32 hFlip, uint32 bank) -{ - if (ws_gpu_operatingInColor) - { - if (bank) - tileIndex+=512; - - // need to update tile cache ? - // 4 colors tiles - if ((ws_videoMode==2)&&(ws_modified_tile[tileIndex])) - { -#ifdef STATISTICS - ws_4_colors_tiles_cache_update_time+=-ticker(); -#endif - uint8 *tileInCachePtr = &wsc_tile_cache[tileIndex<<6]; - uint8 *hflippedTileInCachePtr = &wsc_hflipped_tile_cache[tileIndex<<6]; - uint16 *tileInRamPtr = (uint16*)&internalRam[0x2000+(tileIndex<<4)]; - uint16 tileLine; - - for (int line=0;line<8;line++) - { - tileLine=*tileInRamPtr++; - - tileInCachePtr[0]=((tileLine&0x80)>>7)|((tileLine&0x8000)>>14); - hflippedTileInCachePtr[7]=tileInCachePtr[0]; - tileInCachePtr[1]=((tileLine&0x40)>>6)|((tileLine&0x4000)>>13); - hflippedTileInCachePtr[6]=tileInCachePtr[1]; - tileInCachePtr[2]=((tileLine&0x20)>>5)|((tileLine&0x2000)>>12); - hflippedTileInCachePtr[5]=tileInCachePtr[2]; - tileInCachePtr[3]=((tileLine&0x10)>>4)|((tileLine&0x1000)>>11); - hflippedTileInCachePtr[4]=tileInCachePtr[3]; - tileInCachePtr[4]=((tileLine&0x08)>>3)|((tileLine&0x0800)>>10); - hflippedTileInCachePtr[3]=tileInCachePtr[4]; - tileInCachePtr[5]=((tileLine&0x04)>>2)|((tileLine&0x0400)>>9); - hflippedTileInCachePtr[2]=tileInCachePtr[5]; - tileInCachePtr[6]=((tileLine&0x02)>>1)|((tileLine&0x0200)>>8); - hflippedTileInCachePtr[1]=tileInCachePtr[6]; - tileInCachePtr[7]=((tileLine&0x01)>>0)|((tileLine&0x0100)>>7); - hflippedTileInCachePtr[0]=tileInCachePtr[7]; - - tileInCachePtr+=8; - hflippedTileInCachePtr+=8; - } - ws_modified_tile[tileIndex]=0; -#ifdef STATISTICS - ws_4_colors_tiles_cache_update_time+=ticker(); - ws_4_colors_tiles_cache_update_number++; -#endif - } - else - if (wsc_modified_tile[tileIndex]) - { - // 16 colors by tile layered mode - if (ws_videoMode==6) - { -#ifdef STATISTICS - ws_16_colors_layered_tiles_cache_update_time+=-ticker(); -#endif - uint8 *tileInCachePtr = &wsc_tile_cache[tileIndex<<6]; - uint8 *hflippedTileInCachePtr = &wsc_hflipped_tile_cache[tileIndex<<6]; - uint32 *tileInRamPtr = (uint32*)&internalRam[0x4000+(tileIndex<<5)]; - uint32 tileLine; - - for (int line=0;line<8;line++) - { - tileLine=*tileInRamPtr++; - - tileInCachePtr[0]=((tileLine&0x00000080)>>7)|((tileLine&0x00008000)>>14)| - ((tileLine&0x00800000)>>21)|((tileLine&0x80000000)>>28); - hflippedTileInCachePtr[7]=tileInCachePtr[0]; - - tileInCachePtr[1]=((tileLine&0x00000040)>>6)|((tileLine&0x00004000)>>13)| - ((tileLine&0x00400000)>>20)|((tileLine&0x40000000)>>27); - hflippedTileInCachePtr[6]=tileInCachePtr[1]; - - tileInCachePtr[2]=((tileLine&0x00000020)>>5)|((tileLine&0x00002000)>>12)| - ((tileLine&0x00200000)>>19)|((tileLine&0x20000000)>>26); - hflippedTileInCachePtr[5]=tileInCachePtr[2]; - - tileInCachePtr[3]=((tileLine&0x00000010)>>4)|((tileLine&0x00001000)>>11)| - ((tileLine&0x00100000)>>18)|((tileLine&0x10000000)>>25); - hflippedTileInCachePtr[4]=tileInCachePtr[3]; - - tileInCachePtr[4]=((tileLine&0x00000008)>>3)|((tileLine&0x00000800)>>10)| - ((tileLine&0x00080000)>>17)|((tileLine&0x08000000)>>24); - hflippedTileInCachePtr[3]=tileInCachePtr[4]; - - tileInCachePtr[5]=((tileLine&0x00000004)>>2)|((tileLine&0x00000400)>>9)| - ((tileLine&0x00040000)>>16)|((tileLine&0x04000000)>>23); - hflippedTileInCachePtr[2]=tileInCachePtr[5]; - - tileInCachePtr[6]=((tileLine&0x00000002)>>1)|((tileLine&0x00000200)>>8)| - ((tileLine&0x00020000)>>15)|((tileLine&0x02000000)>>22); - hflippedTileInCachePtr[1]=tileInCachePtr[6]; - - tileInCachePtr[7]=((tileLine&0x00000001)>>0)|((tileLine&0x00000100)>>7)| - ((tileLine&0x00010000)>>14)|((tileLine&0x01000000)>>21); - hflippedTileInCachePtr[0]=tileInCachePtr[7]; - - tileInCachePtr+=8; - hflippedTileInCachePtr+=8; - } -#ifdef STATISTICS - ws_16_colors_layered_tiles_cache_update_time+=ticker(); - ws_16_colors_layered_tiles_cache_update_number++; -#endif - } - else - // 16 colors by tile packed mode - if (ws_videoMode==7) - { -#ifdef STATISTICS - ws_16_colors_packed_tiles_cache_update_time+=-ticker(); -#endif - uint8 *tileInCachePtr = &wsc_tile_cache[tileIndex<<6]; - uint8 *hflippedTileInCachePtr = &wsc_hflipped_tile_cache[tileIndex<<6]; - uint32 *tileInRamPtr = (uint32*)&internalRam[0x4000+(tileIndex<<5)]; - uint32 tileLine; - - for (int line=0;line<8;line++) - { - tileLine=*tileInRamPtr++; - - tileInCachePtr[0]=(tileLine>>4)&0x0f; - hflippedTileInCachePtr[7]=tileInCachePtr[0]; - tileInCachePtr[1]=(tileLine>>0)&0x0f; - hflippedTileInCachePtr[6]=tileInCachePtr[1]; - tileInCachePtr[2]=(tileLine>>12)&0x0f; - hflippedTileInCachePtr[5]=tileInCachePtr[2]; - tileInCachePtr[3]=(tileLine>>8)&0x0f; - hflippedTileInCachePtr[4]=tileInCachePtr[3]; - tileInCachePtr[4]=(tileLine>>20)&0x0f; - hflippedTileInCachePtr[3]=tileInCachePtr[4]; - tileInCachePtr[5]=(tileLine>>16)&0x0f; - hflippedTileInCachePtr[2]=tileInCachePtr[5]; - tileInCachePtr[6]=(tileLine>>28)&0x0f; - hflippedTileInCachePtr[1]=tileInCachePtr[6]; - tileInCachePtr[7]=(tileLine>>24)&0x0f; - hflippedTileInCachePtr[0]=tileInCachePtr[7]; - - tileInCachePtr+=8; - hflippedTileInCachePtr+=8; - - } -#ifdef STATISTICS - ws_16_colors_packed_tiles_cache_update_time+=ticker(); - ws_16_colors_packed_tiles_cache_update_number++; -#endif - } - else - { - // unknown mode - } - // tile cache updated - wsc_modified_tile[tileIndex]=0; - } - if (vFlip) - line=7-line; - if (hFlip) - return(&wsc_hflipped_tile_cache[(tileIndex<<6)+(line<<3)]); - else - return(&wsc_tile_cache[(tileIndex<<6)+(line<<3)]); - - } - else - { - // need to update tile cache ? - if (ws_modified_tile[tileIndex]) - { -#ifdef STATISTICS - ws_4_shades_tiles_cache_update_time+=-ticker(); -#endif - uint8 *tileInCachePtr = &ws_tile_cache[tileIndex<<6]; - uint8 *hflippedTileInCachePtr = &ws_hflipped_tile_cache[(tileIndex<<6)+7]; - uint32 *tileInRamPtr = (uint32*)&internalRam[0x2000+(tileIndex<<4)]; - uint32 tileLine; - - for (int line=0;line<4;line++) - { - tileLine=*tileInRamPtr++; - - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x80)>>7)|((tileLine&0x8000)>>14); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x40)>>6)|((tileLine&0x4000)>>13); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x20)>>5)|((tileLine&0x2000)>>12); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x10)>>4)|((tileLine&0x1000)>>11); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x08)>>3)|((tileLine&0x0800)>>10); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x04)>>2)|((tileLine&0x0400)>>9); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x02)>>1)|((tileLine&0x0200)>>8); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x01)>>0)|((tileLine&0x0100)>>7); - hflippedTileInCachePtr+=16; - tileLine>>=16; - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x80)>>7)|((tileLine&0x8000)>>14); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x40)>>6)|((tileLine&0x4000)>>13); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x20)>>5)|((tileLine&0x2000)>>12); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x10)>>4)|((tileLine&0x1000)>>11); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x08)>>3)|((tileLine&0x0800)>>10); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x04)>>2)|((tileLine&0x0400)>>9); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x02)>>1)|((tileLine&0x0200)>>8); - *hflippedTileInCachePtr--=*tileInCachePtr++=((tileLine&0x01)>>0)|((tileLine&0x0100)>>7); - hflippedTileInCachePtr+=16; - } - // tile cache updated - ws_modified_tile[tileIndex]=0; -#ifdef STATISTICS - ws_4_shades_tiles_cache_update_time+=ticker(); - ws_4_shades_tiles_cache_update_number++; -#endif - } - if (vFlip) - line=7-line; - if (hFlip) - return(&ws_hflipped_tile_cache[(tileIndex<<6)+(line<<3)]); - else - return(&ws_tile_cache[(tileIndex<<6)+(line<<3)]); - } - return(NULL); -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_drawClippedSpriteLine(int16 *framebuffer, uint16 scanline, - uint32 x, uint32 y, uint32 tileIndex, uint32 paletteIndex, - uint32 vFlip, uint32 hFlip, - uint32 clip_x0, uint32 clip_y0, uint32 clip_x1, uint32 clip_y1) -{ - - if ((scanline(y+7))) - return; - if ((x+7=clip_x1)) - return; - if ((y+7=clip_y1)) - return; - - uint8 *ws_tileRow=ws_tileCache_getTileRow(tileIndex,(scanline-y)&0x07,hFlip,vFlip, 0); - uint16 nbPixels=8; - if (xclip_x1) - nbPixels=(clip_x1-x); - framebuffer+=x; - - if (ws_gpu_operatingInColor) - { - int16 *wsc_paletteAlias=&wsc_palette[paletteIndex<<4]; - while (nbPixels) - { - if (*ws_tileRow) *framebuffer=wsc_paletteAlias[*ws_tileRow]; - framebuffer++; ws_tileRow++; - nbPixels--; - } - } - else - { - int16 *ws_paletteAlias=&ws_palette[paletteIndex<<2]; - if (paletteIndex&0x04) - { - while (nbPixels) - { - if (*ws_tileRow) *framebuffer=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - framebuffer++; ws_tileRow++; - nbPixels--; - } - } - else - { - while (nbPixels) - { - *framebuffer=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - framebuffer++; ws_tileRow++; - nbPixels--; - } - } - } -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_renderScanline(int16 *framebuffer) -{ - - if (ws_gpu_scanline>143) - return; -#ifdef STATISTICS - long startTime=ticker(); -#endif - framebuffer+=(224*ws_gpu_scanline); - - // fill with background color - int16 backgroundColor; - if (ws_gpu_operatingInColor) - backgroundColor=wsc_palette[ws_ioRam[0x01]]; - else - backgroundColor=ws_shades[ws_paletteColors[ws_palette[((ws_ioRam[0x01]&0xf0)>>2)+(ws_ioRam[0x01]&0x03)]]]; - - for (int i=0;i<224;i++) - framebuffer[i]=backgroundColor; -#ifdef STATISTICS - ws_background_color_rendering_time=ticker(); -#endif - // render background layer - if (ws_ioRam[0x00]&0x01) - { - int ws_bgScroll_x=ws_ioRam[0x10]; - int ws_bgScroll_y=ws_ioRam[0x11]; - - // seek to the first tile - ws_bgScroll_y=(ws_bgScroll_y+ws_gpu_scanline)&0xff; - - // note: byte ordering assumptions! - int ws_currentTile=(ws_bgScroll_x>>3); - uint16 *ws_bgScrollRamBase=(uint16*)(internalRam+(((uint32)ws_ioRam[0x07]&0x0f)<<11)+ - ((ws_bgScroll_y&0xfff8)<<3)); - - int lineInTile = ws_bgScroll_y&0x07; - int columnInTile = ws_bgScroll_x&0x07; - - int16 *scanlinePtr=framebuffer; - - if (ws_gpu_operatingInColor) - { - // render the first clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_bgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - ws_tileRow+=columnInTile; - for (int i=columnInTile;i<8;i++) - { - if (*ws_tileRow) - *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; - scanlinePtr++; - ws_tileRow++; - } - } - - // render the tiles between them - int nbTiles=28; - if (columnInTile) - nbTiles=27; - - for (int i=0;i>9)&0x0f)<<4]; - - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - } - - // render the last clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_bgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - - - for (int i=0;i>9)&0x0f)<<2]; - ws_tileRow+=columnInTile; - - if ((tileInfo>>9)&0x04) - { - for (int i=columnInTile;i<8;i++) - { - if (*ws_tileRow) - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - scanlinePtr++; - ws_tileRow++; - } - } - else - { - for (int i=columnInTile;i<8;i++) - { - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - scanlinePtr++; - ws_tileRow++; - } - } - } - int nbTiles=28; - if (columnInTile) - nbTiles=27; - - for (int i=0;i>9)&0x0f)<<2]; - - if ((tileInfo>>9)&0x04) - { - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - } - else - { - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - } - - } - - // render the last clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_bgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *ws_paletteAlias=&ws_palette[((tileInfo>>9)&0x0f)<<2]; - - - if ((tileInfo>>9)&0x04) - { - for (int i=0;iws_ioRam[0x05];i--) - { - uint32 spr=*ws_sprRamBase--; - - if (!(spr&0x2000)) - { - // sprite window on ? - if ((ws_ioRam[0x00]&0x08)&&(spr&0x1000)&&(ws_sprWindow_x0!=ws_sprWindow_x1)) - { - ws_drawClippedSpriteLine(framebuffer,ws_gpu_scanline,(spr&0xff000000)>>24, (spr&0x00ff0000)>>16, - spr&0x1ff,8+((spr&0xe00)>>9),spr&0x4000,spr&0x8000, - ws_sprWindow_x0,ws_sprWindow_y0,ws_sprWindow_x1,ws_sprWindow_y1); - } - else - { - ws_drawClippedSpriteLine(framebuffer,ws_gpu_scanline,(spr&0xff000000)>>24, (spr&0x00ff0000)>>16, - spr&0x1ff,8+((spr&0xe00)>>9),spr&0x4000,spr&0x8000, - 0,0,224,144); - } - } - } - } -#ifdef STATISTICS - ws_priority_0_sprites_rendering_time=ticker(); -#endif - // render foreground layer - if (ws_ioRam[0x00]&0x02) - { - int ws_fgWindow_x0=ws_ioRam[0x08]; - int ws_fgWindow_y0=ws_ioRam[0x09]; - int ws_fgWindow_x1=ws_ioRam[0x0a]; - int ws_fgWindow_y1=ws_ioRam[0x0b]; - int ws_fgScroll_x=ws_ioRam[0x12]; - int ws_fgScroll_y=ws_ioRam[0x13]; - - int windowMode=ws_ioRam[0x00]&0x30; - - // seek to the first tile - ws_fgScroll_y=(ws_fgScroll_y+ws_gpu_scanline)&0xff; - - // note: byte ordering assumptions! - int ws_currentTile=(ws_fgScroll_x>>3); - uint16 *ws_fgScrollRamBase=(uint16*)(internalRam+(((uint32)ws_ioRam[0x07]&0xf0)<<7)+ - ((ws_fgScroll_y&0xfff8)<<3)); - - int lineInTile = ws_fgScroll_y&0x07; - int columnInTile = ws_fgScroll_x&0x07; - - int16 *scanlinePtr=framebuffer; - - - // window disabled - if (!windowMode) - { - if (ws_gpu_operatingInColor) - { - // render the first clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - - ws_tileRow+=columnInTile; - - for (int i=columnInTile;i<8;i++) - { - if (*ws_tileRow) - *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; - scanlinePtr++; - ws_tileRow++; - } - } - - // render the tiles between them - int nbTiles=28; - if (columnInTile) - nbTiles=27; - - for (int i=0;i>9)&0x0f)<<4]; - - - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; - } - - // render the last clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - - - for (int i=0;i>9)&0x0f)<<2]; - ws_tileRow+=columnInTile; - if ((tileInfo>>9)&0x04) - { - for (int i=columnInTile;i<8;i++) - { - if (*ws_tileRow) - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - scanlinePtr++; - ws_tileRow++; - } - } - else - { - for (int i=columnInTile;i<8;i++) - { - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - scanlinePtr++; - ws_tileRow++; - } - } - } - int nbTiles=28; - if (columnInTile) - nbTiles=27; - - for (int i=0;i>9)&0x0f)<<2]; - - if ((tileInfo>>9)&0x04) - { - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - if (*ws_tileRow) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - } - else - { - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; - } - } - - // render the last clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *ws_paletteAlias=&ws_palette[((tileInfo>>9)&0x0f)<<2]; - - - if ((tileInfo>>9)&0x04) - { - for (int i=0;i>9)&0x0f)<<4]; - - ws_tileRow+=columnInTile; - - for (int i=columnInTile;i<8;i++) - { - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) - *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; - column++; - scanlinePtr++; - ws_tileRow++; - } - } - - // render the tiles between them - int nbTiles=28; - if (columnInTile) - nbTiles=27; - - for (int i=0;i>9)&0x0f)<<4]; - - - - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - } - - // render the last clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - - - for (int i=0;i=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) - *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; - column++; - scanlinePtr++; - ws_tileRow++; - } - } - } - else - { - // render the first clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - - int16 *ws_paletteAlias=&ws_palette[((tileInfo>>9)&0x0f)<<2]; - ws_tileRow+=columnInTile; - - for (int i=columnInTile;i<8;i++) - { - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - column++; - scanlinePtr++; - ws_tileRow++; - } - } - int nbTiles=28; - if (columnInTile) - nbTiles=27; - - for (int i=0;i>9)&0x0f)<<2]; - - - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&(column>=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - } - - // render the last clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *ws_paletteAlias=&ws_palette[((tileInfo>>9)&0x0f)<<2]; - - - for (int i=0;i=ws_fgWindow_x0)&&(column<=ws_fgWindow_x1)) - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - column++; - scanlinePtr++; - ws_tileRow++; - } - } - } - } - else - // foreground layer displayed only outside the window - if (windowMode==0x30) - { - int column=0; - if (ws_gpu_operatingInColor) - { - // render the first clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - - ws_tileRow+=columnInTile; - - for (int i=columnInTile;i<8;i++) - { - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) - *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; - column++; - scanlinePtr++; - ws_tileRow++; - } - } - - // render the tiles between them - int nbTiles=28; - if (columnInTile) - nbTiles=27; - - for (int i=0;i>9)&0x0f)<<4]; - - - - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; scanlinePtr++; ws_tileRow++; column++; - } - - // render the last clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *wsc_paletteAlias=&wsc_palette[((tileInfo>>9)&0x0f)<<4]; - - - for (int i=0;iws_fgWindow_x1))) - *scanlinePtr=wsc_paletteAlias[*ws_tileRow]; - column++; - scanlinePtr++; - ws_tileRow++; - } - } - } - else - { - // render the first clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - - int16 *ws_paletteAlias=&ws_palette[((tileInfo>>9)&0x0f)<<2]; - ws_tileRow+=columnInTile; - - for (int i=columnInTile;i<8;i++) - { - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - column++; - scanlinePtr++; - ws_tileRow++; - } - } - int nbTiles=28; - if (columnInTile) - nbTiles=27; - - for (int i=0;i>9)&0x0f)<<2]; - - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - if ((*ws_tileRow)&&((columnws_fgWindow_x1))) *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; scanlinePtr++; ws_tileRow++; column++; - } - - // render the last clipped tile - if (columnInTile) - { - uint16 tileInfo=ws_fgScrollRamBase[ws_currentTile&0x1f]; - ws_currentTile++; - uint8 *ws_tileRow=ws_tileCache_getTileRow( tileInfo&0x1ff, lineInTile, - tileInfo&0x8000, tileInfo&0x4000, tileInfo&0x2000); - int16 *ws_paletteAlias=&ws_palette[((tileInfo>>9)&0x0f)<<2]; - - - for (int i=0;iws_fgWindow_x1))) - *scanlinePtr=ws_shades[ws_paletteColors[ws_paletteAlias[*ws_tileRow]]]; - column++; - scanlinePtr++; - ws_tileRow++; - } - } - } - } - else - { - // unknown - } - } -#ifdef STATISTICS - ws_foreground_rendering_time=ticker(); -#endif - // render sprites - if (ws_ioRam[0x00]&0x04) - { - int ws_sprWindow_x0=ws_ioRam[0x0c]; - int ws_sprWindow_y0=ws_ioRam[0x0d]; - int ws_sprWindow_x1=ws_ioRam[0x0e]; - int ws_sprWindow_y1=ws_ioRam[0x0f]; - uint32 *ws_sprRamBase=(uint32*)(internalRam+(((uint32)ws_ioRam[0x04])<<9)); - - // seek to first sprite - ws_sprRamBase+=ws_ioRam[0x06]-1; - - for (int i=ws_ioRam[0x06];i>ws_ioRam[0x05];i--) - { - uint32 spr=*ws_sprRamBase--; - - if (spr&0x2000) - { - // sprite window on ? - if ((ws_ioRam[0x00]&0x08)&&(spr&0x1000)&&(ws_sprWindow_x0!=ws_sprWindow_x1)) - { - ws_drawClippedSpriteLine(framebuffer,ws_gpu_scanline,(spr&0xff000000)>>24, (spr&0x00ff0000)>>16, - spr&0x1ff,8+((spr&0xe00)>>9),spr&0x4000,spr&0x8000, - ws_sprWindow_x0,ws_sprWindow_y0,ws_sprWindow_x1,ws_sprWindow_y1); - } - else - { - ws_drawClippedSpriteLine(framebuffer,ws_gpu_scanline,(spr&0xff000000)>>24, (spr&0x00ff0000)>>16, - spr&0x1ff,8+((spr&0xe00)>>9),spr&0x4000,spr&0x8000, - 0,0,224,144); - } - } - } - } -#ifdef STATISTICS - ws_priority_1_sprites_rendering_time=ticker(); - - ws_priority_1_sprites_rendering_time-=ws_foreground_rendering_time; - ws_foreground_rendering_time-=ws_priority_0_sprites_rendering_time; - ws_priority_0_sprites_rendering_time-=ws_background_rendering_time; - ws_background_rendering_time-=ws_background_color_rendering_time; - ws_background_color_rendering_time-=startTime; -#endif -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -void ws_gpu_write_byte(DWORD offset, BYTE value) -{ - // ws 4 color tiles - if ((offset>=0x2000)&&(offset<0x4000)) - { - if (internalRam[offset]!=value) - ws_modified_tile[(offset&0x1fff)>>4]=1; - // update the ram - internalRam[offset]=value; - } - if (ws_gpu_operatingInColor) - { - // wsc 16 color tiles bank 0 - if ((offset>=0x4000)&&(offset<0x8000)) - { - if (internalRam[offset]!=value) - wsc_modified_tile[(offset&0x3fff)>>5]=1; - } - else - // wsc 16 color tiles bank 1 - if ((offset>=0x8000)&&(offset<0xC000)) - { - if (internalRam[offset]!=value) - wsc_modified_tile[512+((offset&0x3fff)>>5)]=1; - } - - // update the ram - internalRam[offset]=value; - // palette ram - if (offset>=0xfe00) - { - // RGB444 format - uint16 color=(internalRam[(offset&0xfffe)+1]); - color<<=8; - color|=(internalRam[(offset&0xfffe)]); - - wsc_palette[(offset&0x1ff)>>1]=RGB555(((color>>8)&0x0f)<<1,((color>>4)&0x0f)<<1,(color&0x0f)<<1); - } - } - else - if (offset<0x4000) - internalRam[offset]=value; -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -unsigned int ws_gpu_unknownPort; -void ws_gpu_port_write(DWORD port,BYTE value) -{ - ws_gpu_unknownPort=0; - switch (port) - { - case 0x60: ws_gpu_changeVideoMode(value); - return; - case 0x1C: ws_paletteColors[0]=value&0xf; - ws_paletteColors[1]=(value>>4)&0xf; - return; - case 0x1D: ws_paletteColors[2]=value&0xf; - ws_paletteColors[3]=(value>>4)&0xf; - return; - case 0x1E: ws_paletteColors[4]=value&0xf; - ws_paletteColors[5]=(value>>4)&0xf; - return; - case 0x1F: ws_paletteColors[6]=value&0xf; - ws_paletteColors[7]=(value>>4)&0xf; - return; - default: ws_gpu_unknownPort=1; - } - if ((port>=0x20)&&(port<=0x3f)) - { - ws_gpu_unknownPort=0; - port-=0x20; - int paletteIndex=port>>1; - if (port&0x01) - { - ws_palette[(paletteIndex<<2)+2]=value&0x7; - ws_palette[(paletteIndex<<2)+3]=(value>>4)&0x7; - } - else - { - ws_palette[(paletteIndex<<2)+0]=value&0x7; - ws_palette[(paletteIndex<<2)+1]=(value>>4)&0x7; - } - } -} -//////////////////////////////////////////////////////////////////////////////// -// -//////////////////////////////////////////////////////////////////////////////// -// -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////////////////// -BYTE ws_gpu_port_read(BYTE port) -{ - if (port==0xa0) - { - if (ws_gpu_forceColorSystemBool) - return ws_ioRam[0xa0]|2; - else - if (ws_gpu_forceMonoSystemBool) - return ws_ioRam[0xa0]&(~0x02); - else - { - if (ws_gpu_operatingInColor) - return ws_ioRam[0xa0]|2; - else - return ws_ioRam[0xa0]&(~0x02); - } - } - return(ws_ioRam[port]); -} diff --git a/oswan/source/io.cpp b/oswan/source/io.cpp index 9136b14..1f17e10 100644 --- a/oswan/source/io.cpp +++ b/oswan/source/io.cpp @@ -65,7 +65,7 @@ void ws_io_reset(void) ws_key_button_2=0; int i; for (i=0;i<0x100;i++) - ws_ioRam[i]=initialIoValue[i]; + ws_ioRam[i]= initialIoValue[i]; for (i=0;i<0xc9;i++) cpu_writeport(i,initialIoValue[i]); @@ -162,8 +162,11 @@ void set_baudrate(int speed) { cfsetospeed(&options, B38400); } - +#if 0 options.c_cflag &= ~CNEW_RTSCTS; +#else + options.c_cflag &= ~CRTSCTS; +#endif options.c_cflag |= (CLOCAL | CREAD); options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); @@ -254,9 +257,9 @@ void write_serial(unsigned char value) BYTE cpu_readport(BYTE port) { int w1,w2; - BYTE retVal; + BYTE retVal = 0; - if (port >= 0xBA) && (port <= 0xBE) + if ((port >= 0xBA) && (port <= 0xBE)) { printf("Reading IEEP %02X\n", port); } @@ -453,7 +456,8 @@ BYTE cpu_readport(BYTE port) goto exit; default: - if (port > 0xD0) printf("ReadIO %02X <= %02X\n", port, retVal); + if (port > 0xD0) + printf("ReadIO %02X <= %02X\n", port, retVal); break; } @@ -475,11 +479,11 @@ exit: //////////////////////////////////////////////////////////////////////////////// void cpu_writeport(DWORD port,BYTE value) { - unsigned short F0dbg = 0; - int w1,w2; + //unsigned short F0dbg = 0; + int w1; //,w2; int unknown_io_port=0; - if (port >= 0xBA) && (port <= 0xBE) + if ((port >= 0xBA) && (port <= 0xBE)) { printf("Writing IEEP %02X <= %02X\n", port, value); } @@ -696,6 +700,8 @@ void cpu_writeport(DWORD port,BYTE value) case 0xF1: printf("%d\n", (signed short)((value << 8) | ws_ioRam[0xF0])); break; case 0xF2: printf("%c", value); fflush(stdout); break; + case 0xB7: break; /* Somwthing to write there, but what? */ + default: unknown_io_port=1; } diff --git a/oswan/source/memory.cpp b/oswan/source/memory.cpp index 2be5f32..8755cb0 100644 --- a/oswan/source/memory.cpp +++ b/oswan/source/memory.cpp @@ -74,9 +74,9 @@ void dump_memory() fp = fopen("memorydump.bin", "wb"); fwrite(internalRam, 1, 0x10000, fp); /* page 1 */ - fwrite(&(ws_staticRam[sramAddressMask]), 1, 0x10000, fp); + fwrite(&(ws_staticRam[0 & sramAddressMask]), 1, 0x10000, fp); fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR+2]&((romSize>>16)-1))<<16)]), 1, 0x10000, fp); - fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR+3]&((romSize>>16)-1))<<16)]), 1, 0x10000, fp); + fwrite(&(ws_rom[((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR+3]&((romSize>>16)-1))<<16)]), 1, 0x10000, fp); for(i = 4; i < 0x10; i++) { int romBank=(256-(((ws_ioRam[IO_ROM_BANK_BASE_SELECTOR]&0xf)<<4)|(i&0xf))); @@ -274,7 +274,7 @@ uint16 memory_getRomCrc(void) void ws_sram_load(char *path) { FILE *f; - size_t read; + //size_t read; f = fopen(path, "r"); if (NULL == f) @@ -283,7 +283,7 @@ void ws_sram_load(char *path) return; } - read = fread(ws_staticRam, 1, 0x8000, f); + /*read = */fread(ws_staticRam, 1, 0x8000, f); //fprintf(log_get(), "read 0x%x (of 0x%x?) bytes of save ram from %s\n", read, ws_rom_sramSize(ws_rom, romSize), path); fclose(f); } @@ -291,7 +291,7 @@ void ws_sram_load(char *path) void ws_sram_save(char *path) { FILE *f; - size_t wrote; + //size_t wrote; f = fopen(path, "wb"); if (NULL == f) @@ -300,7 +300,7 @@ void ws_sram_save(char *path) return; } - wrote = fwrite(ws_staticRam, 1, 0x8000, f); + /*wrote = */fwrite(ws_staticRam, 1, 0x8000, f); fflush(f); //fprintf(log_get(), "wrote 0x%x bytes of save ram to %s\n", wrote, path); fclose(f); diff --git a/oswan/source/nec/nec.cpp b/oswan/source/nec/nec.cpp index 8d8babe..a56787e 100644 --- a/oswan/source/nec/nec.cpp +++ b/oswan/source/nec/nec.cpp @@ -132,11 +132,11 @@ void nec_int(DWORD wektor) } } -static void nec_interrupt(unsigned int_num, /*BOOLEAN*/ int md_flag) +static void nec_interrupt(uint32_t int_num, /*BOOLEAN*/ int md_flag) { UINT32 dest_seg, dest_off; - if (int_num == -1) + if (int_num == UINT32_MAX) return; i_pushf(); @@ -303,7 +303,7 @@ OP( 0x5e, i_pop_si ) { POP(I.regs.w[IX]); CLK(1); } OP( 0x5f, i_pop_di ) { POP(I.regs.w[IY]); CLK(1); } OP( 0x60, i_pusha ) { - unsigned tmp=I.regs.w[SP]; + uint32_t tmp=I.regs.w[SP]; PUSH(I.regs.w[AW]); PUSH(I.regs.w[CW]); PUSH(I.regs.w[DW]); @@ -315,7 +315,7 @@ OP( 0x60, i_pusha ) { CLK(9); } OP( 0x61, i_popa ) { - unsigned tmp; + uint32_t tmp; POP(I.regs.w[IY]); POP(I.regs.w[IX]); POP(I.regs.w[BP]); @@ -324,6 +324,7 @@ OP( 0x61, i_popa ) { POP(I.regs.w[DW]); POP(I.regs.w[CW]); POP(I.regs.w[AW]); + (void)tmp; // We need to uppop something and need tmp CLK(8); } OP( 0x62, i_chkind ) { @@ -560,7 +561,7 @@ OP( 0xbf, i_mov_did16 ) { I.regs.b[IYL] = FETCH; I.regs.b[IYH] = FETCH; CLK(1); OP( 0xc0, i_rotshft_bd8 ) { UINT32 src, dst; UINT8 c; - GetModRM; src = (unsigned)GetRMByte(ModRM); dst=src; + GetModRM; src = (uint32_t)GetRMByte(ModRM); dst=src; c=FETCH; c&=0x1f; CLKM(5,3); @@ -578,7 +579,7 @@ OP( 0xc0, i_rotshft_bd8 ) { OP( 0xc1, i_rotshft_wd8 ) { UINT32 src, dst; UINT8 c; - GetModRM; src = (unsigned)GetRMWord(ModRM); dst=src; + GetModRM; src = (uint32_t)GetRMWord(ModRM); dst=src; c=FETCH; c&=0x1f; CLKM(5,3); @@ -693,11 +694,11 @@ OP( 0xd3, i_rotshft_wcl ) { } } -OP( 0xd4, i_aam ) { UINT32 mult=FETCH; mult=0; I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLK(17); } -OP( 0xd5, i_aad ) { UINT32 mult=FETCH; mult=0; I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLK(6); } +OP( 0xd4, i_aam ) { /*UINT32 mult=FETCH; mult=0;*/ I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLK(17); } +OP( 0xd5, i_aad ) { /*UINT32 mult=FETCH; mult=0;*/ I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLK(6); } OP( 0xd6, i_setalc ) { I.regs.b[AL] = (CF)?0xff:0x00; CLK(3); } /* nop at V30MZ? */ OP( 0xd7, i_trans ) { UINT32 dest = (I.regs.w[BW]+I.regs.b[AL])&0xffff; I.regs.b[AL] = GetMemB(DS, dest); CLK(5); } -OP( 0xd8, i_fpo ) { GetModRM; CLK(3); } /* nop at V30MZ? */ +OP( 0xd8, i_fpo ) { /*GetModRM;*/ CLK(3); } /* nop at V30MZ? */ OP( 0xe0, i_loopne ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if (!ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); CLK(6); } else CLK(3); } OP( 0xe1, i_loope ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if ( ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); CLK(6); } else CLK(3); } @@ -852,7 +853,7 @@ static void i_invalid(void) /*****************************************************************************/ -unsigned nec_get_reg(int regnum) +uint32_t nec_get_reg(int regnum) { switch( regnum ) { @@ -880,7 +881,7 @@ unsigned nec_get_reg(int regnum) void nec_set_irq_line(int irqline, int state); -void nec_set_reg(int regnum, unsigned val) +void nec_set_reg(int regnum, uint32_t val) { switch( regnum ) { diff --git a/oswan/source/nec/nec.h b/oswan/source/nec/nec.h index f81e6f4..5ab8ef6 100644 --- a/oswan/source/nec/nec.h +++ b/oswan/source/nec/nec.h @@ -23,7 +23,7 @@ typedef struct UINT16 ip; INT32 SignVal; - UINT32 AuxVal, OverVal, ZeroVal, CarryVal, ParityVal; /* 0 or non-0 valued flags */ + INT32 AuxVal, OverVal, ZeroVal, CarryVal, ParityVal; /* 0 or non-0 valued flags */ UINT8 TF, IF, DF, MF; /* 0 or 1 valued flags */ /* OB[19.07.99] added Mode Flag V30 */ UINT32 int_vector; UINT32 pending_irq; @@ -172,8 +172,8 @@ typedef struct #define IncWordReg(Reg) \ - unsigned tmp = (unsigned)I.regs.w[Reg]; \ - unsigned tmp1 = tmp+1; \ + uint16_t tmp = (uint16_t)I.regs.w[Reg]; \ + uint16_t tmp1 = tmp+1; \ I.OverVal = (tmp == 0x7fff); \ SetAF(tmp1,tmp,1); \ SetSZPF_Word(tmp1); \ @@ -182,8 +182,8 @@ typedef struct #define DecWordReg(Reg) \ - unsigned tmp = (unsigned)I.regs.w[Reg]; \ - unsigned tmp1 = tmp-1; \ + uint16_t tmp = (uint16_t)I.regs.w[Reg]; \ + uint16_t tmp1 = tmp-1; \ I.OverVal = (tmp == 0x8000); \ SetAF(tmp1,tmp,1); \ SetSZPF_Word(tmp1); \ @@ -317,8 +317,8 @@ typedef struct #define ADD4S { \ int i,v1,v2,result; \ int count = (I.regs.b[CL]+1)/2; \ - unsigned di = I.regs.w[IY]; \ - unsigned si = I.regs.w[IX]; \ + uint16_t di = I.regs.w[IY]; \ + uint16_t si = I.regs.w[IX]; \ I.ZeroVal = I.CarryVal = 0; \ for (i=0;idwHandle = (DWORD) lpWave->lpData; + lpWave->dwHandle = (uintptr_t) lpWave->lpData; return AUDIO_ERROR_NONE; } return AUDIO_ERROR_INVALHANDLE; diff --git a/seal-hack/src/modeng.c b/seal-hack/src/modeng.c index 918d009..4b82b67 100644 --- a/seal-hack/src/modeng.c +++ b/seal-hack/src/modeng.c @@ -14,6 +14,7 @@ #ifdef __GNUC__ #include #endif +#include #include #include #include "audio.h" diff --git a/seal-hack/src/modfile.c b/seal-hack/src/modfile.c index 08dce4d..2960102 100644 --- a/seal-hack/src/modfile.c +++ b/seal-hack/src/modfile.c @@ -217,8 +217,7 @@ UINT AIAPI ALoadModuleMOD(LPSTR lpszFileName, } /* initialize the module structure */ - strncpy(lpModule->szModuleName, Header.aModuleName, - sizeof(Header.aModuleName)); + strncpy(lpModule->szModuleName, Header.aModuleName, sizeof(lpModule->szModuleName)); lpModule->wFlags = AUDIO_MODULE_AMIGA | AUDIO_MODULE_PANNING; lpModule->nOrders = Header.nSongLength; lpModule->nRestart = Header.nRestart; @@ -262,8 +261,7 @@ UINT AIAPI ALoadModuleMOD(LPSTR lpszFileName, lpPatch = lpModule->aPatchTable; for (n = 0; n < lpModule->nPatches; n++, lpPatch++) { memcpy(&Sample, &Header.aSampleTable[n], sizeof(MODSAMPLEHEADER)); - strncpy(lpPatch->szPatchName, Sample.aSampleName, - sizeof(Sample.aSampleName)); + strncpy(lpPatch->szPatchName, Sample.aSampleName, sizeof(lpPatch->szPatchName)); if (Sample.wLength != 0) { if ((lpSample = (LPAUDIOSAMPLE) calloc(1, sizeof(AUDIOSAMPLE))) == NULL) { diff --git a/seal-hack/src/mp b/seal-hack/src/mp deleted file mode 100755 index 7a9f68f..0000000 Binary files a/seal-hack/src/mp and /dev/null differ diff --git a/seal-hack/src/mp.c b/seal-hack/src/mp.c index 8c5f11d..ec26d6a 100644 --- a/seal-hack/src/mp.c +++ b/seal-hack/src/mp.c @@ -36,7 +36,7 @@ struct { void Assert(UINT nErrorCode) { - static CHAR szText[80]; + static char szText[80]; if (nErrorCode != AUDIO_ERROR_NONE) { AGetErrorText(nErrorCode, szText, sizeof(szText) - 1); @@ -194,7 +194,8 @@ int main(int argc, char *argv[]) State.nVolume = 96; /* parse command line options */ - for (n = 1; n < argc && (lpszOption = argv[n])[0] == '-'; n++) { + for (n = 1; n < argc && argv[n][0] == '-'; n++) { + lpszOption = argv[n]; lpszOptArg = &lpszOption[2]; if (strchr("crv", lpszOption[1]) && !lpszOptArg[0] && n < argc - 1) lpszOptArg = argv[++n]; diff --git a/seal-hack/src/mtmfile.c b/seal-hack/src/mtmfile.c index f0054f4..fcff0e7 100644 --- a/seal-hack/src/mtmfile.c +++ b/seal-hack/src/mtmfile.c @@ -126,8 +126,7 @@ static UINT MTMMakeSample(LPAUDIOPATCH lpPatch, LPMTMSAMPLE lpMTMSample) DWORD dwCount; UINT rc; - strncpy(lpPatch->szPatchName, lpMTMSample->szSampleName, - sizeof(lpMTMSample->szSampleName)); + strncpy(lpPatch->szPatchName, lpMTMSample->szSampleName, sizeof(lpPatch->szPatchName) - 1); if (lpMTMSample->dwLength) { if ((lpSample = (LPAUDIOSAMPLE) calloc(1, sizeof(AUDIOSAMPLE))) == NULL) return AUDIO_ERROR_NOMEMORY; @@ -203,8 +202,7 @@ UINT AIAPI ALoadModuleMTM(LPSTR lpszFileName, } /* build the local module header structure */ - strncpy(lpModule->szModuleName, Header.szModuleName, - sizeof(Header.szModuleName)); + strncpy(lpModule->szModuleName, Header.szModuleName, sizeof(lpModule->szModuleName)); lpModule->wFlags = AUDIO_MODULE_AMIGA | AUDIO_MODULE_PANNING; lpModule->nOrders = Header.nOrders + 1; lpModule->nRestart = AUDIO_MAX_ORDERS; diff --git a/seal-hack/src/s3mfile.c b/seal-hack/src/s3mfile.c index 36cda9b..07cd22c 100644 --- a/seal-hack/src/s3mfile.c +++ b/seal-hack/src/s3mfile.c @@ -585,7 +585,7 @@ UINT AIAPI ALoadModuleS3M(LPSTR lpszFileName, AIOReadFile(Header.aReserved, sizeof(Header.aReserved)); AIOReadShort(&Header.wSpecial); AIOReadFile(Header.aChannelTable, sizeof(Header.aChannelTable)); - printf("[%lX] vs [%lX]\n", Header.dwSCRM, S3M_SCRM_MAGIC); + printf("[%X] vs [%lX]\n", Header.dwSCRM, S3M_SCRM_MAGIC); if (Header.dwSCRM != S3M_SCRM_MAGIC || Header.nSongLength > S3M_MAX_ORDERS || Header.nPatterns > S3M_MAX_PATTERNS || diff --git a/seal-hack/src/sdldrv.c b/seal-hack/src/sdldrv.c index e1887f6..d0772f5 100644 --- a/seal-hack/src/sdldrv.c +++ b/seal-hack/src/sdldrv.c @@ -74,8 +74,9 @@ static void updatecallback(void *userdata, Uint8 *stream, int len); static UINT AIAPI OpenAudio(LPAUDIOINFO lpInfo) { - int nBitsPerSample, nStereoOn, nSampleRate, nFrags; - + //int nBitsPerSample, nStereoOn, nSampleRate, nFrags; + int nStereoOn; + memset(&Audio, 0, sizeof(Audio)); if (!SDL_WasInit(SDL_INIT_EVERYTHING)) @@ -90,7 +91,7 @@ static UINT AIAPI OpenAudio(LPAUDIOINFO lpInfo) return AUDIO_ERROR_NODEVICE; - nBitsPerSample = lpInfo->wFormat & AUDIO_FORMAT_16BITS ? 16 : 8; + //nBitsPerSample = lpInfo->wFormat & AUDIO_FORMAT_16BITS ? 16 : 8; nStereoOn = lpInfo->wFormat & AUDIO_FORMAT_STEREO ? 1 : 0; /*nSampleRate = lpInfo->nSampleRate;*/ diff --git a/seal-hack/src/xmfile.c b/seal-hack/src/xmfile.c index b25a0ee..5f624aa 100644 --- a/seal-hack/src/xmfile.c +++ b/seal-hack/src/xmfile.c @@ -184,8 +184,7 @@ UINT AIAPI ALoadModuleXM(LPSTR lpszFileName, } /* initialize module structure */ - strncpy(lpModule->szModuleName, Header.aModuleName, - sizeof(Header.aModuleName)); + strncpy(lpModule->szModuleName, Header.aModuleName, sizeof(lpModule->szModuleName)); if (Header.wFlags & XM_MODULE_LINEAR) lpModule->wFlags |= AUDIO_MODULE_LINEAR; lpModule->nOrders = Header.nSongLength; @@ -296,8 +295,7 @@ UINT AIAPI ALoadModuleXM(LPSTR lpszFileName, } /* initialize patch structure */ - strncpy(lpPatch->szPatchName, Patch.aPatchName, - sizeof(Patch.aPatchName)); + strncpy(lpPatch->szPatchName, Patch.aPatchName, sizeof(lpPatch->szPatchName)); for (m = 0; m < AUDIO_MAX_NOTES; m++) { lpPatch->aSampleNumber[m] = Patch.aSampleNumber[m]; if (lpPatch->aSampleNumber[m] >= Patch.nSamples) @@ -365,8 +363,7 @@ UINT AIAPI ALoadModuleXM(LPSTR lpszFileName, AIOReadFile(Sample.aSampleName, sizeof(Sample.aSampleName)); AIOSeekFile(Patch.dwSampleHeaderSize - XM_SAMPLE_HEADER_SIZE, SEEK_CUR); - strncpy(lpSample->szSampleName, Sample.aSampleName, - sizeof(Sample.aSampleName)); + strncpy(lpSample->szSampleName, Sample.aSampleName, sizeof(lpSample->szSampleName)); lpSample->Wave.dwLength = Sample.dwLength; lpSample->Wave.dwLoopStart = Sample.dwLoopStart; lpSample->Wave.dwLoopEnd = Sample.dwLoopStart + Sample.dwLoopLength;