-Virtual Jaguar v1.0.0 GCC/SDL release INSTALL
+Virtual Jaguar v1.0.3 GCC/SDL release INSTALL
---------------------------------------------
- Requirements :
If you sure you have the minimum software requirements, you can safely
compile Virtual Jaguar v1.0.0 GCC/SDL release by doing the following :
-1) On UN*X systems first do the command : sh ./fix-unix.sh
-2) Go to the src/star026c directory and start on of the scripts :
-
- ./build_s68000.win32 (for WIN32 systems with mingw)
- ./build_s68000.unix (for UN*X systems with gcc)
-
-3) After the generation of the 68000.o file, you can now compile the
- program with the following commands :
+1) Compile:
make -f Makefile.win32 (for WIN32 systems with mingw)
make -f Makefile.unix (for UN*X systems with gcc)
-4) Optionally you can manually strip jag_em[.exe] to downsize the binary.
+2) Optionally you can manually strip jag_em[.exe] to downsize the binary.
+If you don't have upx in your path somewhere, you can ignore the error
+message that make throws at you about not being able to find upx.
That's it! You're done! You can now start the emulator with ./jag_em[.exe].
See the output for more details or consult the docs/README for more info.
following e-mail address : sdlemu AT ngemu DOT com.
SDLEMU
-
-
NASM = nasm
CFLAGS = -Wall -O3 -D__PORT__ -D__GCCWIN32__ -Dstricmp="strcasecmp" \
- -fomit-frame-pointer `sdl-config --cflags`
-# -fomit-frame-pointer `sdl-config --cflags` -DCPU_DEBUG
+ -fomit-frame-pointer `sdl-config --cflags` -DLOG_UNMAPPED_MEMORY_ACCESSES
+# -fomit-frame-pointer `sdl-config --cflags`
# -fomit-frame-pointer `sdl-config --cflags` -DTOM_DEBUG
LDFLAGS = $(CFLAGS)
+Virtual Jaguar v1.0.3 GCC/SDL - source only release
+------------------------------------------------------
+
+* Converted GNU assembly in the GPU core to C code -- Rayman and
+ Alien vs Predator work again. :-)
+* Removed closed source Starscream and replaced it with the open source
+ Musashi core. Because of this, VJ runs a little faster now. :-)
+* Various cleanups to the source files (still lots of work to do!)
+
+NOTE: Tested only on WIN32 platform!
+
+1.0.1 - 1.0.2 - Unreleased, mostly for testing/finding bugs
+
Virtual Jaguar v1.0.0 GCC/SDL - initial source release
------------------------------------------------------
-////////////////////////////////////////////////////////////////////////////////
//
-////////////////////////////////////////////////////////////////////////////////
+// Virtual Jaguar Emulator
//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
//
-//
-//
-//
-//
-//
-////////////////////////////////////////////////////////////////////////////////
+
#ifndef __PORT__
#include "stdafx.h"
#include <mmsystem.h>
int main(int argc, char * argv[])
{
-
- uint32 startTime, totalFrames, endTime, w, h;
- int32 *vs;
- unsigned int nNormalLast = 0;
- int nNormalFrac = 0;
- int i = 0;
- int nTime = 0;
- int nCount = 0;
- int nFrameskip = 1; /* Frameskip */
- int nFrame = 0; /* No. of Frame */
- int nJoyport = 0; /* Joystick port */
+ uint32 startTime, totalFrames;//, endTime;//, w, h;
+// int32 * vs;
+ uint32 nNormalLast = 0;
+ int32 nNormalFrac = 0;
+// int32 i = 0;
+//unused int32 nTime = 0;
+//unused int32 nCount = 0;
+ int32 nFrameskip = 1; // Frameskip
+ int32 nFrame = 0; // No. of Frame
+ int32 nJoyport = 0; // Joystick port
printf("Virtual Jaguar/SDL v1.0.1 (GCC/SDL Port)\n");
printf("Based upon Virtual Jaguar core v1.0.0 by Potato emulation.\n");
printf("Written by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)\n");
printf("Portions massaged by James L. Hammons (WIN32)\n");
- printf("Contact : http://sdlemu.ngemu.com/ | sdlemu@ngemu.com\n");
+ printf("Contact: http://sdlemu.ngemu.com/ | sdlemu@ngemu.com\n");
if (argc <= 1)
{
printf("Usage : \n\n");
- printf("jag_em <romfile> [switches] ]\n");
+ printf("jag_em <romfile> [switches]\n");
printf(" -fullscreen : Enable fullscreen mode \n");
printf(" -window : Enable windowed mode (default) \n");
printf(" -frameskip 1-10 : Enable frameskip 1 (default) - 10\n");
return true;
}
- jaguar_boot_dir=(char*)malloc(1024);
- getcwd(jaguar_boot_dir,1024);
+ jaguar_boot_dir = (char *)malloc(1024);
+ getcwd(jaguar_boot_dir, 1024);
log_init("jag_em.log");
jaguar_init(argv[1]);
jaguar_reset();
- /* Setting up the backbuffer */
- int16 *backbuffer=(int16*)malloc(845*525*sizeof(int16));
- memset(backbuffer,0xaa,tom_getVideoModeWidth()*tom_getVideoModeHeight()*sizeof(int16));
+ /* Setting up the backbuffer */
+ int16 * backbuffer = (int16 *)malloc(845 * 525 * sizeof(int16));
+ memset(backbuffer, 0xAA, tom_getVideoModeWidth() * tom_getVideoModeHeight() * sizeof(int16));
/* Setting up the primary SDL display */
- Format format(16,0x007c00,0x00003e0,0x0000001f);
- surface=new Surface(tom_getVideoModeWidth(),tom_getVideoModeHeight(), format);
+//Already defined! Format format(16, 0x007C00, 0x00003E0, 0x0000001F);
+ surface = new Surface(tom_getVideoModeWidth(), tom_getVideoModeHeight(), format);
console.option("windowed output");
- /* Checking the switches ;) */
- for(i = 0; (i < argc || argv[i] != NULL); i++)
+ /* Checking the switches ;) */
+ for(int i=0; (i<argc || argv[i]!=NULL); i++)
{
- if(!strcmp(argv[i], "-fullscreen"))
- console.option("fullscreen output");
+ if (!strcmp(argv[i], "-fullscreen"))
+ console.option("fullscreen output");
- if(!strcmp(argv[i], "-window"))
- console.option("windowed output");
+ if (!strcmp(argv[i], "-window"))
+ console.option("windowed output");
- if(!strcmp(argv[i], "-joystick"))
- console.option("joystick enabled");
+ if (!strcmp(argv[i], "-joystick"))
+ console.option("joystick enabled");
- if(!strcmp(argv[i], "-joyport"))
- {
- nJoyport = atoi(argv[++i]) + 1;
- if(nJoyport > 3) nJoyport = 3;
- }
+ if (!strcmp(argv[i], "-joyport"))
+ {
+ nJoyport = atoi(argv[++i]) + 1;
+ if (nJoyport > 3)
+ nJoyport = 3;
+ }
- if(!strcmp(argv[i], "-frameskip"))
- {
- nFrameskip = atoi(argv[++i]) + 1;
- if(nFrameskip > 10) nFrameskip = 10;
+ if (!strcmp(argv[i], "-frameskip"))
+ {
+ nFrameskip = atoi(argv[++i]) + 1;
+ if (nFrameskip > 10)
+ nFrameskip = 10;
#ifdef SPEED_CONTROL
nFrameskip = 0;
#endif
}
-
-
-
}
-
/* Initialize Joystick support under SDL */
- if ( console.JoyEnabled() == 1 ) {
-
- if(SDL_NumJoysticks() <= 0)
+ if (console.JoyEnabled() == 1)
{
- console.option("joystick disabled");
- printf("No joystick(s) or joypad(s) detected on your system. Using keyboards....\n");
- }
- else {
- if((console.joystick = SDL_JoystickOpen(nJoyport)) == 0)
- {
- console.option("joystick disabled");
- printf("Unable to open a Joystick on port : %d\n", nJoyport);
- }
- else
- printf("Using: %s\n", SDL_JoystickName(nJoyport));
- }
+ if (SDL_NumJoysticks() <= 0)
+ {
+ console.option("joystick disabled");
+ printf("No joystick(s) or joypad(s) detected on your system. Using keyboards....\n");
+ }
+ else
+ {
+ if ((console.joystick = SDL_JoystickOpen(nJoyport)) == 0)
+ {
+ console.option("joystick disabled");
+ printf("Unable to open a Joystick on port : %d\n", (int)nJoyport);
+ }
+ else
+ printf("Using: %s\n", SDL_JoystickName(nJoyport));
+ }
}
/* Open the display and start emulating some l337 Atari Jaguar games :P */
- console.open("Virtual Jaguar",tom_getVideoModeWidth(),tom_getVideoModeHeight(),format);
-
+ console.open("Virtual Jaguar", tom_getVideoModeWidth(), tom_getVideoModeHeight(), format);
- 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 = SDL_GetTicks(); //timeGetTime();
- nNormalLast=SDL_GetTicks();//timeGetTime();
while (!finished)
{
#ifdef SPEED_CONTROL
- nTime=SDL_GetTicks()-nNormalLast; // calcule le temps écoulé depuis le dernier affichage
- // nTime est en mili-secondes.
+ nTime = SDL_GetTicks() - nNormalLast; // calcule le temps écoulé depuis le dernier affichage
+ // nTime est en mili-secondes.
// détermine le nombre de trames à passer + 1
- nCount=(nTime*600 - nNormalFrac) /10000;
+ nCount = (nTime * 600 - nNormalFrac) / 10000;
// si le nombre de trames à passer + 1 est nul ou négatif,
// ne rien faire pendant 2 ms
- if (nCount<=0)
+ if (nCount <= 0)
{
//Sleep(2);
//SDL_Delay(1);
} // No need to do anything for a bit
else
{
- nNormalFrac+=nCount*10000; //
- nNormalLast+=nNormalFrac/600; // add the duration of nNormalFrac frames
- nNormalFrac%=600; //
+ nNormalFrac += nCount * 10000; //
+ nNormalLast += nNormalFrac / 600; // add the duration of nNormalFrac frames
+ nNormalFrac %= 600; //
// Pas plus de 9 (10-1) trames non affichées
- if (nCount>10)
- nCount=10;
- for (i=0;i<nCount-1;i++)
- jaguar_exec(backbuffer,0);
+ if (nCount > 10)
+ nCount = 10;
+ for(int i=0; i<nCount-1; i++)
+ jaguar_exec(backbuffer, 0);
#endif
/* Setting up new backbuffer with new pixels and data */
- jaguar_exec(backbuffer,1);
+ jaguar_exec(backbuffer, 1);
totalFrames++;
/* Simple frameskip */
- if ( nFrame == nFrameskip ) {
- w=tom_width;
- h=tom_height;
- vs = (int32 *)surface->lock();
- memcpy(vs,backbuffer,w*h*2);
- surface->unlock();
- surface->copy(console);
- console.update();
- nFrame = 0;
+ if (nFrame == nFrameskip)
+ {
+ int32 * vs = (int32 *)surface->lock();
+ memcpy(vs, backbuffer, tom_width * tom_height * 2);
+ surface->unlock();
+ surface->copy(console);
+ console.update();
+ nFrame = 0;
}
- else
- nFrame++;
+ else
+ nFrame++;
+
joystick_exec();
#ifdef SPEED_CONTROL
}
#endif
}
- int elapsedTime=clock()-startTime;
- int fps=(1000*totalFrames)/elapsedTime;
- printf("statistics: %i fps\n",fps);
+
+ int elapsedTime = clock() - startTime;
+ int fps = (1000 * totalFrames) / elapsedTime;
+ fprintf(log_get(), "Statistics: %i fps\n", fps);
- if ( console.JoyEnabled() == 1 ) {}
+ if (console.JoyEnabled() == 1) {}
jaguar_done();
version_done();
memory_done();
log_done();
- console.close(); // Close SDL items as last!
+ console.close(); // Close SDL items as last!
return 0;
}
+//
+// Analog joystick handler
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+
#include "jaguar.h"
static uint8 anajoy_ram[2];
static uint8 analog_x, analog_y;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void anajoy_init(void)
{
anajoy_reset();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void anajoy_reset(void)
{
memset(anajoy_ram,0x00,2);
analog_x=128;
analog_y=128;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void anajoy_done(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void anajoy_byte_write(uint32 offset, uint8 data)
{
anajoy_ram[offset&0x01]=data;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void anajoy_word_write(uint32 offset, uint16 data)
{
offset&=0x01;
anajoy_ram[offset+0]=(data>>8)&0xff;
anajoy_ram[offset+1]=data&0xff;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint8 anajoy_byte_read(uint32 offset)
{
if (anajoy_ram[1]&0x01)
else
return(analog_x);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint16 anajoy_word_read(uint32 offset)
{
uint16 data=anajoy_byte_read((offset+0)&0x01);
+//
+// Blitter core
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+
#define GEN_CODE
//#define LOG_BLITS
//#define USE_GENERIC_BLITTER
void blitter_blit(uint32 cmd)
{
colour_index = 0;
- src=(cmd&0x07);
- dst=(cmd>>3)&0x07;
- misc=(cmd>>6)&0x03;
- a1ctl=(cmd>>8)&0x7;
- mode=(cmd>>11)&0x07;
- ity=(cmd>>14)&0x0f;
- zop=(cmd>>18)&0x07;
- op=(cmd>>21)&0x0f;
- ctrl=(cmd>>25)&0x3f;
-
- a1_addr=REG(A1_BASE);
- a2_addr=REG(A2_BASE);
+ src = cmd & 0x07;
+ dst = (cmd >> 3) & 0x07;
+ misc = (cmd >> 6) & 0x03;
+ a1ctl = (cmd >> 8) & 0x7;
+ mode = (cmd >> 11) & 0x07;
+ ity = (cmd >> 14) & 0x0F;
+ zop = (cmd >> 18) & 0x07;
+ op = (cmd >> 21) & 0x0F;
+ ctrl = (cmd >> 25) & 0x3F;
+
+ a1_addr = REG(A1_BASE);
+ a2_addr = REG(A2_BASE);
a1_zoffs = (REG(A1_FLAGS) >> 6) & 7;
a2_zoffs = (REG(A2_FLAGS) >> 6) & 7;
- xadd_a1_control=(REG(A1_FLAGS)>>16)&0x03;
- xadd_a2_control=(REG(A2_FLAGS)>>16)&0x03;
+ xadd_a1_control = (REG(A1_FLAGS) >> 16) & 0x03;
+ xadd_a2_control = (REG(A2_FLAGS) >> 16) & 0x03;
a1_pitch = (REG(A1_FLAGS) & 3) ^ ((REG(A1_FLAGS) & 2) >> 1);
a2_pitch = (REG(A2_FLAGS) & 3) ^ ((REG(A2_FLAGS) & 2) >> 1);
- n_pixels=(REG(PIXLINECOUNTER)&0xffff);
- n_lines=((REG(PIXLINECOUNTER)>>16)&0xffff);
+ n_pixels = REG(PIXLINECOUNTER) & 0xFFFF;
+ n_lines = (REG(PIXLINECOUNTER) >> 16) & 0xFFFF;
- a1_x=(REG(A1_PIXEL)<<16)|(REG(A1_FPIXEL)&0xffff);
- a1_y=(REG(A1_PIXEL)&0xffff0000)|(REG(A1_FPIXEL)>>16);
- a1_width=blitter_scanline_width[((REG(A1_FLAGS)&0x00007E00)>>9)];
+ a1_x = (REG(A1_PIXEL) << 16) | (REG(A1_FPIXEL) & 0xFFFF);
+ a1_y = (REG(A1_PIXEL) & 0xFFFF0000) | (REG(A1_FPIXEL) >> 16);
+ a1_width = blitter_scanline_width[((REG(A1_FLAGS) & 0x00007E00) >> 9)];
- a2_x=(REG(A2_PIXEL)&0x0000ffff)<<16;
- a2_y=(REG(A2_PIXEL)&0xffff0000);
- a2_width=blitter_scanline_width[((REG(A2_FLAGS)&0x00007E00)>>9)];
- a2_mask_x=0xffff|((REG(A2_MASK)&0x0000ffff)<<16);
- a2_mask_y=((REG(A2_MASK)&0xffff0000)|0xffff);
+ a2_x = (REG(A2_PIXEL) & 0x0000FFFF) << 16;
+ a2_y = (REG(A2_PIXEL) & 0xFFFF0000);
+ a2_width = blitter_scanline_width[((REG(A2_FLAGS) & 0x00007E00) >> 9)];
+ a2_mask_x = 0xFFFF | ((REG(A2_MASK) & 0x0000FFFF) << 16);
+ a2_mask_y = ((REG(A2_MASK) & 0xFFFF0000) | 0xFFFF);
//
- if (!((REG(A2_FLAGS))&0x8000))
+ if (!(REG(A2_FLAGS) & 0x8000))
{
- a2_mask_x=0xffffffff; // must be 16.16
- a2_mask_y=0xffffffff; // must be 16.16
+ a2_mask_x = 0xFFFFFFFF; // must be 16.16
+ a2_mask_y = 0xFFFFFFFF; // must be 16.16
}
- a1_phrase_mode=0;
+ a1_phrase_mode = 0;
// determine a1_yadd
if (YADD1_A1)
a1_yadd = 0;
if (YSIGNSUB_A1)
- a1_yadd=-a1_yadd;
+ a1_yadd = -a1_yadd;
// determine a1_xadd
switch (xadd_a1_control)
{
case XADDPHR:
- // add phrase offset to X and truncate
- a1_xadd = 1 << 16;
-
- a1_phrase_mode=1;
- break;
+ // add phrase offset to X and truncate
+ a1_xadd = 1 << 16;
+ a1_phrase_mode = 1;
+ break;
case XADDPIX:
- // add pixelsize (1) to X
- a1_xadd = 1 << 16;
- break;
+ // add pixelsize (1) to X
+ a1_xadd = 1 << 16;
+ break;
case XADD0:
- // add zero (for those nice vertical lines)
- a1_xadd = 0;
- break;
+ // add zero (for those nice vertical lines)
+ a1_xadd = 0;
+ break;
case XADDINC:
- // add the contents of the increment register
- a1_xadd = (REG(A1_INC) << 16) | (REG(A1_FINC) & 0xffff);
- a1_yadd = (REG(A1_INC) & 0xffff0000) | (REG(A1_FINC) >> 16);
- break;
+ // add the contents of the increment register
+ a1_xadd = (REG(A1_INC) << 16) | (REG(A1_FINC) & 0xFFFF);
+ a1_yadd = (REG(A1_INC) & 0xFFFF0000) | (REG(A1_FINC) >> 16);
+ break;
}
if (XSIGNSUB_A1)
- a1_xadd=-a1_xadd;
+ a1_xadd = -a1_xadd;
// determine a2_yadd
- if ((YADD1_A2)||(YADD1_A1))
+ if (YADD1_A2 || YADD1_A1)
a2_yadd = 1 << 16;
else
a2_yadd = 0;
if (YSIGNSUB_A2)
- a2_yadd=-a2_yadd;
+ a2_yadd = -a2_yadd;
- a2_phrase_mode=0;
+ a2_phrase_mode = 0;
// determine a2_xadd
switch (xadd_a2_control)
{
case XADDPHR:
- // add phrase offset to X and truncate
- a2_xadd = 1 << 16;
-
- a2_phrase_mode=1;
- break;
+ // add phrase offset to X and truncate
+ a2_xadd = 1 << 16;
+ a2_phrase_mode = 1;
+ break;
case XADDPIX:
- // add pixelsize (1) to X
- a2_xadd = 1 << 16;
- break;
+ // add pixelsize (1) to X
+ a2_xadd = 1 << 16;
+ break;
case XADD0:
- // add zero (for those nice vertical lines)
- a2_xadd = 0;
- break;
+ // add zero (for those nice vertical lines)
+ a2_xadd = 0;
+ break;
case XADDINC:
- // add the contents of the increment register
- // since there is no register for a2 we just add 1
- a2_xadd = 1 << 16;
- break;
+ // add the contents of the increment register
+ // since there is no register for a2 we just add 1
+ a2_xadd = 1 << 16;
+ break;
}
if (XSIGNSUB_A2)
- a2_xadd=-a2_xadd;
+ a2_xadd = -a2_xadd;
// modify outer loop steps based on command
- a1_step_x=0;
- a1_step_y=0;
- a2_step_x=0;
- a2_step_y=0;
+ a1_step_x = 0;
+ a1_step_y = 0;
+ a2_step_x = 0;
+ a2_step_y = 0;
if (cmd & 0x00000100)
{
a2_step_y = (REG(A2_STEP)&0xffff0000);
}
+ outer_loop = n_lines;
- outer_loop=n_lines;
-
-
- a2_psize=1 << ((REG(A2_FLAGS) >> 3) & 7);
- a1_psize=1 << ((REG(A1_FLAGS) >> 3) & 7);
+ a2_psize = 1 << ((REG(A2_FLAGS) >> 3) & 7);
+ a1_psize = 1 << ((REG(A1_FLAGS) >> 3) & 7);
// zbuffering
if (GOURZ)
{
- zadd=jaguar_long_read(0xF02274);
+ zadd = jaguar_long_read(0xF02274);
- for(int v=0;v<4;v++)
- z_i[v]=(int32)jaguar_long_read(0xF0228C+(v<<2));
+ for(int v=0; v<4; v++)
+ z_i[v] = (int32)jaguar_long_read(0xF0228C + (v << 2));
}
- if ((GOURD)||(GOURZ)||(SRCSHADE))
+ if (GOURD || GOURZ || SRCSHADE)
{
// gouraud shading
gouraud_add = jaguar_long_read(0xF02270);
-
gd_c[0] = jaguar_byte_read(0xF02268);
gd_i[0] = jaguar_byte_read(0xF02269);
- gd_i[0]<<=16;
- gd_i[0]|=jaguar_word_read(0xF02240);
+ gd_i[0] <<= 16;
+ gd_i[0] |= jaguar_word_read(0xF02240);
gd_c[1] = jaguar_byte_read(0xF0226A);
- gd_i[1] = jaguar_byte_read(0xF0226b);
- gd_i[1]<<=16;
- gd_i[1]|=jaguar_word_read(0xF02242);
+ gd_i[1] = jaguar_byte_read(0xF0226B);
+ gd_i[1] <<= 16;
+ gd_i[1] |= jaguar_word_read(0xF02242);
gd_c[2] = jaguar_byte_read(0xF0226C);
- gd_i[2] = jaguar_byte_read(0xF0226d);
- gd_i[2]<<=16;
- gd_i[2]|=jaguar_word_read(0xF02244);
+ gd_i[2] = jaguar_byte_read(0xF0226D);
+ gd_i[2] <<= 16;
+ gd_i[2] |= jaguar_word_read(0xF02244);
gd_c[3] = jaguar_byte_read(0xF0226E);
- gd_i[3] = jaguar_byte_read(0xF0226f);
- gd_i[3]<<=16;
- gd_i[3]|=jaguar_word_read(0xF02246);
+ gd_i[3] = jaguar_byte_read(0xF0226F);
+ gd_i[3] <<= 16;
+ gd_i[3] |= jaguar_word_read(0xF02246);
gd_ia = gouraud_add & 0xFFFFFF;
- if(gd_ia & 0x800000)
+ if (gd_ia & 0x800000)
gd_ia = 0xFF000000 | gd_ia;
gd_ca = (gouraud_add>>24) & 0xFF;
- if(gd_ca & 0x80)
+ if (gd_ca & 0x80)
gd_ca = 0xFFFFFF00 | gd_ca;
}
}
#endif
-
- blitter_working=1;
+ blitter_working = 1;
#ifndef USE_GENERIC_BLITTER
if (!blitter_execute_cached_code(blitter_in_cache(cmd)))
#endif
blitter_generic(cmd);
- blitter_working=0;
+ blitter_working = 0;
}
uint32 blitter_reg_read(uint32 offset)
{
for (int i=0;i<256;i++)
{
- blitter_cache[i]=(struct s_blitter_cache *)malloc(sizeof(struct s_blitter_cache));
+ blitter_cache[i] = (struct s_blitter_cache *)malloc(sizeof(struct s_blitter_cache));
blitter_cache[i]->next=null;
blitter_cache[i]->prev=null;
}
- blitter_cache_init=1;
+ blitter_cache_init = 1;
}
#ifndef USE_GENERIC_BLITTER
#include "include/blit_i.h"
blitter_reset();
#ifdef GEN_CODE
- blitters_code_fp=fopen("include/blit_c.h","awrt");
- blitters_code_init_fp=fopen("include/blit_i.h","awrt");
+ blitters_code_fp = fopen("include/blit_c.h","awrt");
+ blitters_code_init_fp = fopen("include/blit_i.h","awrt");
#endif
}
void blitter_done(void)
{
- blitter_list();
+// blitter_list();
#ifdef GEN_CODE
fclose(blitters_code_fp);
fclose(blitters_code_init_fp);
#endif
+ fprintf(log_get(), "BLIT: Done.\n");
}
void blitter_byte_write(uint32 offset, uint8 data)
case 0x89: blitter_ram[0x6F] = data; break;
case 0x9A: blitter_ram[0x46] = data; break;
case 0x9B: blitter_ram[0x47] = data; break;
-
}
}
-//////////////////////////////////////////////////////////////////////////////
//
-//////////////////////////////////////////////////////////////////////////////
+// CD BIOS core
//
-// 20.02.2002: fixed sector to msf conversion
-// 19.02.2002: fixed a bug in toc encoding function
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
//
+// cal2:
+// 02/20/2002: fixed sector to msf conversion
+// 02/19/2002: fixed a bug in toc encoding function
//
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "include/cdbios.h"
+
+#include "cdbios.h"
/* Added by SDLEMU (http://sdlemu.ngemu.com */
/* Some GCC UNIX includes */
#ifdef __GCCUNIX__
- #include <unistd.h>
+#include <unistd.h>
#endif
#define ERR_FLAG 0x3e00
#define CD_TOC 0x2c00
#define BIOS_VER 0x3004
-
#define CDBIOS_INIT 0
#define CDBIOS_INITM 1
#define CDBIOS_INITF 2
-
-
#define CD_INIT 0x3000
#define CD_MODE 0x3006
#define CD_ACK 0x300C
#define CD_INITM 0x3060
#define CD_INITF 0x3066
-
-char *cdbios_command[]={"init","mode","ack","jeri","spin","stop","mute","umute","pause","upause",
- "read","uread","setup","ptr","osamp","getoc","initm","initf",
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+char * cdbios_command[] =
+ { "init", "mode", "ack", "jeri", "spin", "stop", "mute", "umute", "pause", "upause",
+ "read", "uread", "setup", "ptr", "osamp", "getoc", "initm", "initf",
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#define CDROM_AUDIO_MODE 0
#define CDROM_DATA_MODE 1
#define CDROM_STATUS_OK 0
#define CDROM_STATUS_ERROR 1
-
uint32 cdrom_mode = CDROM_DATA_MODE;
uint32 cdrom_speed = CDROM_SINGLE_SPEED;
uint32 cdrom_oversample_factor = 1;
-uint32 cdbios_session=0;
+uint32 cdbios_session = 0;
uint32 cdrom_destination_buffer_beginning;
uint32 cdrom_destination_buffer_end;
uint32 cdrom_circular_buffer_size;
uint32 cdbios_init_type;
-uint32 *cdbios_sector_lut;
-uint32 cdbios_init_done=0;
+uint32 * cdbios_sector_lut;
+uint32 cdbios_init_done = 0;
+
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
void cdbios_build_sector_lut(void)
{
uint32 last_sector=0;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_get_time(uint32 sectors, uint32 *mm, uint32 *ss, uint32 *ff)
{
uint32 _sectors=sectors;
// fprintf(log_get(),"[%.2i:%.2i:%.2i]\n",_mm,_ss,_ff);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_encode_toc(void)
{
int i;
}
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_decode_toc(void)
{
uint32 addr=0x2c00;
nb_tracks--;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cd_bios_boot(char *filename)
{
cd_bios_init();
// fprintf(log_get(),"cdbios: boot code:\n");
// jaguar_dasm(cdi_load_address, cdi_code_length);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cd_bios_init(void)
{
fprintf(log_get(),"cd_bios: initializing\n");
cd_bios_reset();
cdbios_init_done=1;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cd_bios_reset(void)
{
fprintf(log_get(), "cd_bios: reset\n");
cdrom_oversample_factor = 1;
cdbios_session = 0;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cd_bios_done(void)
{
- fprintf(log_get(),"cd_bios: done\n");
close(cdi_fp);
+ fprintf(log_get(), "CD BIOS: Done.\n");
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_init(void)
{
cdbios_init_type = CDBIOS_INIT;
jaguar_word_write(ERR_FLAG, CDROM_STATUS_OK);
fprintf(log_get(), "cdbios: init(0x%.8x)\n", m68k_get_reg(NULL, M68K_REG_A0));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_mode(void)
{
// uint32 data = s68000context.dreg[0];
// fprintf(log_get(),"cdbios: %s\n",(cdrom_mode==CDROM_AUDIO_MODE)?"audio mode":"data mode");
// fprintf(log_get(),"cdbios: %s\n",(cdrom_speed==CDROM_DOUBLE_SPEED)?"double speed":"single speed");
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_ack(void)
{
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_jeri(void)
{
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_spin(void)
{
// uint16 spin=(1<<(s68000context.dreg[0]&0xffff));
jaguar_word_write(ERR_FLAG, CDROM_STATUS_OK);
// fprintf(log_get(),"cdbios: switching to session %i\n",spin);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_stop(void)
{
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_mute(void)
{
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_umute(void)
{
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_pause(void)
{
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_upause(void)
{
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
count--;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_read(void)
{
static uint8 cdbios_sector[2352];
}
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_uread(void)
{
// stop the recording started with a cd_read command
// for now, there is nothing to do
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_setup(void)
{
// initialize the cd system
jaguar_word_write(ERR_FLAG, CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_ptr(void)
{
// s68000context.areg[0]=cdrom_destination_buffer_end+4;
m68k_set_reg(M68K_REG_A0, cdrom_destination_buffer_end + 4);
jaguar_word_write(ERR_FLAG, CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_osamp(void)
{
// cdrom_oversample_factor=(1<<(s68000context.dreg[0]&0xffff));
cdrom_oversample_factor = 1 << (m68k_get_reg(NULL, M68K_REG_D0) & 0xFFFF);
jaguar_word_write(ERR_FLAG, CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_gettoc(void)
{
jaguar_word_write(ERR_FLAG,CDROM_STATUS_OK);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_initm(void)
{
cdbios_init_type = CDBIOS_INITM;
// fprintf(log_get(),"cdbios: initm(0x%.8x)\n",s68000context.areg[0]);
fprintf(log_get(), "cdbios: initm(0x%.8x)\n", m68k_get_reg(NULL, M68K_REG_A0));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdbios_cmd_initf(void)
{
cdbios_init_type = CDBIOS_INITF;
// fprintf(log_get(),"cdbios: initf(0x%.8x)\n",s68000context.areg[0]);
fprintf(log_get(), "cdbios: initf(0x%.8x)\n", m68k_get_reg(NULL, M68K_REG_A0));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cd_bios_process(uint32 offset)
{
if (!cdbios_init_done)
m68k_set_reg(M68K_REG_PC, jaguar_long_read(m68k_get_reg(NULL, M68K_REG_A7)));
m68k_set_reg(M68K_REG_A7, (m68k_get_reg(NULL, M68K_REG_A7) + 4) & 0xFFFFFFFF);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cd_bios_exec(uint32 scanline)
{
// single speed mode: 150 Kb/s (153600 bytes/s)
+//
+// CD Interface handler
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+
#include "cdi.h"
/* Added by SDLEMU (http://sdlemu.ngemu.com) */
/* Added for GCC UNIX compatibility */
#ifdef __GCCUNIX__
- #include <unistd.h>
- #include <sys/types.h>
- #include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
- #define O_BINARY (0)
+#define O_BINARY (0)
#endif
#define CDI_V2 0x80000004
#define CDI_V3 0x80000005
#define CDI_V35 0x80000006
-static uint8 cdi_track_start_mark[10] = { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
-
-
+static uint8 cdi_track_start_mark[10] =
+ { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
int cdi_fp;
uint32 cdi_load_address;
uint32 cdi_code_length;
-s_cdi_descriptor *cdi_descriptor;
-s_cdi_track **cdi_tracks;
-uint32 cdi_tracks_count;
+s_cdi_descriptor * cdi_descriptor;
+s_cdi_track ** cdi_tracks;
+uint32 cdi_tracks_count;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-int cdi_open(char *path)
+int cdi_open(char * path)
{
- fprintf(log_get(),"cdi: opening %s\n",path);
- return(open(path,O_BINARY|O_RDONLY));
+ fprintf(log_get(), "CDI: Opening %s\n", path);
+ return open(path, O_BINARY | O_RDONLY);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdi_close(int fp)
{
- fprintf(log_get(),"cdi: closing\n");
+ fprintf(log_get(), "CDI: Closing\n");
close(fp);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
#ifdef __PORT__
long tell(int fd)
{
return lseek(fd, 0LL, SEEK_CUR);
}
#endif
+
s_cdi_descriptor *cdi_get_descriptor(int fp, FILE *stdfp)
{
s_cdi_descriptor *descriptor;
return(descriptor);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdi_dump_descriptor(FILE *fp,s_cdi_descriptor *cdi_descriptor)
{
fprintf(fp,"cdi: %i Mb\n",cdi_descriptor->length>>20);
}
fprintf(fp,"cdi: %i sessions\n",cdi_descriptor->nb_of_sessions);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-uint8 *cdi_extract_boot_code(int fp, s_cdi_descriptor *cdi_descriptor)
+
+uint8 * cdi_extract_boot_code(int fp, s_cdi_descriptor * cdi_descriptor)
{
- s_cdi_track *boot_track=&cdi_descriptor->sessions[1].tracks[0];
- uint32 boot_track_size=boot_track->length*boot_track->sector_size;
+ s_cdi_track * boot_track = &cdi_descriptor->sessions[1].tracks[0];
+ uint32 boot_track_size = boot_track->length * boot_track->sector_size;
- uint8 *boot_track_data=(uint8*)malloc(boot_track_size);
- lseek(fp,2+(boot_track->position), SEEK_SET);
- read(fp,boot_track_data,boot_track_size);
+ uint8 * boot_track_data = (uint8 *)malloc(boot_track_size);
+ lseek(fp, 2 + (boot_track->position), SEEK_SET);
+ read(fp, boot_track_data, boot_track_size);
- uint32 *boot_track_data_32=(uint32*)boot_track_data;
- uint32 offset=0;
- while (offset<(boot_track_size>>2))
+ uint32 * boot_track_data_32 = (uint32 *)boot_track_data;
+ uint32 offset = 0;
+ while (offset < (boot_track_size >> 2))
{
- if (boot_track_data_32[offset]==0x49205452)
+ if (boot_track_data_32[offset] == 0x49205452)
break;
offset++;
}
- if (offset==(boot_track_size>>2))
+ if (offset == (boot_track_size >> 2))
{
- fprintf(log_get(),"cdi: cannot find the boot code\n");
- return(NULL);
+ fprintf(log_get(), "CDI: Cannot find the boot code\n");
+ return NULL;
}
- offset=(offset<<2)+4;
- uint16 *data16=(uint16*)&boot_track_data[offset];
- cdi_load_address=*data16++; cdi_load_address<<=16; cdi_load_address|=*data16++;
- cdi_code_length=*data16++; cdi_code_length<<=16; cdi_code_length|=*data16++;
- fprintf(log_get(),"cdi: load address: 0x%.8x\n",cdi_load_address);
- fprintf(log_get(),"cdi: length: 0x%.8x\n",cdi_code_length);
- fprintf(log_get(),"cdi: byte swapping boot code\n");
-
- for (uint32 i=0;i<(cdi_code_length>>1);i++)
+
+ offset = (offset << 2) + 4;
+ uint16 * data16 = (uint16 *)&boot_track_data[offset];
+ cdi_load_address = *data16++;
+ cdi_load_address <<= 16;
+ cdi_load_address |= *data16++;
+ cdi_code_length = *data16++;
+ cdi_code_length <<= 16;
+ cdi_code_length |= *data16++;
+ fprintf(log_get(), "CDI: Load address: %08X\n", cdi_load_address);
+ fprintf(log_get(), "CDI: Length: %08X\n", cdi_code_length);
+//No need for byte swapping any more...
+/* fprintf(log_get(), "cdi: byte swapping boot code\n");
+
+ for(uint32 i=0; i<(cdi_code_length >> 1); i++)
{
- uint16 sdata=data16[i];
- sdata=(sdata>>8)|(sdata<<8);
- data16[i]=sdata;
- }
- return((uint8*)data16);
+ uint16 sdata = data16[i];
+ sdata = (sdata >> 8) | (sdata << 8);
+ data16[i] = sdata;
+ }*/
+
+ return (uint8 *)data16;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void cdi_load_sector(uint32 sector, uint8 *buffer)
+
+void cdi_load_sector(uint32 sector, uint8 * buffer)
{
- if (sector==0xffffffff)
+ if (sector == 0xFFFFFFFF)
{
- memset(buffer,0x00,2352);
+ memset(buffer, 0x00, 2352);
return;
}
- sector*=2352;
+ sector *= 2352;
- lseek(cdi_fp,2+sector,SEEK_SET);
- read(cdi_fp,buffer,2352);
+ lseek(cdi_fp, 2+sector, SEEK_SET);
+ read(cdi_fp, buffer, 2352);
- // byte swap
+//This is probably not needed any more...
+/* // byte swap
for (uint32 i=0;i<2352;i+=2)
{
uint8 sdata=buffer[i+0];
buffer[i+0]=buffer[i+1];
buffer[i+1]=sdata;
- }
-
+ }*/
}
-#include "include/cdrom.h"
+//
+// CD handler
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+
+#include "cdrom.h"
//#define CDROM_LOG
-static uint8 cdrom_ram[0x100];
-static uint16 cdrom_cmd=0;
+static uint8 cdrom_ram[0x100];
+static uint16 cdrom_cmd = 0;
+
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
void cdrom_init(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdrom_reset(void)
{
- memset(cdrom_ram,0x00,0x100);
- cdrom_cmd=0;
-
+ memset(cdrom_ram, 0x00, 0x100);
+ cdrom_cmd = 0;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdrom_done(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdrom_byte_write(uint32 offset, uint8 data)
{
- offset&=0xff;
- cdrom_ram[offset]=data;
+ offset &= 0xFF;
+ cdrom_ram[offset] = data;
#ifdef CDROM_LOG
fprintf(log_get(),"cdrom: writing byte 0x%.2x at 0x%.8x\n",data,offset);
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void cdrom_word_write(uint32 offset, uint16 data)
{
- offset&=0xff;
- cdrom_ram[offset+0]=(data>>8)&0xff;
- cdrom_ram[offset+1]=data&0xff;
+ offset &= 0xFF;
+ cdrom_ram[offset+0] = (data >> 8) & 0xFF;
+ cdrom_ram[offset+1] = data & 0xFF;
// command register
/*
fprintf(log_get(),"cdrom: writing word 0x%.4x at 0x%.8x\n",data,offset);
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint8 cdrom_byte_read(uint32 offset)
{
- offset&=0xff;
#ifdef CDROM_LOG
fprintf(log_get(),"cdrom: reading byte from 0x%.8x\n",offset);
#endif
- return(cdrom_ram[offset]);
+ return cdrom_ram[offset & 0xFF];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint16 cdrom_word_read(uint32 offset)
{
- offset&=0xff;
+ offset &= 0xFF;
- uint16 data=0x0000;
+ uint16 data = 0x0000;
- if (offset==0x00)
- data=0x0000;
- else
- if (offset==0x02)
- data=0x2000;
- else
- if (offset==0x0a)
+ if (offset == 0x00)
+ data = 0x0000;
+ else if (offset == 0x02)
+ data = 0x2000;
+ else if (offset == 0x0A)
{
- if (cdrom_cmd==0x7001)
- data=cdrom_cmd;
+ if (cdrom_cmd == 0x7001)
+ data = cdrom_cmd;
else
- data=0x0400;
+ data = 0x0400;
}
else
- {
- data=cdrom_ram[offset+0];
- data<<=8;
- data|=cdrom_ram[offset+1];
- }
+ data = (cdrom_ram[offset+0] << 8) | cdrom_ram[offset+1];
+
#ifdef CDROM_LOG
fprintf(log_get(),"cdrom: reading word 0x%.4x from 0x%.8x [68k pc=0x%.8x]\n",data,offset,s68000readPC());
#endif
- return(data);
+ return data;
}
-#include "include/jaguar.h"
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
//
+// Clock handler
//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
//
-//////////////////////////////////////////////////////////////////////////////
+
+#include "jaguar.h"
+
+
void clock_init(void)
{
clock_reset();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void clock_reset(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void clock_done(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void clock_byte_write(uint32 offset, uint8 data)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void clock_word_write(uint32 offset, uint16 data)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint8 clock_byte_read(uint32 offset)
{
- return(0xff);
+ return 0xFF;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint16 clock_word_read(uint32 offset)
{
- return(0xffff);
+ return 0xFFFF;
}
-//////////////////////////////////////////////////////////////////////////////
//
-//////////////////////////////////////////////////////////////////////////////
+// CRC support
//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
//
-//
-//////////////////////////////////////////////////////////////////////////////
+
#include <stdio.h>
#include <stdlib.h>
-#include "include/crc32.h"
+#include "crc32.h"
unsigned long crctable[256] =
{
0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
};
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-static unsigned long update_crc(unsigned char *p, unsigned long crc, int reclen)
-{
- int i;
- for (i = 0; i < reclen; i++)
+static unsigned long update_crc(unsigned char * p, unsigned long crc, int reclen)
+{
+ for(int i=0; i<reclen; i++)
crc = crctable[(crc ^ *p++) & 0xFFL] ^ (crc >> 8);
- return (crc);
+ return crc;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-int crc32_calcCheckSum(unsigned char *data, unsigned int length)
+int crc32_calcCheckSum(unsigned char * data, unsigned int length)
{
- int sum;
+/* int sum;
int Xor;
unsigned int i;
- int j;
-
+ int j;*/
- return(update_crc(data, 0xFFFFFFFFL, length)^0xFFFFFFFFL);
- sum = 0;
- Xor = 0;
+ return update_crc(data, 0xFFFFFFFFL, length) ^ 0xFFFFFFFFL;
+/* sum = 0;
+ Xor = 0;
for (i = 0;i < length;i+=2)
{
Xor ^= j;
}
sum = ((sum & 0xffff) << 16) | (Xor & 0xffff);
- return sum;
+ return sum;*/
}
-////////////////////////////////////////////////////////////////////////////////
-// Audio
-////////////////////////////////////////////////////////////////////////////////
+//
+// Audio handler
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+// We really need to convert this to SDL... DirectSound won't cut it here!
+//
-#include "include/jaguar.h"
-#include "include/dsnd.h"
+#include "jaguar.h"
+#include "dsnd.h"
int ym2413_enable;
-int FREQUENCE=44100;
+int FREQUENCE = 44100;
void dsound_reset(void);
int chipBufferLength; //Number of bytes to hold SOUND_BUFFER seconds.
-int lastChipWrite =0;
-int chipWrite =UNDEFINED; //Write Cursor
+int lastChipWrite = 0;
+int chipWrite = UNDEFINED; //Write Cursor
-INT16* buf1;
+INT16 * buf1;
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
void ws_write_state(int fp)
{
}
-
void ws_read_state(int fp)
{
}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
void ws_audio_init(void)
{
#ifdef _EMULATE_SOUND
// ws_audio_reset();
#endif
}
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
+
void ws_audio_reset(void)
{
#ifdef _EMULATE_SOUND
#endif
}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
void ws_audio_done(void)
{
#ifdef _EMULATE_SOUND
#endif
}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
void ws_audio_clear_channel(int Channel)
{
#ifdef _EMULATE_SOUND
#endif
}
-
-
-////////////////////////////////////////////////////////////////////////////////
+//
// start playing a channel
-////////////////////////////////////////////////////////////////////////////////
+//
+
int ws_audio_play_channel(int Channel)
{
#ifdef _EMULATE_SOUND
return 0;
}
-
-////////////////////////////////////////////////////////////////////////////////
+//
// stop playing a channel
-////////////////////////////////////////////////////////////////////////////////
+//
+
int ws_audio_stop_channel(int Channel)
{
#ifdef _EMULATE_SOUND
return(0);
}
-
-
void dsound_reset(void)
{
#ifdef _EMULATE_SOUND
#endif
}
-
-
void system_sound_shutdown(void)
{
#ifdef _EMULATE_SOUND
#endif
}
-
void system_sound_update(void)
{
#ifdef _EMULATE_SOUND
-//////////////////////////////////////////////////////////////////////////////
//
-//////////////////////////////////////////////////////////////////////////////
+// DSP core
//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "include/dsp.h"
+#include "dsp.h"
#define CINT0FLAG 0x00200
#define CINT1FLAG 0x00400
static uint16 *mirror_table;
static uint8 *dsp_ram_8;
-
static uint32 dsp_pc;
static uint32 dsp_acc;
static uint32 dsp_remain;
uint8 *dsp_branch_condition_table=0;
#define branch_condition(x) dsp_branch_condition_table[(x) + ((jaguar_flags & 7) << 5)]
-static uint32 dsp_in_exec=0;
-static uint32 dsp_releaseTimeSlice_flag=0;
+static uint32 dsp_in_exec = 0;
+static uint32 dsp_releaseTimeSlice_flag = 0;
+
+FILE * dsp_fp;
-FILE *dsp_fp;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
void dsp_reset_stats(void)
{
- for (uint32 i=0;i<64;i++)
- dsp_opcode_use[i]=0;
+ for (uint32 i=0; i<64; i++)
+ dsp_opcode_use[i] = 0;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
void dsp_releaseTimeslice(void)
{
- dsp_releaseTimeSlice_flag=1;
+ dsp_releaseTimeSlice_flag = 1;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
void dsp_build_branch_condition_table(void)
{
int i,j;
}
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
unsigned dsp_byte_read(unsigned int offset)
{
// battlemorph
}
return(jaguar_byte_read(offset));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
unsigned dsp_word_read(unsigned int offset)
{
offset&=0xFFFFFFFE;
}
return(jaguar_word_read(offset));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
unsigned dsp_long_read(unsigned int offset)
{
offset&=0xFFFFFFFC;
data|=jaguar_word_read(offset+2);
return(data);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_byte_write(unsigned offset, unsigned data)
{
if ((offset >= dsp_work_ram_base) && (offset < dsp_work_ram_base+0x2000))
// fprintf(log_get(),"dsp: writing %.2x at 0x%.8x\n",data,offset);
jaguar_byte_write(offset, data);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_word_write(unsigned offset, unsigned data)
{
offset &= 0xFFFFFFFE;
}
jaguar_word_write(offset, data);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_long_write(unsigned offset, unsigned data)
{
offset &= 0xFFFFFFFC;
jaguar_word_write(offset, (data>>16) & 0xFFFF);
jaguar_word_write(offset+2, data & 0xFFFF);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint8 * jaguar_rom_load(char * path, uint32 * romSize);
void dsp_load_bin_at(char * path, uint32 offset)
{
for(uint32 i=0; i<romSize; i++)
jaguar_byte_write(offset+i, rom[i]);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static int go = 0;
void dsp_update_register_banks(void)
{
}
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_check_if_i2s_interrupt_needed(void)
{
static uint32 count=8;
dsp_set_irq_line(1,1);
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_check_irqs(void)
{
int bits, mask, which = 0;
dsp_pc += which * 0x10;
dsp_reg[30]=dsp_pc;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_set_irq_line(int irqline, int state)
{
int mask = 0x40 << irqline;
dsp_check_irqs();
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_init(void)
{
- memory_malloc_secure((void**)&dsp_ram_8,0x2000,"dsp work ram");
- memory_malloc_secure((void**)&dsp_reg,32*sizeof(int32),"dsp bank 0 regs");
- memory_malloc_secure((void**)&dsp_alternate_reg,32*sizeof(int32),"dsp bank 1 regs");
+ memory_malloc_secure((void **)&dsp_ram_8, 0x2000, "dsp work ram");
+ memory_malloc_secure((void **)&dsp_reg, 32*sizeof(int32), "dsp bank 0 regs");
+ memory_malloc_secure((void **)&dsp_alternate_reg, 32*sizeof(int32), "dsp bank 1 regs");
dsp_build_branch_condition_table();
-
dsp_reset();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_reset(void)
{
dsp_pc = 0x00f1b000;
dsp_div_control = 0x00000000;
dsp_in_exec = 0;
- for (int i=0;i<32;i++)
+ for(int i=0; i<32; i++)
{
dsp_reg[i] = 0x00000000;
dsp_alternate_reg[i] = 0x00000000;
reset_flag_n();
reset_flag_c();
- dsp_alternate_flag_z=0;
- dsp_alternate_flag_n=0;
- dsp_alternate_flag_c=0;
+ dsp_alternate_flag_z = 0;
+ dsp_alternate_flag_n = 0;
+ dsp_alternate_flag_c = 0;
dsp_reset_stats();
-
- memset(dsp_ram_8, 0xff, 0x2000);
+ memset(dsp_ram_8, 0xFF, 0x2000);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void dsp_done(void)
{
int i, j;
memory_free(dsp_ram_8);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
void dsp_exec(int32 cycles)
{
if ((cycles!=1)&&(jaguar_mainRom_crc32==0xba74c3ed))
}
dsp_in_exec--;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_jump(void)
{
uint32 delayed_pc = Rm;
dsp_pc=delayed_pc;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_jr(void)
{
int32 offset=(imm_1&0x10) ? (0xFFFFFFF0|imm_1) : imm_1;
dsp_pc=delayed_pc;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_add(void)
{
uint32 _Rm=Rm;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_addc(void)
{
uint32 _Rm=Rm;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_addq(void)
{
uint32 _Rn=Rn;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_sub(void)
{
uint32 _Rm=Rm;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_subc(void)
{
uint32 _Rm=Rm;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_subq(void)
{
uint32 _Rm=dsp_convert_zero[imm_1];
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_cmp(void)
{
uint32 _Rm=Rm;
};
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_cmpq(void)
{
static int32 sqtable[32] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1};
};
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_and(void)
{
uint32 _Rm=Rm;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_or(void)
{
uint32 _Rm=Rm;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_xor(void)
{
uint32 _Rm=Rm;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_not(void)
{
uint32 _Rn=Rn;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_move_pc(void)
{
Rn = dsp_pc-2;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_sat8(void)
{
int32 _Rn=(int32)Rn;
set_flag_z(res);
reset_flag_n();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_sat16(void)
{
uint32 _Rn=Rn;
set_flag_z(res);
reset_flag_n();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_sat24(void)
{
uint32 _Rn=Rn;
set_flag_z(res);
reset_flag_n();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_store_r14_indexed(void)
{
dsp_long_write( dsp_reg[14] + (dsp_convert_zero[imm_1] << 2),Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_store_r15_indexed(void)
{
dsp_long_write( dsp_reg[15] + (dsp_convert_zero[imm_1] << 2),Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_load_r14_ri(void)
{
Rn=dsp_long_read(dsp_reg[14] + Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_load_r15_ri(void)
{
Rn=dsp_long_read(dsp_reg[15] + Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_store_r14_ri(void)
{
dsp_long_write(dsp_reg[14] + Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_store_r15_ri(void)
{
dsp_long_write(dsp_reg[15] + Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_nop(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_pack(void)
{
uint32 _Rn=Rn;
set_flag_z(Rn);
set_flag_n(Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_storeb(void)
{
if ((Rm >= dsp_work_ram_base) && (Rm < (dsp_work_ram_base+0x2000)))
else
jaguar_byte_write(Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_storew(void)
{
if ((Rm >= dsp_work_ram_base) && (Rm < (dsp_work_ram_base+0x2000)))
else
jaguar_word_write(Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_store(void)
{
dsp_long_write(Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_loadb(void)
{
if ((Rm >= dsp_work_ram_base) && (Rm < (dsp_work_ram_base+0x2000)))
else
Rn=jaguar_byte_read(Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_loadw(void)
{
if ((Rm >= dsp_work_ram_base) && (Rm < (dsp_work_ram_base+0x2000)))
else
Rn=jaguar_word_read(Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_load(void)
{
Rn = dsp_long_read(Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_load_r14_indexed(void)
{
Rn = dsp_long_read( dsp_reg[14] + (dsp_convert_zero[imm_1] << 2));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_load_r15_indexed(void)
{
Rn = dsp_long_read( dsp_reg[15] + (dsp_convert_zero[imm_1] << 2));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_movei(void)
{
Rn = ((uint32)dsp_word_read(dsp_pc)) + (((uint32)dsp_word_read(dsp_pc+2))<<16);
dsp_pc+=4;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_moveta(void)
{
alternate_Rn = Rm;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_movefa(void)
{
Rn = alternate_Rm;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_move(void)
{
Rn = Rm;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_moveq(void)
{
Rn = imm_1;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_resmac(void)
{
Rn = dsp_acc;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_imult(void)
{
uint32 res=Rn=((int16)Rn)*((int16)Rm);
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_mult(void)
{
uint32 res=Rn = ((uint16)Rm) * ((uint16)Rn);
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_bclr(void)
{
uint32 _Rm=imm_1;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_btst(void)
{
uint32 _Rm=imm_1;
};
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_bset(void)
{
uint32 _Rm=imm_1;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_subqt(void)
{
Rn -= dsp_convert_zero[imm_1];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_addqt(void)
{
Rn += dsp_convert_zero[imm_1];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_imacn(void)
{
uint32 res=((int16)Rm) * ((int16)(Rn));
dsp_acc += res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_mtoi(void)
{
uint32 _Rm=Rm;
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_normi(void)
{
uint32 _Rm = Rm;
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_mmult(void)
{
int count = dsp_matrix_control&0x0f;
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_abs(void)
{
uint32 _Rn=Rn;
set_flag_z(res);
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_div(void)
{
uint32 _Rm=Rm;
else
Rn=0xffffffff;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_imultn(void)
{
uint32 res=(int32)(((int16)Rn)*((int16)Rm));
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_neg(void)
{
uint32 _Rn=Rn;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_shlq(void)
{
uint32 shift=(32-dsp_convert_zero[imm_1]);
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_shrq(void)
{
uint32 shift=dsp_convert_zero[imm_1];
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_ror(void)
{
uint32 shift=Rm;
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_rorq(void)
{
uint32 shift=dsp_convert_zero[imm_1&0x1f];
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_sha(void)
{
int32 sRm=(int32)Rm;
set_flag_z(_Rn);
set_flag_n(_Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_sharq(void)
{
uint32 shift=dsp_convert_zero[imm_1];
set_flag_z(_Rn);
set_flag_n(_Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void dsp_opcode_sh(void)
{
int32 sRm=(int32)Rm;
+//
+// EEPROM handler
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+
#include "eeprom.h"
#define eeprom_LOG
FILE * jerry_ee_fp;
extern char * jaguar_boot_dir;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void eeprom_init(void)
{
- static char eeprom_filename[256];
- sprintf(eeprom_filename,"%s\\%s%.8x.eep",jaguar_boot_dir,jaguar_eeproms_path,jaguar_mainRom_crc32);
- jerry_ee_fp=fopen(eeprom_filename,"rb");
+ static char eeprom_filename[1024];
+
+ sprintf(eeprom_filename, "%s\\%s%08X.eep", jaguar_boot_dir, jaguar_eeproms_path, (unsigned int)jaguar_mainRom_crc32);
+ jerry_ee_fp = fopen(eeprom_filename, "rb");
if (jerry_ee_fp)
{
- fread(eeprom_ram,1,128,jerry_ee_fp);
+ fread(eeprom_ram, 1, 128, jerry_ee_fp);
fclose(jerry_ee_fp);
- fprintf(log_get(),"eeprom: loaded from %s\n",eeprom_filename);
- jerry_ee_fp=fopen(eeprom_filename,"wrb");
+ fprintf(log_get(), "eeprom: loaded from %s\n", eeprom_filename);
+ jerry_ee_fp = fopen(eeprom_filename, "wrb");
}
else
{
- fprintf(log_get(),"eeprom: creating %s\n",eeprom_filename);
- jerry_ee_fp=fopen(eeprom_filename,"wb");
- if (jerry_ee_fp==NULL)
- fprintf(log_get(),"eeprom: could not open/create %s\n",eeprom_filename);
+ fprintf(log_get(), "eeprom: creating %s\n", eeprom_filename);
+ jerry_ee_fp = fopen(eeprom_filename, "wb");
+ if (jerry_ee_fp == NULL)
+ fprintf(log_get(), "EEPROM: Could not open/create %s\n", eeprom_filename);
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void eeprom_reset(void)
{
- if (jerry_ee_fp==NULL)
- memset(eeprom_ram,0xff,64*2);
+ if (jerry_ee_fp == NULL)
+ memset(eeprom_ram, 0xFF, 64 * sizeof(uint16));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void eeprom_done(void)
{
if (jerry_ee_fp)
{
- fwrite(eeprom_ram,1,128,jerry_ee_fp);
+ fwrite(eeprom_ram, 1, 128, jerry_ee_fp);
fclose(jerry_ee_fp);
}
else
fprintf(log_get(),"eeprom: not saved\n");
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void eeprom_byte_write(uint32 offset, uint8 data)
{
switch (offset)
{
- case 0xf14001: break;
- case 0xf14801: eeprom_set_di(data&0x01); break;
- case 0xf15001: eeprom_set_cs(1); break;
+ case 0xF14001:
+ break;
+ case 0xF14801:
+ eeprom_set_di(data & 0x01);
+ break;
+ case 0xF15001:
+ eeprom_set_cs(1);
+ break;
// default: fprintf(log_get(),"eeprom: unmapped 0x%.8x\n",offset); break;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void eeprom_word_write(uint32 offset, uint16 data)
{
- eeprom_byte_write(offset+0,(data>>8)&0xff);
- eeprom_byte_write(offset+1,(data&0xff));
+ eeprom_byte_write(offset+0, (data >> 8) & 0xFF);
+ eeprom_byte_write(offset+1, data & 0xFF);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint8 eeprom_byte_read(uint32 offset)
{
switch (offset)
{
- case 0xf14001: return(eeprom_get_do()); break;
- case 0xf14801: break;
- case 0xf15001: eeprom_set_cs(1); break;
+ case 0xF14001:
+ return eeprom_get_do();
+ case 0xF14801:
+ break;
+ case 0xF15001:
+ eeprom_set_cs(1);
+ break;
// default: fprintf(log_get(),"eeprom: unmapped 0x%.8x\n",offset); break;
}
- return(0x00);
+
+ return 0x00;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint16 eeprom_word_read(uint32 offset)
{
- uint16 data=eeprom_byte_read(offset+0);
- data<<=8;
- data|=eeprom_byte_read(offset+1);
- return(data);
+ return ((uint16)eeprom_byte_read(offset+0) << 8) | eeprom_byte_read(offset+1);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void eeprom_set_di(uint32 data)
{
// fprintf(log_get(),"eeprom: di=%i\n",data);
// fprintf(log_get(),"eeprom: state %i\n",jerry_ee_state);
switch (jerry_ee_state)
{
- case EE_STATE_START: {
- jerry_ee_state=EE_STATE_OP_A;
- break;
- }
- case EE_STATE_OP_A: {
- jerry_ee_op=(data<<1);
- jerry_ee_state=EE_STATE_OP_B;
- break;
- }
- case EE_STATE_OP_B: {
- jerry_ee_op|=data;
- jerry_ee_direct_jump=0;
-// fprintf(log_get(),"eeprom: opcode %i\n",jerry_ee_op);
- switch (jerry_ee_op)
- {
- case 0: jerry_ee_state=EE_STATE_0; break;
- case 1: jerry_ee_state=EE_STATE_1; break;
- case 2: jerry_ee_state=EE_STATE_2; break;
- case 3: jerry_ee_state=EE_STATE_3; break;
- }
- eeprom_set_di(data);
- break;
- }
- case EE_STATE_0: {
- jerry_ee_rstate=EE_STATE_0_0;
- jerry_ee_state=EE_READ_ADDRESS;
- jerry_ee_direct_jump=1;
- jerry_ee_address_cnt=6;
- jerry_ee_address_data=0;
- break;
- }
- case EE_STATE_0_0: {
- switch ((jerry_ee_address_data>>4)&0x03)
- {
- case 0: jerry_ee_state=EE_STATE_0_0_0; break;
- case 1: jerry_ee_state=EE_STATE_0_0_1; break;
- case 2: jerry_ee_state=EE_STATE_0_0_2; break;
- case 3: jerry_ee_state=EE_STATE_0_0_3; break;
- }
- eeprom_set_di(data);
- break;
- }
- case EE_STATE_0_0_0:{
- // writes disable
- // fprintf(log_get(),"eeprom: read only\n");
- jerry_writes_enabled=0;
- jerry_ee_state=EE_STATE_START;
- break;
- }
- case EE_STATE_0_0_1:{
- // writes all
- jerry_ee_rstate=EE_STATE_0_0_1_0;
- jerry_ee_state=EE_READ_DATA;
- jerry_ee_data_cnt=16;
- jerry_ee_data=0;
- jerry_ee_direct_jump=1;
- break;
- }
- case EE_STATE_0_0_1_0:{
- // fprintf(log_get(),"eeprom: filling eeprom with 0x%.4x\n",data);
- if (jerry_writes_enabled)
- {
- for (int i=0;i<64;i++)
- eeprom_ram[i]=jerry_ee_data;
- }
- //else
- // fprintf(log_get(),"eeprom: not writing because read only\n");
- jerry_ee_state=EE_STATE_BUSY;
- break;
- }
- case EE_STATE_0_0_2:{
- // erase all
- //fprintf(log_get(),"eeprom: erasing eeprom\n");
- if (jerry_writes_enabled)
- {
- for (int i=0;i<64;i++)
- eeprom_ram[i]=0xffff;
- }
- jerry_ee_state=EE_STATE_BUSY;
- break;
- }
- case EE_STATE_0_0_3:{
- // writes enable
- //fprintf(log_get(),"eeprom: read/write\n");
- jerry_writes_enabled=1;
- jerry_ee_state=EE_STATE_START;
- break;
- }
- case EE_STATE_1: {
- jerry_ee_rstate=EE_STATE_1_0;
- jerry_ee_state=EE_READ_ADDRESS;
- jerry_ee_address_cnt=6;
- jerry_ee_address_data=0;
- jerry_ee_direct_jump=1;
- break;
- }
- case EE_STATE_1_0: {
- jerry_ee_rstate=EE_STATE_1_1;
- jerry_ee_state=EE_READ_DATA;
- jerry_ee_data_cnt=16;
- jerry_ee_data=0;
- jerry_ee_direct_jump=1;
- break;
- }
- case EE_STATE_1_1: {
- //fprintf(log_get(),"eeprom: writing 0x%.4x at 0x%.2x\n",jerry_ee_data,jerry_ee_address_data);
- if (jerry_writes_enabled)
- eeprom_ram[jerry_ee_address_data]=jerry_ee_data;
- jerry_ee_state=EE_STATE_BUSY;
- break;
- }
- case EE_STATE_2: {
- jerry_ee_rstate=EE_STATE_2_0;
- jerry_ee_state=EE_READ_ADDRESS;
- jerry_ee_address_cnt=6;
- jerry_ee_address_data=0;
- jerry_ee_data_cnt=16;
- jerry_ee_data=0;
- break;
- }
- case EE_STATE_3: {
- jerry_ee_rstate=EE_STATE_3_0;
- jerry_ee_state=EE_READ_ADDRESS;
- jerry_ee_address_cnt=6;
- jerry_ee_address_data=0;
- jerry_ee_direct_jump=1;
- break;
- }
- case EE_STATE_3_0: {
- //fprintf(log_get(),"eeprom: erasing 0x%.2x\n",jerry_ee_address_data);
- if (jerry_writes_enabled)
- eeprom_ram[jerry_ee_address_data]=0xffff;
- jerry_ee_state=EE_STATE_BUSY;
- break;
- }
+ case EE_STATE_START:
+ jerry_ee_state = EE_STATE_OP_A;
+ break;
+ case EE_STATE_OP_A:
+ jerry_ee_op = (data << 1);
+ jerry_ee_state = EE_STATE_OP_B;
+ break;
+ case EE_STATE_OP_B:
+ jerry_ee_op |= data;
+ jerry_ee_direct_jump = 0;
+// fprintf(log_get(),"eeprom: opcode %i\n",jerry_ee_op);
+ switch (jerry_ee_op)
+ {
+ case 0: jerry_ee_state = EE_STATE_0; break;
+ case 1: jerry_ee_state = EE_STATE_1; break;
+ case 2: jerry_ee_state = EE_STATE_2; break;
+ case 3: jerry_ee_state = EE_STATE_3; break;
+ }
+ eeprom_set_di(data);
+ break;
+ case EE_STATE_0:
+ jerry_ee_rstate = EE_STATE_0_0;
+ jerry_ee_state = EE_READ_ADDRESS;
+ jerry_ee_direct_jump = 1;
+ jerry_ee_address_cnt = 6;
+ jerry_ee_address_data = 0;
+ break;
+ case EE_STATE_0_0:
+ switch ((jerry_ee_address_data >> 4) & 0x03)
+ {
+ case 0: jerry_ee_state=EE_STATE_0_0_0; break;
+ case 1: jerry_ee_state=EE_STATE_0_0_1; break;
+ case 2: jerry_ee_state=EE_STATE_0_0_2; break;
+ case 3: jerry_ee_state=EE_STATE_0_0_3; break;
+ }
+ eeprom_set_di(data);
+ break;
+ case EE_STATE_0_0_0:
+ // writes disable
+ // fprintf(log_get(),"eeprom: read only\n");
+ jerry_writes_enabled = 0;
+ jerry_ee_state = EE_STATE_START;
+ break;
+ case EE_STATE_0_0_1:
+ // writes all
+ jerry_ee_rstate = EE_STATE_0_0_1_0;
+ jerry_ee_state = EE_READ_DATA;
+ jerry_ee_data_cnt = 16;
+ jerry_ee_data = 0;
+ jerry_ee_direct_jump = 1;
+ break;
+ case EE_STATE_0_0_1_0:
+ // fprintf(log_get(),"eeprom: filling eeprom with 0x%.4x\n",data);
+ if (jerry_writes_enabled)
+ for(int i=0; i<64; i++)
+ eeprom_ram[i] = jerry_ee_data;
+ //else
+ // fprintf(log_get(),"eeprom: not writing because read only\n");
+ jerry_ee_state = EE_STATE_BUSY;
+ break;
+ case EE_STATE_0_0_2:
+ // erase all
+ //fprintf(log_get(),"eeprom: erasing eeprom\n");
+ if (jerry_writes_enabled)
+ for(int i=0; i<64; i++)
+ eeprom_ram[i] = 0xFFFF;
+
+ jerry_ee_state=EE_STATE_BUSY;
+ break;
+ case EE_STATE_0_0_3:
+ // writes enable
+ //fprintf(log_get(),"eeprom: read/write\n");
+ jerry_writes_enabled = 1;
+ jerry_ee_state = EE_STATE_START;
+ break;
+ case EE_STATE_1:
+ jerry_ee_rstate = EE_STATE_1_0;
+ jerry_ee_state = EE_READ_ADDRESS;
+ jerry_ee_address_cnt = 6;
+ jerry_ee_address_data = 0;
+ jerry_ee_direct_jump = 1;
+ break;
+ case EE_STATE_1_0:
+ jerry_ee_rstate = EE_STATE_1_1;
+ jerry_ee_state = EE_READ_DATA;
+ jerry_ee_data_cnt = 16;
+ jerry_ee_data = 0;
+ jerry_ee_direct_jump = 1;
+ break;
+ case EE_STATE_1_1:
+ //fprintf(log_get(),"eeprom: writing 0x%.4x at 0x%.2x\n",jerry_ee_data,jerry_ee_address_data);
+ if (jerry_writes_enabled)
+ eeprom_ram[jerry_ee_address_data] = jerry_ee_data;
+ jerry_ee_state = EE_STATE_BUSY;
+ break;
+ case EE_STATE_2:
+ jerry_ee_rstate = EE_STATE_2_0;
+ jerry_ee_state = EE_READ_ADDRESS;
+ jerry_ee_address_cnt = 6;
+ jerry_ee_address_data = 0;
+ jerry_ee_data_cnt = 16;
+ jerry_ee_data = 0;
+ break;
+ case EE_STATE_3:
+ jerry_ee_rstate = EE_STATE_3_0;
+ jerry_ee_state = EE_READ_ADDRESS;
+ jerry_ee_address_cnt = 6;
+ jerry_ee_address_data = 0;
+ jerry_ee_direct_jump = 1;
+ break;
+ case EE_STATE_3_0:
+ //fprintf(log_get(),"eeprom: erasing 0x%.2x\n",jerry_ee_address_data);
+ if (jerry_writes_enabled)
+ eeprom_ram[jerry_ee_address_data] = 0xFFFF;
+ jerry_ee_state = EE_STATE_BUSY;
+ break;
case EE_READ_DATA:
- {
- //fprintf(log_get(),"eeprom:\t\t\t%i bit %i\n",data,jerry_ee_data_cnt-1);
- jerry_ee_data<<=1;
- jerry_ee_data|=data;
- jerry_ee_data_cnt--;
- if (!jerry_ee_data_cnt)
- {
- jerry_ee_state=jerry_ee_rstate;
- if (jerry_ee_direct_jump)
- eeprom_set_di(data);
- }
- break;
- }
+ //fprintf(log_get(),"eeprom:\t\t\t%i bit %i\n",data,jerry_ee_data_cnt-1);
+ jerry_ee_data <<= 1;
+ jerry_ee_data |= data;
+ jerry_ee_data_cnt--;
+ if (!jerry_ee_data_cnt)
+ {
+ jerry_ee_state = jerry_ee_rstate;
+ if (jerry_ee_direct_jump)
+ eeprom_set_di(data);
+ }
+ break;
case EE_READ_ADDRESS:
- {
- jerry_ee_address_data<<=1;
- jerry_ee_address_data|=data;
- jerry_ee_address_cnt--;
-// fprintf(log_get(),"eeprom:\t%i bits remaining\n",jerry_ee_address_cnt);
- if (!jerry_ee_address_cnt)
- {
- jerry_ee_state=jerry_ee_rstate;
- //fprintf(log_get(),"eeprom:\t\tread address 0x%.2x\n",jerry_ee_address_data);
- if (jerry_ee_direct_jump)
- eeprom_set_di(data);
- }
- break;
- }
- default: {
- jerry_ee_state=EE_STATE_OP_A;
- break;
- }
-
+ jerry_ee_address_data <<= 1;
+ jerry_ee_address_data |= data;
+ jerry_ee_address_cnt--;
+// fprintf(log_get(),"eeprom:\t%i bits remaining\n",jerry_ee_address_cnt);
+ if (!jerry_ee_address_cnt)
+ {
+ jerry_ee_state = jerry_ee_rstate;
+ //fprintf(log_get(),"eeprom:\t\tread address 0x%.2x\n",jerry_ee_address_data);
+ if (jerry_ee_direct_jump)
+ eeprom_set_di(data);
+ }
+ break;
+ default:
+ jerry_ee_state = EE_STATE_OP_A;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void eeprom_set_cs(uint32 state)
{
// fprintf(log_get(),"eeprom: cs=%i\n",state);
- jerry_ee_state=EE_STATE_START;
- jerry_ee_op=0;
- jerry_ee_rstate=0;
- jerry_ee_address_data=0;
- jerry_ee_address_cnt=6;
- jerry_ee_data=0;
- jerry_ee_data_cnt=16;
- jerry_writes_enabled=1;
+ jerry_ee_state = EE_STATE_START;
+ jerry_ee_op = 0;
+ jerry_ee_rstate = 0;
+ jerry_ee_address_data = 0;
+ jerry_ee_address_cnt = 6;
+ jerry_ee_data = 0;
+ jerry_ee_data_cnt = 16;
+ jerry_writes_enabled = 1;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint32 eeprom_get_do(void)
{
- uint16 data=1;
+ uint16 data = 1;
+
switch (jerry_ee_state)
{
- case EE_STATE_START: {
- data=1;
- break;
- }
- case EE_STATE_BUSY: {
- jerry_ee_state=EE_STATE_START;
- data=0;
- break;
- }
- case EE_STATE_2_0: {
- jerry_ee_data_cnt--;
- data=((eeprom_ram[jerry_ee_address_data]&(1<<jerry_ee_data_cnt))>>jerry_ee_data_cnt);
- if (!jerry_ee_data_cnt)
- {
- //fprintf(log_get(),"eeprom: read 0x%.4x at 0x%.2x cpu %i pc=0x%.8x\n",eeprom_ram[jerry_ee_address_data],jerry_ee_address_data,jaguar_cpu_in_exec,s68000readPC());
- jerry_ee_state=EE_STATE_START;
- }
- break;
- }
+ case EE_STATE_START:
+ data = 1;
+ break;
+ case EE_STATE_BUSY:
+ jerry_ee_state = EE_STATE_START;
+ data = 0;
+ break;
+ case EE_STATE_2_0:
+ jerry_ee_data_cnt--;
+ data = (eeprom_ram[jerry_ee_address_data] & (1 << jerry_ee_data_cnt)) >> jerry_ee_data_cnt;
+ if (!jerry_ee_data_cnt)
+ {
+ //fprintf(log_get(),"eeprom: read 0x%.4x at 0x%.2x cpu %i pc=0x%.8x\n",eeprom_ram[jerry_ee_address_data],jerry_ee_address_data,jaguar_cpu_in_exec,s68000readPC());
+ jerry_ee_state = EE_STATE_START;
+ }
+ break;
}
+
// fprintf(log_get(),"eeprom: do=%i\n",data);
- return(data);
+ return data;
}
-//////////////////////////////////////////////////////////////////////////////
//
-//////////////////////////////////////////////////////////////////////////////
+// GPU Core
//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups, endian wrongness, and bad ASM amelioration by James L. Hammons
+// Note: Endian wrongness probably stems from the MAME origins of this emu and
+// the braindead way in which MAME handles memory. :-)
//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "include/gpu.h"
+#include "gpu.h"
#define CINT0FLAG 0x00200
#define CINT1FLAG 0x00400
extern int start_logging;
-
static void gpu_opcode_add(void);
static void gpu_opcode_addc(void);
static void gpu_opcode_addq(void);
static uint32 gpu_opcode_first_parameter;
static uint32 gpu_opcode_second_parameter;
-#define gpu_running (gpu_control&0x01)
+#define GPU_RUNNING (gpu_control & 0x01)
#define Rm gpu_reg[gpu_opcode_first_parameter]
#define Rn gpu_reg[gpu_opcode_second_parameter]
#define imm_1 gpu_opcode_first_parameter
#define imm_2 gpu_opcode_second_parameter
-#define set_flag_z(r) gpu_flag_z=(r==0);
-#define set_flag_n(r) gpu_flag_n=((r&0x80000000)>>31);
+#define set_flag_z(r) gpu_flag_z = (r==0);
+#define set_flag_n(r) gpu_flag_n = ((r&0x80000000)>>31);
+
+#define reset_flag_z() gpu_flag_z = 0;
+#define reset_flag_n() gpu_flag_n = 0;
+#define reset_flag_c() gpu_flag_c = 0;
-#define reset_flag_z() gpu_flag_z=0;
-#define reset_flag_n() gpu_flag_n=0;
-#define reset_flag_c() gpu_flag_c=0;
+#define CLR_Z (gpu_flag_z = 0)
+#define CLR_ZN (gpu_flag_z = gpu_flag_n = 0)
+#define CLR_ZNC (gpu_flag_z = gpu_flag_n = gpu_flag_c = 0)
+#define SET_Z(r) (gpu_flag_z = ((r) == 0))
+#define SET_N(r) (gpu_flag_n = (((UINT32)(r) >> 31) & 0x01))
+#define SET_C_ADD(a,b) (gpu_flag_c = ((UINT32)(b) > (UINT32)(~(a))))
+#define SET_C_SUB(a,b) (gpu_flag_c = ((UINT32)(b) > (UINT32)(a)))
+#define SET_ZN(r) SET_N(r); SET_Z(r)
+#define SET_ZNC_ADD(a,b,r) SET_N(r); SET_Z(r); SET_C_ADD(a,b)
+#define SET_ZNC_SUB(a,b,r) SET_N(r); SET_Z(r); SET_C_SUB(a,b)
uint32 gpu_convert_zero[32] = { 32,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 };
static uint32 gpu_in_exec = 0;
static uint32 gpu_releaseTimeSlice_flag = 0;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_releaseTimeslice(void)
{
gpu_releaseTimeSlice_flag = 1;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint32 gpu_get_pc(void)
{
return gpu_pc;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void build_branch_condition_table(void)
{
#define ZFLAG 0x00001
if ((offset >= gpu_work_ram_base) && (offset < gpu_work_ram_base+0x1000))
{
offset &= 0xFFF;
- uint16 data = (((uint16)gpu_ram_8[offset]) << 8) | (uint16)gpu_ram_8[offset+1];
+ uint16 data = ((uint16)gpu_ram_8[offset] << 8) | (uint16)gpu_ram_8[offset+1];
return data;
}
else if ((offset >= gpu_control_ram_base) && (offset < gpu_control_ram_base+0x20))
break;
case 0x14:
{
- uint32 gpu_was_running = gpu_running;
+ uint32 gpu_was_running = GPU_RUNNING;
data &= (~0x7C0); // disable writes to irq pending
- /*if (gpu_running)
+ /*if (GPU_RUNNING)
{
fprintf(log_get(),"gpu pc is 0x%.8x\n",gpu_pc);
fclose(log_get());
// if gpu wasn't running but is now running, execute a few cycles
#ifndef GPU_SINGLE_STEPPING
- if ((!gpu_was_running) && (gpu_running))
+ if ((!gpu_was_running) && (GPU_RUNNING))
gpu_exec(200);
#else
if (gpu_control & 0x18)
gpu_exec(1);
-#endif
+#endif // #ifndef GPU_SINGLE_STEPPING
+#ifdef GPU_DEBUG
+fprintf(log_get(), "Write to GPU CTRL: %08X ", data);
+if (GPU_RUNNING)
+ fprintf(log_get(), "-- Starting to run at %08X...", gpu_pc);
+fprintf(log_get(), "\n");
+#endif // #ifdef GPU_DEBUG
break;
}
case 0x18:
jaguar_word_write(offset, (data >> 16) & 0xFFFF);
jaguar_word_write(offset+2, data & 0xFFFF);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_update_register_banks(void)
{
uint32 temp;
// fprintf(log_get(),"\tnot switching banks\n");
// }
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_check_irqs(void)
{
int bits, mask, which = 0;
gpu_pc += which * 0x10;
gpu_reg[30] = gpu_pc;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_set_irq_line(int irqline, int state)
{
if (start_logging)
gpu_check_irqs();
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_init(void)
{
memory_malloc_secure((void **)&gpu_ram_8, 0x1000, "GPU work ram");
gpu_reset();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_reset(void)
{
gpu_pc = 0x00F03000;
gpu_reset_stats();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint32 gpu_read_pc(void)
{
return gpu_pc;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_reset_stats(void)
{
for(uint32 i=0; i<64; i++)
gpu_opcode_use[i] = 0;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_done(void)
{
- int i, j;
- fprintf(log_get(),"gpu: stopped at pc=0x%.8x (gpu %s running)\n",gpu_pc,gpu_running?"was":"wasn't");
- int bits, mask;
+ fprintf(log_get(), "GPU: stopped at PC=%08X (GPU %s running)\n", gpu_pc, GPU_RUNNING ? "was" : "wasn't");
// get the active interrupt bits
- bits = (gpu_control >> 6) & 0x1F;
+ int bits = (gpu_control >> 6) & 0x1F;
bits |= (gpu_control >> 10) & 0x20;
// get the interrupt mask
- mask = (gpu_flags >> 4) & 0x1F;
+ int mask = (gpu_flags >> 4) & 0x1F;
mask |= (gpu_flags >> 11) & 0x20;
- fprintf(log_get(),"gpu: bits=0x%.8x mask=0x%.8x\n",bits,mask);
+ fprintf(log_get(), "GPU: ibits=0x%.8x imask=0x%.8x\n", bits, mask);
// fprintf(log_get(),"\nregisters bank 0\n");
// for (int j=0;j<8;j++)
// {
// (j<<2)+3,gpu_alternate_reg[(j<<2)+3]);
//
// }
-// fprintf(log_get(),"---[GPU code at 0x00f03000]---------------------------\n");
+ fprintf(log_get(),"---[GPU code at 00F03000]---------------------------\n");
static char buffer[512];
- j = 0xF03000;
+ int j = 0xF03000;
for(int i=0; i<4096; i++)
{
uint32 oldj = j;
fprintf(log_get(), "---[GPU code at %08X]---------------------------\n", gpu_pc);
j = gpu_pc - 64;
- for(i=0; i<4096; i++)
+ for(int i=0; i<4096; i++)
{
uint32 oldj = j;
j += dasmjag(JAGUAR_GPU, buffer, j);
}
fprintf(log_get(), "gpu opcodes use:\n");
- for(i=0; i<64; i++)
+ for(int i=0; i<64; i++)
{
if (gpu_opcode_use[i])
fprintf(log_get(), "\t%s %lu\n", gpu_opcode_str[i], gpu_opcode_use[i]);
}
memory_free(gpu_ram_8);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
+
//
+// Main GPU execution core
//
-//////////////////////////////////////////////////////////////////////////////
+
void gpu_exec(int32 cycles)
{
- if (!gpu_running)
+ if (!GPU_RUNNING)
return;
#ifdef GPU_SINGLE_STEPPING
gpu_releaseTimeSlice_flag = 0;
gpu_in_exec++;
- while ((cycles > 0) && gpu_running)
+ while ((cycles > 0) && GPU_RUNNING)
{
gpu_flag_c = (gpu_flag_c ? 1 : 0);
gpu_flag_z = (gpu_flag_z ? 1 : 0);
gpu_flag_n = (gpu_flag_n ? 1 : 0);
uint16 opcode = gpu_word_read(gpu_pc);
+/*static char buffer[512];
+dasmjag(JAGUAR_GPU, buffer, gpu_pc);
+fprintf(log_get(), "GPU: [%08X] %s\n", gpu_pc, buffer);*/
uint32 index = opcode >> 10;
- gpu_opcode_first_parameter = (opcode & 0x3E0) >> 5;
- gpu_opcode_second_parameter = (opcode & 0x1F);
+ gpu_opcode_first_parameter = (opcode >> 5) & 0x1F;
+ gpu_opcode_second_parameter = opcode & 0x1F;
gpu_pc += 2;
gpu_opcode[index]();
cycles -= gpu_opcode_cycles[index];
gpu_in_exec--;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
+
//
+// GPU opcodes
//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_jump(void)
{
uint32 delayed_pc = Rm;
gpu_pc = delayed_pc;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_jr(void)
{
int32 offset=(imm_1&0x10) ? (0xFFFFFFF0|imm_1) : imm_1;
gpu_pc=delayed_pc;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_add(void)
{
uint32 _Rm=Rm;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* uint32 index = opcode >> 10;
+ gpu_opcode_first_parameter = (opcode & 0x3E0) >> 5;
+ gpu_opcode_second_parameter = (opcode & 0x1F);
+ gpu_pc += 2;
+ gpu_opcode[index]();
+ cycles -= gpu_opcode_cycles[index];
+ gpu_opcode_use[index]++;*/
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 + r1;
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZNC_ADD(r2,r1,res);*/
+
+ UINT32 res = Rn + Rm;
+ CLR_ZNC; SET_ZNC_ADD(Rn, Rm, res);
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
-
- #ifdef __GCCWIN32__
+
+#ifdef __GCCWIN32__
asm(
"addl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"addl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
sets [gpu_flag_n]
mov res,eax
};
-#endif
+#endif // #ifdef __PORT__
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_addc(void)
{
uint32 _Rm=Rm;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 + r1 + ((jaguar.FLAGS >> 1) & 1);
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZNC_ADD(r2,r1,res);*/
+ UINT32 res = Rn + Rm + gpu_flag_c;
+ CLR_ZNC; SET_ZNC_ADD(Rn, Rm, res);
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"addl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"addl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_addq(void)
{
uint32 _Rn=Rn;
uint32 _Rm=gpu_convert_zero[imm_1];
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = convert_zero[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 + r1;
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZNC_ADD(r2,r1,res);*/
+ UINT32 r1 = gpu_convert_zero[imm_1];
+ UINT32 res = Rn + r1;
+ CLR_ZNC; SET_ZNC_ADD(Rn, r1, res);
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"addl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"addl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_addqt(void)
{
Rn += gpu_convert_zero[imm_1];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_sub(void)
{
uint32 _Rm=Rm;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 - r1;
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZNC_SUB(r2,r1,res);*/
+ UINT32 res = Rn - Rm;
+ CLR_ZNC; SET_ZNC_SUB(Rn, Rm, res);
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"subl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"subl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_subc(void)
{
uint32 _Rm=Rm;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 - r1 - ((jaguar.FLAGS >> 1) & 1);
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZNC_SUB(r2,r1,res);*/
+ UINT32 res = Rn - Rm - gpu_flag_c;
+ CLR_ZNC; SET_ZNC_SUB(Rn, Rm, res);
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"addl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"addl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_subq(void)
{
uint32 _Rm=gpu_convert_zero[imm_1];
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = convert_zero[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 - r1;
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZNC_SUB(r2,r1,res);*/
+ UINT32 r1 = gpu_convert_zero[imm_1];
+ UINT32 res = Rn - r1;
+ CLR_ZNC; SET_ZNC_SUB(Rn, r1, res);
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"subl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"subl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_subqt(void)
{
Rn -= gpu_convert_zero[imm_1];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_cmp(void)
{
uint32 _Rm=Rm;
uint32 _Rn=Rn;
#ifdef __PORT__
+#ifndef USE_ASSEMBLY
+{
+/* UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[jaguar.op & 31];
+ UINT32 res = r2 - r1;
+ CLR_ZNC; SET_ZNC_SUB(r2,r1,res);*/
+ UINT32 res = Rn - Rm;
+ CLR_ZNC; SET_ZNC_SUB(Rn, Rm, res);
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"cmpl %0, %1 \n\
:
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"cmpl %0, %1 \n\
:
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
};
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_cmpq(void)
{
- static int32 sqtable[32] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1};
+ static int32 sqtable[32] =
+ { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1 };
int32 _Rm=sqtable[imm_1&0x1f];
uint32 _Rn=Rn;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* UINT32 r1 = (INT8)(jaguar.op >> 2) >> 3;
+ UINT32 r2 = jaguar.r[jaguar.op & 31];
+ UINT32 res = r2 - r1;
+ CLR_ZNC; SET_ZNC_SUB(r2,r1,res);*/
+ UINT32 r1 = sqtable[imm_1 & 0x1F]; // I like this better -> (INT8)(jaguar.op >> 2) >> 3;
+ UINT32 res = Rn - r1;
+ CLR_ZNC; SET_ZNC_SUB(Rn, r1, res);
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"cmpl %0, %1 \n\
:
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"cmpl %0, %1 \n\
:
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
};
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_and(void)
{
uint32 _Rm=Rm;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 & r1;
+ jaguar.r[dreg] = res;
+ CLR_ZN; SET_ZN(res);*/
+ UINT32 res = Rn & Rm;
+ Rn = res;
+ CLR_ZN; SET_ZN(res);
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"andl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"andl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_or(void)
{
uint32 _Rm=Rm;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r1 | r2;
+ jaguar.r[dreg] = res;
+ CLR_ZN; SET_ZN(res);*/
+ UINT32 res = Rn | Rm;
+ Rn = res;
+ CLR_ZN; SET_ZN(res);
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"orl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"orl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_xor(void)
{
uint32 _Rm=Rm;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r1 ^ r2;
+ jaguar.r[dreg] = res;
+ CLR_ZN; SET_ZN(res);*/
+ UINT32 res = Rn ^ Rm;
+ Rn = res;
+ CLR_ZN; SET_ZN(res);
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"xorl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"xorl %1, %2 \n\
: "=m"(res)
: "d"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_not(void)
{
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 res = ~jaguar.r[dreg];
+ jaguar.r[dreg] = res;
+ CLR_ZN; SET_ZN(res);*/
+ UINT32 res = ~Rn;
+ Rn = res;
+ CLR_ZN; SET_ZN(res);
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"notl %1 \n\
: "=m"(res)
: "a"(_Rn));
- #else
+#else
asm(
"notl %1 \n\
: "=m"(res)
: "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_move_pc(void)
{
Rn = gpu_pc-2;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_sat8(void)
{
int32 _Rn=(int32)Rn;
set_flag_z(res);
reset_flag_n();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_sat16(void)
{
int32 _Rn=(int32)Rn;
set_flag_z(res);
reset_flag_n();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_sat24(void)
{
int32 _Rn=(int32)Rn;
set_flag_z(res);
reset_flag_n();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_store_r14_indexed(void)
{
gpu_long_write( gpu_reg[14] + (gpu_convert_zero[imm_1] << 2),Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_store_r15_indexed(void)
{
gpu_long_write( gpu_reg[15] + (gpu_convert_zero[imm_1] << 2),Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_load_r14_ri(void)
{
Rn=gpu_long_read(gpu_reg[14] + Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_load_r15_ri(void)
{
Rn=gpu_long_read(gpu_reg[15] + Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_store_r14_ri(void)
{
gpu_long_write(gpu_reg[14] + Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_store_r15_ri(void)
{
gpu_long_write(gpu_reg[15] + Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_nop(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_pack(void)
{
uint32 _Rn=Rn;
set_flag_z(Rn);
set_flag_n(Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_storeb(void)
{
if ((Rm >= 0xF03000) && (Rm < 0xF04000))
else
jaguar_byte_write(Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_storew(void)
{
if ((Rm >= 0xF03000) && (Rm < 0xF04000))
else
jaguar_word_write(Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_store(void)
{
gpu_long_write(Rm,Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_storep(void)
{
uint32 _Rm=Rm;
gpu_long_write(_Rm, gpu_hidata);
gpu_long_write(_Rm+4, Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_loadb(void)
{
if ((Rm >= 0xF03000) && (Rm < 0xF04000))
else
Rn=jaguar_byte_read(Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_loadw(void)
{
if ((Rm >= 0xF03000) && (Rm < 0xF04000))
else
Rn=jaguar_word_read(Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_load(void)
{
Rn = gpu_long_read(Rm);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_loadp(void)
{
uint32 _Rm=Rm;
gpu_hidata = gpu_long_read(_Rm);
Rn = gpu_long_read(_Rm+4);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_load_r14_indexed(void)
{
Rn = gpu_long_read( gpu_reg[14] + (gpu_convert_zero[imm_1] << 2));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_load_r15_indexed(void)
{
Rn = gpu_long_read( gpu_reg[15] + (gpu_convert_zero[imm_1] << 2));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_movei(void)
{
- Rn = ((uint32)gpu_word_read(gpu_pc)) + (((uint32)gpu_word_read(gpu_pc+2))<<16);
- gpu_pc+=4;
-}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+ Rn = (uint32)gpu_word_read(gpu_pc) | ((uint32)gpu_word_read(gpu_pc + 2) << 16);
+ gpu_pc += 4;
+}
+
static void gpu_opcode_moveta(void)
{
alternate_Rn = Rm;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_movefa(void)
{
Rn = alternate_Rm;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_move(void)
{
Rn = Rm;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_moveq(void)
{
Rn = imm_1;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_resmac(void)
{
Rn = gpu_acc;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_imult(void)
{
uint32 res=Rn=((int16)Rn)*((int16)Rm);
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_mult(void)
{
uint32 res=Rn = ((uint16)Rm) * ((uint16)Rn);
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_bclr(void)
{
uint32 _Rm=imm_1;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = (jaguar.op >> 5) & 31;
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 & ~(1 << r1);
+ jaguar.r[dreg] = res;
+ CLR_ZN; SET_ZN(res);*/
+ UINT32 res = Rn & ~(1 << imm_1);
+ Rn = res;
+ CLR_ZN; SET_ZN(res);
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"btrl %1, %2 \n\
: "=m"(res)
: "c"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"btrl %1, %2 \n\
: "=m"(res)
: "c"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_btst(void)
{
uint32 _Rm=imm_1;
uint32 _Rn=Rn;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* UINT32 r1 = (jaguar.op >> 5) & 31;
+ UINT32 r2 = jaguar.r[jaguar.op & 31];
+ CLR_Z; jaguar.FLAGS |= (~r2 >> r1) & 1;*/
+ CLR_Z; gpu_flag_z = (~Rn >> imm_1) & 1;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"bt %0, %1 \n\
:
: "c"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"bt %0, %1 \n\
:
: "c"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
};
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_bset(void)
{
uint32 _Rm=imm_1;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = (jaguar.op >> 5) & 31;
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 | (1 << r1);
+ jaguar.r[dreg] = res;
+ CLR_ZN; SET_ZN(res);*/
+ UINT32 res = Rn | (1 << imm_1);
+ Rn = res;
+ CLR_ZN; SET_ZN(res);
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"btsl %1, %2 \n\
: "=m"(res)
: "c"(_Rm), "a"(_Rn));
- #else
+#else
asm(
"btsl %1, %2 \n\
: "=m"(res)
: "c"(_Rm), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_imacn(void)
{
uint32 res = ((int16)Rm) * ((int16)(Rn));
gpu_acc += res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_mtoi(void)
{
uint32 _Rm=Rm;
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_normi(void)
{
uint32 _Rm = Rm;
if (_Rm)
{
- while ((_Rm & 0xffc00000) == 0)
+ while ((_Rm & 0xFFC00000) == 0)
{
_Rm <<= 1;
res--;
}
- while ((_Rm & 0xff800000) != 0)
+ while ((_Rm & 0xFF800000) != 0)
{
_Rm >>= 1;
res++;
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_mmult(void)
{
- int count = gpu_matrix_control&0x0f;
+ int count = gpu_matrix_control & 0x0F;
uint32 addr = gpu_pointer_to_matrix; // in the gpu ram
int64 accum = 0;
uint32 res;
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_abs(void)
{
uint32 _Rn=Rn;
set_flag_z(res);
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_div(void)
{
uint32 _Rm=Rm;
else
Rn=0xffffffff;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_imultn(void)
{
uint32 res = (int32)((int16)Rn * (int16)Rm);
set_flag_z(res);
set_flag_n(res);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_neg(void)
{
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+{
+/* int dreg = jaguar.op & 31;
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = -r2;
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZNC_SUB(0,r2,res);*/
+ UINT32 res = -Rn;
+ CLR_ZNC; SET_ZNC_SUB(0, Rn, res);
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"subl %1, %2 \n\
: "=m"(res)
: "d"(_Rn), "a"(0));
- #else
+#else
asm(
"subl %1, %2 \n\
: "=m"(res)
: "d"(_Rn), "a"(0));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_shlq(void)
{
uint32 shift=(32-gpu_convert_zero[imm_1]);
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+/* int dreg = jaguar.op & 31;
+ INT32 r1 = convert_zero[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 << (32 - r1);
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZN(res); jaguar.FLAGS |= (r2 >> 30) & 2;*/
+{
+ INT32 r1 = gpu_convert_zero[imm_1];
+ UINT32 res = Rn << (32 - r1);
+ CLR_ZNC; SET_ZN(res); gpu_flag_c = (Rn >> 31) & 1;
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"testl $0x80000000, %2 \n\
: "=m"(res)
: "c"(shift), "a"(_Rn));
- #else
+#else
asm(
"testl $0x80000000, %2 \n\
: "=m"(res)
: "c"(shift), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_shrq(void)
{
uint32 shift=gpu_convert_zero[imm_1];
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+/* int dreg = jaguar.op & 31;
+ INT32 r1 = convert_zero[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = r2 >> r1;
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZN(res); jaguar.FLAGS |= (r2 << 1) & 2;*/
+{
+ INT32 r1 = gpu_convert_zero[imm_1];
+ UINT32 res = Rn >> r1;
+ CLR_ZNC; SET_ZN(res); gpu_flag_c = Rn & 1;
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"testl $0x00000001, %2 \n\
: "=m"(res)
: "c"(shift), "a"(_Rn));
- #else
+#else
asm(
"testl $0x00000001, %2 \n\
: "=m"(res)
: "c"(shift), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_ror(void)
{
uint32 shift=Rm;
uint32 _Rn=Rn;
uint32 res;
#ifdef __PORT__
-
+#ifndef USE_ASSEMBLY
+//#ifndef __PORT__ // For testing...
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = jaguar.r[(jaguar.op >> 5) & 31] & 31;
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = (r2 >> r1) | (r2 << (32 - r1));
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZN(res); jaguar.FLAGS |= (r2 >> 30) & 2;*/
+{
+ UINT32 r1 = Rm & 0x1F;
+ UINT32 res = (Rn >> r1) | (Rn << (32 - r1));
+ CLR_ZNC; SET_ZN(res); gpu_flag_c = (Rn >> 31) & 1;
+ Rn = res;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
variables in asm until we put a _ before it.
So the declaration dsp_flag_c needs to be _dsp_flag_c on mingw.
*/
- #ifdef __GCCWIN32__
+#ifdef __GCCWIN32__
asm(
"testl $0x80000000, %2 \n\
: "=m"(res)
: "c"(shift), "a"(_Rn));
- #else
+#else
asm(
"testl $0x80000000, %2 \n\
: "=m"(res)
: "c"(shift), "a"(_Rn));
- #endif
+#endif // #ifdef __GCCWIN32__
+#endif // #ifndef USE_ASSEMBLY
#else
__asm
#endif
Rn=res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_rorq(void)
{
uint32 shift = gpu_convert_zero[imm_1 & 0x1F];
uint32 _Rn = Rn;
uint32 res;
#ifdef __PORT__
+#ifndef USE_ASSEMBLY
+/* uint32 index = opcode >> 10;
+ gpu_opcode_first_parameter = (opcode & 0x3E0) >> 5;
+ gpu_opcode_second_parameter = (opcode & 0x1F);
+ gpu_pc += 2;
+ gpu_opcode[index]();
+ cycles -= gpu_opcode_cycles[index];
+ gpu_opcode_use[index]++;*/
+
+/* int dreg = jaguar.op & 31;
+ UINT32 r1 = convert_zero[(jaguar.op >> 5) & 31];
+ UINT32 r2 = jaguar.r[dreg];
+ UINT32 res = (r2 >> r1) | (r2 << (32 - r1));
+ jaguar.r[dreg] = res;
+ CLR_ZNC; SET_ZN(res); jaguar.FLAGS |= (r2 >> 30) & 2;*/
+{
+ UINT32 r1 = gpu_convert_zero[imm_1 & 0x1F];
+ UINT32 r2 = Rn;
+ UINT32 res = (r2 >> r1) | (r2 << (32 - r1));
+ Rn = res;
+ CLR_ZNC; SET_ZN(res); gpu_flag_c = (r2 >> 31) & 0x01;
+ return;
+}
+#else
/*
GCC on WIN32 (more importantly mingw) doesn't know the declared
: "c"(shift), "a"(_Rn));
#endif // #ifdef __GCCWIN32__
-
+#endif // #ifndef USE_ASSEMBLY
+
#else
__asm
{
#endif // #ifdef __PORT__
Rn = res;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_sha(void)
{
int32 sRm=(int32)Rm;
set_flag_z(_Rn);
set_flag_n(_Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_sharq(void)
{
uint32 shift=gpu_convert_zero[imm_1];
set_flag_z(_Rn);
set_flag_n(_Rn);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
static void gpu_opcode_sh(void)
{
int32 sRm=(int32)Rm;
{
Uint32 flags = SDL_SWSURFACE;
- if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
+//Testing if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) < 0)
throw Error(SDL_GetError());
const SDL_VideoInfo * info = SDL_GetVideoInfo(); // Let us get proper info about the platform.
- if (flags&FLAGS_READMODIFY)
+ if (flags & FLAGS_READMODIFY)
{
- if (flags&FLAGS_HFLIP)
+ if (flags & FLAGS_HFLIP)
{
while (iwidth)
{
- if (flags&FLAGS_TRANSPARENT)
+ uint8 dataHi = jaguar_byte_read(ptr++), dataLo = jaguar_byte_read(ptr++);
+
+ if (flags & FLAGS_TRANSPARENT)
{
- uint16 data=jaguar_byte_read(ptr++);
- data<<=8;
- data|=jaguar_byte_read(ptr++);
- if (data)
+// uint16 data = jaguar_byte_read(ptr++);
+// data <<= 8;
+// data |= jaguar_byte_read(ptr++);
+/* if (data)
+ {
+ *current_line_buffer-- = BLEND_Y(*current_line_buffer, data >> 8);
+ *current_line_buffer-- = BLEND_CC(*current_line_buffer, data & 0xFF);
+ }*/
+ if (dataHi | dataLo)
{
- *current_line_buffer--=BLEND_Y(*current_line_buffer,(data>>8));
- *current_line_buffer--=BLEND_CC(*current_line_buffer,(data&0xff));
+ *current_line_buffer-- = BLEND_Y(*current_line_buffer, dataHi);
+ *current_line_buffer-- = BLEND_CC(*current_line_buffer, dataLo);
}
else
- current_line_buffer-=2;
+ current_line_buffer -= 2;
}
- else
+ else // !FLAGS_TRANSPARENT
{
- *current_line_buffer--=BLEND_Y(*current_line_buffer,jaguar_byte_read(ptr++));
- *current_line_buffer--=BLEND_CC(*current_line_buffer,jaguar_byte_read(ptr++));
+// *current_line_buffer-- = BLEND_Y(*current_line_buffer, jaguar_byte_read(ptr++));
+// *current_line_buffer-- = BLEND_CC(*current_line_buffer, jaguar_byte_read(ptr++));
+ *current_line_buffer-- = BLEND_Y(*current_line_buffer, dataHi);
+ *current_line_buffer-- = BLEND_CC(*current_line_buffer, dataLo);
}
iwidth--;
}
}
- else
+ else // !FLAGS_HFLIP
{
while (iwidth)
{
- if (flags&FLAGS_TRANSPARENT)
+ uint8 dataHi = jaguar_byte_read(ptr++), dataLo = jaguar_byte_read(ptr++);
+
+ if (flags & FLAGS_TRANSPARENT)
{
- uint16 data=jaguar_byte_read(ptr++);
- data<<=8;
- data|=jaguar_byte_read(ptr++);
+/* uint16 data = jaguar_byte_read(ptr++);
+ data <<= 8;
+ data |= jaguar_byte_read(ptr++);
if (data)
{
- *current_line_buffer++=BLEND_Y(*current_line_buffer,(data>>8));
- *current_line_buffer++=BLEND_CC(*current_line_buffer,(data&0xff));
+ *current_line_buffer++ = BLEND_Y(*current_line_buffer, data >> 8);
+ *current_line_buffer++ = BLEND_CC(*current_line_buffer, data & 0xFF);
+ }*/
+ if (dataHi | dataLo)
+ {
+ *current_line_buffer++ = BLEND_Y(*current_line_buffer, dataHi);
+ *current_line_buffer++ = BLEND_CC(*current_line_buffer, dataLo);
}
else
- current_line_buffer+=2;
+ current_line_buffer += 2;
}
else
{
- *current_line_buffer++=BLEND_Y(*current_line_buffer,jaguar_byte_read(ptr++));
- *current_line_buffer++=BLEND_CC(*current_line_buffer,jaguar_byte_read(ptr++));
+// *current_line_buffer++ = BLEND_Y(*current_line_buffer, jaguar_byte_read(ptr++));
+// *current_line_buffer++ = BLEND_CC(*current_line_buffer, jaguar_byte_read(ptr++));
+ *current_line_buffer++ = BLEND_Y(*current_line_buffer, dataHi);
+ *current_line_buffer++ = BLEND_CC(*current_line_buffer, dataLo);
}
iwidth--;
}
}
}
- else
+ else // !FLAGS_READMODIFY
{
- if (flags&FLAGS_HFLIP)
+ if (flags & FLAGS_HFLIP)
{
while (iwidth)
{
- if (flags&FLAGS_TRANSPARENT)
+ uint8 dataHi = jaguar_byte_read(ptr++), dataLo = jaguar_byte_read(ptr++);
+
+ if (flags & FLAGS_TRANSPARENT)
{
- uint16 data=jaguar_byte_read(ptr++);
- data<<=8;
- data|=jaguar_byte_read(ptr++);
+/* uint16 data = jaguar_byte_read(ptr++);
+ data <<= 8;
+ data |= jaguar_byte_read(ptr++);
if (data)
{
- *current_line_buffer--=(data>>8);
- *current_line_buffer--=(data&0xff);
- }
+ *current_line_buffer-- = data >> 8;
+ *current_line_buffer-- = data & 0xFF;
+ }*/
+ if (dataHi | dataLo)
+ *current_line_buffer-- = dataHi,
+ *current_line_buffer-- = dataLo;
else
- current_line_buffer-=2;
+ current_line_buffer -= 2;
}
else
{
- *current_line_buffer--=jaguar_byte_read(ptr++);
- *current_line_buffer--=jaguar_byte_read(ptr++);
+// *current_line_buffer-- = jaguar_byte_read(ptr++);
+// *current_line_buffer-- = jaguar_byte_read(ptr++);
+ *current_line_buffer-- = dataHi;
+ *current_line_buffer-- = dataLo;
}
iwidth--;
}
}
- else
+ else // !FLAGS_HFLIP
{
- int count=0;
+ int count = 0;
while (iwidth)
{
- if (flags&FLAGS_TRANSPARENT)
- {
- uint16 data=jaguar_byte_read(ptr++);
- data<<=8;
- data|=jaguar_byte_read(ptr++);
+ uint8 dataHi = jaguar_byte_read(ptr++), dataLo = jaguar_byte_read(ptr++);
+
+ if (flags & FLAGS_TRANSPARENT)
+ {
+/* uint16 data = jaguar_byte_read(ptr++);
+ data <<= 8;
+ data |= jaguar_byte_read(ptr++);
if (data)
{
- *current_line_buffer++=(data>>8);
- *current_line_buffer++=(data&0xff);
- }
+ *current_line_buffer++ = data >> 8;
+ *current_line_buffer++ = data & 0xFF;
+ }*/
+ if (dataHi | dataLo)
+ *current_line_buffer++ = dataHi,
+ *current_line_buffer++ = dataLo;
else
- current_line_buffer+=2;
+ current_line_buffer += 2;
}
else
{
- *current_line_buffer++=jaguar_byte_read(ptr++);
- *current_line_buffer++=jaguar_byte_read(ptr++);
+// *current_line_buffer++ = jaguar_byte_read(ptr++);
+// *current_line_buffer++ = jaguar_byte_read(ptr++);
+ *current_line_buffer++ = dataHi;
+ *current_line_buffer++ = dataLo;
}
- count+=2;
- if (count==8) // 8 bytes = a phrase (64 bits)
+ count += 2;
+ if (count == 8) // 8 bytes = a phrase (64 bits)
{
- ptr+=8*(pitch-1);
- count=0;
+ ptr += 8 * (pitch - 1);
+ count = 0;
}
iwidth--;
}
uint32 jaguar_interrupt_handler_is_valid(uint32 i);
void jaguar_dasm(uint32 offset, uint32 qt);
+//Temp debug stuff
+
+void DumpMainMemory(void);
+uint8 * GetRamPtr(void);
+
#endif // #ifndef __JAGUAR_H__
-//
-// Useful types (platform specific)
-//
-// by cal16
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
// Removal of unsafe macros and addition of typdefs by James L. Hammons
//
0x00, 0x00, 0x0A, 0xBC, 0xFF, 0xFF, 0xEC, 0xFD, 0x00, 0x00, 0x0E, 0xAA, 0xFF, 0xFF, 0xFC, 0x53,
0xFF, 0xFF, 0xFB, 0xFD, 0xFF, 0xFF, 0xF0, 0x58, 0x00, 0x00, 0x02, 0x91, 0xFF, 0xFF, 0xE3, 0x83,
0x00, 0x00, 0x18, 0x80, 0xFF, 0xFF, 0xF1, 0x35, 0xFF, 0xFF, 0xF3, 0x0C, 0xFF, 0xFF, 0xE6, 0xD6,
- } ;
+ };
pc += 2;
switch (op >> 10)
{
- case 0: sprintf(buffer, "add r%d,r%d", reg1, reg2); break;
- case 1: sprintf(buffer, "addc r%d,r%d", reg1, reg2); break;
- case 2: sprintf(buffer, "addq $%x,r%d", convert_zero[reg1], reg2); break;
+ case 0: sprintf(buffer, "+add r%d,r%d", reg1, reg2); break;
+ case 1: sprintf(buffer, "+addc r%d,r%d", reg1, reg2); break;
+ case 2: sprintf(buffer, "+addq $%x,r%d", convert_zero[reg1], reg2); break;
case 3: sprintf(buffer, "addqt $%x,r%d", convert_zero[reg1], reg2); break;
- case 4: sprintf(buffer, "sub r%d,r%d", reg1, reg2); break;
- case 5: sprintf(buffer, "subc r%d,r%d", reg1, reg2); break;
- case 6: sprintf(buffer, "subq $%x,r%d", convert_zero[reg1], reg2); break;
+ case 4: sprintf(buffer, "+sub r%d,r%d", reg1, reg2); break;
+ case 5: sprintf(buffer, "+subc r%d,r%d", reg1, reg2); break;
+ case 6: sprintf(buffer, "+subq $%x,r%d", convert_zero[reg1], reg2); break;
case 7: sprintf(buffer, "subqt $%x,r%d", convert_zero[reg1], reg2); break;
- case 8: sprintf(buffer, "neg r%d", reg2); break;
- case 9: sprintf(buffer, "and r%d,r%d", reg1, reg2); break;
- case 10: sprintf(buffer, "or r%d,r%d", reg1, reg2); break;
- case 11: sprintf(buffer, "xor r%d,r%d", reg1, reg2); break;
- case 12: sprintf(buffer, "not r%d", reg2); break;
- case 13: sprintf(buffer, "btst $%x,r%d", reg1, reg2); break;
- case 14: sprintf(buffer, "bset $%x,r%d", reg1, reg2); break;
- case 15: sprintf(buffer, "bclr $%x,r%d", reg1, reg2); break;
+ case 8: sprintf(buffer, "+neg r%d", reg2); break;
+ case 9: sprintf(buffer, "+and r%d,r%d", reg1, reg2); break;
+ case 10: sprintf(buffer, "+or r%d,r%d", reg1, reg2); break;
+ case 11: sprintf(buffer, "+xor r%d,r%d", reg1, reg2); break;
+ case 12: sprintf(buffer, "+not r%d", reg2); break;
+ case 13: sprintf(buffer, "+btst $%x,r%d", reg1, reg2); break;
+ case 14: sprintf(buffer, "+bset $%x,r%d", reg1, reg2); break;
+ case 15: sprintf(buffer, "+bclr $%x,r%d", reg1, reg2); break;
case 16: sprintf(buffer, "mult r%d,r%d", reg1, reg2); break;
case 17: sprintf(buffer, "imult r%d,r%d", reg1, reg2); break;
case 18: sprintf(buffer, "imultn r%d,r%d", reg1, reg2); break;
case 21: sprintf(buffer, "div r%d,r%d", reg1, reg2); break;
case 22: sprintf(buffer, "abs r%d", reg2); break;
case 23: sprintf(buffer, "sh r%d,r%d", reg1, reg2); break;
- case 24: sprintf(buffer, "shlq $%x,r%d", 32 - convert_zero[reg1], reg2); break;
- case 25: sprintf(buffer, "shrq $%x,r%d", convert_zero[reg1], reg2); break;
+ case 24: sprintf(buffer, "+shlq $%x,r%d", 32 - convert_zero[reg1], reg2); break;
+ case 25: sprintf(buffer, "+shrq $%x,r%d", convert_zero[reg1], reg2); break;
case 26: sprintf(buffer, "sha r%d,r%d", reg1, reg2); break;
case 27: sprintf(buffer, "sharq $%x,r%d", convert_zero[reg1], reg2); break;
- case 28: sprintf(buffer, "ror r%d,r%d", reg1, reg2); break;
+ case 28: sprintf(buffer, "+ror r%d,r%d", reg1, reg2); break;
case 29: sprintf(buffer, "rorq $%x,r%d", convert_zero[reg1], reg2); break;
- case 30: sprintf(buffer, "cmp r%d,r%d", reg1, reg2); break;
- case 31: sprintf(buffer, "cmpq %s,r%d", signed_16bit((INT16)(reg1 << 11) >> 11), reg2);break;
+ case 30: sprintf(buffer, "+cmp r%d,r%d", reg1, reg2); break;
+ case 31: sprintf(buffer, "+cmpq %s,r%d", signed_16bit((INT16)(reg1 << 11) >> 11), reg2);break;
case 32: if (dsp_type == JAGUAR_GPU)
sprintf(buffer, "sat8 r%d", reg2);
else
//
// JAGUAR.CPP
//
-// by cal16
+// by cal2
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
// Cleanups and endian wrongness amelioration by James L. Hammons
// Note: Endian wrongness probably stems from the MAME origins of this emu and
#define JAGUAR_WIP_RELEASE
#define JAGUAR_REAL_SPEED
-
-//////////////////////////////////////////////////////////////////////////////
-// Bios path
-//////////////////////////////////////////////////////////////////////////////
-//
//
+// Bios path
//
-//////////////////////////////////////////////////////////////////////////////
+
//static char *jaguar_bootRom_path="c:/jaguarEmu/newload.img";
static char * jaguar_bootRom_path = "./bios/jagboot.rom";
//static char *jaguar_bootRom_path="./bios/JagOS.bin";
char * jaguar_eeproms_path = "./eeproms/";
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
uint32 jaguar_mainRom_crc32;
static uint32 m68k_cycles_per_scanline;
static uint8 * jaguar_mainRam = NULL;
static uint8 * jaguar_bootRom = NULL;
static uint8 * jaguar_mainRom = NULL;
-//////////////////////////////////////////////////////////////////////////////
//
return vector;
}
-//Do this in makefile???
+//Do this in makefile??? Yes!
//#define LOG_UNMAPPED_MEMORY_ACCESSES 1
unsigned int m68k_read_memory_8(unsigned int address)
m68k_write_memory_16(address + 2, value & 0xFFFF);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-/*struct STARSCREAM_PROGRAMREGION *jaguar_programfetch;
-struct STARSCREAM_DATAREGION *jaguar_readbyte;
-struct STARSCREAM_DATAREGION *jaguar_readword;
-struct STARSCREAM_DATAREGION *jaguar_writebyte;
-struct STARSCREAM_DATAREGION *jaguar_writeword;
-UINT16 jaguar_regionsCount[6];*/
//////////////////////////////////////////////////////////////////////////////
//
uint32 jaguar_get_handler(uint32 i)
{
// return (jaguar_word_read(i<<2) << 16) | jaguar_word_read((i<<2) + 2);
- return (jaguar_word_read(i*4) << 16) | jaguar_word_read((i*4) + 2);
+// return (jaguar_word_read(i*4) << 16) | jaguar_word_read((i*4) + 2);
+ return jaguar_long_read(i * 4);
}
//////////////////////////////////////////////////////////////////////////////
#ifndef __PORT__
static char romLoadDialog_initialDirectory[1024];
-int jaguar_open_rom(HWND hWnd,char *title,char *filterString)
+int jaguar_open_rom(HWND hWnd, char * title, char * filterString)
{
OPENFILENAME ofn;
-
-
romLoadDialog_initialDirectory[0] = 0;
-
-
romLoadDialog_filePath[0] = 0;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
uint8 * jaguar_rom_load(char * path, uint32 * romSize)
{
- uint8 * rom = NULL;
- fpos_t pos;
- int x;
__int64 filepos;
fprintf(log_get(), "jaguar: loading %s...", path);
/* Added by SDLEMU (http://sdlemu.ngemu.com) */
/* Added for GCC UNIX compatibility */
- #ifdef __GCCUNIX__
+#ifdef __GCCUNIX__
fgetpos(fp, (fpos_t *)&filepos);
- #else
+#else
fgetpos(fp, &filepos);
- #endif
+#endif
*romSize = (int)filepos;
fseek(fp, 0, SEEK_SET);
- rom = (uint8 *)malloc(*romSize);
+ uint8 * rom = (uint8 *)malloc(*romSize);
fread(rom, 1, *romSize, fp);
fclose(fp);
fprintf(log_get(), "ok (%i bytes)\n", *romSize);
/* Added by SDLEMU (http://sdlemu.ngemu.com) */
/* Added for GCC UNIX compatibility */
- #ifdef __GCCUNIX__
+#ifdef __GCCUNIX__
fgetpos(fp, (fpos_t *)&filepos);
- #else
+#else
fgetpos(fp, &filepos);
- #endif
+#endif
*romSize = (int)filepos;
fseek(fp, 0, SEEK_SET);
// Byte swap a region of memory
//
-void jaguar_byte_swap(uint8 * rom, uint32 size)
+/*void jaguar_byte_swap(uint8 * rom, uint32 size)
{
while (size > 0)
{
rom += 2;
size -= 2;
}
-}
+}*/
//
// Disassemble instructions at the given offset
void jaguar_dasm(uint32 offset, uint32 qt)
{
+#ifdef CPU_DEBUG
static char buffer[2048], mem[64];
int pc = offset, oldpc;
{
oldpc = pc;
for(int j=0; j<64; j++)
-// mem[j^0x01] = jaguar_byte_read(pc + j);
mem[j^0x01] = jaguar_byte_read(pc + j);
pc += Dasm68000((char *)mem, buffer, 0);
-#ifdef CPU_DEBUG
fprintf(log_get(), "%08X: %s\n", oldpc, buffer);
-#endif
}
+#endif
}
//
// Is there a need for this? The answer is !!! NO !!!
// jaguar_byte_swap(mem+offs, romsize);
jaguar_mainRom_crc32 = crc32_calcCheckSum(jaguar_mainRom, romsize);
- fprintf(log_get(), "crc: %08X\n", jaguar_mainRom_crc32);
+ fprintf(log_get(), "CRC: %08X\n", jaguar_mainRom_crc32);
// Brain dead endian dependent crap
// *((uint32 *)&jaguar_mainRam[4]) = boot;
gpu_cycles_per_scanline = (26591000 / 4) / (jaguar_screen_scanlines * 60);
dsp_cycles_per_scanline = (26591000 / 4) / (jaguar_screen_scanlines * 60);
- memory_malloc_secure((void**)&jaguar_mainRam, 0x400000, "Jaguar 68k cpu ram");
- memory_malloc_secure((void**)&jaguar_bootRom, 0x040000, "Jaguar 68k cpu boot rom");
- memory_malloc_secure((void**)&jaguar_mainRom, 0x600000, "Jaguar 68k cpu rom");
+ memory_malloc_secure((void **)&jaguar_mainRam, 0x400000, "Jaguar 68k cpu ram");
+ memory_malloc_secure((void **)&jaguar_bootRom, 0x040000, "Jaguar 68k cpu boot rom");
+ memory_malloc_secure((void **)&jaguar_mainRom, 0x600000, "Jaguar 68k cpu rom");
memset(jaguar_mainRam, 0x00, 0x400000);
jaguar_rom_load_to(jaguar_bootRom, jaguar_bootRom_path, &romsize);
#endif
//WAS: jaguar_load_cart(romLoadDialog_filePath, jaguar_mainRom, 0x0000, 0x20000080, 0);
jaguar_load_cart(romLoadDialog_filePath, jaguar_mainRom, 0x0000, 0x00802000, 0);
+
+//JLH:
+/* if (jaguar_mainRom_crc32 == 0xA9F8A00E)
+ {
+ dsp_enabled = 1;
+ fprintf(log_get(), "--> Rayman detected, DSP enabled...\n");
+ }//*/
+
+
if ((jaguar_mainRom_crc32 == 0x3966698f) || (jaguar_mainRom_crc32 == 0x5e705756)
|| (jaguar_mainRom_crc32 == 0x2630cbc4) || (jaguar_mainRom_crc32 == 0xd46437e8)
|| (jaguar_mainRom_crc32 == 0x2630cbc4))
if (jaguar_use_bios)
{
memcpy(jaguar_mainRam, jaguar_bootRom, 8);
- *((uint32 *)&jaguar_mainRam[0]) = 0x00000020;
+// *((uint32 *)&jaguar_mainRam[0]) = 0x00000020;
+// SET32(jaguar_mainRam, 0, 0x00200000);
}
// s68000init();
jerry_init();
cdrom_init();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
unsigned jaguar_byte_read(unsigned int offset)
{
uint8 data = 0x00;
offset &= 0xFFFFFF;
if (offset < 0x400000)
// data = (jaguar_mainRam[(offset^0x01) & 0x3FFFFF]);
- data = (jaguar_mainRam[offset & 0x3FFFFF]);
+ data = jaguar_mainRam[offset & 0x3FFFFF];
else if ((offset >= 0x800000) && (offset < 0xC00000))
// data = (jaguar_mainRom[(offset^0x01)-0x800000]);
- data = (jaguar_mainRom[offset - 0x800000]);
- else if ((offset >= 0xDFFF00) && (offset < 0xDFFF00))
+ data = jaguar_mainRom[offset - 0x800000];
+// else if ((offset >= 0xDFFF00) && (offset < 0xDFFF00))
+ else if ((offset >= 0xDFFF00) && (offset <= 0xDFFFFF))
data = cdrom_byte_read(offset);
else if ((offset >= 0xE00000) && (offset < 0xE40000))
// data = (jaguar_bootRom[(offset^0x01) & 0x3FFFF]);
- data = (jaguar_bootRom[offset & 0x3FFFF]);
+ data = jaguar_bootRom[offset & 0x3FFFF];
else if ((offset >= 0xF00000) && (offset < 0xF10000))
- data = (tom_byte_read(offset));
+ data = tom_byte_read(offset);
else if ((offset >= 0xF10000) && (offset < 0xF20000))
- data = (jerry_byte_read(offset));
+ data = jerry_byte_read(offset);
else
data = jaguar_unknown_readbyte(offset);
return data;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
unsigned jaguar_word_read(unsigned int offset)
{
offset &= 0xFFFFFF;
- if (offset < 0x400000)
+ if (offset <= 0x3FFFFE)
{
// return (jaguar_mainRam[(offset+1) & 0x3FFFFF] << 8) | jaguar_mainRam[(offset+0) & 0x3FFFFF];
return (jaguar_mainRam[(offset+0) & 0x3FFFFF] << 8) | jaguar_mainRam[(offset+1) & 0x3FFFFF];
}
- else if ((offset >= 0x800000) && (offset < 0xC00000))
+ else if ((offset >= 0x800000) && (offset <= 0xBFFFFE))
{
offset -= 0x800000;
// return (jaguar_mainRom[offset+1] << 8) | jaguar_mainRom[offset+0];
return (jaguar_mainRom[offset+0] << 8) | jaguar_mainRom[offset+1];
}
- else if ((offset >= 0xDFFF00) && (offset < 0xDFFF00))
+// else if ((offset >= 0xDFFF00) && (offset < 0xDFFF00))
+ else if ((offset >= 0xDFFF00) && (offset <= 0xDFFFFE))
return cdrom_word_read(offset);
- else if ((offset >= 0xE00000) && (offset < 0xE40000))
- return *((uint16 *)&jaguar_bootRom[offset & 0x3FFFF]);
- else if ((offset >= 0xF00000) && (offset < 0xF10000))
+ else if ((offset >= 0xE00000) && (offset <= 0xE3FFFE))
+// return *((uint16 *)&jaguar_bootRom[offset & 0x3FFFF]);
+ return (jaguar_bootRom[(offset+0) & 0x3FFFF] << 8) | jaguar_bootRom[(offset+1) & 0x3FFFF];
+ else if ((offset >= 0xF00000) && (offset <= 0xF0FFFE))
return tom_word_read(offset);
- else if ((offset >= 0xF10000) && (offset < 0xF20000))
+ else if ((offset >= 0xF10000) && (offset <= 0xF1FFFE))
return jerry_word_read(offset);
return jaguar_unknown_readword(offset);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void jaguar_byte_write(unsigned offset, unsigned data)
+
+void jaguar_byte_write(unsigned offset, unsigned data)
{
offset &= 0xFFFFFF;
if (offset < 0x400000)
jaguar_mainRam[offset & 0x3FFFFF] = data;
return;
}
- else if ((offset >= 0xDFFF00) && (offset < 0xDFFF00))
+// else if ((offset >= 0xDFFF00) && (offset < 0xDFFF00))
+ else if ((offset >= 0xDFFF00) && (offset <= 0xDFFFFF))
{
cdrom_byte_write(offset, data);
return;
}
- else if ((offset >= 0xF00000) && (offset < 0xF10000))
+ else if ((offset >= 0xF00000) && (offset <= 0xF0FFFF))
{
tom_byte_write(offset, data);
return;
}
- else if ((offset >= 0xF10000) && (offset < 0xF20000))
+ else if ((offset >= 0xF10000) && (offset <= 0xF1FFFF))
{
jerry_byte_write(offset, data);
return;
jaguar_unknown_writebyte(offset, data);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jaguar_word_write(unsigned offset, unsigned data)
{
offset &= 0xFFFFFF;
- if (offset < 0x400000)
+ if (offset <= 0x3FFFFE)
{
// jaguar_mainRam[(offset+0) & 0x3FFFFF] = data & 0xFF;
// jaguar_mainRam[(offset+1) & 0x3FFFFF] = (data>>8) & 0xFF;
jaguar_mainRam[(offset+1) & 0x3FFFFF] = data & 0xFF;
return;
}
- else if ((offset >= 0xDFFF00) && (offset < 0xDFFFFF))
+ else if ((offset >= 0xDFFF00) && (offset <= 0xDFFFFE))
{
cdrom_word_write(offset, data);
return;
}
- else if ((offset >= 0xF00000) && (offset < 0xF10000))
+ else if ((offset >= 0xF00000) && (offset <= 0xF0FFFE))
{
tom_word_write(offset, data);
return;
}
- else if ((offset >= 0xF10000) && (offset < 0xF20000))
+ else if ((offset >= 0xF10000) && (offset <= 0xF1FFFE))
{
jerry_word_write(offset, data);
return;
jaguar_unknown_writeword(offset, data);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
unsigned jaguar_long_read(unsigned int offset)
{
/* uint32 data = jaguar_word_read(offset);
return data;*/
return (jaguar_word_read(offset) << 16) | jaguar_word_read(offset+2);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jaguar_long_write(unsigned offset, unsigned data)
{
jaguar_word_write(offset, data >> 16);
jaguar_word_write(offset+2, data & 0xFFFF);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jaguar_done(void)
{
+ fprintf(log_get(), "jaguar_done() ...START\n");
+#ifdef CPU_DEBUG
fprintf(log_get(), "jaguar: top of stack: %08X\n", jaguar_long_read(0x001FFFF8));
// fprintf(log_get(),"jaguar: cd bios version 0x%.4x\n",jaguar_word_read(0x3004));
// fprintf(log_get(),"jaguar: vbl interrupt is %s\n",((tom_irq_enabled(IRQ_VBLANK))&&(jaguar_interrupt_handler_is_valid(64)))?"enabled":"disabled");
s68000show_context();
+#endif
#ifdef SOUND_OUTPUT
ws_audio_done();
#endif
memory_free(jaguar_mainRom);
memory_free(jaguar_bootRom);
memory_free(jaguar_mainRam);
-// fprintf(log_get(),"jaguar_done()\n");
+ fprintf(log_get(), "jaguar_done() ...END\n");
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jaguar_reset(void)
{
// fprintf(log_get(),"jaguar_reset():\n");
m68k_pulse_reset(); // Reset the 68000
fprintf(log_get(), "\t68K PC=%06X SP=%08X\n", m68k_get_reg(NULL, M68K_REG_PC), m68k_get_reg(NULL, M68K_REG_A7));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jaguar_reset_handler(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jaguar_exec(int16 * backbuffer, uint8 render)
{
- int i;
- uint32 vblank_duration = tom_get_vdb();
+ uint32 i, vblank_duration = tom_get_vdb();
// vblank
if ((tom_irq_enabled(IRQ_VBLANK)) && (jaguar_interrupt_handler_is_valid(64)))
// Then again, since IRQ_VBLANK is set to zero, this would not be necessary in this case.
}
}
+
for(i=0; i<vblank_duration; i++)
{
/* uint32 invalid_instruction_address = s68000exec(m68k_cycles_per_scanline);
system_sound_update();
#endif
}
+
+// Temp debugging stuff
+
+void DumpMainMemory(void)
+{
+ FILE * fp = fopen("./memdump.bin", "wb");
+
+ if (fp == NULL)
+ return;
+
+ fwrite(jaguar_mainRam, 1, 0x400000, fp);
+// for(int i=0; i<0x400000; i++)
+// fprintf(fp, "%c", jaguar_mainRam[i]);
+// fputc(jaguar_mainRam[i], fp);
+
+ fclose(fp);
+}
+
+uint8 * GetRamPtr(void)
+{
+ return jaguar_mainRam;
+}
-/***************************************************************************
-
- Atari Jaguar hardware
-
-****************************************************************************
-
- ------------------------------------------------------------
- JERRY REGISTERS
- ------------------------------------------------------------
- F10000-F13FFF R/W xxxxxxxx xxxxxxxx Jerry
- F10000 W xxxxxxxx xxxxxxxx JPIT1 - timer 1 pre-scaler
- F10004 W xxxxxxxx xxxxxxxx JPIT2 - timer 1 divider
- F10008 W xxxxxxxx xxxxxxxx JPIT3 - timer 2 pre-scaler
- F1000C W xxxxxxxx xxxxxxxx JPIT4 - timer 2 divider
- F10010 W ------xx xxxxxxxx CLK1 - processor clock divider
- F10012 W ------xx xxxxxxxx CLK2 - video clock divider
- F10014 W -------- --xxxxxx CLK3 - chroma clock divider
- F10020 R/W ---xxxxx ---xxxxx JINTCTRL - interrupt control register
- W ---x---- -------- (J_SYNCLR - clear synchronous serial intf ints)
- W ----x--- -------- (J_ASYNCLR - clear asynchronous serial intf ints)
- W -----x-- -------- (J_TIM2CLR - clear timer 2 [tempo] interrupts)
- W ------x- -------- (J_TIM1CLR - clear timer 1 [sample] interrupts)
- W -------x -------- (J_EXTCLR - clear external interrupts)
- R/W -------- ---x---- (J_SYNENA - enable synchronous serial intf ints)
- R/W -------- ----x--- (J_ASYNENA - enable asynchronous serial intf ints)
- R/W -------- -----x-- (J_TIM2ENA - enable timer 2 [tempo] interrupts)
- R/W -------- ------x- (J_TIM1ENA - enable timer 1 [sample] interrupts)
- R/W -------- -------x (J_EXTENA - enable external interrupts)
- F10030 R/W -------- xxxxxxxx ASIDATA - asynchronous serial data
- F10032 W -x------ -xxxxxxx ASICTRL - asynchronous serial control
- W -x------ -------- (TXBRK - transmit break)
- W -------- -x------ (CLRERR - clear error)
- W -------- --x----- (RINTEN - enable receiver interrupts)
- W -------- ---x---- (TINTEN - enable transmitter interrupts)
- W -------- ----x--- (RXIPOL - receiver input polarity)
- W -------- -----x-- (TXOPOL - transmitter output polarity)
- W -------- ------x- (PAREN - parity enable)
- W -------- -------x (ODD - odd parity select)
- F10032 R xxx-xxxx x-xxxxxx ASISTAT - asynchronous serial status
- R x------- -------- (ERROR - OR of PE,FE,OE)
- R -x------ -------- (TXBRK - transmit break)
- R --x----- -------- (SERIN - serial input)
- R ----x--- -------- (OE - overrun error)
- R -----x-- -------- (FE - framing error)
- R ------x- -------- (PE - parity error)
- R -------x -------- (TBE - transmit buffer empty)
- R -------- x------- (RBF - receive buffer full)
- R -------- ---x---- (TINTEN - enable transmitter interrupts)
- R -------- ----x--- (RXIPOL - receiver input polarity)
- R -------- -----x-- (TXOPOL - transmitter output polarity)
- R -------- ------x- (PAREN - parity enable)
- R -------- -------x (ODD - odd parity)
- F10034 R/W xxxxxxxx xxxxxxxx ASICLK - asynchronous serial interface clock
- ------------------------------------------------------------
- F14000-F17FFF R/W xxxxxxxx xxxxxxxx Joysticks and GPIO0-5
- F14000 R xxxxxxxx xxxxxxxx JOYSTICK - read joystick state
- F14000 W x------- xxxxxxxx JOYSTICK - latch joystick output
- W x------- -------- (enable joystick outputs)
- W -------- xxxxxxxx (joystick output data)
- F14002 R xxxxxxxx xxxxxxxx JOYBUTS - button register
- F14800-F14FFF R/W xxxxxxxx xxxxxxxx GPI00 - reserved
- F15000-F15FFF R/W xxxxxxxx xxxxxxxx GPI01 - reserved
- F16000-F16FFF R/W xxxxxxxx xxxxxxxx GPI02 - reserved
- F17000-F177FF R/W xxxxxxxx xxxxxxxx GPI03 - reserved
- F17800-F17BFF R/W xxxxxxxx xxxxxxxx GPI04 - reserved
- F17C00-F17FFF R/W xxxxxxxx xxxxxxxx GPI05 - reserved
- ------------------------------------------------------------
- F18000-F1FFFF R/W xxxxxxxx xxxxxxxx Jerry DSP
- F1A100 R/W xxxxxxxx xxxxxxxx D_FLAGS - DSP flags register
- R/W x------- -------- (DMAEN - DMA enable)
- R/W -x------ -------- (REGPAGE - register page)
- W --x----- -------- (D_EXT0CLR - clear external interrupt 0)
- W ---x---- -------- (D_TIM2CLR - clear timer 2 interrupt)
- W ----x--- -------- (D_TIM1CLR - clear timer 1 interrupt)
- W -----x-- -------- (D_I2SCLR - clear I2S interrupt)
- W ------x- -------- (D_CPUCLR - clear CPU interrupt)
- R/W -------x -------- (D_EXT0ENA - enable external interrupt 0)
- R/W -------- x------- (D_TIM2ENA - enable timer 2 interrupt)
- R/W -------- -x------ (D_TIM1ENA - enable timer 1 interrupt)
- R/W -------- --x----- (D_I2SENA - enable I2S interrupt)
- R/W -------- ---x---- (D_CPUENA - enable CPU interrupt)
- R/W -------- ----x--- (IMASK - interrupt mask)
- R/W -------- -----x-- (NEGA_FLAG - ALU negative)
- R/W -------- ------x- (CARRY_FLAG - ALU carry)
- R/W -------- -------x (ZERO_FLAG - ALU zero)
- F1A102 R/W -------- ------xx D_FLAGS - upper DSP flags
- R/W -------- ------x- (D_EXT1ENA - enable external interrupt 1)
- R/W -------- -------x (D_EXT1CLR - clear external interrupt 1)
- F1A104 W -------- ----xxxx D_MTXC - matrix control register
- W -------- ----x--- (MATCOL - column/row major)
- W -------- -----xxx (MATRIX3-15 - matrix width)
- F1A108 W ----xxxx xxxxxx-- D_MTXA - matrix address register
- F1A10C W -------- -----x-x D_END - data organization register
- W -------- -----x-- (BIG_INST - big endian instruction fetch)
- W -------- -------x (BIG_IO - big endian I/O)
- F1A110 R/W xxxxxxxx xxxxxxxx D_PC - DSP program counter
- F1A114 R/W xxxxxxxx xx-xxxxx D_CTRL - DSP control/status register
- R xxxx---- -------- (VERSION - DSP version code)
- R/W ----x--- -------- (BUS_HOG - hog the bus!)
- R/W -----x-- -------- (D_EXT0LAT - external interrupt 0 latch)
- R/W ------x- -------- (D_TIM2LAT - timer 2 interrupt latch)
- R/W -------x -------- (D_TIM1LAT - timer 1 interrupt latch)
- R/W -------- x------- (D_I2SLAT - I2S interrupt latch)
- R/W -------- -x------ (D_CPULAT - CPU interrupt latch)
- R/W -------- ---x---- (SINGLE_GO - single step one instruction)
- R/W -------- ----x--- (SINGLE_STEP - single step mode)
- R/W -------- -----x-- (FORCEINT0 - cause interrupt 0 on GPU)
- R/W -------- ------x- (CPUINT - send GPU interrupt to CPU)
- R/W -------- -------x (DSPGO - enable DSP execution)
- F1A116 R/W -------- -------x D_CTRL - upper DSP control/status register
- R/W -------- -------x (D_EXT1LAT - external interrupt 1 latch)
- F1A118-F1A11B W xxxxxxxx xxxxxxxx D_MOD - modulo instruction mask
- F1A11C-F1A11F R xxxxxxxx xxxxxxxx D_REMAIN - divide unit remainder
- F1A11C W -------- -------x D_DIVCTRL - divide unit control
- W -------- -------x (DIV_OFFSET - 1=16.16 divide, 0=32-bit divide)
- F1A120-F1A123 R xxxxxxxx xxxxxxxx D_MACHI - multiply & accumulate high bits
- F1A148 W xxxxxxxx xxxxxxxx R_DAC - right transmit data
- F1A14C W xxxxxxxx xxxxxxxx L_DAC - left transmit data
- F1A150 W -------- xxxxxxxx SCLK - serial clock frequency
- F1A150 R -------- ------xx SSTAT
- R -------- ------x- (left - no description)
- R -------- -------x (WS - word strobe status)
- F1A154 W -------- --xxxx-x SMODE - serial mode
- W -------- --x----- (EVERYWORD - interrupt on MSB of every word)
- W -------- ---x---- (FALLING - interrupt on falling edge)
- W -------- ----x--- (RISING - interrupt of rising edge)
- W -------- -----x-- (WSEN - enable word strobes)
- W -------- -------x (INTERNAL - enables serial clock)
- ------------------------------------------------------------
- F1B000-F1CFFF R/W xxxxxxxx xxxxxxxx Local DSP RAM
- ------------------------------------------------------------
- F1D000 R xxxxxxxx xxxxxxxx ROM_TRI - triangle wave
- F1D200 R xxxxxxxx xxxxxxxx ROM_SINE - full sine wave
- F1D400 R xxxxxxxx xxxxxxxx ROM_AMSINE - amplitude modulated sine wave
- F1D600 R xxxxxxxx xxxxxxxx ROM_12W - sine wave and second order harmonic
- F1D800 R xxxxxxxx xxxxxxxx ROM_CHIRP16 - chirp
- F1DA00 R xxxxxxxx xxxxxxxx ROM_NTRI - traingle wave with noise
- F1DC00 R xxxxxxxx xxxxxxxx ROM_DELTA - spike
- F1DE00 R xxxxxxxx xxxxxxxx ROM_NOISE - white noise
- ------------------------------------------------------------
- F20000-FFFFFF R xxxxxxxx xxxxxxxx Bootstrap ROM
-
-****************************************************************************/
+//
+// JERRY Core
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+// ------------------------------------------------------------
+// JERRY REGISTERS (Mapped by Aaron Giles)
+// ------------------------------------------------------------
+// F10000-F13FFF R/W xxxxxxxx xxxxxxxx Jerry
+// F10000 W xxxxxxxx xxxxxxxx JPIT1 - timer 1 pre-scaler
+// F10004 W xxxxxxxx xxxxxxxx JPIT2 - timer 1 divider
+// F10008 W xxxxxxxx xxxxxxxx JPIT3 - timer 2 pre-scaler
+// F1000C W xxxxxxxx xxxxxxxx JPIT4 - timer 2 divider
+// F10010 W ------xx xxxxxxxx CLK1 - processor clock divider
+// F10012 W ------xx xxxxxxxx CLK2 - video clock divider
+// F10014 W -------- --xxxxxx CLK3 - chroma clock divider
+// F10020 R/W ---xxxxx ---xxxxx JINTCTRL - interrupt control register
+// W ---x---- -------- (J_SYNCLR - clear synchronous serial intf ints)
+// W ----x--- -------- (J_ASYNCLR - clear asynchronous serial intf ints)
+// W -----x-- -------- (J_TIM2CLR - clear timer 2 [tempo] interrupts)
+// W ------x- -------- (J_TIM1CLR - clear timer 1 [sample] interrupts)
+// W -------x -------- (J_EXTCLR - clear external interrupts)
+// R/W -------- ---x---- (J_SYNENA - enable synchronous serial intf ints)
+// R/W -------- ----x--- (J_ASYNENA - enable asynchronous serial intf ints)
+// R/W -------- -----x-- (J_TIM2ENA - enable timer 2 [tempo] interrupts)
+// R/W -------- ------x- (J_TIM1ENA - enable timer 1 [sample] interrupts)
+// R/W -------- -------x (J_EXTENA - enable external interrupts)
+// F10030 R/W -------- xxxxxxxx ASIDATA - asynchronous serial data
+// F10032 W -x------ -xxxxxxx ASICTRL - asynchronous serial control
+// W -x------ -------- (TXBRK - transmit break)
+// W -------- -x------ (CLRERR - clear error)
+// W -------- --x----- (RINTEN - enable receiver interrupts)
+// W -------- ---x---- (TINTEN - enable transmitter interrupts)
+// W -------- ----x--- (RXIPOL - receiver input polarity)
+// W -------- -----x-- (TXOPOL - transmitter output polarity)
+// W -------- ------x- (PAREN - parity enable)
+// W -------- -------x (ODD - odd parity select)
+// F10032 R xxx-xxxx x-xxxxxx ASISTAT - asynchronous serial status
+// R x------- -------- (ERROR - OR of PE,FE,OE)
+// R -x------ -------- (TXBRK - transmit break)
+// R --x----- -------- (SERIN - serial input)
+// R ----x--- -------- (OE - overrun error)
+// R -----x-- -------- (FE - framing error)
+// R ------x- -------- (PE - parity error)
+// R -------x -------- (TBE - transmit buffer empty)
+// R -------- x------- (RBF - receive buffer full)
+// R -------- ---x---- (TINTEN - enable transmitter interrupts)
+// R -------- ----x--- (RXIPOL - receiver input polarity)
+// R -------- -----x-- (TXOPOL - transmitter output polarity)
+// R -------- ------x- (PAREN - parity enable)
+// R -------- -------x (ODD - odd parity)
+// F10034 R/W xxxxxxxx xxxxxxxx ASICLK - asynchronous serial interface clock
+// ------------------------------------------------------------
+// F14000-F17FFF R/W xxxxxxxx xxxxxxxx Joysticks and GPIO0-5
+// F14000 R xxxxxxxx xxxxxxxx JOYSTICK - read joystick state
+// F14000 W x------- xxxxxxxx JOYSTICK - latch joystick output
+// W x------- -------- (enable joystick outputs)
+// W -------- xxxxxxxx (joystick output data)
+// F14002 R xxxxxxxx xxxxxxxx JOYBUTS - button register
+// F14800-F14FFF R/W xxxxxxxx xxxxxxxx GPI00 - reserved
+// F15000-F15FFF R/W xxxxxxxx xxxxxxxx GPI01 - reserved
+// F16000-F16FFF R/W xxxxxxxx xxxxxxxx GPI02 - reserved
+// F17000-F177FF R/W xxxxxxxx xxxxxxxx GPI03 - reserved
+// F17800-F17BFF R/W xxxxxxxx xxxxxxxx GPI04 - reserved
+// F17C00-F17FFF R/W xxxxxxxx xxxxxxxx GPI05 - reserved
+// ------------------------------------------------------------
+// F18000-F1FFFF R/W xxxxxxxx xxxxxxxx Jerry DSP
+// F1A100 R/W xxxxxxxx xxxxxxxx D_FLAGS - DSP flags register
+// R/W x------- -------- (DMAEN - DMA enable)
+// R/W -x------ -------- (REGPAGE - register page)
+// W --x----- -------- (D_EXT0CLR - clear external interrupt 0)
+// W ---x---- -------- (D_TIM2CLR - clear timer 2 interrupt)
+// W ----x--- -------- (D_TIM1CLR - clear timer 1 interrupt)
+// W -----x-- -------- (D_I2SCLR - clear I2S interrupt)
+// W ------x- -------- (D_CPUCLR - clear CPU interrupt)
+// R/W -------x -------- (D_EXT0ENA - enable external interrupt 0)
+// R/W -------- x------- (D_TIM2ENA - enable timer 2 interrupt)
+// R/W -------- -x------ (D_TIM1ENA - enable timer 1 interrupt)
+// R/W -------- --x----- (D_I2SENA - enable I2S interrupt)
+// R/W -------- ---x---- (D_CPUENA - enable CPU interrupt)
+// R/W -------- ----x--- (IMASK - interrupt mask)
+// R/W -------- -----x-- (NEGA_FLAG - ALU negative)
+// R/W -------- ------x- (CARRY_FLAG - ALU carry)
+// R/W -------- -------x (ZERO_FLAG - ALU zero)
+// F1A102 R/W -------- ------xx D_FLAGS - upper DSP flags
+// R/W -------- ------x- (D_EXT1ENA - enable external interrupt 1)
+// R/W -------- -------x (D_EXT1CLR - clear external interrupt 1)
+// F1A104 W -------- ----xxxx D_MTXC - matrix control register
+// W -------- ----x--- (MATCOL - column/row major)
+// W -------- -----xxx (MATRIX3-15 - matrix width)
+// F1A108 W ----xxxx xxxxxx-- D_MTXA - matrix address register
+// F1A10C W -------- -----x-x D_END - data organization register
+// W -------- -----x-- (BIG_INST - big endian instruction fetch)
+// W -------- -------x (BIG_IO - big endian I/O)
+// F1A110 R/W xxxxxxxx xxxxxxxx D_PC - DSP program counter
+// F1A114 R/W xxxxxxxx xx-xxxxx D_CTRL - DSP control/status register
+// R xxxx---- -------- (VERSION - DSP version code)
+// R/W ----x--- -------- (BUS_HOG - hog the bus!)
+// R/W -----x-- -------- (D_EXT0LAT - external interrupt 0 latch)
+// R/W ------x- -------- (D_TIM2LAT - timer 2 interrupt latch)
+// R/W -------x -------- (D_TIM1LAT - timer 1 interrupt latch)
+// R/W -------- x------- (D_I2SLAT - I2S interrupt latch)
+// R/W -------- -x------ (D_CPULAT - CPU interrupt latch)
+// R/W -------- ---x---- (SINGLE_GO - single step one instruction)
+// R/W -------- ----x--- (SINGLE_STEP - single step mode)
+// R/W -------- -----x-- (FORCEINT0 - cause interrupt 0 on GPU)
+// R/W -------- ------x- (CPUINT - send GPU interrupt to CPU)
+// R/W -------- -------x (DSPGO - enable DSP execution)
+// F1A116 R/W -------- -------x D_CTRL - upper DSP control/status register
+// R/W -------- -------x (D_EXT1LAT - external interrupt 1 latch)
+// F1A118-F1A11B W xxxxxxxx xxxxxxxx D_MOD - modulo instruction mask
+// F1A11C-F1A11F R xxxxxxxx xxxxxxxx D_REMAIN - divide unit remainder
+// F1A11C W -------- -------x D_DIVCTRL - divide unit control
+// W -------- -------x (DIV_OFFSET - 1=16.16 divide, 0=32-bit divide)
+// F1A120-F1A123 R xxxxxxxx xxxxxxxx D_MACHI - multiply & accumulate high bits
+// F1A148 W xxxxxxxx xxxxxxxx R_DAC - right transmit data
+// F1A14C W xxxxxxxx xxxxxxxx L_DAC - left transmit data
+// F1A150 W -------- xxxxxxxx SCLK - serial clock frequency
+// F1A150 R -------- ------xx SSTAT
+// R -------- ------x- (left - no description)
+// R -------- -------x (WS - word strobe status)
+// F1A154 W -------- --xxxx-x SMODE - serial mode
+// W -------- --x----- (EVERYWORD - interrupt on MSB of every word)
+// W -------- ---x---- (FALLING - interrupt on falling edge)
+// W -------- ----x--- (RISING - interrupt of rising edge)
+// W -------- -----x-- (WSEN - enable word strobes)
+// W -------- -------x (INTERNAL - enables serial clock)
+// ------------------------------------------------------------
+// F1B000-F1CFFF R/W xxxxxxxx xxxxxxxx Local DSP RAM
+// ------------------------------------------------------------
+// F1D000 R xxxxxxxx xxxxxxxx ROM_TRI - triangle wave
+// F1D200 R xxxxxxxx xxxxxxxx ROM_SINE - full sine wave
+// F1D400 R xxxxxxxx xxxxxxxx ROM_AMSINE - amplitude modulated sine wave
+// F1D600 R xxxxxxxx xxxxxxxx ROM_12W - sine wave and second order harmonic
+// F1D800 R xxxxxxxx xxxxxxxx ROM_CHIRP16 - chirp
+// F1DA00 R xxxxxxxx xxxxxxxx ROM_NTRI - traingle wave with noise
+// F1DC00 R xxxxxxxx xxxxxxxx ROM_DELTA - spike
+// F1DE00 R xxxxxxxx xxxxxxxx ROM_NOISE - white noise
+// ------------------------------------------------------------
#include "jerry.h"
#include "wavetable.h"
static uint8 * jerry_ram_8;
//static uint16 *jerry_ram_16;
-static uint8 * jerry_wave_rom;
+//static uint8 * jerry_wave_rom;
//#define JERRY_CONFIG jerry_ram_16[0x4002>>1]
static int32 jerry_i2s_interrupt_timer = -1;
static int32 jerry_i2s_interrupt_cycles_per_scanline = 0;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_i2s_exec(uint32 cycles)
{
jerry_i2s_interrupt_divide &= 0xFF;
jerry_i2s_interrupt_timer += jerry_i2s_interrupt_cycles_per_scanline;
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_reset_i2s_timer(void)
{
//fprintf(log_get(),"i2s: reseting\n");
- jerry_i2s_interrupt_divide=8;
- jerry_i2s_interrupt_timer=-1;
+ jerry_i2s_interrupt_divide = 8;
+ jerry_i2s_interrupt_timer = -1;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_reset_timer_1(void)
{
- if ((!jerry_timer_1_prescaler)||(!jerry_timer_1_divider))
- jerry_timer_1_counter=0;
+ if (!jerry_timer_1_prescaler || !jerry_timer_1_divider)
+ jerry_timer_1_counter = 0;
else
- jerry_timer_1_counter=(1+jerry_timer_1_prescaler)*(1+jerry_timer_1_divider);
+ jerry_timer_1_counter = (1 + jerry_timer_1_prescaler) * (1 + jerry_timer_1_divider);
// if (jerry_timer_1_counter)
// fprintf(log_get(),"jerry: reseting timer 1 to 0x%.8x (%i)\n",jerry_timer_1_counter,jerry_timer_1_counter);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_reset_timer_2(void)
{
- if ((!jerry_timer_2_prescaler)||(!jerry_timer_2_divider))
+ if (!jerry_timer_2_prescaler || !jerry_timer_2_divider)
{
- jerry_timer_2_counter=0;
+ jerry_timer_2_counter = 0;
return;
}
else
- jerry_timer_2_counter=((1+jerry_timer_2_prescaler)*(1+jerry_timer_2_divider));
+ jerry_timer_2_counter = ((1 + jerry_timer_2_prescaler) * (1 + jerry_timer_2_divider));
// if (jerry_timer_2_counter)
// fprintf(log_get(),"jerry: reseting timer 2 to 0x%.8x (%i)\n",jerry_timer_2_counter,jerry_timer_2_counter);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_pit_exec(uint32 cycles)
{
if (jerry_timer_1_counter)
- jerry_timer_1_counter-=cycles;
+ jerry_timer_1_counter -= cycles;
- if (jerry_timer_1_counter<=0)
+ if (jerry_timer_1_counter <= 0)
{
- dsp_set_irq_line(2,1);
+ dsp_set_irq_line(2, 1);
jerry_reset_timer_1();
}
if (jerry_timer_2_counter)
- jerry_timer_2_counter-=cycles;
+ jerry_timer_2_counter -= cycles;
- if (jerry_timer_2_counter<=0)
+ if (jerry_timer_2_counter <= 0)
{
- dsp_set_irq_line(3,1);
+ dsp_set_irq_line(3, 1);
jerry_reset_timer_2();
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_wave_rom_init(void)
{
- memory_malloc_secure((void **)&jerry_wave_rom, 0x1000, "jerry wave rom");
- uint32 * jaguar_wave_rom_32 = (uint32 *)jerry_wave_rom;
-
-/* for (i = 0; i < 0x80; i++)
- {
- // F1D000 = triangle wave
- jaguar_wave_rom_32[0x000 + i] = ((i <= 0x40) ? i : 0x80 - i) * 32767 / 0x40;
-
- // F1D200 = full sine wave
- jaguar_wave_rom_32[0x080 + i] = (int)(32767. * sin(2.0 * 3.1415927 * (double)i / (double)0x80));
-
- // F1D400 = amplitude modulated sine wave?
- jaguar_wave_rom_32[0x100 + i] = (int)(32767. * sin(2.0 * 3.1415927 * (double)i / (double)0x80));
-
- // F1D600 = sine wave and second order harmonic
- jaguar_wave_rom_32[0x180 + i] = (int)(32767. * sin(2.0 * 3.1415927 * (double)i / (double)0x80));
+// memory_malloc_secure((void **)&jerry_wave_rom, 0x1000, "jerry wave rom");
+// uint32 * jaguar_wave_rom_32 = (uint32 *)jerry_wave_rom;
- // F1D800 = chirp (sine wave of increasing frequency)
- jaguar_wave_rom_32[0x200 + i] = (int)(32767. * sin(2.0 * 3.1415927 * (double)i / (double)0x80));
-
- // F1DA00 = traingle wave with noise
- jaguar_wave_rom_32[0x280 + i] = jaguar_wave_rom_32[0x000 + i] * (rand() % 32768) / 32768;
-
- // F1DC00 = spike
- jaguar_wave_rom_32[0x300 + i] = (i == 0x40) ? 32767 : 0;
-
- // F1DE00 = white noise
- jaguar_wave_rom_32[0x380 + i] = rand() % 32768;
- }
- */
// use real wave table dump
-// Looks like this WT dump is in the wrong endian...
- memcpy(jerry_wave_rom, wave_table, 0x1000);
+// JLH: Looks like this WT dump is in the wrong endian (For the Jaguar, that is)...
+// memcpy(jerry_wave_rom, wave_table, 0x1000);
// reverse byte ordering
-// Actually, this does nothing...
- for(int i=0; i<0x400; i++)
+// JLH: Actually, this does nothing...
+/* for(int i=0; i<0x400; i++)
{
uint32 data = jaguar_wave_rom_32[i];
- data = ((data&0xff000000)>>24)|((data&0x0000ff00)<<8)|
- ((data&0x00ff0000)>>8) |((data&0x000000ff)<<24);
- }
+ data = ((data & 0xFF000000) >> 24) | ((data & 0x0000FF00) << 8)
+ | ((data & 0x00FF0000) >> 8) | ((data & 0x000000FF) << 24);
+ }*/
+// Why the need for an extra buffer to hold it, when it already exists in the form of wave_table???
+// Also, there was a memory leak, since it was never deallocated... (jerry_wave_rom)
- // copy it to dsp ram
- memcpy(&jerry_ram_8[0xD000], jerry_wave_rom, 0x1000);
+ // Copy it to DSP RAM
+//WAS: memcpy(&jerry_ram_8[0xD000], jerry_wave_rom, 0x1000);
+ memcpy(&jerry_ram_8[0xD000], wave_table, 0x1000);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_init(void)
{
//fprintf(log_get(),"jerry_init()\n");
// jerry_ram_16 = (uint16 *)jerry_ram_8;
jerry_wave_rom_init();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_reset(void)
{
//fprintf(log_get(),"jerry_reset()\n");
jerry_timer_2_counter = 0;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_done(void)
{
//fprintf(log_get(),"jerry_done()\n");
joystick_done();
eeprom_done();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
+
//
+// JERRY byte access (read)
//
-//////////////////////////////////////////////////////////////////////////////
+
unsigned jerry_byte_read(unsigned int offset)
{
#ifdef JERRY_DEBUG
#endif
if ((offset >= dsp_control_ram_base) && (offset < dsp_control_ram_base+0x20))
return dsp_byte_read(offset);
-
- if ((offset >= dsp_work_ram_base) && (offset < dsp_work_ram_base+0x2000))
+ else if ((offset >= dsp_work_ram_base) && (offset < dsp_work_ram_base+0x2000))
return dsp_byte_read(offset);
-
- if ((offset >= 0xF10000) && (offset <= 0xF10007))
+ else if ((offset >= 0xF10000) && (offset <= 0xF10007))
{
switch(offset & 0x07)
{
- case 0: return(jerry_timer_1_prescaler>>8);
- case 1: return(jerry_timer_1_prescaler&0xff);
- case 2: return(jerry_timer_1_divider>>8);
- case 3: return(jerry_timer_1_divider&0xff);
- case 4: return(jerry_timer_2_prescaler>>8);
- case 5: return(jerry_timer_2_prescaler&0xff);
- case 6: return(jerry_timer_2_divider>>8);
- case 7: return(jerry_timer_2_divider&0xff);
+ case 0:
+ return jerry_timer_1_prescaler >> 8;
+ case 1:
+ return jerry_timer_1_prescaler & 0xFF;
+ case 2:
+ return jerry_timer_1_divider >> 8;
+ case 3:
+ return jerry_timer_1_divider & 0xFF;
+ case 4:
+ return jerry_timer_2_prescaler >> 8;
+ case 5:
+ return jerry_timer_2_prescaler & 0xFF;
+ case 6:
+ return jerry_timer_2_divider >> 8;
+ case 7:
+ return jerry_timer_2_divider & 0xFF;
}
}
-
- if ((offset>=0xf10010)&&(offset<0xf10016))
- return(clock_byte_read(offset));
-
- if ((offset>=0xf17c00)&&(offset<0xf17c02))
- return(anajoy_byte_read(offset));
-
- if ((offset>=0xf14000)&&(offset<=0xf14003))
+ else if ((offset >= 0xF10010) && (offset <= 0xf10015))
+ return clock_byte_read(offset);
+ else if ((offset >= 0xF17C00) && (offset <= 0xF17C01))
+ return anajoy_byte_read(offset);
+ else if ((offset >= 0xF14000) && (offset <= 0xF14003))
{
- return(joystick_byte_read(offset)|eeprom_byte_read(offset));
+ return joystick_byte_read(offset) | eeprom_byte_read(offset);
}
-
- if ((offset >= 0xF14000) && (offset <= 0xF1A0FF))
- return(eeprom_byte_read(offset));
+ else if ((offset >= 0xF14000) && (offset <= 0xF1A0FF))
+ return eeprom_byte_read(offset);
return jerry_ram_8[offset & 0xFFFF];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
+
//
+// JERRY word access (read)
//
-//////////////////////////////////////////////////////////////////////////////
+
unsigned jerry_word_read(unsigned int offset)
{
#ifdef JERRY_DEBUG
fprintf(log_get(),"jerry: reading word at 0x%.6x\n",offset);
#endif
- if ((offset>=dsp_control_ram_base)&&(offset<dsp_control_ram_base+0x20))
- return(dsp_word_read(offset));
-
- if ((offset>=dsp_work_ram_base)&&(offset<dsp_work_ram_base+0x2000))
- return(dsp_word_read(offset));
- if ((offset>=0xf10000)&&(offset<=0xf10007))
+ if ((offset >= dsp_control_ram_base) && (offset < dsp_control_ram_base+0x20))
+ return dsp_word_read(offset);
+ else if ((offset >= dsp_work_ram_base) && (offset < dsp_work_ram_base+0x2000))
+ return dsp_word_read(offset);
+ else if ((offset >= 0xF10000) && (offset <= 0xF10007))
{
- switch(offset&0x07)
+ switch(offset & 0x07)
{
- case 0: return(jerry_timer_1_prescaler);
- case 2: return(jerry_timer_1_divider);
- case 4: return(jerry_timer_2_prescaler);
- case 6: return(jerry_timer_2_divider);
+ case 0:
+ return jerry_timer_1_prescaler;
+ case 2:
+ return jerry_timer_1_divider;
+ case 4:
+ return jerry_timer_2_prescaler;
+ case 6:
+ return jerry_timer_2_divider;
}
+ // Unaligned word reads???
}
-
- if ((offset>=0xf10010)&&(offset<0xf10016))
- return(clock_word_read(offset));
-
- if (offset==0xF10020)
- return(0x00);
-
- if ((offset>=0xf17c00)&&(offset<0xf17c02))
- return(anajoy_word_read(offset));
-
- if (offset==0xf14000)
+ else if ((offset >= 0xF10010) && (offset <= 0xF10015))
+ return clock_word_read(offset);
+ else if (offset == 0xF10020)
+ return 0x00;
+ else if ((offset >= 0xF17C00) && (offset <= 0xF17C01))
+ return anajoy_word_read(offset);
+ else if (offset == 0xF14000)
{
- uint16 dta=(joystick_word_read(offset)&0xfffe)|eeprom_word_read(offset);
//fprintf(log_get(),"reading 0x%.4x from 0xf14000\n");
- return(dta);
+ return (joystick_word_read(offset) & 0xFFFE) | eeprom_word_read(offset);
}
- if ((offset>=0xf14002)&&(offset<0xf14003))
- return(joystick_word_read(offset));
-
- if ((offset>=0xf14000)&&(offset<=0xF1A0FF))
- return(eeprom_word_read(offset));
-
-
+ else if ((offset >= 0xF14002) && (offset < 0xF14003))
+ return joystick_word_read(offset);
+ else if ((offset >= 0xF14000) && (offset <= 0xF1A0FF))
+ return eeprom_word_read(offset);
- offset&=0xffff;
+// This is never executed!
+/* offset &= 0xFFFF;
if (offset==0x4002)
- return(0xffff);
-
+ return(0xffff);*/
- uint16 data=jerry_ram_8[offset+0];
- data<<=8;
- data|=jerry_ram_8[offset+1];
- return(data);
+/* uint16 data = jerry_ram_8[offset+0];
+ data <<= 8;
+ data |= jerry_ram_8[offset+1];
+ return data;*/
+ return ((uint16)jerry_ram_8[offset+0] << 8) | jerry_ram_8[offset+1];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
+
//
+// JERRY byte access (write)
//
-//////////////////////////////////////////////////////////////////////////////
-void jerry_byte_write(unsigned offset, unsigned data)
+
+void jerry_byte_write(unsigned offset, unsigned data)
{
#ifdef JERRY_DEBUG
fprintf(log_get(),"jerry: writing byte %.2x at 0x%.6x\n",data,offset);
#endif
- if ((offset>=dsp_control_ram_base)&&(offset<dsp_control_ram_base+0x20))
+ if ((offset >= dsp_control_ram_base) && (offset < dsp_control_ram_base+0x20))
{
- dsp_byte_write(offset,data);
+ dsp_byte_write(offset, data);
return;
}
- if ((offset>=dsp_work_ram_base)&&(offset<dsp_work_ram_base+0x2000))
+ else if ((offset >= dsp_work_ram_base) && (offset < dsp_work_ram_base+0x2000))
{
- dsp_byte_write(offset,data);
+ dsp_byte_write(offset, data);
return;
}
-
- if ((offset>=0xf1a152)&&(offset<0xf1a154))
+ else if ((offset >= 0xF1A152) && (offset <= 0xF1A153))
{
// fprintf(log_get(),"i2s: writing 0x%.2x to SCLK\n",data);
- if ((offset&0x03)==2)
- jerry_i2s_interrupt_divide=(jerry_i2s_interrupt_divide&0x00ff)|(((uint32)data)<<8);
+ if ((offset & 0x03) == 2)
+ jerry_i2s_interrupt_divide = (jerry_i2s_interrupt_divide & 0x00FF) | ((uint32)data << 8);
else
- jerry_i2s_interrupt_divide=(jerry_i2s_interrupt_divide&0xff00)|((uint32)data);
+ jerry_i2s_interrupt_divide = (jerry_i2s_interrupt_divide & 0xFF00) | (uint32)data;
- jerry_i2s_interrupt_timer=-1;
+ jerry_i2s_interrupt_timer = -1;
jerry_i2s_exec(0);
+ return;
}
- if ((offset>=0xf10000)&&(offset<=0xf10007))
+ else if ((offset >= 0xF10000) && (offset <= 0xF10007))
{
- switch(offset&0x07)
+ switch(offset & 0x07)
{
- case 0: { jerry_timer_1_prescaler=(jerry_timer_1_prescaler&0x00ff)|(data<<8); jerry_reset_timer_1(); return; }
+ case 0:
+ jerry_timer_1_prescaler = (jerry_timer_1_prescaler & 0x00FF) | (data << 8);
+ jerry_reset_timer_1();
+ break;
case 1: { jerry_timer_1_prescaler=(jerry_timer_1_prescaler&0xff00)|(data); jerry_reset_timer_1(); return; }
case 2: { jerry_timer_1_divider=(jerry_timer_1_divider&0x00ff)|(data<<8); jerry_reset_timer_1(); return; }
case 3: { jerry_timer_1_divider=(jerry_timer_1_divider&0xff00)|(data); jerry_reset_timer_1(); return; }
case 6: { jerry_timer_2_divider=(jerry_timer_2_divider&0x00ff)|(data<<8); jerry_reset_timer_2(); return; }
case 7: { jerry_timer_2_divider=(jerry_timer_2_divider&0xff00)|(data); jerry_reset_timer_2(); return; }
}
+ return;
}
-
-
- if ((offset>=0xf10010)&&(offset<0xf10016))
+ else if ((offset >= 0xF10010) && (offset <= 0xF10015))
{
- clock_byte_write(offset,data);
+ clock_byte_write(offset, data);
return;
}
- if ((offset>=0xf17c00)&&(offset<0xf17c02))
+ else if ((offset >= 0xF17C00) && (offset <= 0xF17C01))
{
- anajoy_byte_write(offset,data);
+ anajoy_byte_write(offset, data);
return;
}
- if ((offset>=0xf14000)&&(offset<0xf14003))
+ else if ((offset >= 0xF14000) && (offset <= 0xF14003))
{
- joystick_byte_write(offset,data);
- eeprom_byte_write(offset,data);
+ joystick_byte_write(offset, data);
+ eeprom_byte_write(offset, data);
return;
}
- if ((offset>=0xf14000)&&(offset<=0xF1A0FF))
+ else if ((offset >= 0xF14000) && (offset <= 0xF1A0FF))
{
- eeprom_byte_write(offset,data);
+ eeprom_byte_write(offset, data);
return;
}
- offset&=0xffff;
- jerry_ram_8[offset]=data;
+
+ jerry_ram_8[offset & 0xFFFF] = data;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
+
//
+// JERRY word access (write)
//
-//////////////////////////////////////////////////////////////////////////////
+
void jerry_word_write(unsigned offset, unsigned data)
{
#ifdef JERRY_DEBUG
dsp_word_write(offset, data);
return;
}
- if ((offset >=dsp_work_ram_base) && (offset < dsp_work_ram_base+0x2000))
+ else if ((offset >= dsp_work_ram_base) && (offset < dsp_work_ram_base+0x2000))
{
dsp_word_write(offset, data);
return;
}
- if (offset == 0xF1A152)
+ else if (offset == 0xF1A152)
{
// fprintf(log_get(),"i2s: writing 0x%.4x to SCLK\n",data);
jerry_i2s_interrupt_divide = data & 0xFF;
jerry_i2s_interrupt_timer = -1;
jerry_i2s_exec(0);
}
-
- if ((offset >= 0xF10000) && (offset <= 0xF10007))
+ else if ((offset >= 0xF10000) && (offset <= 0xF10007))
{
switch(offset & 0x07)
{
- case 0: { jerry_timer_1_prescaler=data; jerry_reset_timer_1(); return; }
- case 2: { jerry_timer_1_divider=data; jerry_reset_timer_1(); return; }
- case 4: { jerry_timer_2_prescaler=data; jerry_reset_timer_2(); return; }
- case 6: { jerry_timer_2_divider=data; jerry_reset_timer_2(); return; }
+ case 0:
+ jerry_timer_1_prescaler = data;
+ jerry_reset_timer_1();
+ break;
+ case 2:
+ jerry_timer_1_divider = data;
+ jerry_reset_timer_1();
+ break;
+ case 4:
+ jerry_timer_2_prescaler = data;
+ jerry_reset_timer_2();
+ break;
+ case 6:
+ jerry_timer_2_divider = data;
+ jerry_reset_timer_2();
}
+ // Need to handle (unaligned) cases???
+ return;
}
-
- if ((offset >= 0xF1A148) && (offset < 0xF1A150))
+ else if ((offset >= 0xF1A148) && (offset < 0xF1A150))
{
- pcm_word_write(offset-0xF1A148, data);
+ pcm_word_write(offset - 0xF1A148, data);
return;
}
-
- if ((offset >= 0xF10010) && (offset < 0xF10016))
+ else if ((offset >= 0xF10010) && (offset < 0xF10016))
{
clock_word_write(offset, data);
return;
}
- if ((offset >= 0xf17C00) && (offset < 0xF17C02))
+ else if ((offset >= 0xF17C00) && (offset < 0xF17C02))
{
anajoy_word_write(offset, data);
return;
}
- if ((offset >= 0xF14000) && (offset < 0xF14003))
+ else if ((offset >= 0xF14000) && (offset < 0xF14003))
{
joystick_word_write(offset, data);
eeprom_word_write(offset, data);
return;
}
- if ((offset >= 0xF14000) && (offset <= 0xF1A0FF))
+ else if ((offset >= 0xF14000) && (offset <= 0xF1A0FF))
{
- eeprom_word_write(offset,data);
+ eeprom_word_write(offset, data);
return;
}
jerry_ram_8[(offset+0) & 0xFFFF] = (data >> 8) & 0xFF;
jerry_ram_8[(offset+1) & 0xFFFF] = data & 0xFF;
-
}
+//
+// Joystick handler
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+
#ifndef __PORT__
#include "include/stdafx.h"
#include <mmsystem.h>
#endif
#include <time.h>
#include <SDL.h>
-#include "include/SDLptc.h"
-#include "include/jaguar.h"
+#include "SDLptc.h"
+#include "jaguar.h"
void main_screen_switch(void);
-
#define BUTTON_U 0
#define BUTTON_D 1
#define BUTTON_L 2
extern uint8 finished;
extern int start_logging;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void joystick_init(void)
{
joystick_reset();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void joystick_exec(void)
{
-
- uint8 *keystate = SDL_GetKeyState(NULL);
- Sint16 x = 0, y = 0;
- extern Console console;
+ uint8 * keystate = SDL_GetKeyState(NULL);
+ extern Console console;
- memset(joypad_0_buttons,0,21);
- memset(joypad_1_buttons,0,21);
+ memset(joypad_0_buttons, 0, 21);
+ memset(joypad_1_buttons, 0, 21);
- if ((keystate[SDLK_LALT])&(keystate[SDLK_RETURN])) main_screen_switch();
+ if ((keystate[SDLK_LALT]) & (keystate[SDLK_RETURN]))
+ main_screen_switch();
/* Added/Changed by SDLEMU (http://sdlemu.ngemu.com) */
- if (keystate[SDLK_UP]) joypad_0_buttons[BUTTON_U]=0x01;
- if (keystate[SDLK_DOWN]) joypad_0_buttons[BUTTON_D]=0x01;
- if (keystate[SDLK_LEFT]) joypad_0_buttons[BUTTON_L]=0x01;
- if (keystate[SDLK_RIGHT]) joypad_0_buttons[BUTTON_R]=0x01;
- if (keystate[SDLK_z]) joypad_0_buttons[BUTTON_A]=0x01;
- if (keystate[SDLK_x]) joypad_0_buttons[BUTTON_B]=0x01;
- if (keystate[SDLK_c]) joypad_0_buttons[BUTTON_C]=0x01;
- if (keystate[SDLK_TAB]) joypad_0_buttons[BUTTON_OPTION]=0x01;
- if (keystate[SDLK_RETURN]) joypad_0_buttons[BUTTON_PAUSE]=0x01;
- if (keystate[SDLK_q]) start_logging=1;
- if (keystate[SDLK_w]) gpu_reset_stats();
-//f (keystate[SDLK_u]) jaguar_long_write(0xf1c384,jaguar_long_read(0xf1c384)+1);
+ if (keystate[SDLK_UP]) joypad_0_buttons[BUTTON_U] = 0x01;
+ if (keystate[SDLK_DOWN]) joypad_0_buttons[BUTTON_D] = 0x01;
+ if (keystate[SDLK_LEFT]) joypad_0_buttons[BUTTON_L] = 0x01;
+ if (keystate[SDLK_RIGHT]) joypad_0_buttons[BUTTON_R] = 0x01;
+ if (keystate[SDLK_z]) joypad_0_buttons[BUTTON_A] = 0x01;
+ if (keystate[SDLK_x]) joypad_0_buttons[BUTTON_B] = 0x01;
+ if (keystate[SDLK_c]) joypad_0_buttons[BUTTON_C] = 0x01;
+ if (keystate[SDLK_TAB]) joypad_0_buttons[BUTTON_OPTION] = 0x01;
+ if (keystate[SDLK_RETURN]) joypad_0_buttons[BUTTON_PAUSE] = 0x01;
+ if (keystate[SDLK_q])
+ start_logging = 1;
+ if (keystate[SDLK_w])
+ gpu_reset_stats();
+// if (keystate[SDLK_u]) jaguar_long_write(0xf1c384,jaguar_long_read(0xf1c384)+1);
+ if (keystate[SDLK_d])
+ DumpMainMemory();
+
+ if (keystate[SDLK_KP0]) joypad_0_buttons[BUTTON_0] = 0x01;
+ if (keystate[SDLK_KP1]) joypad_0_buttons[BUTTON_1] = 0x01;
+ if (keystate[SDLK_KP2]) joypad_0_buttons[BUTTON_2] = 0x01;
+ if (keystate[SDLK_KP3]) joypad_0_buttons[BUTTON_3] = 0x01;
+ if (keystate[SDLK_KP4]) joypad_0_buttons[BUTTON_4] = 0x01;
+ if (keystate[SDLK_KP5]) joypad_0_buttons[BUTTON_5] = 0x01;
+ if (keystate[SDLK_KP6]) joypad_0_buttons[BUTTON_6] = 0x01;
+ if (keystate[SDLK_KP7]) joypad_0_buttons[BUTTON_7] = 0x01;
+ if (keystate[SDLK_KP8]) joypad_0_buttons[BUTTON_8] = 0x01;
+ if (keystate[SDLK_KP9]) joypad_0_buttons[BUTTON_9] = 0x01;
+
+ if (keystate[SDLK_ESCAPE])
+ finished = 1;
- if (keystate[SDLK_KP0]) joypad_0_buttons[BUTTON_0]=0x01;
- if (keystate[SDLK_KP1]) joypad_0_buttons[BUTTON_1]=0x01;
- if (keystate[SDLK_KP2]) joypad_0_buttons[BUTTON_2]=0x01;
- if (keystate[SDLK_KP3]) joypad_0_buttons[BUTTON_3]=0x01;
- if (keystate[SDLK_KP4]) joypad_0_buttons[BUTTON_4]=0x01;
- if (keystate[SDLK_KP5]) joypad_0_buttons[BUTTON_5]=0x01;
- if (keystate[SDLK_KP6]) joypad_0_buttons[BUTTON_6]=0x01;
- if (keystate[SDLK_KP7]) joypad_0_buttons[BUTTON_7]=0x01;
- if (keystate[SDLK_KP8]) joypad_0_buttons[BUTTON_8]=0x01;
- if (keystate[SDLK_KP9]) joypad_0_buttons[BUTTON_9]=0x01;
-
- if (keystate[SDLK_ESCAPE]) finished=1;
-
/* Added/Changed by SDLEMU (http://sdlemu.ngemu.com */
/* Joystick support */
- if ( console.JoyEnabled() == 1 ) {
-
- x = SDL_JoystickGetAxis(console.joystick, 0);
- y = SDL_JoystickGetAxis(console.joystick, 1);
+ if (console.JoyEnabled() == 1)
+ {
+ int16 x = SDL_JoystickGetAxis(console.joystick, 0),
+ y = SDL_JoystickGetAxis(console.joystick, 1);
- if ( x > 16384 ) joypad_0_buttons[BUTTON_R]=0x01;
- if ( x < -16384 ) joypad_0_buttons[BUTTON_L]=0x01;
- if ( y > 16384 ) joypad_0_buttons[BUTTON_D]=0x01;
- if ( y < -16384 ) joypad_0_buttons[BUTTON_U]=0x01;
+ if (x > 16384)
+ joypad_0_buttons[BUTTON_R] = 0x01;
+ if (x < -16384)
+ joypad_0_buttons[BUTTON_L] = 0x01;
+ if (y > 16384)
+ joypad_0_buttons[BUTTON_D] = 0x01;
+ if (y < -16384)
+ joypad_0_buttons[BUTTON_U] = 0x01;
- if (SDL_JoystickGetButton(console.joystick, 0) == SDL_PRESSED) joypad_0_buttons[BUTTON_A]=0x01;
- if (SDL_JoystickGetButton(console.joystick, 1) == SDL_PRESSED) joypad_0_buttons[BUTTON_B]=0x01;
- if (SDL_JoystickGetButton(console.joystick, 2) == SDL_PRESSED) joypad_0_buttons[BUTTON_C]=0x01;
-
+ if (SDL_JoystickGetButton(console.joystick, 0) == SDL_PRESSED)
+ joypad_0_buttons[BUTTON_A] = 0x01;
+ if (SDL_JoystickGetButton(console.joystick, 1) == SDL_PRESSED)
+ joypad_0_buttons[BUTTON_B] = 0x01;
+ if (SDL_JoystickGetButton(console.joystick, 2) == SDL_PRESSED)
+ joypad_0_buttons[BUTTON_C] = 0x01;
}
/* ADDED by SDLEMU (http://sdlemu.ngemu.com */
/* Needed to make sure that the events queue is empty */
SDL_PumpEvents();
-
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void joystick_reset(void)
{
- memset(joystick_ram,0x00,4);
- memset(joypad_0_buttons,0,21);
- memset(joypad_1_buttons,0,21);
+ memset(joystick_ram, 0x00, 4);
+ memset(joypad_0_buttons, 0, 21);
+ memset(joypad_1_buttons, 0, 21);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void joystick_done(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void joystick_byte_write(uint32 offset, uint8 data)
{
- joystick_ram[offset&0x03]=data;
+ joystick_ram[offset&0x03] = data;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void joystick_word_write(uint32 offset, uint16 data)
{
- offset&=0x03;
- joystick_ram[offset+0]=(data>>8)&0xff;
- joystick_ram[offset+1]=data&0xff;
+ offset &= 0x03;
+ joystick_ram[offset+0] = (data >> 8) & 0xFF;
+ joystick_ram[offset+1] = data & 0xFF;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint8 joystick_byte_read(uint32 offset)
{
- offset&=0x03;
+ offset &= 0x03;
- if (offset==0)
+ if (offset == 0)
{
- uint8 data=0x00;
- int pad0Index=joystick_ram[1]&0x0f;
- int pad1Index=(joystick_ram[1]>>4)&0x0f;
+ uint8 data = 0x00;
+ int pad0Index = joystick_ram[1] & 0x0F;
+ int pad1Index = (joystick_ram[1] >> 4) & 0x0F;
- if (!(pad0Index&0x01))
- pad0Index=0;
- else
- if (!(pad0Index&0x02))
- pad0Index=1;
- else
- if (!(pad0Index&0x04))
- pad0Index=2;
- else
- pad0Index=3;
+ if (!(pad0Index & 0x01))
+ pad0Index = 0;
+ else if (!(pad0Index & 0x02))
+ pad0Index = 1;
+ else if (!(pad0Index & 0x04))
+ pad0Index = 2;
+ else
+ pad0Index = 3;
- if (!(pad1Index&0x01))
- pad1Index=0;
+ if (!(pad1Index & 0x01))
+ pad1Index = 0;
+ else if (!(pad1Index & 0x02))
+ pad1Index = 1;
+ else if (!(pad1Index & 0x04))
+ pad1Index = 2;
else
- if (!(pad1Index&0x02))
- pad1Index=1;
- else
- if (!(pad1Index&0x04))
- pad1Index=2;
- else
- pad1Index=3;
-
- if (joypad_0_buttons[(pad0Index<<2)+0]) data|=0x01;
- if (joypad_0_buttons[(pad0Index<<2)+1]) data|=0x02;
- if (joypad_0_buttons[(pad0Index<<2)+2]) data|=0x04;
- if (joypad_0_buttons[(pad0Index<<2)+3]) data|=0x08;
- if (joypad_1_buttons[(pad1Index<<2)+0]) data|=0x10;
- if (joypad_1_buttons[(pad1Index<<2)+1]) data|=0x20;
- if (joypad_1_buttons[(pad1Index<<2)+2]) data|=0x40;
- if (joypad_1_buttons[(pad1Index<<2)+3]) data|=0x80;
- return(~data);
+ pad1Index = 3;
+
+ if (joypad_0_buttons[(pad0Index << 2) + 0]) data |= 0x01;
+ if (joypad_0_buttons[(pad0Index << 2) + 1]) data |= 0x02;
+ if (joypad_0_buttons[(pad0Index << 2) + 2]) data |= 0x04;
+ if (joypad_0_buttons[(pad0Index << 2) + 3]) data |= 0x08;
+ if (joypad_1_buttons[(pad1Index << 2) + 0]) data |= 0x10;
+ if (joypad_1_buttons[(pad1Index << 2) + 1]) data |= 0x20;
+ if (joypad_1_buttons[(pad1Index << 2) + 2]) data |= 0x40;
+ if (joypad_1_buttons[(pad1Index << 2) + 3]) data |= 0x80;
+
+ return ~data;
}
- else
- if (offset==3)
+ else if (offset == 3)
{
- uint8 data=((1<<5)|(1<<4)|0x0f) ;
- int pad0Index=joystick_ram[1]&0x0f;
- int pad1Index=(joystick_ram[1]>>4)&0x0f;
+ uint8 data = ((1 << 5) | (1 << 4) | 0x0F);
+ int pad0Index = joystick_ram[1] & 0x0F;
+//unused int pad1Index = (joystick_ram[1] >> 4) & 0x0F;
- if (!(pad0Index&0x01))
+ if (!(pad0Index & 0x01))
{
- if (joypad_0_buttons[BUTTON_PAUSE]) data^=0x01;
- if (joypad_0_buttons[BUTTON_A]) data^=0x02;
+ if (joypad_0_buttons[BUTTON_PAUSE])
+ data ^= 0x01;
+ if (joypad_0_buttons[BUTTON_A])
+ data ^= 0x02;
}
- else
- if (!(pad0Index&0x02))
+ else if (!(pad0Index & 0x02))
{
- if (joypad_0_buttons[BUTTON_B]) data^=0x02;
+ if (joypad_0_buttons[BUTTON_B])
+ data ^= 0x02;
}
- else
- if (!(pad0Index&0x04))
+ else if (!(pad0Index & 0x04))
{
- if (joypad_0_buttons[BUTTON_C]) data^=0x02;
+ if (joypad_0_buttons[BUTTON_C])
+ data ^= 0x02;
}
else
{
- if (joypad_0_buttons[BUTTON_OPTION]) data^=0x02;
+ if (joypad_0_buttons[BUTTON_OPTION])
+ data ^= 0x02;
}
- return(data);
+ return data;
}
- return(joystick_ram[offset]);
+
+ return joystick_ram[offset];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint16 joystick_word_read(uint32 offset)
{
- uint16 data=joystick_byte_read((offset+0)&0x03);
- data<<=8;
- data|=joystick_byte_read((offset+1)&0x03);
- return(data);
+ return ((uint16)joystick_byte_read((offset+0)&0x03) << 8) | joystick_byte_read((offset+1)&0x03);
}
-//////////////////////////////////////////////////////////////////////////////
//
-//////////////////////////////////////////////////////////////////////////////
+// Log handler
//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "include/log.h"
+#include "log.h"
-FILE *log_stream=NULL;
+FILE * log_stream = NULL;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-int log_init(char *path)
+int log_init(char * path)
{
- log_stream=fopen(path,"wrt");
- if (log_stream==NULL)
- return(0);
- return(1);
+ log_stream = fopen(path, "wrt");
+ if (log_stream == NULL)
+ return 0;
+ return 1;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-FILE *log_get(void)
+
+FILE * log_get(void)
{
- return(log_stream);
+ return log_stream;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void log_done(void)
{
fclose(log_stream);
-//////////////////////////////////////////////////////////////////////////////
//
-//////////////////////////////////////////////////////////////////////////////
+// Memory handler
//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-#include "include/memory.h"
+#include "memory.h"
typedef struct sMemBlockInfo
{
- void *ptr;
- char *info;
- UINT32 size;
- struct sMemBlockInfo *next;
- struct sMemBlockInfo *prev;
+ void * ptr;
+ char * info;
+ UINT32 size;
+ struct sMemBlockInfo * next;
+ struct sMemBlockInfo * prev;
} sMemBlockInfo;
-sMemBlockInfo memoryInfo;
-UINT32 memoryMaxAllocated;
-UINT32 currentAllocatedMemory;
-UINT32 maximumAllocatedMemory;
+sMemBlockInfo memoryInfo;
+UINT32 memoryMaxAllocated;
+UINT32 currentAllocatedMemory;
+UINT32 maximumAllocatedMemory;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void memory_addMemInfo(void *ptr, UINT32 size, char *info)
+
+void memory_addMemInfo(void * ptr, UINT32 size, char * info)
{
- sMemBlockInfo *alias;
+ sMemBlockInfo * alias;
- alias=&memoryInfo;
- while (alias->next) alias=alias->next;
- alias->next=(sMemBlockInfo*)malloc(sizeof(sMemBlockInfo));
- if (alias->next==NULL)
+ alias = &memoryInfo;
+ while (alias->next)
+ alias=alias->next;
+ alias->next = (sMemBlockInfo *)malloc(sizeof(sMemBlockInfo));
+ if (alias->next == NULL)
{
exit(0);
return;
}
- alias->next->prev=alias;
- alias=alias->next;
- alias->next=NULL;
- alias->size=size;
- alias->ptr=ptr;
- alias->info=info;
+ alias->next->prev = alias;
+ alias = alias->next;
+ alias->next = NULL;
+ alias->size = size;
+ alias->ptr = ptr;
+ alias->info = info;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void memory_init(void)
{
- memoryInfo.next=NULL;
- memoryInfo.prev=NULL;
- currentAllocatedMemory=0;
- maximumAllocatedMemory=0;
+ memoryInfo.next = NULL;
+ memoryInfo.prev = NULL;
+ currentAllocatedMemory = 0;
+ maximumAllocatedMemory = 0;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void *memory_malloc(UINT32 size, char *info)
+
+void * memory_malloc(UINT32 size, char * info)
{
- void *ptr;
+ void * ptr;
- ptr=(void*)malloc(size);
- if (ptr==NULL)
- {
- return(NULL);
- }
- memory_addMemInfo(ptr,size,info);
- currentAllocatedMemory+=size;
- if (currentAllocatedMemory>maximumAllocatedMemory)
- maximumAllocatedMemory=currentAllocatedMemory;
- return(ptr);
+ ptr = (void *)malloc(size);
+ if (ptr == NULL)
+ return NULL;
+
+ memory_addMemInfo(ptr, size, info);
+ currentAllocatedMemory += size;
+
+ if (currentAllocatedMemory > maximumAllocatedMemory)
+ maximumAllocatedMemory = currentAllocatedMemory;
+
+ return ptr;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void memory_malloc_secure(void **new_ptr, UINT32 size, char *info)
+
+void memory_malloc_secure(void ** new_ptr, UINT32 size, char * info)
{
- void *ptr;
+ void * ptr;
- fprintf(log_get(),"memory: allocating %i bytes of memory for <%s>...",size,(info==NULL)?"unknown":info);
- ptr=(void*)malloc(size);
- if (ptr==NULL)
+ fprintf(log_get(), "memory: allocating %i bytes of memory for <%s>...", size, (info == NULL) ? "unknown" : info);
+ ptr = (void *)malloc(size);
+ if (ptr == NULL)
{
- fprintf(log_get(),"failed\n");
+ fprintf(log_get(), "failed\n");
log_done();
exit(0);
}
- memory_addMemInfo(ptr,size,info);
- currentAllocatedMemory+=size;
- if (currentAllocatedMemory>maximumAllocatedMemory)
- maximumAllocatedMemory=currentAllocatedMemory;
- *new_ptr=ptr;
- fprintf(log_get(),"ok\n");
+ memory_addMemInfo(ptr, size, info);
+ currentAllocatedMemory += size;
+ if (currentAllocatedMemory > maximumAllocatedMemory)
+ maximumAllocatedMemory = currentAllocatedMemory;
+ *new_ptr = ptr;
+ fprintf(log_get(), "ok\n");
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void memory_memoryUsage(FILE *fp)
+
+void memory_memoryUsage(FILE * fp)
{
- sMemBlockInfo *alias;
- UINT32 total=0;
+ sMemBlockInfo * alias;
+ UINT32 total = 0;
- fprintf(fp,"Memory usage:\n");
- alias=&memoryInfo;
- alias=alias->next;
+ fprintf(fp, "Memory usage:\n");
+ alias = &memoryInfo;
+ alias = alias->next;
while (alias)
{
- fprintf(fp,"\t%16i bytes : <%s> (@ 0x%.8x)\n",alias->size,alias->info,alias->ptr);
- total+=alias->size;
- alias=alias->next;
+ fprintf(fp, "\t%16i bytes : <%s> (@ 0x%.8x)\n", alias->size, alias->info, alias->ptr);
+ total += alias->size;
+ alias = alias->next;
}
- fprintf(fp,"\n\t%16i bytes total(%i Mb)\n",total,(total>>20));
- fprintf(fp,"\n\t%16i bytes memory peak(%i Mb)\n",maximumAllocatedMemory,maximumAllocatedMemory>>20);
+ fprintf(fp, "\n\t%16i bytes total(%i Mb)\n", total, total >> 20);
+ fprintf(fp, "\n\t%16i bytes memory peak(%i Mb)\n", maximumAllocatedMemory, maximumAllocatedMemory >> 20);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
void memory_done(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void memory_free(void *ptr)
+
+void memory_free(void * ptr)
{
- sMemBlockInfo *alias;
+ sMemBlockInfo * alias;
- alias=&memoryInfo;
- alias=alias->next;
- while (alias->ptr!=ptr)
- alias=alias->next;
+ alias = &memoryInfo;
+ alias = alias->next;
+ while (alias->ptr != ptr)
+ alias = alias->next;
free(ptr);
- currentAllocatedMemory-=alias->size;
- alias->prev->next=alias->next;
- if (alias->next!=NULL)
- alias->next->prev=alias->prev;
+ currentAllocatedMemory -= alias->size;
+ alias->prev->next = alias->next;
+ if (alias->next != NULL)
+ alias->next->prev = alias->prev;
free(alias);
}
+//
+// Object Processor
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "jaguar.h"
-
//#define OP_DEBUG
//#define OP_DEBUG_BMP
-static int cnt = 0;
+//WTFITF???static int cnt = 0;
extern uint32 jaguar_mainRom_crc32;
static uint8 * op_blend_y;
#define BLEND_Y(dst,src) op_blend_y[(((uint16)dst)<<8) | ((uint16)(src))]
#define BLEND_CC(dst,src) op_blend_cc[(((uint16)dst)<<8) | ((uint16)(src))]
-
static uint8 objectp_ram[0x40];
uint8 objectp_running;
#define OBJECT_TYPE_GPU 2
#define OBJECT_TYPE_BRANCH 3
#define OBJECT_TYPE_STOP 4
+/*
+#define OBJECT_TYPE_BITMAP 000
+#define OBJECT_TYPE_SCALE 001
+#define OBJECT_TYPE_GPU 010
+#define OBJECT_TYPE_BRANCH 011
+#define OBJECT_TYPE_STOP 100
+*/
#define CONDITION_EQUAL 0
#define CONDITION_LESS_THAN 1
#define FLAGS_READMODIFY 2
#define FLAGS_HFLIP 1
-
-static char * condition_to_str[8] = {"==","<",">","(opflag set)","(second half line)","?","?","?"};
-
-static uint8 op_bitmap_bit_depth[8]={1, 2, 4, 8, 16, 24, 32, 0 };
-static uint32 op_bitmap_bit_size[8]={0.125*65536, 0.25*65536, 0.5*65536, 1*65536, 2*65536, 1*65536, 1*65536, 1*65536};
+static uint8 op_bitmap_bit_depth[8] = { 1, 2, 4, 8, 16, 24, 32, 0 };
+static uint32 op_bitmap_bit_size[8] =
+ { (uint32)(0.125*65536), (uint32)(0.25*65536), (uint32)(0.5*65536), (uint32)(1*65536),
+ (uint32)(2*65536), (uint32)(1*65536), (uint32)(1*65536), (uint32)(1*65536) };
static uint32 op_pointer;
-static int cnt_bitmap = 0;
+//WTFITF???static int cnt_bitmap = 0;
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
//
+// Object Processor bitmap processing
//
-//
-//////////////////////////////////////////////////////////////////////////////
-void op_process_bitmap(int16 *backbuffer, int scanline, uint64 p0, uint64 p1, int render)
+
+void op_process_bitmap(int16 * backbuffer, int scanline, uint64 p0, uint64 p1, int render)
{
- uint8 bitdepth=(p1>>12)&0x07;
-
- int16 ypos=(((p0>>3)&0x3ff)/2);
- int32 xpos=(((int32)((p1<<20)&0xffffffff))>>20)-tom_getHBlankWidthInPixels();
- int32 iwidth=((p1>>28)&0x3ff)*4;
- uint32 dwidth=((p1>>18)&0x3ff)*4;
- int16 height=((p0>>14)&0x3ff)-1;
- uint32 link=((p0>>24)&0x7ffff)<<3;
- uint32 ptr=(((p0>>43)&0x1fffff)<<3);
- uint32 firstPix=(p1>>49)&0x3f;
- uint8 flags=(p1>>45)&0x0f;
- uint8 idx=(p1>>38)&0x7f;
- uint32 pitch=(p1>>15)&0x07;
- int16 scanline_width=tom_getVideoModeWidth();
- uint8 *tom_ram_8=tom_get_ram_pointer();
- uint8 *current_line_buffer=&tom_ram_8[0x1800];
- uint8 *paletteRam=&tom_ram_8[0x400];
- uint8 doom_hack=0;
-
- op_pointer=link;
-
- if ((!render)||(op_pointer==0)||(height<0)||(dwidth<0)||(ptr==0)||(pitch==0))
- {
+ uint8 bitdepth = (p1 >> 12) & 0x07;
+ int16 ypos = ((p0 >> 3) & 0x3FF) / 2; // ??? What if not interlaced (/2)?
+ int32 xpos = (((int32)((p1 << 20) & 0xFFFFFFFF)) >> 20) - tom_getHBlankWidthInPixels();
+ int32 iwidth = ((p1 >> 28) & 0x3FF) * 4;
+ int32 dwidth = ((p1 >> 18) & 0x3FF) * 4; // ??? Should it be signed or unsigned ???
+ int16 height = ((p0 >> 14) & 0x3FF) - 1;
+ uint32 link = ((p0 >> 24) & 0x7FFFF) << 3;
+ uint32 ptr = ((p0 >> 43) & 0x1FFFFF) << 3;
+#ifdef OP_DEBUG_BMP
+ uint32 firstPix = (p1 >> 49) & 0x3F;
+#endif
+ uint8 flags = (p1 >> 45) & 0x0F;
+ uint8 idx = (p1 >> 38) & 0x7F;
+ uint32 pitch = (p1 >> 15) & 0x07;
+ int16 scanline_width = tom_getVideoModeWidth();
+ uint8 * tom_ram_8 = tom_get_ram_pointer();
+ uint8 * current_line_buffer = &tom_ram_8[0x1800];
+ uint8 * paletteRam = &tom_ram_8[0x400];
+ uint8 doom_hack = 0;
+
+//if (scanline == 200)
+// fprintf(log_get(), "OP --> Current OPPtr: %08X, next: %08X, BMPPtr: %08X\n", op_pointer, link, ptr);
+
+ op_pointer = link;
+
+ if (!render || (op_pointer == 0) || (height < 0) || (dwidth < 0) || (ptr == 0) || (pitch == 0))
return;
- }
- if (iwidth==0)
- {
- dwidth=iwidth=height;
- }
- if (jaguar_mainRom_crc32==0x5e705756) // doom
+
+ if (iwidth == 0)
+ dwidth = iwidth = height;
+
+ if (jaguar_mainRom_crc32 == 0x5e705756) // doom
{
if ((iwidth==160)&&(height==179)&&(xpos==-9)&&(ypos==24))
{
{
ypos+=8;
}
- if (op_bitmap_bit_depth[bitdepth]==24)
+ if (op_bitmap_bit_depth[bitdepth] == 24)
{
- iwidth*=2;
- dwidth*=2;
+ iwidth *= 2;
+ dwidth *= 2;
}
- if (op_bitmap_bit_depth[bitdepth]==8)
+ if (op_bitmap_bit_depth[bitdepth] == 8)
{
- iwidth*=2;
- dwidth*=2;
+ iwidth *= 2;
+ dwidth *= 2;
}
- if (op_bitmap_bit_depth[bitdepth]==4)
+ if (op_bitmap_bit_depth[bitdepth] == 4)
{
- iwidth*=2;
- dwidth*=2;
+ iwidth *= 2;
+ dwidth *= 2;
}
- if (op_bitmap_bit_depth[bitdepth]==2)
+ if (op_bitmap_bit_depth[bitdepth] == 2)
{
- iwidth*=2;
- dwidth*=2;
+ iwidth *= 2;
+ dwidth *= 2;
}
- if (op_bitmap_bit_depth[bitdepth]==1)
+ if (op_bitmap_bit_depth[bitdepth] == 1)
{
- iwidth*=2;
- dwidth*=2;
+ iwidth *= 2;
+ dwidth *= 2;
}
// Power Drive Rally (fixed size bitmaps have a 240 lines vertical offset)
// but could well be a modulo 240
if (jaguar_mainRom_crc32==0x0ab88d90)
- ypos%=240;
-
+ ypos %= 240;
#ifdef OP_DEBUG_BMP
fprintf(log_get(),"bitmap %ix%i %ibpp at %i,%i firstpix=%i ptr=0x%.8x pitch %i hflipped=%s dwidth=%i (linked to 0x%.8x) Transluency=%s\n",iwidth,height,op_bitmap_bit_depth[bitdepth],xpos,ypos,firstPix,ptr,pitch,flags&FLAGS_HFLIP?"yes":"no",dwidth,op_pointer,(flags&FLAGS_READMODIFY)?"yes":"no");
#endif
- if ((scanline<ypos)||(scanline>(ypos+height)))
- {
+ if ((scanline < ypos) || (scanline > (ypos + height)))
return;
- }
+
// seek to the good bitmap scanline
// not sure for palettized modes
if (op_bitmap_bit_depth[bitdepth] > 8)
- {
ptr += ((dwidth * op_bitmap_bit_size[bitdepth]) >> 16) * (scanline - ypos);
- }
else
ptr += dwidth * (scanline - ypos);
if (iwidth <= 0)
{
-#ifdef OP_DEBUG
- fprintf(log_get(),"not rendering because iwidth<0\n");
+#ifdef OP_DEBUG_BMP
+ fprintf(log_get(), "not rendering because iwidth <= 0\n");
#endif
return;
}
- if (flags&FLAGS_HFLIP)
+ if (flags & FLAGS_HFLIP)
{
- if ((xpos<0)||((xpos-iwidth)>=scanline_width))
+ if ((xpos < 0) || ((xpos - iwidth) >= scanline_width))
return;
- if ((xpos-iwidth)<0)
- iwidth=xpos;
+ if ((xpos - iwidth) < 0)
+ iwidth = xpos;
}
else
{
- if (((xpos+iwidth)<0)||(xpos>=scanline_width))
+ if (((xpos + iwidth) < 0) || (xpos >= scanline_width))
return;
- if ((xpos+iwidth)>scanline_width)
- iwidth=scanline_width-xpos;
+ if ((xpos + iwidth) > scanline_width)
+ iwidth = scanline_width - xpos;
}
-
- current_line_buffer+=(xpos*2); // 2 in 16 bpp modes (need to take the mode into account)
+ current_line_buffer += xpos * 2; // 2 in 16 bpp modes (need to take the mode into account)
// doom switches the resolution from 320 to 160 to double the display width
// this is not yet supported
}
return;
}
- if (op_bitmap_bit_depth[bitdepth]==1)
+ if (op_bitmap_bit_depth[bitdepth] == 1)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/fbmpop1.h"
+#include "fbmpop1.h"
}
else
{
- #include "include/fbmpop1p.h"
+#include "fbmpop1p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==2)
+ else if (op_bitmap_bit_depth[bitdepth] == 2)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/fbmpop2.h"
+#include "fbmpop2.h"
}
else
{
- #include "include/fbmpop2p.h"
+#include "fbmpop2p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==4)
+ else if (op_bitmap_bit_depth[bitdepth] == 4)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/fbmpop4.h"
+#include "fbmpop4.h"
}
else
{
- #include "include/fbmpop4p.h"
+#include "fbmpop4p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==8)
+ else if (op_bitmap_bit_depth[bitdepth] == 8)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/fbmpop8.h"
+#include "fbmpop8.h"
}
else
{
- #include "include/fbmpop8p.h"
+#include "fbmpop8p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==16)
+ else if (op_bitmap_bit_depth[bitdepth] == 16)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/fbmpop16.h"
+#include "fbmpop16.h"
}
else
{
- #include "include/fbmpop16p.h"
+#include "fbmpop16p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==24)
+ else if (op_bitmap_bit_depth[bitdepth] == 24)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/fbmpop24.h"
+#include "fbmpop24.h"
}
else
{
- #include "include/fbmpop24p.h"
+#include "fbmpop24p.h"
}
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
+
//
+// Object Processor scaled bitmap processing
//
-//////////////////////////////////////////////////////////////////////////////
-void op_process_scaled_bitmap(int16 *backbuffer, int scanline, uint64 p0, uint64 p1, uint64 p2, int render)
-{
- int32 xpos=(((int32)((p1<<20)&0xffffffff))>>20)-tom_getHBlankWidthInPixels();
- int16 ypos=(((p0&0x3ff8)>>3)/2);
- uint16 iwidth=((p1>>28)&0x3ff)*4;
- uint16 dwidth=((p1>>18)&0x3ff)*4;
- uint16 height=(p0>>14)&0x3ff;
- uint32 link=((p0>>24)&0x7ffff)<<3;
- uint32 ptr=((p0>>43)&0x1fffff)<<3;
- uint32 firstPix=(p1>>49)&0x3f;
- uint8 flags=(p1>>45)&0x0f;
- uint8 idx=(p1>>38)&0x7f;
- uint8 pitch=(p1>>15)&0x07;
- uint8 bitdepth=(p1>>12)&0x07;
- int16 scanline_width=tom_getVideoModeWidth();
- uint8 *tom_ram_8=tom_get_ram_pointer();
- uint8 *current_line_buffer=&tom_ram_8[0x1800];
- float vscale;
- float hscale;
-
- uint32 vscale_fixed3p5=((p2>>8)&0xff);
- uint32 hscale_fixed3p5=(p2&0xff);
- vscale=((float)vscale_fixed3p5)/32;
- hscale=((float)hscale_fixed3p5)/32;
- op_pointer=link;
+void op_process_scaled_bitmap(int16 * backbuffer, int scanline, uint64 p0, uint64 p1, uint64 p2, int render)
+{
+// if ((render == 0) || (op_pointer == 0) || (height < 0) || (dwidth < 0) || (ptr == 0) || (pitch == 0))
+
+ int32 xpos = (((int32)((p1 << 20) & 0xFFFFFFFF)) >> 20) - tom_getHBlankWidthInPixels();
+ int16 ypos = ((p0 & 0x3FF8) >> 3) / 2;
+ uint16 iwidth = ((p1 >> 28) & 0x3FF) * 4;
+ int16 dwidth = ((p1 >> 18) & 0x3FF) * 4; // ??? Signed or unsigned ???
+ int16 height = (p0 >> 14) & 0x3FF; // ??? Signed or unsigned ???
+ uint32 link = ((p0 >> 24) & 0x7FFFF) << 3;
+ uint32 ptr = ((p0 >> 43) & 0x1FFFFF) << 3;
+//unused uint32 firstPix = (p1 >> 49) & 0x3F;
+ uint8 flags = (p1 >> 45) & 0x0F;
+ uint8 idx = (p1 >> 38) & 0x7F;
+ uint8 pitch = (p1 >> 15) & 0x07;
+ uint8 bitdepth = (p1 >> 12) & 0x07;
+ int16 scanline_width = tom_getVideoModeWidth();
+ uint8 * tom_ram_8 = tom_get_ram_pointer();
+ uint8 * current_line_buffer = &tom_ram_8[0x1800];
+ uint32 vscale_fixed3p5 = ((p2 >> 8) & 0xFF);
+ uint32 hscale_fixed3p5 = (p2 & 0xFF);
+ float vscale = (float)vscale_fixed3p5 / 32.0f, hscale = (float)hscale_fixed3p5 / 32.0f;
+
+ op_pointer = link;
if (jaguar_mainRom_crc32==0x5a5b9c68) // atari karts
{
}
#ifdef OP_DEBUG_BMP
if (xpos == -3)
- fprintf(log_get(),"[scanline %i] %ix%i scaled to %ix%i scale (%f, %f)%i bpp pitch %i at (%i,%i) @ 0x%.8x Transluency=%s\n",
- scanline,
- iwidth,height,
- (int)(iwidth*hscale),
- (int)(height*vscale),
- hscale, vscale,
- op_bitmap_bit_depth[bitdepth],pitch,xpos,ypos,ptr,(flags&FLAGS_READMODIFY)?"yes":"no");
+ fprintf(log_get(), "[scanline %i] %ix%i scaled to %ix%i scale (%f, %f)%i bpp pitch %i at (%i,%i) @ 0x%.8x Transluency=%s\n",
+ scanline, iwidth,height, (int)(iwidth*hscale), (int)(height*vscale), hscale, vscale,
+ op_bitmap_bit_depth[bitdepth], pitch, xpos, ypos, ptr, (flags&FLAGS_READMODIFY) ? "yes" : "no");
#endif
if (jaguar_mainRom_crc32==0x2f032271)
- {
- ypos+=8;
- }
+ ypos += 8;
- if ((render==0)||(op_pointer==0)||(height<0)||(dwidth<0)||(ptr==0)||(pitch==0))
- {
+ if ((render == 0) || (op_pointer == 0) || (height < 0) || (dwidth < 0) || (ptr == 0) || (pitch == 0))
return;
- }
if (op_bitmap_bit_depth[bitdepth]==8)
{
dwidth*=2;
}
- uint16 scaled_width=iwidth*hscale;
- uint16 scaled_height=height*vscale;
+ uint16 scaled_width = (uint16)((float)iwidth * hscale),
+ scaled_height = (uint16)((float)height * vscale);
- if (op_bitmap_bit_depth[bitdepth]==4) // why ?
- scaled_width*=2;
+ if (op_bitmap_bit_depth[bitdepth] == 4) // why ?
+ scaled_width *= 2;
- if (op_bitmap_bit_depth[bitdepth]==2) // why ?
- scaled_width*=4;
+ if (op_bitmap_bit_depth[bitdepth] == 2) // why ?
+ scaled_width *= 4;
- if (op_bitmap_bit_depth[bitdepth]==1) // why ?
- scaled_width*=8;
+ if (op_bitmap_bit_depth[bitdepth] == 1) // why ?
+ scaled_width *= 8;
// seek to the good bitmap scanline
// not sure for palettized modes
- if (op_bitmap_bit_depth[bitdepth]>8)
- ptr+=((dwidth*op_bitmap_bit_size[bitdepth])>>16)*((uint32)((scanline-ypos)/vscale));
+ if (op_bitmap_bit_depth[bitdepth] > 8)
+ ptr += ((dwidth * op_bitmap_bit_size[bitdepth]) >> 16) * ((uint32)((scanline - ypos) / vscale));
else
- ptr+=dwidth*((uint32)((scanline-ypos)/vscale));
+ ptr += dwidth * ((uint32)((scanline - ypos) / vscale));
// visible ?
- if ((scanline<ypos)||(scanline>(ypos+scaled_height))||((xpos+scaled_width)<0)||(xpos>=scanline_width))
+ if ((scanline < ypos) || (scanline > (ypos+scaled_height)) || ((xpos+scaled_width) < 0)
+ || (xpos >= scanline_width))
return;
-
- if (xpos<0)
+ if (xpos < 0)
{
- scaled_width+=xpos;
- ptr+=(pitch*op_bitmap_bit_size[bitdepth]*((uint32)((-xpos)/hscale)))>>16;
- xpos=0;
+ scaled_width += xpos;
+ ptr += (pitch * op_bitmap_bit_size[bitdepth] * ((uint32)((-xpos) / hscale))) >> 16;
+ xpos = 0;
}
if (iwidth<=0)
scaled_width=scanline_width-xpos;
}
- current_line_buffer+=(xpos*2);
+ current_line_buffer += xpos * 2;
- int32 hscale_fixed=(int32)(65536.0f/hscale);
- int32 cnt=0;
+ int32 hscale_fixed = (int32)(65536.0f / hscale);
+ int32 cnt = 0;
- if (op_bitmap_bit_depth[bitdepth]==1)
+ if (op_bitmap_bit_depth[bitdepth] == 1)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/zbmpop1.h"
+#include "zbmpop1.h"
}
else
{
- #include "include/zbmpop1p.h"
+#include "zbmpop1p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==2)
+ else if (op_bitmap_bit_depth[bitdepth] == 2)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/zbmpop2.h"
+#include "zbmpop2.h"
}
else
{
- #include "include/zbmpop2p.h"
+#include "zbmpop2p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==4)
+ else if (op_bitmap_bit_depth[bitdepth] == 4)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/zbmpop4.h"
+#include "zbmpop4.h"
}
else
{
- #include "include/zbmpop4p.h"
+#include "zbmpop4p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==8)
+ else if (op_bitmap_bit_depth[bitdepth] == 8)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/zbmpop8.h"
+#include "zbmpop8.h"
}
else
{
- #include "include/zbmpop8p.h"
+#include "zbmpop8p.h"
}
}
- else
- if (op_bitmap_bit_depth[bitdepth]==16)
+ else if (op_bitmap_bit_depth[bitdepth] == 16)
{
- if (pitch==1)
+ if (pitch == 1)
{
- #include "include/zbmpop16.h"
+#include "zbmpop16.h"
}
else
{
- #include "include/zbmpop16p.h"
+#include "zbmpop16p.h"
}
}
else
fprintf(log_get(),"(unimplemented) %i bpp scaled bitmap\n",op_bitmap_bit_depth[bitdepth]);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint64 op_load_phrase(uint32 offset)
{
- offset &= (~0x07); // 8 byte alignment
-
- uint64 data = jaguar_byte_read(offset++);
- data <<= 8;
- data |= jaguar_byte_read(offset++);
- data <<= 8;
- data |= jaguar_byte_read(offset++);
- data <<= 8;
- data |= jaguar_byte_read(offset++);
- data <<= 8;
- data |= jaguar_byte_read(offset++);
- data <<= 8;
- data |= jaguar_byte_read(offset++);
- data <<= 8;
- data |= jaguar_byte_read(offset++);
- data <<= 8;
- data |= jaguar_byte_read(offset++);
-
- return data;
+ offset &= ~0x07; // 8 byte alignment
+ return ((uint64)jaguar_long_read(offset) << 32) | (uint64)jaguar_long_read(offset+4);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
+
//
+// Object Processor main list processing
//
-//////////////////////////////////////////////////////////////////////////////
+
void op_process_list(int16 * backbuffer, int scanline, int render)
{
- uint64 p0;
-
- cnt_bitmap = 0;
+// char * condition_to_str[8] =
+// { "==", "<", ">", "(opflag set)", "(second half line)", "?", "?", "?" };
+//WTFITF??? cnt_bitmap = 0;
if (scanline < tom_get_vdb())
return;
op_pointer = op_get_list_pointer();
objectp_stop_reading_list = 0;
- cnt = 0;
+//WTFITF??? cnt = 0;
// if (op_pointer) fprintf(log_get()," new op list at 0x%.8x scanline %i\n",op_pointer,scanline);
while (op_pointer)
if (objectp_stop_reading_list)
return;
- p0 = op_load_phrase(op_pointer);
+ uint64 p0 = op_load_phrase(op_pointer);
op_pointer += 8;
+/*if (scanline == tom_get_vdb())
+{
+fprintf(log_get(), "%08X --> phrase %08X %08X", op_pointer - 8, (int)(p0>>32), (int)(p0&0xFFFFFFFF));
+if ((p0 & 0x07) == OBJECT_TYPE_BITMAP)
+{
+fprintf(log_get(), " (BITMAP) ");
+uint64 p1 = op_load_phrase(op_pointer);
+fprintf(log_get(), "\n%08X --> phrase %08X %08X ", op_pointer, (int)(p1>>32), (int)(p1&0xFFFFFFFF));
+ uint8 bitdepth = (p1 >> 12) & 0x07;
+ int16 ypos = ((p0 >> 3) & 0x3FF); // ??? What if not interlaced (/2)?
+// int32 xpos = (((int32)((p1 << 20) & 0xFFFFFFFF)) >> 20);
+int32 xpos = p1 & 0xFFF;
+xpos = (xpos & 0x800 ? xpos | 0xFFFFF000 : xpos);
+ uint32 iwidth = ((p1 >> 28) & 0x3FF);
+ uint32 dwidth = ((p1 >> 18) & 0x3FF); // ??? Should it be signed or unsigned ???
+ int16 height = ((p0 >> 14) & 0x3FF) - 1;
+ uint32 link = ((p0 >> 24) & 0x7FFFF) << 3;
+ uint32 ptr = ((p0 >> 43) & 0x1FFFFF) << 3;
+ uint32 firstPix = (p1 >> 49) & 0x3F;
+ uint8 flags = (p1 >> 45) & 0x0F;
+ uint8 idx = (p1 >> 38) & 0x7F;
+ uint32 pitch = (p1 >> 15) & 0x07;
+fprintf(log_get(), "[%u (%u) x %u @ %i, %u (%u bpp), l: %08X, p: %08X fp: %02X, fl:%02X, idx:%02X, pt:%02X]\n", iwidth, dwidth, height, xpos, ypos, op_bitmap_bit_depth[bitdepth], link, ptr, firstPix, flags, idx, pitch);
+uint8 * jaguar_mainRam = GetRamPtr();
+fprintf(log_get(), "[RAM] --> ");
+for(int k=0; k<16; k++)
+ fprintf(log_get(), "%02X ", jaguar_mainRam[op_pointer-8 + k]);
+fprintf(log_get(), "\n");
+}
+if ((p0 & 0x07) == OBJECT_TYPE_SCALE)
+{
+fprintf(log_get(), " (SCALED BITMAP)\n");
+}
+if ((p0 & 0x07) == OBJECT_TYPE_GPU)
+fprintf(log_get(), " (GPU)\n");
+if ((p0 & 0x07) == OBJECT_TYPE_BRANCH)
+{
+fprintf(log_get(), " (BRANCH)\n");
+uint8 * jaguar_mainRam = GetRamPtr();
+fprintf(log_get(), "[RAM] --> ");
+for(int k=0; k<8; k++)
+ fprintf(log_get(), "%02X ", jaguar_mainRam[op_pointer-8 + k]);
+fprintf(log_get(), "\n");
+}
+if ((p0 & 0x07) == OBJECT_TYPE_STOP)
+fprintf(log_get(), " --> List end\n");
+}*/
-
// fprintf(log_get(),"0x%.8x type %i\n",op_pointer,((uint8)p0&0x07));
- switch ((uint8)p0&0x07)
+ switch ((uint8)p0 & 0x07)
{
case OBJECT_TYPE_BITMAP:
{
}
case OBJECT_TYPE_GPU:
{
- uint64 data = p0 >> 3;
+//unused uint64 data = p0 >> 3;
op_set_current_object(p0);
gpu_set_irq_line(3, 1);
break;
}
case OBJECT_TYPE_BRANCH:
{
- uint16 vcnt = (p0>>3) & 0x7FF;
- uint8 cc = (p0>>14) & 0x03;
- uint32 link = ((p0>>24) & 0x1FFFFF) << 3;
+ uint16 vcnt = (p0 >> 3) & 0x7FF;
+ uint8 cc = (p0 >> 14) & 0x03;
+ uint32 link = ((p0 >> 24) & 0x1FFFFF) << 3;
// if ((vcnt!=507)&&(vcnt!=25))
// fprintf(log_get(),"\t%i%s%i link=0x%.8x\n",scanline,condition_to_str[cc],vcnt>>1,link);
case CONDITION_EQUAL:
if ((vcnt != 0x7FF) && (vcnt & 0x01))
vcnt ^= 0x01;
- if (((2*tom_get_scanline()) == vcnt) || (vcnt == 0x7FF))
- op_pointer=link;
+ if (((2 * tom_get_scanline()) == vcnt) || (vcnt == 0x7FF))
+ op_pointer = link;
break;
case CONDITION_LESS_THAN:
- if ((2*tom_get_scanline()) < vcnt)
- op_pointer=link;
+ if ((2 * tom_get_scanline()) < vcnt)
+ op_pointer = link;
break;
case CONDITION_GREATER_THAN:
- if ((2*tom_get_scanline()) > vcnt)
- op_pointer=link;
+ if ((2 * tom_get_scanline()) > vcnt)
+ op_pointer = link;
break;
case CONDITION_OP_FLAG_SET:
if (op_get_status_register() & 0x01)
- op_pointer=link;
+ op_pointer = link;
break;
case CONDITION_SECOND_HALF_LINE:
fprintf(log_get(), "op: unexpected CONDITION_SECOND_HALF_LINE in BRANCH object\nop: shuting down\n");
break;
}
default:
- {
fprintf(log_get(),"op: unknown object type %i\n", ((uint8)p0 & 0x07));
return;
}
- }
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
+
//
+// Object Processor initialization
//
-//////////////////////////////////////////////////////////////////////////////
+
void op_init(void)
{
memory_malloc_secure((void **)&op_blend_y, 0x10000, "Jaguar Object processor Y blend lookup table");
}
op_reset();
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
+
//
+// Object Processor reset
//
-//////////////////////////////////////////////////////////////////////////////
+
void op_reset(void)
{
- memset(objectp_ram, 0x00, 0x18);
+ memset(objectp_ram, 0x00, 0x40);
objectp_running = 0;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void op_done(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void op_byte_write(uint32 offset, uint8 data)
{
offset &= 0x3F;
objectp_ram[offset] = data;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void op_word_write(uint32 offset, uint16 data)
{
offset &= 0x3F;
objectp_ram[offset] = (data >> 8) & 0xFF;
objectp_ram[offset+1] = data & 0xFF;
+/*if (offset == 0x20)
+fprintf(log_get(), "OP: Setting lo list pointer: %04X\n", data);
+if (offset == 0x22)
+fprintf(log_get(), "OP: Setting hi list pointer: %04X\n", data);//*/
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
+// Memory range: F00010 - F00027
+
uint8 op_byte_read(uint32 offset)
{
offset &= 0x3F;
return objectp_ram[offset];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint16 op_word_read(uint32 offset)
{
return (objectp_ram[offset & 0x3F] << 8) | objectp_ram[(offset+1) & 0x3F];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
+// F00010-F00017 R xxxxxxxx xxxxxxxx OB - current object code from the graphics processor
+// F00020-F00023 W xxxxxxxx xxxxxxxx OLP - start of the object list
+// F00026 W -------- -------x OBF - object processor flag
+
uint32 op_get_list_pointer(void)
{
- uint32 ptr = objectp_ram[0x22];
+ // Note: This register is WORD swapped, hence the funky look of this...
+/* uint32 ptr = objectp_ram[0x22];
ptr <<= 8;
ptr |= objectp_ram[0x23];
ptr <<= 8;
ptr |= objectp_ram[0x20];
ptr <<= 8;
ptr |= objectp_ram[0x21];
+fprintf(log_get(), "OP: Getting list pointer: %08X\n", (unsigned int)ptr);
ptr &= ~0x07;
return ptr;//*/
-// return (objectp_ram[0x20] << 24) | (objectp_ram[0x21] << 16) | (objectp_ram[0x22] << 8) | objectp_ram[0x23];
+ return (objectp_ram[0x22] << 24) | (objectp_ram[0x23] << 16) | (objectp_ram[0x20] << 8) | objectp_ram[0x21];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint32 op_get_status_register(void)
{
- uint32 ptr = objectp_ram[0x26];
+/* uint32 ptr = objectp_ram[0x26];
ptr <<= 8;
ptr |= objectp_ram[0x27];
ptr <<= 8;
ptr <<= 8;
ptr |= objectp_ram[0x29];
- return ptr;
+ return ptr;//*/
+ return (objectp_ram[0x26] << 24) | (objectp_ram[0x27] << 16) | (objectp_ram[0x28] << 8) | objectp_ram[0x29];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void op_set_status_register(uint32 data)
{
objectp_ram[0x26] = (data & 0xFF000000) >> 24;
objectp_ram[0x28] = (data & 0x0000FF00) >> 8;
objectp_ram[0x29] |= (data & 0xFE);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void op_set_current_object(uint64 object)
{
- // less significant 32 bits first
- objectp_ram[0x13] = object&0xff; object>>=8;
- objectp_ram[0x12] = object&0xff; object>>=8;
- objectp_ram[0x11] = object&0xff; object>>=8;
- objectp_ram[0x10] = object&0xff; object>>=8;
-
- objectp_ram[0x17] = object&0xff; object>>=8;
- objectp_ram[0x16] = object&0xff; object>>=8;
- objectp_ram[0x15] = object&0xff; object>>=8;
- objectp_ram[0x14] = object&0xff;
+/*
+ 32 28 24 20 16 12 8 4 0
+ +--------^---------^---------^--------^--------^--------^--------^--------+
+0 | object-data |
+ +-------------------------------------------------------------------------+
+
+ 64 60 56 52 48 44 40 36 32
+ +--------^---------^---------^--------^--------^--------^--------^--------+
+1 | object-data |
+ +-------------------------------------------------------------------------+
+*/
+ // Stored as least significant 32 bits first, ms32 last in big endian
+ objectp_ram[0x13] = object & 0xFF; object >>= 8;
+ objectp_ram[0x12] = object & 0xFF; object >>= 8;
+ objectp_ram[0x11] = object & 0xFF; object >>= 8;
+ objectp_ram[0x10] = object & 0xFF; object >>= 8;
+
+ objectp_ram[0x17] = object & 0xFF; object >>= 8;
+ objectp_ram[0x16] = object & 0xFF; object >>= 8;
+ objectp_ram[0x15] = object & 0xFF; object >>= 8;
+ objectp_ram[0x14] = object & 0xFF;
}
-
-#include "include/pcm.h"
+//
+// PCM Handler
+//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
+//
+
+#include "pcm.h"
-#define PCM_DUMP
+//#define PCM_DUMP
#define sample_rate 44100
#define sample_bits 16
static uint32 pcm_right_pos;
static uint32 pcm_left_playback_pos;
static uint32 pcm_right_playback_pos;
-static FILE * fp_left;
-static FILE * fp_right;
static uint32 pcm_sample_rate = sample_rate;
static uint32 pcm_inc = (pcm_sample_rate << 8) / sample_rate;
+#ifdef PCM_DUMP
+static FILE * fp_left;
+static FILE * fp_right;
+#endif
+
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
void pcm_set_sample_rate(int rate)
{
pcm_sample_rate = rate;
pcm_inc = (pcm_sample_rate << 8) / sample_rate;
// fprintf(log_get(),"pcm: sample rate is %i hz, sample increment is %i (%f)\n",pcm_sample_rate,pcm_inc,((float)pcm_inc)/256.0f);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void pcm_updateOne(int channel, int16 *data, uint32 length)
+
+void pcm_updateOne(int channel, int16 * data, uint32 length)
{
- if (channel==0)
+ if (channel == 0)
{
while (length)
{
- *data++=pcm_left[(pcm_left_playback_pos>>8)%buffer_modulo];
- pcm_left_playback_pos+=pcm_inc;
+ *data++ = pcm_left[(pcm_left_playback_pos >> 8) % buffer_modulo];
+ pcm_left_playback_pos += pcm_inc;
length--;
}
}
{
while (length)
{
- *data++=pcm_right[(pcm_right_playback_pos>>8)%buffer_modulo];
- pcm_right_playback_pos+=pcm_inc;
+ *data++ = pcm_right[(pcm_right_playback_pos >> 8) % buffer_modulo];
+ pcm_right_playback_pos += pcm_inc;
length--;
}
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void pcm_init(void)
{
- memory_malloc_secure((void**)&pcm_left,buffer_modulo*sizeof(int16),"Left dac buffer");
- memory_malloc_secure((void**)&pcm_right,buffer_modulo*sizeof(int16),"Right dac buffer");
+ memory_malloc_secure((void **)&pcm_left, buffer_modulo * sizeof(int16), "Left dac buffer");
+ memory_malloc_secure((void **)&pcm_right, buffer_modulo * sizeof(int16), "Right dac buffer");
pcm_reset();
- fp_left=fopen("leftdac.raw","wb");
- fp_right=fopen("rightdac.raw","wb");
-
+#ifdef PCM_DUMP
+ fp_left = fopen("leftdac.raw", "wb");
+ fp_right = fopen("rightdac.raw", "wb");
+#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void pcm_reset(void)
{
- pcm_left_pos=0;
- pcm_right_pos=0;
- pcm_left_playback_pos=0;
- pcm_right_playback_pos=0;
+ pcm_left_pos = 0;
+ pcm_right_pos = 0;
+ pcm_left_playback_pos = 0;
+ pcm_right_playback_pos = 0;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void pcm_done(void)
{
+#ifdef PCM_DUMP
fclose(fp_left);
fclose(fp_right);
+#endif
+ fprintf(log_get(), "PCM: Done.\n");
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void pcm_update(void)
{
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void pcm_render_left_dac(void)
{
#ifdef PCM_DUMP
- fwrite(pcm_left,1,sample_rate*2,fp_left);
+ fwrite(pcm_left, 1, sample_rate * 2, fp_left);
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void pcm_render_right_dac(void)
{
#ifdef PCM_DUMP
- fwrite(pcm_right,1,sample_rate*2,fp_right);
+ fwrite(pcm_right, 1, sample_rate * 2, fp_right);
#endif
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void pcm_byte_write(uint32 offset, uint8 data)
{
// fprintf(log_get(),"pcm: writing 0x%.2x at 0x%.8x\n",data,offset);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void pcm_word_write(uint32 offset, uint16 data)
{
- if (offset==2)
+ if (offset == 2)
{
- pcm_left[pcm_left_pos%buffer_modulo]=data;
+ pcm_left[pcm_left_pos % buffer_modulo] = data;
pcm_left_pos++;
- if ((pcm_left_pos%buffer_modulo)==0)
+ if ((pcm_left_pos % buffer_modulo) == 0)
pcm_render_left_dac();
}
else
- if (offset==6)
+ if (offset == 6)
{
- pcm_right[pcm_right_pos%buffer_modulo]=data;
+ pcm_right[pcm_right_pos % buffer_modulo] = data;
pcm_right_pos++;
- if ((pcm_right_pos%buffer_modulo)==0)
+ if ((pcm_right_pos % buffer_modulo) == 0)
pcm_render_right_dac();
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint8 pcm_byte_read(uint32 offset)
{
// fprintf(log_get(),"pcm: reading byte from 0x%.8x\n",offset);
- return(0xff);
+ return 0xFF;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint16 pcm_word_read(uint32 offset)
{
// fprintf(log_get(),"pcm: reading word from 0x%.8x\n",offset);
- return(0xffff);
+ return 0xFFFF;
}
//
// TOM Processing
//
-// by cal16
+// by cal2
// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
// Cleanups and endian wrongness amelioration by James L. Hammons
// Note: Endian wrongness probably stems from the MAME origins of this emu and
tom_timer_counter = 0;
memcpy(scanline_render, scanline_render_normal, sizeof(scanline_render));
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-void tom_done(void)
-{
-// fprintf(log_get(),"tom: done()\n");
- op_done();
- pcm_done();
- blitter_done();
- fprintf(log_get(), "tom: resolution %ix%i %s\n", tom_getVideoModeWidth(), tom_getVideoModeHeight(),
- videoMode_to_str[tom_getVideoMode()]);
-// fprintf(log_get(),"\ntom: object processor:\n");
-// fprintf(log_get(),"tom: pointer to object list: 0x%.8x\n",op_get_list_pointer());
-// fprintf(log_get(),"tom: INT1=0x%.2x%.2x\n",tom_byte_read(0xf000e0),tom_byte_read(0xf000e1));
- gpu_done();
- dsp_done();
- memory_free(tom_ram_8);
-}
//
// TOM byte access (read)
}
}
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
int tom_irq_enabled(int irq)
{
return jaguar_byte_read(0xF000E1) & (1 << irq);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void tom_set_irq_latch(int irq, int enabled)
{
tom_ram_8[0xE0] = (tom_ram_8[0xE0] & (~(1<<irq))) | (enabled ? (1<<irq) : 0);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
uint16 tom_irq_control_reg(void)
{
return (tom_ram_8[0xE0] << 8) | tom_ram_8[0xE1];
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void tom_reset_timer(void)
{
if ((!tom_timer_prescaler) || (!tom_timer_divider))
tom_timer_counter = (1 + tom_timer_prescaler) * (1 + tom_timer_divider);
// fprintf(log_get(),"tom: reseting timer to 0x%.8x (%i)\n",tom_timer_counter,tom_timer_counter);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
void tom_pit_exec(uint32 cycles)
{
if (tom_timer_counter > 0)
}
}
}
+
+void tom_done(void)
+{
+ fprintf(log_get(),"TOM: done() ...START\n");
+ op_done();
+ pcm_done();
+//This is killing the log for some reason, even though it doesn't do much of anything...
+// blitter_done();
+ fprintf(log_get(), "TOM: resolution %i x %i %s\n", tom_getVideoModeWidth(), tom_getVideoModeHeight(),
+ videoMode_to_str[tom_getVideoMode()]);
+// fprintf(log_get(),"\ntom: object processor:\n");
+// fprintf(log_get(),"tom: pointer to object list: 0x%.8x\n",op_get_list_pointer());
+// fprintf(log_get(),"tom: INT1=0x%.2x%.2x\n",tom_byte_read(0xf000e0),tom_byte_read(0xf000e1));
+ gpu_done();
+ dsp_done();
+ memory_free(tom_ram_8);
+ fprintf(log_get(),"TOM: done() ...END\n");
+}
-////////////////////////////////////////////////////////////////////////////////
//
-////////////////////////////////////////////////////////////////////////////////
+// VERSION.CPP
//
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
//
-//
-//
-//
-//
-//
-////////////////////////////////////////////////////////////////////////////////
-#include "include/version.h"
+#include "version.h"
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//
-////////////////////////////////////////////////////////////////////////////////
void version_init(void)
{
}
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//
-////////////////////////////////////////////////////////////////////////////////
-void version_display(FILE *fp)
+
+void version_display(FILE * fp)
{
- fprintf(fp,"VirtualJaguar v1.0.0 (Last full build on %s %s)\n",__DATE__,__TIME__);
+ fprintf(fp, "VirtualJaguar v1.0.3 (Last full build on %s %s)\n", __DATE__, __TIME__);
}
-////////////////////////////////////////////////////////////////////////////////
-//
-////////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//
-////////////////////////////////////////////////////////////////////////////////
+
void version_done(void)
{
}
-