code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
# Makefile for genplus DOS # # (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald # modified by Eke-Eke <eke_eke31@yahoo.fr> # # Defines : # -DLSB_FIRST - Leave undefined for big-endian processors. # -DDOS - Enable DOS/x86 specific code. # -DDEBUG - Enable debugging code # -DX86_ASM - Enable inline x86 assembly code in Z80 emulator CC = gcc AS = nasm -f coff LDFLAGS = FLAGS = -I. -I.. -I../z80 -I../m68k -I../dos -I../sound -I../sound/SRC -I../cart_hw -I../cart_hw/svp -I../ntsc \ -Wall -g \ -O6 -march=i686 -fomit-frame-pointer \ -DLSB_FIRST -DX86_ASM -DDOS LIBS = -lalleg -laudio -lz -lm OBJECTS = obj/z80.o OBJECTS += obj/m68kcpu.o \ obj/m68kops.o OBJECTS += obj/genesis.o \ obj/vdp_ctrl.o \ obj/vdp_render.o \ obj/system.o \ obj/io_ctrl.o \ obj/mem68k.o \ obj/memz80.o \ obj/membnk.o \ obj/state.o OBJECTS += obj/input.o \ obj/gamepad.o \ obj/lightgun.o \ obj/mouse.o \ obj/activator.o \ obj/xe_a1p.o \ obj/teamplayer.o \ obj/paddle.o \ obj/sportspad.o OBJECTS += obj/sound.o \ obj/sn76489.o \ obj/ym2612.o OBJECTS += obj/Fir_Resampler.o OBJECTS += obj/blip.o OBJECTS += obj/eq.o \ OBJECTS += obj/sram.o \ obj/eeprom.o \ obj/svp.o \ obj/ssp16.o \ obj/ggenie.o \ obj/areplay.o \ obj/md_cart.o \ obj/sms_cart.o OBJECTS += obj/dos.o \ obj/sealintf.o \ obj/config.o \ obj/error.o \ obj/unzip.o \ obj/fileio.o \ obj/loadrom.o OBJECTS += obj/sms_ntsc.o \ obj/md_ntsc.o EXE = ../gen.exe all : $(EXE) $(EXE) : $(OBJ) $(CC) -o $(EXE) $(OBJ) $(LIBS) $(LDFLAGS) obj/%.o : ../%.c ../%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../asm/%.s $(AS) $< -o $@ obj/%.o : ../sound/%.c ../sound/%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../sound/%.c $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../sound/SRC/%.c ../sound/SRC/%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../sound/SRC/%.c $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../input_hw/%.c ../input_hw/%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../cart_hw/%.c ../cart_hw/%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../cart_hw/svp/%.c $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../cart_hw/svp/%.c ../cart_hw/svp/%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../z80/%.c ../z80/%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../m68k/%.c ../m68k/%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ./%.c ./%.h $(CC) -c $< -o $@ $(FLAGS) obj/%.o : ../ntsc/%.c ../ntsc/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ pack : strip $(EXE) upx -1 $(EXE) clean : rm -f obj/*.o rm -f *.bak rm -f *.exe rm -f *.log rm -f *.wav rm -f *.zip cleancpu : rm -f obj/z80.oa makedir : mkdir obj archive: pk -dir -add -max \ -excl=rom -excl=test \ mdsrc.zip *.* # # end of makefile #
zyking1987-genplus-droid
genplusgx/unused/dos/Makefile
Makefile
gpl2
3,148
/* unzip.c -- IO on .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Read unzip.h for more info */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "zlib.h" #include "unzip.h" #ifdef STDC # include <stddef.h> # include <string.h> # include <stdlib.h> #endif #ifdef NO_ERRNO_H extern int errno; #else #include <errno.h> #endif #ifndef local #define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ #if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ !defined(CASESENSITIVITYDEFAULT_NO) #define CASESENSITIVITYDEFAULT_NO #endif #ifndef UNZ_BUFSIZE #define UNZ_BUFSIZE (16384) #endif #ifndef UNZ_MAXFILENAMEINZIP #define UNZ_MAXFILENAMEINZIP (256) #endif #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif #ifndef TRYFREE # define TRYFREE(p) {if (p) free(p);} #endif #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif #ifndef SEEK_SET #define SEEK_SET 0 #endif const char unz_copyright[] = " unzip 0.15 Copyright 1998 Gilles Vollant "; /* unz_file_info_interntal contain internal info about a file in zipfile*/ typedef struct unz_file_info_internal_s { uLong offset_curfile;/* relative offset of local header 4 bytes */ } unz_file_info_internal; /* file_in_zip_read_info_s contain internal information about a file in zipfile, when reading and decompress it */ typedef struct { char *read_buffer; /* internal buffer for compressed data */ z_stream stream; /* zLib stream structure for inflate */ uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ uLong stream_initialised; /* flag set if stream structure is initialised*/ uLong offset_local_extrafield;/* offset of the local extra field */ uInt size_local_extrafield;/* size of the local extra field */ uLong pos_local_extrafield; /* position in the local extra field in read*/ uLong crc32; /* crc32 of all data uncompressed */ uLong crc32_wait; /* crc32 we must obtain after decompress all */ uLong rest_read_compressed; /* number of byte to be decompressed */ uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ FILE* file; /* io structore of the zipfile */ uLong compression_method; /* compression method (0==store) */ uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ } file_in_zip_read_info_s; /* unz_s contain internal information about the zipfile */ typedef struct { FILE* file; /* io structore of the zipfile */ unz_global_info gi; /* public global information */ uLong byte_before_the_zipfile; /* byte before the zipfile, (>0 for sfx)*/ uLong num_file; /* number of the current file in the zipfile*/ uLong pos_in_central_dir; /* pos of the current file in the central dir*/ uLong current_file_ok; /* flag about the usability of the current file*/ uLong central_pos; /* position of the beginning of the central dir*/ uLong size_central_dir; /* size of the central directory */ uLong offset_central_dir; /* offset of start of central directory with respect to the starting disk number */ unz_file_info cur_file_info; /* public info about the current file in zip*/ unz_file_info_internal cur_file_info_internal; /* private info about it*/ file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current file if we are decompressing it */ } unz_s; /* =========================================================================== Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ local int unzlocal_getByte(fin,pi) FILE *fin; int *pi; { unsigned char c; int err = fread(&c, 1, 1, fin); if (err==1) { *pi = (int)c; return UNZ_OK; } else { if (ferror(fin)) return UNZ_ERRNO; else return UNZ_EOF; } } /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ local int unzlocal_getShort (fin,pX) FILE* fin; uLong *pX; { uLong x ; int i = 0; int err; err = unzlocal_getByte(fin,&i); x = (uLong)i; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } local int unzlocal_getLong (fin,pX) FILE* fin; uLong *pX; { uLong x ; int i = 0; int err; err = unzlocal_getByte(fin,&i); x = (uLong)i; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<16; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<24; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } /* My own strcmpi / strcasecmp */ local int strcmpcasenosensitive_internal (fileName1,fileName2) const char* fileName1; const char* fileName2; { for (;;) { char c1=*(fileName1++); char c2=*(fileName2++); if ((c1>='a') && (c1<='z')) c1 -= 0x20; if ((c2>='a') && (c2<='z')) c2 -= 0x20; if (c1=='\0') return ((c2=='\0') ? 0 : -1); if (c2=='\0') return 1; if (c1<c2) return -1; if (c1>c2) return 1; } } #ifdef CASESENSITIVITYDEFAULT_NO #define CASESENSITIVITYDEFAULTVALUE 2 #else #define CASESENSITIVITYDEFAULTVALUE 1 #endif #ifndef STRCMPCASENOSENTIVEFUNCTION #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal #endif /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) const char* fileName1; const char* fileName2; int iCaseSensitivity; { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; if (iCaseSensitivity==1) return strcmp(fileName1,fileName2); return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); } #define BUFREADCOMMENT (0x400) /* Locate the Central directory of a zipfile (at the end, just before the global comment) */ local uLong unzlocal_SearchCentralDir(fin) FILE *fin; { unsigned char* buf; uLong uSizeFile; uLong uBackRead; uLong uMaxBack=0xffff; /* maximum size of global comment */ uLong uPosFound=0; if (fseek(fin,0,SEEK_END) != 0) return 0; uSizeFile = ftell( fin ); if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); if (buf==NULL) return 0; uBackRead = 4; while (uBackRead<uMaxBack) { uLong uReadSize,uReadPos ; int i; if (uBackRead+BUFREADCOMMENT>uMaxBack) uBackRead = uMaxBack; else uBackRead+=BUFREADCOMMENT; uReadPos = uSizeFile-uBackRead ; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); if (fseek(fin,uReadPos,SEEK_SET)!=0) break; if (fread(buf,(uInt)uReadSize,1,fin)!=1) break; for (i=(int)uReadSize-3; (i--)>0;) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { uPosFound = uReadPos+i; break; } if (uPosFound!=0) break; } TRYFREE(buf); return uPosFound; } /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer "zlib/zlib109.zip". If the zipfile cannot be opened (file don't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ extern unzFile ZEXPORT unzOpen (path) const char *path; { unz_s us; unz_s *s; uLong central_pos,uL; FILE * fin ; uLong number_disk; /* number of the current dist, used for spaning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used for spaning ZIP, unsupported, always 0*/ uLong number_entry_CD; /* total number of entries in the central dir (same than number_entry on nospan) */ int err=UNZ_OK; if (unz_copyright[0]!=' ') return NULL; fin=fopen(path,"rb"); if (fin==NULL) return NULL; central_pos = unzlocal_SearchCentralDir(fin); if (central_pos==0) err=UNZ_ERRNO; if (fseek(fin,central_pos,SEEK_SET)!=0) err=UNZ_ERRNO; /* the signature, already checked */ if (unzlocal_getLong(fin,&uL)!=UNZ_OK) err=UNZ_ERRNO; /* number of this disk */ if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) err=UNZ_ERRNO; /* number of the disk with the start of the central directory */ if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central dir on this disk */ if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central dir */ if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) err=UNZ_ERRNO; if ((number_entry_CD!=us.gi.number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) err=UNZ_BADZIPFILE; /* size of the central directory */ if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) err=UNZ_ERRNO; /* offset of start of central directory with respect to the starting disk number */ if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) err=UNZ_ERRNO; /* zipfile comment length */ if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) err=UNZ_ERRNO; if ((central_pos<us.offset_central_dir+us.size_central_dir) && (err==UNZ_OK)) err=UNZ_BADZIPFILE; if (err!=UNZ_OK) { fclose(fin); return NULL; } us.file=fin; us.byte_before_the_zipfile = central_pos - (us.offset_central_dir+us.size_central_dir); us.central_pos = central_pos; us.pfile_in_zip_read = NULL; s=(unz_s*)ALLOC(sizeof(unz_s)); *s=us; unzGoToFirstFile((unzFile)s); return (unzFile)s; } /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzClose (file) unzFile file; { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (s->pfile_in_zip_read!=NULL) unzCloseCurrentFile(file); fclose(s->file); TRYFREE(s); return UNZ_OK; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) unzFile file; unz_global_info *pglobal_info; { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; *pglobal_info=s->gi; return UNZ_OK; } /* Translate date/time from Dos format to tm_unz (readable more easilty) */ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) uLong ulDosDate; tm_unz* ptm; { uLong uDate; uDate = (uLong)(ulDosDate>>16); ptm->tm_mday = (uInt)(uDate&0x1f) ; ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; } /* Get Info about the current file in the zipfile, with internal only info */ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); local int unzlocal_GetCurrentFileInfoInternal (file, pfile_info, pfile_info_internal, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) unzFile file; unz_file_info *pfile_info; unz_file_info_internal *pfile_info_internal; char *szFileName; uLong fileNameBufferSize; void *extraField; uLong extraFieldBufferSize; char *szComment; uLong commentBufferSize; { unz_s* s; unz_file_info file_info; unz_file_info_internal file_info_internal; int err=UNZ_OK; uLong uMagic; long lSeek=0; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) err=UNZ_ERRNO; /* we check the magic */ if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x02014b50) err=UNZ_BADZIPFILE; } if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) err=UNZ_ERRNO; unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) err=UNZ_ERRNO; lSeek+=file_info.size_filename; if ((err==UNZ_OK) && (szFileName!=NULL)) { uLong uSizeRead ; if (file_info.size_filename<fileNameBufferSize) { *(szFileName+file_info.size_filename)='\0'; uSizeRead = file_info.size_filename; } else uSizeRead = fileNameBufferSize; if ((file_info.size_filename>0) && (fileNameBufferSize>0)) if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) err=UNZ_ERRNO; lSeek -= uSizeRead; } if ((err==UNZ_OK) && (extraField!=NULL)) { uLong uSizeRead ; if (file_info.size_file_extra<extraFieldBufferSize) uSizeRead = file_info.size_file_extra; else uSizeRead = extraFieldBufferSize; if (lSeek!=0) { if (fseek(s->file,lSeek,SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; } if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) err=UNZ_ERRNO; lSeek += file_info.size_file_extra - uSizeRead; } else lSeek+=file_info.size_file_extra; if ((err==UNZ_OK) && (szComment!=NULL)) { uLong uSizeRead ; if (file_info.size_file_comment<commentBufferSize) { *(szComment+file_info.size_file_comment)='\0'; uSizeRead = file_info.size_file_comment; } else uSizeRead = commentBufferSize; if (lSeek!=0) { if (fseek(s->file,lSeek,SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; } if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) err=UNZ_ERRNO; lSeek+=file_info.size_file_comment - uSizeRead; } else lSeek+=file_info.size_file_comment; if ((err==UNZ_OK) && (pfile_info!=NULL)) *pfile_info=file_info; if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) *pfile_info_internal=file_info_internal; return err; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetCurrentFileInfo (file, pfile_info, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) unzFile file; unz_file_info *pfile_info; char *szFileName; uLong fileNameBufferSize; void *extraField; uLong extraFieldBufferSize; char *szComment; uLong commentBufferSize; { return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, szFileName,fileNameBufferSize, extraField,extraFieldBufferSize, szComment,commentBufferSize); } /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToFirstFile (file) unzFile file; { int err=UNZ_OK; unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; s->pos_in_central_dir=s->offset_central_dir; s->num_file=0; err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzGoToNextFile (file) unzFile file; { unz_s* s; int err; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; if (s->num_file+1==s->gi.number_entry) return UNZ_END_OF_LIST_OF_FILE; s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; s->num_file++; err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzipStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) unzFile file; const char *szFileName; int iCaseSensitivity; { unz_s* s; int err; uLong num_fileSaved; uLong pos_in_central_dirSaved; if (file==NULL) return UNZ_PARAMERROR; if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; num_fileSaved = s->num_file; pos_in_central_dirSaved = s->pos_in_central_dir; err = unzGoToFirstFile(file); while (err == UNZ_OK) { char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; unzGetCurrentFileInfo(file,NULL, szCurrentFileName,sizeof(szCurrentFileName)-1, NULL,0,NULL,0); if (unzStringFileNameCompare(szCurrentFileName, szFileName,iCaseSensitivity)==0) return UNZ_OK; err = unzGoToNextFile(file); } s->num_file = num_fileSaved ; s->pos_in_central_dir = pos_in_central_dirSaved ; return err; } /* Read the local header of the current zipfile Check the coherency of the local header and info in the end of central directory about this file store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, poffset_local_extrafield, psize_local_extrafield) unz_s* s; uInt* piSizeVar; uLong *poffset_local_extrafield; uInt *psize_local_extrafield; { uLong uMagic,uData,uFlags; uLong size_filename; uLong size_extra_field; int err=UNZ_OK; *piSizeVar = 0; *poffset_local_extrafield = 0; *psize_local_extrafield = 0; if (fseek(s->file,s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile,SEEK_SET)!=0) return UNZ_ERRNO; if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) err=UNZ_BADZIPFILE; } if (unzlocal_getShort(s->file,&uData) != UNZ_OK) err=UNZ_ERRNO; /* else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) err=UNZ_BADZIPFILE; */ if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&uData) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) err=UNZ_BADZIPFILE; if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) err=UNZ_BADZIPFILE; *piSizeVar += (uInt)size_filename; if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) err=UNZ_ERRNO; *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + size_filename; *psize_local_extrafield = (uInt)size_extra_field; *piSizeVar += (uInt)size_extra_field; return err; } /* Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ extern int ZEXPORT unzOpenCurrentFile (file) unzFile file; { int err=UNZ_OK; int Store; uInt iSizeVar; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uLong offset_local_extrafield; /* offset of the local extra field */ uInt size_local_extrafield; /* size of the local extra field */ if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_PARAMERROR; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) return UNZ_BADZIPFILE; pfile_in_zip_read_info = (file_in_zip_read_info_s*) ALLOC(sizeof(file_in_zip_read_info_s)); if (pfile_in_zip_read_info==NULL) return UNZ_INTERNALERROR; pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; pfile_in_zip_read_info->pos_local_extrafield=0; if (pfile_in_zip_read_info->read_buffer==NULL) { TRYFREE(pfile_in_zip_read_info); return UNZ_INTERNALERROR; } pfile_in_zip_read_info->stream_initialised=0; if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; Store = s->cur_file_info.compression_method==0; pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; pfile_in_zip_read_info->crc32=0; pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; pfile_in_zip_read_info->file=s->file; pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; pfile_in_zip_read_info->stream.total_out = 0; if (!Store) { pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; pfile_in_zip_read_info->stream.zfree = (free_func)0; pfile_in_zip_read_info->stream.opaque = (voidpf)0; err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); if (err == Z_OK) pfile_in_zip_read_info->stream_initialised=1; /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and * return Z_STREAM_END. * In unzip, i don't wait absolutely Z_STREAM_END because I known the * size of both compressed and uncompressed data */ } pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size ; pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size ; pfile_in_zip_read_info->pos_in_zipfile = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + iSizeVar; pfile_in_zip_read_info->stream.avail_in = (uInt)0; s->pfile_in_zip_read = pfile_in_zip_read_info; return UNZ_OK; } /* Read bytes from the current file. buf contain buffer where data must be copied len the size of buf. return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern int ZEXPORT unzReadCurrentFile (file, buf, len) unzFile file; voidp buf; unsigned len; { int err=UNZ_OK; uInt iRead = 0; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if ((pfile_in_zip_read_info->read_buffer == NULL)) return UNZ_END_OF_LIST_OF_FILE; if (len==0) return 0; pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; pfile_in_zip_read_info->stream.avail_out = (uInt)len; if (len>pfile_in_zip_read_info->rest_read_uncompressed) pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed; while (pfile_in_zip_read_info->stream.avail_out>0) { if ((pfile_in_zip_read_info->stream.avail_in==0) && (pfile_in_zip_read_info->rest_read_compressed>0)) { uInt uReadThis = UNZ_BUFSIZE; if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; if (uReadThis == 0) return UNZ_EOF; if (fseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) return UNZ_ERRNO; if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, pfile_in_zip_read_info->file)!=1) return UNZ_ERRNO; pfile_in_zip_read_info->pos_in_zipfile += uReadThis; pfile_in_zip_read_info->rest_read_compressed-=uReadThis; pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->read_buffer; pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; } if (pfile_in_zip_read_info->compression_method==0) { uInt uDoCopy,i ; if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) uDoCopy = pfile_in_zip_read_info->stream.avail_out ; else uDoCopy = pfile_in_zip_read_info->stream.avail_in ; for (i=0;i<uDoCopy;i++) *(pfile_in_zip_read_info->stream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, pfile_in_zip_read_info->stream.next_out, uDoCopy); pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; pfile_in_zip_read_info->stream.avail_in -= uDoCopy; pfile_in_zip_read_info->stream.avail_out -= uDoCopy; pfile_in_zip_read_info->stream.next_out += uDoCopy; pfile_in_zip_read_info->stream.next_in += uDoCopy; pfile_in_zip_read_info->stream.total_out += uDoCopy; iRead += uDoCopy; } else { uLong uTotalOutBefore,uTotalOutAfter; const Bytef *bufBefore; uLong uOutThis; int flush=Z_SYNC_FLUSH; uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; bufBefore = pfile_in_zip_read_info->stream.next_out; /* if ((pfile_in_zip_read_info->rest_read_uncompressed == pfile_in_zip_read_info->stream.avail_out) && (pfile_in_zip_read_info->rest_read_compressed == 0)) flush = Z_FINISH; */ err=inflate(&pfile_in_zip_read_info->stream,flush); uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uOutThis = uTotalOutAfter-uTotalOutBefore; pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); if (err==Z_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead; if (err!=Z_OK) break; } } if (err==Z_OK) return iRead; return err; } /* Give the current position in uncompressed data */ extern z_off_t ZEXPORT unztell (file) unzFile file; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; return (z_off_t)pfile_in_zip_read_info->stream.total_out; } /* return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzeof (file) unzFile file; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->rest_read_uncompressed == 0) return 1; else return 0; } /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field that can be read if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) unzFile file; voidp buf; unsigned len; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uInt read_now; uLong size_to_read; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; size_to_read = (pfile_in_zip_read_info->size_local_extrafield - pfile_in_zip_read_info->pos_local_extrafield); if (buf==NULL) return (int)size_to_read; if (len>size_to_read) read_now = (uInt)size_to_read; else read_now = (uInt)len ; if (read_now==0) return 0; if (fseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) return UNZ_ERRNO; if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) return UNZ_ERRNO; return (int)read_now; } /* Close the file in zip opened with unzipOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzCloseCurrentFile (file) unzFile file; { int err=UNZ_OK; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->rest_read_uncompressed == 0) { if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) err=UNZ_CRCERROR; } TRYFREE(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; if (pfile_in_zip_read_info->stream_initialised) inflateEnd(&pfile_in_zip_read_info->stream); pfile_in_zip_read_info->stream_initialised = 0; TRYFREE(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; return err; } /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) unzFile file; char *szComment; uLong uSizeBuf; { /* int err=UNZ_OK; */ unz_s* s; uLong uReadThis ; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; uReadThis = uSizeBuf; if (uReadThis>s->gi.size_comment) uReadThis = s->gi.size_comment; if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) return UNZ_ERRNO; if (uReadThis>0) { *szComment='\0'; if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) return UNZ_ERRNO; } if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) *(szComment+s->gi.size_comment)='\0'; return (int)uReadThis; }
zyking1987-genplus-droid
genplusgx/unused/dos/unzip.c
C
gpl2
36,877
/* dos.c -- DOS interface code for the emulator */ #include "shared.h" #include "osd.h" #define FRAMES_PER_SECOND 60 #define MSG_LEN 1024 RGB vdp_palette[3][0x200]; PALETTE gen_pal; BITMAP *gen_bmp; volatile int frame_skip = 1; volatile int frame_count = 0; volatile int frames_rendered = 0; volatile int frame_rate = 0; volatile int tick_count = 0; volatile int old_tick_count = 0; volatile int skip = 0; int quit = 0; unsigned char buf[STATE_SIZE]; uint8 log_error = 1; uint8 debug_on = 0; void msg_print(int x, int y, char *fmt, ...) { int i = bitmap.viewport.x; int j = bitmap.viewport.y; va_list ap; char token[MSG_LEN]; char str[MSG_LEN]; strcpy(str, "\0"); va_start(ap, fmt); vsprintf(token, fmt, ap); strcat(str, token); va_end(ap); textprintf_ex(gen_bmp, font, i+x+1, j+y , 0x00, -1, "%s", str); textprintf_ex(gen_bmp, font, i+x-1, j+y , 0x00, -1, "%s", str); textprintf_ex(gen_bmp, font, i+x , j+y+1, 0x00, -1, "%s", str); textprintf_ex(gen_bmp, font, i+x , j+y-1, 0x00, -1, "%s", str); textprintf_ex(gen_bmp, font, i+x , j+y , 0xffff, -1, "%s", str); } int main (int argc, char *argv[]) { if(argc < 2) { printf("Genesis Plus - Sega Mega Drive emulator (v1.0)\n"); printf("(C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald\n"); printf("Usage %s file.[bin|smd|zip] [-options]\n", argv[0]); printf("Type `%s -help' for a list of options.\n", argv[0]); exit(1); }; if(stricmp(argv[1], "-help") == 0) { print_options(); return (0); } error_init(); cart.rom = malloc(0xA00000); memset(cart.rom, 0, 0xA00000); if(!load_rom(argv[1])) { printf("File `%s' not found.\n", argv[1]); return (0); } /* load BIOS */ memset(bios_rom, 0, sizeof(bios_rom)); FILE *f = fopen("./BIOS.bin", "rb"); if (f!=NULL) { fread(&bios_rom, 0x800,1,f); fclose(f); int i; for(i = 0; i < 0x800; i += 2) { uint8 temp = bios_rom[i]; bios_rom[i] = bios_rom[i+1]; bios_rom[i+1] = temp; } config.tmss |= 2; } /* initialize genesis VM */ init_machine(); /* default config */ do_config("genplus.cfg"); set_config_defaults(); /* initialize emulation */ system_init(); audio_init(option.sndrate, vdp_pal ? 50 : 60); f = fopen("./game.srm", "rb"); if (f!=NULL) { fread(&sram.sram,0x10000,1, f); fclose(f); } /* reset emulation */ system_reset(); /* emulation loop */ for(;;) { dos_update_input(); frame_count += 1; if(quit) break; if(frame_count % frame_skip == 0) { system_frame(0); frames_rendered++; dos_update_video(); } else { system_frame(1); } audio_update(); if(option.sound) dos_update_audio(); } f = fopen("./game.srm", "wb"); if (f!=NULL) { fwrite(&sram.sram, 0x10000,1,f); fclose(f); } trash_machine(); system_shutdown(); error_shutdown(); free(cart.rom); return (0); } /* Timer handler */ void tick_handler(void) { tick_count += 1; if(tick_count % FRAMES_PER_SECOND == 0) { frame_rate = frames_rendered; frames_rendered = 0; } } END_OF_FUNCTION(tick_handler); int load_file(char *filename, char *buf, int size) { FILE *fd = fopen(filename, "rb"); if(!fd) return (0); fread(buf, size, 1, fd); fclose(fd); return (1); } int save_file(char *filename, char *buf, int size) { FILE *fd = NULL; if(!(fd = fopen(filename, "wb"))) return (0); fwrite(buf, size, 1, fd); fclose(fd); return (1); } static int joynum = 0; void dos_update_input(void) { FILE *f; if(key[KEY_ESC] || key[KEY_END]) { quit = 1; } while (input.dev[joynum] == NO_DEVICE) { joynum ++; if (joynum > MAX_DEVICES - 1) joynum = 0; } if(check_key(KEY_F11)) { joynum ++; if (joynum > MAX_DEVICES - 1) joynum = 0; while (input.dev[joynum] == NO_DEVICE) { joynum ++; if (joynum > MAX_DEVICES - 1) joynum = 0; } } input.pad[joynum] = 0; /* Is the joystick being used ? */ if(option.joy_driver != JOY_TYPE_NONE) { poll_joystick(); /* Check player 1 joystick */ if(joy[0].stick[0].axis[1].d1) input.pad[0] |= INPUT_UP; else if(joy[0].stick[0].axis[1].d2) input.pad[0] |= INPUT_DOWN; if(joy[0].stick[0].axis[0].d1) input.pad[0] |= INPUT_LEFT; else if(joy[0].stick[0].axis[0].d2) input.pad[0] |= INPUT_RIGHT; if(joy[0].button[0].b) input.pad[0] |= INPUT_A; if(joy[0].button[1].b) input.pad[0] |= INPUT_B; if(joy[0].button[2].b) input.pad[0] |= INPUT_C; if(joy[0].button[3].b) input.pad[0] |= INPUT_START; if(joy[0].button[4].b) input.pad[0] |= INPUT_X; if(joy[0].button[5].b) input.pad[0] |= INPUT_Y; if(joy[0].button[6].b) input.pad[0] |= INPUT_Z; if(joy[0].button[7].b) input.pad[0] |= INPUT_MODE; /* More than one joystick supported ? */ if(num_joysticks > 2) { /* Check player 2 joystick */ if(joy[1].stick[0].axis[1].d1) input.pad[1] |= INPUT_UP; else if(joy[1].stick[0].axis[1].d2) input.pad[1] |= INPUT_DOWN; if(joy[1].stick[0].axis[0].d1) input.pad[1] |= INPUT_LEFT; else if(joy[1].stick[0].axis[0].d1) input.pad[1] |= INPUT_RIGHT; if(joy[1].button[0].b) input.pad[1] |= INPUT_A; if(joy[1].button[1].b) input.pad[1] |= INPUT_B; if(joy[1].button[2].b) input.pad[1] |= INPUT_C; if(joy[1].button[3].b) input.pad[1] |= INPUT_START; if(joy[1].button[4].b) input.pad[1] |= INPUT_X; if(joy[1].button[5].b) input.pad[1] |= INPUT_Y; if(joy[1].button[6].b) input.pad[1] |= INPUT_Z; if(joy[1].button[7].b) input.pad[1] |= INPUT_MODE; } } /* keyboard */ if(key[KEY_UP]) input.pad[joynum] |= INPUT_UP; else if(key[KEY_DOWN]) input.pad[joynum] |= INPUT_DOWN; if(key[KEY_LEFT]) input.pad[joynum] |= INPUT_LEFT; else if(key[KEY_RIGHT]) input.pad[joynum] |= INPUT_RIGHT; if(key[KEY_A]) input.pad[joynum] |= INPUT_A; if(key[KEY_S]) input.pad[joynum] |= INPUT_B; if(key[KEY_D]) input.pad[joynum] |= INPUT_C; if(key[KEY_Z]) input.pad[joynum] |= INPUT_X; if(key[KEY_X]) input.pad[joynum] |= INPUT_Y; if(key[KEY_C]) input.pad[joynum] |= INPUT_Z; if(key[KEY_V]) input.pad[joynum] |= INPUT_MODE; if(key[KEY_F]) input.pad[joynum] |= INPUT_START; extern uint8 pico_current; if (input.dev[joynum] == DEVICE_LIGHTGUN) { /* Poll mouse if necessary */ if(mouse_needs_poll() == TRUE) poll_mouse(); /* Calculate X Y axis values */ input.analog[joynum][0] = (mouse_x * bitmap.viewport.w) / SCREEN_W; input.analog[joynum][1] = (mouse_y * bitmap.viewport.h) / SCREEN_H; /* Map mouse buttons to player #1 inputs */ if(mouse_b & 4) input.pad[joynum] |= INPUT_C; if(mouse_b & 2) input.pad[joynum] |= INPUT_B; if(mouse_b & 1) input.pad[joynum] |= INPUT_A; } else if (input.dev[joynum] == DEVICE_MOUSE) { /* Poll mouse if necessary */ if(mouse_needs_poll() == TRUE) poll_mouse(); /* Get X & Y quantity of movement */ get_mouse_mickeys(&input.analog[joynum][0], &input.analog[joynum][1]); /* Sega Mouse range is -256;+256 */ input.analog[joynum][0] = (input.analog[joynum][0] * 256) / SCREEN_W; input.analog[joynum][1] = (input.analog[joynum][1] * 256) / SCREEN_H; /* Vertical movement is upsidedown */ if (!config.invert_mouse) input.analog[joynum][1] = 0 - input.analog[joynum][1]; /* Map mouse buttons to player #1 inputs */ if(mouse_b & 4) input.pad[joynum] |= INPUT_C; if(mouse_b & 1) input.pad[joynum] |= INPUT_B; if(mouse_b & 2) input.pad[joynum] |= INPUT_A; } else if (system_hw == SYSTEM_PICO) { /* Poll mouse if necessary */ if(mouse_needs_poll() == TRUE) poll_mouse(); /* Calculate X Y axis values */ input.analog[0][0] = 0x3c + (mouse_x * (0x17c-0x03c+1)) / SCREEN_W; input.analog[0][1] = 0x1fc + (mouse_y * (0x2f7-0x1fc+1)) / SCREEN_H; /* Map mouse buttons to player #1 inputs */ if(mouse_b & 2) input.pad[0] |= INPUT_B; if(mouse_b & 1) input.pad[0] |= INPUT_A; if(mouse_b & 4) pico_current++; if (pico_current > 6) pico_current = 0; } if(check_key(KEY_F1)) frame_skip = 1; if(check_key(KEY_F2)) frame_skip = 2; if(check_key(KEY_F3)) frame_skip = 3; if(check_key(KEY_F4)) frame_skip = 4; if(check_key(KEY_F5)) log_error ^= 1; if(check_key(KEY_F6)) debug_on ^= 1; if(check_key(KEY_F7)) { f = fopen("game.gpz","r+b"); if (f) { fread(&buf, STATE_SIZE, 1, f); state_load(buf); fclose(f); } } if(check_key(KEY_F8)) { f = fopen("game.gpz","w+b"); if (f) { state_save(buf); fwrite(&buf, STATE_SIZE, 1, f); fclose(f); } } if(check_key(KEY_F9)) { vdp_pal ^= 1; /* save YM2612 context */ unsigned char *temp = malloc(YM2612GetContextSize()); if (temp) memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize()); /* reinitialize all timings */ audio_init(snd.sample_rate, snd.frame_rate); system_init(); /* restore YM2612 context */ if (temp) { YM2612Restore(temp); free(temp); } /* reinitialize VC max value */ static const uint16 vc_table[4][2] = { /* NTSC, PAL */ {0xDA , 0xF2}, /* Mode 4 (192 lines) */ {0xEA , 0x102}, /* Mode 5 (224 lines) */ {0xDA , 0xF2}, /* Mode 4 (192 lines) */ {0x106, 0x10A} /* Mode 5 (240 lines) */ }; vc_max = vc_table[(reg[1] >> 2) & 3][vdp_pal]; /* reinitialize overscan area */ bitmap.viewport.y = (config.overscan & 1) ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0; } if(check_key(KEY_F10)) set_softreset(); if(check_key(KEY_TAB)) system_reset(); } void dos_update_audio(void) { osd_play_streamed_sample_16(option.swap ^ 0, snd.buffer[0], snd.buffer_size * 2, option.sndrate, FRAMES_PER_SECOND, -100); osd_play_streamed_sample_16(option.swap ^ 1, snd.buffer[1], snd.buffer_size * 2, option.sndrate, FRAMES_PER_SECOND, 100); } #if 0 void dos_update_palette(void) { if(is_border_dirty) { uint16 data = *(uint16 *)&cram[(border << 1)]; RGB *color; is_border_dirty = 0; if(reg[12] & 8) { int j; for(j = 0; j < 3; j += 1) { color = &vdp_palette[j][data]; set_color((j << 6), color); } } else { color = &vdp_palette[1][data]; set_color(0x00, color); set_color(0x40, color); set_color(0x80, color); } } if(is_color_dirty) { int i; uint16 *p = (uint16 *)&cram[0]; is_color_dirty = 0; for(i = 0; i < 64; i += 1) { if((color_dirty[i]) && ((i & 0x0F) != 0x00)) { RGB *color; color_dirty[i] = 0; if(reg[12] & 8) { int j; for(j = 0; j < 3; j += 1) { color = &vdp_palette[j][p[i]]; set_color((j << 6) | i, color); } } else { color = &vdp_palette[1][p[i]]; set_color(0x00 | i, color); set_color(0x40 | i, color); set_color(0x80 | i, color); } } } } } #endif void dos_update_video(void) { int width = (bitmap.viewport.w + 2 * bitmap.viewport.x); int height = (bitmap.viewport.h + 2 * bitmap.viewport.y) << (interlaced ? 1:0); int center_x = (SCREEN_W - width) / 2; int center_y = (SCREEN_H / (option.scanlines ? 4 : 2)) - (height / 2); /* Wait for VSync */ if(option.vsync) vsync(); if(bitmap.viewport.changed) { bitmap.viewport.changed = 0; if(bitmap.remap) { clear(screen); } else { clear_to_color(screen, 0xFF); } } #if 0 if(bitmap.remap == 0) { dos_update_palette(); } #endif msg_print(2, 2, "%d", frame_rate); if(option.scanlines) { int y; for(y = 0; y < height; y += 1) { blit(gen_bmp, screen, 0x0, y, center_x, (center_y + y) << 1, width, 1); } } else { stretch_blit(gen_bmp, screen, 0, 0, width, height, (SCREEN_W-352)/2, (SCREEN_H-240)/2, 352,240 << (interlaced ? 1:0)); } } void init_machine(void) { do_config("gen.cfg"); if(option.sound) { msdos_init_sound(&option.sndrate, option.sndcard); } allegro_init(); install_mouse(); install_keyboard(); install_joystick(option.joy_driver); install_timer(); LOCK_FUNCTION(tick_handler); LOCK_VARIABLE(tick_count); LOCK_VARIABLE(frame_rate); install_int_ex(tick_handler, BPS_TO_TIMER(FRAMES_PER_SECOND)); set_color_depth(option.video_depth); gen_bmp = create_bitmap(720, 576); clear(gen_bmp); memset(&bitmap, 0, sizeof(bitmap)); bitmap.data = (uint8 *)&gen_bmp->line[0][0]; bitmap.width = gen_bmp->w; bitmap.height = gen_bmp->h; bitmap.depth = option.video_depth; switch(option.video_depth) { case 8: bitmap.granularity = 1; break; case 15: bitmap.granularity = 2; break; case 16: bitmap.granularity = 2; break; case 32: bitmap.granularity = 4; break; } bitmap.pitch = (bitmap.width * bitmap.granularity); bitmap.viewport.w = 256; bitmap.viewport.h = 224; bitmap.viewport.x = 0x00; bitmap.viewport.y = 0x00; bitmap.remap = 0; if(option.remap) bitmap.remap = 1; else if(bitmap.depth > 8) bitmap.remap = 1; make_vdp_palette(); memcpy(gen_pal, black_palette, sizeof(PALETTE)); gen_pal[0xFE].r = \ gen_pal[0xFE].g = \ gen_pal[0xFE].b = 0x3F; dos_change_mode(); } void trash_machine(void) { if(option.sound) { msdos_shutdown_sound(); } clear(screen); destroy_bitmap(gen_bmp); set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); } void make_vdp_palette(void) { uint8 lut[3][8] = { {0x00, 0x04, 0x08, 0x0C, 0x10, 0x14, 0x18, 0x1C}, {0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38}, {0x20, 0x24, 0x28, 0x2C, 0x30, 0x34, 0x38, 0x3C}, }; int j; for(j = 0; j < 0x600; j += 1) { int r = (j >> 6) & 7; int g = (j >> 3) & 7; int b = (j >> 0) & 7; int i = (j >> 9) & 3; vdp_palette[i][j & 0x1FF].r = lut[i][r]; vdp_palette[i][j & 0x1FF].g = lut[i][g]; vdp_palette[i][j & 0x1FF].b = lut[i][b]; } } void dos_change_mode(void) { int ret; int width = option.video_width; int height = option.video_height; if(option.scanlines) height *= 2; ret = set_gfx_mode(option.video_driver, width, height, 0, 0); if(ret != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); printf("Error setting graphics mode (%dx%d %dbpp).\nAllegro says: `%s'\n", width, height, option.video_depth, allegro_error); exit(1); } if(bitmap.depth == 8) { if(bitmap.remap) { int i; for(i = 0; i < 0x100; i += 1) { gen_pal[i].r = ((i >> 5) & 7) << 3; gen_pal[i].g = ((i >> 2) & 7) << 3; gen_pal[i].b = ((i >> 0) & 3) << 4; } set_palette(gen_pal); } else { clear_to_color(screen, 0xFF); gen_pal[0xfe].r = 0xff; gen_pal[0xfe].g = 0xff; gen_pal[0xfe].b = 0xff; set_palette(gen_pal); inp(0x3DA); outp(0x3C0, 0x31); outp(0x3C0, 0xFF); } } else { clear(screen); } } /* Check if a key is pressed */ int check_key(int code) { static char lastbuf[0x100] = {0}; if((!key[code]) && (lastbuf[code] == 1)) lastbuf[code] = 0; if((key[code]) && (lastbuf[code] == 0)) { lastbuf[code] = 1; return (1); } return (0); }
zyking1987-genplus-droid
genplusgx/unused/dos/dos.c
C
gpl2
16,262
#ifndef _ERROR_H_ #define _ERROR_H_ /* Global variables */ FILE *error_log; /* Function prototypes */ void error_init(void); void error_shutdown(void); void error(char *format, ...); #endif /* _ERROR_H_ */
zyking1987-genplus-droid
genplusgx/unused/dos/error.h
C
gpl2
223
#ifndef _SEALINTF_H_ #define _SEALINTF_H_ #define MAX_SOUND 4 #define NUMVOICES 16 #define MAX_STREAM_CHANNELS 6 /* Function prototypes */ void osd_update_audio(void); void osd_set_mastervolume(int _attenuation); int msdos_init_sound(int *rate, int card); void msdos_shutdown_sound(void); void playstreamedsample(int channel,signed char *data,int len,int freq,int volume,int pan,int bits); void osd_play_streamed_sample_16(int channel,signed short *data,int len,int freq,int volume,int pan); #endif /* _SEALINTF_H_ */
zyking1987-genplus-droid
genplusgx/unused/dos/SEALINTF.H
C
gpl2
571
/* unzip.h -- IO for uncompress .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Copyright (C) 1998 Gilles Vollant This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g WinZip, InfoZip tools and compatible. Encryption and multi volume ZipFile (span) are not supported. Old compressions used by old PKZip 1.x are not supported THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE CAN CHANGE IN FUTURE VERSION !! I WAIT FEEDBACK at mail info@winimage.com Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution Condition of use and distribution are the same than zlib : This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* for more info about .ZIP format, see ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip PkWare has also a specification at : ftp://ftp.pkware.com/probdesc.zip */ #ifndef _unz_H #define _unz_H #ifdef __cplusplus extern "C" { #endif #ifndef _ZLIB_H #include "zlib.h" #endif #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ typedef struct TagunzFile__ { int unused; } unzFile__; typedef unzFile__ *unzFile; #else typedef voidp unzFile; #endif #define UNZ_OK (0) #define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_ERRNO (Z_ERRNO) #define UNZ_EOF (0) #define UNZ_PARAMERROR (-102) #define UNZ_BADZIPFILE (-103) #define UNZ_INTERNALERROR (-104) #define UNZ_CRCERROR (-105) /* tm_unz contain date/time info */ typedef struct tm_unz_s { uInt tm_sec; /* seconds after the minute - [0,59] */ uInt tm_min; /* minutes after the hour - [0,59] */ uInt tm_hour; /* hours since midnight - [0,23] */ uInt tm_mday; /* day of the month - [1,31] */ uInt tm_mon; /* months since January - [0,11] */ uInt tm_year; /* years - [1980..2044] */ } tm_unz; /* unz_global_info structure contain global data about the ZIPfile These data comes from the end of central dir */ typedef struct unz_global_info_s { uLong number_entry; /* total number of entries in the central dir on this disk */ uLong size_comment; /* size of the global comment of the zipfile */ } unz_global_info; /* unz_file_info contain information about a file in the zipfile */ typedef struct unz_file_info_s { uLong version; /* version made by 2 bytes */ uLong version_needed; /* version needed to extract 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */ uLong compression_method; /* compression method 2 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong crc; /* crc-32 4 bytes */ uLong compressed_size; /* compressed size 4 bytes */ uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong size_filename; /* filename length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_comment; /* file comment length 2 bytes */ uLong disk_num_start; /* disk number start 2 bytes */ uLong internal_fa; /* internal file attributes 2 bytes */ uLong external_fa; /* external file attributes 4 bytes */ tm_unz tmu_date; } unz_file_info; extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, const char* fileName2, int iCaseSensitivity)); /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ extern unzFile ZEXPORT unzOpen OF((const char *path)); /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer "zlib/zlib111.zip". If the zipfile cannot be opened (file don't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ extern int ZEXPORT unzClose OF((unzFile file)); /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, unz_global_info *pglobal_info)); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalComment OF((unzFile file, char *szComment, uLong uSizeBuf)); /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ /***************************************************************************/ /* Unzip package allow you browse the directory of the zipfile */ extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToNextFile OF((unzFile file)); /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzLocateFile OF((unzFile file, const char *szFileName, int iCaseSensitivity)); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); /* Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain somes info about the current file if szFileName!=NULL, the filemane string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). This is the Central-header version of the extra field if szComment!=NULL, the comment string of the file will be copied in szComment (commentBufferSize is the size of the buffer) */ /***************************************************************************/ /* for reading the content of the current zipfile, you can open it, read data from it, and close it (you can close it before reading all the file) */ extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); /* Open for reading data the current file in the zipfile. If there is no error, the return value is UNZ_OK. */ extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); /* Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, voidp buf, unsigned len)); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied len the size of buf. return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern z_off_t ZEXPORT unztell OF((unzFile file)); /* Give the current position in uncompressed data */ extern int ZEXPORT unzeof OF((unzFile file)); /* return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, voidp buf, unsigned len)); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ #ifdef __cplusplus } #endif #endif /* _unz_H */
zyking1987-genplus-droid
genplusgx/unused/dos/unzip.h
C
gpl2
10,294
#include "osd.h" int seal_sample_rate = 44100; int seal_sound_card = -1; HAC hVoice[NUMVOICES]; LPAUDIOWAVE lpWave[NUMVOICES]; AUDIOINFO info; AUDIOCAPS caps; int c[MAX_STREAM_CHANNELS]; int nominal_sample_rate; static int attenuation = 0; static int master_volume = 256; void osd_update_audio(void) { if (seal_sample_rate == 0) return; AUpdateAudio(); } /* attenuation in dB */ void osd_set_mastervolume(int _attenuation) { float volume; attenuation = _attenuation; volume = 256.0; /* range is 0-256 */ while (_attenuation++ < 0) volume /= 1.122018454; /* = (10 ^ (1/20)) = 1dB */ master_volume = volume; ASetAudioMixerValue(AUDIO_MIXER_MASTER_VOLUME,master_volume); } int msdos_init_sound(int *rate, int card) { int i; seal_sample_rate = *rate; seal_sound_card = card; if (AInitialize() != AUDIO_ERROR_NONE) return 1; /* Ask the user if no sound card was chosen */ if (seal_sound_card == -1) { unsigned int k; printf("\n SELECT YOUR AUDIO DEVICE :\n\n" " AWE32/64 playback requires onboard DRAM,\n" " Sound Blaster playback is the most compatible & better for emulation\n\n"); for (k = 0;k < AGetAudioNumDevs();k++) { if (AGetAudioDevCaps(k,&caps) == AUDIO_ERROR_NONE) printf(" %2d. %s\n",k,caps.szProductName); } printf("\n"); if (k < 10) { i = getch(); seal_sound_card = i - '0'; } else scanf("%d",&seal_sound_card); } /* initialize SEAL audio library */ if (seal_sound_card == 0) /* silence */ { /* update the Machine structure to show that sound is disabled */ seal_sample_rate = 0; exit(0); return 0; } /* open audio device */ /* info.nDeviceId = AUDIO_DEVICE_MAPPER;*/ info.nDeviceId = seal_sound_card; /* always use 16 bit mixing if possible - better quality and same speed of 8 bit */ info.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO | AUDIO_FORMAT_RAW_SAMPLE; info.nSampleRate = seal_sample_rate; if (AOpenAudio(&info) != AUDIO_ERROR_NONE) { return (1); } AGetAudioDevCaps(info.nDeviceId,&caps); printf("Using `%s' at %d-bit %s %u Hz\n", caps.szProductName, info.wFormat & AUDIO_FORMAT_16BITS ? 16 : 8, info.wFormat & AUDIO_FORMAT_STEREO ? "stereo" : "mono", info.nSampleRate); /* open and allocate voices, allocate waveforms */ if (AOpenVoices(NUMVOICES) != AUDIO_ERROR_NONE) { printf("voices initialization failed\n"); return 1; } for (i = 0; i < NUMVOICES; i++) { if (ACreateAudioVoice(&hVoice[i]) != AUDIO_ERROR_NONE) { printf("voice #%d creation failed\n",i); return 1; } ASetVoicePanning(hVoice[i],128); lpWave[i] = 0; } /* update the Machine structure to reflect the actual sample rate */ *rate = seal_sample_rate = info.nSampleRate; { uclock_t a,b; LONG start,end; if ((lpWave[0] = (LPAUDIOWAVE)malloc(sizeof(AUDIOWAVE))) == 0) return 1; lpWave[0]->wFormat = AUDIO_FORMAT_8BITS | AUDIO_FORMAT_MONO; lpWave[0]->nSampleRate = seal_sample_rate; lpWave[0]->dwLength = 3*seal_sample_rate; lpWave[0]->dwLoopStart = 0; lpWave[0]->dwLoopEnd = 3*seal_sample_rate; if (ACreateAudioData(lpWave[0]) != AUDIO_ERROR_NONE) { free(lpWave[0]); lpWave[0] = 0; return 1; } memset(lpWave[0]->lpData,0,3*seal_sample_rate); /* upload the data to the audio DRAM local memory */ AWriteAudioData(lpWave[0],0,3*seal_sample_rate); APrimeVoice(hVoice[0],lpWave[0]); ASetVoiceFrequency(hVoice[0],seal_sample_rate); ASetVoiceVolume(hVoice[0],0); AStartVoice(hVoice[0]); a = uclock(); /* wait some time to let everything stabilize */ do { osd_update_audio(); b = uclock(); } while (b-a < UCLOCKS_PER_SEC/10); a = uclock(); AGetVoicePosition(hVoice[0],&start); do { osd_update_audio(); b = uclock(); } while (b-a < UCLOCKS_PER_SEC); AGetVoicePosition(hVoice[0],&end); nominal_sample_rate = seal_sample_rate; seal_sample_rate = end - start; AStopVoice(hVoice[0]); ADestroyAudioData(lpWave[0]); free(lpWave[0]); lpWave[0] = 0; } osd_set_mastervolume(0); /* start at maximum volume */ return 0; } void msdos_shutdown_sound(void) { if (seal_sample_rate != 0) { int n; /* stop and release voices */ for (n = 0; n < NUMVOICES; n++) { AStopVoice(hVoice[n]); ADestroyAudioVoice(hVoice[n]); if (lpWave[n]) { ADestroyAudioData(lpWave[n]); free(lpWave[n]); lpWave[n] = 0; } } ACloseVoices(); ACloseAudio(); } } void playstreamedsample(int channel,signed char *data,int len,int freq,int volume,int pan,int bits) { static int playing[NUMVOICES]; static int c[NUMVOICES]; /* backwards compatibility with old 0-255 volume range */ if (volume > 100) volume = volume * 25 / 255; if (seal_sample_rate == 0 || channel >= NUMVOICES) return; if (!playing[channel]) { if (lpWave[channel]) { AStopVoice(hVoice[channel]); ADestroyAudioData(lpWave[channel]); free(lpWave[channel]); lpWave[channel] = 0; } if ((lpWave[channel] = (LPAUDIOWAVE)malloc(sizeof(AUDIOWAVE))) == 0) return; lpWave[channel]->wFormat = (bits == 8 ? AUDIO_FORMAT_8BITS : AUDIO_FORMAT_16BITS) | AUDIO_FORMAT_MONO | AUDIO_FORMAT_LOOP; lpWave[channel]->nSampleRate = nominal_sample_rate; lpWave[channel]->dwLength = 3*len; lpWave[channel]->dwLoopStart = 0; lpWave[channel]->dwLoopEnd = 3*len; if (ACreateAudioData(lpWave[channel]) != AUDIO_ERROR_NONE) { free(lpWave[channel]); lpWave[channel] = 0; return; } memset(lpWave[channel]->lpData,0,3*len); memcpy(lpWave[channel]->lpData,data,len); /* upload the data to the audio DRAM local memory */ AWriteAudioData(lpWave[channel],0,3*len); APrimeVoice(hVoice[channel],lpWave[channel]); /* need to cast to double because freq*nominal_sample_rate can exceed the size of an int */ ASetVoiceFrequency(hVoice[channel],(double)freq*nominal_sample_rate/seal_sample_rate); AStartVoice(hVoice[channel]); playing[channel] = 1; c[channel] = 1; } else { LONG pos; for(;;) { AGetVoicePosition(hVoice[channel],&pos); if (c[channel] == 0 && pos >= len) break; if (c[channel] == 1 && (pos < len || pos >= 2*len)) break; if (c[channel] == 2 && pos < 2*len) break; osd_update_audio(); } memcpy(&lpWave[channel]->lpData[len * c[channel]],data,len); AWriteAudioData(lpWave[channel],len*c[channel],len); c[channel]++; if (c[channel] == 3) c[channel] = 0; } ASetVoiceVolume(hVoice[channel],volume * 64 / 100); ASetVoicePanning(hVoice[channel],(pan + 100) * 255 / 200); } void osd_play_streamed_sample_16(int channel,signed short *data,int len,int freq,int volume,int pan) { playstreamedsample(channel,(signed char *)data,len,freq,volume,pan,16); }
zyking1987-genplus-droid
genplusgx/unused/dos/SEALINTF.C
C
gpl2
7,342
#ifndef _OSD_H_ #define _OSD_H_ #include <stdio.h> #include <allegro.h> #include <string.h> #include <audio.h> #include <time.h> #include <conio.h> #include "shared.h" #include "dos.h" #include "config.h" #include "sealintf.h" #include "error.h" #include "unzip.h" #include "fileio.h" volatile int frame_count; #endif /* _OSD_H_ */
zyking1987-genplus-droid
genplusgx/unused/dos/osd.h
C
gpl2
359
#include "shared.h" /* Load a normal file, or ZIP/GZ archive. Returns NULL if an error occured. */ uint8 *load_archive(char *filename, int *file_size) { int size = 0; uint8 *buf = NULL; if(check_zip(filename)) { unzFile *fd = NULL; unz_file_info info; int ret = 0; /* Attempt to open the archive */ fd = unzOpen(filename); if(!fd) return (NULL); /* Go to first file in archive */ ret = unzGoToFirstFile(fd); if(ret != UNZ_OK) { unzClose(fd); return (NULL); } ret = unzGetCurrentFileInfo(fd, &info, filename, 128, NULL, 0, NULL, 0); if(ret != UNZ_OK) { unzClose(fd); return (NULL); } /* Open the file for reading */ ret = unzOpenCurrentFile(fd); if(ret != UNZ_OK) { unzClose(fd); return (NULL); } /* Allocate file data buffer */ size = info.uncompressed_size; buf = malloc(size); if(!buf) { unzClose(fd); return (NULL); } /* Read (decompress) the file */ ret = unzReadCurrentFile(fd, buf, info.uncompressed_size); if(ret != info.uncompressed_size) { free(buf); unzCloseCurrentFile(fd); unzClose(fd); return (NULL); } /* Close the current file */ ret = unzCloseCurrentFile(fd); if(ret != UNZ_OK) { free(buf); unzClose(fd); return (NULL); } /* Close the archive */ ret = unzClose(fd); if(ret != UNZ_OK) { free(buf); return (NULL); } /* Update file size and return pointer to file data */ *file_size = size; return (buf); } else { gzFile *gd = NULL; /* Open file */ gd = gzopen(filename, "rb"); if(!gd) return (0); /* Get file size */ size = gzsize(gd); /* Allocate file data buffer */ buf = malloc(size); if(!buf) { gzclose(gd); return (0); } /* Read file data */ gzread(gd, buf, size); /* Close file */ gzclose(gd); /* Update file size and return pointer to file data */ *file_size = size; return (buf); } } /* Verifies if a file is a ZIP archive or not. Returns: 1= ZIP archive, 0= not a ZIP archive */ int check_zip(char *filename) { uint8 buf[2]; FILE *fd = NULL; fd = fopen(filename, "rb"); if(!fd) return (0); fread(buf, 2, 1, fd); fclose(fd); if(memcmp(buf, "PK", 2) == 0) return (1); return (0); } /* Returns the size of a GZ compressed file. */ int gzsize(gzFile *gd) { #define CHUNKSIZE (0x10000) int size = 0, length = 0; unsigned char buffer[CHUNKSIZE]; gzrewind(gd); do { size = gzread(gd, buffer, CHUNKSIZE); if(size <= 0) break; length += size; } while (!gzeof(gd)); gzrewind(gd); return (length); #undef CHUNKSIZE }
zyking1987-genplus-droid
genplusgx/unused/dos/fileio.c
C
gpl2
3,371
#include "osd.h" t_option option; t_config config; void do_config(char *file) { extern int __crt0_argc; extern char **__crt0_argv; /* Our token list */ int i, argc; char *argv[TOKEN_LIST_SIZE]; set_option_defaults(); for(i = 0; i < TOKEN_LIST_SIZE; i += 1) argv[i] = NULL; /* Check configuration file */ if(file) parse_file(file, &argc, argv); /* Check extracted tokens */ parse_args(argc, argv); /* Free token list */ for(i = 0; i < argc; i += 1) if(argv[argc]) free (argv[argc]); /* Check command line */ parse_args(__crt0_argc, __crt0_argv); } /* Parse configuration file */ int parse_file(char *filename, int *argc, char **argv) { char token[0x100]; FILE *handle = NULL; *argc = 0; handle = fopen(filename, "r"); if(!handle) return (0); fscanf(handle, "%s", &token[0]); while(!(feof(handle))) { int size = strlen(token) + 1; argv[*argc] = malloc(size); if(!argv[*argc]) return (0); strcpy(argv[*argc], token); *argc += 1; fscanf(handle, "%s", &token[0]); } if(handle) fclose(handle); return (1); } int check_bool(char *token) { int result = 1; if(stricmp("off", token) == 0) result = 0; if(stricmp("no", token) == 0) result = 0; return (result); } void set_option_defaults(void) { option.video_driver = GFX_AUTODETECT; option.video_width = 640; option.video_height = 480; option.video_depth = 16; option.remap = 0; option.scanlines = 0; option.scale = 0; option.vsync = 0; option.throttle = 0; option.skip = 1; option.sound = 0; option.sndcard = -1; option.sndrate = 48000; option.swap = 0; option.joy_driver = JOY_TYPE_NONE; } void set_config_defaults(void) { int i; /* sound options */ config.psg_preamp = 150; config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 0; config.filter = 1; config.low_freq = 200; config.high_freq = 8000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; config.lp_range = 50; config.rolloff = 0.999; /* system options */ config.region_detect = 0; config.force_dtack = 0; config.addr_error = 1; config.tmss = 0; config.lock_on = 0; config.romtype = 0; /* display options */ config.overscan = 1; config.render = 0; /* controllers options */ input.system[0] = SYSTEM_MD_GAMEPAD; input.system[1] = SYSTEM_MD_GAMEPAD; config.gun_cursor[0] = 1; config.gun_cursor[1] = 1; config.invert_mouse = 0; for (i=0;i<MAX_INPUTS;i++) config.input[i].padtype = DEVICE_PAD3B; } void print_options(void) { printf(" -vdriver <s> \t Select video driver (auto)\n"); printf(" -res <w> <h> \t Specify display resolution (320x240)\n"); printf(" -depth <n> \t Specify display depth (8)\n"); printf(" -remap <on|off> \t Enable raster-based palette effects (8-bit color only)\n"); printf(" -scanlines <on|off> \t Enable scanlines effect\n"); printf(" -scale <on|off> \t Scale display to width of screen\n"); printf(" -vsync <on|off> \t Enable vsync polling\n"); printf(" -throttle <on|off> \t Enable speed throttling\n"); printf(" -skip <n> \t Specify frame skip level (1=no frames skipped)\n"); printf(" -sound <on|off> \t Enable sound output\n"); printf(" -sndcard <n> \t Select sound card\n"); printf(" -sndrate <n> \t Specify sound sample rate (8000-44100)\n"); printf(" -swap <on|off> \t Swap left and right channels\n"); printf(" -joy <s> \t Select joystick driver (auto)\n"); } void parse_args(int argc, char **argv) { int i, j; for(i = 0; i < argc; i += 1) { if(stricmp("-vdriver", argv[i]) == 0) { for(j = 0; video_driver_table[j].token != NULL; j += 1) { if(stricmp(argv[i+1], video_driver_table[j].token) == 0) { option.video_driver = video_driver_table[j].value; } } } if(stricmp("-res", argv[i]) == 0) { option.video_width = atoi(argv[i+1]); option.video_height = atoi(argv[i+2]); } if(stricmp("-depth", argv[i]) == 0) { option.video_depth = atoi(argv[i+1]); } if(stricmp("-remap", argv[i]) == 0) { option.remap = check_bool(argv[i+1]); } if(stricmp("-scanlines", argv[i]) == 0) { option.scanlines = check_bool(argv[i+1]); } if(stricmp("-scale", argv[i]) == 0) { option.scale = check_bool(argv[i+1]); } if(stricmp("-vsync", argv[i]) == 0) { option.vsync = check_bool(argv[i+1]); } if(stricmp("-throttle", argv[i]) == 0) { option.throttle = check_bool(argv[i+1]); } if(stricmp("-skip", argv[i]) == 0) { option.skip = atoi(argv[i+1]); if(!option.skip) option.skip = 1; } if(stricmp("-sound", argv[i]) == 0) { option.sound = check_bool(argv[i+1]); } if(stricmp("-sndcard", argv[i]) == 0) { option.sndcard = atoi(argv[i+1]); } if(stricmp("-sndrate", argv[i]) == 0) { option.sndrate = atoi(argv[i+1]); } if(stricmp("-swap", argv[i]) == 0) { option.swap = check_bool(argv[i+1]); } if(stricmp("-joy", argv[i]) == 0) { for(j = 0; joy_driver_table[j].token != NULL; j += 1) { if(stricmp(argv[i+1], joy_driver_table[j].token) == 0) { option.joy_driver = joy_driver_table[j].value; } } } } if(option.remap) option.video_depth = 8; } t_strint video_driver_table[] = { { "auto", GFX_AUTODETECT }, { "safe", GFX_SAFE }, { "vga", GFX_VGA }, { "modex", GFX_MODEX }, { "vesa2l", GFX_VESA2L }, { "vesa3", GFX_VESA3 }, { "vbeaf", GFX_VBEAF }, { NULL, 0 } }; t_strint joy_driver_table[] = { { "auto", JOY_TYPE_AUTODETECT }, { "none", JOY_TYPE_NONE }, { "standard", JOY_TYPE_STANDARD }, { "2pads", JOY_TYPE_2PADS }, { "4button", JOY_TYPE_4BUTTON }, { "6button", JOY_TYPE_6BUTTON }, { "8button", JOY_TYPE_8BUTTON }, { "fspro", JOY_TYPE_FSPRO }, { "wingex", JOY_TYPE_WINGEX }, { "sidewinder", JOY_TYPE_SIDEWINDER }, { "gamepadpro", JOY_TYPE_GAMEPAD_PRO }, { "grip", JOY_TYPE_GRIP }, { "grip4", JOY_TYPE_GRIP4 }, { "sneslpt1", JOY_TYPE_SNESPAD_LPT1 }, { "sneslpt2", JOY_TYPE_SNESPAD_LPT2 }, { "sneslpt3", JOY_TYPE_SNESPAD_LPT3 }, { "psxlpt1", JOY_TYPE_PSXPAD_LPT1 }, { "psxlpt2", JOY_TYPE_PSXPAD_LPT2 }, { "psxlpt3", JOY_TYPE_PSXPAD_LPT3 }, { "n64lpt1", JOY_TYPE_N64PAD_LPT1 }, { "n64lpt2", JOY_TYPE_N64PAD_LPT2 }, { "n64lpt3", JOY_TYPE_N64PAD_LPT3 }, { "db9lpt1", JOY_TYPE_DB9_LPT1 }, { "db9lpt2", JOY_TYPE_DB9_LPT2 }, { "db9lpt3", JOY_TYPE_DB9_LPT3 }, { "tglpt1", JOY_TYPE_TURBOGRAFX_LPT1 }, { "tglpt2", JOY_TYPE_TURBOGRAFX_LPT2 }, { "tglpt3", JOY_TYPE_TURBOGRAFX_LPT3 }, { "wingwar", JOY_TYPE_WINGWARRIOR }, { "segaisa", JOY_TYPE_IFSEGA_ISA}, { "segapci", JOY_TYPE_IFSEGA_PCI}, { "segapci2", JOY_TYPE_IFSEGA_PCI_FAST}, { NULL, 0 } };
zyking1987-genplus-droid
genplusgx/unused/dos/config.c
C
gpl2
8,417
#ifndef _CONFIG_H_ #define _CONFIG_H_ #define PATH_SIZE (0x100) #define TOKEN_LIST_SIZE (0x20) typedef struct { char *token; int value; }t_strint; typedef struct { int video_width; int video_height; int video_depth; int video_driver; int autores; int autores_w; int autores_h; int remap; int blur; int scanlines; int scale; int vsync; int throttle; int fps; int skip; int sound; int sndcard; int sndrate; int swap; int wave; char wavpath[PATH_SIZE]; int joy_driver; int split; /* 1= Split image at 2 megabit boundary */ int flip; /* 1= Bit-flip image */ int usa; /* 1= Set D6 of $1000 to indicate US machine */ int softres; /* 1= Allow RUN+SELECT */ } t_option; /**************************************************************************** * Config Option * ****************************************************************************/ typedef struct { uint8 padtype; } t_input_c; typedef struct { uint8 hq_fm; uint8 psgBoostNoise; int32 psg_preamp; int32 fm_preamp; uint8 filter; uint16 low_freq; uint16 high_freq; uint8 lp_range; float lg; float mg; float hg; float rolloff; uint8 region_detect; uint8 force_dtack; uint8 addr_error; uint8 tmss; uint8 lock_on; uint8 romtype; uint8 overscan; uint8 render; uint8 ntsc; t_input_c input[MAX_INPUTS]; uint8 gun_cursor[2]; uint8 invert_mouse; } t_config; /* Global variables */ extern t_option option; extern t_config config; extern t_strint video_driver_table[]; extern t_strint joy_driver_table[]; /* Function prototypes */ void do_config(char *file); int parse_file(char *filename, int *argc, char **argv); void parse_args(int argc, char **argv); void print_options(void); int check_bool(char *token); void set_option_defaults(void); void set_config_defaults(void); #endif /* _CONFIG_H_ */
zyking1987-genplus-droid
genplusgx/unused/dos/config.h
C
gpl2
2,087
/**************************************************************************** * gx_video.c * * Genesis Plus GX video & rendering support * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #include "font.h" #include "aram.h" #include "md_ntsc.h" #include "sms_ntsc.h" #include <png.h> #define TEX_WIDTH 720 #define TEX_HEIGHT 576 #define TEX_SIZE (TEX_WIDTH * TEX_HEIGHT * 2) #define DEFAULT_FIFO_SIZE 256 * 1024 #define HASPECT 320 #define VASPECT 240 /* libpng wrapper */ typedef struct { u8 *buffer; u32 offset; } png_image; extern const u8 Crosshair_p1_png[]; extern const u8 Crosshair_p2_png[]; /*** VI ***/ u32 *xfb[2]; /* External Framebuffers */ u32 whichfb = 0; /* Current Framebuffer */ GXRModeObj *vmode; /* Default Video Mode */ u8 *texturemem; /* Texture Data */ u8 *screenshot; /* Texture Data */ /*** 50/60hz flag ***/ u32 gc_pal = 0; /*** NTSC Filters ***/ sms_ntsc_t sms_ntsc; md_ntsc_t md_ntsc; static sms_ntsc_setup_t sms_setup; static md_ntsc_setup_t md_setup; /*** GX FIFO ***/ static u8 gp_fifo[DEFAULT_FIFO_SIZE] ATTRIBUTE_ALIGN (32); /*** GX Textures ***/ static u32 vwidth,vheight; static gx_texture *crosshair[2]; /***************************************************************************************/ /* Emulation video modes */ /***************************************************************************************/ static GXRModeObj *rmode; /* 288 lines progressive (PAL 50Hz) */ static GXRModeObj TV50hz_288p = { VI_TVMODE_PAL_DS, // viDisplayMode 640, // fbWidth 286, // efbHeight 286, // xfbHeight 0, // viXOrigin (VI_MAX_HEIGHT_PAL - 572)/2, // viYOrigin VI_MAX_WIDTH_PAL, // viWidth 572, // viHeight VI_XFBMODE_SF, // xFBmode GX_FALSE, // field_rendering GX_FALSE, // aa // sample points arranged in increasing Y order { {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each {6,6},{6,6},{6,6}, // pix 1 {6,6},{6,6},{6,6}, // pix 2 {6,6},{6,6},{6,6} // pix 3 }, // vertical filter[7], 1/64 units, 6 bits each { 0, // line n-1 0, // line n-1 21, // line n 22, // line n 21, // line n 0, // line n+1 0 // line n+1 } }; /* 288 lines interlaced (PAL 50Hz) */ static GXRModeObj TV50hz_288i = { VI_TVMODE_PAL_INT, // viDisplayMode 640, // fbWidth 286, // efbHeight 286, // xfbHeight 0, // viXOrigin (VI_MAX_HEIGHT_PAL - 572)/2, // viYOrigin VI_MAX_WIDTH_PAL, // viWidth 572, // viHeight VI_XFBMODE_SF, // xFBmode GX_TRUE, // field_rendering GX_FALSE, // aa // sample points arranged in increasing Y order { {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each {6,6},{6,6},{6,6}, // pix 1 {6,6},{6,6},{6,6}, // pix 2 {6,6},{6,6},{6,6} // pix 3 }, // vertical filter[7], 1/64 units, 6 bits each { 0, // line n-1 0, // line n-1 21, // line n 22, // line n 21, // line n 0, // line n+1 0 // line n+1 } }; /* 576 lines interlaced (PAL 50Hz, scaled) */ static GXRModeObj TV50hz_576i = { VI_TVMODE_PAL_INT, // viDisplayMode 640, // fbWidth 480, // efbHeight VI_MAX_HEIGHT_PAL, // xfbHeight 0, // viXOrigin 0, // viYOrigin VI_MAX_WIDTH_PAL, // viWidth VI_MAX_HEIGHT_PAL, // viHeight VI_XFBMODE_DF, // xFBmode GX_FALSE, // field_rendering GX_FALSE, // aa // sample points arranged in increasing Y order { {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each {6,6},{6,6},{6,6}, // pix 1 {6,6},{6,6},{6,6}, // pix 2 {6,6},{6,6},{6,6} // pix 3 }, // vertical filter[7], 1/64 units, 6 bits each { 8, // line n-1 8, // line n-1 10, // line n 12, // line n 10, // line n 8, // line n+1 8 // line n+1 } }; /* 240 lines progressive (NTSC or PAL 60Hz) */ static GXRModeObj TV60hz_240p = { VI_TVMODE_EURGB60_DS, // viDisplayMode 640, // fbWidth VI_MAX_HEIGHT_NTSC/2, // efbHeight VI_MAX_HEIGHT_NTSC/2, // xfbHeight 0, // viXOrigin 0, // viYOrigin VI_MAX_WIDTH_NTSC, // viWidth VI_MAX_HEIGHT_NTSC, // viHeight VI_XFBMODE_SF, // xFBmode GX_FALSE, // field_rendering GX_FALSE, // aa // sample points arranged in increasing Y order { {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each {6,6},{6,6},{6,6}, // pix 1 {6,6},{6,6},{6,6}, // pix 2 {6,6},{6,6},{6,6} // pix 3 }, // vertical filter[7], 1/64 units, 6 bits each { 0, // line n-1 0, // line n-1 21, // line n 22, // line n 21, // line n 0, // line n+1 0 // line n+1 } }; /* 240 lines interlaced (NTSC or PAL 60Hz) */ static GXRModeObj TV60hz_240i = { VI_TVMODE_EURGB60_INT, // viDisplayMode 640, // fbWidth VI_MAX_HEIGHT_NTSC/2, // efbHeight VI_MAX_HEIGHT_NTSC/2, // xfbHeight 0, // viXOrigin 0, // viYOrigin VI_MAX_WIDTH_NTSC, // viWidth VI_MAX_HEIGHT_NTSC, // viHeight VI_XFBMODE_SF, // xFBmode GX_TRUE, // field_rendering GX_FALSE, // aa // sample points arranged in increasing Y order { {3,2},{9,6},{3,10}, // pix 0, 3 sample points, 1/12 units, 4 bits each {3,2},{9,6},{3,10}, // pix 1 {9,2},{3,6},{9,10}, // pix 2 {9,2},{3,6},{9,10} // pix 3 }, // vertical filter[7], 1/64 units, 6 bits each { 0, // line n-1 0, // line n-1 21, // line n 22, // line n 21, // line n 0, // line n+1 0 // line n+1 } }; /* 480 lines interlaced (NTSC or PAL 60Hz) */ static GXRModeObj TV60hz_480i = { VI_TVMODE_EURGB60_INT,// viDisplayMode 640, // fbWidth VI_MAX_HEIGHT_NTSC, // efbHeight VI_MAX_HEIGHT_NTSC, // xfbHeight 0, // viXOrigin 0, // viYOrigin VI_MAX_WIDTH_NTSC, // viWidth VI_MAX_HEIGHT_NTSC, // viHeight VI_XFBMODE_DF, // xFBmode GX_FALSE, // field_rendering GX_FALSE, // aa // sample points arranged in increasing Y order { {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each {6,6},{6,6},{6,6}, // pix 1 {6,6},{6,6},{6,6}, // pix 2 {6,6},{6,6},{6,6} // pix 3 }, // vertical filter[7], 1/64 units, 6 bits each { 8, // line n-1 8, // line n-1 10, // line n 12, // line n 10, // line n 8, // line n+1 8 // line n+1 } }; /* TV modes pointer table */ static GXRModeObj *tvmodes[6] = { /* 60hz modes */ &TV60hz_240p, &TV60hz_240i, &TV60hz_480i, /* 50Hz modes */ &TV50hz_288p, &TV50hz_288i, &TV50hz_576i }; /***************************************************************************************/ /* GX rendering engine */ /***************************************************************************************/ typedef struct tagcamera { guVector pos; guVector up; guVector view; } camera; /*** Square Matrix This structure controls the size of the image on the screen. Think of the output as a -80 x 80 by -60 x 60 graph. ***/ static s16 square[] ATTRIBUTE_ALIGN (32) = { /* * X, Y, Z * Values set are for roughly 4:3 aspect */ -HASPECT, VASPECT, 0, // 0 HASPECT, VASPECT, 0, // 1 HASPECT, -VASPECT, 0, // 2 -HASPECT, -VASPECT, 0, // 3 }; static camera cam = { {0.0F, 0.0F, -100.0F}, {0.0F, -1.0F, 0.0F}, {0.0F, 0.0F, 0.0F} }; /* VSYNC callback */ static void vi_callback(u32 cnt) { frameticker++; } /* Vertex Rendering */ static inline void draw_vert(u8 pos, f32 s, f32 t) { GX_Position1x8(pos); GX_TexCoord2f32(s, t); } /* textured quad rendering */ static inline void draw_square(void) { GX_Begin(GX_QUADS, GX_VTXFMT0, 4); draw_vert(3, 0.0, 0.0); draw_vert(2, 1.0, 0.0); draw_vert(1, 1.0, 1.0); draw_vert(0, 0.0, 1.0); GX_End (); } /* Initialize GX */ static void gxStart(void) { /*** Clear out FIFO area ***/ memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE); /*** GX default ***/ GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE); GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_SetCullMode(GX_CULL_NONE); GX_SetClipMode(GX_CLIP_DISABLE); GX_SetDispCopyGamma(GX_GM_1_0); GX_SetZMode(GX_FALSE, GX_ALWAYS, GX_FALSE); GX_SetColorUpdate(GX_TRUE); GX_SetAlphaUpdate(GX_FALSE); /* Modelview */ Mtx view; memset (&view, 0, sizeof (Mtx)); guLookAt(view, &cam.pos, &cam.up, &cam.view); GX_LoadPosMtxImm(view, GX_PNMTX0); GX_Flush(); } /* Reset GX rendering */ static void gxResetRendering(u8 type) { GX_ClearVtxDesc(); if (type) { /* uses direct positionning, alpha blending & color channel (menu rendering) */ GX_SetBlendMode(GX_BM_BLEND,GX_BL_SRCALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxDesc (GX_VA_CLR0, GX_DIRECT); /* Color.out = Color.rasterized*Color.texture Alpha.out = Alpha.rasterized*Alpha.texture */ GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_SetNumTexGens(1); GX_SetNumChans(1); } else { /* uses array positionning, no alpha blending, no color channel (video emulation) */ GX_SetBlendMode(GX_BM_NONE,GX_BL_SRCALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); GX_SetVtxDesc(GX_VA_POS, GX_INDEX8); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetArray(GX_VA_POS, square, 3 * sizeof (s16)); /* Color.out = Color.texture Alpha.out = Alpha.texture */ GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL); GX_SetNumTexGens(1); GX_SetNumChans(0); } GX_Flush(); } /* Reset GX rendering mode */ static void gxResetMode(GXRModeObj *tvmode) { Mtx44 p; f32 yScale = GX_GetYScaleFactor(tvmode->efbHeight, tvmode->xfbHeight); u16 xfbHeight = GX_SetDispCopyYScale(yScale); u16 xfbWidth = tvmode->fbWidth; if (xfbWidth & 15) // xfb width is 16 pixels aligned xfbWidth = (xfbWidth & ~15) + 16; GX_SetCopyClear((GXColor)BLACK,0x00ffffff); GX_SetViewport(0.0F, 0.0F, tvmode->fbWidth, tvmode->efbHeight, 0.0F, 1.0F); GX_SetScissor(0, 0, tvmode->fbWidth, tvmode->efbHeight); GX_SetDispCopySrc(0, 0, tvmode->fbWidth, tvmode->efbHeight); GX_SetDispCopyDst(xfbWidth, xfbHeight); GX_SetCopyFilter(tvmode->aa, tvmode->sample_pattern, (tvmode->xfbMode == VI_XFBMODE_SF) ? GX_FALSE : GX_TRUE, tvmode->vfilter); GX_SetFieldMode(tvmode->field_rendering, ((tvmode->viHeight == 2 * tvmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); guOrtho(p, tvmode->efbHeight/2, -(tvmode->efbHeight/2), -(tvmode->fbWidth/2), tvmode->fbWidth/2, 100, 1000); GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC); GX_Flush(); } /* Manage Aspect Ratio */ static void gxSetAspectRatio(int *xscale, int *yscale) { /* original aspect ratio */ /* the following values have been deducted from comparison with a real 50/60hz Mega Drive */ if (config.aspect) { if (config.overscan) { /* borders are emulated */ *xscale = 358 + ((reg[12] & 1)*2) - gc_pal; *yscale = vdp_pal + ((gc_pal && !config.render) ? 143 : 120); } else { /* borders are simulated (black) */ *xscale = 325 + ((reg[12] & 1)*2) - gc_pal; *yscale = bitmap.viewport.h / 2; if (vdp_pal && (!gc_pal || config.render)) *yscale = *yscale * 240 / 288; else if (!vdp_pal && gc_pal && !config.render) *yscale = *yscale * 288 / 240; } /* 16/9 correction */ if (config.aspect & 2) *xscale = (*xscale * 3) / 4; } /* manual aspect ratio (default is fullscreen) */ else { if (config.overscan) { /* borders are emulated */ *xscale = 352; *yscale = (gc_pal && !config.render) ? (vdp_pal ? (268*144 / bitmap.viewport.h):143) : (vdp_pal ? (224*144 / bitmap.viewport.h):120); } else { /* borders are simulated (black) */ *xscale = 320; *yscale = (gc_pal && !config.render) ? 134 : 112; } /* add user scaling */ *xscale += config.xscale; *yscale += config.yscale; } } /* Reset GX/VI hardware scaler */ static void gxResetScaler(u32 width, u32 height) { int xscale = 0; int yscale = 0; int offset = 0; /* retrieve screen aspect ratio */ gxSetAspectRatio(&xscale, &yscale); /* default EFB width */ rmode->fbWidth = 640; /* no filtering, disable GX horizontal scaling */ if (!config.bilinear && !config.ntsc) { if ((width * 2) <= 640) rmode->fbWidth = width * 2; else if (width <= 640) rmode->fbWidth = width; } /* configure VI width */ if ((xscale * 2) > rmode->fbWidth) { /* max width = 720 pixels */ if (xscale > 360) { /* save offset for later */ offset = ((xscale - 360) * rmode->fbWidth) / rmode->viWidth; /* maximal width */ xscale = 360; } /* enable VI upscaling */ rmode->viWidth = xscale * 2; rmode->viXOrigin = (720 - (xscale * 2)) / 2; /* default GX horizontal scaling */ xscale = (rmode->fbWidth / 2); /* handle additional upscaling */ if (offset) { /* no filtering, reduce EFB width to increase VI upscaling */ if (!config.bilinear && !config.ntsc) rmode->fbWidth -= (offset * 2); /* increase GX horizontal scaling */ else xscale += offset; } } else { /* VI horizontal scaling is disabled */ rmode->viWidth = rmode->fbWidth; rmode->viXOrigin = (720 - rmode->fbWidth) / 2; } /* Adjust screen position */ int xshift = (config.xshift * rmode->fbWidth) / rmode->viWidth; int yshift = (config.yshift * rmode->efbHeight) / rmode->viHeight; /* Configure GX vertical scaling (480i/576i/480p) */ if (config.render) yscale = yscale * 2; /* Set GX scaler (Vertex Position matrix) */ square[6] = square[3] = xshift + xscale; square[0] = square[9] = xshift - xscale; square[4] = square[1] = yshift + yscale; square[7] = square[10] = yshift - yscale; DCFlushRange(square, 32); GX_InvVtxCache(); } static void gxDrawCrosshair(gx_texture *texture, int x, int y) { if (texture->data) { /* load texture object */ GXTexObj texObj; GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_InvalidateTexAll(); /* reset GX rendering */ gxResetRendering(1); /* adjust coordinates */ int w = (texture->width * rmode->fbWidth) / (rmode->viWidth); int h = (texture->height * rmode->efbHeight) / (rmode->viHeight); x = ((x * rmode->fbWidth) / bitmap.viewport.w) - w/2 - (rmode->fbWidth/2); y = ((y * rmode->efbHeight) / bitmap.viewport.h) - h/2 - (rmode->efbHeight/2); /* Draw textured quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(x,y+h); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(0.0, 1.0); GX_Position2s16(x+w,y+h); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(1.0, 1.0); GX_Position2s16(x+w,y); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(1.0, 0.0); GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(0.0, 0.0); GX_End (); /* restore GX rendering */ gxResetRendering(0); /* restore texture object */ GXTexObj texobj; GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); if (!config.bilinear) GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); GX_LoadTexObj(&texobj, GX_TEXMAP0); GX_InvalidateTexAll(); } } void gxDrawRectangle(s32 x, s32 y, s32 w, s32 h, u8 alpha, GXColor color) { /* GX only use Color channel for rendering */ GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); GX_Flush(); /* vertex coordinate */ x -= (vmode->fbWidth/2); y -= (vmode->efbHeight/2); /* draw colored quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(x,y+h); GX_Color4u8(color.r,color.g,color.b,alpha); GX_Position2s16(x+w,y+h); GX_Color4u8(color.r,color.g,color.b,alpha); GX_Position2s16(x+w,y); GX_Color4u8(color.r,color.g,color.b,alpha); GX_Position2s16(x,y); GX_Color4u8(color.r,color.g,color.b,alpha); GX_End (); GX_DrawDone(); /* restore GX rendering */ GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_Flush(); } void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha) { if (!texture) return; if (texture->data) { /* load texture object */ GXTexObj texObj; GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); /* does this really change anything ? */ GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_InvalidateTexAll(); /* vertex coordinate */ x -= (vmode->fbWidth/2); y -= (vmode->efbHeight/2); /* draw textured quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(x,y+h); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 1.0); GX_Position2s16(x+w,y+h); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(1.0, 1.0); GX_Position2s16(x+w,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(1.0, 0.0); GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 0.0); GX_End (); GX_DrawDone(); } } void gxDrawTextureRotate(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, f32 angle, u8 alpha) { if (!texture) return; if (texture->data) { /* load texture object */ GXTexObj texObj; GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_InvalidateTexAll(); /* vertex coordinate */ x -= (vmode->fbWidth/2); y -= (vmode->efbHeight/2); /* Modelview rotation */ Mtx m,mv; guVector axis = (guVector) {0,0,1}; guLookAt(mv, &cam.pos, &cam.up, &cam.view); guMtxRotAxisDeg (m, &axis, angle); guMtxTransApply(m,m, x+w/2,y+h/2,0); guMtxConcat(mv,m,mv); GX_LoadPosMtxImm(mv, GX_PNMTX0); GX_Flush(); /* draw textured quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(-w/2,-h/2); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 0.0); GX_Position2s16(w/2,-h/2); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(1.0, 0.0); GX_Position2s16(w/2,h/2); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(1.0, 1.0); GX_Position2s16(-w/2,h/2); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 1.0); GX_End (); GX_DrawDone(); /* restore default Modelview */ guLookAt(mv, &cam.pos, &cam.up, &cam.view); GX_LoadPosMtxImm(mv, GX_PNMTX0); GX_Flush(); } } void gxDrawTextureRepeat(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha) { if (!texture) return; if (texture->data) { /* load texture object */ GXTexObj texObj; GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_MIRROR, GX_MIRROR, GX_FALSE); GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_InvalidateTexAll(); /* vertex coordinate */ x -= (vmode->fbWidth/2); y -= (vmode->efbHeight/2); /* texture coordinates */ f32 s = (f32)w / (f32)texture->width; f32 t = (f32)h / (f32)texture->height; /* draw textured quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(x,y+h); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, t); GX_Position2s16(x+w,y+h); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(s, t); GX_Position2s16(x+w,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(s, 0.0); GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 0.0); GX_End (); GX_DrawDone(); } } void gxDrawScreenshot(u8 alpha) { if (!rmode) return; /* get current game screen texture */ GXTexObj texobj; GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_LoadTexObj(&texobj, GX_TEXMAP0); GX_InvalidateTexAll(); /* get current aspect ratio */ int xscale,yscale; gxSetAspectRatio(&xscale, &yscale); /* adjust horizontal scaling */ xscale = (xscale * vmode->fbWidth) / vmode->viWidth; /* adjust screen position */ int xshift = (config.xshift * vmode->fbWidth) / vmode->viWidth; int yshift = (config.yshift * vmode->efbHeight) / vmode->viHeight; /* set vertices position & size */ s32 x = xshift - xscale; s32 y = yshift - (yscale * 2); s32 w = xscale * 2; s32 h = yscale * 4; /* draw textured quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(x,y+h); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 1.0); GX_Position2s16(x+w,y+h); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(1.0, 1.0); GX_Position2s16(x+w,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(1.0, 0.0); GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 0.0); GX_End (); GX_DrawDone(); } void gxCopyScreenshot(gx_texture *texture) { /* retrieve gamescreen texture */ gxClearScreen((GXColor)BLACK); GXTexObj texobj; GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_LoadTexObj(&texobj, GX_TEXMAP0); GX_InvalidateTexAll(); /* scale texture to EFB width */ s32 w = bitmap.viewport.x ? 704 : 640; s32 h = (bitmap.viewport.h + 2*bitmap.viewport.y) * 2; s32 x = -w/2; s32 y = -(240+ 2*bitmap.viewport.y); /* draw textured quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(x,y+h); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(0.0, 1.0); GX_Position2s16(x+w,y+h); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(1.0, 1.0); GX_Position2s16(x+w,y); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(1.0, 0.0); GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(0.0, 0.0); GX_End (); /* copy EFB to texture */ texture->format = GX_TF_RGBA8; texture->width = 320; texture->height = bitmap.viewport.h; texture->data = screenshot; GX_SetTexCopySrc(0, 0, texture->width * 2, texture->height * 2); GX_SetTexCopyDst(texture->width, texture->height, texture->format, GX_TRUE); GX_DrawDone(); GX_CopyTex(texture->data, GX_TRUE); GX_Flush(); /* wait for copy operation to finish */ /* GX_PixModeSync is only useful if GX_ command follows */ /* we use dummy GX commands to stall CPU execution */ GX_PixModeSync(); GX_LoadTexObj(&texobj, GX_TEXMAP0); GX_InvalidateTexAll(); GX_Flush(); DCFlushRange(texture->data, texture->width * texture->height * 4); } /* Take Screenshot */ void gxSaveScreenshot(char *filename) { /* capture screenshot into a texture */ gx_texture texture; gxCopyScreenshot(&texture); /* open PNG file */ FILE *f = fopen(filename,"wb"); if (f) { /* encode screenshot into PNG file */ gxTextureWritePNG(&texture,f); fclose(f); } } void gxSetScreen(void) { GX_DrawDone(); GX_CopyDisp(xfb[whichfb], GX_FALSE); GX_Flush(); VIDEO_SetNextFramebuffer (xfb[whichfb]); VIDEO_Flush (); VIDEO_WaitVSync (); } void gxClearScreen(GXColor color) { whichfb ^= 1; GX_SetCopyClear(color,0x00ffffff); GX_CopyDisp(xfb[whichfb], GX_TRUE); GX_Flush(); } /***************************************************************************************/ /* GX Texture <-> LibPNG routines */ /***************************************************************************************/ /* libpng read callback function */ static void png_read_from_mem (png_structp png_ptr, png_bytep data, png_size_t length) { png_image *image = (png_image *)png_get_io_ptr(png_ptr); /* copy data from image buffer */ memcpy (data, image->buffer + image->offset, length); /* advance in the file */ image->offset += length; } /* convert PNG image (from file or data buffer) into RGBA8 texture */ gx_texture *gxTextureOpenPNG(const u8 *png_data, FILE *png_file) { int i; /* create a png read struct */ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL); if (!png_ptr) return NULL; /* create a png info struct */ png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { png_destroy_read_struct(&png_ptr,NULL,NULL); return NULL; } if (png_data) { /* init PNG image structure */ png_image image; image.buffer = (u8 *) png_data; image.offset = 0; /* set callback for the read function */ png_set_read_fn(png_ptr,(png_voidp *)(&image),png_read_from_mem); } else if (png_file) { /* check for valid magic number */ png_byte magic[8]; if (fread (magic, 1, 8, png_file) != 8) { png_destroy_read_struct(&png_ptr,&info_ptr,NULL); return NULL; } if (!png_check_sig (magic, 8)) if (fread (magic, 1, 8, png_file) != 8) { png_destroy_read_struct(&png_ptr,&info_ptr,NULL); return NULL; } /* set IO callback for read function */ png_init_io (png_ptr, png_file); png_set_sig_bytes (png_ptr, 8); } else { png_destroy_read_struct(&png_ptr,&info_ptr,NULL); return NULL; } /* read png info */ png_read_info(png_ptr,info_ptr); /* retrieve image information */ u32 width = png_get_image_width(png_ptr,info_ptr); u32 height = png_get_image_height(png_ptr,info_ptr); u32 bit_depth = png_get_bit_depth(png_ptr,info_ptr); u32 color_type = png_get_color_type(png_ptr,info_ptr); /* ensure PNG file is in the supported format */ if (png_file) { /* support for RGBA8 textures ONLY !*/ if ((color_type != PNG_COLOR_TYPE_RGB_ALPHA) || (bit_depth != 8)) { png_destroy_read_struct(&png_ptr, &info_ptr,NULL); return NULL; } /* 4x4 tiles are required */ if ((width%4) || (height%4)) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); return NULL; } } /* allocate memory to store raw image data */ u32 stride = width << 2; u8 *img_data = memalign (32, stride * height); if (!img_data) { png_destroy_read_struct(&png_ptr,&info_ptr,NULL); return NULL; } /* allocate row pointer data */ png_bytep *row_pointers = (png_bytep *)memalign (32, sizeof (png_bytep) * height); if (!row_pointers) { free (img_data); png_destroy_read_struct(&png_ptr,&info_ptr,NULL); return NULL; } /* store raw image data */ for (i = 0; i < height; i++) { row_pointers[i] = img_data + (i * stride); } /* decode image */ png_read_image(png_ptr, row_pointers); /* finish decompression and release memory */ png_read_end(png_ptr, NULL); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); free(row_pointers); /* initialize texture */ gx_texture *texture = (gx_texture *)memalign(32, sizeof(gx_texture)); if (!texture) { free (img_data); return NULL; } /* initialize texture data */ texture->data = memalign(32, stride * height); if (!texture->data) { free (img_data); free(texture); return NULL; } memset(texture->data, 0, stride * height); texture->width = width; texture->height = height; texture->format = GX_TF_RGBA8; /* encode to GX_TF_RGBA8 format (4x4 pixels paired titles) */ u16 *dst_ar = (u16 *)(texture->data); u16 *dst_gb = (u16 *)(texture->data + 32); u32 *src1 = (u32 *)(img_data); u32 *src2 = (u32 *)(img_data + stride); u32 *src3 = (u32 *)(img_data + 2*stride); u32 *src4 = (u32 *)(img_data + 3*stride); u32 pixel,h,w; for (h=0; h<height; h+=4) { for (w=0; w<width; w+=4) { /* line N (4 pixels) */ for (i=0; i<4; i++) { pixel = *src1++; *dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff); *dst_gb++= (pixel >> 8) & 0xffff; } /* line N + 1 (4 pixels) */ for (i=0; i<4; i++) { pixel = *src2++; *dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff); *dst_gb++= (pixel >> 8) & 0xffff; } /* line N + 2 (4 pixels) */ for (i=0; i<4; i++) { pixel = *src3++; *dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff); *dst_gb++= (pixel >> 8) & 0xffff; } /* line N + 3 (4 pixels) */ for (i=0; i<4; i++) { pixel = *src4++; *dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff); *dst_gb++= (pixel >> 8) & 0xffff; } /* next paired tiles */ dst_ar += 16; dst_gb += 16; } /* next 4 lines */ src1 = src4; src2 = src1 + width; src3 = src2 + width; src4 = src3 + width; } /* release memory */ free(img_data); /* flush texture data from cache */ DCFlushRange(texture->data, height * stride); return texture; } /* Write RGBA8 Texture to PNG file */ void gxTextureWritePNG(gx_texture *texture, FILE *png_file) { /* allocate PNG data buffer */ u8 *img_data = (u8 *)memalign(32, texture->width * texture->height * 4); if(!img_data) return; /* decode GX_TF_RGBA8 format (4x4 pixels paired titles) */ u16 *ar = (u16 *)(texture->data); u16 *gb = (u16 *)(texture->data + 32); u32 *dst1 = (u32 *)(img_data); u32 *dst2 = dst1 + texture->width; u32 *dst3 = dst2 + texture->width; u32 *dst4 = dst3 + texture->width; u32 i,h,w,pixel; for (h=0; h<texture->height; h+=4) { for (w=0; w<texture->width; w+=4) { /* line N (4 pixels) */ for (i=0; i<4; i++) { pixel = ((*ar & 0xff) << 24) | (*gb << 8) | ((*ar & 0xff00) >> 8); *dst1++ = pixel; ar++; gb++; } /* line N + 1 (4 pixels) */ for (i=0; i<4; i++) { pixel = ((*ar & 0xff) << 24) | (*gb << 8) | ((*ar & 0xff00) >> 8); *dst2++ = pixel; ar++; gb++; } /* line N + 2 (4 pixels) */ for (i=0; i<4; i++) { pixel = ((*ar & 0xff) << 24) | (*gb << 8) | ((*ar & 0xff00) >> 8); *dst3++ = pixel; ar++; gb++; } /* line N + 3 (4 pixels) */ for (i=0; i<4; i++) { pixel = ((*ar & 0xff) << 24) | (*gb << 8) | ((*ar & 0xff00) >> 8); *dst4++ = pixel; ar++; gb++; } /* next paired tiles */ ar += 16; gb += 16; } /* next 4 lines */ dst1 = dst4; dst2 = dst1 + texture->width; dst3 = dst2 + texture->width; dst4 = dst3 + texture->width; } /* create a png write struct */ png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if(!png_ptr) { free(img_data); return; } /* create a png info struct */ png_infop info_ptr = png_create_info_struct (png_ptr); if (!info_ptr) { free(img_data); png_destroy_write_struct(&png_ptr, NULL); return; } /* set IO callback for the write function */ png_init_io(png_ptr, png_file); /* set PNG file properties */ png_set_IHDR(png_ptr, info_ptr, texture->width, texture->height, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); /* allocate row pointer data */ png_bytep *row_pointers = (png_bytep *)memalign (32, sizeof (png_bytep) * texture->height); if (!row_pointers) { free (img_data); png_destroy_write_struct(&png_ptr, &info_ptr); return; } /* store raw image data */ for (i = 0; i < texture->height; i++) { row_pointers[i] = img_data + (i * texture->width * 4); } /* configure libpng for image data */ png_set_rows(png_ptr,info_ptr,row_pointers); /* write data to PNG file */ png_write_png(png_ptr,info_ptr,PNG_TRANSFORM_IDENTITY,NULL); /* finish compression and release memory */ png_write_end(png_ptr, NULL); free(row_pointers); free(img_data); png_destroy_write_struct(&png_ptr, &info_ptr); } void gxTextureClose(gx_texture **p_texture) { gx_texture *texture = *p_texture; if (texture) { if (texture->data) free(texture->data); free(texture); *p_texture = NULL; } } /***************************************************************************************/ /* VIDEO engine */ /***************************************************************************************/ /* Emulation mode -> Menu mode */ void gx_video_Stop(void) { /* lightgun textures */ gxTextureClose(&crosshair[0]); gxTextureClose(&crosshair[1]); /* GX menu rendering */ gxResetRendering(1); gxResetMode(vmode); /* default VI settings */ VIDEO_SetPreRetraceCallback(NULL); VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); #ifdef HW_RVL VIDEO_SetTrapFilter(1); VIDEO_SetGamma(VI_GM_1_0); #endif /* default TV mode */ vmode->viWidth = config.screen_w; vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - vmode->viWidth)/2; VIDEO_Configure(vmode); /* starts menu rendering */ gxDrawScreenshot(0xff); gxSetScreen(); } /* Menu mode -> Emulation mode */ void gx_video_Start(void) { /* 50Hz/60Hz mode */ if ((config.tv_mode == 1) || ((config.tv_mode == 2) && vdp_pal)) gc_pal = 1; else gc_pal = 0; #ifdef HW_RVL VIDEO_SetTrapFilter(config.trap); VIDEO_SetGamma((int)(config.gamma * 10.0)); #endif /* VSYNC callbacks */ /* in 60hz mode, frame emulation is synchronized with Video Interrupt */ if (!gc_pal && !vdp_pal) VIDEO_SetPreRetraceCallback(vi_callback); VIDEO_SetPostRetraceCallback(NULL); VIDEO_Flush(); /* set interlaced or progressive video mode */ if (config.render == 2) { tvmodes[2]->viTVMode = VI_TVMODE_NTSC_PROG; tvmodes[2]->xfbMode = VI_XFBMODE_SF; } else if (config.render == 1) { tvmodes[2]->viTVMode = tvmodes[0]->viTVMode & ~3; tvmodes[2]->xfbMode = VI_XFBMODE_DF; } /* overscan emulation */ if (config.overscan) { bitmap.viewport.x = (reg[12] & 1) ? 16 : 12; bitmap.viewport.y = (reg[1] & 8) ? 0 : 8; if (vdp_pal) bitmap.viewport.y += 24; } else { bitmap.viewport.x = 0; bitmap.viewport.y = 0; } /* reinitialize video size */ vwidth = bitmap.viewport.w + (2 * bitmap.viewport.x); vheight = bitmap.viewport.h + (2 * bitmap.viewport.y); /* software NTSC filters */ if (config.ntsc == 1) { sms_setup = sms_ntsc_composite; md_setup = md_ntsc_composite; sms_ntsc_init( &sms_ntsc, &sms_setup ); md_ntsc_init( &md_ntsc, &md_setup ); } else if (config.ntsc == 2) { sms_setup = sms_ntsc_svideo; md_setup = md_ntsc_svideo; sms_ntsc_init( &sms_ntsc, &sms_setup ); md_ntsc_init( &md_ntsc, &md_setup ); } else if (config.ntsc == 3) { sms_setup = sms_ntsc_rgb; md_setup = md_ntsc_rgb; sms_ntsc_init( &sms_ntsc, &sms_setup ); md_ntsc_init( &md_ntsc, &md_setup ); } /* lightgun textures */ if (config.gun_cursor[0] && (input.dev[4] == DEVICE_LIGHTGUN)) crosshair[0] = gxTextureOpenPNG(Crosshair_p1_png,0); if (config.gun_cursor[1] && (input.dev[5] == DEVICE_LIGHTGUN)) crosshair[1] = gxTextureOpenPNG(Crosshair_p2_png,0); /* force changes on next video update */ bitmap.viewport.changed = 1; /* GX emulation rendering */ gxResetRendering(0); /* resynchronize emulation with VSYNC*/ VIDEO_WaitVSync(); } /* GX render update */ void gx_video_Update(void) { int update = bitmap.viewport.changed; /* check if display has changed */ if (update) { /* update texture size */ int old_vwidth = vwidth; vwidth = bitmap.viewport.w + (2 * bitmap.viewport.x); vheight = bitmap.viewport.h + (2 * bitmap.viewport.y); /* if width has been changed, do no render this frame */ /* this fixes texture glitches when changing width middle-frame */ if (vwidth != old_vwidth) return; /* interlaced mode */ if (config.render && interlaced) vheight = vheight << 1; /* ntsc filter */ if (config.ntsc) vwidth = (reg[12]&1) ? MD_NTSC_OUT_WIDTH(vwidth) : SMS_NTSC_OUT_WIDTH(vwidth); /* texels size must be multiple of 4 */ vwidth = (vwidth >> 2) << 2; vheight = (vheight >> 2) << 2; /* initialize texture object */ GXTexObj texobj; GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); /* configure texture filtering */ if (!config.bilinear) GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); /* load texture object */ GX_LoadTexObj(&texobj, GX_TEXMAP0); /* update TV mode */ if (config.render) rmode = tvmodes[gc_pal*3 + 2]; else rmode = tvmodes[gc_pal*3 + interlaced]; /* update aspect ratio */ gxResetScaler(vwidth,vheight); /* update GX rendering mode */ gxResetMode(rmode); /* update VI mode */ VIDEO_Configure(rmode); VIDEO_Flush(); } /* texture is now directly mapped by the line renderer */ /* force texture cache update */ DCFlushRange(texturemem, TEX_SIZE); GX_InvalidateTexAll(); /* render textured quad */ draw_square(); /* LightGun marks */ if (crosshair[0]) gxDrawCrosshair(crosshair[0], input.analog[0][0],input.analog[0][1]); if (crosshair[1]) gxDrawCrosshair(crosshair[1], input.analog[1][0],input.analog[1][1]); /* swap XFB */ whichfb ^= 1; /* copy EFB to XFB */ GX_DrawDone(); GX_CopyDisp(xfb[whichfb], GX_TRUE); GX_Flush(); VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_Flush(); if (update) { /* field synchronization */ VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); else while (VIDEO_GetNextField() != odd_frame) VIDEO_WaitVSync(); if (frameticker > 1) frameticker = 1; /* force audio DMA resynchronization */ audioStarted = 0; bitmap.viewport.changed = 0; } } /* Initialize VIDEO subsystem */ void gx_video_Init(void) { /* * Before doing anything else under libogc, * Call VIDEO_Init */ VIDEO_Init(); /* * Before any memory is allocated etc. * Rescue any tagged ROM in data 2 */ int *romptr = (int *)0x80700000; StartARAM(); cart.romsize = 0; if (memcmp((char *)romptr,"GENPLUSR",8) == 0) { cart.romsize = romptr[2]; ARAMPut((char *) 0x80700000 + 0x20, (char *) 0x8000, cart.romsize); } /* Get the current VIDEO mode then : - set menu VIDEO mode (480p, 480i or 576i) - set emulator rendering TV modes (PAL/MPAL/NTSC/EURGB60) */ vmode = VIDEO_GetPreferredMode(NULL); /* Adjust display settings */ switch (vmode->viTVMode >> 2) { case VI_PAL: /* 576 lines (PAL 50Hz) */ TV60hz_240p.viTVMode = VI_TVMODE_EURGB60_DS; TV60hz_240i.viTVMode = VI_TVMODE_EURGB60_INT; TV60hz_480i.viTVMode = VI_TVMODE_EURGB60_INT; config.tv_mode = 1; /* use harwdare vertical scaling to fill screen */ vmode = &TVPal574IntDfScale; break; case VI_NTSC: /* 480 lines (NTSC 60hz) */ TV60hz_240p.viTVMode = VI_TVMODE_NTSC_DS; TV60hz_240i.viTVMode = VI_TVMODE_NTSC_INT; TV60hz_480i.viTVMode = VI_TVMODE_NTSC_INT; config.tv_mode = 0; #ifndef HW_RVL /* force 480p on NTSC GameCube if the Component Cable is present */ if (VIDEO_HaveComponentCable()) vmode = &TVNtsc480Prog; #endif break; default: /* 480 lines (PAL 60Hz) */ TV60hz_240p.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_NON_INTERLACE); TV60hz_240i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE); TV60hz_480i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE); config.tv_mode = 2; break; } /* Configure VI */ VIDEO_Configure (vmode); /* Configure the framebuffers (double-buffering) */ xfb[0] = (u32 *) MEM_K0_TO_K1((u32 *) SYS_AllocateFramebuffer(&TV50hz_576i)); xfb[1] = (u32 *) MEM_K0_TO_K1((u32 *) SYS_AllocateFramebuffer(&TV50hz_576i)); /* Define a console */ console_init(xfb[0], 20, 64, 640, 574, 574 * 2); /* Clear framebuffers to black */ VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK); VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK); /* Set the framebuffer to be displayed at next VBlank */ VIDEO_SetNextFramebuffer(xfb[0]); /* Enable Video Interface */ VIDEO_SetBlack(FALSE); /* Update VIDEO settings for next VBlank */ VIDEO_Flush(); /* Wait for VBlank */ VIDEO_WaitVSync(); VIDEO_WaitVSync(); /* Initialize GX */ gxStart(); gxResetRendering(1); gxResetMode(vmode); /* initialize FONT */ if (!FONT_Init()) { #ifdef HW_RVL DI_Close(); SYS_ResetSystem(SYS_RESTART,0,0); #else SYS_ResetSystem(SYS_HOTRESET,0,0); #endif } /* Initialize textures */ texturemem = memalign(32, TEX_SIZE); screenshot = memalign(32, HASPECT*VASPECT*4); if (!texturemem || !screenshot) { FONT_writeCenter("Failed to allocate textures memory... Rebooting",18,0,640,200,(GXColor)WHITE); gxSetScreen(); sleep(2); gx_video_Shutdown(); #ifdef HW_RVL DI_Close(); SYS_ResetSystem(SYS_RESTART,0,0); #else SYS_ResetSystem(SYS_HOTRESET,0,0); #endif } } void gx_video_Shutdown(void) { if (texturemem) free(texturemem); if (screenshot) free(screenshot); FONT_Shutdown(); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); }
zyking1987-genplus-droid
genplusgx/unused/gx/gx_video.c
C
gpl2
45,779
/**************************************************************************** * gx_video.c * * Genesis Plus GX video support * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #ifndef _GC_VIDEO_H_ #define _GC_VIDEO_H_ /* EFB colors */ #define BLACK {0,0,0,0xff} #define DARK_GREY {0x22,0x22,0x22,0xff} #define WHITE {0xff,0xff,0xff,0xff} /* image texture */ typedef struct { u8 *data; u16 width; u16 height; u8 format; } gx_texture; /* Global variables */ extern u32 *xfb[2]; extern u32 whichfb; extern GXRModeObj *vmode; extern u8 *texturemem; extern u32 gc_pal; /* GX rendering */ extern void gxDrawRectangle(s32 x, s32 y, s32 w, s32 h, u8 alpha, GXColor color); extern void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha); extern void gxDrawTextureRepeat(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha); extern void gxDrawTextureRotate(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, f32 angle, u8 alpha); extern void gxDrawScreenshot(u8 alpha); extern void gxCopyScreenshot(gx_texture *texture); extern void gxSaveScreenshot(char *filename); extern void gxClearScreen(GXColor color); extern void gxSetScreen(void); /* PNG textures */ extern gx_texture *gxTextureOpenPNG(const u8 *png_data, FILE *png_file); extern void gxTextureWritePNG(gx_texture *p_texture, FILE *png_file); extern void gxTextureClose(gx_texture **p_texture); /* GX video engine */ extern void gx_video_Init(void); extern void gx_video_Shutdown(void); extern void gx_video_Start(void); extern void gx_video_Stop(void); extern void gx_video_Update(void); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/gx_video.h
C
gpl2
2,474
/**************************************************************************** * gx_input.c * * Genesis Plus GX input support * * Eke-Eke (2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #include "font.h" #include "gui.h" /* Analog sticks sensitivity */ #define ANALOG_SENSITIVITY 30 /* Delay before held keys triggering */ /* higher is the value, less responsive is the key update */ #define HELD_DELAY 30 /* Direction & selection update speed when a key is being held */ /* lower is the value, faster is the key update */ #define HELD_SPEED 4 /* Menu request flag */ u32 ConfigRequested = 0; /* Configurable Genesis keys */ #define KEY_BUTTONA 0 #define KEY_BUTTONB 1 #define KEY_BUTTONC 2 #define KEY_START 3 #define KEY_BUTTONX 4 /* 6-buttons only */ #define KEY_BUTTONY 5 /* 6-buttons only */ #define KEY_BUTTONZ 6 /* 6-buttons only */ #define KEY_MODE 7 /* 6-buttons only */ static const char *keys_name[MAX_KEYS] = { "Button A", "Button B", "Button C", "START Button", "Button X", "Button Y", "Button Z", "MODE Button" }; static int held_cnt = 0; #ifdef HW_RVL #define PAD_UP 0 #define PAD_DOWN 1 #define PAD_LEFT 2 #define PAD_RIGHT 3 /* default directions mapping */ static u32 wpad_dirmap[3][4] = { {WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, /* WIIMOTE */ {WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT}, /* WIIMOTE + NUNCHUK */ {WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN, WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT} /* CLASSIC */ }; #endif /***************************************************************************************/ /* Gamecube PAD support */ /***************************************************************************************/ static void pad_config(int chan, int max_keys) { int i; u16 p,key; char msg[30]; /* reset VSYNC callback */ VIDEO_SetPostRetraceCallback(NULL); VIDEO_Flush(); /* Check if PAD is connected */ if (!(PAD_ScanPads() & (1<<chan))) { /* restore inputs update callback */ VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); VIDEO_Flush(); sprintf(msg, "PAD #%d is not connected !", chan+1); GUI_WaitPrompt("Error",msg); return; } /* Configure each keys */ for (i=0; i<max_keys; i++) { /* remove any pending keys */ while (PAD_ButtonsHeld(chan)) { VIDEO_WaitVSync(); PAD_ScanPads(); } /* wait for user input */ sprintf(msg,"Press key for %s\n(Z to return)",keys_name[i]); GUI_MsgBoxUpdate(0,msg); key = 0; while (!key) { /* update PAD status */ VIDEO_WaitVSync(); PAD_ScanPads(); p = PAD_ButtonsDown(chan); /* find pressed key */ if (p & PAD_TRIGGER_Z) key = 0xff; else if (p & PAD_BUTTON_A) key = PAD_BUTTON_A; else if (p & PAD_BUTTON_B) key = PAD_BUTTON_B; else if (p & PAD_BUTTON_X) key = PAD_BUTTON_X; else if (p & PAD_BUTTON_Y) key = PAD_BUTTON_Y; else if (p & PAD_TRIGGER_R) key = PAD_TRIGGER_R; else if (p & PAD_TRIGGER_L) key = PAD_TRIGGER_L; else if (p & PAD_BUTTON_START) key = PAD_BUTTON_START; } /* update key mapping */ if (key !=0xff) config.pad_keymap[chan][i] = key; else break; } /* remove any pending keys */ while (PAD_ButtonsHeld(chan)) { VIDEO_WaitVSync(); PAD_ScanPads(); } /* restore inputs update callback */ VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); VIDEO_Flush(); } static void pad_update(s8 chan, u8 i) { /* PAD status */ u16 p = PAD_ButtonsHeld(chan); s8 x = PAD_StickX (chan); s8 y = PAD_StickY (chan); if (p & PAD_TRIGGER_Z) { /* Menu Request */ ConfigRequested = 1; return; } else if ((p & PAD_TRIGGER_L) && (p & PAD_TRIGGER_Z)) { /* Soft RESET */ set_softreset(); } /* Retrieve current key mapping */ u16 pad_keymap[MAX_KEYS]; memcpy(pad_keymap, config.pad_keymap[chan], MAX_KEYS * sizeof(u16)); /* Generic buttons */ if (p & pad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_A; if (p & pad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_B; if (p & pad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_C; if (p & pad_keymap[KEY_BUTTONX]) input.pad[i] |= INPUT_X; if (p & pad_keymap[KEY_BUTTONY]) input.pad[i] |= INPUT_Y; if (p & pad_keymap[KEY_BUTTONZ]) input.pad[i] |= INPUT_Z; if (p & pad_keymap[KEY_START]) input.pad[i] |= INPUT_START; /* Emulated device specific */ switch (input.dev[i]) { case DEVICE_LIGHTGUN: { /* Lightgun cursor position (x,y) */ input.analog[i-4][0] += x / ANALOG_SENSITIVITY; input.analog[i-4][1] -= y / ANALOG_SENSITIVITY; if (input.analog[i-4][0] < 0) input.analog[i-4][0] = 0; else if (input.analog[i-4][0] > bitmap.viewport.w) input.analog[i-4][0] = bitmap.viewport.w; if (input.analog[i-4][1] < 0) input.analog[i-4][1] = 0; else if (input.analog[i-4][1] > bitmap.viewport.h) input.analog[i-4][1] = bitmap.viewport.h; break; } case DEVICE_MOUSE: { /* MOUSE relative movement (-255,255) */ input.analog[2][0] = (x / ANALOG_SENSITIVITY) * 2; input.analog[2][1] = (y / ANALOG_SENSITIVITY) * 2; if (config.invert_mouse) input.analog[2][1] = -input.analog[2][1]; break; } default: { if (system_hw != SYSTEM_PICO) { /* gamepad */ if ((p & PAD_BUTTON_UP) || (y > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_UP; else if ((p & PAD_BUTTON_DOWN) || (y < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_DOWN; if ((p & PAD_BUTTON_LEFT) || (x < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_LEFT; else if ((p & PAD_BUTTON_RIGHT) || (x > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_RIGHT; } else if (!i) { /* PICO PEN tablet position (x,y) */ input.analog[0][0] += x / ANALOG_SENSITIVITY; input.analog[0][1] -= y / ANALOG_SENSITIVITY; if (input.analog[0][0] < 0x17c) input.analog[0][0] = 0x17c; else if (input.analog[0][0] > 0x3c) input.analog[0][0] = 0x3c; if (input.analog[0][1] < 0x1fc) input.analog[0][1] = 0x1fc; else if (input.analog[0][1] > 0x3f3) input.analog[0][1] = 0x3f3; } break; } } } /***************************************************************************************/ /* Wii WPAD support */ /***************************************************************************************/ #ifdef HW_RVL static s8 WPAD_StickX(WPADData *data,u8 right) { float mag = 0.0; float ang = 0.0; switch (data->exp.type) { case WPAD_EXP_NUNCHUK: case WPAD_EXP_GUITARHERO3: if (right == 0) { mag = data->exp.nunchuk.js.mag; ang = data->exp.nunchuk.js.ang; } break; case WPAD_EXP_CLASSIC: if (right == 0) { mag = data->exp.classic.ljs.mag; ang = data->exp.classic.ljs.ang; } else { mag = data->exp.classic.rjs.mag; ang = data->exp.classic.rjs.ang; } break; default: break; } /* calculate X value (angle need to be converted into radian) */ if (mag > 1.0) mag = 1.0; else if (mag < -1.0) mag = -1.0; double val = mag * sin(M_PI * ang/180.0f); return (s8)(val * 128.0f); } static s8 WPAD_StickY(WPADData *data, u8 right) { float mag = 0.0; float ang = 0.0; switch (data->exp.type) { case WPAD_EXP_NUNCHUK: case WPAD_EXP_GUITARHERO3: if (right == 0) { mag = data->exp.nunchuk.js.mag; ang = data->exp.nunchuk.js.ang; } break; case WPAD_EXP_CLASSIC: if (right == 0) { mag = data->exp.classic.ljs.mag; ang = data->exp.classic.ljs.ang; } else { mag = data->exp.classic.rjs.mag; ang = data->exp.classic.rjs.ang; } break; default: break; } /* calculate X value (angle need to be converted into radian) */ if (mag > 1.0) mag = 1.0; else if (mag < -1.0) mag = -1.0; double val = mag * cos(M_PI * ang/180.0f); return (s8)(val * 128.0f); } static void wpad_config(u8 chan, u8 exp, u8 max_keys) { int i; char msg[30]; u32 key,p = 255; /* remove inputs update callback */ VIDEO_SetPostRetraceCallback(NULL); VIDEO_Flush(); /* Check if device is connected */ WPAD_Probe(chan, &p); if (((exp > WPAD_EXP_NONE) && (p != exp)) || (p == 255)) { /* restore inputs update callback */ VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); VIDEO_Flush(); if (exp == WPAD_EXP_NONE) sprintf(msg, "WIIMOTE #%d is not connected !", chan+1); if (exp == WPAD_EXP_NUNCHUK) sprintf(msg, "NUNCHUK #%d is not connected !", chan+1); if (exp == WPAD_EXP_CLASSIC) sprintf(msg, "CLASSIC #%d is not connected !", chan+1); GUI_WaitPrompt("Error",msg); return; } /* loop on each mapped keys */ for (i=0; i<max_keys; i++) { /* remove any pending buttons */ while (WPAD_ButtonsHeld(chan)) { WPAD_ScanPads(); VIDEO_WaitVSync(); } /* wait for user input */ sprintf(msg,"Press key for %s\n(HOME to return)",keys_name[i]); GUI_MsgBoxUpdate(0,msg); /* wait for input */ key = 0; while (!key) { VIDEO_WaitVSync(); WPAD_ScanPads(); p = WPAD_ButtonsDown(chan); switch (exp) { /* Wiimote (TODO: add motion sensing !) */ case WPAD_EXP_NONE: if (p & WPAD_BUTTON_HOME) key = 0xff; else if (p & WPAD_BUTTON_2) key = WPAD_BUTTON_2; else if (p & WPAD_BUTTON_1) key = WPAD_BUTTON_1; else if (p & WPAD_BUTTON_B) key = WPAD_BUTTON_B; else if (p & WPAD_BUTTON_A) key = WPAD_BUTTON_A; else if (p & WPAD_BUTTON_PLUS) key = WPAD_BUTTON_PLUS; else if (p & WPAD_BUTTON_MINUS) key = WPAD_BUTTON_MINUS; break; /* Wiimote + Nunchuk (TODO: add motion sensing !) */ case WPAD_EXP_NUNCHUK: if (p & WPAD_BUTTON_HOME) key = 0xff; else if (p & WPAD_BUTTON_2) key = WPAD_BUTTON_2; else if (p & WPAD_BUTTON_1) key = WPAD_BUTTON_1; else if (p & WPAD_BUTTON_B) key = WPAD_BUTTON_B; else if (p & WPAD_BUTTON_A) key = WPAD_BUTTON_A; else if (p & WPAD_BUTTON_PLUS) key = WPAD_BUTTON_PLUS; else if (p & WPAD_BUTTON_MINUS) key = WPAD_BUTTON_MINUS; else if (p & WPAD_NUNCHUK_BUTTON_Z) key = WPAD_NUNCHUK_BUTTON_Z; else if (p & WPAD_NUNCHUK_BUTTON_C) key = WPAD_NUNCHUK_BUTTON_C; break; /* Classic Controller */ case WPAD_EXP_CLASSIC: if (p & WPAD_CLASSIC_BUTTON_HOME) key = 0xff; else if (p & WPAD_CLASSIC_BUTTON_X) key = WPAD_CLASSIC_BUTTON_X; else if (p & WPAD_CLASSIC_BUTTON_A) key = WPAD_CLASSIC_BUTTON_A; else if (p & WPAD_CLASSIC_BUTTON_Y) key = WPAD_CLASSIC_BUTTON_Y; else if (p & WPAD_CLASSIC_BUTTON_B) key = WPAD_CLASSIC_BUTTON_B; else if (p & WPAD_CLASSIC_BUTTON_ZL) key = WPAD_CLASSIC_BUTTON_ZL; else if (p & WPAD_CLASSIC_BUTTON_ZR) key = WPAD_CLASSIC_BUTTON_ZR; else if (p & WPAD_CLASSIC_BUTTON_PLUS) key = WPAD_CLASSIC_BUTTON_PLUS; else if (p & WPAD_CLASSIC_BUTTON_MINUS) key = WPAD_CLASSIC_BUTTON_MINUS; else if (p & WPAD_CLASSIC_BUTTON_FULL_L) key = WPAD_CLASSIC_BUTTON_FULL_L; else if (p & WPAD_CLASSIC_BUTTON_FULL_R) key = WPAD_CLASSIC_BUTTON_FULL_R; break; default: key = 0xff; break; } } /* update key mapping */ if (key != 0xff) config.wpad_keymap[exp + (chan * 3)][i] = key; else break; } /* remove any pending buttons */ while (WPAD_ButtonsHeld(chan)) { WPAD_ScanPads(); VIDEO_WaitVSync(); } /* restore inputs update callback */ VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); VIDEO_Flush(); } static float old_x = 0.0; static float old_y = 0.0; static void wpad_update(s8 chan, u8 i, u32 exp) { /* WPAD data */ WPADData *data = WPAD_Data(chan); /* WPAD status */ s8 x = 0; s8 y = 0; u32 p = data->btns_h; u32 u = data->btns_u; if ((u & WPAD_BUTTON_HOME) || (u & WPAD_CLASSIC_BUTTON_HOME)) { /* Menu Request */ ConfigRequested = 1; return; } else if (((p & WPAD_BUTTON_PLUS) && (p & WPAD_BUTTON_MINUS)) || ((p & WPAD_CLASSIC_BUTTON_PLUS) && (p & WPAD_CLASSIC_BUTTON_MINUS))) { /* Soft RESET */ set_softreset(); } /* Retrieve current key mapping */ u32 *wpad_keymap = config.wpad_keymap[exp + (3 * chan)]; /* Generic buttons */ if (p & wpad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_A; if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_B; if (p & wpad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_C; if (p & wpad_keymap[KEY_BUTTONX]) input.pad[i] |= INPUT_X; if (p & wpad_keymap[KEY_BUTTONY]) input.pad[i] |= INPUT_Y; if (p & wpad_keymap[KEY_BUTTONZ]) input.pad[i] |= INPUT_Z; if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START; if (p & wpad_keymap[KEY_MODE]) input.pad[i] |= INPUT_MODE; /* Analog sticks */ if (exp != WPAD_EXP_NONE) { x = WPAD_StickX(data,0); y = WPAD_StickY(data,0); } /* Emulated device specific */ switch (input.dev[i]) { case DEVICE_LIGHTGUN: { /* Lightgun cursor position (x,y) */ if (x || y) { /* analog stick absolute positions */ input.analog[i-4][0] += x / ANALOG_SENSITIVITY; input.analog[i-4][1] -= y / ANALOG_SENSITIVITY; if (input.analog[i-4][0] < 0) input.analog[i-4][0] = 0; else if (input.analog[i-4][0] > bitmap.viewport.w) input.analog[i-4][0] = bitmap.viewport.w; if (input.analog[i-4][1] < 0) input.analog[i-4][1] = 0; else if (input.analog[i-4][1] > bitmap.viewport.h) input.analog[i-4][1] = bitmap.viewport.h; } /* Wiimote IR */ if (exp != WPAD_EXP_CLASSIC) { struct ir_t ir; WPAD_IR(chan, &ir); if (ir.valid) { input.analog[i-4][0] = (ir.x * bitmap.viewport.w) / 640; input.analog[i-4][1] = (ir.y * bitmap.viewport.h) / 480; /* use default trigger button */ if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B; } } break; } case DEVICE_MOUSE: { /* Mouse relative movement (-255,255) */ if (x || y) { /* analog stick relative positions */ input.analog[2][0] = (x * 2) / ANALOG_SENSITIVITY; input.analog[2][1] = -(y * 2) / ANALOG_SENSITIVITY; } /* Wiimote IR */ if (exp != WPAD_EXP_CLASSIC) { struct ir_t ir; WPAD_IR(chan, &ir); if (ir.valid) { /* calculate mouse values (FIXME) */ input.analog[2][0] = (ir.x - old_x); input.analog[2][1] = (ir.y - old_y); old_x = ir.x; old_y = ir.y; if (input.analog[2][0] > 255) input.analog[2][0] = 255; else if (input.analog[2][0] < -255) input.analog[2][0] = -255; if (input.analog[2][1] > 255) input.analog[2][1] = 255; else if (input.analog[2][1] < -255) input.analog[2][1] = -255; /* use default trigger button */ if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B; } } #ifdef USB_MOUSE /* USB mouse support (NOT WORKING) */ if (MOUSE_IsConnected()) { mouse_event event; MOUSE_GetEvent(&event); MOUSE_FlushEvents(); /* relative X/Y position: (-128;+127) -> (-255;+255) */ if (event.rx) input.analog[2][0] = (event.rx * 2) + 1; else input.analog[2][0] = 0; if (event.ry) input.analog[2][1] = (event.ry * 2) + 1; else input.analog[2][1] = 0; /* pressed buttons */ if (event.button & 1) input.pad[i] |= INPUT_A; if (event.button & 2) input.pad[i] |= INPUT_B; } #endif /* Invert Y coordinate */ if (!config.invert_mouse) input.analog[2][1] = -input.analog[2][1]; break; } default: { if (system_hw != SYSTEM_PICO) { /* gamepad */ if ((p & wpad_dirmap[exp][PAD_UP]) || (y > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_UP; else if ((p & wpad_dirmap[exp][PAD_DOWN]) || (y < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_DOWN; if ((p & wpad_dirmap[exp][PAD_LEFT]) || (x < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_LEFT; else if ((p & wpad_dirmap[exp][PAD_RIGHT]) || (x > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_RIGHT; } else if (!i) { /* PICO PEN tablet position (x,y) */ if (x || y) { /* analog stick relative positions */ input.analog[0][0] += x / ANALOG_SENSITIVITY; input.analog[0][1] -= y / ANALOG_SENSITIVITY; if (input.analog[0][0] < 0x17c) input.analog[0][0] = 0x17c; else if (input.analog[0][0] > 0x3c) input.analog[0][0] = 0x3c; if (input.analog[0][1] < 0x1fc) input.analog[0][1] = 0x1fc; else if (input.analog[0][1] > 0x3f3) input.analog[0][1] = 0x3f3; } /* Wiimote IR */ if (exp != WPAD_EXP_CLASSIC) { struct ir_t ir; WPAD_IR(chan, &ir); if (ir.valid) { input.analog[0][0] = 0x3c + (ir.x * (0x17c - 0x3c + 1)) / 640; input.analog[0][1] = 0x1fc + (ir.y * (0x3f3 - 0x1fc + 1)) / 480; /* use default trigger button */ if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B; } } } break; } } } #endif /***************************************************************************************/ /* GX Input interface */ /***************************************************************************************/ void gx_input_Init(void) { PAD_Init (); #ifdef HW_RVL WPAD_Init(); WPAD_SetIdleTimeout(60); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL,640,480); #endif VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); VIDEO_Flush(); } void gx_input_SetDefault(void) { int i,j; u32 exp; /* set default key mapping for each type of devices */ for (i=0; i<4; i++) { config.pad_keymap[i][KEY_BUTTONA] = PAD_BUTTON_B; config.pad_keymap[i][KEY_BUTTONB] = PAD_BUTTON_A; config.pad_keymap[i][KEY_BUTTONC] = PAD_BUTTON_X; config.pad_keymap[i][KEY_START] = PAD_BUTTON_START; config.pad_keymap[i][KEY_BUTTONX] = PAD_TRIGGER_L; config.pad_keymap[i][KEY_BUTTONY] = PAD_BUTTON_Y; config.pad_keymap[i][KEY_BUTTONZ] = PAD_TRIGGER_R; config.pad_keymap[i][KEY_MODE] = 0; } #ifdef HW_RVL for (i=0; i<4; i++) { /* Wiimote */ config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONA] = WPAD_BUTTON_A; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONB] = WPAD_BUTTON_2; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONC] = WPAD_BUTTON_1; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_START] = WPAD_BUTTON_PLUS; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONX] = 0; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONY] = 0; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONZ] = 0; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_MODE] = 0; /* Wiimote + Nunchuk */ config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONA] = WPAD_NUNCHUK_BUTTON_Z; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONB] = WPAD_BUTTON_A; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONC] = WPAD_BUTTON_B; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_START] = WPAD_BUTTON_PLUS; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONX] = WPAD_NUNCHUK_BUTTON_C; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONY] = WPAD_BUTTON_1; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONZ] = WPAD_BUTTON_2; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_MODE] = WPAD_BUTTON_MINUS; /* Classic Controller */ config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONA] = WPAD_CLASSIC_BUTTON_Y; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONB] = WPAD_CLASSIC_BUTTON_B; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONC] = WPAD_CLASSIC_BUTTON_A; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_START] = WPAD_CLASSIC_BUTTON_PLUS; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONX] = WPAD_CLASSIC_BUTTON_ZL; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONY] = WPAD_CLASSIC_BUTTON_X; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONZ] = WPAD_CLASSIC_BUTTON_ZR; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_MODE] = WPAD_CLASSIC_BUTTON_MINUS; } #endif /* Default player inputs */ for (i=0; i<MAX_INPUTS; i++) { config.input[i].device = -1; config.input[i].port = i%4; config.input[i].padtype = 0; } #ifdef HW_RVL /* Autodetect Wii Controllers */ VIDEO_WaitVSync(); for (i=0; i<4; i++) { /* try to autodetect connected controller */ exp = 255; WPAD_Probe(i, &exp); if (exp <= WPAD_EXP_CLASSIC) { /* set expansion controller (or wiimote if no expansion) as default */ config.input[i].device = exp + 1; config.input[i].port = i; } else { /* look for unassigned wiimotes */ for (j=0; j<i; j++) { /* classic controller is already assigned, which means wiimote is not used */ if (config.input[j].device == (WPAD_EXP_CLASSIC + 1)) { /* assign wiimote */ config.input[i].device = 1; config.input[i].port = j; } } } } #endif /* Autodetect Gamecube Controllers */ VIDEO_WaitVSync(); exp = PAD_ScanPads(); for (i=0; i<4; i++) { /* check if Gamecube Controller is connected */ if (exp & (1 << i)) { for (j=0; j<MAX_INPUTS; j++) { /* look for the first unassigned player */ if (config.input[j].device == -1) { config.input[j].device = 0; config.input[j].port = i; } } } } /* default emulated inputs */ input.system[0] = SYSTEM_GAMEPAD; input.system[1] = (config.input[1].device != -1) ? SYSTEM_GAMEPAD : NO_SYSTEM; } void gx_input_Config(u8 chan, u8 type, u8 max) { switch (type) { case 0: pad_config(chan, max); break; default: #ifdef HW_RVL wpad_config(chan,type-1, max); #endif break; } } void gx_input_UpdateEmu(void) { int i; int player = 0; /* update controllers */ PAD_ScanPads(); #ifdef HW_RVL WPAD_ScanPads(); #endif #ifdef HW_RVL if (SYS_ResetButtonDown()) { /* Soft RESET */ set_softreset(); } #endif for (i=0; i<MAX_DEVICES; i++) { /* clear key status */ input.pad[i] = 0; /* update inputs */ if (input.dev[i] != NO_DEVICE) { if (config.input[player].device == 0) pad_update(config.input[player].port, i); #ifdef HW_RVL else if (config.input[player].device > 0) wpad_update(config.input[player].port,i, config.input[player].device - 1); #endif player ++; } } } /* Menu inputs update function (done by Video Interrupt callback) */ void gx_input_UpdateMenu(u32 cnt) { /* PAD status update */ PAD_ScanPads(); /* PAD pressed keys */ s16 pp = PAD_ButtonsDown(0); /* PAD held keys (direction/selection) */ s16 hp = PAD_ButtonsHeld(0) & (PAD_BUTTON_UP|PAD_BUTTON_DOWN|PAD_BUTTON_LEFT|PAD_BUTTON_RIGHT|PAD_BUTTON_A); /* PAD analog sticks (handled as PAD held direction keys) */ s8 x = PAD_StickX(0); s8 y = PAD_StickY(0); if (x > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_RIGHT; else if (x < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_LEFT; else if (y > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_UP; else if (y < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_DOWN; #ifdef HW_RVL /* WPAD status update */ WPAD_ScanPads(); WPADData *data = WPAD_Data(0); /* WPAD pressed keys */ u32 pw = data->btns_d; /* WPAD held keys (direction/selection) */ u32 hw = data->btns_h & (WPAD_BUTTON_UP|WPAD_BUTTON_DOWN|WPAD_BUTTON_LEFT|WPAD_BUTTON_RIGHT|WPAD_BUTTON_A|WPAD_BUTTON_2); /* WPAD analog sticks (handled as PAD held direction keys) */ x = WPAD_StickX(data, 0); y = WPAD_StickY(data, 0); if (x > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_RIGHT; else if (x < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_LEFT; else if (y > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_UP; else if (y < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_DOWN; #endif /* check if any direction/selection key is being held or just being pressed/released */ #ifdef HW_RVL if (pp||pw) held_cnt = 0; else if (hp||hw) held_cnt++; else held_cnt = 0; #else if (pp) held_cnt = 0; else if (hp) held_cnt++; else held_cnt = 0; #endif /* initial delay (prevents triggering to start immediately) */ if (held_cnt > HELD_DELAY) { /* key triggering */ pp |= hp; #ifdef HW_RVL pw |= hw; #endif /* delay until next triggering (adjusts direction/selection update speed) */ held_cnt -= HELD_SPEED; } #ifdef HW_RVL /* Wiimote direction keys */ WPAD_IR(0, &m_input.ir); if (m_input.ir.valid) { /* Wiimote is handled vertically */ if (pw & WPAD_BUTTON_UP) pp |= PAD_BUTTON_UP; else if (pw & WPAD_BUTTON_DOWN) pp |= PAD_BUTTON_DOWN; else if (pw & WPAD_BUTTON_LEFT) pp |= PAD_BUTTON_LEFT; else if (pw & WPAD_BUTTON_RIGHT) pp |= PAD_BUTTON_RIGHT; } else { /* Wiimote is handled horizontally */ if (pw & WPAD_BUTTON_UP) pp |= PAD_BUTTON_LEFT; else if (pw & WPAD_BUTTON_DOWN) pp |= PAD_BUTTON_RIGHT; else if (pw & WPAD_BUTTON_LEFT) pp |= PAD_BUTTON_DOWN; else if (pw & WPAD_BUTTON_RIGHT) pp |= PAD_BUTTON_UP; } /* Classic Controller direction keys */ if (pw & WPAD_CLASSIC_BUTTON_UP) pp |= PAD_BUTTON_UP; else if (pw & WPAD_CLASSIC_BUTTON_DOWN) pp |= PAD_BUTTON_DOWN; else if (pw & WPAD_CLASSIC_BUTTON_LEFT) pp |= PAD_BUTTON_LEFT; else if (pw & WPAD_CLASSIC_BUTTON_RIGHT) pp |= PAD_BUTTON_RIGHT; /* WPAD buttons */ if (pw & WPAD_BUTTON_MINUS) pp |= PAD_TRIGGER_L; if (pw & WPAD_BUTTON_PLUS) pp |= PAD_TRIGGER_R; if (pw & WPAD_BUTTON_A) pp |= PAD_BUTTON_A; if (pw & WPAD_BUTTON_B) pp |= PAD_BUTTON_B; if (pw & WPAD_BUTTON_2) pp |= PAD_BUTTON_A; if (pw & WPAD_BUTTON_1) pp |= PAD_BUTTON_B; if (pw & WPAD_BUTTON_HOME) pp |= PAD_TRIGGER_Z; if (pw & WPAD_CLASSIC_BUTTON_FULL_L) pp |= PAD_TRIGGER_L; if (pw & WPAD_CLASSIC_BUTTON_FULL_R) pp |= PAD_TRIGGER_R; if (pw & WPAD_CLASSIC_BUTTON_A) pp |= PAD_BUTTON_A; if (pw & WPAD_CLASSIC_BUTTON_B) pp |= PAD_BUTTON_B; if (pw & WPAD_CLASSIC_BUTTON_HOME) pp |= PAD_TRIGGER_Z; #endif /* Update menu inputs */ m_input.keys = pp; }
zyking1987-genplus-droid
genplusgx/unused/gx/gx_input.c
C
gpl2
29,308
/**************************************************************************** * gx_audio.c * * Genesis Plus GX audio support * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" /* DMA soundbuffers (required to be 32-bytes aligned) Length is dimensionned for one frame of emulation (800/808 samples @60hz, 960 samples@50Hz) To prevent audio clashes, we use double buffering technique: one buffer is the active DMA buffer the other one is the current work buffer (updated during frame emulation) We do not need more since frame emulation and DMA operation are synchronized */ u8 soundbuffer[2][3840] ATTRIBUTE_ALIGN(32); /* Current work soundbuffer */ u32 mixbuffer; /* audio DMA status */ u32 audioStarted; /* Background music */ static u8 *Bg_music_ogg = NULL; static u32 Bg_music_ogg_size = 0; /***************************************************************************************/ /* Audio engine */ /***************************************************************************************/ /* Audio DMA callback */ static void ai_callback(void) { frameticker++; } /* AUDIO engine initialization */ void gx_audio_Init(void) { /* Initialize AUDIO processing library (ASNDLIB) */ /* AUDIO & DSP hardware are initialized */ /* Default samplerate is set to 48kHz */ ASND_Init(); /* Load background music from FAT device */ char fname[MAXPATHLEN]; sprintf(fname,"%s/Bg_music.ogg",DEFAULT_PATH); FILE *f = fopen(fname,"rb"); if (f) { struct stat filestat; stat(fname, &filestat); Bg_music_ogg_size = filestat.st_size; Bg_music_ogg = memalign(32,Bg_music_ogg_size); if (Bg_music_ogg) fread(Bg_music_ogg,1,Bg_music_ogg_size,f); fclose(f); } } /* AUDIO engine shutdown */ void gx_audio_Shutdown(void) { PauseOgg(1); StopOgg(); ASND_Pause(1); ASND_End(); if (Bg_music_ogg) free(Bg_music_ogg); } /*** gx_audio_Update This function retrieves samples for the frame then set the next DMA parameters Parameters will be taken in account only when current DMA operation is over ***/ void gx_audio_Update(void) { /* retrieve audio samples */ int size = audio_update() * 4; /* set next DMA soundbuffer */ s16 *sb = (s16 *)(soundbuffer[mixbuffer]); DCFlushRange((void *)sb, size); AUDIO_InitDMA((u32) sb, size); mixbuffer ^= 1; /* Start Audio DMA */ /* this is called once to kick-off DMA from external memory to audio interface */ /* DMA operation is automatically restarted when all samples have been sent. */ /* If DMA settings are not updated at that time, previous sound buffer will be used. */ /* Therefore we need to make sure frame emulation is completed before current DMA is */ /* completed, either by synchronizing frame emulation with DMA start or by syncing it */ /* with Vertical Interrupt and outputing a suitable number of samples per frame. */ /* In 60hz mode, VSYNC period is actually 16715 ms which is 802.32 samples at 48kHz. */ /* */ /* In both cases, audio DMA need to be synchronized with VSYNC and therefore need to */ /* be resynchronized (restarted) every time video settings are changed (hopefully, */ /* this generally happens while no music is played. */ if (!audioStarted) { audioStarted = 1; /* when not using 60hz mode, frame emulation is synchronized with Audio Interface DMA */ if (gc_pal | vdp_pal) AUDIO_RegisterDMACallback(ai_callback); /* restart audio DMA */ AUDIO_StopDMA(); AUDIO_StartDMA(); if (frameticker > 1) frameticker = 1; } } /*** gx_audio_Start This function restart the audio engine This is called when coming back from Main Menu ***/ void gx_audio_Start(void) { /* shutdown background music */ PauseOgg(1); StopOgg(); /* shutdown menu audio processing */ ASND_Pause(1); AUDIO_StopDMA(); AUDIO_RegisterDMACallback(NULL); DSP_Halt(); /* reset emulation audio processing */ memset(soundbuffer, 0, 2 * 3840); audioStarted = 0; mixbuffer = 0; } /*** gx_audio_Stop This function stops current Audio DMA process This is called when going back to Main Menu DMA need to be restarted when going back to the game (see above) ***/ void gx_audio_Stop(void) { /* restart menu audio processing */ DSP_Unhalt(); ASND_Init(); ASND_Pause(0); /* play background music */ if (Bg_music_ogg && !Shutdown) { PauseOgg(0); PlayOgg((char *)Bg_music_ogg, Bg_music_ogg_size, 0, OGG_INFINITE_TIME); SetVolumeOgg(((int)config.bgm_volume * 255) / 100); } }
zyking1987-genplus-droid
genplusgx/unused/gx/gx_audio.c
C
gpl2
5,814
/**************************************************************************** * main.c * * Genesis Plus GX * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #include "font.h" #include "gui.h" #include "history.h" #include "aram.h" #include "dvd.h" #include <fat.h> #include <ogc/cast.h> #ifdef HW_RVL #include <wiiuse/wpad.h> #endif u32 Shutdown = 0; #ifdef HW_RVL /* Power Button callback */ static void Power_Off(void) { Shutdown = 1; ConfigRequested = 1; } #endif /*************************************************************************** * Genesis Plus Virtual Machine * ***************************************************************************/ static void load_bios(void) { /* reset BIOS found flag */ config.bios_enabled &= ~2; /* open BIOS file */ FILE *fp = fopen(OS_ROM, "rb"); if (fp == NULL) return; /* read file */ fread(bios_rom, 1, 0x800, fp); fclose(fp); /* update BIOS flags */ config.bios_enabled |= 2; } static void init_machine(void) { /* Allocate cart_rom here ( 10 MBytes ) */ cart.rom = memalign(32, MAXROMSIZE); if (!cart.rom) { FONT_writeCenter("Failed to allocate ROM buffer... Rebooting",18,0,640,200,(GXColor)WHITE); gxSetScreen(); sleep(2); gx_audio_Shutdown(); gx_video_Shutdown(); #ifdef HW_RVL DI_Close(); SYS_ResetSystem(SYS_RESTART,0,0); #else SYS_ResetSystem(SYS_HOTRESET,0,0); #endif } /* BIOS support */ load_bios(); /* allocate global work bitmap */ memset (&bitmap, 0, sizeof (bitmap)); bitmap.width = 720; bitmap.height = 576; bitmap.depth = 16; bitmap.granularity = 2; bitmap.pitch = bitmap.width * bitmap.granularity; bitmap.viewport.w = 256; bitmap.viewport.h = 224; bitmap.viewport.x = 0; bitmap.viewport.y = 0; bitmap.data = texturemem; } /************************************************** Load a new rom and performs some initialization ***************************************************/ void reloadrom (int size, char *name) { /* cartridge hot-swap support */ uint8 hotswap = 0; if (cart.romsize) hotswap = config.hot_swap; /* Load ROM */ cart.romsize = size; load_rom(name); if (hotswap) { cart_hw_init(); cart_hw_reset(); } else { /* initialize audio back-end */ /* 60hz video mode requires synchronization with Video Interrupt. */ /* VSYNC period is 16715 us on Wii/Gamecube (approx. 802.32 samples per frame) */ float framerate; if (vdp_pal) framerate = 50.0; else framerate = ((config.tv_mode == 0) || (config.tv_mode == 2)) ? (1000000.0/16715.0) : 60.0; audio_init(48000, framerate); /* System Power ON */ system_init (); ClearGGCodes (); system_reset (); } } /************************************************** Shutdown everything properly ***************************************************/ void shutdown(void) { /* system shutdown */ memfile_autosave(-1,config.state_auto); system_shutdown(); audio_shutdown(); free(cart.rom); gx_audio_Shutdown(); gx_video_Shutdown(); #ifdef HW_RVL DI_Close(); #endif } /*************************************************************************** * M A I N * ***************************************************************************/ u32 fat_enabled = 0; u32 frameticker = 0; int main (int argc, char *argv[]) { #ifdef HW_RVL /* initialize DVDX */ DI_Init(); #endif /* initialize hardware */ gx_video_Init(); gx_input_Init(); #ifdef HW_DOL DVD_Init (); dvd_drive_detect(); #endif /* initialize FAT devices */ if (fatInitDefault()) { /* check for default directories */ DIR_ITER *dir = NULL; /* base directory */ char pathname[MAXPATHLEN]; sprintf (pathname, DEFAULT_PATH); dir = diropen(pathname); if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* SRAM & Savestate files directory */ sprintf (pathname, "%s/saves",DEFAULT_PATH); dir = diropen(pathname); if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* Snapshot files directory */ sprintf (pathname, "%s/snaps",DEFAULT_PATH); dir = diropen(pathname); if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); /* Cheat files directory */ sprintf (pathname, "%s/cheats",DEFAULT_PATH); dir = diropen(pathname); if (dir == NULL) mkdir(pathname,S_IRWXU); else dirclose(dir); } /* initialize sound engine */ gx_audio_Init(); /* initialize core engine */ legal(); config_default(); history_default(); init_machine(); /* run any injected rom */ if (cart.romsize) { ARAMFetch((char *)cart.rom, (void *)0x8000, cart.romsize); reloadrom (cart.romsize,"INJECT.bin"); gx_video_Start(); gx_audio_Start(); frameticker = 1; } else { /* Main Menu */ ConfigRequested = 1; } /* initialize GUI engine */ GUI_Initialize(); #ifdef HW_RVL /* Power button callback */ SYS_SetPowerCallback(Power_Off); #endif /* main emulation loop */ while (1) { /* Main Menu request */ if (ConfigRequested) { /* stop video & audio */ gx_audio_Stop(); gx_video_Stop(); /* show menu */ MainMenu (); ConfigRequested = 0; /* start video & audio */ gx_audio_Start(); gx_video_Start(); frameticker = 1; } if (frameticker > 1) { /* skip frame */ system_frame(1); --frameticker; } else { while (frameticker < 1) usleep(10); /* render frame */ system_frame(0); --frameticker; /* update video */ gx_video_Update(); } /* update audio */ gx_audio_Update(); } return 0; }
zyking1987-genplus-droid
genplusgx/unused/gx/main.c
C
gpl2
6,846
/**************************************************************************** * gui.c * * generic GUI Engine, using GX hardware * * Eke-Eke (2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #include "gui.h" #include "font.h" #ifdef HW_RVL gx_texture *w_pointer; #endif u8 SILENT = 0; /* message box */ static gui_message message_box; static lwp_t msgboxthread; /* background color */ static GXColor bg_color; /*****************************************************************************/ /* Generic GUI routines */ /*****************************************************************************/ /* Allocate Menu texture images data */ void GUI_InitMenu(gui_menu *menu) { int i; gui_item *item; gui_butn *button; gui_image *image; /* background elements */ for (i=0; i<menu->max_images; i++) { image = &menu->bg_images[i]; image->texture = gxTextureOpenPNG(image->data,0); } for (i=0; i<2; i++) { /* key helpers */ item = menu->helpers[i]; if (item) item->texture = gxTextureOpenPNG(item->data,0); /* arrows */ button = menu->arrows[i]; if (button) { if (!button->data->texture[0]) button->data->texture[0] = gxTextureOpenPNG(button->data->image[0],0); if (!button->data->texture[1]) button->data->texture[1] = gxTextureOpenPNG(button->data->image[1],0); /* initial state */ button->state &= ~BUTTON_VISIBLE; if (((i==0) && (menu->offset != 0)) || ((i==1) && (menu->offset + menu->max_buttons) < menu->max_items)) button->state |= BUTTON_VISIBLE; } } /* menu buttons */ for (i=0; i<menu->max_buttons; i++) { button = &menu->buttons[i]; if (button->data) { if (!button->data->texture[0]) button->data->texture[0] = gxTextureOpenPNG(button->data->image[0],0); if (!button->data->texture[1]) button->data->texture[1] = gxTextureOpenPNG(button->data->image[1],0); } } /* menu items */ for (i=0; i<menu->max_items; i++) { item = &menu->items[i]; if (item->data) item->texture = gxTextureOpenPNG(item->data,0); } /* update message box */ message_box.parent = menu; } /* Release Menu allocated memory */ void GUI_DeleteMenu(gui_menu *menu) { int i; gui_butn *button; gui_item *item; gui_image *image; /* background elements */ for (i=0; i<menu->max_images; i++) { image = &menu->bg_images[i]; gxTextureClose(&image->texture); } for (i=0; i<2; i++) { /* key helpers */ item = menu->helpers[i]; if (item) gxTextureClose(&item->texture); /* arrows */ button = menu->arrows[i]; if (button) { gxTextureClose(&button->data->texture[0]); gxTextureClose(&button->data->texture[1]); } } /* menu buttons */ for (i=0; i<menu->max_buttons; i++) { button = &menu->buttons[i]; if (button->data) { gxTextureClose(&button->data->texture[0]); gxTextureClose(&button->data->texture[1]); } } /* menu items */ for (i=0; i<menu->max_items; i++) { item = &menu->items[i]; gxTextureClose(&item->texture); } } /* Draw Menu */ void GUI_DrawMenu(gui_menu *menu) { int i; gui_item *item; gui_butn *button; gui_image *image; /* background color */ if (menu->screenshot) { gxClearScreen((GXColor)BLACK); gxDrawScreenshot(menu->screenshot); } else { gxClearScreen(bg_color); } /* background elements */ for (i=0; i<menu->max_images; i++) { image = &menu->bg_images[i]; if (image->state & IMAGE_REPEAT) gxDrawTextureRepeat(image->texture,image->x,image->y,image->w,image->h,image->alpha); else if (image->state & IMAGE_VISIBLE) gxDrawTexture(image->texture,image->x,image->y,image->w,image->h,image->alpha); } /* menu title */ FONT_write(menu->title, 22,10,56,640,(GXColor)WHITE); /* draw buttons + items */ for (i=0; i<menu->max_buttons; i++) { button = &menu->buttons[i]; if (button->state & BUTTON_VISIBLE) { /* draw button + items */ item = &menu->items[menu->offset +i]; if ((i == menu->selected) && (button->state & BUTTON_ACTIVE)) { if (button->data) gxDrawTexture(button->data->texture[1],button->x-4,button->y-4,button->w+8,button->h+8,255); if (item->texture) { gxDrawTexture(item->texture, item->x-4,item->y-4,item->w+8,item->h+8,255); FONT_writeCenter(item->text,18,button->x+4,item->x-4,button->y+(button->h - 36)/2+18,(GXColor)DARK_GREY); } else { FONT_writeCenter(item->text,18,item->x+2,item->x+item->w+2,button->y+(button->h-18)/2+18,(GXColor)DARK_GREY); } } else { if (button->data) gxDrawTexture(button->data->texture[0],button->x,button->y,button->w, button->h,255); if (item->texture) { gxDrawTexture(item->texture,item->x,item->y,item->w,item->h,255); FONT_writeCenter(item->text,16,button->x+8,item->x,button->y+(button->h - 32)/2+16,(GXColor)DARK_GREY); } else { FONT_writeCenter(item->text,16,item->x,item->x+item->w,button->y+(button->h - 16)/2+16,(GXColor)DARK_GREY); } } } } /* draw arrow */ for (i=0; i<2; i++) { button = menu->arrows[i]; if (button) { if (button->state & BUTTON_VISIBLE) { if (menu->selected == (menu->max_buttons + i)) gxDrawTexture(button->data->texture[1],button->x-2,button->y-2,button->w+4,button->h+4,255); else gxDrawTexture(button->data->texture[0],button->x,button->y,button->w, button->h,255); } } } /* left comment */ item = menu->helpers[0]; if (item) { if (item->data && strlen(item->comment)) { gxDrawTexture(item->texture,item->x,item->y,item->w,item->h,255); FONT_write(item->comment,16,item->x+item->w+6,item->y+(item->h-16)/2 + 16,640,(GXColor)WHITE); } } /* right comment */ item = menu->helpers[1]; if (item) { if (item->data && strlen(item->comment)) { gxDrawTexture(item->texture,item->x,item->y,item->w,item->h,255); FONT_alignRight(item->comment,16,item->x-6,item->y+(item->h-16)/2+16,(GXColor)WHITE); } } } /* Draw Menu with transitions effects */ void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out) { int i,temp,xoffset,yoffset; int max_offset = 0; u8 item_alpha = 255; GXColor text_color = DARK_GREY; gui_item *item; gui_butn *button; gui_image *image; /* find maximal offset */ for (i=0; i<menu->max_images; i++) { image = &menu->bg_images[i]; if (image->state & IMAGE_SLIDE_LEFT) { temp = image->x + image->w; if (max_offset < temp) max_offset = temp; } else if (image->state & IMAGE_SLIDE_RIGHT) { temp = 640 - image->x; if (max_offset < temp) max_offset = temp; } if (image->state & IMAGE_SLIDE_TOP) { temp = image->y + image->h; if (max_offset < temp) max_offset = temp; } else if (image->state & IMAGE_SLIDE_BOTTOM) { temp = 480 - image->y; if (max_offset < temp) max_offset = temp; } } temp = max_offset; /* Alpha steps */ int alpha = 0; int alpha_step = (255 * speed) / max_offset; if (out) { alpha = 255; alpha_step = -alpha_step; } /* Let's loop until final position has been reached */ while (temp > 0) { /* background color */ if (menu->screenshot) { gxClearScreen((GXColor)BLACK); if (alpha >= menu->screenshot) gxDrawScreenshot(menu->screenshot); else gxDrawScreenshot(255 - alpha); } else { gxClearScreen(bg_color); } /* background images */ for (i=0; i<menu->max_images; i++) { image = &menu->bg_images[i]; /* X offset */ if (image->state & IMAGE_SLIDE_LEFT) xoffset = out ? (temp - max_offset) : (-temp); else if (image->state & IMAGE_SLIDE_RIGHT) xoffset = out ? (max_offset - temp) : (temp); else xoffset = 0; /* Y offset */ if (image->state & IMAGE_SLIDE_TOP) yoffset = out ? (temp - max_offset) : (-temp); else if (image->state & IMAGE_SLIDE_BOTTOM) yoffset = out ? (max_offset - temp) : (temp); else yoffset = 0; /* draw image */ if ((image->state & IMAGE_FADE) && ((out && (image->alpha > alpha)) || (!out && (image->alpha < alpha)))) { /* FADE In-Out */ if (image->state & IMAGE_REPEAT) gxDrawTextureRepeat(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,alpha); else if (image->state & IMAGE_VISIBLE) gxDrawTexture(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,alpha); } else { if (image->state & IMAGE_REPEAT) gxDrawTextureRepeat(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,image->alpha); else if (image->state & IMAGE_VISIBLE) gxDrawTexture(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,image->alpha); } } /* menu title */ if (menu->bg_images[2].state & IMAGE_SLIDE_TOP) { FONT_write(menu->title, 22,10,out ? (56 + temp - max_offset) : (56 -temp),640,(GXColor)WHITE); } else { FONT_write(menu->title, 22,10,56,640,(GXColor)WHITE); } /* draw buttons + items */ for (i=0; i<menu->max_buttons; i++) { button = &menu->buttons[i]; if (button->state & BUTTON_VISIBLE) { /* X offset */ if (button->state & BUTTON_SLIDE_LEFT) xoffset = out ? (temp - max_offset) : (-temp); else if (button->state & BUTTON_SLIDE_RIGHT) xoffset = out ? (max_offset - temp) : (temp); else xoffset = 0; /* Y offset */ if (button->state & BUTTON_SLIDE_TOP) yoffset = out ? (temp - max_offset) : (-temp); else if (button->state & BUTTON_SLIDE_BOTTOM) yoffset = out ? (max_offset - temp) : (temp); else yoffset = 0; /* Alpha transparency */ if (button->state & BUTTON_FADE) { item_alpha = alpha; text_color.a = alpha; } else { item_alpha = 255; text_color.a = 255; } /* draw button + items */ item = &menu->items[menu->offset + i]; if (button->data) gxDrawTexture(button->data->texture[0],button->x+xoffset,button->y+yoffset,button->w, button->h,item_alpha); if (item->texture) { gxDrawTexture(item->texture,item->x+xoffset,item->y+yoffset,item->w,item->h,item_alpha); FONT_writeCenter(item->text,16,button->x+xoffset+8,item->x+xoffset,button->y+yoffset+(button->h - 32)/2+16,text_color); } else { FONT_writeCenter(item->text,16,item->x+xoffset,item->x+item->w+xoffset,button->y+yoffset+(button->h - 16)/2+16,text_color); } } } /* update offset */ temp -= speed; /* update alpha */ alpha += alpha_step; if (alpha > 255) alpha = 255; else if (alpha < 0) alpha = 0; /* copy EFB to XFB */ gxSetScreen(); } /* final position */ if (!out) { GUI_DrawMenu(menu); gxSetScreen(); } else if (menu->screenshot) { gxClearScreen((GXColor)BLACK); gxDrawScreenshot(255); gxSetScreen(); } } /* Basic menu title slide effect */ void GUI_SlideMenuTitle(gui_menu *m, int title_offset) { #ifdef HW_RVL gui_butn *button; int i,x,y; #endif char title[64]; strcpy(title,m->title); while (title_offset > 0) { /* update title */ strcpy(m->title,title+title_offset); m->title[strlen(title)-title_offset-1] = 0; /* draw menu */ GUI_DrawMenu(m); #ifdef HW_RVL if (m_input.ir.valid) { /* get cursor position */ x = m_input.ir.x; y = m_input.ir.y; /* draw wiimote pointer */ gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); /* check for valid buttons */ m->selected = m->max_buttons + 2; for (i=0; i<m->max_buttons; i++) { button = &m->buttons[i]; if ((button->state & BUTTON_ACTIVE)&&(x>=button->x)&&(x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) { m->selected = i; break; } } for (i=0; i<2; i++) { button = m->arrows[i]; if (button) { if (button->state & BUTTON_VISIBLE) { if ((x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) { m->selected = m->max_buttons + i; break; } } } } } else { /* reinitialize selection */ if (m->selected >= m->max_buttons) m->selected = 0; } #endif gxSetScreen(); usleep(6000); title_offset--; } strcpy(m->title,title); } /* Update current menu */ int GUI_UpdateMenu(gui_menu *menu) { u16 p; int ret = 0; int selected = menu->selected; int max_items = menu->max_items; int max_buttons = menu->max_buttons; gui_butn *button; #ifdef HW_RVL if (Shutdown) { GUI_DeleteMenu(menu); GUI_FadeOut(); shutdown(); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } else if (m_input.ir.valid) { /* get cursor position */ int x = m_input.ir.x; int y = m_input.ir.y; /* draw wiimote pointer */ gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); /* check for valid buttons */ selected = max_buttons + 2; int i; for (i=0; i<max_buttons; i++) { button = &menu->buttons[i]; if ((button->state & BUTTON_ACTIVE)&&(x>=button->x)&&(x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) { selected = i; break; } } for (i=0; i<2; i++) { button = menu->arrows[i]; if (button) { if (button->state & BUTTON_VISIBLE) { if ((x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) { selected = max_buttons + i; break; } } } } } else { /* reinitialize selection */ if (selected >= menu->max_buttons) selected = 0; } #endif /* update screen */ gxSetScreen(); /* update menu */ p = m_input.keys; if (selected < max_buttons) { button = &menu->buttons[selected]; if (p & PAD_BUTTON_UP) { selected -= button->shift[0]; if (selected < 0) { selected = 0; if (menu->offset) menu->offset --; } } else if (p & PAD_BUTTON_DOWN) { selected += button->shift[1]; if (selected >= max_buttons) { selected = max_buttons - 1; if ((menu->offset + selected < (max_items - 1))) menu->offset ++; } } else if (p & PAD_BUTTON_LEFT) { selected -= button->shift[2]; if (selected < 0) { selected = 0; if (menu->offset) menu->offset --; } } else if (p & PAD_BUTTON_RIGHT) { selected += button->shift[3]; if (selected >= max_buttons) { selected = max_buttons - 1; if ((menu->offset + selected < (max_items - 1))) menu->offset ++; } } } if (p & PAD_BUTTON_A) { if (selected < max_buttons) ret = 1; /* menu clicked */ else if (selected == max_buttons) menu->offset --; /* up arrow */ else if (selected == (max_buttons+1))menu->offset ++; /* down arrow */ } else if ((p & PAD_BUTTON_B) || (p & PAD_TRIGGER_Z)) { /* quit menu */ ret = -1; } /* selected item has changed ? */ if (menu->selected != selected) { if (selected < max_buttons) { /* sound fx */ button = &menu->buttons[selected]; if (button->state & BUTTON_OVER_SFX) { ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } else if (selected < (max_buttons + 2)) { /* sound fx */ button = menu->arrows[selected-max_buttons]; if (button->state & BUTTON_OVER_SFX) { ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } /* update selection */ menu->selected = selected; } /* update helper comment */ if (menu->helpers[1]) { if ((menu->offset + selected) < max_items) { gui_item *item = &menu->items[menu->offset + selected]; strcpy(menu->helpers[1]->comment,item->comment); } else { strcpy(menu->helpers[1]->comment,""); } } /* update arrows buttons status (items list) */ button = menu->arrows[0]; if (button) { if (menu->offset > 0) button->state |= BUTTON_VISIBLE; else button->state &= ~BUTTON_VISIBLE; } button = menu->arrows[1]; if (button) { if ((menu->offset + max_buttons) < max_items) button->state |= BUTTON_VISIBLE; else button->state &= ~BUTTON_VISIBLE; } if (ret > 0) { if (selected < max_buttons) { /* sound fx */ button = &menu->buttons[selected]; if (button->state & BUTTON_SELECT_SFX) { ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_select_pcm,button_select_pcm_size, ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } } return ret; } /* Generic routine to render & update menus */ int GUI_RunMenu(gui_menu *menu) { int update = 0; /* update menu */ while (!update) { GUI_DrawMenu(menu); update = GUI_UpdateMenu(menu); } if (update == 2) return (-2-menu->offset-menu->selected); else if (update == 1) return (menu->offset + menu->selected); else return -1; } #if 0 /* Scrollable Text Window (with configurable text size) */ void GUI_TextWindow(gui_menu *parent, char *title, char *items[], u8 nb_items, u8 fheight) { int i, ret, quit = 0; s32 selected = 0; s32 old; s16 p; #ifdef HW_RVL int x,y; #endif /* initialize arrows */ butn_data arrow[2]; arrow[0].texture[0] = gxTextureOpenPNG(Button_up_png,0); arrow[0].texture[1] = gxTextureOpenPNG(Button_up_over_png,0); arrow[1].texture[0] = gxTextureOpenPNG(Button_down_png,0); arrow[1].texture[1] = gxTextureOpenPNG(Button_down_over_png,0); /* initialize window */ gx_texture *window = gxTextureOpenPNG(Frame_s1_png,0); gx_texture *top = gxTextureOpenPNG(Frame_s1_title_png,0); /* initialize text position */ int offset = 0; int pagesize = ( window->height - 2*top->height) / fheight; /* set initial positions */ int xwindow = (640 - window->width)/2; int ywindow = (480 - window->height)/2; int ypos = ywindow + top->height + fheight; int ypos2 = ywindow + window->height - arrow[1].texture[0]->height; /* set initial vertical offset */ int yoffset = ywindow + window->height; /* disable helper comment */ if (parent->helpers[1]) parent->helpers[1]->data = 0; /* slide in */ while (yoffset > 0) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); /* draw title */ FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); /* draw text */ for (i=0; i<max; i++) { FONT_writeCenter(items[i],fheight,xwindow,xwindow+window->width,ypos+i*fheight- yoffset,(GXColor)WHITE); } /* update display */ gxSetScreen(); /* slide speed */ yoffset -= 60; } /* draw menu */ while (quit == 0) { /* draw parent menu (should have been initialized first) */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow,window->width,window->height,230); /* draw text */ for (i=0; i<max; i++) { FONT_writeCenter(items[offset + i],fheight,xwindow,xwindow+window->width,ypos+i*fheight,(GXColor)WHITE); } /* down arrow */ if ((max + offset) < nb_items) { if (selected == 1) gxDrawTexture(arrow[1].texture[1],xwindow,ypos2,arrow[1].texture[1]->width,arrow[1].texture[1]->height,255); else gxDrawTexture(arrow[1].texture[0],xwindow,ypos2,arrow[1].texture[0]->width,arrow[1].texture[0]->height,255); } /* up arrow */ if (offset > 0) { if (selected == 0) gxDrawTexture(arrow[1].texture[1],xwindow,ywindow,arrow[1].texture[1]->width,arrow[1].texture[1]->height,255); else gxDrawTexture(arrow[1].texture[0],xwindow,ywindow,arrow[1].texture[1]->width,arrow[1].texture[1]->height,255); } else { gxDrawTexture(top,xwindow,ywindow,top->width,top->height,255); FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20,(GXColor)WHITE); } p = m_input.keys; #ifdef HW_RVL if (Shutdown) { gxTextureClose(&window); gxTextureClose(&top); gxTextureClose(&arrow[0].texture[0]); gxTextureClose(&arrow[0].texture[1]); gxTextureClose(&arrow[1].texture[0]); gxTextureClose(&arrow[1].texture[1]); gxTextureClose(&w_pointer); GUI_DeleteMenu(parent); GUI_FadeOut(); shutdown(); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } else if (m_input.ir.valid) { /* get cursor position */ x = m_input.ir.x; y = m_input.ir.y; /* draw wiimote pointer */ gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); /* check for valid buttons */ selected = -1; if ((x>=xwindow)&&(x<=(xwindow+window->width))&&(y>=ypos+i*(20 + h))&&(y<=(ypos+i*(20+h)+h))) { selected = i; break; } } } else { /* reinitialize selection */ if (selected == -1) selected = 0; } #endif /* update screen */ gxSetScreen(); /* update selection */ if (p&PAD_BUTTON_UP) { if (selected > 0) selected --; } else if (p&PAD_BUTTON_DOWN) { if (selected < (nb_items -1)) selected ++; } /* sound fx */ if (selected != old) { if (selected >= 0) { ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } if (p & PAD_BUTTON_A) { if (selected >= 0) { quit = 1; ret = selected; } } else if (p & PAD_BUTTON_B) { quit = 1; ret = -1; } } /* reset initial vertical offset */ yoffset = 0; /* slide out */ while (yoffset < (ywindow + window->height)) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window + header */ gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); /* draw title */ FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); /* draw buttons + text */ for (i=0; i<nb_items; i++) { gxDrawTexture(button.texture[0],xpos,ypos+i*(20+h)-yoffset,w,h,255); FONT_writeCenter(items[i],18,xpos,xpos+w,ypos+i*(20+h)+(h+18)/2-yoffset,(GXColor)WHITE); } yoffset += 60; gxSetScreen(); } /* restore helper comment */ if (parent->helpers[1]) parent->helpers[1]->data = Key_A_png; /* final position */ GUI_DrawMenu(parent); gxSetScreen(); /* close textures */ gxTextureClose(&window); gxTextureClose(&top); gxTextureClose(&button.texture[0]); gxTextureClose(&button.texture[1]); return ret; } #endif /* Option Window (returns selected item) */ int GUI_OptionWindow(gui_menu *parent, char *title, char *items[], u8 nb_items) { int i, ret, quit = 0; s32 selected = 0; s32 old; butn_data button; s16 p; #ifdef HW_RVL int x,y; #endif /* initialize buttons data */ button.texture[0] = gxTextureOpenPNG(Button_text_png,0); button.texture[1] = gxTextureOpenPNG(Button_text_over_png,0); /* initialize texture window */ gx_texture *window = gxTextureOpenPNG(Frame_s1_png,0); gx_texture *top = gxTextureOpenPNG(Frame_s1_title_png,0); /* get initial positions */ int w = button.texture[0]->width; int h = button.texture[0]->height; int xwindow = (640 - window->width)/2; int ywindow = (480 - window->height)/2; int xpos = xwindow + (window->width - w)/2; int ypos = (window->height - top->height - (h*nb_items) - (nb_items-1)*20)/2; ypos = ypos + ywindow + top->height; /* set initial vertical offset */ int yoffset = ywindow + window->height; /* disable helper comment */ if (parent->helpers[1]) parent->helpers[1]->data = 0; /* slide in */ while (yoffset > 0) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); /* draw title */ FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); /* draw buttons + text */ for (i=0; i<nb_items; i++) { gxDrawTexture(button.texture[0],xpos,ypos+i*(20 + h)-yoffset,w,h,255); FONT_writeCenter(items[i],18,xpos,xpos+w,ypos+i*(20 + h)+(h + 18)/2- yoffset,(GXColor)DARK_GREY); } /* update display */ gxSetScreen(); /* slide speed */ yoffset -= 60; } /* draw menu */ while (quit == 0) { /* draw parent menu (should have been initialized first) */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow,top->width,top->height,255); /* draw title */ FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20,(GXColor)WHITE); /* draw buttons + text */ for (i=0; i<nb_items; i++) { if (i==selected) { gxDrawTexture(button.texture[1],xpos-4,ypos+i*(20+h)-4,w+8,h+8,255); FONT_writeCenter(items[i],22,xpos,xpos+w,ypos+i*(20+h)+(h+22)/2,(GXColor)DARK_GREY); } else { gxDrawTexture(button.texture[0],xpos,ypos+i*(20 + h),w,h,255); FONT_writeCenter(items[i],18,xpos,xpos+w,ypos+i*(20+h)+(h+18)/2,(GXColor)DARK_GREY); } } old = selected; p = m_input.keys; #ifdef HW_RVL if (Shutdown) { gxTextureClose(&window); gxTextureClose(&top); gxTextureClose(&button.texture[0]); gxTextureClose(&button.texture[1]); gxTextureClose(&w_pointer); GUI_DeleteMenu(parent); GUI_FadeOut(); shutdown(); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } else if (m_input.ir.valid) { /* get cursor position */ x = m_input.ir.x; y = m_input.ir.y; /* draw wiimote pointer */ gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); /* check for valid buttons */ selected = -1; for (i=0; i<nb_items; i++) { if ((x>=xpos)&&(x<=(xpos+w))&&(y>=ypos+i*(20 + h))&&(y<=(ypos+i*(20+h)+h))) { selected = i; break; } } } else { /* reinitialize selection */ if (selected == -1) selected = 0; } #endif /* update screen */ gxSetScreen(); /* update selection */ if (p&PAD_BUTTON_UP) { if (selected > 0) selected --; } else if (p&PAD_BUTTON_DOWN) { if (selected < (nb_items -1)) selected ++; } /* sound fx */ if (selected != old) { if (selected >= 0) { ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } if (p & PAD_BUTTON_A) { if (selected >= 0) { quit = 1; ret = selected; } } else if (p & PAD_BUTTON_B) { quit = 1; ret = -1; } } /* reset initial vertical offset */ yoffset = 0; /* slide out */ while (yoffset < (ywindow + window->height)) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window + header */ gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); /* draw title */ FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); /* draw buttons + text */ for (i=0; i<nb_items; i++) { gxDrawTexture(button.texture[0],xpos,ypos+i*(20+h)-yoffset,w,h,255); FONT_writeCenter(items[i],18,xpos,xpos+w,ypos+i*(20+h)+(h+18)/2-yoffset,(GXColor)WHITE); } yoffset += 60; gxSetScreen(); } /* restore helper comment */ if (parent->helpers[1]) parent->helpers[1]->data = Key_A_png; /* final position */ GUI_DrawMenu(parent); gxSetScreen(); /* close textures */ gxTextureClose(&window); gxTextureClose(&top); gxTextureClose(&button.texture[0]); gxTextureClose(&button.texture[1]); return ret; } /* Option Box */ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type) { gx_texture *arrow[2]; arrow[0] = gxTextureOpenPNG(Button_arrow_png,0); arrow[1] = gxTextureOpenPNG(Button_arrow_over_png,0); gx_texture *window = gxTextureOpenPNG(Frame_s4_png,0); gx_texture *top = gxTextureOpenPNG(Frame_s4_title_png,0); /* window position */ int xwindow = 166; int ywindow = 160; /* arrows position */ int xleft = 206; int xright = 392; int yleft = 238; int yright = 238; /* disable action button helper */ if (parent->helpers[1]) parent->helpers[1]->data = 0; /* slide in */ char msg[16]; int yoffset = ywindow + window->height; while (yoffset > 0) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); /* display title */ FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); /* update display */ gxSetScreen(); /* slide speed */ yoffset -= 60; } /* display option box */ int quit = 0; int modified = 0; int selected = -1; s16 p; #ifdef HW_RVL int x,y; #endif while (!quit) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow,top->width,top->height,255); /* display title */ FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20,(GXColor)WHITE); /* option type */ if (type) { /* integer type */ if (*(s16 *)option < 0) sprintf(msg,"-%d",abs(*(s16 *)option)); else sprintf(msg,"%d",abs(*(s16 *)option)); } else { /* float type */ if (*(float *)option < 0.0) sprintf(msg,"-%1.3f",fabs(*(float *)option)); else sprintf(msg,"%1.3f",fabs(*(float *)option)); } /* draw option text */ FONT_writeCenter(msg,24,xwindow,xwindow+window->width,272,(GXColor)WHITE); /* update inputs */ p = m_input.keys; /* draw buttons */ if (selected < 0) { /* nothing selected */ gxDrawTexture(arrow[0],xleft,yleft,arrow[0]->width,arrow[0]->height,255); gxDrawTextureRotate(arrow[0],xright,yright,arrow[0]->width,arrow[0]->height,180.0,255); } #ifdef HW_RVL else if (selected) { /* right button selected */ gxDrawTexture(arrow[0],xleft,yleft,arrow[0]->width,arrow[0]->height,255); gxDrawTextureRotate(arrow[1],xright-4,yright-4,arrow[1]->width+8,arrow[1]->height+8,180.0,255); } else { /* left button selected */ gxDrawTexture(arrow[1],xleft-4,yleft-4,arrow[1]->width+8,arrow[1]->height+8,255); gxDrawTextureRotate(arrow[0],xright,yright,arrow[0]->width,arrow[0]->height,180.0,255); } selected = -1; if (Shutdown) { gxTextureClose(&arrow[0]); gxTextureClose(&arrow[1]); gxTextureClose(&window); gxTextureClose(&top); gxTextureClose(&w_pointer); GUI_DeleteMenu(parent); GUI_FadeOut(); shutdown(); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } else if (m_input.ir.valid) { /* get cursor position */ x = m_input.ir.x; y = m_input.ir.y; /* draw wiimote pointer */ gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); /* check for valid buttons */ if ((x>=xleft)&&(x<=(xleft+arrow[0]->width))&&(y>=yleft)&&(y<=(yleft+arrow[0]->height))) { selected = 0; if (p & PAD_BUTTON_A) p |= PAD_BUTTON_LEFT; } else if ((x>=xright)&&(x<=(xright+arrow[0]->width))&&(y>=yright)&&(y<=(yright+arrow[0]->height))) { selected = 1; if (p & PAD_BUTTON_A) p |= PAD_BUTTON_RIGHT; } } #endif /* update screen */ gxSetScreen(); /* check input */ if (p&PAD_BUTTON_LEFT) { /* decrement option value */ if (type) { /* integer type */ *(s16 *)option -= (s16)step; if (*(s16 *)option < (s16)min) *(s16 *)option = (s16)max; } else { /* float type */ *(float *)option -= step; if (*(float *)option < min) *(float *)option = max; } modified = 1; } else if (p&PAD_BUTTON_RIGHT) { /* increment option value */ if (type) { /* integer type */ *(s16 *)option += (s16)step; if (*(s16 *)option > (s16)max) *(s16 *)option = (s16)min; } else { /* float type */ *(float *)option += step; if (*(float *)option > max) *(float *)option = min; } modified = 1; } else if (p & PAD_BUTTON_B) { quit = 1; } if (modified) { modified = 0; /* play sound effect */ ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); /* option callback */ if (cb) cb(); } } /* slide out */ yoffset = 0; ; while (yoffset < (ywindow + window->height)) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); /* display title */ FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); /* update display */ gxSetScreen(); /* slide speed */ yoffset += 60; } /* restore action button helper */ if (parent->helpers[1]) parent->helpers[1]->data = Key_A_png; /* final position */ GUI_DrawMenu(parent); gxSetScreen(); /* close textures */ gxTextureClose(&arrow[0]); gxTextureClose(&arrow[1]); gxTextureClose(&window); gxTextureClose(&top); } /* Option Box with two parameters */ void GUI_OptionBox2(gui_menu *parent, char *text_1, char *text_2, s16 *option_1, s16 *option_2, s16 step, s16 min, s16 max) { gx_texture *arrow[2]; arrow[0] = gxTextureOpenPNG(Button_arrow_png,0); arrow[1] = gxTextureOpenPNG(Button_arrow_over_png,0); gx_texture *window = gxTextureOpenPNG(Frame_s4_png,0); /* window position */ int xwindow = 166; int ywindow = 160; /* arrows position */ int arrow_pos[4][2] = { {144,218}, {452,218}, {298,138}, {298,298} }; /* disable action button helper */ if (parent->helpers[1]) parent->helpers[1]->data = 0; /* slide in */ char msg[16]; int yoffset = ywindow + window->height; while (yoffset > 0) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); /* update display */ gxSetScreen(); /* slide speed */ yoffset -= 60; } /* display option box */ int quit = 0; int modified = 0; s16 p; #ifdef HW_RVL int selected = -1; int i,x,y; #endif while (!quit) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow,window->width,window->height,230); /* draw options text */ if (*option_1 < 0) sprintf(msg,"%s: -%02d",text_1,abs(*option_1)); else sprintf(msg,"%s: +%02d",text_1,abs(*option_1)); FONT_writeCenter(msg,24,xwindow,xwindow+window->width,240,(GXColor)WHITE); if (*option_2 < 0) sprintf(msg,"%s: -%02d",text_2,abs(*option_2)); else sprintf(msg,"%s: +%02d",text_2,abs(*option_2)); FONT_writeCenter(msg,24,xwindow,xwindow+window->width,264,(GXColor)WHITE); /* update inputs */ p = m_input.keys; /* draw buttons */ #ifdef HW_RVL switch (selected) { case 0: /* left button */ gxDrawTexture(arrow[1],arrow_pos[0][0]-4,arrow_pos[0][1]-4,arrow[0]->width+8,arrow[0]->height+8,255); gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); if (p & PAD_BUTTON_A) p |= PAD_BUTTON_LEFT; break; case 1: /* right button */ gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); gxDrawTextureRotate(arrow[1],arrow_pos[1][0]-4,arrow_pos[1][1]-4,arrow[0]->width+8,arrow[0]->height+8,180.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); if (p & PAD_BUTTON_A) p |= PAD_BUTTON_RIGHT; break; case 2: /* up button */ gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); gxDrawTextureRotate(arrow[1],arrow_pos[2][0]-4,arrow_pos[2][1]-4,arrow[0]->width+8,arrow[0]->height+8,90.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); if (p & PAD_BUTTON_A) p |= PAD_BUTTON_UP; break; case 3: /* down button */ gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); gxDrawTextureRotate(arrow[1],arrow_pos[3][0]-4,arrow_pos[3][1]-4,arrow[0]->width+8,arrow[0]->height+8,270.0,255); if (p & PAD_BUTTON_A) p |= PAD_BUTTON_DOWN; break; default: /* nothing selected */ gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); break; } if (Shutdown) { gxTextureClose(&arrow[0]); gxTextureClose(&arrow[1]); gxTextureClose(&window); gxTextureClose(&w_pointer); GUI_DeleteMenu(parent); GUI_FadeOut(); shutdown(); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } /* update selection */ selected = -1; if (m_input.ir.valid) { /* get cursor position */ x = m_input.ir.x; y = m_input.ir.y; /* draw wiimote pointer */ gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); /* check for valid buttons */ for (i=0; i<4; i++) { if ((x>=arrow_pos[i][0])&&(x<=(arrow_pos[i][0]+arrow[0]->width))&&(y>=arrow_pos[i][1])&&(y<=(arrow_pos[i][1]+arrow[0]->height))) selected = i; } } #else gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); #endif /* update screen */ gxSetScreen(); if (p&PAD_BUTTON_LEFT) { /* decrement option 1 value */ *option_1 -= step; if (*option_1 < min) *option_1 = max; modified = 1; } else if (p&PAD_BUTTON_RIGHT) { /* decrement option 1 value */ *option_1 += step; if (*option_1 > max) *option_1 = min; modified = 1; } else if (p&PAD_BUTTON_UP) { /* decrement option 2 value */ *option_2 -= step; if (*option_2 < min) *option_2 = max; modified = 1; } else if (p&PAD_BUTTON_DOWN) { /* increment option 2 value */ *option_2 += step; if (*option_2 > max) *option_2 = min; modified = 1; } else if (p & PAD_BUTTON_B) { quit = 1; } if (modified) { modified = 0; /* play sound effect */ ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } /* slide out */ yoffset = 0; ; while (yoffset < (ywindow + window->height)) { /* draw parent menu */ GUI_DrawMenu(parent); /* draw window */ gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); /* update display */ gxSetScreen(); /* slide speed */ yoffset += 60; } /* restore action button helper */ if (parent->helpers[1]) parent->helpers[1]->data = Key_A_png; /* final position */ GUI_DrawMenu(parent); gxSetScreen(); /* close textures */ gxTextureClose(&arrow[0]); gxTextureClose(&arrow[1]); gxTextureClose(&window); } /* Interactive Message Box */ /* Message Box displays a message until a specific action is completed */ /* Message Box LWP Thread */ static void *MsgBox_Thread(void *arg) { while (1) { if (message_box.refresh) { /* draw parent menu */ GUI_DrawMenu(message_box.parent); /* draw window */ gxDrawTexture(message_box.window,166,160,message_box.window->width,message_box.window->height,230); gxDrawTexture(message_box.top,166,160,message_box.top->width,message_box.top->height,255); /* draw title */ if (message_box.title) FONT_writeCenter(message_box.title,20,166,166+message_box.window->width,160+(message_box.top->height-20)/2+20,(GXColor)WHITE); /* draw box message */ if (message_box.msg) FONT_writeCenter(message_box.msg,18,166,166+message_box.window->width,248,(GXColor)WHITE); /* draw throbber */ if (message_box.throbber) { gxDrawTextureRotate(message_box.throbber,166+(message_box.window->width-message_box.throbber->width)/2,160+message_box.window->height-message_box.throbber->height-20,message_box.throbber->width,message_box.throbber->height,(message_box.progress * 360.0) / 100.0, 255); } /* draw exit message */ if (message_box.buttonA) { if (message_box.buttonB) { FONT_write("OK",18,220+message_box.buttonA->width+6,288,640,(GXColor)WHITE); FONT_alignRight("CANCEL",18,166+message_box.window->width-(220-166),288,(GXColor)WHITE); if (message_box.buttonA) gxDrawTexture(message_box.buttonA, 220, 288-18+(18-message_box.buttonA->height)/2,message_box.buttonA->width, message_box.buttonA->height,255); if (message_box.buttonB) gxDrawTexture(message_box.buttonB, 328, 288-18+(18-message_box.buttonB->height)/2,message_box.buttonB->width, message_box.buttonB->height,255); } else { FONT_writeCenter("Press to continue.",18,166,166+message_box.window->width,248+22,(GXColor)WHITE); if (message_box.buttonA) gxDrawTexture(message_box.buttonA, 166+116, 248+4+(18-message_box.buttonA->height)/2,message_box.buttonA->width, message_box.buttonA->height,255); } } /* update display */ gxSetScreen(); /* update progression */ message_box.progress++; if (message_box.progress > 100) message_box.progress = 0; } else { LWP_YieldThread(); } } return NULL; } /* update current Message Box */ void GUI_MsgBoxUpdate(char *title, char *msg) { if (title) strncpy(message_box.title,title,64); if (msg) strncpy(message_box.msg,msg,64); } /* setup current Message Box */ void GUI_MsgBoxOpen(char *title, char *msg, bool throbber) { if (SILENT) return; /* clear unused textures */ gxTextureClose(&message_box.buttonA); gxTextureClose(&message_box.buttonB); gxTextureClose(&message_box.throbber); /* update message box */ GUI_MsgBoxUpdate(title,msg); /* ensure we are not already running */ if (!message_box.refresh) { /* initialize default textures */ message_box.window = gxTextureOpenPNG(Frame_s4_png,0); message_box.top = gxTextureOpenPNG(Frame_s4_title_png,0); if (throbber) message_box.throbber = gxTextureOpenPNG(Frame_throbber_png,0); /* window position */ int xwindow = 166; int ywindow = 160; int ypos = 248; /* disable helper comments */ if (message_box.parent->helpers[0]) message_box.parent->helpers[0]->data = 0; if (message_box.parent->helpers[1]) message_box.parent->helpers[1]->data = 0; /* slide in */ int yoffset = ywindow + message_box.window->height; while (yoffset > 0) { /* draw parent menu */ GUI_DrawMenu(message_box.parent); /* draw window */ gxDrawTexture(message_box.window,xwindow,ywindow-yoffset,message_box.window->width,message_box.window->height,230); gxDrawTexture(message_box.top,xwindow,ywindow-yoffset,message_box.top->width,message_box.top->height,255); /* draw title */ if (title) FONT_writeCenter(title,20,xwindow,xwindow+message_box.window->width,ywindow+(message_box.top->height-20)/2+20-yoffset,(GXColor)WHITE); /* draw box message */ if (msg) FONT_writeCenter(msg,18,xwindow,xwindow+message_box.window->width,ypos-yoffset,(GXColor)WHITE); /* update display */ gxSetScreen(); /* slide speed */ yoffset -= 60; } /* resume LWP thread for MessageBox refresh */ message_box.progress = 0; message_box.refresh = TRUE; LWP_ResumeThread(msgboxthread); } } /* Close current messagebox */ void GUI_MsgBoxClose(void) { if (message_box.refresh) { /* suspend MessageBox refresh */ message_box.refresh = FALSE; LWP_SuspendThread(msgboxthread); /* window position */ int xwindow = 166; int ywindow = 160; int ypos = 248; /* slide out */ int yoffset = 0; while (yoffset < (ywindow + message_box.window->height)) { /* draw parent menu */ GUI_DrawMenu(message_box.parent); /* draw window */ gxDrawTexture(message_box.window,xwindow,ywindow-yoffset,message_box.window->width,message_box.window->height,230); gxDrawTexture(message_box.top,xwindow,ywindow-yoffset,message_box.top->width,message_box.top->height,255); /* draw title */ if (message_box.title) FONT_writeCenter(message_box.title,20,xwindow,xwindow+message_box.window->width,ywindow+(message_box.top->height-20)/2+20-yoffset,(GXColor)WHITE); /* draw text */ if (message_box.msg) FONT_writeCenter(message_box.msg,18,xwindow,xwindow+message_box.window->width,ypos-yoffset,(GXColor)WHITE); /* update display */ gxSetScreen(); /* slide speed */ yoffset += 60; } /* restore helper comment */ if (message_box.parent->helpers[0]) message_box.parent->helpers[0]->data = Key_B_png; if (message_box.parent->helpers[1]) message_box.parent->helpers[1]->data = Key_A_png; /* final position */ GUI_DrawMenu(message_box.parent); gxSetScreen(); /* clear all textures */ gxTextureClose(&message_box.window); gxTextureClose(&message_box.top); gxTextureClose(&message_box.buttonA); gxTextureClose(&message_box.buttonB); gxTextureClose(&message_box.throbber); } } void GUI_WaitPrompt(char *title, char *msg) { if (SILENT) return; /* update message box */ GUI_MsgBoxOpen(title, msg, 0); /* allocate texture */ message_box.buttonA = gxTextureOpenPNG(Key_A_png,0); /* wait for button A */ while (m_input.keys & PAD_BUTTON_A) VIDEO_WaitVSync(); while (!(m_input.keys & PAD_BUTTON_A)) VIDEO_WaitVSync(); /* always close message box */ GUI_MsgBoxClose(); } int GUI_ConfirmPrompt(char *msg) { if (config.ask_confirm) { /* update message box */ GUI_MsgBoxOpen("User Confirmation", msg, 0); /* allocate textures */ message_box.buttonA = gxTextureOpenPNG(Key_A_png,0); message_box.buttonB = gxTextureOpenPNG(Key_B_png,0); /* wait for button A or button B*/ s16 p = 0; while (m_input.keys) VIDEO_WaitVSync(); while (!(p & (PAD_BUTTON_A | PAD_BUTTON_B))) { VIDEO_WaitVSync(); p = m_input.keys; } /* return user choice */ if (p & PAD_BUTTON_A) return 1; else return 0; } return 1; } /* Basic Fading */ void GUI_FadeOut() { int alpha = 0; while (alpha < 256) { gxDrawRectangle(0, 0, 640, 480, alpha, (GXColor)BLACK); gxSetScreen(); alpha +=3; } } /* Select default background color */ void GUI_SetBgColor(GXColor color) { bg_color.r = color.r; bg_color.g = color.g; bg_color.b = color.b; bg_color.a = color.a; } /* Initialize GUI engine */ void GUI_Initialize(void) { /* create LWP thread for MessageBox refresh */ message_box.refresh = FALSE; LWP_CreateThread (&msgboxthread, MsgBox_Thread, NULL, NULL, 0, 10); LWP_SuspendThread(msgboxthread); }
zyking1987-genplus-droid
genplusgx/unused/gx/gui/gui.c
C
gpl2
54,713
/**************************************************************************** * gui.c * * generic GUI engine, using GX hardware * * Eke-Eke (2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #ifndef _GUI_H #define _GUI_H #ifdef HW_RVL #include <wiiuse/wpad.h> #endif /*****************************************************************************/ /* GUI Buttons state */ /*****************************************************************************/ #define BUTTON_VISIBLE 0x01 #define BUTTON_ACTIVE 0x02 #define BUTTON_OVER_SFX 0x04 #define BUTTON_SELECT_SFX 0x10 #define BUTTON_FADE 0x20 #define BUTTON_SLIDE_LEFT 0x40 #define BUTTON_SLIDE_RIGHT 0x80 #define BUTTON_SLIDE_TOP 0x100 #define BUTTON_SLIDE_BOTTOM 0x200 /*****************************************************************************/ /* GUI Image state */ /*****************************************************************************/ #define IMAGE_VISIBLE 0x01 #define IMAGE_REPEAT 0x02 #define IMAGE_FADE 0x04 #define IMAGE_SLIDE_LEFT 0x08 #define IMAGE_SLIDE_RIGHT 0x10 #define IMAGE_SLIDE_TOP 0x20 #define IMAGE_SLIDE_BOTTOM 0x40 /*****************************************************************************/ /* Generic GUI structures */ /*****************************************************************************/ /* Item descriptor*/ typedef struct { gx_texture *texture; /* temporary texture data */ const u8 *data; /* pointer to png image data (items icon only) */ char text[64]; /* item string (items list only) */ char comment[64]; /* item comment */ u16 x; /* item image or text X position (upper left corner) */ u16 y; /* item image or text Y position (upper left corner) */ u16 w; /* item image or text width */ u16 h; /* item image or text height */ } gui_item; /* Button Data descriptor */ typedef struct { gx_texture *texture[2]; /* temporary texture datas */ const u8 *image[2]; /* pointer to png image datas (default) */ } butn_data; /* Button descriptor */ typedef struct { butn_data *data; /* pointer to button image/texture data */ u16 state; /* button state (ACTIVE,VISIBLE,SELECTED...) */ u8 shift[4]; /* direction offsets */ u16 x; /* button image X position (upper left corner) */ u16 y; /* button image Y position (upper left corner) */ u16 w; /* button image pixels width */ u16 h; /* button image pixels height */ } gui_butn; /* Image descriptor */ typedef struct { gx_texture *texture; /* temporary texture data */ const u8 *data; /* pointer to png image data */ u8 state; /* image state (VISIBLE) */ u16 x; /* image X position (upper left corner) */ u16 y; /* image Y position (upper left corner) */ u16 w; /* image width */ u16 h; /* image height */ u8 alpha; /* alpha transparency */ } gui_image; /* Menu descriptor */ typedef struct { char title[64]; /* menu title */ s8 selected; /* index of selected item */ s8 offset; /* items list offset */ u8 max_items; /* total number of items */ u8 max_buttons; /* total number of buttons */ u8 max_images; /* total number of background images */ u8 screenshot; /* game screen background */ gui_item *items; /* menu items */ gui_butn *buttons; /* menu buttons */ gui_image *bg_images; /* background images */ gui_item *helpers[2]; /* left & right key comments */ gui_butn *arrows[2]; /* arrows buttons */ } gui_menu; typedef struct { u32 progress; /* progress counter */ bool refresh; /* messagebox current state */ gui_menu *parent; /* parent menu */ char title[64]; /* box title */ char msg[64]; /* box message */ gx_texture *window; /* pointer to box texture */ gx_texture *top; /* pointer to box title texture */ gx_texture *buttonA; /* pointer to button A texture */ gx_texture *buttonB; /* pointer to button B texture */ gx_texture *throbber; /* pointer to throbber texture */ } gui_message; /* Menu inputs */ struct t_input_menu { u16 keys; #ifdef HW_RVL struct ir_t ir; #endif } m_input; /* Optionbox callback */ typedef void (*optioncallback)(void); /* PNG images */ /* Intro */ extern const u8 Bg_intro_c1_png[]; extern const u8 Bg_intro_c2_png[]; extern const u8 Bg_intro_c3_png[]; extern const u8 Bg_intro_c4_png[]; extern const u8 Bg_intro_c5_png[]; /* Generic backgrounds */ extern const u8 Bg_main_png[]; extern const u8 Bg_overlay_png[]; extern const u8 Banner_main_png[]; extern const u8 Banner_bottom_png[]; extern const u8 Banner_top_png[]; extern const u8 Main_logo_png[]; /* Generic frames */ extern const u8 Frame_s1_png[]; extern const u8 Frame_s2_png[]; extern const u8 Frame_s3_png[]; extern const u8 Frame_s4_png[]; extern const u8 Frame_s1_title_png[]; extern const u8 Frame_s4_title_png[]; extern const u8 Frame_throbber_png[]; /* ROM Browser */ extern const u8 Overlay_bar_png[]; extern const u8 Browser_dir_png[]; extern const u8 Star_full_png[]; extern const u8 Star_empty_png[]; extern const u8 Snap_empty_png[]; extern const u8 Snap_frame_png[]; /* Main menu */ extern const u8 Main_load_png[]; extern const u8 Main_options_png[]; extern const u8 Main_quit_png[]; extern const u8 Main_file_png[]; extern const u8 Main_reset_png[]; extern const u8 Main_ggenie_png[]; extern const u8 Main_showinfo_png[]; extern const u8 Main_takeshot_png[]; #ifdef HW_RVL extern const u8 Main_play_wii_png[]; #else extern const u8 Main_play_gcn_png[]; #endif /* Options menu */ extern const u8 Option_menu_png[]; extern const u8 Option_ctrl_png[]; extern const u8 Option_sound_png[]; extern const u8 Option_video_png[]; extern const u8 Option_system_png[]; /* Load ROM menu */ extern const u8 Load_recent_png[]; extern const u8 Load_sd_png[]; extern const u8 Load_dvd_png[]; #ifdef HW_RVL extern const u8 Load_usb_png[]; #endif /* Generic Buttons */ extern const u8 Button_text_png[]; extern const u8 Button_text_over_png[]; extern const u8 Button_icon_png[]; extern const u8 Button_icon_over_png[]; extern const u8 Button_icon_sm_png[]; extern const u8 Button_icon_sm_over_png[]; extern const u8 Button_up_png[]; extern const u8 Button_up_over_png[]; extern const u8 Button_down_png[]; extern const u8 Button_down_over_png[]; extern const u8 Button_arrow_png[]; extern const u8 Button_arrow_over_png[]; /* Controller Settings */ extern const u8 Ctrl_4wayplay_png[]; extern const u8 Ctrl_gamepad_png[]; extern const u8 Ctrl_justifiers_png[]; extern const u8 Ctrl_menacer_png[]; extern const u8 Ctrl_mouse_png[]; extern const u8 Ctrl_none_png[]; extern const u8 Ctrl_teamplayer_png[]; extern const u8 Ctrl_pad3b_png[]; extern const u8 Ctrl_pad6b_png[]; extern const u8 Ctrl_config_png[]; extern const u8 Ctrl_player_png[]; extern const u8 Ctrl_player_over_png[]; extern const u8 Ctrl_player_none_png[]; extern const u8 ctrl_option_off_png[]; extern const u8 ctrl_option_on_png[]; extern const u8 ctrl_gamecube_png[]; #ifdef HW_RVL extern const u8 ctrl_classic_png[]; extern const u8 ctrl_nunchuk_png[]; extern const u8 ctrl_wiimote_png[]; #endif /* Generic images*/ #ifdef HW_RVL #define Key_A_png Key_A_wii_png #define Key_B_png Key_B_wii_png extern const u8 generic_point_png[]; extern const u8 Key_A_wii_png[]; extern const u8 Key_B_wii_png[]; #else #define Key_A_png Key_A_gcn_png #define Key_B_png Key_B_gcn_png extern const u8 Key_A_gcn_png[]; extern const u8 Key_B_gcn_png[]; #endif /* Generic Sounds */ extern const u8 button_over_pcm[]; extern const u8 button_select_pcm[]; extern const u8 intro_pcm[]; extern const u32 button_select_pcm_size; extern const u32 button_over_pcm_size; extern const u32 intro_pcm_size; /* Generic textures*/ #ifdef HW_RVL extern gx_texture *w_pointer; #endif extern u8 SILENT; extern void GUI_InitMenu(gui_menu *menu); extern void GUI_DeleteMenu(gui_menu *menu); extern void GUI_DrawMenu(gui_menu *menu); extern void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out); extern void GUI_SlideMenuTitle(gui_menu *m, int title_offset); extern int GUI_UpdateMenu(gui_menu *menu); extern int GUI_RunMenu(gui_menu *menu); extern int GUI_OptionWindow(gui_menu *parent, char *title, char *items[], u8 nb_items); extern void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type); extern void GUI_OptionBox2(gui_menu *parent, char *text_1, char *text_2, s16 *option_1, s16 *option_2, s16 step, s16 min, s16 max); extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber); extern void GUI_MsgBoxUpdate(char *title, char *msg); extern void GUI_MsgBoxClose(void); extern void GUI_WaitPrompt(char *title, char *msg); extern int GUI_ConfirmPrompt(char *msg); extern void GUI_FadeOut(); extern void GUI_SetBgColor(GXColor color); extern void GUI_Initialize(void); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/gui/gui.h
C
gpl2
10,990
/**************************************************************************** * menu.c * * Genesis Plus GX menus * * Eke-Eke (2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #include "font.h" #include "gui.h" #include "dvd.h" #include "file_dvd.h" #include "file_fat.h" #include "filesel.h" #define BG_COLOR_MAX 15 /* various background colors */ static GXColor bg_colors[BG_COLOR_MAX]= { {0xd4,0xd0,0xc8,0xff}, /* cream */ {0xcc,0xcc,0xcc,0xff}, /* light grey */ {0x66,0x66,0x66,0xff}, /* faded grey */ {0x50,0x51,0x5b,0xff}, /* grey blue */ {0xb8,0xc7,0xda,0xff}, /* light blue */ {0xc0,0xcf,0xe7,0xff}, /* sky blue */ {0x98,0xb1,0xd8,0xff}, /* sea blue */ {0x7b,0x8c,0xa6,0xff}, /* violet */ {0xa9,0xc7,0xc6,0xff}, /* green blue */ {0x7d,0xa4,0x9f,0xff}, /* darker green blue */ {0x22,0x52,0x74,0xff}, /* dark blue */ {0x33,0x33,0x33,0xff}, /* dark grey */ {0x00,0x00,0x00,0xff}, /* black */ {0xd6,0xcb,0xba,0xff}, /* light gold */ {0xbb,0xb0,0x99,0xff} /* gold */ }; /*****************************************************************************/ /* Generic Buttons data */ /*****************************************************************************/ static butn_data arrow_up_data = { {NULL,NULL}, {Button_up_png,Button_up_over_png} }; static butn_data arrow_down_data = { {NULL,NULL}, {Button_down_png,Button_down_over_png} }; static butn_data button_text_data = { {NULL,NULL}, {Button_text_png,Button_text_over_png} }; static butn_data button_icon_data = { {NULL,NULL}, {Button_icon_png,Button_icon_over_png} }; static butn_data button_icon_sm_data = { {NULL,NULL}, {Button_icon_sm_png,Button_icon_sm_over_png} }; static butn_data button_player_data = { {NULL,NULL}, {Ctrl_player_png,Ctrl_player_over_png} }; static butn_data button_player_none_data = { {NULL,NULL}, {Ctrl_player_none_png,NULL} }; /*****************************************************************************/ /* Generic GUI items */ /*****************************************************************************/ static gui_item action_cancel = { NULL,Key_B_png,"","Back",10,422,28,28 }; static gui_item action_select = { NULL,Key_A_png,"","",602,422,28,28 }; /*****************************************************************************/ /* Generic GUI backgrounds */ /*****************************************************************************/ static gui_image bg_main[4] = { {NULL,Bg_main_png,IMAGE_VISIBLE|IMAGE_FADE,146,80,348,288,255}, {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, {NULL,Banner_main_png,IMAGE_VISIBLE|IMAGE_SLIDE_BOTTOM,0,340,640,140,255}, {NULL,Main_logo_png,IMAGE_VISIBLE|IMAGE_SLIDE_BOTTOM,202,362,232,56,255} }; static gui_image bg_misc[5] = { {NULL,Bg_main_png,IMAGE_VISIBLE|IMAGE_FADE,146,80,348,288,255}, {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, {NULL,Banner_top_png,IMAGE_VISIBLE|IMAGE_SLIDE_TOP,0,0,640,108,255}, {NULL,Banner_bottom_png,IMAGE_VISIBLE|IMAGE_SLIDE_BOTTOM,0,380,640,100,255}, {NULL,Main_logo_png,IMAGE_VISIBLE|IMAGE_SLIDE_TOP,466,40,152,44,255} }; static gui_image bg_ctrls[8] = { {NULL,Bg_main_png,IMAGE_VISIBLE,356,144,348,288,255}, {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, {NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255}, {NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255}, {NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255}, {NULL,Frame_s4_png,IMAGE_VISIBLE,38,72,316,168,128}, {NULL,Frame_s4_png,IMAGE_VISIBLE,38,242,316,168,128}, {NULL,Frame_s3_png,IMAGE_SLIDE_RIGHT,400,134,292,248,128} }; static gui_image bg_list[6] = { {NULL,Bg_main_png,IMAGE_VISIBLE,356,144,348,288,255}, {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, {NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255}, {NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255}, {NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255}, {NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,128} }; /*****************************************************************************/ /* Menu Items description */ /*****************************************************************************/ static gui_item items_main[9] = { {NULL,Main_load_png ,"","",114, 72,80,92}, {NULL,Main_options_png ,"","",290, 76,60,88}, {NULL,Main_quit_png ,"","",460, 80,52,84}, {NULL,Main_file_png ,"","",114,216,80,92}, {NULL,Main_reset_png ,"","",282,224,76,84}, {NULL,Main_ggenie_png ,"","",450,224,72,84}, #ifdef HW_RVL {NULL,Main_play_wii_png,"","", 10,372,84,32}, #else {NULL,Main_play_gcn_png,"","", 10,372,84,32}, #endif {NULL,Main_takeshot_png,"","",546,334,84,32}, {NULL,Main_showinfo_png,"","",546,372,84,32} }; static gui_item items_ctrls[13] = { {NULL,NULL,"","", 0, 0, 0, 0}, {NULL,NULL,"","", 0, 0, 0, 0}, {NULL,NULL,"","",304, 0, 24, 0}, {NULL,NULL,"","",304, 0, 24, 0}, {NULL,NULL,"","",304, 0, 24, 0}, {NULL,NULL,"","",304, 0, 24, 0}, {NULL,NULL,"","",304, 0, 24, 0}, {NULL,NULL,"","",304, 0, 24, 0}, {NULL,NULL,"","",304, 0, 24, 0}, {NULL,NULL,"","",304, 0, 24, 0}, {NULL,NULL,"","", 0, 0, 0, 0}, {NULL,NULL,"","", 0, 0, 0, 0}, {NULL,Ctrl_config_png,"Keys\nConfig","Configure Controller Keys",530,306,32,32} }; #ifdef HW_RVL static gui_item items_load[4] = { {NULL,Load_recent_png,"","Load recent ROM files (USB/SD)" ,276,120,88,96}, {NULL,Load_sd_png ,"","Load ROM files from SDCARD" ,110,266,88,96}, {NULL,Load_usb_png ,"","Load ROM files from USB device" ,276,266,88,96}, {NULL,Load_dvd_png ,"","Load ROM files from DVD" ,442,266,88,96} }; #else static gui_item items_load[3] = { {NULL,Load_recent_png,"","Load recent ROM files (SD)" ,110,198,88,96}, {NULL,Load_sd_png ,"","Load ROM files from SDCARD" ,276,198,88,96}, {NULL,Load_dvd_png ,"","Load ROM files from DVD" ,442,198,88,96} }; #endif static gui_item items_options[5] = { {NULL,Option_system_png,"","System settings", 114,142,80,92}, {NULL,Option_video_png ,"","Video settings", 288,150,64,84}, {NULL,Option_sound_png ,"","Audio settings", 464,154,44,80}, {NULL,Option_ctrl_png ,"","Input settings", 192,286,88,92}, {NULL,Option_menu_png ,"","Menu settings", 370,286,60,92} }; /* Audio options */ static gui_item items_audio[12] = { {NULL,NULL,"High-Quality FM: ON", "Enable/disable YM2612 resampling", 52,132,276,48}, {NULL,NULL,"FM Roll-off: 0.999", "Adjust FIR low-pass filtering", 52,132,276,48}, {NULL,NULL,"FM Resolution: MAX", "Adjust YM2612 DAC precision", 52,132,276,48}, {NULL,NULL,"FM Volume: 1.00", "Adjust YM2612 output level", 52,132,276,48}, {NULL,NULL,"PSG Volume: 2.50", "Adjust SN76489 output level", 52,132,276,48}, {NULL,NULL,"PSG Noise Boost: OFF", "Boost SN76489 Noise Channel", 52,132,276,48}, {NULL,NULL,"Filtering: 3-BAND EQ", "Setup Audio filtering", 52,132,276,48}, {NULL,NULL,"Low Gain: 1.00", "Adjust EQ Low Band Gain", 52,132,276,48}, {NULL,NULL,"Mid Gain: 1.00", "Adjust EQ Mid Band Gain", 52,132,276,48}, {NULL,NULL,"High Gain: 1.00", "Adjust EQ High BandGain", 52,132,276,48}, {NULL,NULL,"Low Freq: 200 Hz", "Adjust EQ Lowest Frequency", 52,132,276,48}, {NULL,NULL,"High Freq: 20000 Hz", "Adjust EQ Highest Frequency", 52,132,276,48} }; /* System options */ static gui_item items_system[7] = { {NULL,NULL,"Console Region: AUTO", "Select system region", 52,132,276,48}, {NULL,NULL,"System Lockups: OFF", "Enable/disable original system lock-ups", 52,132,276,48}, {NULL,NULL,"68k Address Error: ON", "Enable/disable 68k Address Error", 52,132,276,48}, {NULL,NULL,"System BIOS: OFF", "Enable/disable TMSS BIOS support", 52,132,276,48}, {NULL,NULL,"Lock-on: OFF", "Select Lock-On cartridge type", 52,132,276,48}, {NULL,NULL,"Cartridge Swap: OFF", "Enable/disable cartridge hot swap", 52,132,276,48}, {NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 52,132,276,48} }; /* Video options */ #ifdef HW_RVL static gui_item items_video[10] = #else static gui_item items_video[8] = #endif { {NULL,NULL,"Display: PROGRESSIVE", "Select video signal type", 52,132,276,48}, {NULL,NULL,"TV mode: 50/60Hz", "Select video signal frequency", 52,132,276,48}, {NULL,NULL,"GX Bilinear Filter: OFF", "Enable/disable texture hardware filtering", 52,132,276,48}, #ifdef HW_RVL {NULL,NULL,"VI Trap Filter: ON", "Enable/disable video hardware filtering", 52,132,276,48}, {NULL,NULL,"VI Gamma Correction: 1.0","Adjust video hardware gamma correction", 52,132,276,48}, #endif {NULL,NULL,"NTSC Filter: COMPOSITE", "Enable/disable NTSC software filtering", 52,132,276,48}, {NULL,NULL,"Borders: OFF", "Enable/disable overscan emulation", 52,132,276,48}, {NULL,NULL,"Aspect: ORIGINAL (4:3)", "Select display aspect ratio", 52,132,276,48}, {NULL,NULL,"Screen Position (+0,+0)", "Adjust display position", 52,132,276,48}, {NULL,NULL,"Screen Scaling (+0,+0)", "Adjust display scaling", 52,132,276,48} }; /* Menu options */ static gui_item items_prefs[7] = { {NULL,NULL,"Auto SRAM: OFF", "Enable/disable automatic SRAM", 52,132,276,48}, {NULL,NULL,"Auto STATE: OFF", "Enable/disable automatic Savestate", 52,132,276,48}, {NULL,NULL,"SFX Volume: 100", "Adjust sound effects volume", 52,132,276,48}, {NULL,NULL,"BGM Volume: 100", "Adjust background music volume", 52,132,276,48}, {NULL,NULL,"BG Color: DEFAULT", "Change background color", 52,132,276,48}, {NULL,NULL,"Screen Width: 658", "Adjust Screen Width", 52,132,276,48}, {NULL,NULL,"Confirm Box: OFF", "Enable/disable user confirmation", 52,132,276,48} }; /*****************************************************************************/ /* Menu Buttons description */ /*****************************************************************************/ /* Generic Buttons for list menu */ static gui_butn arrow_up = {&arrow_up_data,BUTTON_OVER_SFX,{0,0,0,0},14,76,360,32}; static gui_butn arrow_down = {&arrow_down_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,{0,0,0,0},14,368,360,32}; /* Generic list menu */ static gui_butn buttons_list[4] = { {&button_text_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0},52,132,276,48}, {&button_text_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0},52,188,276,48}, {&button_text_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0},52,244,276,48}, {&button_text_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0},52,300,276,48} }; /* Main menu */ static gui_butn buttons_main[9] = { {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,0,1}, 80, 50,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,1,1},246, 50,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,1,1},412, 50,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX ,{3,0,1,1}, 80,194,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX ,{3,0,1,1},246,194,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX ,{3,0,1,0},412,194,148,132}, {NULL , BUTTON_FADE|BUTTON_OVER_SFX ,{3,0,1,1}, 10,372, 84, 32}, {NULL , BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{2,1,1,1},546,334, 84, 32}, {NULL , BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,0,1,0},546,372, 84, 32} }; /* Controllers Menu */ static gui_butn buttons_ctrls[13] = { {&button_icon_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX ,{0,1,0,2}, 60, 88,148,132}, {&button_icon_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX ,{1,0,0,5}, 60,258,148,132}, {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,1,2,0},250, 79, 84, 32}, {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,3,0},250,117, 84, 32}, {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,4,0},250,155, 84, 32}, {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,5,0},250,193, 84, 32}, {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,5,0},250,249, 84, 32}, {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,6,0},250,287, 84, 32}, {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,7,0},250,325, 84, 32}, {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,0,8,0},250,363, 84, 32}, {&button_icon_sm_data ,BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX ,{0,1,1,0},436,168,160, 52}, {&button_icon_sm_data ,BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX ,{1,1,0,0},436,232,160, 52}, {&button_icon_sm_data ,BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX|BUTTON_SELECT_SFX ,{1,0,0,0},436,296,160, 52} }; /* Load Game menu */ #ifdef HW_RVL static gui_butn buttons_load[4] = { {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,2,0,1},246,102,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,0,1,1}, 80,248,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{2,0,1,1},246,248,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,0,1,0},412,248,148,132} }; #else static gui_butn buttons_load[3] = { {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,0,0,1}, 80,180,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,0,1,1},246,180,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,0,1,0},412,180,148,132} }; #endif /* Options menu */ static gui_butn buttons_options[5] = { {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,0,1}, 80,120,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,1,1},246,120,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,2,1,1},412,120,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,0,1,1},162,264,148,132}, {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_FADE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{2,0,1,0},330,264,148,132} }; /*****************************************************************************/ /* Menu descriptions */ /*****************************************************************************/ /* Main menu */ static gui_menu menu_main = { "", 0,0, 9,9,4,0, items_main, buttons_main, bg_main, {NULL,NULL}, {NULL,NULL} }; /* Main menu */ gui_menu menu_ctrls = { "Controller Settings", 0,0, 13,13,8,0, items_ctrls, buttons_ctrls, bg_ctrls, {&action_cancel, &action_select}, {NULL,NULL} }; /* Load Game menu */ static gui_menu menu_load = { "Load Game", 0,0, #ifdef HW_RVL 4,4,5,0, #else 3,3,5,0, #endif items_load, buttons_load, bg_misc, {&action_cancel, &action_select}, {NULL,NULL} }; /* Options menu */ static gui_menu menu_options = { "Settings", 0,0, 5,5,5,0, items_options, buttons_options, bg_misc, {&action_cancel, &action_select}, {NULL,NULL} }; /* System Options menu */ static gui_menu menu_system = { "System Settings", 0,0, 6,4,6,0, items_system, buttons_list, bg_list, {&action_cancel, &action_select}, {&arrow_up,&arrow_down} }; /* Video Options menu */ static gui_menu menu_video = { "Video Settings", 0,0, 8,4,6,0, items_video, buttons_list, bg_list, {&action_cancel, &action_select}, {&arrow_up,&arrow_down} }; /* Sound Options menu */ static gui_menu menu_audio = { "Audio Settings", 0,0, 8,4,6,0, items_audio, buttons_list, bg_list, {&action_cancel, &action_select}, {&arrow_up,&arrow_down} }; /* Sound Options menu */ static gui_menu menu_prefs = { "Menu Settings", 0,0, 7,4,6,0, items_prefs, buttons_list, bg_list, {&action_cancel, &action_select}, {&arrow_up,&arrow_down} }; /*************************************************************************** * drawmenu (deprecated) * * As it says, simply draws the menu with a highlight on the currently * selected item :) ***************************************************************************/ char menutitle[60] = { "" }; static int menu = 0; static void drawmenu (char items[][25], int maxitems, int selected) { int i; int ypos; ypos = (226 - (fheight * maxitems)) >> 1; ypos += 130; /* reset texture data */ gx_texture *texture; memset(&texture,0,sizeof(gx_texture)); /* draw background items */ gxClearScreen (bg_colors[config.bg_color]); texture= gxTextureOpenPNG(Bg_main_png,0); if (texture) { gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); if (texture->data) free(texture->data); free(texture); } texture= gxTextureOpenPNG(Banner_bottom_png,0); if (texture) { gxDrawTexture(texture, 0, 480-texture->height, texture->width, texture->height, 255); if (texture->data) free(texture->data); free(texture); } texture= gxTextureOpenPNG(Banner_top_png,0); if (texture) { gxDrawTexture(texture, 0, 0, texture->width, texture->height, 255); if (texture->data) free(texture->data); free(texture); } texture= gxTextureOpenPNG(Main_logo_png,0); if (texture) { gxDrawTexture(texture, 444, 28, 176, 48, 255); if (texture->data) free(texture->data); free(texture); } for (i = 0; i < maxitems; i++) { if (i == selected) WriteCentre_HL (i * fheight + ypos, (char *) items[i]); else WriteCentre (i * fheight + ypos, (char *) items[i]); } gxSetScreen(); } static int domenu (char items[][25], int maxitems, u8 fastmove) { int redraw = 1; int quit = 0; short p; int ret = 0; while (quit == 0) { if (redraw) { drawmenu (&items[0], maxitems, menu); redraw = 0; } p = m_input.keys; if (p & PAD_BUTTON_UP) { redraw = 1; menu--; if (menu < 0) menu = maxitems - 1; } else if (p & PAD_BUTTON_DOWN) { redraw = 1; menu++; if (menu == maxitems) menu = 0; } if (p & PAD_BUTTON_A) { quit = 1; ret = menu; } else if (p & PAD_BUTTON_B) { quit = 1; ret = -1; } if (fastmove) { if (p & PAD_BUTTON_RIGHT) { quit = 1; ret = menu; } else if (p & PAD_BUTTON_LEFT) { quit = 1; ret = 0 - 2 - menu; } } } return ret; } /**************************************************************************** * GUI Settings menu * ****************************************************************************/ static void update_screen_w(void) { vmode->viWidth = config.screen_w; vmode->viXOrigin = (VI_MAX_WIDTH_NTSC -config.screen_w)/2; VIDEO_Configure(vmode); VIDEO_Flush(); } static void update_bgm(void) { SetVolumeOgg(((int)config.bgm_volume * 255) / 100); } static void prefmenu () { int ret, quit = 0; gui_menu *m = &menu_prefs; gui_item *items = m->items; if (config.sram_auto == 0) sprintf (items[0].text, "SRAM Auto: FAT"); else if (config.sram_auto == 1) sprintf (items[0].text, "SRAM Auto: MCARD A"); else if (config.sram_auto == 2) sprintf (items[0].text, "SRAM Auto: MCARD B"); else sprintf (items[0].text, "SRAM Auto: OFF"); if (config.state_auto == 0) sprintf (items[1].text, "Savestate Auto: FAT"); else if (config.state_auto == 1) sprintf (items[1].text, "Savestate Auto: MCARD A"); else if (config.state_auto == 2) sprintf (items[1].text, "Savestate Auto: MCARD B"); else sprintf (items[1].text, "Savestate Auto: OFF"); sprintf (items[2].text, "SFX Volume: %1.1f", config.sfx_volume); sprintf (items[3].text, "BGM Volume: %1.1f", config.bgm_volume); if (config.bg_color) sprintf (items[4].text, "BG Color: Type %d", config.bg_color); else sprintf (items[4].text, "BG Color: DEFAULT"); sprintf (items[5].text, "Screen Width: %d", config.screen_w); sprintf (items[6].text, "Confirmation Box: %s",config.ask_confirm ? "ON":"OFF"); GUI_InitMenu(m); GUI_SlideMenuTitle(m,strlen("Menu ")); while (quit == 0) { ret = GUI_RunMenu(m); switch (ret) { case 0: /*** SRAM auto load/save ***/ config.sram_auto ++; if (config.sram_auto > 2) config.sram_auto = -1; if (config.sram_auto == 0) sprintf (items[0].text, "SRAM Auto: FAT"); else if (config.sram_auto == 1) sprintf (items[0].text, "SRAM Auto: MCARD A"); else if (config.sram_auto == 2) sprintf (items[0].text, "SRAM Auto: MCARD B"); else sprintf (items[0].text, "SRAM Auto: OFF"); break; case 1: /*** Savestate auto load/save ***/ config.state_auto ++; if (config.state_auto > 2) config.state_auto = -1; if (config.state_auto == 0) sprintf (items[1].text, "Savestate Auto: FAT"); else if (config.state_auto == 1) sprintf (items[1].text, "Savestate Auto: MCARD A"); else if (config.state_auto == 2) sprintf (items[1].text, "Savestate Auto: MCARD B"); else sprintf (items[1].text, "Savestate Auto: OFF"); break; case 2: /*** Sound effects volume ***/ GUI_OptionBox(m,0,"SFX Volume",(void *)&config.sfx_volume,10.0,0.0,100.0,0); sprintf (items[2].text, "SFX Volume: %1.1f", config.sfx_volume); break; case 3: /*** Background music volume ***/ GUI_OptionBox(m,update_bgm,"BGM Volume",(void *)&config.bgm_volume,10.0,0.0,100.0,0); sprintf (items[3].text, "BGM Volume: %1.1f", config.bgm_volume); break; case 4: /*** Background color ***/ if (ret < 0) config.bg_color --; else config.bg_color ++; if (config.bg_color < 0) config.bg_color = BG_COLOR_MAX - 1; else if (config.bg_color >= BG_COLOR_MAX) config.bg_color = 0; if (config.bg_color) sprintf (items[4].text, "BG Color: Type %d", config.bg_color); else sprintf (items[4].text, "BG Color: DEFAULT"); GUI_SetBgColor(bg_colors[config.bg_color]); break; case 5: GUI_OptionBox(m,update_screen_w,"Screen Width",(void *)&config.screen_w,2,640,VI_MAX_WIDTH_NTSC,1); sprintf (items[5].text, "Screen Width: %d", config.screen_w); break; case 6: config.ask_confirm ^= 1; sprintf (items[6].text, "Confirmation Box: %s",config.ask_confirm ? "ON":"OFF"); break; case -1: quit = 1; break; } } GUI_DeleteMenu(m); } /**************************************************************************** * Audio Settings menu * ****************************************************************************/ static int update_snd_items(void) { gui_menu *m = &menu_audio; gui_item *items = m->items; int offset; float fm_volume = (float)config.fm_preamp/100.0; float psg_volume = (float)config.psg_preamp/100.0; if (config.hq_fm) { sprintf (items[0].text, "High-Quality FM: ON"); sprintf (items[1].text, "FM Roll-off: %1.3f",config.rolloff); strcpy (items[1].comment, "Adjust FIR low-pass filtering"); offset = 2; } else { sprintf (items[0].text, "High-Quality FM: OFF"); offset = 1; } strcpy(items[offset].comment, "Adjust YM2612 DAC precision"); strcpy(items[offset+1].comment, "Adjust YM2612 output level"); strcpy(items[offset+2].comment, "Adjust SN76489 output level"); strcpy(items[offset+3].comment, "Boost SN76489 Noise Channel"); strcpy(items[offset+4].comment, "Configure Audio filtering"); if (config.dac_bits < 14) sprintf (items[offset].text, "FM Resolution: %d bits", config.dac_bits); else sprintf (items[offset].text, "FM Resolution: MAX"); sprintf (items[offset+1].text, "FM Volume: %1.2f", fm_volume); sprintf (items[offset+2].text, "PSG Volume: %1.2f", psg_volume); sprintf (items[offset+3].text, "PSG Noise Boost: %s", config.psgBoostNoise ? "ON":"OFF"); if (config.filter == 2) { sprintf (items[offset+4].text, "Filtering: 3-BAND EQ"); sprintf (items[offset+5].text, "Low Gain: %1.2f", config.lg); sprintf (items[offset+6].text, "Middle Gain: %1.2f", config.mg); sprintf (items[offset+7].text, "High Gain: %1.2f", config.hg); sprintf (items[offset+8].text, "Low Freq: %d", config.low_freq); sprintf (items[offset+9].text, "High Freq: %d", config.high_freq); strcpy (items[offset+5].comment, "Adjust EQ Low Band Gain"); strcpy (items[offset+6].comment, "Adjust EQ Mid Band Gain"); strcpy (items[offset+7].comment, "Adjust EQ High Band Gain"); strcpy (items[offset+8].comment, "Adjust EQ Lowest Frequency"); strcpy (items[offset+9].comment, "Adjust EQ Highest Frequency"); m->max_items = offset + 10; } else if (config.filter == 1) { sprintf (items[offset+4].text, "Filtering: LOW-PASS"); sprintf (items[offset+5].text, "Low-Pass Rate: %d %%", config.lp_range); strcpy (items[offset+5].comment, "Adjust Low Pass filter"); m->max_items = offset + 6; } else { sprintf (items[offset+4].text, "Filtering: OFF"); m->max_items = offset + 5; } sprintf (items[offset+6].text, "Middle Gain: %1.2f", config.mg); sprintf (items[offset+7].text, "High Gain: %1.2f", config.hg); sprintf (items[offset+8].text, "Low Freq: %d", config.low_freq); sprintf (items[offset+9].text, "High Freq: %d", config.high_freq); strcpy (items[offset+5].comment, "Adjust EQ Low Band Gain"); strcpy (items[offset+6].comment, "Adjust EQ Mid Band Gain"); strcpy (items[offset+7].comment, "Adjust EQ High Band Gain"); strcpy (items[offset+8].comment, "Adjust EQ Lowest Frequency"); strcpy (items[offset+9].comment, "Adjust EQ Highest Frequency"); return offset; } static void soundmenu () { int ret, quit = 0; u8 *temp; gui_menu *m = &menu_audio; gui_item *items = m->items; float fm_volume = (float)config.fm_preamp/100.0; float psg_volume = (float)config.psg_preamp/100.0; int offset = update_snd_items(); GUI_InitMenu(m); GUI_SlideMenuTitle(m,strlen("Audio ")); while (quit == 0) { ret = GUI_RunMenu(m); /* special case */ if (config.hq_fm) { if (ret == 1) { GUI_OptionBox(m,0,"FM Roll-off",(void *)&config.rolloff,0.001,0.800,1.000,0); sprintf (items[1].text, "FM Roll-off: %1.3f",config.rolloff); ret = 255; if (cart.romsize) { /* save YM2612 context */ temp = memalign(32,YM2612GetContextSize()); if (temp) { /* save YM2612 context */ memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize()); /* reinitialize audio timings */ audio_init(snd.sample_rate,snd.frame_rate); sound_init(); /* restore YM2612 context */ YM2612Restore(temp); free(temp); } } } else if (ret > 1) { ret--; } } switch (ret) { case 0: config.hq_fm ^= 1; offset = update_snd_items(); if (cart.romsize) { /* save YM2612 context */ temp = memalign(32,YM2612GetContextSize()); if (temp) { memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize()); } /* reinitialize audio timings */ audio_init(snd.sample_rate,snd.frame_rate); sound_init(); /* restore YM2612 context */ if (temp) { YM2612Restore(temp); free(temp); } } break; case 1: config.dac_bits++; if (config.dac_bits > 14) config.dac_bits = 7; if (config.dac_bits < 14) sprintf (items[offset].text, "FM Resolution: %d bits", config.dac_bits); else sprintf (items[offset].text, "FM Resolution: MAX"); if (cart.romsize) { /* save YM2612 context */ temp = memalign(32,YM2612GetContextSize()); if (temp) { memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize()); } /* reinitialize audio timings */ audio_init(snd.sample_rate,snd.frame_rate); sound_init(); /* restore YM2612 context */ if (temp) { YM2612Restore(temp); free(temp); } } break; case 2: GUI_OptionBox(m,0,"FM Volume",(void *)&fm_volume,0.01,0.0,5.0,0); sprintf (items[offset+1].text, "FM Volume: %1.2f", fm_volume); config.fm_preamp = (int)(fm_volume * 100.0); break; case 3: GUI_OptionBox(m,0,"PSG Volume",(void *)&psg_volume,0.01,0.0,5.0,0); sprintf (items[offset+2].text, "PSG Volume: %1.2f", psg_volume); config.psg_preamp = (int)(psg_volume * 100.0); break; case 4: config.psgBoostNoise ^= 1; sprintf (items[offset+3].text, "PSG Noise Boost: %s", config.psgBoostNoise ? "ON":"OFF"); SN76489_BoostNoise(config.psgBoostNoise); break; case 5: config.filter = (config.filter + 1) % 3; if (config.filter == 2) { sprintf (items[offset+4].text, "Filtering: 3-BAND EQ"); sprintf (items[offset+5].text, "Low Gain: %1.2f", config.lg); strcpy (items[offset+5].comment, "Adjust EQ Low Band Gain"); m->max_items = offset + 10; audio_set_equalizer(); } else if (config.filter == 1) { sprintf (items[offset+4].text, "Filtering: LOW-PASS"); sprintf (items[offset+5].text, "Low-Pass Rate: %d %%", config.lp_range); strcpy (items[offset+5].comment, "Adjust Low Pass filter"); m->max_items = offset + 6; } else { sprintf (items[offset+4].text, "Filtering: OFF"); m->max_items = offset + 5; } while ((m->offset + 4) > m->max_items) { m->offset --; m->selected++; } break; case 6: if (config.filter == 1) { GUI_OptionBox(m,0,"Low-Pass Rate",(void *)&config.lp_range,1,0,100,1); sprintf (items[offset+5].text, "Low-Pass Rate: %d %%", config.lp_range); } else { GUI_OptionBox(m,0,"Low Gain",(void *)&config.lg,0.01,0.0,2.0,0); sprintf (items[offset+5].text, "Low Gain: %1.2f", config.lg); audio_set_equalizer(); } break; case 7: GUI_OptionBox(m,0,"Middle Gain",(void *)&config.mg,0.01,0.0,2.0,0); sprintf (items[offset+6].text, "Middle Gain: %1.2f", config.mg); audio_set_equalizer(); break; case 8: GUI_OptionBox(m,0,"High Gain",(void *)&config.hg,0.01,0.0,2.0,0); sprintf (items[offset+7].text, "High Gain: %1.2f", config.hg); audio_set_equalizer(); break; case 9: GUI_OptionBox(m,0,"Low Frequency",(void *)&config.low_freq,10,0,config.high_freq,1); sprintf (items[offset+8].text, "Low Freq: %d", config.low_freq); audio_set_equalizer(); break; case 10: GUI_OptionBox(m,0,"High Frequency",(void *)&config.high_freq,100,config.low_freq,30000,1); sprintf (items[offset+9].text, "High Freq: %d", config.high_freq); audio_set_equalizer(); break; case -1: quit = 1; break; } } GUI_DeleteMenu(m); } /**************************************************************************** * System Settings menu * ****************************************************************************/ static void systemmenu () { int ret, quit = 0; float framerate; u8 *temp; gui_menu *m = &menu_system; gui_item *items = m->items; if (config.region_detect == 0) sprintf (items[0].text, "Console Region: AUTO"); else if (config.region_detect == 1) sprintf (items[0].text, "Console Region: USA"); else if (config.region_detect == 2) sprintf (items[0].text, "Console Region: EUR"); else if (config.region_detect == 3) sprintf (items[0].text, "Console Region: JAP"); sprintf (items[1].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); sprintf (items[2].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); sprintf (items[3].text, "System BIOS: %s", (config.bios_enabled & 1) ? "ON":"OFF"); if (config.lock_on == TYPE_GG) sprintf (items[4].text, "Lock-On: GAME GENIE"); else if (config.lock_on == TYPE_AR) sprintf (items[4].text, "Lock-On: ACTION REPLAY"); else if (config.lock_on == TYPE_SK) sprintf (items[4].text, "Lock-On: SONIC & KNUCKLES"); else sprintf (items[4].text, "Lock-On: OFF"); sprintf (items[5].text, "Cartridge Swap: %s", config.hot_swap ? "ON":"OFF"); if (svp) { sprintf (items[6].text, "SVP Cycles: %d", SVP_cycles); m->max_items = 7; } else { m->max_items = 6; } GUI_InitMenu(m); GUI_SlideMenuTitle(m,strlen("System ")); while (quit == 0) { ret = GUI_RunMenu(m); switch (ret) { case 0: /*** Region Force ***/ config.region_detect = (config.region_detect + 1) % 4; if (config.region_detect == 0) sprintf (items[0].text, "Console Region: AUTO"); else if (config.region_detect == 1) sprintf (items[0].text, "Console Region: USA"); else if (config.region_detect == 2) sprintf (items[0].text, "Console Region: EUR"); else if (config.region_detect == 3) sprintf (items[0].text, "Console Region: JAP"); if (cart.romsize) { /* force region & cpu mode */ set_region(); /* update framerate */ if (vdp_pal) framerate = 50.0; else framerate = ((config.tv_mode == 0) || (config.tv_mode == 2)) ? (1000000.0/16715.0) : 60.0; /* save YM2612 context */ temp = memalign(32,YM2612GetContextSize()); if (temp) memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize()); /* reinitialize all timings */ audio_init(snd.sample_rate, framerate); system_init(); /* restore SRAM */ memfile_autoload(config.sram_auto,-1); /* restore YM2612 context */ if (temp) { YM2612Restore(temp); free(temp); } /* reinitialize HVC tables */ vctab = vdp_pal ? ((reg[1] & 8) ? vc_pal_240 : vc_pal_224) : vc_ntsc_224; hctab = (reg[12] & 1) ? cycle2hc40 : cycle2hc32; /* reinitialize overscan area */ bitmap.viewport.x = config.overscan ? 14 : 0; bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0; } break; case 1: /*** force DTACK ***/ config.force_dtack ^= 1; sprintf (items[1].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); break; case 2: /*** 68k Address Error ***/ config.addr_error ^= 1; cart_hw_init (); sprintf (items[2].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); break; case 3: /*** BIOS support ***/ config.bios_enabled ^= 1; sprintf (items[3].text, "System BIOS: %s", (config.bios_enabled & 1) ? "ON":"OFF"); if (cart.romsize) { system_init(); system_reset(); memfile_autoload(config.sram_auto,-1); } break; case 4: /*** Cart Lock-On ***/ config.lock_on++; if (config.lock_on > TYPE_SK) config.lock_on = 0; if (config.lock_on == TYPE_GG) sprintf (items[4].text, "Lock-On: GAME GENIE"); else if (config.lock_on == TYPE_AR) sprintf (items[4].text, "Lock-On: ACTION REPLAY"); else if (config.lock_on == TYPE_SK) sprintf (items[4].text, "Lock-On: SONIC & KNUCKLES"); else sprintf (items[4].text, "Lock-On: OFF"); if (cart.romsize) { system_reset(); /* clear any patches first */ system_init(); system_reset(); memfile_autoload(config.sram_auto,-1); } break; case 5: /*** Cartridge Hot Swap ***/ config.hot_swap ^= 1; sprintf (items[5].text, "Cartridge Swap: %s", config.hot_swap ? "ON":"OFF"); break; case 6: /*** SVP cycles per line ***/ GUI_OptionBox(m,0,"SVP Cycles",(void *)&SVP_cycles,1,1,1500,1); sprintf (items[6].text, "SVP Cycles: %d", SVP_cycles); break; case -1: quit = 1; break; } } GUI_DeleteMenu(m); } /**************************************************************************** * Video Settings menu * ****************************************************************************/ #ifdef HW_RVL #define VI_OFFSET 5 static void update_gamma(void) { VIDEO_SetGamma((int)(config.gamma * 10.0)); VIDEO_Flush(); } #else #define VI_OFFSET 3 #endif static void videomenu () { u16 state[2]; int ret, quit = 0; float framerate; u8 *temp; gui_menu *m = &menu_video; gui_item *items = m->items; if (config.render == 1) sprintf (items[0].text,"Display: INTERLACED"); else if (config.render == 2) sprintf (items[0].text, "Display: PROGRESSIVE"); else sprintf (items[0].text, "Display: ORIGINAL"); if (config.tv_mode == 0) sprintf (items[1].text, "TV Mode: 60HZ"); else if (config.tv_mode == 1) sprintf (items[1].text, "TV Mode: 50HZ"); else sprintf (items[1].text, "TV Mode: 50/60HZ"); sprintf (items[2].text, "GX Bilinear Filter: %s", config.bilinear ? " ON" : "OFF"); #ifdef HW_RVL sprintf (items[3].text, "VI Trap Filter: %s", config.trap ? " ON" : "OFF"); sprintf (items[4].text, "VI Gamma Correction: %1.1f", config.gamma); #endif if (config.ntsc == 1) sprintf (items[VI_OFFSET].text, "NTSC Filter: COMPOSITE"); else if (config.ntsc == 2) sprintf (items[VI_OFFSET].text, "NTSC Filter: S-VIDEO"); else if (config.ntsc == 3) sprintf (items[VI_OFFSET].text, "NTSC Filter: RGB"); else sprintf (items[VI_OFFSET].text, "NTSC Filter: OFF"); sprintf (items[VI_OFFSET+1].text, "Borders: %s", config.overscan ? "ON" : "OFF"); if (config.aspect == 1) sprintf (items[VI_OFFSET+2].text,"Aspect: ORIGINAL (4:3)"); else if (config.aspect == 2) sprintf (items[VI_OFFSET+2].text, "Aspect: ORIGINAL (16:9)"); else sprintf (items[VI_OFFSET+2].text, "Aspect: MANUAL SCALE"); sprintf (items[VI_OFFSET+3].text, "Screen Position: (%s%02d,%s%02d)", (config.xshift < 0) ? "":"+", config.xshift, (config.yshift < 0) ? "":"+", config.yshift); sprintf (items[VI_OFFSET+4].text, "Screen Scaling: (%s%02d,%s%02d)", (config.xscale < 0) ? "":"+", config.xscale, (config.yscale < 0) ? "":"+", config.yscale); if (config.aspect) m->max_items = VI_OFFSET+4; else m->max_items = VI_OFFSET+5; GUI_InitMenu(m); GUI_SlideMenuTitle(m,strlen("Video ")); while (quit == 0) { ret = GUI_RunMenu(m); switch (ret) { case 0: /*** rendering ***/ config.render = (config.render + 1) % 3; if (config.render == 2) { if (VIDEO_HaveComponentCable()) { /* progressive mode (60hz only) */ config.tv_mode = 0; sprintf (items[1].text, "TV Mode: 60HZ"); } else { /* do nothing if component cable is not detected */ config.render = 0; } } if (config.render == 1) sprintf (items[0].text,"Display: INTERLACED"); else if (config.render == 2) sprintf (items[0].text, "Display: PROGRESSIVE"); else sprintf (items[0].text, "Display: ORIGINAL"); break; case 1: /*** tv mode ***/ if (config.render != 2) { config.tv_mode = (config.tv_mode + 1) % 3; /* update framerate */ if (vdp_pal) framerate = 50.0; else framerate = ((config.tv_mode == 0) || (config.tv_mode == 2)) ? (1000000.0/16715.0) : 60.0; /* save YM2612 context */ temp = memalign(32,YM2612GetContextSize()); if (temp) memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize()); /* reinitialize audio timings */ audio_init(snd.sample_rate, framerate); sound_init(); /* restore YM2612 context */ if (temp) { YM2612Restore(temp); free(temp); } if (config.tv_mode == 0) sprintf (items[1].text, "TV Mode: 60HZ"); else if (config.tv_mode == 1) sprintf (items[1].text, "TV Mode: 50HZ"); else sprintf (items[1].text, "TV Mode: 50/60HZ"); } else { GUI_WaitPrompt("Error","Progressive Mode is 60hz only !\n"); } break; case 2: /*** GX Texture filtering ***/ config.bilinear ^= 1; sprintf (items[2].text, "GX Bilinear Filter: %s", config.bilinear ? " ON" : "OFF"); break; #ifdef HW_RVL case 3: /*** VIDEO Trap filtering ***/ config.trap ^= 1; sprintf (items[3].text, "VI Trap Filter: %s", config.trap ? " ON" : "OFF"); break; case 4: /*** VIDEO Gamma correction ***/ if (cart.romsize) { update_gamma(); state[0] = m->arrows[0]->state; state[1] = m->arrows[1]->state; m->max_buttons = 0; m->max_images = 0; m->arrows[0]->state = 0; m->arrows[1]->state = 0; m->screenshot = 255; strcpy(m->title,""); GUI_OptionBox(m,update_gamma,"VI Gamma Correction",(void *)&config.gamma,0.1,0.1,3.0,0); m->max_buttons = 4; m->max_images = 6; m->arrows[0]->state = state[0]; m->arrows[1]->state = state[1]; m->screenshot = 0; strcpy(m->title,"Video Settings"); sprintf (items[4].text, "VI Gamma Correction: %1.1f", config.gamma); VIDEO_SetGamma(VI_GM_1_0); VIDEO_Flush(); } else { GUI_WaitPrompt("Error","Please load a game first !\n"); } break; #endif case VI_OFFSET: /*** NTSC filter ***/ config.ntsc = (config.ntsc + 1) % 4; if (config.ntsc == 1) sprintf (items[VI_OFFSET].text, "NTSC Filter: COMPOSITE"); else if (config.ntsc == 2) sprintf (items[VI_OFFSET].text, "NTSC Filter: S-VIDEO"); else if (config.ntsc == 3) sprintf (items[VI_OFFSET].text, "NTSC Filter: RGB"); else sprintf (items[VI_OFFSET].text, "NTSC Filter: OFF"); break; case VI_OFFSET+1: /*** overscan emulation ***/ config.overscan ^= 1; sprintf (items[VI_OFFSET+1].text, "Borders: %s", config.overscan ? "ON" : "OFF"); break; case VI_OFFSET+2: /*** aspect ratio ***/ config.aspect = (config.aspect + 1) % 3; if (config.aspect == 1) sprintf (items[VI_OFFSET+2].text,"Aspect: ORIGINAL (4:3)"); else if (config.aspect == 2) sprintf (items[VI_OFFSET+2].text, "Aspect: ORIGINAL (16:9)"); else sprintf (items[VI_OFFSET+2].text, "Aspect: MANUAL SCALE"); if (config.aspect) { /* disable items */ m->max_items = VI_OFFSET+4; /* reset menu selection */ if (m->offset > VI_OFFSET) { m->offset = VI_OFFSET; m->selected = 2; } } else { /* enable items */ m->max_items = VI_OFFSET+5; } break; case VI_OFFSET+3: /*** screen position ***/ if (cart.romsize) { state[0] = m->arrows[0]->state; state[1] = m->arrows[1]->state; m->max_buttons = 0; m->max_images = 0; m->arrows[0]->state = 0; m->arrows[1]->state = 0; m->screenshot = 255; strcpy(m->title,""); GUI_OptionBox2(m,"X Offset","Y Offset",&config.xshift,&config.yshift,1,-99,99); m->max_buttons = 4; m->max_images = 6; m->arrows[0]->state = state[0]; m->arrows[1]->state = state[1]; m->screenshot = 0; strcpy(m->title,"Video Settings"); sprintf (items[VI_OFFSET+3].text, "Screen Position: (%s%02d,%s%02d)", (config.xshift < 0) ? "":"+", config.xshift, (config.yshift < 0) ? "":"+", config.yshift); } else { GUI_WaitPrompt("Error","Please load a game first !\n"); } break; case VI_OFFSET+4: /*** screen scaling ***/ if (cart.romsize) { state[0] = m->arrows[0]->state; state[1] = m->arrows[1]->state; m->max_buttons = 0; m->max_images = 0; m->arrows[0]->state = 0; m->arrows[1]->state = 0; m->screenshot = 255; strcpy(m->title,""); GUI_OptionBox2(m,"X Scale","Y Scale",&config.xscale,&config.yscale,1,-99,99); m->max_buttons = 4; m->max_images = 6; m->arrows[0]->state = state[0]; m->arrows[1]->state = state[1]; m->screenshot = 0; strcpy(m->title,"Video Settings"); sprintf (items[VI_OFFSET+4].text, "Screen Scaling: (%s%02d,%s%02d)", (config.xscale < 0) ? "":"+", config.xscale, (config.yscale < 0) ? "":"+", config.yscale); } else { GUI_WaitPrompt("Error","Please load a game first !\n"); } break; case -1: quit = 1; break; } } GUI_DeleteMenu(m); } /**************************************************************************** * Controllers Settings menu ****************************************************************************/ /* Set menu elements depending on current system configuration */ static void ctrlmenu_raz(void) { int i,max = 0; gui_menu *m = &menu_ctrls; /* update players buttons */ for (i=0; i<MAX_DEVICES; i++) { if (input.dev[i] == NO_DEVICE) { m->buttons[i+2].data = &button_player_none_data; m->buttons[i+2].state &= ~BUTTON_ACTIVE; strcpy(m->items[i+2].text,""); strcpy(m->items[i+2].comment,""); } else { m->buttons[i+2].data = &button_player_data; m->buttons[i+2].state |= BUTTON_ACTIVE; sprintf(m->items[i+2].text,"%d",max + 1); if (cart.hw.jcart && (i > 4)) sprintf(m->items[i+2].comment,"Configure Player %d (J-CART) settings", max + 1); else sprintf(m->items[i+2].comment,"Configure Player %d settings", max + 1); max++; } } /* update buttons navigation */ if (input.dev[0] != NO_DEVICE) m->buttons[0].shift[3] = 2; else if (input.dev[4] != NO_DEVICE) m->buttons[0].shift[3] = 6; else m->buttons[0].shift[3] = 0; if (input.dev[4] != NO_DEVICE) m->buttons[1].shift[3] = 5; else if (input.dev[0] != NO_DEVICE) m->buttons[1].shift[3] = 1; else m->buttons[1].shift[3] = 0; if (input.dev[1] != NO_DEVICE) m->buttons[2].shift[1] = 1; else if (input.dev[4] != NO_DEVICE) m->buttons[2].shift[1] = 4; else m->buttons[2].shift[1] = 0; if (input.dev[3] != NO_DEVICE) m->buttons[6].shift[0] = 1; else if (input.dev[0] != NO_DEVICE) m->buttons[6].shift[0] = 4; else m->buttons[6].shift[0] = 0; if (input.dev[4] != NO_DEVICE) m->buttons[5].shift[1] = 1; else m->buttons[5].shift[1] = 0; if (input.dev[5] != NO_DEVICE) { m->buttons[6].shift[1] = 1; if (input.dev[6] != NO_DEVICE) { m->buttons[7].shift[1] = 1; if (input.dev[7] != NO_DEVICE) m->buttons[8].shift[1] = 1; else m->buttons[8].shift[1] = 0; } else { m->buttons[7].shift[1] = 0; } } else { m->buttons[6].shift[1] = 0; } } static void ctrlmenu(void) { int player = 0; int old_player = -1; int i = 0; int update = 0; gui_item *items = NULL; u8 *special = NULL; char msg[16]; u32 exp; /* System devices */ gui_item items_sys[2][7] = { { {NULL,Ctrl_none_png ,"","Select Port 1 device",110,130,48,72}, {NULL,Ctrl_gamepad_png ,"","Select Port 1 device", 87,117,96,84}, {NULL,Ctrl_mouse_png ,"","Select Port 1 device", 97,113,64,88}, {NULL,Ctrl_menacer_png ,"","Select Port 1 device", 94,113,80,88}, {NULL,Ctrl_justifiers_png ,"","Select Port 1 device", 88,117,80,84}, {NULL,Ctrl_teamplayer_png ,"","Select Port 1 device", 94,109,80,92}, {NULL,Ctrl_4wayplay_png ,"","Select Port 1 device", 98,110,72,92} }, { {NULL,Ctrl_none_png ,"","Select Port 2 device",110,300,48,72}, {NULL,Ctrl_gamepad_png ,"","Select Port 2 device", 87,287,96,84}, {NULL,Ctrl_mouse_png ,"","Select Port 2 device", 97,283,64,88}, {NULL,Ctrl_menacer_png ,"","Select Port 2 device", 94,283,80,88}, {NULL,Ctrl_justifiers_png ,"","Select Port 2 device", 88,287,80,84}, {NULL,Ctrl_teamplayer_png ,"","Select Port 2 device", 94,279,80,92}, {NULL,Ctrl_4wayplay_png ,"","Select Port 2 device", 98,280,72,92} } }; /* Player Configuration special items */ gui_item items_special[3][2] = { { /* Gamepad options */ {NULL,Ctrl_pad3b_png,"Pad\nType","Use 3-buttons Pad",528,180,44,28}, {NULL,Ctrl_pad6b_png,"Pad\nType","Use 6-buttons Pad",528,180,44,28} }, { /* Mouse options */ {NULL,ctrl_option_off_png,"Invert\nMouse","Enable/Disable Mouse Y-Axis inversion",534,180,24,24}, {NULL,ctrl_option_on_png ,"Invert\nMouse","Enable/Disable Mouse Y-Axis inversion",534,180,24,24}, }, { /* Gun options */ {NULL,ctrl_option_off_png,"Show\nCursor","Enable/Disable Lightgun cursor",534,180,24,24}, {NULL,ctrl_option_on_png ,"Show\nCursor","Enable/Disable Lightgun cursor",534,180,24,24}, } }; /* Player Configuration device items */ #ifdef HW_RVL gui_item items_device[5] = { {NULL,ctrl_option_off_png ,"Input\nDevice","Select Input Controller",534,244,24,24}, {NULL,ctrl_gamecube_png ,"Input\nDevice","Select Input Controller",530,246,36,24}, {NULL,ctrl_wiimote_png ,"Input\nDevice","Select Input Controller",526,250,40,12}, {NULL,ctrl_nunchuk_png ,"Input\nDevice","Select Input Controller",532,242,32,32}, {NULL,ctrl_classic_png ,"Input\nDevice","Select Input Controller",526,242,40,32}, }; #else gui_item items_device[2] = { {NULL,ctrl_option_off_png ,"Input\nDevice","Select Input Controller",534,244,24,24}, {NULL,ctrl_gamecube_png ,"Input\nDevice","Select Input Controller",530,246,36,24} }; #endif /* initialize menu */ gui_menu *m = &menu_ctrls; GUI_InitMenu(m); /* initialize custom buttons */ button_player_data.texture[0] = gxTextureOpenPNG(button_player_data.image[0],0); button_player_data.texture[1] = gxTextureOpenPNG(button_player_data.image[1],0); button_player_none_data.texture[0] = gxTextureOpenPNG(button_player_none_data.image[0],0); /* initialize custom images */ items_sys[1][0].texture = items_sys[0][0].texture = gxTextureOpenPNG(items_sys[0][0].data,0); items_sys[1][1].texture = items_sys[0][1].texture = gxTextureOpenPNG(items_sys[0][1].data,0); items_sys[1][2].texture = items_sys[0][2].texture = gxTextureOpenPNG(items_sys[0][2].data,0); items_sys[1][3].texture = items_sys[0][3].texture = gxTextureOpenPNG(items_sys[0][3].data,0); items_sys[1][4].texture = items_sys[0][4].texture = gxTextureOpenPNG(items_sys[0][4].data,0); items_sys[1][5].texture = items_sys[0][5].texture = gxTextureOpenPNG(items_sys[0][5].data,0); items_sys[1][6].texture = items_sys[0][6].texture = gxTextureOpenPNG(items_sys[0][6].data,0); items_special[0][0].texture = gxTextureOpenPNG(items_special[0][0].data,0); items_special[0][1].texture = gxTextureOpenPNG(items_special[0][1].data,0); items_special[2][0].texture = items_special[1][0].texture = gxTextureOpenPNG(items_special[1][0].data,0); items_special[2][1].texture = items_special[1][1].texture = gxTextureOpenPNG(items_special[1][1].data,0); items_device[0].texture = items_special[1][0].texture; items_device[1].texture = gxTextureOpenPNG(items_device[1].data,0); #ifdef HW_RVL items_device[2].texture = gxTextureOpenPNG(items_device[2].data,0); items_device[3].texture = gxTextureOpenPNG(items_device[3].data,0); items_device[4].texture = gxTextureOpenPNG(items_device[4].data,0); #endif /* restore current menu elements */ ctrlmenu_raz(); memcpy(&m->items[0],&items_sys[0][input.system[0]],sizeof(gui_item)); memcpy(&m->items[1],&items_sys[1][input.system[1]],sizeof(gui_item)); /* menu title slide effect */ m->selected = 0; GUI_SlideMenuTitle(m,strlen("Controller ")); while (update != -1) { /* draw menu */ GUI_DrawMenu(m); /* draw device port number */ if (m->bg_images[7].state & IMAGE_VISIBLE) { if (config.input[player].device != -1) { sprintf(msg,"%d",config.input[player].port + 1); if (m->selected == 11) FONT_write(msg,16,m->items[11].x+m->items[11].w+4,m->items[11].y+m->items[11].h+4,640,(GXColor)DARK_GREY); else FONT_write(msg,14,m->items[11].x+m->items[11].w,m->items[11].y+m->items[11].h,640,(GXColor)DARK_GREY); } } /* update menu */ update = GUI_UpdateMenu(m); if (update > 0) { switch (m->selected) { case 0: /* update port 1 system */ if (cart.hw.jcart) break; if (input.system[0] == SYSTEM_MOUSE) input.system[0] +=3; /* lightguns are never used on Port 1 */ else input.system[0]++; if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE)) input.system[0] +=3; if (input.system[0] == SYSTEM_WAYPLAY) input.system[1] = SYSTEM_WAYPLAY; if (input.system[0] > SYSTEM_WAYPLAY) { input.system[0] = NO_SYSTEM; input.system[1] = SYSTEM_GAMEPAD; } old_system[0] = -1; old_system[1] = -1; io_init(); io_reset(); old_system[0] = input.system[0]; old_system[1] = input.system[1]; /* update menu elements */ ctrlmenu_raz(); memcpy(&m->items[0],&items_sys[0][input.system[0]],sizeof(gui_item)); memcpy(&m->items[1],&items_sys[1][input.system[1]],sizeof(gui_item)); if (m->bg_images[7].state & IMAGE_VISIBLE) { /* slide out configuration window */ GUI_DrawMenuFX(m, 20, 1); /* remove configuration window */ m->bg_images[7].state &= ~IMAGE_VISIBLE; /* disable configuration buttons */ m->buttons[10].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); m->buttons[11].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); m->buttons[12].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); /* update directions */ m->buttons[2].shift[3] = 0; m->buttons[3].shift[3] = 0; m->buttons[4].shift[3] = 0; m->buttons[5].shift[3] = 0; m->buttons[6].shift[3] = 0; m->buttons[7].shift[3] = 0; m->buttons[8].shift[3] = 0; m->buttons[9].shift[3] = 0; /* update title */ sprintf(m->title,"Controller Settings"); } break; case 1: /* update port 2 system */ if (cart.hw.jcart) break; input.system[1] ++; if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE)) input.system[1] ++; if (input.system[1] == SYSTEM_WAYPLAY) input.system[0] = SYSTEM_WAYPLAY; if (input.system[1] > SYSTEM_WAYPLAY) { input.system[1] = NO_SYSTEM; input.system[0] = SYSTEM_GAMEPAD; } old_system[0] = -1; old_system[1] = -1; io_init(); io_reset(); old_system[0] = input.system[0]; old_system[1] = input.system[1]; /* update menu elements */ ctrlmenu_raz(); memcpy(&m->items[0],&items_sys[0][input.system[0]],sizeof(gui_item)); memcpy(&m->items[1],&items_sys[1][input.system[1]],sizeof(gui_item)); if (m->bg_images[7].state & IMAGE_VISIBLE) { /* slide out configuration window */ GUI_DrawMenuFX(m, 20, 1); /* remove configuration window */ m->bg_images[7].state &= ~IMAGE_VISIBLE; /* disable configuration buttons */ m->buttons[10].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); m->buttons[11].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); m->buttons[12].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); /* update directions */ m->buttons[2].shift[3] = 0; m->buttons[3].shift[3] = 0; m->buttons[4].shift[3] = 0; m->buttons[5].shift[3] = 0; m->buttons[6].shift[3] = 0; m->buttons[7].shift[3] = 0; m->buttons[8].shift[3] = 0; m->buttons[9].shift[3] = 0; /* update title */ sprintf(m->title,"Controller Settings"); } break; case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: /* remove duplicate assigned inputs */ for (i=0; i<MAX_INPUTS; i++) { if ((i!=player) && (config.input[i].device == config.input[player].device) && (config.input[i].port == config.input[player].port)) { config.input[i].device = -1; config.input[i].port = i%4; } } /* update player index */ old_player = player; player = 0; for (i=0; i<(m->selected-2); i++) if (input.dev[i] != NO_DEVICE) player ++; if (m->bg_images[7].state & IMAGE_VISIBLE) { if (old_player == player) break; /* slide out configuration window */ GUI_DrawMenuFX(m, 20, 1); } else { /* append configuration window */ m->bg_images[7].state |= IMAGE_VISIBLE; /* enable configuration buttons */ m->buttons[10].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); m->buttons[11].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); m->buttons[12].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); /* update directions */ m->buttons[2].shift[3] = 8; m->buttons[3].shift[3] = 7; m->buttons[4].shift[3] = 6; m->buttons[5].shift[3] = 5; m->buttons[6].shift[3] = 4; m->buttons[7].shift[3] = 3; m->buttons[8].shift[3] = 2; m->buttons[9].shift[3] = 1; } /* retrieve current player informations */ if (input.dev[m->selected-2] == DEVICE_LIGHTGUN) { items = items_special[2]; special = &config.gun_cursor[m->selected & 1]; } else if (input.dev[m->selected-2] == DEVICE_MOUSE) { items = items_special[1]; special = &config.invert_mouse; } else { items = items_special[0]; special = &config.input[player].padtype; } memcpy(&m->items[10],&items[*special],sizeof(gui_item)); memcpy(&m->items[11],&items_device[config.input[player].device + 1],sizeof(gui_item)); /* slide in configuration window */ m->buttons[10].shift[2] = 10 - m->selected; m->buttons[11].shift[2] = 11 - m->selected; m->buttons[12].shift[2] = 12 - m->selected; m->selected = 10; GUI_DrawMenuFX(m, 20, 0); /* update title */ if (cart.hw.jcart && (player > 1)) sprintf(m->title,"Controller Settings (Player %d) (J-CART)",player+1); else sprintf(m->title,"Controller Settings (Player %d)",player+1); break; case 10: /* specific option */ if (special == &config.input[player].padtype) { if (config.input[player].device == 1) break; config.input[player].padtype ^= 1; input_init(); input_reset(); } else { *special ^= 1; } /* update menu items */ memcpy(&m->items[10],&items[*special],sizeof(gui_item)); break; case 11: /* input controller selection */ /* no input device */ if (config.input[player].device < 0) { /* try gamecube controllers */ config.input[player].device = 0; config.input[player].port = 0; } else { /* try next port */ config.input[player].port ++; } /* autodetect connected gamecube controllers */ if (config.input[player].device == 0) { exp = 0; while ((config.input[player].port<4) && !exp) { exp = PAD_ScanPads() & (1<<config.input[player].port); if (!exp) config.input[player].port ++; } if (config.input[player].port >= 4) { #ifdef HW_RVL /* no gamecube controller found, try wiimote */ config.input[player].port = 0; config.input[player].device = 1; #else /* no input controller left */ config.input[player].device = -1; config.input[player].port = player%4; #endif } } #ifdef HW_RVL /* autodetect connected wiimotes (without nunchuk) */ if (config.input[player].device == 1) { exp = 4; if (config.input[player].port<4) { WPAD_Probe(config.input[player].port,&exp); if (exp == WPAD_EXP_NUNCHUK) exp = 4; } while ((config.input[player].port<4) && (exp == 4)) { /* try next port */ config.input[player].port ++; if (config.input[player].port<4) { exp = 4; WPAD_Probe(config.input[player].port,&exp); if (exp == WPAD_EXP_NUNCHUK) exp = 4; } } if (config.input[player].port >= 4) { /* no wiimote (without nunchuk) found, try wiimote+nunchuks */ config.input[player].port = 0; config.input[player].device = 2; } } /* autodetect connected wiimote+nunchuks */ if (config.input[player].device == 2) { exp = 4; if (config.input[player].port<4) { WPAD_Probe(config.input[player].port,&exp); } while ((config.input[player].port<4) && (exp != WPAD_EXP_NUNCHUK)) { /* try next port */ config.input[player].port ++; if (config.input[player].port<4) { exp = 4; WPAD_Probe(config.input[player].port,&exp); } } if (config.input[player].port >= 4) { /* no wiimote+nunchuk found, try classic controllers */ config.input[player].port = 0; config.input[player].device = 3; } } /* autodetect connected classic controllers */ if (config.input[player].device == 3) { exp = 4; if (config.input[player].port<4) { WPAD_Probe(config.input[player].port,&exp); } while ((config.input[player].port<4) && (exp != WPAD_EXP_CLASSIC)) { /* try next port */ config.input[player].port ++; if (config.input[player].port<4) { exp = 4; WPAD_Probe(config.input[player].port,&exp); } } if (config.input[player].port >= 4) { /* no input controller left */ config.input[player].device = -1; config.input[player].port = player%4; } } /* force 3-buttons gamepad when using Wiimote */ if (config.input[player].device == 1) { config.input[player].padtype = DEVICE_3BUTTON; memcpy(&m->items[10],&items[*special],sizeof(gui_item)); } #endif /* update menu items */ memcpy(&m->items[11],&items_device[config.input[player].device + 1],sizeof(gui_item)); break; case 12: /* Controller Keys Configuration */ if (config.input[player].device < 0) break; GUI_MsgBoxOpen("Keys Configuration", "",0); if (config.input[player].padtype == DEVICE_6BUTTON) { /* 6-buttons gamepad */ if (config.input[player].device == 0) { /* Gamecube PAD: 6-buttons w/o MODE */ gx_input_Config(config.input[player].port, config.input[player].device, 7); } else { gx_input_Config(config.input[player].port, config.input[player].device, 8); } } else { /* 3-Buttons gamepad, mouse, lightgun */ gx_input_Config(config.input[player].port, config.input[player].device, 4); } GUI_MsgBoxClose(); break; } } else if (update < 0) { if (m->bg_images[7].state & IMAGE_VISIBLE) { /* slide out configuration window */ GUI_DrawMenuFX(m, 20, 1); /* disable configuration window */ m->bg_images[7].state &= ~IMAGE_VISIBLE; /* disable configuration buttons */ m->buttons[10].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); m->buttons[11].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); m->buttons[12].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); /* clear directions */ m->buttons[2].shift[3] = 0; m->buttons[3].shift[3] = 0; m->buttons[4].shift[3] = 0; m->buttons[5].shift[3] = 0; m->buttons[6].shift[3] = 0; m->buttons[7].shift[3] = 0; m->buttons[8].shift[3] = 0; m->buttons[9].shift[3] = 0; /* update selector */ m->selected -= m->buttons[m->selected].shift[2]; /* restore title */ sprintf(m->title,"Controller Settings"); /* stay in menu */ update = 0; } } /* check we have at least one connected input before leaving */ if (update < 0) { old_player = player; player = 0; for (i=0; i<MAX_DEVICES; i++) { /* check inputs */ if (input.dev[i] != NO_DEVICE) { if (config.input[player].device != -1) break; player++; } } player = old_player; /* no input connected */ if (i == MAX_DEVICES) { /* stay in menu */ GUI_WaitPrompt("Error","No input connected !"); update = 0; } } } /* remove duplicate assigned inputs before leaving */ for (i=0; i<8; i++) { if ((i!=player) && (config.input[i].device == config.input[player].device) && (config.input[i].port == config.input[player].port)) { config.input[i].device = -1; config.input[i].port = i%4; } } /* disable configuration window */ m->bg_images[7].state &= ~IMAGE_VISIBLE; /* disable configuration buttons */ m->buttons[10].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); m->buttons[11].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); m->buttons[12].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); /* clear directions */ m->buttons[2].shift[3] = 0; m->buttons[3].shift[3] = 0; m->buttons[4].shift[3] = 0; m->buttons[5].shift[3] = 0; m->buttons[6].shift[3] = 0; m->buttons[7].shift[3] = 0; m->buttons[8].shift[3] = 0; m->buttons[9].shift[3] = 0; /* clear menu items */ memset(&m->items[0],0,sizeof(gui_item)); memset(&m->items[1],0,sizeof(gui_item)); memset(&m->items[10],0,sizeof(gui_item)); memset(&m->items[11],0,sizeof(gui_item)); /* clear player buttons */ m->buttons[2].data = NULL; m->buttons[3].data = NULL; m->buttons[4].data = NULL; m->buttons[5].data = NULL; m->buttons[6].data = NULL; m->buttons[7].data = NULL; m->buttons[8].data = NULL; m->buttons[9].data = NULL; /* delete menu */ GUI_DeleteMenu(m); /* delete custom buttons */ gxTextureClose(&button_player_data.texture[0]); gxTextureClose(&button_player_data.texture[1]); gxTextureClose(&button_player_none_data.texture[0]); /* delete custom images */ gxTextureClose(&items_sys[0][0].texture); gxTextureClose(&items_sys[0][1].texture); gxTextureClose(&items_sys[0][2].texture); gxTextureClose(&items_sys[0][3].texture); gxTextureClose(&items_sys[0][4].texture); gxTextureClose(&items_sys[0][5].texture); gxTextureClose(&items_sys[0][6].texture); gxTextureClose(&items_special[0][0].texture); gxTextureClose(&items_special[0][1].texture); gxTextureClose(&items_special[1][0].texture); gxTextureClose(&items_special[1][1].texture); gxTextureClose(&items_device[1].texture); #ifdef HW_RVL gxTextureClose(&items_device[2].texture); gxTextureClose(&items_device[3].texture); gxTextureClose(&items_device[4].texture); #endif } /**************************************************************************** * Main Option menu * ****************************************************************************/ static void optionmenu(void) { int ret, quit = 0; gui_menu *m = &menu_options; while (quit == 0) { GUI_InitMenu(m); ret = GUI_RunMenu(m); GUI_DeleteMenu(m); switch (ret) { case 0: systemmenu(); break; case 1: videomenu(); break; case 2: soundmenu(); break; case 3: ctrlmenu(); break; case 4: prefmenu(); break; case -1: quit = 1; break; } } config_save(); } /**************************************************************************** * Generic Load/Save menu * ****************************************************************************/ static u8 device = 0; static int loadsavemenu (int which) { int prevmenu = menu; int quit = 0; int ret; int count = 3; char items[3][25]; menu = 2; if (which == 1) { sprintf(items[1], "Save State"); sprintf(items[2], "Load State"); } else { sprintf(items[1], "Save SRAM"); sprintf(items[2], "Load SRAM"); } while (quit == 0) { if (device == 0) sprintf(items[0], "Device: FAT"); else if (device == 1) sprintf(items[0], "Device: MCARD A"); else if (device == 2) sprintf(items[0], "Device: MCARD B"); ret = domenu (&items[0], count, 0); switch (ret) { case -1: quit = 1; break; case 0: device = (device + 1)%3; break; case 1: case 2: SILENT = 1; if (which == 1) quit = ManageState(ret-1,device); else if (which == 0) quit = ManageSRAM(ret-1,device); SILENT = 0; if (quit) return 1; break; } } menu = prevmenu; return 0; } /**************************************************************************** * File Manager menu * ****************************************************************************/ static int filemenu () { int prevmenu = menu; int ret; int quit = 0; int count = 2; char items[2][25] = { {"SRAM Manager"}, {"STATE Manager"} }; menu = 0; while (quit == 0) { strcpy (menutitle, "Press B to return"); ret = domenu (&items[0], count, 0); switch (ret) { case -1: /*** Button B ***/ ret = 0; quit = 1; break; case 0: /*** SRAM Manager ***/ case 1: /*** SaveState Manager ***/ if (loadsavemenu(ret)) return 1; break; } } menu = prevmenu; return 0; } /**************************************************************************** * Load Rom menu * ****************************************************************************/ static int loadmenu () { int ret,size; gui_menu *m = &menu_load; GUI_InitMenu(m); while (1) { ret = GUI_RunMenu(m); switch (ret) { /*** Button B ***/ case -1: GUI_DeleteMenu(m); return 0; /*** Load from DVD ***/ #ifdef HW_RVL case 3: #else case 2: #endif if (DVD_Open()) { GUI_DeleteMenu(m); size = FileSelector(cart.rom,0); if (size) return 1; GUI_InitMenu(m); } break; /*** Load from FAT device ***/ default: if (FAT_Open(ret)) { GUI_DeleteMenu(m); size = FileSelector(cart.rom,1); if (size) return 1; GUI_InitMenu(m); } break; } } return 0; } /*************************************************************************** * Show rom info screen ***************************************************************************/ static void showrominfo () { int ypos; u8 i,j,quit,redraw,max; char msg[128]; short p; char pName[14][21]; quit = 0; j = 0; redraw = 1; /*** Remove any still held buttons ***/ while (PAD_ButtonsHeld(0)) PAD_ScanPads(); #ifdef HW_RVL while (WPAD_ButtonsHeld(0)) WPAD_ScanPads(); #endif max = 14; for (i = 0; i < 14; i++) { if (peripherals & (1 << i)) { sprintf(pName[max-14],"%s", peripheralinfo[i].pName); max ++; } } while (quit == 0) { if (redraw) { gxClearScreen ((GXColor)BLACK); ypos = 134; WriteCentre(ypos, "ROM Header Information"); ypos += 2*fheight; for (i=0; i<8; i++) { switch (i+j) { case 0: sprintf (msg, "Console type: %s", rominfo.consoletype); break; case 1: sprintf (msg, "Copyright: %s", rominfo.copyright); break; case 2: sprintf (msg, "Company: %s", companyinfo[getcompany ()].company); break; case 3: sprintf (msg, "Game Domestic Name:"); break; case 4: sprintf(msg, " %s",rominfo.domestic); break; case 5: sprintf (msg, "Game International Name:"); break; case 6: sprintf(msg, " %s",rominfo.international); break; case 7: sprintf (msg, "Type - %s : %s", rominfo.ROMType, strcmp (rominfo.ROMType, "AI") ? "Game" : "Educational"); break; case 8: sprintf (msg, "Product - %s", rominfo.product); break; case 9: sprintf (msg, "Checksum - %04x (%04x) (%s)", rominfo.checksum, realchecksum, (rominfo.checksum == realchecksum) ? "Good" : "Bad"); break; case 10: sprintf (msg, "ROM end: $%06X", rominfo.romend); break; case 11: if (svp) sprintf (msg, "SVP Chip detected"); else if (sram.custom) sprintf (msg, "EEPROM(%dK) - $%06X", ((eeprom.type.size_mask+1)* 8) /1024, (unsigned int)sram.start); else if (sram.detected) sprintf (msg, "SRAM Start - $%06X", sram.start); else sprintf (msg, "External RAM undetected"); break; case 12: if (sram.custom) sprintf (msg, "EEPROM(%dK) - $%06X", ((eeprom.type.size_mask+1)* 8) /1024, (unsigned int)sram.end); else if (sram.detected) sprintf (msg, "SRAM End - $%06X", sram.end); else if (sram.on) sprintf (msg, "Default SRAM activated "); else sprintf (msg, "SRAM is disactivated "); break; case 13: if (region_code == REGION_USA) sprintf (msg, "Region - %s (USA)", rominfo.country); else if (region_code == REGION_EUROPE) sprintf (msg, "Region - %s (EUR)", rominfo.country); else if (region_code == REGION_JAPAN_NTSC) sprintf (msg, "Region - %s (JAP)", rominfo.country); else if (region_code == REGION_JAPAN_PAL) sprintf (msg, "Region - %s (JPAL)", rominfo.country); break; default: sprintf (msg, "Supports - %s", pName[i+j-14]); break; } write_font (100, ypos, msg); ypos += fheight; } ypos += fheight; WriteCentre (ypos, "Press A to Continue"); gxSetScreen(); } p = m_input.keys; redraw = 0; if ((j<(max-8)) && (p & PAD_BUTTON_DOWN)) {redraw = 1; j++;} if ((j>0) && (p & PAD_BUTTON_UP)) {redraw = 1; j--;} if (p & PAD_BUTTON_A) quit = 1; if (p & PAD_BUTTON_B) quit = 1; } } /**************************************************************************** * Main Menu * ****************************************************************************/ static int rom_loaded = 0; void MainMenu (void) { int ret, quit = 0; char *items[3] = { "View Credits", "Exit to Loader", #ifdef HW_RVL "Exit to System Menu" #else "Reset System" #endif }; /* autosave SRAM */ memfile_autosave(config.sram_auto,-1); #ifdef HW_RVL /* sutdown Wii */ if (Shutdown) { GUI_FadeOut(); shutdown(); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } /* wiimote pointer */ w_pointer = gxTextureOpenPNG(generic_point_png,0); #endif gui_menu *m = &menu_main; if (!rom_loaded) { /* check if a game is running */ if (cart.romsize) { m->screenshot = 128; m->bg_images[0].state &= ~IMAGE_VISIBLE; m->buttons[3].state |= BUTTON_SELECT_SFX; m->buttons[5].state |= BUTTON_SELECT_SFX; m->buttons[6].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); m->buttons[7].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); m->buttons[8].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); m->buttons[3].shift[1] = 3; m->buttons[4].shift[1] = 3; m->buttons[5].shift[1] = 2; m->buttons[5].shift[3] = 1; rom_loaded = 1; } } GUI_InitMenu(m); GUI_SetBgColor(bg_colors[config.bg_color]); GUI_DrawMenuFX(m,10,0); while (quit == 0) { ret = GUI_RunMenu(m); switch (ret) { /*** Load Game Menu ***/ case 0: GUI_DeleteMenu(m); quit = loadmenu(); if (quit) break; GUI_InitMenu(m); break; /*** Options Menu */ case 1: GUI_DeleteMenu(m); optionmenu(); GUI_InitMenu(m); break; /*** Exit Menu ***/ case 2: { switch (GUI_OptionWindow(m, VERSION, items,3)) { case 1: /* return to loader */ #ifdef HW_RVL gxTextureClose(&w_pointer); #endif GUI_DeleteMenu(m); GUI_FadeOut(); shutdown(); exit(0); break; case 2: /* soft reset */ #ifdef HW_RVL gxTextureClose(&w_pointer); #endif GUI_DeleteMenu(m); GUI_FadeOut(); shutdown(); #ifdef HW_RVL SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); #else SYS_ResetSystem(SYS_HOTRESET,0,0); #endif break; default: /* credits (TODO !!!) */ break; } break; } /*** File Manager (TODO !!!) ***/ case 3: if (!cart.romsize) break; GUI_DeleteMenu(m); quit = filemenu(); if (quit) break; GUI_InitMenu(m); break; /*** Virtual system hard reset ***/ case 4: if (!cart.romsize) break; GUI_DrawMenuFX(m,10,1); GUI_DeleteMenu(m); gxClearScreen((GXColor)BLACK); gxSetScreen(); audio_init(snd.sample_rate,snd.frame_rate); system_init(); system_reset(); memfile_autoload(config.sram_auto,-1); quit = 1; break; /*** Game Genie menu (TODO !!!) ***/ case 5: if (!cart.romsize) break; GUI_DeleteMenu(m); GetGGEntries(); GUI_InitMenu(m); break; /*** Return to Game ***/ case 6: case -1: if (!cart.romsize) break; GUI_DrawMenuFX(m,10,1); GUI_DeleteMenu(m); quit = 1; break; /*** Game Capture ***/ case 7: if (!cart.romsize) break; char filename[MAXPATHLEN]; sprintf(filename,"%s/snaps/%s.png", DEFAULT_PATH, rom_filename); gxSaveScreenshot(filename); break; /*** ROM information screen (TODO !!!) ***/ case 8: if (!cart.romsize) break; GUI_DeleteMenu(m); showrominfo(); GUI_InitMenu(m); break; } } /*** Remove any still held buttons ***/ while (PAD_ButtonsHeld(0)) PAD_ScanPads(); #ifdef HW_RVL while (WPAD_ButtonsHeld(0)) WPAD_ScanPads(); /* free wiimote pointer data */ gxTextureClose(&w_pointer); #endif #ifndef HW_RVL /*** Stop the DVD from causing clicks while playing ***/ uselessinquiry (); #endif }
zyking1987-genplus-droid
genplusgx/unused/gx/gui/menu.c
C
gpl2
86,729
/* * filesel.c * * File Selection menu * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #include "shared.h" #include "font.h" #include "gui.h" #include "file_dvd.h" #include "file_fat.h" #include "filesel.h" #ifdef HW_RVL #include <wiiuse/wpad.h> #endif #define PAGESIZE 11 #define PAGEOFFSET 120 FILEENTRIES filelist[MAXFILES]; static int offset = 0; static int selection = 0; static int old_selection = 0; static int old_offset = 0; static int maxfiles = 0; /*****************************************************************************/ /* GUI Buttons data */ /*****************************************************************************/ static butn_data arrow_up_data = { {NULL,NULL}, {Button_up_png,Button_up_over_png} }; static butn_data arrow_down_data = { {NULL,NULL}, {Button_down_png,Button_down_over_png} }; /*****************************************************************************/ /* GUI Arrows button */ /*****************************************************************************/ static gui_butn arrow_up = {&arrow_up_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,{0,0,0,0},14,76,360,32}; static gui_butn arrow_down = {&arrow_down_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,{0,0,0,0},14,368,360,32}; /*****************************************************************************/ /* GUI helpers */ /*****************************************************************************/ static gui_item action_cancel = { NULL,Key_B_png,"","Previous Directory",10,422,28,28 }; static gui_item action_select = { NULL,Key_A_png,"","Load ROM file",602,422,28,28 }; /*****************************************************************************/ /* GUI Background images */ /*****************************************************************************/ static gui_image bg_filesel[10] = { {NULL,Bg_main_png,IMAGE_VISIBLE,356,144,348,288,255}, {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, {NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255}, {NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255}, {NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255}, {NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,230}, {NULL,Frame_s2_png,0,384,264,248,140,200}, {NULL,Snap_empty_png,IMAGE_VISIBLE,422,114,164,116,255}, {NULL,NULL,0,424,116,160,112,255}, {NULL,Snap_frame_png,IMAGE_VISIBLE,388,112,236,148,255} }; /*****************************************************************************/ /* GUI Descriptor */ /*****************************************************************************/ static gui_menu menu_browser = { "Game Selection", -1,-1, 0,0,10,0, NULL, NULL, bg_filesel, {&action_cancel, &action_select}, {&arrow_up,&arrow_down} }; /*************************************************************************** * FileSortCallback (Marty Disibio) * * Quick sort callback to sort file entries with the following order: * . * .. * <dirs> * <files> ***************************************************************************/ int FileSortCallback(const void *f1, const void *f2) { /* Special case for implicit directories */ if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.') { if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; } if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; } if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; } if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; } } /* If one is a file and one is a directory the directory is first. */ if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1; if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1; return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename); } /**************************************************************************** * FileSelector * * Let user select a file from the File listing ..* ROM file buffer is provided as input * ROM size is returned * ****************************************************************************/ int FileSelector(unsigned char *buffer, bool useFAT) { short p; int ret,i,yoffset; int size = 0; int go_up = 0; int string_offset = 0; int old = -1; char text[MAXPATHLEN]; char fname[MAXPATHLEN]; FILE *xml,*snap; #ifdef HW_RVL int x,y; gui_butn *button; #endif /* Initialize Menu */ gui_menu *m = &menu_browser; GUI_InitMenu(m); /* Initialize directory icon */ gui_image dir_icon; dir_icon.texture = gxTextureOpenPNG(Browser_dir_png,0); dir_icon.w = dir_icon.texture->width; dir_icon.h = dir_icon.texture->height; dir_icon.x = 26; dir_icon.y = PAGEOFFSET; /* Initialize selection bar */ gui_image bar_over; bar_over.texture = gxTextureOpenPNG(Overlay_bar_png,0); bar_over.w = bar_over.texture->width; bar_over.h = bar_over.texture->height; bar_over.x = 22; bar_over.y = -(bar_over.h - dir_icon.h)/2; while (1) { /* ROM file snapshot/database */ if (old != selection) { old = selection; string_offset = 0; /* delete previous texture if any */ gxTextureClose(&bg_filesel[8].texture); bg_filesel[8].state &= ~IMAGE_VISIBLE; bg_filesel[6].state &= ~IMAGE_VISIBLE; if (!filelist[selection].flags) { /* get ROM filename without extension */ sprintf (text, "%s", filelist[selection].filename); if (strlen(text) >= 4) text[strlen(text) - 4] = 0; /* ROM database informations */ sprintf (fname, "%s/db/%s.xml", DEFAULT_PATH, text); xml = fopen(fname, "rb"); if (xml) { bg_filesel[6].state |= IMAGE_VISIBLE; fclose(xml); /* TODO */ } /* open screenshot file */ sprintf (fname, "%s/snaps/%s.png", DEFAULT_PATH, text); snap = fopen(fname, "rb"); if (snap) { bg_filesel[8].texture = gxTextureOpenPNG(0,snap); if (bg_filesel[8].texture) bg_filesel[8].state |= IMAGE_VISIBLE; fclose(snap); } } } /* update helper */ if (m->selected != -1) { /* out of focus */ strcpy(action_select.comment,""); } else if (!filelist[selection].flags) { /* this is a file */ strcpy(action_select.comment,"Load ROM File"); } else { /* this is a directory */ if (!strcmp(filelist[selection].filename,"..")) strcpy(action_select.comment,"Previous Directory"); else strcpy(action_select.comment,"Open Directory"); } /* Draw menu*/ GUI_DrawMenu(m); /* Draw Files list */ yoffset = PAGEOFFSET; for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++) { if (i == selection) { /* scrolling text */ if ((string_offset/10) >= strlen(filelist[i].filename)) string_offset = 0; sprintf(text, "%s ",filelist[i].filename + string_offset/10); strncat(text, filelist[i].filename, string_offset/10); gxDrawTexture(bar_over.texture,bar_over.x,yoffset+bar_over.y,bar_over.w,bar_over.h,255); if (filelist[i].flags) { /* directory icon */ gxDrawTexture(dir_icon.texture,dir_icon.x-1,yoffset-1,dir_icon.w+2,dir_icon.h+2,255); if (FONT_write(text,18,dir_icon.x+dir_icon.w+6,yoffset+16,bar_over.w-dir_icon.w-14,(GXColor)WHITE)) { /* text scrolling */ string_offset ++; } } else { if (FONT_write(text,18,dir_icon.x,yoffset+16,bar_over.w-8,(GXColor)WHITE)) { /* text scrolling */ string_offset ++; } } } else { if (filelist[i].flags) { /* directory icon */ gxDrawTexture(dir_icon.texture,dir_icon.x,yoffset,dir_icon.w,dir_icon.h,255); FONT_write(filelist[i].filename,16,dir_icon.x+dir_icon.w+6,yoffset+16,bar_over.w-dir_icon.w-14,(GXColor)WHITE); } else { FONT_write(filelist[i].filename,16,dir_icon.x,yoffset+16,bar_over.w-8,(GXColor)WHITE); } } yoffset += 22; } #ifdef HW_RVL if (Shutdown) { gxTextureClose(&w_pointer); gxTextureClose(&bar_over.texture); gxTextureClose(&dir_icon.texture); GUI_DeleteMenu(m); GUI_FadeOut(); shutdown(); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } else if (m_input.ir.valid) { /* get cursor position */ x = m_input.ir.x; y = m_input.ir.y; /* draw wiimote pointer */ gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); /* find selected item */ yoffset = PAGEOFFSET - 4; m->selected = m->max_buttons + 2; for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++) { if ((x<=380)&&(y>=yoffset)&&(y<(yoffset+24))) { selection = i; m->selected = -1; break; } yoffset += 24; } /* find selected button */ for (i=0; i<2; i++) { button = m->arrows[i]; if (button) { if (button->state & BUTTON_VISIBLE) { if ((x>=button->x)&&(x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) { m->selected = m->max_buttons + i; break; } } } } } else { /* reset indicator */ m->selected = -1; } #endif /* copy EFB to XFB */ gxSetScreen(); p = m_input.keys; /* highlight next item */ if (p & PAD_BUTTON_DOWN) { selection++; if (selection == maxfiles) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; } /* highlight previous item */ else if (p & PAD_BUTTON_UP) { selection--; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; } /* go back one page */ else if (p & PAD_TRIGGER_L) { selection -= PAGESIZE; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; } /* go forward one page */ else if (p & PAD_TRIGGER_R) { selection += PAGESIZE; if (selection > maxfiles - 1) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; } /* quit */ else if (p & PAD_TRIGGER_Z) { GUI_DeleteMenu(m); gxTextureClose(&bar_over.texture); gxTextureClose(&dir_icon.texture); return 0; } /* open selected file or directory */ else if ((p & PAD_BUTTON_A) || (p & PAD_BUTTON_B)) { string_offset = 0; go_up = 0; if (p & PAD_BUTTON_B) { /* go up one directory or quit */ go_up = 1; selection = 0; } #ifdef HW_RVL else { /* arrow buttons selected */ if (m->selected == m->max_buttons) /* up arrow */ { selection--; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; } else if (m->selected == (m->max_buttons+1)) /* down arrow */ { selection++; if (selection == maxfiles) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; } } #endif /* ensure we are in focus area */ if (go_up || (m->selected < m->max_buttons)) { /*** This is directory ***/ if (filelist[selection].flags) { /* force going up */ go_up = (selection == 0); /* get new directory */ if (useFAT) ret = FAT_UpdateDirectory(go_up,filelist[selection].filename); else ret = DVD_UpdateDirectory(go_up,filelist[selection].offset,filelist[selection].length); /* get new entry list or quit */ if (ret) { /* reinit selector (previous value is saved for one level) */ if (selection == 0) { selection = old_selection; offset = old_offset; old_selection = 0; old_offset = 0; } else { /* save current selector value */ old_selection = selection; old_offset = offset; selection = 0; offset = 0; } /* get directory entries */ if (useFAT) maxfiles = FAT_ParseDirectory(); else maxfiles = DVD_ParseDirectory(); } else { GUI_DeleteMenu(m); gxTextureClose(&bar_over.texture); gxTextureClose(&dir_icon.texture); return 0; } } /*** This is a file ***/ else { /* root directory ? */ if (go_up) { GUI_DeleteMenu(m); gxTextureClose(&bar_over.texture); gxTextureClose(&dir_icon.texture); return 0; } else { /* user confirmation */ if (GUI_ConfirmPrompt("Load selected File ?")) { /* Load ROM file from device */ if (useFAT) size = FAT_LoadFile(buffer,selection); else size = DVD_LoadFile(buffer,selection); /* Reload emulation */ if (size) { memfile_autosave(-1,config.state_auto); reloadrom(size,filelist[selection].filename); memfile_autoload(config.sram_auto,config.state_auto); } /* Exit */ GUI_MsgBoxClose(); GUI_DeleteMenu(m); gxTextureClose(&bar_over.texture); gxTextureClose(&dir_icon.texture); return size; } /* user canceled */ GUI_MsgBoxClose(); } } } } } } void ClearSelector(u32 max) { maxfiles = max; offset = 0; selection = 0; old_offset = 0; old_selection = 0; }
zyking1987-genplus-droid
genplusgx/unused/gx/gui/filesel.c
C
gpl2
16,376
/* * filesel.c * * File Selection menu * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #ifndef _FILESEL_H #define _FILESEL_H #define MAXJOLIET 256 #define MAXFILES 1000 /* Filelist structure */ typedef struct { u64 offset; u32 length; char flags; char filename[MAXJOLIET]; }FILEENTRIES; /* Globals */ extern int FileSelector(unsigned char *buffer, bool useFAT); extern int FileSortCallback(const void *f1, const void *f2); extern void ClearSelector(u32 max); extern FILEENTRIES filelist[MAXFILES]; #endif
zyking1987-genplus-droid
genplusgx/unused/gx/gui/filesel.h
C
gpl2
1,400
/***************************************************************************** * font.c * * IPL font engine * * original font support by Softdev (2006) * GX rendering by Eke-Eke (2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #include "shared.h" #include "font.h" #include "gui.h" #define _SHIFTR(v, s, w) \ ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1))) typedef struct _yay0header { unsigned int id ATTRIBUTE_PACKED; unsigned int dec_size ATTRIBUTE_PACKED; unsigned int links_offset ATTRIBUTE_PACKED; unsigned int chunks_offset ATTRIBUTE_PACKED; } yay0header; int font_size[256]; int fheight; static u8 *fontImage; static u8 *fontTexture; static void *ipl_fontarea; static sys_fontheader *fontHeader; #ifndef HW_RVL /* disable Qoob Modchip before IPL access (emukiddid) */ static void ipl_set_config(unsigned char c) { volatile unsigned long* exi = (volatile unsigned long*)0xCC006800; unsigned long val,addr; addr=0xc0000000; val = c << 24; exi[0] = ((((exi[0]) & 0x405) | 256) | 48); //select IPL //write addr of IPL exi[0 * 5 + 4] = addr; exi[0 * 5 + 3] = ((4 - 1) << 4) | (1 << 2) | 1; while (exi[0 * 5 + 3] & 1); //write the ipl we want to send exi[0 * 5 + 4] = val; exi[0 * 5 + 3] = ((4 - 1) << 4) | (1 << 2) | 1; while (exi[0 * 5 + 3] & 1); exi[0] &= 0x405; //deselect IPL } #endif static void decode_szp(void *src,void *dest) { u32 i,k,link; u8 *dest8,*tmp; u32 loff,coff,roff; u32 size,cnt,cmask,bcnt; yay0header *header; dest8 = (u8*)dest; header = (yay0header*)src; size = header->dec_size; loff = header->links_offset; coff = header->chunks_offset; roff = sizeof(yay0header); cmask = 0; cnt = 0; bcnt = 0; do { if(!bcnt) { cmask = *(u32*)(src+roff); roff += 4; bcnt = 32; } if(cmask&0x80000000) { dest8[cnt++] = *(u8*)(src+coff); coff++; } else { link = *(u16*)(src+loff); loff += 2; tmp = dest8+(cnt-(link&0x0fff)-1); k = link>>12; if(k==0) { k = (*(u8*)(src+coff))+18; coff++; } else k += 2; for(i=0;i<k;i++) { dest8[cnt++] = tmp[i]; } } cmask <<= 1; bcnt--; } while(cnt<size); } static void expand_font(u8 *src,u8 *dest) { s32 cnt; u32 idx; u8 val1,val2; sys_fontheader *sys_fontdata = fontHeader; u8 *data = (u8*)sys_fontdata+44; if(sys_fontdata->sheet_format==0x0000) { cnt = (sys_fontdata->sheet_fullsize/2)-1; while(cnt>=0) { idx = _SHIFTR(src[cnt],6,2); val1 = data[idx]; idx = _SHIFTR(src[cnt],4,2); val2 = data[idx]; dest[(cnt<<1)+0] =((val1&0xf0)|(val2&0x0f)); idx = _SHIFTR(src[cnt],2,2); val1 = data[idx]; idx = _SHIFTR(src[cnt],0,2); val2 = data[idx]; dest[(cnt<<1)+1] =((val1&0xf0)|(val2&0x0f)); cnt--; } } DCStoreRange(dest,sys_fontdata->sheet_fullsize); } static void GetFontTexel(s32 c,void *image,s32 pos,s32 stride) { u32 sheets,rem; u32 xoff,yoff; u32 xpos,ypos; u8 *img_start; u8 *ptr1,*ptr2; sys_fontheader *sys_fontdata = fontHeader; if(c<sys_fontdata->first_char || c>sys_fontdata->last_char) c = sys_fontdata->inval_char; else c -= sys_fontdata->first_char; sheets = sys_fontdata->sheet_column*sys_fontdata->sheet_row; rem = c%sheets; sheets = c/sheets; xoff = (rem%sys_fontdata->sheet_column)*sys_fontdata->cell_width; yoff = (rem/sys_fontdata->sheet_column)*sys_fontdata->cell_height; img_start = fontImage+(sys_fontdata->sheet_size*sheets); ypos = 0; while(ypos<sys_fontdata->cell_height) { xpos = 0; while(xpos<sys_fontdata->cell_width) { ptr1 = img_start+(((sys_fontdata->sheet_width/8)<<5)*((ypos+yoff)/8)); ptr1 = ptr1+(((xpos+xoff)/8)<<5); ptr1 = ptr1+(((ypos+yoff)%8)<<2); ptr1 = ptr1+(((xpos+xoff)%8)/2); ptr2 = image+((ypos/8)*(((stride<<1)/8)<<5)); ptr2 = ptr2+(((xpos+pos)/8)<<5); ptr2 = ptr2+(((xpos+pos)%8)/2); ptr2 = ptr2+((ypos%8)<<2); *ptr2 = *ptr1; xpos += 2; } ypos++; } } static void DrawChar(unsigned char c, int xpos, int ypos, int size, GXColor color) { /* reintialize texture object */ GXTexObj texobj; GX_InitTexObj(&texobj, fontTexture, fontHeader->cell_width, fontHeader->cell_height, GX_TF_I4, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_LoadTexObj(&texobj, GX_TEXMAP0); /* reinitialize font texture data */ memset(fontTexture,0,fontHeader->cell_width * fontHeader->cell_height / 2); GetFontTexel(c,fontTexture,0,fontHeader->cell_width/2); DCFlushRange(fontTexture, fontHeader->cell_width * fontHeader->cell_height / 2); GX_InvalidateTexAll(); /* adjust texture width */ s32 width = (fontHeader->cell_width * size) / fontHeader->cell_height; /* GX rendering */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(xpos, ypos - size); GX_Color4u8(color.r, color.g, color.b, 0xff); GX_TexCoord2f32(0.0, 0.0); GX_Position2s16(xpos + width, ypos - size); GX_Color4u8(color.r, color.g, color.b, 0xff); GX_TexCoord2f32(1.0, 0.0); GX_Position2s16(xpos + width, ypos); GX_Color4u8(color.r, color.g, color.b, 0xff); GX_TexCoord2f32(1.0, 1.0); GX_Position2s16(xpos, ypos); GX_Color4u8(color.r, color.g, color.b, 0xff); GX_TexCoord2f32(0.0, 1.0); GX_End (); GX_DrawDone(); } /**************************************************************************** * IPL font support * ****************************************************************************/ extern void __SYS_ReadROM(void *buf,u32 len,u32 offset); int FONT_Init(void) { #ifndef HW_RVL /* --- Game Cube --- disable Qoob before accessing IPL */ ipl_set_config(6); #endif /* read IPL font (ASCII) from Mask ROM */ ipl_fontarea = memalign(32,131360); if (!ipl_fontarea) return 0; memset(ipl_fontarea,0,131360); __SYS_ReadROM(ipl_fontarea+119072,12288,0x1FCF00); /* YAY0 decompression */ decode_szp(ipl_fontarea+119072,ipl_fontarea); /* retrieve IPL font data */ fontHeader = (sys_fontheader*)ipl_fontarea; fontImage = (u8*)((((u32)ipl_fontarea+fontHeader->sheet_image)+31)&~31); /* expand to I4 format */ expand_font((u8*)ipl_fontarea+fontHeader->sheet_image,fontImage); /* character width table */ int i,c; for (i=0; i<256; ++i) { if ((i < fontHeader->first_char) || (i > fontHeader->last_char)) c = fontHeader->inval_char; else c = i - fontHeader->first_char; font_size[i] = ((unsigned char*)fontHeader)[fontHeader->width_table + c]; } /* font height */ fheight = fontHeader->cell_height; /* initialize texture data */ fontTexture = memalign(32, fontHeader->cell_width * fontHeader->cell_height / 2); if (!fontTexture) { free(ipl_fontarea); return 0; } return 1; } void FONT_Shutdown(void) { if (fontHeader) free(ipl_fontarea); if (fontTexture) free(fontTexture); } int FONT_write(char *string, int size, int x, int y, int max_width, GXColor color) { x -= (vmode->fbWidth / 2); y -= (vmode->efbHeight / 2); int w, ox = x; while (*string) { w = (font_size[(u8)*string] * size) / fheight; if ((x + w) <= (ox + max_width)) { DrawChar(*string, x, y, size,color); x += w; string++; } else return 1; } return 0; } void FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color) { int i=0; u16 width = 0; while (string[i] && (string[i] != '\n')) width += (font_size[(u8)string[i++]] * size) / fheight; int x = x1 + (x2 - x1 - width - vmode->fbWidth) / 2; y -= (vmode->efbHeight / 2); while (*string && (*string != '\n')) { DrawChar(*string, x, y, size,color); x += (font_size[(u8)*string++] * size) / fheight; } if (*string == '\n') { string++; i = 0; width = 0; while (string[i]) width += (font_size[(u8)string[i++]] * size) / fheight; x = x1 + (x2 - x1 - width - vmode->fbWidth) / 2; y += size; while (*string) { DrawChar(*string, x, y, size,color); x += (font_size[(u8)*string++] * size) / fheight; } } } void FONT_alignRight(char *string, int size, int x, int y, GXColor color) { int i; u16 width = 0; for (i=0; i<strlen(string); i++) width += (font_size[(u8)string[i]] * size) / fheight; x -= (vmode->fbWidth / 2) + width; y -= (vmode->efbHeight / 2); while (*string) { DrawChar(*string, x, y, size,color); x += (font_size[(u8)*string++] * size) / fheight; } } /**************************************************************************** * Write functions (OLD) * ****************************************************************************/ void write_font(int x, int y, char *string) { int ox = x; while (*string && (x < (ox + 640))) { DrawChar(*string, x -(vmode->fbWidth/2), y-(vmode->efbHeight/2),fontHeader->cell_height,(GXColor)WHITE); x += font_size[(u8)*string]; string++; } } void WriteCentre( int y, char *string) { int x, t; for (x=t=0; t<strlen(string); t++) x += font_size[(u8)string[t]]; if (x>640) x=640; x = (640 - x) >> 1; write_font(x, y, string); } void WriteCentre_HL( int y, char *string) { gx_texture *texture = gxTextureOpenPNG(Overlay_bar_png,0); if (texture) { gxDrawTexture(texture, 0, y-fheight, 640, fheight,240); if (texture->data) free(texture->data); free(texture); } WriteCentre(y, string); } /**************************************************************************** * Draw functions (FrameBuffer) * ****************************************************************************/ void fntDrawHLine (int x1, int x2, int y, int color) { int i; y = 320 * y; x1 >>= 1; x2 >>= 1; for (i = x1; i <= x2; i++) xfb[whichfb][y + i] = color; } void fntDrawVLine (int x, int y1, int y2, int color) { int i; x >>= 1; for (i = y1; i <= y2; i++) xfb[whichfb][x + (640 * i) / 2] = color; } void fntDrawBox (int x1, int y1, int x2, int y2, int color) { fntDrawHLine (x1, x2, y1, color); fntDrawHLine (x1, x2, y2, color); fntDrawVLine (x1, y1, y2, color); fntDrawVLine (x2, y1, y2, color); } void fntDrawBoxFilled (int x1, int y1, int x2, int y2, int color) { int h; for (h = y1; h <= y2; h++) fntDrawHLine (x1, x2, h, color); }
zyking1987-genplus-droid
genplusgx/unused/gx/gui/font.c
C
gpl2
11,324
/**************************************************************************** * legal.c * * Genesis Plus GX Disclaimer * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #include "font.h" #include "gui.h" /* * This is the legal stuff - which must be shown at program startup * Any derivative work MUST include the same textual output. * * In other words, play nice and give credit where it's due. */ void legal () { int ypos = 56; gxClearScreen((GXColor)BLACK); FONT_writeCenter ("DISCLAIMER",22,0,640,ypos,(GXColor)WHITE); ypos += 32; FONT_writeCenter ("This is free software, and you are welcome to",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("redistribute it under the conditions of the",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("GNU GENERAL PUBLIC LICENSE Version 2.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("This software includes code from the MAME project and",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("therefore, its use is conditionned by the MAME license.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("You may not sell, lease, rent or generally use",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("this software in any commercial product or activity.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("You may not distribute this software with any ROM images",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("unless you have the legal right to distribute them.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("This software is not endorsed by or affiliated",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("with Sega Enterprises Ltd or Nintendo Co Ltd.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("All trademarks and registered trademarks are",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("the property of their respective owners.",20,0,640,ypos,(GXColor)WHITE); ypos += 38; GXColor color = {0x99,0xcc,0xff,0xff}; #ifdef HW_RVL gx_texture *button = gxTextureOpenPNG(Key_A_wii_png,0); #else gx_texture *button = gxTextureOpenPNG(Key_A_gcn_png,0); #endif gx_texture *logo_bottom= gxTextureOpenPNG(Bg_intro_c5_png,0); gx_texture *logo_top = gxTextureOpenPNG(Bg_intro_c4_png,0); gxDrawTexture(logo_bottom, (640-logo_bottom->width-logo_top->width -32)/2, 480-logo_bottom->height-24, logo_bottom->width, logo_bottom->height,255); gxDrawTexture(logo_top, (640-logo_bottom->width-logo_top->width -32)/2+logo_bottom->width+32, 480-logo_bottom->height-24, logo_top->width, logo_top->height,255); gxSetScreen(); sleep(1); int count = 2000; int vis = 0; while (!(m_input.keys & PAD_BUTTON_A) && (count > 0)) { ypos = 56; gxClearScreen((GXColor)BLACK); FONT_writeCenter ("DISCLAIMER",22,0,640,ypos,(GXColor)WHITE); ypos += 32; FONT_writeCenter ("This is free software, and you are welcome to",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("redistribute it under the conditions of the",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("GNU GENERAL PUBLIC LICENSE Version 2.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("This software includes code from the MAME project and",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("therefore, its use is conditionned by the MAME license.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("You may not sell, lease, rent or generally use",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("this software in any commercial product or activity.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("You may not distribute this software with any ROM images",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("unless you have the legal right to distribute them.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("This software is not endorsed by or affiliated",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("with Sega Enterprises Ltd or Nintendo Co Ltd.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("All trademarks and registered trademarks are",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("the property of their respective owners.",20,0,640,ypos,(GXColor)WHITE); ypos += 38; if (count%25 == 0) vis^=1; if (vis) { FONT_writeCenter("Press button to continue.",24,0,640,ypos,color); gxDrawTexture(button, 220, ypos-24+(24-button->height)/2, button->width, button->height,255); } gxDrawTexture(logo_bottom, (640-logo_bottom->width-logo_top->width - 32)/2, 480-logo_bottom->height-24, logo_bottom->width, logo_bottom->height,255); gxDrawTexture(logo_top, (640-logo_bottom->width-logo_top->width -32)/2+logo_bottom->width+32, 480-logo_bottom->height-24, logo_top->width, logo_top->height,255); gxSetScreen(); count--; } gxTextureClose(&logo_top); gxTextureClose(&button); gxTextureClose(&logo_bottom); if (count > 0) { ASND_Init(); ASND_Pause(0); int voice = ASND_GetFirstUnusedVoice(); ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)button_select_pcm,button_select_pcm_size,200,200,NULL); GUI_FadeOut(); ASND_Pause(1); ASND_End(); return; } gxClearScreen((GXColor)BLACK); gx_texture *texture = gxTextureOpenPNG(Bg_intro_c1_png,0); if (texture) { gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); if (texture->data) free(texture->data); free(texture); } gxSetScreen(); sleep (1); gxClearScreen((GXColor)WHITE); texture = gxTextureOpenPNG(Bg_intro_c2_png,0); if (texture) { gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); if (texture->data) free(texture->data); free(texture); } gxSetScreen(); sleep (1); gxClearScreen((GXColor)BLACK); texture = gxTextureOpenPNG(Bg_intro_c3_png,0); if (texture) { gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); if (texture->data) free(texture->data); free(texture); } gxSetScreen(); ASND_Pause(0); int voice = ASND_GetFirstUnusedVoice(); ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)intro_pcm,intro_pcm_size,200,200,NULL); sleep (2); ASND_Pause(1); }
zyking1987-genplus-droid
genplusgx/unused/gx/gui/legal.c
C
gpl2
7,602
<html> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/gui/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:08:08 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> <head><title>genplus-gx - Revision 427: /trunk/source/gx/gui</title></head> <body> <h2>genplus-gx - Revision 427: /trunk/source/gx/gui</h2> <ul> <li><a href="../index.html">..</a></li> <li><a href="filesel.c">filesel.c</a></li> <li><a href="filesel.h">filesel.h</a></li> <li><a href="font.c">font.c</a></li> <li><a href="font.h">font.h</a></li> <li><a href="ggentry.c">ggentry.c</a></li> <li><a href="gui.c">gui.c</a></li> <li><a href="gui.h">gui.h</a></li> <li><a href="legal.c">legal.c</a></li> <li><a href="menu.c">menu.c</a></li> <li><a href="oggplayer.c">oggplayer.c</a></li> <li><a href="oggplayer.h">oggplayer.h</a></li> <li><a href="saveicon.h">saveicon.h</a></li> </ul> <hr noshade><em><a href="http://code.google.com/">Google Code</a> powered by <a href="http://subversion.apache.org/">Subversion</a></em> </body> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/gui/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:08:23 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> </html>
zyking1987-genplus-droid
genplusgx/unused/gx/gui/index.html
HTML
gpl2
1,424
/**************************************************************************** * ggentry.c * * Genesis Plus GX Game Genie * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #include "font.h" #include "gui.h" #define MAXCODES 8 extern char menutitle[60]; typedef struct { int address; unsigned short data; } GGPATCH; /*** Game Genie Codes Array ***/ unsigned char ggcodes[MAXCODES][10]; /*** Codes are entered as XXXX-XXXX ***/ int gghpos[MAXCODES]; /*** Edit positions ***/ int ggrow = 0; int editing = 0; char ggvalidchars[] = "ABCDEFGHJKLMNPRSTVWXYZ0123456789*"; GGPATCH ggpatch[8]; /**************************************************************************** * Decode Game Genie entries to memory patches ****************************************************************************/ void decode_genie (char *code, int which) { char *p; int n, i; for (i = 0; i < 8; i++) { /*** This should only happen if memory is corrupt! ***/ p = strchr (ggvalidchars, code[i]); if (p == NULL) { ggpatch[which].address = ggpatch[which].data = 0; return; } n = p - ggvalidchars; switch (i) { case 0: ggpatch[which].data |= n << 3; break; case 1: ggpatch[which].data |= n >> 2; ggpatch[which].address |= (n & 3) << 14; break; case 2: ggpatch[which].address |= n << 9; break; case 3: ggpatch[which].address |= (n & 0xF) << 20 | (n >> 4) << 8; break; case 4: ggpatch[which].data |= (n & 1) << 12; ggpatch[which].address |= (n >> 1) << 16; break; case 5: ggpatch[which].data |= (n & 1) << 15 | (n >> 1) << 8; break; case 6: ggpatch[which].data |= (n >> 3) << 13; ggpatch[which].address |= (n & 7) << 5; break; case 7: ggpatch[which].address |= n; break; } } } void decode_ggcodes () { int i, j; char thiscode[10]; /*** Clear out any old patches ***/ memset (&ggpatch[0], 0, 8 * sizeof (GGPATCH)); memset (&thiscode, 0, 10); j = 0; for (i = 0; i < 8; i++) { if (strcmp ((char *)ggcodes[i], "AAAA-AAAA")) { /*** Move the code into thiscode ***/ memcpy (&thiscode, &ggcodes[i], 4); memcpy (&thiscode[4], &ggcodes[i][5], 4); decode_genie (thiscode, j); j++; } } /*** And now apply the patches ***/ if (j) { for (i = 0; i < j; i++) { if (ggpatch[i].address < 0x400000) { /*** Patching ROM space ONLY (Game Genie does NOT have access to other memory areas) ***/ if (cart.rom) *(uint16 *)(cart.rom + ggpatch[i].address) = ggpatch[i].data & 0xffff; } } } } /**************************************************************************** * ClearGGCodes * * Should be called whenever a new rom is loaded ****************************************************************************/ void ClearGGCodes () { int i; for (i = 0; i < MAXCODES; i++) { strcpy ((char *)ggcodes[i], "AAAA-AAAA"); gghpos[i] = 0; } ggrow = 0; } /**************************************************************************** * DrawGGCodes * * Just draw the codes, with the current one highlighted. ****************************************************************************/ void DrawGGCodes () { int i,j; unsigned char c[2] = { 0, 0 }; gxClearScreen ((GXColor)BLACK); WriteCentre (134, menutitle); for (i = 0; i < MAXCODES; i++) { if (i == ggrow) { /*** Highlight selected ***/ WriteCentre_HL (i * fheight + 190, (char *)ggcodes[i]); /*** If editing, highlight the current character ***/ if (editing) { int hpos = 0; for (j=0; j<strlen ((char *)ggcodes[i]); j++) hpos += font_size[ggcodes[i][j]]; hpos = ((640 - hpos) >> 1); for (j=0; j<gghpos[i]; j++) hpos += font_size[ggcodes[i][j]]; c[0] = ggcodes[i][gghpos[i]]; fntDrawBoxFilled (hpos, (i * fheight) + 190, hpos + font_size[c[0]], ((i + 1) * fheight) + 190, COLOR_YELLOW); write_font (hpos, (i * fheight) + 190, (char *)c); } } else WriteCentre ((i * fheight) + 190, (char *)ggcodes[i]); } gxSetScreen(); } /**************************************************************************** * GGEditLine * * Up/Down traverses valid character array * Left/Right moves along current line * A exits edit mode ****************************************************************************/ void GGEditLine () { short p; char c[2] = { 0, 0 }; char *v; int redraw = 1; int quit = 0; editing = 1; while (quit == 0) { if (redraw) { DrawGGCodes (); redraw = 0; } p = m_input.keys; if (p & PAD_BUTTON_UP) { /*** Increment the entry ***/ redraw = 1; c[0] = ggcodes[ggrow][gghpos[ggrow]]; v = strstr (ggvalidchars, c); v++; if (*v == '*') ggcodes[ggrow][gghpos[ggrow]] = 'A'; else ggcodes[ggrow][gghpos[ggrow]] = *v; } if (p & PAD_BUTTON_DOWN) { /*** Decrement entry ***/ redraw = 1; c[0] = ggcodes[ggrow][gghpos[ggrow]]; v = strstr (ggvalidchars, c); if (*v == 'A') ggcodes[ggrow][gghpos[ggrow]] = '9'; else { v--; ggcodes[ggrow][gghpos[ggrow]] = *v; } } if (p & PAD_BUTTON_LEFT) { redraw = 1; gghpos[ggrow]--; if (gghpos[ggrow] == 4) gghpos[ggrow]--; } if (p & PAD_BUTTON_RIGHT) { redraw = 1; gghpos[ggrow]++; if (gghpos[ggrow] == 4) gghpos[ggrow]++; } if (gghpos[ggrow] < 0) gghpos[ggrow] = 8; if (gghpos[ggrow] > 8) gghpos[ggrow] = 0; if (p & PAD_BUTTON_A) quit = 1; } editing = 0; } /**************************************************************************** * GGSelectLine * * Select which line to edit ****************************************************************************/ void GGSelectLine () { int redraw = 1; int quit = 0; short j; /*** To select a line, just move up or down. Pressing A will enter edit mode. Pressing B will exit to caller. ***/ while (quit == 0) { if (redraw) { DrawGGCodes (); redraw = 0; } j = m_input.keys; if (j & PAD_BUTTON_UP) { ggrow--; redraw = 1; } if (j & PAD_BUTTON_DOWN) { ggrow++; redraw = 1; } if (ggrow < 0) ggrow = MAXCODES - 1; if (ggrow == MAXCODES) ggrow = 0; if (j & PAD_BUTTON_B) quit = 1; if (j & PAD_BUTTON_A) { GGEditLine (); redraw = 1; } if (j & PAD_TRIGGER_Z) { /* reset code */ strcpy ((char *)ggcodes[ggrow], "AAAA-AAAA"); gghpos[ggrow] = 0; redraw = 1; } } } /**************************************************************************** * GetGGEntries * * Screen to return encoded Game Genie codes. * No keyboard is available, so it's just a simple wrap round each line kind * of thing. ****************************************************************************/ void GetGGEntries () { editing = 0; strcpy (menutitle, "Game Genie Entry"); GGSelectLine (); /* Apply Game Genie patches */ decode_ggcodes (); }
zyking1987-genplus-droid
genplusgx/unused/gx/gui/ggentry.c
C
gpl2
8,459
/***************************************************************************** * font.c * * IPL Font Engine, powered by GX hardware * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #ifndef _FONT_H #define _FONT_H extern int FONT_Init(void); extern void FONT_Shutdown(void); extern int FONT_write(char *string, int size, int x, int y, int max_width, GXColor color); extern void FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color); extern void FONT_alignRight(char *string, int size, int x, int y, GXColor color); extern void WriteCentre_HL( int y, char *string); extern void WriteCentre (int y, char *string); extern void write_font (int x, int y, char *string); extern void WriteText(char *text, int size, int x, int y); extern void fntDrawBoxFilled (int x1, int y1, int x2, int y2, int color); extern int fheight; extern int font_size[256]; #endif
zyking1987-genplus-droid
genplusgx/unused/gx/gui/font.h
C
gpl2
1,758
/*********************************************************** * Genesis Plus Save Icon * Made by Brakken (http://www.tehskeen.com) * ************************************************************/ unsigned short icon[1024] = { 0xFFFF, 0xFFFF, 0xFBDE, 0xFBDE, 0xFBDE, 0xFBDE, 0xFBDE, 0xEB5A, 0xFBDE, 0xFBDE, 0xFBDE, 0xBDCD, 0xFBDE, 0xF7BD, 0xF7BD, 0xAD49, 0xEB59, 0xB9AD, 0xC1EF, 0xC1EF, 0x9062, 0x8000, 0x8C41, 0x8C41, 0x8000, 0x9CE6, 0xA0E6, 0xA507, 0x8400, 0x9CC5, 0xA0E6, 0xA0E6, 0xC1EF, 0xC1EF, 0xC1EF, 0xC1EF, 0x8000, 0x8000, 0x8000, 0x8000, 0x9083, 0x8C63, 0x8C63, 0x9484, 0x8C63, 0x9083, 0x9484, 0x94A4, 0xC1EF, 0xC20F, 0xC20F, 0xBDCE, 0x8000, 0x8000, 0x8000, 0x8000, 0x9083, 0x8821, 0x8842, 0x8842, 0x8842, 0xA107, 0xB58C, 0xAD6B, 0xA529, 0x94A4, 0x9083, 0x94A4, 0x8000, 0x8000, 0x8400, 0x8400, 0x8842, 0x8842, 0x8842, 0x8821, 0xB18B, 0xA949, 0xA108, 0xA107, 0xA528, 0xB9AD, 0xC630, 0xCE51, 0x8000, 0x8000, 0x8000, 0x8000, 0x8821, 0x8821, 0x8821, 0x8400, 0xA108, 0xA529, 0xA108, 0xA529, 0xCA30, 0xC630, 0xCA30, 0xFBDE, 0x8000, 0x8000, 0x8000, 0xAD27, 0x8400, 0x9083, 0x8863, 0x8400, 0x9CE6, 0x8842, 0x8C63, 0x8C20, 0xFBDE, 0xFBDE, 0xFFFF, 0xFFFF, 0xFBDE, 0xFBDE, 0xFBDE, 0xFBDE, 0xDA92, 0xFBDE, 0xFBDE, 0xFBDE, 0xC1AB, 0xF7BD, 0xFBDE, 0xFBDE, 0xF7BD, 0xF7BD, 0xF7BD, 0xA0E6, 0xF7BD, 0xF7BD, 0xF39C, 0x9484, 0xF39C, 0xF39C, 0xDEF7, 0x8C41, 0xF39C, 0xEF7B, 0xD272, 0x8400, 0x8C42, 0x9CE6, 0xA507, 0xA0E6, 0x8C63, 0x9CC5, 0xA107, 0x9CE6, 0x9484, 0x98A5, 0x9CE6, 0x98C5, 0x9CC5, 0x98C5, 0xA0E7, 0x98C5, 0x8C42, 0x9083, 0x94A5, 0x9083, 0x8C42, 0x9083, 0x9084, 0x8C62, 0x8C62, 0x9083, 0x9084, 0x8C62, 0x8C63, 0x9083, 0x94A4, 0x8C63, 0x8842, 0x9CC6, 0xA107, 0xA0E7, 0x8842, 0x8842, 0xA108, 0xA54A, 0x8842, 0x8C63, 0xB5AD, 0xB5AD, 0x8C63, 0x8C62, 0x8842, 0x8C63, 0x98C5, 0xA528, 0xB5AC, 0xB5AC, 0xA52A, 0xBDEF, 0xC631, 0xCA52, 0xB9CE, 0xB9CE, 0xA94A, 0xAD6B, 0x8C63, 0x8821, 0x8821, 0x8821, 0xA529, 0x98C5, 0x98C5, 0xA0E6, 0xC210, 0xA529, 0xA529, 0xA529, 0xB5AD, 0xB5CD, 0xB5AD, 0xBDEF, 0x8400, 0x8821, 0x8C62, 0x8821, 0xA0E7, 0x8842, 0x8842, 0x8C41, 0x9083, 0x8842, 0x8842, 0x8842, 0x94A5, 0x8842, 0x8C62, 0x8C62, 0x8C42, 0x9083, 0x8C62, 0x8C62, 0xB548, 0xF7BD, 0xF7BD, 0xF7BD, 0xA4C4, 0xF7BD, 0xF7BD, 0xF7BD, 0x9461, 0xDED5, 0xF39C, 0xF39C, 0x8C20, 0xD271, 0xF39C, 0xF39C, 0xEF7B, 0xEF7B, 0xC610, 0x8400, 0xEF7B, 0xEB5A, 0xB9AC, 0x8000, 0xEB5A, 0xEB5A, 0xA528, 0x9CC5, 0xE739, 0xE739, 0x9CC6, 0x98A5, 0x98C5, 0x98C5, 0xA0E6, 0x94A4, 0x94A4, 0x98C5, 0x94A5, 0x9484, 0xA528, 0x98C5, 0x9CE6, 0xA0E7, 0x9CE6, 0xA4E6, 0x98A4, 0xA507, 0x8C62, 0x9083, 0x9484, 0x9083, 0x94A4, 0x94A5, 0x98C5, 0x98C5, 0xA107, 0xA107, 0xA107, 0xB18B, 0xA907, 0x9062, 0x9484, 0x9CE6, 0x8842, 0x94A4, 0x9484, 0x9084, 0x8C62, 0x8C63, 0x9CC5, 0x9CC5, 0x98C6, 0x8C63, 0x9484, 0xA0E6, 0x9CE6, 0x9084, 0x94A4, 0x90A5, 0x8C63, 0x8C42, 0x8C62, 0x8C62, 0x8C63, 0xA108, 0xA94A, 0xA528, 0x94A5, 0x8884, 0x8884, 0x8884, 0xB0A5, 0xBC84, 0xA483, 0xA484, 0x8C63, 0x8C42, 0x8C63, 0x9083, 0xA94A, 0x9083, 0x8C62, 0x94A4, 0x8884, 0x8063, 0x90A5, 0x94A4, 0xA483, 0xBC63, 0xA884, 0x8884, 0x9083, 0x8C63, 0x8C42, 0x8C63, 0x9084, 0x8842, 0x9083, 0x9084, 0x8C42, 0x8C62, 0x98C6, 0xAD6A, 0x9083, 0x8C63, 0x98C5, 0xA107, 0x8400, 0xC1ED, 0xEF7B, 0xEF7B, 0x8400, 0xAD27, 0xEF7B, 0xEF7B, 0x9CE6, 0x9CA4, 0xEB5A, 0xEB5A, 0x9CE6, 0x9062, 0xDAB4, 0xE739, 0xE739, 0xE318, 0x9483, 0x8C63, 0xE318, 0xCE72, 0x9062, 0x9CC5, 0xDEF7, 0xC20F, 0x8C41, 0x9CE6, 0xDAD6, 0xB9AC, 0x8C20, 0x9CC5, 0xA0E6, 0xA528, 0x9CC5, 0xA528, 0xA508, 0x94A5, 0x98C6, 0xA108, 0x9CE6, 0x9CC5, 0xA0E7, 0xA94A, 0xA0E6, 0xA0E7, 0xA507, 0xAD6B, 0xA107, 0x98C6, 0x9CE6, 0x9083, 0x98C6, 0xA108, 0xA107, 0x98C5, 0xB9CD, 0xB18B, 0xA107, 0x9CC6, 0xC210, 0xB9CE, 0xA528, 0x9CC6, 0x98C5, 0x94A5, 0x9084, 0x8884, 0x9CC6, 0x9CE6, 0x9CC6, 0x94A5, 0x9CE6, 0x9CE6, 0x9CE7, 0xA108, 0x98C5, 0x98C5, 0x98C6, 0x98C6, 0xB0C6, 0xD0C6, 0xD0C6, 0xD0C6, 0x90A4, 0x90A4, 0x98A5, 0x9CA4, 0x9CE6, 0x90A4, 0x9084, 0x9084, 0x98C6, 0x98C6, 0x98C6, 0x98C6, 0xD0A5, 0xD0A5, 0xA484, 0x8483, 0x9484, 0x9083, 0x8C83, 0x9084, 0x90A5, 0x94A5, 0x9CE6, 0x9CE6, 0x98C6, 0x98C6, 0x9CE6, 0x98C6, 0x8C63, 0x9084, 0x9484, 0x9083, 0x98C5, 0x98C5, 0x94A4, 0x94A5, 0x98C6, 0x98C6, 0x98C5, 0x98C5, 0x98C6, 0x98C6, 0x98C6, 0x98C6, 0x9084, 0x8821, 0xCE51, 0xE739, 0x94A5, 0x8C20, 0xBDCE, 0xE318, 0x98C5, 0x8821, 0xB18B, 0xE318, 0x98C6, 0x8842, 0xAD49, 0xDEF7, 0xDAD6, 0xAD49, 0x8C41, 0xA508, 0xD6B5, 0xBDCC, 0x8C20, 0x8C41, 0xD6B5, 0xD294, 0xB98A, 0xAD06, 0xD294, 0xCE73, 0xCE73, 0xCA52, 0xA94A, 0xB5AD, 0xB18C, 0xAD6B, 0x9062, 0x9062, 0x9062, 0x9062, 0xAD27, 0xAD06, 0xAD06, 0xAD06, 0xCA52, 0xC631, 0xC631, 0xC210, 0xA94B, 0xB18C, 0xB58D, 0xAD6B, 0x9062, 0x9484, 0x98A4, 0x98A4, 0xA906, 0xA906, 0xA506, 0xA907, 0xC210, 0xC210, 0xB9F0, 0xBDEF, 0xA94B, 0xA94B, 0xA94B, 0xA94B, 0x98A5, 0x98A5, 0x98A4, 0x98A4, 0xA907, 0xA907, 0xA907, 0xA506, 0xBDEF, 0xBDEF, 0xBDEF, 0xB1F2, 0xA94B, 0xA94A, 0xA54A, 0xA529, 0x9484, 0x9484, 0x9483, 0x9483, 0xA4E6, 0xA4E6, 0xA4E6, 0xA4E6, 0xBDEF, 0xBDEF, 0xBDEF, 0xBDEF, 0xA529, 0xA529, 0xA529, 0xA108, 0x9062, 0x8C63, 0x9062, 0x9062, 0xA4E6, 0x9CE6, 0xA0E6, 0xA506, 0xBDEF, 0xC210, 0xC210, 0xC210, 0xA108, 0x9CE7, 0x9CE7, 0x98C6, 0x8C41, 0x8C42, 0x8C41, 0x8C41, 0xA507, 0xA508, 0xAD27, 0xB127, 0xC631, 0xC631, 0xCA52, 0xCA52, 0x98C6, 0x8C63, 0xA0E6, 0xDAD6, 0x8C41, 0x8400, 0xB548, 0xDAD6, 0xB127, 0xB548, 0xD6B5, 0xD6B5, 0xCE73, 0xCE73, 0xD294, 0xD6B5, 0xD294, 0xCA74, 0xBA56, 0xB635, 0x9A3B, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x8A1F, 0xA27F, 0xA27F, 0x81FF, 0xA27F, 0xFFFF, 0xFFFF, 0xB635, 0xB214, 0xB214, 0xBE11, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0xA27F, 0xA27F, 0xA27F, 0x8A1F, 0xFFFF, 0xFFFF, 0xFFFF, 0xDF7F, 0xA1F7, 0x91FA, 0x81FF, 0x95F9, 0x81FF, 0x81FF, 0x8A1F, 0x81FF, 0x81FF, 0xD75F, 0xBEFF, 0x81FF, 0x81FF, 0xFFFF, 0xBEFF, 0x81FF, 0xB9CE, 0xB9CE, 0x8DFC, 0x81FF, 0xA9D2, 0xA9D2, 0x81FF, 0x9A5F, 0x99D6, 0x99D6, 0x81FF, 0xBEFF, 0x99D6, 0x99D6, 0x81FF, 0xBEFF, 0x85FD, 0x95F9, 0xB5CF, 0xB1F1, 0x81FF, 0x81FF, 0x95F9, 0x81FF, 0xEFBF, 0x81FF, 0x85FD, 0x81FF, 0xFFFF, 0x81FF, 0x81FF, 0x81FF, 0xA5F5, 0xA5F5, 0xB5F2, 0xB214, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0xB2BF, 0xB2BF, 0x81FF, 0x9A5F, 0xDF7F, 0xDF7F, 0x81FF, 0xE79F, 0xA218, 0xA218, 0xA218, 0xA639, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0xBEFF, 0xBEFF, 0xBEFF, 0xBEFF, 0xF7DF, 0xDF7F, 0xDF7F, 0xDF7F, 0xA639, 0xB657, 0xCA75, 0xD294, 0x81FF, 0x81FF, 0x861E, 0xCA95, 0xBEFF, 0xAA9F, 0x81FF, 0xB658, 0xD75F, 0x8A1F, 0x81FF, 0xCA75, 0x81FF, 0xA27F, 0xFFFF, 0xA27F, 0x81FF, 0xA27F, 0xFFFF, 0xFFFF, 0x81FF, 0xA27F, 0xFFFF, 0xBADF, 0x81FF, 0xA27F, 0xFFFF, 0xA27F, 0x81FF, 0x81FF, 0xCF3F, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xBADF, 0xA27F, 0xA27F, 0xA27F, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x923F, 0xFFFF, 0xBEFF, 0x81FF, 0x81FF, 0xFFFF, 0xBEFF, 0x81FF, 0x81FF, 0xFFFF, 0xCF3F, 0xA27F, 0x81FF, 0xFFFF, 0xFFFF, 0xFFFF, 0x99D6, 0x99D6, 0x81FF, 0xBEFF, 0x81FF, 0x81FF, 0x81FF, 0xBEFF, 0xA27F, 0xA27F, 0x9A5F, 0xBADF, 0xFFFF, 0xFFFF, 0xA27F, 0x81FF, 0xFFFF, 0x81FF, 0x81FF, 0x81FF, 0xFFFF, 0x81FF, 0x81FF, 0x81FF, 0xFFFF, 0xBEFF, 0xBEFF, 0xBEFF, 0xC71F, 0xDF7F, 0xDF7F, 0xDF7F, 0xDF7F, 0xDF7F, 0x923F, 0xF7DF, 0xDF7F, 0xDF7F, 0x81FF, 0xAA9F, 0xEFBF, 0xC71F, 0x81FF, 0x9A5F, 0xCF3F, 0x81FF, 0x8A1F, 0xD75F, 0xE79F, 0xBEFF, 0xBEFF, 0xBEFF, 0xDF7F, 0xDF7F, 0xDF7F, 0xDF7F, 0xBEFF, 0xBEFF, 0xBEFF, 0xC71F, 0xDF7F, 0xDF7F, 0xDF7F, 0xDF7F, 0xBEFF, 0x81FF, 0x81FF, 0xB657, 0xFFFF, 0xC71F, 0x81FF, 0xA23A, 0xFFFF, 0xC71F, 0x81FF, 0xA23A, 0xD75F, 0x8A1F, 0x81FF, 0xB658, 0x81FF, 0x9A5F, 0xAA9F, 0x81FF, 0x921D, 0x81FF, 0x81FF, 0x85FE, 0xD294, 0xBE55, 0xB657, 0xC653, 0xD294, 0xD294, 0xCE73, 0xCA52, 0x8A1D, 0xB214, 0xB214, 0x8DFC, 0xBA34, 0xC631, 0xC210, 0xB612, 0xC631, 0xC631, 0xC631, 0xC210, 0xCA52, 0xCA52, 0xC631, 0xC631, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x8DFC, 0x81FF, 0x81FF, 0x81FF, 0xC210, 0xBE10, 0xBDEF, 0xBDEF, 0xC210, 0xC210, 0xC210, 0xBE10, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x8DFB, 0xA5D4, 0xBDEF, 0xB9CE, 0xB9CE, 0xB9CE, 0xBDEF, 0xBDEF, 0xBDEF, 0xBDEF, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x99F8, 0x8DFB, 0x8DFB, 0x8DFB, 0xB9CE, 0xBDEF, 0xBDEF, 0xBDEF, 0xBDEF, 0xBDEF, 0xBE10, 0xC210, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x95F9, 0xA5F5, 0xA1F7, 0x91FA, 0xBDEF, 0xBE10, 0xC210, 0xC210, 0xC210, 0xC210, 0xC631, 0xC631, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x921C, 0x921C, 0x921C, 0x921C, 0xC631, 0xC631, 0xCA52, 0xCA52, 0xC631, 0xCA52, 0xCA52, 0xCE73, 0x81FF, 0x81FF, 0x9A3B, 0xD294, 0x961B, 0xAA39, 0xD294, 0xD294, 0xCE73, 0xCE73, 0xD294, 0xD6B5, 0xCE73, 0xD294, 0xD6B5, 0xD6B5, };
zyking1987-genplus-droid
genplusgx/unused/gx/gui/saveicon.h
C
gpl2
8,816
<html> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/sounds/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:09:22 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> <head><title>genplus-gx - Revision 427: /trunk/source/gx/sounds</title></head> <body> <h2>genplus-gx - Revision 427: /trunk/source/gx/sounds</h2> <ul> <li><a href="../index.html">..</a></li> <li><a href="button_over.pcm">button_over.pcm</a></li> <li><a href="button_select.pcm">button_select.pcm</a></li> <li><a href="intro.pcm">intro.pcm</a></li> </ul> <hr noshade><em><a href="http://code.google.com/">Google Code</a> powered by <a href="http://subversion.apache.org/">Subversion</a></em> </body> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/sounds/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:09:23 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> </html>
zyking1987-genplus-droid
genplusgx/unused/gx/sounds/index.html
HTML
gpl2
1,087
/**************************************************************************** * aram.c * * ARAM wrapper for libogc * * Softdev (2006) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #define ARAMSTART 0x8000 #define ARAM_READ 1 #define ARAM_WRITE 0 /** * StartARAM * This simply sets up the call to internal libOGC. * Passing NULL for array list, and 0 items to allocate. * Required so libOGC knows to handle any interrupts etc. */ void StartARAM () { AR_Init (NULL, 0); } /** * ARAMPut * * Move data from MAIN memory to ARAM */ void ARAMPut (char *src, char *dst, int len) { DCFlushRange (src, len); AR_StartDMA( ARAM_WRITE, (u32)src, (u32)dst, len); while (AR_GetDMAStatus()); } /** * ARAMFetch * * This function will move data from ARAM to MAIN memory */ void ARAMFetch (char *dst, char *src, int len) { DCInvalidateRange(dst, len); AR_StartDMA( ARAM_READ, (u32) dst, (u32) src, len); while (AR_GetDMAStatus()); }
zyking1987-genplus-droid
genplusgx/unused/gx/aram.c
C
gpl2
1,813
/**************************************************************************** * aram.c * * ARAM wrapper for libogc * * Softdev (2006) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #ifndef _ARAM_H #define _ARAM_H extern void StartARAM (); extern void ARAMFetch (char *src, char *dst, int len); extern void ARAMPut (char *src, char *dst, int len); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/aram.h
C
gpl2
1,157
/**************************************************************************** * vi_encoder.c * * Wii Audio/Video Encoder support * * Copyright (C) 2009 Hector Martin (marcan) * Additional code by Eke-Eke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #if defined(HW_RVL) #include <string.h> #include <gccore.h> #include <ogcsys.h> #include <ogc/machine/processor.h> /**************************************************************************** * I2C driver by Hector Martin (marcan) * ****************************************************************************/ #define _SHIFTL(v, s, w) \ ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s))) #define _SHIFTR(v, s, w) \ ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1))) extern void udelay(int us); static u32 i2cIdentFirst = 0; static u32 i2cIdentFlag = 1; static vu16* const _viReg = (u16*)0xCC002000; static vu32* const _i2cReg = (u32*)0xCD800000; static inline void __viOpenI2C(u32 channel) { u32 val = ((_i2cReg[49]&~0x8000)|0x4000); val |= _SHIFTL(channel,15,1); _i2cReg[49] = val; } static inline u32 __viSetSCL(u32 channel) { u32 val = (_i2cReg[48]&~0x4000); val |= _SHIFTL(channel,14,1); _i2cReg[48] = val; return 1; } static inline u32 __viSetSDA(u32 channel) { u32 val = (_i2cReg[48]&~0x8000); val |= _SHIFTL(channel,15,1); _i2cReg[48] = val; return 1; } static inline u32 __viGetSDA() { return _SHIFTR(_i2cReg[50],15,1); } static inline void __viCheckI2C() { __viOpenI2C(0); udelay(4); i2cIdentFlag = 0; if(__viGetSDA()!=0) i2cIdentFlag = 1; } static u32 __sendSlaveAddress(u8 addr) { u32 i; __viSetSDA(i2cIdentFlag^1); udelay(2); __viSetSCL(0); for(i=0;i<8;i++) { if(addr&0x80) __viSetSDA(i2cIdentFlag); else __viSetSDA(i2cIdentFlag^1); udelay(2); __viSetSCL(1); udelay(2); __viSetSCL(0); addr <<= 1; } __viOpenI2C(0); udelay(2); __viSetSCL(1); udelay(2); if(i2cIdentFlag==1 && __viGetSDA()!=0) return 0; __viSetSDA(i2cIdentFlag^1); __viOpenI2C(1); __viSetSCL(0); return 1; } static u32 __VISendI2CData(u8 addr,void *val,u32 len) { u8 c; s32 i,j; u32 level,ret; if(i2cIdentFirst==0) { __viCheckI2C(); i2cIdentFirst = 1; } _CPU_ISR_Disable(level); __viOpenI2C(1); __viSetSCL(1); __viSetSDA(i2cIdentFlag); udelay(4); ret = __sendSlaveAddress(addr); if(ret==0) { _CPU_ISR_Restore(level); return 0; } __viOpenI2C(1); for(i=0;i<len;i++) { c = ((u8*)val)[i]; for(j=0;j<8;j++) { if(c&0x80) __viSetSDA(i2cIdentFlag); else __viSetSDA(i2cIdentFlag^1); udelay(2); __viSetSCL(1); udelay(2); __viSetSCL(0); c <<= 1; } __viOpenI2C(0); udelay(2); __viSetSCL(1); udelay(2); if(i2cIdentFlag==1 && __viGetSDA()!=0) { _CPU_ISR_Restore(level); return 0; } __viSetSDA(i2cIdentFlag^1); __viOpenI2C(1); __viSetSCL(0); } __viOpenI2C(1); __viSetSDA(i2cIdentFlag^1); udelay(2); __viSetSDA(i2cIdentFlag); _CPU_ISR_Restore(level); return 1; } static void __VIWriteI2CRegister8(u8 reg, u8 data) { u8 buf[2]; buf[0] = reg; buf[1] = data; __VISendI2CData(0xe0,buf,2); udelay(2); } static void __VIWriteI2CRegister16(u8 reg, u16 data) { u8 buf[3]; buf[0] = reg; buf[1] = data >> 8; buf[2] = data & 0xFF; __VISendI2CData(0xe0,buf,3); udelay(2); } static void __VIWriteI2CRegister32(u8 reg, u32 data) { u8 buf[5]; buf[0] = reg; buf[1] = data >> 24; buf[2] = (data >> 16) & 0xFF; buf[3] = (data >> 8) & 0xFF; buf[4] = data & 0xFF; __VISendI2CData(0xe0,buf,5); udelay(2); } static void __VIWriteI2CRegisterBuf(u8 reg, int size, u8 *data) { u8 buf[0x100]; buf[0] = reg; memcpy(&buf[1], data, size); __VISendI2CData(0xe0,buf,size+1); udelay(2); } /**************************************************************************** * A/V functions support (Eke-Eke) * ****************************************************************************/ static const u8 gamma_coeffs[][33] = { /* GM_0_0 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* GM_0_1 */ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x97, 0x3B, 0x49, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x80, 0x1B, 0x80, 0xEB, 0x00 }, /* GM_0_2 */ { 0x00, 0x00, 0x00, 0x28, 0x00, 0x5A, 0x02, 0xDB, 0x0D, 0x8D, 0x30, 0x49, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x10, 0x00, 0x10, 0x40, 0x11, 0x00, 0x18, 0x80, 0x42, 0x00, 0xEB, 0x00 }, /* GM_0_3 */ { 0x00, 0x00, 0x00, 0x7A, 0x02, 0x3C, 0x07, 0x6D, 0x12, 0x9C, 0x27, 0x24, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x10, 0x00, 0x10, 0xC0, 0x15, 0x80, 0x29, 0x00, 0x62, 0x00, 0xEB, 0x00 }, /* GM_0_4 */ { 0x00, 0x4E, 0x01, 0x99, 0x05, 0x2D, 0x0B, 0x24, 0x14, 0x29, 0x20, 0xA4, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x00, 0x10, 0x10, 0x40, 0x12, 0xC0, 0x1D, 0xC0, 0x3B, 0x00, 0x78, 0xC0, 0xEB, 0x00 }, /* GM_0_5 */ { 0x00, 0xEC, 0x03, 0xD7, 0x08, 0x00, 0x0D, 0x9E, 0x14, 0x3E, 0x1B, 0xDB, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x10, 0xC0, 0x16, 0xC0, 0x27, 0xC0, 0x4B, 0x80, 0x89, 0x80, 0xEB, 0x00 }, /* GM_0_6 */ { 0x02, 0x76, 0x06, 0x66, 0x0A, 0x96, 0x0E, 0xF3, 0x13, 0xAC, 0x18, 0x49, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x12, 0x00, 0x1C, 0x00, 0x32, 0x80, 0x59, 0xC0, 0x96, 0x00, 0xEB, 0x00 }, /* GM_0_7 */ { 0x04, 0xEC, 0x08, 0xF5, 0x0C, 0x96, 0x0F, 0xCF, 0x12, 0xC6, 0x15, 0x80, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x14, 0x00, 0x22, 0x00, 0x3C, 0xC0, 0x66, 0x40, 0x9F, 0xC0, 0xEB, 0x00 }, /* GM_0_8 */ { 0x08, 0x00, 0x0B, 0xAE, 0x0E, 0x00, 0x10, 0x30, 0x11, 0xCB, 0x13, 0x49, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x16, 0x80, 0x28, 0xC0, 0x46, 0x80, 0x71, 0x00, 0xA7, 0x80, 0xEB, 0x00 }, /* GM_0_9 */ { 0x0B, 0xB1, 0x0E, 0x14, 0x0F, 0x2D, 0x10, 0x18, 0x10, 0xE5, 0x11, 0x80, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x19, 0x80, 0x2F, 0x80, 0x4F, 0xC0, 0x7A, 0x00, 0xAD, 0xC0, 0xEB, 0x00 }, /* GM_1_0 */ { 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xEB, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x60, 0x00, 0x80, 0x00, 0xA0, 0x00, 0xEB, 0x00 }, /* GM_1_1 */ { 0x14, 0xEC, 0x11, 0xC2, 0x10, 0x78, 0x0F, 0xB6, 0x0F, 0x2F, 0x0E, 0xB6, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x21, 0x00, 0x3C, 0xC0, 0x5F, 0xC0, 0x89, 0x00, 0xB7, 0x80, 0xEB, 0x00 }, /* GM_1_2 */ { 0x19, 0xD8, 0x13, 0x33, 0x10, 0xD2, 0x0F, 0x6D, 0x0E, 0x5E, 0x0D, 0xA4, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x25, 0x00, 0x43, 0x00, 0x66, 0xC0, 0x8F, 0x40, 0xBB, 0x40, 0xEB, 0x00 }, /* GM_1_3 */ { 0x1E, 0xC4, 0x14, 0x7A, 0x11, 0x0F, 0xF, 0x0C, 0x0D, 0xA1, 0x0C, 0xB6, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x29, 0x00, 0x49, 0x00, 0x6D, 0x40, 0x94, 0xC0, 0xBE, 0x80, 0xEB, 0x00 }, /* GM_1_4 */ { 0x24, 0x00, 0x15, 0x70, 0x11, 0x0F, 0x0E, 0xAA, 0x0D, 0x0F, 0x0B, 0xDB, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x2D, 0x40, 0x4E, 0xC0, 0x73, 0x00, 0x99, 0x80, 0xC1, 0x80, 0xEB, 0x00 }, /* GM_1_5 */ { 0x29, 0x3B, 0x16, 0x3D, 0x11, 0x0F, 0x0E, 0x30, 0x0C, 0x7D, 0x0B, 0x24, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x31, 0x80, 0x54, 0x40, 0x78, 0x80, 0x9D, 0xC0, 0xC4, 0x00, 0xEB, 0x00 }, /* GM_1_6 */ { 0x2E, 0x27, 0x17, 0x0A, 0x10, 0xD2, 0x0D, 0xE7, 0x0B, 0xEB, 0x0A, 0x80, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x35, 0x80, 0x59, 0x80, 0x7D, 0x40, 0xA1, 0xC0, 0xC6, 0x40, 0xEB, 0x00 }, /* GM_1_7 */ { 0x33, 0x62, 0x17, 0x5C, 0x10, 0xD2, 0x0D, 0x6D, 0x0B, 0x6D, 0x09, 0xED, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x39, 0xC0, 0x5E, 0x40, 0x82, 0x00, 0xA5, 0x40, 0xC8, 0x40, 0xEB, 0x00 }, /* GM_1_8 */ { 0x38, 0x4E, 0x17, 0xAE, 0x10, 0xB4, 0x0D, 0x0C, 0x0A, 0xF0, 0x09, 0x6D, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x3D, 0xC0, 0x62, 0xC0, 0x86, 0x40, 0xA8, 0x80, 0xCA, 0x00, 0xEB, 0x00 }, /* GM_1_9 */ { 0x3D, 0x3B, 0x18, 0x00, 0x10, 0x5A, 0x0C, 0xC3, 0x0A, 0x72, 0x09, 0x00, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x41, 0xC0, 0x67, 0x40, 0x8A, 0x00, 0xAB, 0x80, 0xCB, 0x80, 0xEB, 0x00 }, /* GM_2_0 */ { 0x41, 0xD8, 0x18, 0x28, 0x10, 0x3C, 0x0C, 0x49, 0x0A, 0x1F, 0x08, 0x92, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x45, 0x80, 0x6B, 0x40, 0x8D, 0xC0, 0xAE, 0x00, 0xCD, 0x00, 0xEB, 0x00 }, /* GM_2_1 */ { 0x46, 0x76, 0x18, 0x51, 0x0F, 0xE1, 0x0C, 0x00, 0x09, 0xB6, 0x08, 0x36, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x49, 0x40, 0x6F, 0x40, 0x91, 0x00, 0xB0, 0x80, 0xCE, 0x40, 0xEB, 0x00 }, /* GM_2_2 */ { 0x4A, 0xC4, 0x18, 0x7A, 0x0F, 0xA5, 0x0B, 0x9E, 0x09, 0x63, 0x07, 0xDB, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x4C, 0xC0, 0x73, 0x00, 0x94, 0x40, 0xB2, 0xC0, 0xCF, 0x80, 0xEB, 0x00 }, /* GM_2_3 */ { 0x4F, 0x13, 0x18, 0x51, 0x0F, 0x69, 0x0B, 0x6D, 0x09, 0x0F, 0x07, 0x80, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x50, 0x40, 0x76, 0x40, 0x97, 0x00, 0xB5, 0x00, 0xD0, 0xC0, 0xEB, 0x00 }, /* GM_2_4 */ { 0x53, 0x13, 0x18, 0x7A, 0x0F, 0x0F, 0x0B, 0x24, 0x08, 0xBC, 0x07, 0x36, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x53, 0x80, 0x79, 0xC0, 0x99, 0xC0, 0xB7, 0x00, 0xD1, 0xC0, 0xEB, 0x00 }, /* GM_2_5 */ { 0x57, 0x13, 0x18, 0x51, 0x0E, 0xF0, 0x0A, 0xC3, 0x08, 0x7D, 0x06, 0xED, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x56, 0xC0, 0x7C, 0xC0, 0x9C, 0x80, 0xB8, 0xC0, 0xD2, 0xC0, 0xEB, 0x00 }, /* GM_2_6 */ { 0x5B, 0x13, 0x18, 0x28, 0x0E, 0x96, 0x0A, 0x92, 0x08, 0x29, 0x06, 0xB6, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x5A, 0x00, 0x7F, 0xC0, 0x9E, 0xC0, 0xBA, 0x80, 0xD3, 0x80, 0xEB, 0x00 }, /* GM_2_7 */ { 0x5E, 0xC4, 0x18, 0x00, 0x0E, 0x78, 0x0A, 0x30, 0x08, 0x00, 0x06, 0x6D, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x5D, 0x00, 0x82, 0x80, 0xA1, 0x40, 0xBC, 0x00, 0xD4, 0x80, 0xEB, 0x00 }, /* GM_2_8 */ { 0x62, 0x76, 0x17, 0xD7, 0x0E, 0x1E, 0x0A, 0x00, 0x07, 0xC1, 0x06, 0x36, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x60, 0x00, 0x85, 0x40, 0xA3, 0x40, 0xBD, 0x80, 0xD5, 0x40, 0xEB, 0x00 }, /* GM_2_9 */ { 0x65, 0xD8, 0x17, 0xAE, 0x0D, 0xE1, 0x09, 0xCF, 0x07, 0x82, 0x06, 0x00, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x62, 0xC0, 0x87, 0xC0, 0xA5, 0x40, 0xBF, 0x00, 0xD6, 0x00, 0xEB, 0x00 }, /* GM_3_0 */ { 0x69, 0x3B, 0x17, 0x85, 0x0D, 0xA5, 0x09, 0x86, 0x07, 0x43, 0x05, 0xDB, 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, 0x10, 0x00, 0x65, 0x80, 0x8A, 0x40, 0xA7, 0x40, 0xC0, 0x40, 0xD6, 0x80, 0xEB, 0x00 } }; void __VISetTiming(u8 timing) { __VIWriteI2CRegister8(0x00,timing); } void __VISetYUVSEL(u8 dtvstatus) { u8 vdacFlagRegion = 0; u32 currTvMode = _SHIFTR(_viReg[1],8,2); if(currTvMode==VI_PAL || currTvMode==VI_EURGB60) vdacFlagRegion = 2; else if(currTvMode==VI_MPAL) vdacFlagRegion = 1; __VIWriteI2CRegister8(0x01, _SHIFTL(dtvstatus,5,3)|(vdacFlagRegion&0x1f)); } void __VISetVBICtrl(u16 data) { __VIWriteI2CRegister16(0x02, data); } void __VISetTrapFilter(u8 disable) { if (disable) __VIWriteI2CRegister8(0x03, 0); else __VIWriteI2CRegister8(0x03, 1); } void __VISet3in1Output(u8 enable) { __VIWriteI2CRegister8(0x04,enable); } void __VISetCGMS(u16 value) { __VIWriteI2CRegister16(0x05, value); } void __VISetWSS(u16 value) { __VIWriteI2CRegister16(0x08, value); } void __VISetRGBOverDrive(u8 value) { u32 currTvMode = _SHIFTR(_viReg[1],8,2); if (currTvMode == VI_DEBUG) __VIWriteI2CRegister8(0x0A,(value<<1)|1); else __VIWriteI2CRegister8(0x0A,0); } void __VISetOverSampling(void) { __VIWriteI2CRegister8(0x65,1); } void __VISetCCSEL(void) { __VIWriteI2CRegister8(0x6a,1); } void __VISetFilterEURGB60(u8 enable) { __VIWriteI2CRegister8(0x6e, enable); } void __VISetVolume(u16 value) { __VIWriteI2CRegister16(0x71,value); } void __VISetClosedCaption(u32 value) { __VIWriteI2CRegister32(0x7a, value); } void __VISetGamma(VIGamma gamma) { u8 *data = (u8 *)&gamma_coeffs[gamma][0]; __VIWriteI2CRegisterBuf(0x10, 0x21, data); } /* User Configurable */ void VIDEO_SetGamma(VIGamma gamma) { __VISetGamma(gamma); } void VIDEO_SetTrapFilter(bool enable) { if (enable) __VISetTrapFilter(0); else __VISetTrapFilter(1); } #endif
zyking1987-genplus-droid
genplusgx/unused/gx/vi_encoder.c
C
gpl2
14,066
/**************************************************************************** * vi_encoder.c * * Wii Audio/Video Encoder support * * Copyright (C) 2009 Hector Martin (marcan) * Additional code by Eke-Eke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #if defined(HW_RVL) extern void VIDEO_SetGamma(VIGamma gamma); extern void VIDEO_SetTrapFilter(bool enable); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/vi_encoder.h
C
gpl2
1,169
/**************************************************************************** * gx_input.c * * Genesis Plus GX input support * * Eke-Eke (2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #ifndef _GC_INPUT_H_ #define _GC_INPUT_H_ /* max. supported inputs */ #ifdef HW_DOL #define MAX_INPUTS 4 #else #define MAX_INPUTS 8 #endif /* Genesis controller keys */ #define MAX_KEYS 8 /* Key configuration structure */ typedef struct { s8 device; u8 port; u8 padtype; } t_input_config; extern void gx_input_Init(void); extern void gx_input_SetDefault(void); extern void gx_input_Config(u8 num, u8 type, u8 max_keys); extern void gx_input_UpdateEmu(void); extern void gx_input_UpdateMenu(u32 cnt); extern u32 ConfigRequested; #endif
zyking1987-genplus-droid
genplusgx/unused/gx/gx_input.h
C
gpl2
1,569
/* * dvd.c * * Low-level DVD access * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #ifndef _DVD_H_ #define _DVD_H_ extern u32 dvd_read (void *dst, u32 len, u64 offset); extern void dvd_motor_off (); #ifndef HW_RVL extern void uselessinquiry (); extern void dvd_drive_detect(); #endif #endif
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/dvd.h
C
gpl2
1,155
/* * file_dvd.c * * ISO9660/Joliet DVD loading support * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #include "shared.h" #include "gui.h" #include "dvd.h" #include "unzip.h" #include "filesel.h" #include "file_fat.h" #include "file_dvd.h" /** Minimal ISO Directory Definition **/ #define RECLEN 0 /* Record length */ #define EXTENT 6 /* Extent */ #define FILE_LENGTH 14 /* File length (BIG ENDIAN) */ #define FILE_FLAGS 25 /* File flags */ #define FILENAME_LENGTH 32 /* Filename length */ #define FILENAME 33 /* ASCIIZ filename */ /** Minimal Primary Volume Descriptor **/ #define PVDROOT 0x9c /** Static Variables **/ static u64 rootdir = 0; static u64 basedir = 0; static int rootdirlength = 0; static int IsJoliet = 0; static int diroffset = 0; static int haveDVDdir = 0; static char dvdbuffer[DVDCHUNK]; /**************************************************************************** * Primary Volume Descriptor * * The PVD should reside between sector 16 and 31. * This is for single session DVD only. ****************************************************************************/ static int getpvd() { int sector = 16; u32 rootdir32; basedir = rootdirlength = 0; IsJoliet = -1; /** Look for Joliet PVD first **/ while (sector < 32) { if (dvd_read (&dvdbuffer, DVDCHUNK, (u64)(sector << 11))) { if (memcmp (&dvdbuffer, "\2CD001\1", 8) == 0) { memcpy(&rootdir32, &dvdbuffer[PVDROOT + EXTENT], 4); basedir = (u64)rootdir32; memcpy (&rootdirlength, &dvdbuffer[PVDROOT + FILE_LENGTH], 4); basedir <<= 11; IsJoliet = 1; break; } } else return 0; /*** Can't read sector! ***/ sector++; } if (IsJoliet > 0) return 1; /*** Joliet PVD Found ? ***/ /*** Look for standard ISO9660 PVD ***/ sector = 16; while (sector < 32) { if (dvd_read (&dvdbuffer, DVDCHUNK, (u64)(sector << 11))) { if (memcmp (&dvdbuffer, "\1CD001\1", 8) == 0) { memcpy (&rootdir32, &dvdbuffer[PVDROOT + EXTENT], 4); basedir = (u64)rootdir32; memcpy (&rootdirlength, &dvdbuffer[PVDROOT + FILE_LENGTH], 4); IsJoliet = 0; basedir <<= 11; break; } } else return 0; /*** Can't read sector! ***/ sector++; } return (IsJoliet == 0); } /**************************************************************************** * getentry * * Support function to return the next file entry, if any * Declared static to avoid accidental external entry. ****************************************************************************/ static int getentry(int entrycount) { char fname[512]; /* Huge, but experience has determined this */ char *ptr; char *filename; char *filenamelength; char *rr; int j; u32 offset32; /* Basic checks */ if (entrycount >= MAXFILES) return 0; if (diroffset >= DVDCHUNK) return 0; /** Decode this entry **/ if (dvdbuffer[diroffset]) /* Record length available */ { /* Update offsets into sector buffer */ ptr = (char *) &dvdbuffer[0]; ptr += diroffset; filename = ptr + FILENAME; filenamelength = ptr + FILENAME_LENGTH; /* Check for wrap round - illegal in ISO spec, * but certain crap writers do it! */ if ((diroffset + dvdbuffer[diroffset]) > DVDCHUNK) return 0; if (*filenamelength) { memset (&fname, 0, 512); /*** Do ISO 9660 first ***/ if (!IsJoliet) strcpy (fname, filename); else { /*** The more tortuous unicode joliet entries ***/ for (j = 0; j < (*filenamelength >> 1); j++) { fname[j] = filename[j * 2 + 1]; } fname[j] = 0; if (strlen (fname) >= MAXJOLIET) fname[MAXJOLIET - 1] = 0; if (strlen (fname) == 0) fname[0] = filename[0]; } if (strlen (fname) == 0) strcpy (fname, "."); else { if (fname[0] == 1) strcpy (fname, ".."); else { /* * Move *filenamelength to t, * Only to stop gcc warning for noobs :) */ int t = *filenamelength; fname[t] = 0; } } /** Rockridge Check **/ rr = strstr (fname, ";"); if (rr != NULL) *rr = 0; strcpy (filelist[entrycount].filename, fname); memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4); filelist[entrycount].offset = (u64)offset32; memcpy (&filelist[entrycount].length, &dvdbuffer[diroffset + FILE_LENGTH], 4); memcpy (&filelist[entrycount].flags, &dvdbuffer[diroffset + FILE_FLAGS], 1); filelist[entrycount].offset <<= 11; filelist[entrycount].flags = filelist[entrycount].flags & 2; /*** Prepare for next entry ***/ diroffset += dvdbuffer[diroffset]; return 1; } } return 0; } /*************************************************************************** * DVD_ClearDirectory * * Clear DVD directory flag ***************************************************************************/ void DVD_ClearDirectory(void) { haveDVDdir = 0; } /*************************************************************************** * DVD_UpdateDirectory * * Update DVD current root directory ***************************************************************************/ int DVD_UpdateDirectory(bool go_up, u64 offset, u32 length) { /* root has no parent directory */ if (go_up && (basedir == rootdir)) return 0; /* simply update current root directory */ rootdir = offset; rootdirlength = length; return 1; } /**************************************************************************** * DVD_ParseDirectory * * This function will parse the directory tree. * It relies on rootdir and rootdirlength being pre-populated by a call to * getpvd, a previous parse or a menu selection. * * The return value is number of files collected, or 0 on failure. ****************************************************************************/ int DVD_ParseDirectory(void) { int pdlength; u64 pdoffset; u64 rdoffset; int len = 0; int filecount = 0; pdoffset = rdoffset = rootdir; pdlength = rootdirlength; filecount = 0; /** Clear any existing values ***/ memset (&filelist, 0, sizeof (FILEENTRIES) * MAXFILES); /*** Get as many files as possible ***/ while (len < pdlength) { if (dvd_read (&dvdbuffer, DVDCHUNK, pdoffset) == 0) return 0; diroffset = 0; while (getentry (filecount)) { if (strcmp(filelist[filecount].filename,".") && (filecount < MAXFILES)) filecount++; } len += DVDCHUNK; pdoffset = rdoffset + len; } /* Sort the file list */ qsort(filelist, filecount, sizeof(FILEENTRIES), FileSortCallback); return filecount; } /**************************************************************************** * DVD_LoadFile * * This function will load a BIN, SMD or ZIP file from DVD into the ROM buffer. * The index values indicates the file position in filentry list * This functions return the actual size of data copied into the buffer * ****************************************************************************/ int DVD_LoadFile(u8 *buffer, u32 selection) { /* file size */ int length = filelist[selection].length; if (length > 0) { /* Read first data chunk */ char readbuffer[DVDCHUNK]; u64 discoffset = filelist[selection].offset; dvd_read (&readbuffer, DVDCHUNK, discoffset); /* determine file type */ if (!IsZipFile ((char *) readbuffer)) { char msg[50]; sprintf(msg,"Loading %d bytes...", length); GUI_MsgBoxOpen("Information",msg,1); /* How many 2k blocks to read */ int blocks = length / DVDCHUNK; int readoffset = 0; int i; /* read data chunks */ for (i = 0; i < blocks; i++) { dvd_read(readbuffer, DVDCHUNK, discoffset); discoffset += DVDCHUNK; memcpy (buffer + readoffset, readbuffer, DVDCHUNK); readoffset += DVDCHUNK; } /* final read */ i = length % DVDCHUNK; if (i) { dvd_read (readbuffer, DVDCHUNK, discoffset); memcpy (buffer + readoffset, readbuffer, i); } return length; } else { return UnZipBuffer (buffer, discoffset, NULL); } } return 0; } /**************************************************************************** * DVD_Open * * Function to load a DVD directory and display to user. ****************************************************************************/ int DVD_Open(void) { /* is DVD mounted ? */ if (!getpvd()) { /* mount DVD */ GUI_MsgBoxOpen("Information", "Mounting DVD ...",1); #ifdef HW_RVL u32 val; DI_GetCoverRegister(&val); if(val & 0x1) { GUI_WaitPrompt("Error","No Disc inserted !"); return 0; } DI_Mount(); while(DI_GetStatus() & DVD_INIT) usleep(10); if (!(DI_GetStatus() & DVD_READY)) { char msg[50]; sprintf(msg, "DI Status Error: 0x%08X !\n",DI_GetStatus()); GUI_WaitPrompt("Error",msg); return 0; } #else DVD_Mount(); #endif haveDVDdir = 0; if (!getpvd()) { GUI_WaitPrompt("Error","Disc can not be read !"); return 0; } GUI_MsgBoxClose(); } if (haveDVDdir == 0) { /* reset root directory */ rootdir = basedir; /* parse root directory */ int max = DVD_ParseDirectory (); if (max) { /* set DVD as default */ haveDVDdir = 1; FAT_ClearDirectory(); /* reset File selector */ ClearSelector(max); return 1; } else { /* no entries found */ GUI_WaitPrompt("Error","No files found !"); return 0; } } return 1; }
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/file_dvd.c
C
gpl2
11,048
/* * file_mem.c * * FAT and Memory Card SRAM/Savestate files managment * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" #include "file_mem.h" #include "file_fat.h" #include "dvd.h" #include "gui.h" #include "filesel.h" #include "saveicon.h" /* Global ROM filename */ char rom_filename[MAXJOLIET]; /* Support for MemCards */ /** * libOGC System Work Area */ static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32); static card_dir CardDir; static card_file CardFile; static card_stat CardStatus; /** * DMA Transfer Area. * Must be 32-byte aligned. * 64k SRAM + 2k Icon */ static u8 savebuffer[STATE_SIZE] ATTRIBUTE_ALIGN (32); /**************************************************************************** * SDCARD Access functions * * We use the same buffer as for Memory Card manager * Function returns TRUE on success. *****************************************************************************/ static int FAT_ManageFile(char *filename, u8 direction, u8 filetype) { char fname[MAXPATHLEN]; int done = 0; int filesize; /* build complete SDCARD filename */ sprintf (fname, "%s/saves/%s", DEFAULT_PATH, filename); /* open file */ FILE *fp = fopen(fname, direction ? "rb" : "wb"); if (fp == NULL) { GUI_WaitPrompt("Error","Unable to open file !"); return 0; } switch (direction) { case 0: /* SAVING */ if (filetype) /* SRAM */ { memcpy(savebuffer, sram.sram, 0x10000); sram.crc = crc32 (0, sram.sram, 0x10000); filesize = 0x10000; } else filesize = state_save(savebuffer); /* STATE */ /* write buffer (2k blocks) */ while (filesize > FATCHUNK) { fwrite(savebuffer + done, FATCHUNK, 1, fp); filesize -= FATCHUNK; done += FATCHUNK; } done += fwrite(savebuffer + done, filesize, 1, fp); fclose(fp); if (done < filesize) { GUI_WaitPrompt("Error","Unable to write file !"); return 0; } sprintf (fname, "Saved %d bytes successfully", done); GUI_WaitPrompt("Information",fname); return 1; case 1: /* LOADING */ /* read size */ fseek(fp , 0 , SEEK_END); filesize = ftell (fp); fseek(fp, 0, SEEK_SET); /* read into buffer (2k blocks) */ while (filesize > FATCHUNK) { fread(savebuffer + done, FATCHUNK, 1, fp); filesize -= FATCHUNK; done += FATCHUNK; } done += fread(savebuffer + done, filesize, 1, fp); fclose(fp); if (done < filesize) { GUI_WaitPrompt("Error","Unable to read file !"); return 0; } if (filetype) /* SRAM */ { memcpy(sram.sram, savebuffer, done); sram.crc = crc32 (0, sram.sram, 0x10000); } else { /* STATE */ if (!state_load(savebuffer)) { GUI_WaitPrompt("Error","File version is not compatible !"); return 0; } } sprintf (fname, "Loaded %d bytes successfully", done); GUI_WaitPrompt("Information",fname); return 1; } return 0; } /**************************************************************************** * MountTheCard * * libOGC provides the CARD_Mount function, and it should be all you need. * However, experience with previous emulators has taught me that you are * better off doing a little bit more than that! * * Function returns TRUE on success. *****************************************************************************/ static int MountTheCard (u8 slot) { int tries = 0; int CardError; *(unsigned long *) (0xcc006800) |= 1 << 13; /*** Disable Encryption ***/ #ifndef HW_RVL uselessinquiry (); #endif while (tries < 10) { VIDEO_WaitVSync (); CardError = CARD_Mount (slot, SysArea, NULL); /*** Don't need or want a callback ***/ if (CardError == 0) return 1; else EXI_ProbeReset (); tries++; } return 0; } /**************************************************************************** * CardFileExists * * Wrapper to search through the files on the card. * Returns TRUE if found. ****************************************************************************/ static int CardFileExists (char *filename, u8 slot) { int CardError = CARD_FindFirst (slot, &CardDir, TRUE); while (CardError != CARD_ERROR_NOFILE) { CardError = CARD_FindNext (&CardDir); if (strcmp ((char *) CardDir.filename, filename) == 0) return 1; } return 0; } /**************************************************************************** * FILE autoload (SRAM/FreezeState or Config File) * * *****************************************************************************/ void memfile_autoload(s8 autosram, s8 autostate) { /* this should be transparent to the user */ SILENT = 1; /* SRAM */ if (autosram != -1) ManageSRAM(1,autosram); /* STATE */ if (autostate != -1) ManageState(1,autostate); SILENT = 0; } void memfile_autosave(s8 autosram, s8 autostate) { int crccheck = crc32 (0, sram.sram, 0x10000); /* this should be transparent to the user */ SILENT = 1; /* SRAM */ if ((autosram != -1) && (crccheck != sram.crc)) ManageSRAM(0, autosram); /* STATE */ if (autostate != -1) ManageState(0,autostate); SILENT = 0; } /**************************************************************************** * ManageSRAM * * Here is the main SRAM Management stuff. * The output file contains an icon (2K), 64 bytes comment and the SRAM (64k). * As memcards are allocated in blocks of 8k or more, you have a around * 6k bytes to save/load any other data you wish without altering any of the * main save / load code. * * direction == 0 save, 1 load. ****************************************************************************/ int ManageSRAM (u8 direction, u8 device) { if (!cart.romsize) return 0; char filename[MAXJOLIET]; if (direction) GUI_MsgBoxOpen("Information","Loading SRAM ...",1); else GUI_MsgBoxOpen("Information","Saving SRAM ...",1); /* clean buffer */ memset(savebuffer, 0, STATE_SIZE); if (device == 0) { /* FAT support */ sprintf (filename, "%s.srm", rom_filename); return FAT_ManageFile(filename,direction,1); } /* Memory CARD support */ char action[80]; int CardError; unsigned int SectorSize; int blocks; char comment[2][32] = { {"Genesis Plus 1.2a"}, {"SRAM Save"} }; int outbytes = 0; int sbo; unsigned long inzipped,outzipped; /* First, build a filename */ sprintf (filename, "MD-%04X.srm", realchecksum); strcpy (comment[1], filename); /* set MCARD slot nr. */ u8 CARDSLOT = device - 1; /* Saving */ if (direction == 0) { /*** Build the output buffer ***/ memcpy (&savebuffer, &icon, 2048); memcpy (&savebuffer[2048], &comment[0], 64); inzipped = 0x10000; outzipped = 0x12000; compress2 ((Bytef *) &savebuffer[2112+sizeof(outzipped)], &outzipped, (Bytef *) &sram.sram, inzipped, 9); memcpy(&savebuffer[2112], &outzipped, sizeof(outzipped)); } outbytes = 2048 + 64 + outzipped + sizeof(outzipped); /*** Initialise the CARD system ***/ memset (&SysArea, 0, CARD_WORKAREA); CARD_Init ("GENP", "00"); /*** Attempt to mount the card ***/ CardError = MountTheCard (CARDSLOT); if (CardError) { /*** Retrieve the sector size ***/ CardError = CARD_GetSectorSize (CARDSLOT, &SectorSize); switch (direction) { case 0: /*** Saving ***/ /*** Determine number of blocks on this card ***/ blocks = (outbytes / SectorSize) * SectorSize; if (outbytes % SectorSize) blocks += SectorSize; /*** Check if a previous save exists ***/ if (CardFileExists (filename,CARDSLOT)) { CardError = CARD_Open (CARDSLOT, filename, &CardFile); if (CardError) { sprintf (action, "Unable to open file (%d)", CardError); GUI_WaitPrompt("Error",action); CARD_Unmount (CARDSLOT); return 0; } int size = CardFile.len; CARD_Close (&CardFile); if (size < blocks) { /* new size is bigger: check if there is enough space left */ CardError = CARD_Create (CARDSLOT, "TEMP", blocks-size, &CardFile); if (CardError) { sprintf (action, "Unable to create temporary file (%d)", CardError); GUI_WaitPrompt("Error",action); CARD_Unmount (CARDSLOT); return 0; } CARD_Close (&CardFile); CARD_Delete(CARDSLOT, "TEMP"); } /* always delete existing slot */ CARD_Delete(CARDSLOT, filename); } /*** Create a new slot ***/ CardError = CARD_Create (CARDSLOT, filename, blocks, &CardFile); if (CardError) { sprintf (action, "Unable to create new file (%d)", CardError); GUI_WaitPrompt("Error",action); CARD_Unmount (CARDSLOT); return 0; } /*** Continue and save ***/ CARD_GetStatus (CARDSLOT, CardFile.filenum, &CardStatus); CardStatus.icon_addr = 0x0; CardStatus.icon_fmt = 2; CardStatus.icon_speed = 1; CardStatus.comment_addr = 2048; CARD_SetStatus (CARDSLOT, CardFile.filenum, &CardStatus); /*** And write the blocks out ***/ sbo = 0; while (outbytes > 0) { CardError = CARD_Write (&CardFile, &savebuffer[sbo], SectorSize, sbo); outbytes -= SectorSize; sbo += SectorSize; } CARD_Close (&CardFile); CARD_Unmount (CARDSLOT); sram.crc = crc32 (0, &sram.sram[0], 0x10000); sprintf (action, "Saved %d bytes successfully", blocks); GUI_WaitPrompt("Information",action); return 1; default: /*** Loading ***/ if (!CardFileExists (filename,CARDSLOT)) { GUI_WaitPrompt("Error","File does not exist !"); CARD_Unmount (CARDSLOT); return 0; } memset (&CardFile, 0, sizeof (CardFile)); CardError = CARD_Open (CARDSLOT, filename, &CardFile); if (CardError) { sprintf (action, "Unable to open file (%d)", CardError); GUI_WaitPrompt("Error",action); CARD_Unmount (CARDSLOT); return 0; } blocks = CardFile.len; if (blocks < SectorSize) blocks = SectorSize; if (blocks % SectorSize) blocks++; /*** Just read the file back in ***/ sbo = 0; int size = blocks; while (blocks > 0) { CARD_Read (&CardFile, &savebuffer[sbo], SectorSize, sbo); sbo += SectorSize; blocks -= SectorSize; } CARD_Close (&CardFile); CARD_Unmount (CARDSLOT); /*** update SRAM ***/ memcpy(&inzipped,&savebuffer[2112],sizeof(inzipped)); outzipped = 0x10000; uncompress ((Bytef *) &sram.sram, &outzipped, (Bytef *) &savebuffer[2112+sizeof(inzipped)], inzipped); sram.crc = crc32 (0, &sram.sram[0], 0x10000); /*** Inform user ***/ sprintf (action, "Loaded %d bytes successfully", size); GUI_WaitPrompt("Information",action); return 1; } } GUI_WaitPrompt("Error","Unable to mount memory card"); return 0; } /**************************************************************************** * ManageState * * Here is the main Freeze File Management stuff. * The output file contains an icon (2K), 64 bytes comment and the STATE (~128k) * * direction == 0 save, 1 load. ****************************************************************************/ int ManageState (u8 direction, u8 device) { if (!cart.romsize) return 0; char filename[MAXJOLIET]; if (direction) GUI_MsgBoxOpen("Information","Loading State ...",1); else GUI_MsgBoxOpen("Information","Saving State ...",1); /* clean buffer */ memset(savebuffer, 0, STATE_SIZE); if (device == 0) { /* FAT support */ sprintf (filename, "%s.gpz", rom_filename); return FAT_ManageFile(filename,direction,0); } /* Memory CARD support */ char action[80]; int CardError; unsigned int SectorSize; int blocks; char comment[2][32] = { {"Genesis Plus 1.2a [FRZ]"}, {"Freeze State"} }; int outbytes = 0; int sbo; int state_size = 0; /* First, build a filename */ sprintf (filename, "MD-%04X.gpz", realchecksum); strcpy (comment[1], filename); /* set MCARD slot nr. */ u8 CARDSLOT = device - 1; /* Saving */ if (direction == 0) { /* Build the output buffer */ memcpy (&savebuffer, &icon, 2048); memcpy (&savebuffer[2048], &comment[0], 64); state_size = state_save(&savebuffer[2112]); } outbytes = 2048 + 64 + state_size; /*** Initialise the CARD system ***/ memset (&SysArea, 0, CARD_WORKAREA); CARD_Init ("GENP", "00"); /*** Attempt to mount the card ***/ CardError = MountTheCard (CARDSLOT); if (CardError) { /*** Retrieve the sector size ***/ CardError = CARD_GetSectorSize (CARDSLOT, &SectorSize); switch (direction) { case 0: /*** Saving ***/ /*** Determine number of blocks on this card ***/ blocks = (outbytes / SectorSize) * SectorSize; if (outbytes % SectorSize) blocks += SectorSize; /*** Check if a previous save exists ***/ if (CardFileExists (filename, CARDSLOT)) { CardError = CARD_Open (CARDSLOT, filename, &CardFile); if (CardError) { sprintf (action, "Unable to open file (%d)", CardError); GUI_WaitPrompt("Error",action); CARD_Unmount (CARDSLOT); return 0; } int size = CardFile.len; CARD_Close (&CardFile); if (size < blocks) { /* new size is bigger: check if there is enough space left */ CardError = CARD_Create (CARDSLOT, "TEMP", blocks-size, &CardFile); if (CardError) { sprintf (action, "Unable to create temporary file (%d)", CardError); GUI_WaitPrompt("Error",action); CARD_Unmount (CARDSLOT); return 0; } CARD_Close (&CardFile); CARD_Delete(CARDSLOT, "TEMP"); } /* always delete existing slot */ CARD_Delete(CARDSLOT, filename); } /*** Create a new slot ***/ CardError = CARD_Create (CARDSLOT, filename, blocks, &CardFile); if (CardError) { sprintf (action, "Unable to create new file (%d)", CardError); GUI_WaitPrompt("Error",action); CARD_Unmount (CARDSLOT); return 0; } /*** Continue and save ***/ CARD_GetStatus (CARDSLOT, CardFile.filenum, &CardStatus); CardStatus.icon_addr = 0x0; CardStatus.icon_fmt = 2; CardStatus.icon_speed = 1; CardStatus.comment_addr = 2048; CARD_SetStatus (CARDSLOT, CardFile.filenum, &CardStatus); /*** And write the blocks out ***/ sbo = 0; while (outbytes > 0) { CardError = CARD_Write (&CardFile, &savebuffer[sbo], SectorSize, sbo); outbytes -= SectorSize; sbo += SectorSize; } CARD_Close (&CardFile); CARD_Unmount (CARDSLOT); sprintf (action, "Saved %d bytes successfully", blocks); GUI_WaitPrompt("Information",action); return 1; default: /*** Loading ***/ if (!CardFileExists (filename, CARDSLOT)) { GUI_WaitPrompt("Error","File does not exist !"); CARD_Unmount (CARDSLOT); return 0; } memset (&CardFile, 0, sizeof (CardFile)); CardError = CARD_Open (CARDSLOT, filename, &CardFile); if (CardError) { sprintf (action, "Unable to open file (%d)", CardError); GUI_WaitPrompt("Error",action); CARD_Unmount (CARDSLOT); return 0; } blocks = CardFile.len; if (blocks < SectorSize) blocks = SectorSize; if (blocks % SectorSize) blocks++; /*** Just read the file back in ***/ sbo = 0; int size = blocks; while (blocks > 0) { CARD_Read (&CardFile, &savebuffer[sbo], SectorSize, sbo); sbo += SectorSize; blocks -= SectorSize; } CARD_Close (&CardFile); CARD_Unmount (CARDSLOT); /*** Load State ***/ state_load(&savebuffer[2112]); /*** Inform user ***/ sprintf (action, "Loaded %d bytes successfully", size); GUI_WaitPrompt("Information",action); return 1; } } GUI_WaitPrompt("Error","Unable to mount memory card !"); return 0; }
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/file_mem.c
C
gpl2
18,366
/* * file_fat.c * * FAT loading support * * Eke-Eke (2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #ifndef _FILE_FAT_H #define _FILE_FAT_H #define TYPE_RECENT 0 #define TYPE_SD 1 #ifdef HW_RVL #define TYPE_USB 2 #endif #define FATCHUNK (2048) extern void FAT_ClearDirectory(void); extern int FAT_UpdateDirectory(bool go_up, char *filename); extern int FAT_ParseDirectory(void); extern int FAT_LoadFile(u8* buffer,u32 selection); extern int FAT_Open(int type); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/file_fat.h
C
gpl2
1,314
/* * file_mem.c * * FAT and Memory Card SRAM/Savestate files managment * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #ifndef _FILE_MEM_H #define _FILE_MEM_H extern int ManageSRAM(u8 direction, u8 device); extern int ManageState(u8 direction, u8 device); extern void memfile_autosave(s8 autosram, s8 autostate); extern void memfile_autoload(s8 autosram, s8 autostate); extern char rom_filename[256]; #endif
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/file_mem.h
C
gpl2
1,263
/****************************************************************************** * * unzip.c * * Zip Support * * Only partial support is included, in that only the first file within the archive * is considered to be a ROM image. * * Softdev (2006) * Eke-Eke (2007,2008) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #include "shared.h" #include "dvd.h" #include "file_dvd.h" #include "file_fat.h" #include "gui.h" /* * PKWare Zip Header - adopted into zip standard */ #define PKZIPID 0x504b0304 #define MAXROM 0x500000 #define ZIPCHUNK 2048 /* * Zip file header definition */ typedef struct { unsigned int zipid __attribute__ ((__packed__)); // 0x04034b50 unsigned short zipversion __attribute__ ((__packed__)); unsigned short zipflags __attribute__ ((__packed__)); unsigned short compressionMethod __attribute__ ((__packed__)); unsigned short lastmodtime __attribute__ ((__packed__)); unsigned short lastmoddate __attribute__ ((__packed__)); unsigned int crc32 __attribute__ ((__packed__)); unsigned int compressedSize __attribute__ ((__packed__)); unsigned int uncompressedSize __attribute__ ((__packed__)); unsigned short filenameLength __attribute__ ((__packed__)); unsigned short extraDataLength __attribute__ ((__packed__)); } PKZIPHEADER; /* * Zip files are stored little endian * Support functions for short and int types */ static inline u32 FLIP32 (u32 b) { unsigned int c; c = (b & 0xff000000) >> 24; c |= (b & 0xff0000) >> 8; c |= (b & 0xff00) << 8; c |= (b & 0xff) << 24; return c; } static inline u16 FLIP16 (u16 b) { u16 c; c = (b & 0xff00) >> 8; c |= (b & 0xff) << 8; return c; } /**************************************************************************** * IsZipFile * * Returns TRUE when PKZIPID is first four characters of buffer ****************************************************************************/ int IsZipFile (char *buffer) { unsigned int *check; check = (unsigned int *) buffer; if (check[0] == PKZIPID) return 1; return 0; } /***************************************************************************** * UnZipBuffer * * It should be noted that there is a limit of 5MB total size for any ROM ******************************************************************************/ int UnZipBuffer (unsigned char *outbuffer, u64 discoffset, char *filename) { PKZIPHEADER pkzip; int zipoffset = 0; int zipchunk = 0; char out[ZIPCHUNK]; z_stream zs; int res; int bufferoffset = 0; int have = 0; char readbuffer[2048]; char msg[128]; FILE *fatfile = NULL; /*** FAT file support ***/ if (filename) { fatfile = fopen(filename, "rb"); if (fatfile == NULL) return 0; } /*** Read Zip Header ***/ if (fatfile) { fseek(fatfile, 0, SEEK_SET); fread(readbuffer, FATCHUNK, 1, fatfile); } else { dvd_read (&readbuffer, DVDCHUNK, discoffset); } /*** Copy PKZip header to local, used as info ***/ memcpy (&pkzip, &readbuffer, sizeof (PKZIPHEADER)); sprintf (msg, "Unzipping %d bytes ...", FLIP32 (pkzip.uncompressedSize)); GUI_MsgBoxOpen("Information",msg,1); /*** Prepare the zip stream ***/ memset (&zs, 0, sizeof (z_stream)); zs.zalloc = Z_NULL; zs.zfree = Z_NULL; zs.opaque = Z_NULL; zs.avail_in = 0; zs.next_in = Z_NULL; res = inflateInit2 (&zs, -MAX_WBITS); if (res != Z_OK) { GUI_WaitPrompt("Error","Unable to unzip file !"); return 0; } /*** Set ZipChunk for first pass ***/ zipoffset = (sizeof (PKZIPHEADER) + FLIP16 (pkzip.filenameLength) + FLIP16 (pkzip.extraDataLength)); zipchunk = ZIPCHUNK - zipoffset; /*** Now do it! ***/ do { zs.avail_in = zipchunk; zs.next_in = (Bytef *) & readbuffer[zipoffset]; /*** Now inflate until input buffer is exhausted ***/ do { zs.avail_out = ZIPCHUNK; zs.next_out = (Bytef *) & out; res = inflate (&zs, Z_NO_FLUSH); if (res == Z_MEM_ERROR) { inflateEnd (&zs); GUI_WaitPrompt("Error","Unable to unzip file !"); return 0; } have = ZIPCHUNK - zs.avail_out; if (have) { /*** Copy to normal block buffer ***/ memcpy (&outbuffer[bufferoffset], &out, have); bufferoffset += have; } } while (zs.avail_out == 0); /*** Readup the next 2k block ***/ zipoffset = 0; zipchunk = ZIPCHUNK; if (fatfile) { fread(readbuffer, FATCHUNK, 1, fatfile); } else { discoffset += DVDCHUNK; dvd_read (&readbuffer, DVDCHUNK, discoffset); } } while (res != Z_STREAM_END); inflateEnd (&zs); /* close file */ if (fatfile) fclose(fatfile); if (res == Z_STREAM_END) { if (FLIP32 (pkzip.uncompressedSize) == (u32) bufferoffset) return bufferoffset; else return FLIP32 (pkzip.uncompressedSize); } return 0; }
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/unzip.c
C
gpl2
5,874
/* * file_dvd.c * * ISO9660/Joliet DVD loading support * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #ifndef _FILE_DVD_H #define _FILE_DVD_H #define DVDCHUNK (2048) extern void DVD_ClearDirectory(void); extern int DVD_UpdateDirectory(bool go_up,u64 offset, u32 length); extern int DVD_ParseDirectory(void); extern int DVD_LoadFile(u8 *buffer,u32 selection); extern int DVD_Open(void); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/file_dvd.h
C
gpl2
1,255
/* * dvd.c * * Low-level DVD access * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #include "shared.h" #include "file_dvd.h" #include "gui.h" #ifndef HW_RVL static u64 DvdMaxOffset = 0x57057C00; /* 1.4 GB max. by default */ static vu32* const dvd = (u32*)0xCC006000; /* DVD I/O Address base */ static u8 *inquiry=(unsigned char *)0x80000004; /* pointer to drive ID */ #else static u64 DvdMaxOffset = 0x118244F00LL; /* 4.7 GB max. */ #endif static u8 DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32); /* data buffer for all DVD operations */ /*************************************************************************** * dvd_read * * Read DVD disc sectors ***************************************************************************/ u32 dvd_read (void *dst, u32 len, u64 offset) { /*** We only allow 2k reads **/ if (len > DVDCHUNK) return 0; /*** Let's not read past end of DVD ***/ if(offset < DvdMaxOffset) { unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer; DCInvalidateRange((void *)buffer, len); #ifndef HW_RVL dvd[0] = 0x2E; dvd[1] = 0; dvd[2] = 0xA8000000; dvd[3] = (u32)(offset >> 2); dvd[4] = len; dvd[5] = (u32) buffer; dvd[6] = len; dvd[7] = 3; /*** Enable reading with DMA ***/ while (dvd[7] & 1) usleep(10); memcpy (dst, buffer, len); /*** Ensure it has completed ***/ if (dvd[0] & 0x4) return 0; #else if (DI_ReadDVD(buffer, len >> 11, (u32)(offset >> 11))) return 0; memcpy (dst, buffer, len); #endif return 1; } return 0; } /**************************************************************************** * dvd_motor_off * * Stop the DVD Motor * * This can be used to prevent the Disc from spinning during playtime ****************************************************************************/ void dvd_motor_off( ) { GUI_MsgBoxOpen("Information", "Stopping DVD drive ...", 1); #ifndef HW_RVL dvd[0] = 0x2e; dvd[1] = 0; dvd[2] = 0xe3000000; dvd[3] = 0; dvd[4] = 0; dvd[5] = 0; dvd[6] = 0; dvd[7] = 1; // Do immediate while (dvd[7] & 1) usleep(10); /*** PSO Stops blackscreen at reload ***/ dvd[0] = 0x14; dvd[1] = 0; #else DI_StopMotor(); #endif GUI_MsgBoxClose(); } #ifndef HW_RVL /**************************************************************************** * uselessinquiry * * As the name suggests, this function is quite useless. * It's only purpose is to stop any pending DVD interrupts while we use the * memcard interface. * * libOGC tends to foul up if you don't, and sometimes does if you do! ****************************************************************************/ void uselessinquiry () { dvd[0] = 0; dvd[1] = 0; dvd[2] = 0x12000000; dvd[3] = 0; dvd[4] = 0x20; dvd[5] = 0x80000000; dvd[6] = 0x20; dvd[7] = 1; while (dvd[7] & 1) usleep(10); } /**************************************************************************** * dvd_drive_detect() * * Detect the DVD Drive Type * ****************************************************************************/ void dvd_drive_detect() { dvd[0] = 0x2e; dvd[1] = 0; dvd[2] = 0x12000000; dvd[3] = 0; dvd[4] = 0x20; dvd[5] = 0x80000000; dvd[6] = 0x20; dvd[7] = 3; while( dvd[7] & 1 ) usleep(10); DCFlushRange((void *)0x80000000, 32); int driveid = (int)inquiry[2]; if ((driveid == 4) || (driveid == 6) || (driveid == 8)) { /* Gamecube DVD Drive (1.4 GB)*/ DvdMaxOffset = 0x57057C00; } else { /* Wii DVD Drive (4.7GB) */ DvdMaxOffset = 0x118244F00LL; } } #endif
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/dvd.c
C
gpl2
4,615
/****************************************************************************** * * unzip.c * * Zip Support * * Only partial support is included, in that only the first file within the archive * is considered to be a ROM image. * * Softdev (2006) * Eke-Eke (2007,2008) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #ifndef _UNZIP_H_ #define _UNZIP_H_ extern int IsZipFile (char *buffer); int UnZipBuffer (unsigned char *outbuffer, u64 discoffset, char *filename); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/unzip.h
C
gpl2
1,308
/* * history.c * * Generic ROM history list managment * * Martin Disibio (6/17/08) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #include "shared.h" #include "history.h" t_history history; /**************************************************************************** * history_add_file * * Adds the given file path to the top of the history list, shifting each * existing entry in the history down one place. If given file path is * already in the list then the existing entry is (in effect) moved to the * top instead. ****************************************************************************/ void history_add_file(char *filepath, char *filename) { /* Create the new entry for this path. */ t_history_entry newentry; strncpy(newentry.filepath, filepath, MAXJOLIET - 1); strncpy(newentry.filename, filename, MAXJOLIET - 1); newentry.filepath[MAXJOLIET - 1] = '\0'; newentry.filename[MAXJOLIET - 1] = '\0'; t_history_entry oldentry; /* Old entry is the one being shuffled down a spot. */ t_history_entry currentry; /* Curr entry is the one that just replaced old path. */ /* Initially set curr entry to the new value. */ memcpy(&currentry, &newentry, sizeof(t_history_entry)); int i; for(i=0; i < NUM_HISTORY_ENTRIES; i++) { /* Save off the next entry. */ memcpy(&oldentry, &history.entries[i], sizeof(t_history_entry)); /* Overwrite with the previous entry. */ memcpy(&history.entries[i], &currentry, sizeof(t_history_entry)); /* Switch the old entry to the curr entry now. */ memcpy(&currentry, &oldentry, sizeof(t_history_entry)); /* If the entry in the list at this spot matches the new entry then do nothing and let this entry get deleted. */ if(strcmp(newentry.filepath, currentry.filepath) == 0 && strcmp(newentry.filename, currentry.filename) == 0) break; } /* now save to disk */ history_save(); } void history_save() { /* open file */ char fname[MAXPATHLEN]; sprintf (fname, "%s/history.ini", DEFAULT_PATH); FILE *fp = fopen(fname, "wb"); if (fp) { /* write file */ fwrite(&history, sizeof(history), 1, fp); fclose(fp); } } void history_load(void) { /* open file */ char fname[MAXPATHLEN]; sprintf (fname, "%s/history.ini", DEFAULT_PATH); FILE *fp = fopen(fname, "rb"); if (fp) { /* read file */ fread(&history, sizeof(history), 1, fp); fclose(fp); } } void history_default(void) { int i; for(i=0; i < NUM_HISTORY_ENTRIES; i++) { memset(&history.entries[i], 0, sizeof(t_history_entry)); } /* restore history */ history_load(); }
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/history.c
C
gpl2
3,535
/* * file_fat.c * * FAT loading support * * Eke-Eke (2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #include "shared.h" #include "gui.h" #include "history.h" #include "unzip.h" #include "filesel.h" #include "file_fat.h" #include "file_dvd.h" /* FAT directory has been updated */ static int haveFATdir = 0; /* current FAT directory */ static char fatdir[MAXPATHLEN]; /* current FAT device */ static int fat_type = 0; static int useHistory = 0; /*************************************************************************** * FAT_ClearDirectory * * Clear FAT directory flag ***************************************************************************/ void FAT_ClearDirectory(void) { haveFATdir = 0; } /*************************************************************************** * FAT_UpdateDirectory * * Update FAT current root directory ***************************************************************************/ int FAT_UpdateDirectory(bool go_up, char *filename) { int size=0; char *test; char temp[1024]; /* go up to parent directory */ if (strcmp(filename,"..") == 0) { /* determine last subdirectory namelength */ sprintf(temp,"%s",fatdir); test= strtok(temp,"/"); while (test != NULL) { size = strlen(test); test = strtok(NULL,"/"); } /* remove last subdirectory name */ size = strlen(fatdir) - size; fatdir[size-1] = 0; } else if (go_up) { /* root has no parent directory */ return 0; } else { /* by default, simply append folder name */ sprintf(fatdir, "%s%s/",fatdir, filename); } return 1; } /*************************************************************************** * FAT_ParseDirectory * * List files into one FAT directory ***************************************************************************/ int FAT_ParseDirectory(void) { int nbfiles = 0; char filename[MAXPATHLEN]; struct stat filestat; /* open directory */ DIR_ITER *dir = diropen (fatdir); if (dir == NULL) { GUI_WaitPrompt("Error","Unable to open directory !"); return -1; } while ((dirnext(dir, filename, &filestat) == 0) && (nbfiles < MAXFILES)) { if (strcmp(filename,".") != 0) { memset(&filelist[nbfiles], 0, sizeof (FILEENTRIES)); sprintf(filelist[nbfiles].filename,"%s",filename); filelist[nbfiles].length = filestat.st_size; filelist[nbfiles].flags = (filestat.st_mode & S_IFDIR) ? 1 : 0; nbfiles++; } } dirclose(dir); /* Sort the file list */ qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback); return nbfiles; } /**************************************************************************** * FAT_LoadFile * * This function will load a BIN, SMD or ZIP file from DVD into the ROM buffer. * This functions return the actual size of data copied into the buffer * ****************************************************************************/ int FAT_LoadFile(u8 *buffer, u32 selection) { /* If loading from history then we need to setup a few more things. */ if(useHistory) { /* Get the parent folder for the file. */ strncpy(fatdir, history.entries[selection].filepath, MAXJOLIET-1); fatdir[MAXJOLIET-1] = '\0'; /* Get the length of the file. This has to be done * before calling LoadFile(). */ char filepath[MAXJOLIET]; struct stat filestat; snprintf(filepath, MAXJOLIET-1, "%s%s", history.entries[selection].filepath, history.entries[selection].filename); filepath[MAXJOLIET-1] = '\0'; if(stat(filepath, &filestat) == 0) { filelist[selection].length = filestat.st_size; } /* update filelist */ haveFATdir = 0; } /* file size */ int length = filelist[selection].length; if (length > 0) { /* Add/move the file to the top of the history. */ history_add_file(fatdir, filelist[selection].filename); /* full filename */ char fname[MAXPATHLEN]; sprintf(fname, "%s%s",fatdir,filelist[selection].filename); /* open file */ FILE *sdfile = fopen(fname, "rb"); if (sdfile == NULL) { GUI_WaitPrompt("Error","Unable to open file !"); haveFATdir = 0; return 0; } /* Read first data chunk */ unsigned char temp[FATCHUNK]; fread(temp, FATCHUNK, 1, sdfile); fclose(sdfile); /* determine file type */ if (!IsZipFile ((char *) temp)) { /* re-open and read file */ sdfile = fopen(fname, "rb"); if (sdfile) { char msg[50]; sprintf(msg,"Loading %d bytes ...", length); GUI_MsgBoxOpen("Information",msg,1); int i = 0; while (length > FATCHUNK) { fread(buffer+i, FATCHUNK, 1, sdfile); length -= FATCHUNK; i += FATCHUNK; } fread(buffer+i, length, 1, sdfile); fclose(sdfile); return filelist[selection].length; } } else { /* unzip file */ return UnZipBuffer (buffer, 0, fname); } } return 0; } /**************************************************************************** * OpenFAT * * Function to load a FAT directory and display to user. ****************************************************************************/ int FAT_Open(int type) { int max = 0; char root[10] = ""; /* FAT header */ #ifdef HW_RVL if (type == TYPE_SD) sprintf (root, "sd:"); else if (type == TYPE_USB) sprintf (root, "usb:"); #endif /* if FAT device type changed, reload filelist */ if (fat_type != type) { fat_type = type; haveFATdir = 0; } /* update filelist */ if (haveFATdir == 0) { useHistory = 0; if (type == TYPE_RECENT) { /* fetch history list */ useHistory = 1; int i; for(i=0; i < NUM_HISTORY_ENTRIES; i++) { if(history.entries[i].filepath[0] > 0) { filelist[i].offset = 0; filelist[i].length = 0; filelist[i].flags = 0; strncpy(filelist[i].filename, history.entries[i].filename, MAXJOLIET-1); filelist[i].filename[MAXJOLIET-1] = '\0'; max++; } else { /* Found the end of the list. */ break; } } } else { /* reset root directory */ sprintf (fatdir, "%s%s/roms/", root, DEFAULT_PATH); /* if directory doesn't exist, use root as default */ DIR_ITER *dir = diropen(fatdir); if (dir == NULL) sprintf (fatdir, "%s/", root); else dirclose(dir); /* parse root directory */ max = FAT_ParseDirectory (); } if (max > 0) { /* FAT is default */ haveFATdir = 1; DVD_ClearDirectory(); /* reset File selector */ ClearSelector(max); return 1; } else { /* no entries found */ if (max == 0) GUI_WaitPrompt("Error","No files found !"); return 0; } } return 1; }
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/file_fat.c
C
gpl2
8,020
<html> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/fileio/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:07:59 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> <head><title>genplus-gx - Revision 427: /trunk/source/gx/fileio</title></head> <body> <h2>genplus-gx - Revision 427: /trunk/source/gx/fileio</h2> <ul> <li><a href="../index.html">..</a></li> <li><a href="dvd.c">dvd.c</a></li> <li><a href="dvd.h">dvd.h</a></li> <li><a href="file_dvd.c">file_dvd.c</a></li> <li><a href="file_dvd.h">file_dvd.h</a></li> <li><a href="file_fat.c">file_fat.c</a></li> <li><a href="file_fat.h">file_fat.h</a></li> <li><a href="file_mem.c">file_mem.c</a></li> <li><a href="file_mem.h">file_mem.h</a></li> <li><a href="history.c">history.c</a></li> <li><a href="history.h">history.h</a></li> <li><a href="unzip.c">unzip.c</a></li> <li><a href="unzip.h">unzip.h</a></li> </ul> <hr noshade><em><a href="http://code.google.com/">Google Code</a> powered by <a href="http://subversion.apache.org/">Subversion</a></em> </body> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/fileio/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:08:07 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> </html>
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/index.html
HTML
gpl2
1,452
/* * history.c * * Generic ROM history list managment * * Martin Disibio (6/17/08) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ********************************************************************************/ #ifndef _HISTORY_H #define _HISTORY_H #include "filesel.h" #define NUM_HISTORY_ENTRIES (10) /**************************************************************************** * ROM Play History * ****************************************************************************/ typedef struct { char filepath[MAXJOLIET]; char filename[MAXJOLIET]; } t_history_entry; typedef struct { t_history_entry entries[NUM_HISTORY_ENTRIES]; } t_history; extern t_history history; extern void history_add_file(char *filepath, char *filename); extern void history_save(void); extern void history_load(void); extern void history_default(void); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/fileio/history.h
C
gpl2
1,615
#ifndef _OSD_H_ #define _OSD_H_ #define NGC 1 #include <gccore.h> #include <ogcsys.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h> #include <sys/dir.h> #include <asndlib.h> #include <oggplayer.h> #ifdef HW_RVL #include <di/di.h> #endif #include "gx_input.h" #include "gx_audio.h" #include "gx_video.h" #include "config.h" #include "file_mem.h" #define DEFAULT_PATH "/genplus" #define GG_ROM "/genplus/ggenie.bin" #define AR_ROM "/genplus/areplay.bin" #define OS_ROM "/genplus/bios.bin" #define SK_ROM "/genplus/sk.bin" #define SK_UPMEM "/genplus/sk2chip.bin" #ifdef HW_RVL #define VERSION "version 1.4.0W" #else #define VERSION "version 1.4.0G" #endif #define osd_input_Update() gx_input_UpdateEmu() /* globals */ extern void error(char *format, ...); extern void ClearGGCodes(); extern void GetGGEntries(); extern void MainMenu(void); extern void legal(); extern void reloadrom (int size, char *name); extern void shutdown(); extern u32 frameticker; extern u32 Shutdown; #endif /* _OSD_H_ */
zyking1987-genplus-droid
genplusgx/unused/gx/osd.h
C
gpl2
1,126
/**************************************************************************** * gx_audio.c * * Genesis Plus GX audio support * * Softdev (2006) * Eke-Eke (2007,2008,2009) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #ifndef _GC_AUDIO_H_ #define _GC_AUDIO_H_ extern u8 soundbuffer[2][3840]; extern u32 mixbuffer; extern u32 audioStarted; extern void gx_audio_Init(void); extern void gx_audio_Shutdown(void); extern void gx_audio_Start(void); extern void gx_audio_Stop(void); extern void gx_audio_Update(void); #endif
zyking1987-genplus-droid
genplusgx/unused/gx/gx_audio.h
C
gpl2
1,331
<html> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:07:20 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> <head><title>genplus-gx - Revision 427: /trunk/source/gx</title></head> <body> <h2>genplus-gx - Revision 427: /trunk/source/gx</h2> <ul> <li><a href="../index.html">..</a></li> <li><a href="aram.c">aram.c</a></li> <li><a href="aram.h">aram.h</a></li> <li><a href="config.c">config.c</a></li> <li><a href="config.h">config.h</a></li> <li><a href="fileio/index.html">fileio/</a></li> <li><a href="gui/index.html">gui/</a></li> <li><a href="gx_audio.c">gx_audio.c</a></li> <li><a href="gx_audio.h">gx_audio.h</a></li> <li><a href="gx_input.c">gx_input.c</a></li> <li><a href="gx_input.h">gx_input.h</a></li> <li><a href="gx_video.c">gx_video.c</a></li> <li><a href="gx_video.h">gx_video.h</a></li> <li><a href="images/index.html">images/</a></li> <li><a href="main.c">main.c</a></li> <li><a href="osd.h">osd.h</a></li> <li><a href="sounds/index.html">sounds/</a></li> <li><a href="vi_encoder.c">vi_encoder.c</a></li> <li><a href="vi_encoder.h">vi_encoder.h</a></li> </ul> <hr noshade><em><a href="http://code.google.com/">Google Code</a> powered by <a href="http://subversion.apache.org/">Subversion</a></em> </body> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:07:25 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> </html>
zyking1987-genplus-droid
genplusgx/unused/gx/index.html
HTML
gpl2
1,718
/**************************************************************************** * config.c * * Genesis Plus GX configuration file support * * Eke-Eke (2008) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #include "shared.h" void config_save(void) { /* open configuration file */ char fname[MAXPATHLEN]; sprintf (fname, "%s/config.ini", DEFAULT_PATH); FILE *fp = fopen(fname, "wb"); if (fp) { /* write file */ fwrite(&config, sizeof(config), 1, fp); fclose(fp); } } void config_load(void) { /* open configuration file */ char fname[MAXPATHLEN]; sprintf (fname, "%s/config.ini", DEFAULT_PATH); FILE *fp = fopen(fname, "rb"); if (fp) { /* read version */ char version[16]; fread(version, 16, 1, fp); fclose(fp); if (strcmp(version,VERSION)) return; /* read file */ fp = fopen(fname, "rb"); if (fp) { fread(&config, sizeof(config), 1, fp); fclose(fp); } } } void config_default(void) { /* version TAG */ strncpy(config.version,VERSION,16); /* sound options */ config.psg_preamp = 150; config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 0; config.filter = 1; config.lp_range = 50; config.low_freq = 880; config.high_freq = 5000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; config.rolloff = 0.995; config.dac_bits = 14; /* system options */ config.region_detect = 0; config.force_dtack = 0; config.addr_error = 1; config.bios_enabled = 0; config.lock_on = 0; config.romtype = 0; config.hot_swap = 0; /* video options */ config.xshift = 0; config.yshift = 0; config.xscale = 0; config.yscale = 0; config.aspect = 1; config.overscan = 1; if (VIDEO_HaveComponentCable()) config.render = 2; else config.render = 0; config.ntsc = 0; config.bilinear = 1; #ifdef HW_RVL config.trap = 1; config.gamma = VI_GM_1_0 / 10.0; #endif /* controllers options */ config.gun_cursor[0] = 1; config.gun_cursor[1] = 1; config.invert_mouse = 0; gx_input_SetDefault(); /* menu options */ #ifdef HW_RVL config.sram_auto = 0; #else config.sram_auto = -1; #endif config.state_auto = -1; config.bg_color = 0; config.screen_w = 658; config.ask_confirm = 0; config.bgm_volume = 100.0; config.sfx_volume = 100.0; /* restore saved configuration */ config_load(); io_init(); }
zyking1987-genplus-droid
genplusgx/unused/gx/config.c
C
gpl2
3,452
/**************************************************************************** * config.c * * Genesis Plus GX configuration file support * * Eke-Eke (2008) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #ifndef _CONFIG_H_ #define _CONFIG_H_ /**************************************************************************** * Config Option * ****************************************************************************/ typedef struct { char version[16]; uint8 hq_fm; uint8 psgBoostNoise; int32 psg_preamp; int32 fm_preamp; uint8 filter; int16 lp_range; int16 low_freq; int16 high_freq; float lg; float mg; float hg; float rolloff; uint8 dac_bits; uint8 region_detect; uint8 force_dtack; uint8 addr_error; uint8 bios_enabled; uint8 lock_on; uint8 hot_swap; uint8 romtype; int16 xshift; int16 yshift; int16 xscale; int16 yscale; uint8 tv_mode; uint8 aspect; uint8 overscan; uint8 render; uint8 ntsc; uint8 bilinear; #ifdef HW_RVL uint8 trap; float gamma; #endif uint8 gun_cursor[2]; uint8 invert_mouse; uint16 pad_keymap[4][MAX_KEYS]; uint32 wpad_keymap[4*3][MAX_KEYS]; t_input_config input[MAX_INPUTS]; int8 sram_auto; int8 state_auto; int8 bg_color; int16 screen_w; uint8 ask_confirm; float bgm_volume; float sfx_volume; } t_config; /* Global data */ t_config config; extern void config_save(void); extern void config_load(void); extern void config_default(void); #endif /* _CONFIG_H_ */
zyking1987-genplus-droid
genplusgx/unused/gx/config.h
C
gpl2
2,347
<html> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/images/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:08:23 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> <head><title>genplus-gx - Revision 427: /trunk/source/gx/images</title></head> <body> <h2>genplus-gx - Revision 427: /trunk/source/gx/images</h2> <ul> <li><a href="../index.html">..</a></li> <li><a href="Banner_bottom.png">Banner_bottom.png</a></li> <li><a href="Banner_main.png">Banner_main.png</a></li> <li><a href="Banner_top.png">Banner_top.png</a></li> <li><a href="Bg_credits.png">Bg_credits.png</a></li> <li><a href="Bg_intro_c1.png">Bg_intro_c1.png</a></li> <li><a href="Bg_intro_c2.png">Bg_intro_c2.png</a></li> <li><a href="Bg_intro_c3.png">Bg_intro_c3.png</a></li> <li><a href="Bg_intro_c4.png">Bg_intro_c4.png</a></li> <li><a href="Bg_intro_c5.png">Bg_intro_c5.png</a></li> <li><a href="Bg_main.png">Bg_main.png</a></li> <li><a href="Bg_overlay.png">Bg_overlay.png</a></li> <li><a href="Browser_dir.png">Browser_dir.png</a></li> <li><a href="Button_arrow.png">Button_arrow.png</a></li> <li><a href="Button_arrow_over.png">Button_arrow_over.png</a></li> <li><a href="Button_delete.png">Button_delete.png</a></li> <li><a href="Button_delete_over.png">Button_delete_over.png</a></li> <li><a href="Button_down.png">Button_down.png</a></li> <li><a href="Button_down_over.png">Button_down_over.png</a></li> <li><a href="Button_icon.png">Button_icon.png</a></li> <li><a href="Button_icon_over.png">Button_icon_over.png</a></li> <li><a href="Button_icon_sm.png">Button_icon_sm.png</a></li> <li><a href="Button_icon_sm_over.png">Button_icon_sm_over.png</a></li> <li><a href="Button_load.png">Button_load.png</a></li> <li><a href="Button_load_over.png">Button_load_over.png</a></li> <li><a href="Button_special.png">Button_special.png</a></li> <li><a href="Button_special_over.png">Button_special_over.png</a></li> <li><a href="Button_text.png">Button_text.png</a></li> <li><a href="Button_text_over.png">Button_text_over.png</a></li> <li><a href="Button_up.png">Button_up.png</a></li> <li><a href="Button_up_over.png">Button_up_over.png</a></li> <li><a href="Crosshair_p1.png">Crosshair_p1.png</a></li> <li><a href="Crosshair_p2.png">Crosshair_p2.png</a></li> <li><a href="Ctrl_4wayplay.png">Ctrl_4wayplay.png</a></li> <li><a href="Ctrl_config.png">Ctrl_config.png</a></li> <li><a href="Ctrl_gamepad.png">Ctrl_gamepad.png</a></li> <li><a href="Ctrl_justifiers.png">Ctrl_justifiers.png</a></li> <li><a href="Ctrl_menacer.png">Ctrl_menacer.png</a></li> <li><a href="Ctrl_mouse.png">Ctrl_mouse.png</a></li> <li><a href="Ctrl_none.png">Ctrl_none.png</a></li> <li><a href="Ctrl_pad3b.png">Ctrl_pad3b.png</a></li> <li><a href="Ctrl_pad6b.png">Ctrl_pad6b.png</a></li> <li><a href="Ctrl_player.png">Ctrl_player.png</a></li> <li><a href="Ctrl_player_none.png">Ctrl_player_none.png</a></li> <li><a href="Ctrl_player_over.png">Ctrl_player_over.png</a></li> <li><a href="Ctrl_teamplayer.png">Ctrl_teamplayer.png</a></li> <li><a href="Frame_s1.png">Frame_s1.png</a></li> <li><a href="Frame_s1_title.png">Frame_s1_title.png</a></li> <li><a href="Frame_s2.png">Frame_s2.png</a></li> <li><a href="Frame_s3.png">Frame_s3.png</a></li> <li><a href="Frame_s4.png">Frame_s4.png</a></li> <li><a href="Frame_s4_title.png">Frame_s4_title.png</a></li> <li><a href="Frame_throbber.png">Frame_throbber.png</a></li> <li><a href="Key_A_gcn.png">Key_A_gcn.png</a></li> <li><a href="Key_A_wii.png">Key_A_wii.png</a></li> <li><a href="Key_B_gcn.png">Key_B_gcn.png</a></li> <li><a href="Key_B_wii.png">Key_B_wii.png</a></li> <li><a href="Key_home.png">Key_home.png</a></li> <li><a href="Load_dvd.png">Load_dvd.png</a></li> <li><a href="Load_recent.png">Load_recent.png</a></li> <li><a href="Load_sd.png">Load_sd.png</a></li> <li><a href="Load_usb.png">Load_usb.png</a></li> <li><a href="Main_file.png">Main_file.png</a></li> <li><a href="Main_ggenie.png">Main_ggenie.png</a></li> <li><a href="Main_load.png">Main_load.png</a></li> <li><a href="Main_logo.png">Main_logo.png</a></li> <li><a href="Main_options.png">Main_options.png</a></li> <li><a href="Main_play_gcn.png">Main_play_gcn.png</a></li> <li><a href="Main_play_wii.png">Main_play_wii.png</a></li> <li><a href="Main_quit.png">Main_quit.png</a></li> <li><a href="Main_reset.png">Main_reset.png</a></li> <li><a href="Main_showinfo.png">Main_showinfo.png</a></li> <li><a href="Main_takeshot.png">Main_takeshot.png</a></li> <li><a href="Option_ctrl.png">Option_ctrl.png</a></li> <li><a href="Option_menu.png">Option_menu.png</a></li> <li><a href="Option_sound.png">Option_sound.png</a></li> <li><a href="Option_system.png">Option_system.png</a></li> <li><a href="Option_video.png">Option_video.png</a></li> <li><a href="Overlay_bar.png">Overlay_bar.png</a></li> <li><a href="Overlay_item.png">Overlay_item.png</a></li> <li><a href="Overlay_item_over.png">Overlay_item_over.png</a></li> <li><a href="Progress_bar.png">Progress_bar.png</a></li> <li><a href="Snap_empty.png">Snap_empty.png</a></li> <li><a href="Snap_frame.png">Snap_frame.png</a></li> <li><a href="Star_empty.png">Star_empty.png</a></li> <li><a href="Star_full.png">Star_full.png</a></li> <li><a href="ctrl_classic.png">ctrl_classic.png</a></li> <li><a href="ctrl_gamecube.png">ctrl_gamecube.png</a></li> <li><a href="ctrl_nunchuk.png">ctrl_nunchuk.png</a></li> <li><a href="ctrl_option_off.png">ctrl_option_off.png</a></li> <li><a href="ctrl_option_on.png">ctrl_option_on.png</a></li> <li><a href="ctrl_wiimote.png">ctrl_wiimote.png</a></li> <li><a href="generic_point.png">generic_point.png</a></li> </ul> <hr noshade><em><a href="http://code.google.com/">Google Code</a> powered by <a href="http://subversion.apache.org/">Subversion</a></em> </body> <!-- Mirrored from genplus-gx.googlecode.com/svn/!svn/bc/427/trunk/source/gx/images/ by HTTrack Website Copier/3.x [XR&CO'2010], Mon, 13 Dec 2010 08:09:21 GMT --> <!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8"><!-- /Added by HTTrack --> </html>
zyking1987-genplus-droid
genplusgx/unused/gx/images/index.html
HTML
gpl2
6,308
#ifndef _FILEIO_H_ #define _FILEIO_H_ /* Global variables */ extern int cart_size; extern char cart_name[0x100]; /* Function prototypes */ uint8 *load_archive(char *filename, int *file_size); int load_cart(char *filename); int check_zip(char *filename); int gzsize(gzFile *gd); #endif /* _FILEIO_H_ */
zyking1987-genplus-droid
genplusgx/unused/win/fileio.h
C
gpl2
319
/* error.c -- Error logging */ #include "osd.h" FILE *error_log; struct { int enabled; int verbose; FILE *log; } t_error; void error_init(void) { #ifdef LOGERROR error_log = fopen("error.log","w"); #endif } void error_shutdown(void) { if(error_log) fclose(error_log); } void error(char *format, ...) { if (!log_error) return; va_list ap; va_start(ap, format); if(error_log) vfprintf(error_log, format, ap); va_end(ap); }
zyking1987-genplus-droid
genplusgx/unused/win/error.c
C
gpl2
493
#include <windows.h> #include "SDL.h" #include "SDL_thread.h" #include "shared.h" #include "sms_ntsc.h" #include "md_ntsc.h" #define SOUND_FREQUENCY 48000 #define SOUND_SAMPLES_SIZE 2048 #define VIDEO_WIDTH 320 #define VIDEO_HEIGHT 240 int joynum = 0; int log_error = 0; int debug_on = 0; int turbo_mode = 0; int use_sound = 1; int fullscreen = 0; /* SDL_FULLSCREEN */ /* sound */ struct { char* current_pos; char* buffer; int current_emulated_samples; } sdl_sound; static void sdl_sound_callback(void *userdata, Uint8 *stream, int len) { if(sdl_sound.current_emulated_samples < len) { memset(stream, 0, len); } else { memcpy(stream, sdl_sound.buffer, len); /* loop to compensate desync */ do { sdl_sound.current_emulated_samples -= len; } while(sdl_sound.current_emulated_samples > 2 * len); memcpy(sdl_sound.buffer, sdl_sound.current_pos - sdl_sound.current_emulated_samples, sdl_sound.current_emulated_samples); sdl_sound.current_pos = sdl_sound.buffer + sdl_sound.current_emulated_samples; } } static int sdl_sound_init() { int n; SDL_AudioSpec as_desired, as_obtained; if(SDL_Init(SDL_INIT_AUDIO) < 0) { MessageBox(NULL, "SDL Audio initialization failed", "Error", 0); return 0; } as_desired.freq = SOUND_FREQUENCY; as_desired.format = AUDIO_S16LSB; as_desired.channels = 2; as_desired.samples = SOUND_SAMPLES_SIZE; as_desired.callback = sdl_sound_callback; if(SDL_OpenAudio(&as_desired, &as_obtained) == -1) { MessageBox(NULL, "SDL Audio open failed", "Error", 0); return 0; } if(as_desired.samples != as_obtained.samples) { MessageBox(NULL, "SDL Audio wrong setup", "Error", 0); return 0; } sdl_sound.current_emulated_samples = 0; n = SOUND_SAMPLES_SIZE * 2 * sizeof(short) * 11; sdl_sound.buffer = (char*)malloc(n); if(!sdl_sound.buffer) { MessageBox(NULL, "Can't allocate audio buffer", "Error", 0); return 0; } memset(sdl_sound.buffer, 0, n); sdl_sound.current_pos = sdl_sound.buffer; return 1; } static void sdl_sound_update() { int i; short* p; int size = audio_update(); if (use_sound) { SDL_LockAudio(); p = (short*)sdl_sound.current_pos; for(i = 0; i < size; ++i) { *p = snd.buffer[0][i]; ++p; *p = snd.buffer[1][i]; ++p; } sdl_sound.current_pos = (char*)p; sdl_sound.current_emulated_samples += size * 2 * sizeof(short); SDL_UnlockAudio(); } } static void sdl_sound_close() { SDL_PauseAudio(1); SDL_CloseAudio(); if (sdl_sound.buffer) free(sdl_sound.buffer); } /* video */ md_ntsc_t *md_ntsc; sms_ntsc_t *sms_ntsc; struct { SDL_Surface* surf_screen; SDL_Surface* surf_bitmap; SDL_Rect srect; SDL_Rect drect; Uint32 frames_rendered; } sdl_video; static int sdl_video_init() { if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { MessageBox(NULL, "SDL Video initialization failed", "Error", 0); return 0; } sdl_video.surf_screen = SDL_SetVideoMode(VIDEO_WIDTH, VIDEO_HEIGHT, 16, SDL_SWSURFACE | fullscreen); sdl_video.surf_bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, 720, 576, 16, 0, 0, 0, 0); sdl_video.frames_rendered = 0; SDL_ShowCursor(0); return 1; } static void sdl_video_update() { system_frame(0); /* viewport size changed */ if(bitmap.viewport.changed & 1) { bitmap.viewport.changed &= ~1; /* source bitmap */ sdl_video.srect.w = bitmap.viewport.w+2*bitmap.viewport.x; sdl_video.srect.h = bitmap.viewport.h+2*bitmap.viewport.y; sdl_video.srect.x = 0; sdl_video.srect.y = 0; if (sdl_video.srect.w > VIDEO_WIDTH) { sdl_video.srect.x = (sdl_video.srect.w - VIDEO_WIDTH) / 2; sdl_video.srect.w = VIDEO_WIDTH; } if (sdl_video.srect.h > VIDEO_HEIGHT) { sdl_video.srect.y = (sdl_video.srect.h - VIDEO_HEIGHT) / 2; sdl_video.srect.h = VIDEO_HEIGHT; } /* destination bitmap */ sdl_video.drect.w = sdl_video.srect.w; sdl_video.drect.h = sdl_video.srect.h; sdl_video.drect.x = (VIDEO_WIDTH - sdl_video.drect.w) / 2; sdl_video.drect.y = (VIDEO_HEIGHT - sdl_video.drect.h) / 2; /* clear destination surface */ SDL_FillRect(sdl_video.surf_screen, 0, 0); /*if (config.render && (interlaced || config.ntsc)) rect.h *= 2; if (config.ntsc) rect.w = (reg[12]&1) ? MD_NTSC_OUT_WIDTH(rect.w) : SMS_NTSC_OUT_WIDTH(rect.w); if (config.ntsc) { sms_ntsc = (sms_ntsc_t *)malloc(sizeof(sms_ntsc_t)); md_ntsc = (md_ntsc_t *)malloc(sizeof(md_ntsc_t)); switch (config.ntsc) { case 1: sms_ntsc_init(sms_ntsc, &sms_ntsc_composite); md_ntsc_init(md_ntsc, &md_ntsc_composite); break; case 2: sms_ntsc_init(sms_ntsc, &sms_ntsc_svideo); md_ntsc_init(md_ntsc, &md_ntsc_svideo); break; case 3: sms_ntsc_init(sms_ntsc, &sms_ntsc_rgb); md_ntsc_init(md_ntsc, &md_ntsc_rgb); break; } } else { if (sms_ntsc) { free(sms_ntsc); sms_ntsc = NULL; } if (md_ntsc) { free(md_ntsc); md_ntsc = NULL; } } */ } SDL_BlitSurface(sdl_video.surf_bitmap, &sdl_video.srect, sdl_video.surf_screen, &sdl_video.drect); SDL_UpdateRect(sdl_video.surf_screen, 0, 0, 0, 0); ++sdl_video.frames_rendered; } static void sdl_video_close() { if (sdl_video.surf_bitmap) SDL_FreeSurface(sdl_video.surf_bitmap); if (sdl_video.surf_screen) SDL_FreeSurface(sdl_video.surf_screen); } /* Timer Sync */ struct { SDL_sem* sem_sync; unsigned ticks; } sdl_sync; /* sync */ static Uint32 sdl_sync_timer_callback(Uint32 interval) { SDL_SemPost(sdl_sync.sem_sync); char caption[100]; sdl_sync.ticks++; if (sdl_sync.ticks == (vdp_pal ? 50 : 20)) { int fps = vdp_pal ? (sdl_video.frames_rendered / 3) : sdl_video.frames_rendered; sdl_sync.ticks = sdl_video.frames_rendered = 0; sprintf(caption,"%d fps - %s ", fps, rominfo.international); SDL_WM_SetCaption(caption, NULL); } return interval; } static int sdl_sync_init() { if(SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_EVENTTHREAD) < 0) { MessageBox(NULL, "SDL Timer initialization failed", "Error", 0); return 0; } sdl_sync.sem_sync = SDL_CreateSemaphore(0); sdl_sync.ticks = 0; return 1; } static void sdl_sync_close() { if(sdl_sync.sem_sync) SDL_DestroySemaphore(sdl_sync.sem_sync); } static int sdl_control_update(SDLKey keystate) { switch (keystate) { case SDLK_TAB: { system_init(); system_reset(); break; } case SDLK_F2: { if (fullscreen) fullscreen = 0; else fullscreen = SDL_FULLSCREEN; sdl_video.surf_screen = SDL_SetVideoMode(VIDEO_WIDTH, VIDEO_HEIGHT, 16, SDL_SWSURFACE | fullscreen); break; } case SDLK_F3: { config.render ^=1; break; } case SDLK_F4: { if (!turbo_mode) use_sound ^= 1; break; } case SDLK_F5: { log_error ^= 1; break; } case SDLK_F6: { if (!use_sound) turbo_mode ^=1; break; } case SDLK_F7: { FILE *f = fopen("game.gpz","r+b"); if (f) { uint8 buf[STATE_SIZE]; fread(&buf, STATE_SIZE, 1, f); state_load(buf); fclose(f); } break; } case SDLK_F8: { FILE *f = fopen("game.gpz","w+b"); if (f) { uint8 buf[STATE_SIZE]; state_save(buf); fwrite(&buf, STATE_SIZE, 1, f); fclose(f); } break; } case SDLK_F9: { vdp_pal ^= 1; /* save YM2612 context */ unsigned char *temp = malloc(YM2612GetContextSize()); if (temp) memcpy(temp, YM2612GetContextPtr(), YM2612GetContextSize()); /* reinitialize all timings */ audio_init(snd.sample_rate, snd.frame_rate); system_init(); /* restore YM2612 context */ if (temp) { YM2612Restore(temp); free(temp); } /* reinitialize VC max value */ static const uint16 vc_table[4][2] = { /* NTSC, PAL */ {0xDA , 0xF2}, /* Mode 4 (192 lines) */ {0xEA , 0x102}, /* Mode 5 (224 lines) */ {0xDA , 0xF2}, /* Mode 4 (192 lines) */ {0x106, 0x10A} /* Mode 5 (240 lines) */ }; vc_max = vc_table[(reg[1] >> 2) & 3][vdp_pal]; /* reinitialize display area */ bitmap.viewport.changed = 3; break; } case SDLK_F10: { gen_softreset(1); gen_softreset(0); break; } case SDLK_F11: { config.overscan ^= 1; bitmap.viewport.changed = 3; break; } case SDLK_F12: { joynum = (joynum + 1) % MAX_DEVICES; while (input.dev[joynum] == NO_DEVICE) { joynum = (joynum + 1) % MAX_DEVICES; } break; } case SDLK_ESCAPE: { return 0; } default: break; } return 1; } int sdl_input_update(void) { uint8 *keystate = SDL_GetKeyState(NULL); /* reset input */ input.pad[joynum] = 0; switch (input.dev[joynum]) { case DEVICE_LIGHTGUN: { /* get mouse (absolute values) */ int x,y; int state = SDL_GetMouseState(&x,&y); /* Calculate X Y axis values */ input.analog[joynum][0] = (x * bitmap.viewport.w) / VIDEO_WIDTH; input.analog[joynum][1] = (y * bitmap.viewport.h) / VIDEO_HEIGHT; /* Start,Left,Right,Middle buttons -> 0 0 0 0 START MIDDLE RIGHT LEFT */ if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_C; if(state & SDL_BUTTON_MMASK) input.pad[joynum] |= INPUT_A; if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; break; } case DEVICE_PADDLE: { /* get mouse (absolute values) */ int x; int state = SDL_GetMouseState(&x, NULL); /* Range is [0;256], 128 being middle position */ input.analog[joynum][0] = x * 256 /VIDEO_WIDTH; /* Button I -> 0 0 0 0 0 0 0 I*/ if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; break; } case DEVICE_SPORTSPAD: { /* get mouse (relative values) */ int x,y; int state = SDL_GetRelativeMouseState(&x,&y); /* Range is [0;256] */ input.analog[joynum][0] = (unsigned char)(-x & 0xFF); input.analog[joynum][1] = (unsigned char)(-y & 0xFF); /* Buttons I & II -> 0 0 0 0 0 0 II I*/ if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_C; break; } case DEVICE_MOUSE: { /* get mouse (relative values) */ int x,y; int state = SDL_GetRelativeMouseState(&x,&y); /* Sega Mouse range is [-256;+256] */ input.analog[joynum][0] = x * 2; input.analog[joynum][1] = y * 2; /* Vertical movement is upsidedown */ if (!config.invert_mouse) input.analog[joynum][1] = 0 - input.analog[joynum][1]; /* Start,Left,Right,Middle buttons -> 0 0 0 0 START MIDDLE RIGHT LEFT */ if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_C; if(state & SDL_BUTTON_MMASK) input.pad[joynum] |= INPUT_A; if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; break; } case DEVICE_XE_A1P: { /* A,B,C,D,Select,START,E1,E2 buttons -> E1(?) E2(?) START SELECT(?) A B C D */ if(keystate[SDLK_a]) input.pad[joynum] |= INPUT_START; if(keystate[SDLK_s]) input.pad[joynum] |= INPUT_A; if(keystate[SDLK_d]) input.pad[joynum] |= INPUT_C; if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_Y; if(keystate[SDLK_z]) input.pad[joynum] |= INPUT_B; if(keystate[SDLK_x]) input.pad[joynum] |= INPUT_X; if(keystate[SDLK_c]) input.pad[joynum] |= INPUT_MODE; if(keystate[SDLK_v]) input.pad[joynum] |= INPUT_Z; /* Left Analog Stick (bidirectional) */ if(keystate[SDLK_UP]) input.analog[joynum][1]-=2; else if(keystate[SDLK_DOWN]) input.analog[joynum][1]+=2; else input.analog[joynum][1] = 128; if(keystate[SDLK_LEFT]) input.analog[joynum][0]-=2; else if(keystate[SDLK_RIGHT]) input.analog[joynum][0]+=2; else input.analog[joynum][0] = 128; /* Right Analog Stick (unidirectional) */ if(keystate[SDLK_KP8]) input.analog[joynum+1][0]-=2; else if(keystate[SDLK_KP2]) input.analog[joynum+1][0]+=2; else if(keystate[SDLK_KP4]) input.analog[joynum+1][0]-=2; else if(keystate[SDLK_KP6]) input.analog[joynum+1][0]+=2; else input.analog[joynum+1][0] = 128; /* Limiters */ if (input.analog[joynum][0] > 0xFF) input.analog[joynum][0] = 0xFF; else if (input.analog[joynum][0] < 0) input.analog[joynum][0] = 0; if (input.analog[joynum][1] > 0xFF) input.analog[joynum][1] = 0xFF; else if (input.analog[joynum][1] < 0) input.analog[joynum][1] = 0; if (input.analog[joynum+1][0] > 0xFF) input.analog[joynum+1][0] = 0xFF; else if (input.analog[joynum+1][0] < 0) input.analog[joynum+1][0] = 0; if (input.analog[joynum+1][1] > 0xFF) input.analog[joynum+1][1] = 0xFF; else if (input.analog[joynum+1][1] < 0) input.analog[joynum+1][1] = 0; break; } case DEVICE_ACTIVATOR: { if(keystate[SDLK_g]) input.pad[joynum] |= INPUT_ACTIVATOR_7L; if(keystate[SDLK_h]) input.pad[joynum] |= INPUT_ACTIVATOR_7U; if(keystate[SDLK_j]) input.pad[joynum] |= INPUT_ACTIVATOR_8L; if(keystate[SDLK_k]) input.pad[joynum] |= INPUT_ACTIVATOR_8U; } default: { if(keystate[SDLK_a]) input.pad[joynum] |= INPUT_A; if(keystate[SDLK_s]) input.pad[joynum] |= INPUT_B; if(keystate[SDLK_d]) input.pad[joynum] |= INPUT_C; if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; if(keystate[SDLK_z]) input.pad[joynum] |= INPUT_X; if(keystate[SDLK_x]) input.pad[joynum] |= INPUT_Y; if(keystate[SDLK_c]) input.pad[joynum] |= INPUT_Z; if(keystate[SDLK_v]) input.pad[joynum] |= INPUT_MODE; if(keystate[SDLK_UP]) input.pad[joynum] |= INPUT_UP; else if(keystate[SDLK_DOWN]) input.pad[joynum] |= INPUT_DOWN; if(keystate[SDLK_LEFT]) input.pad[joynum] |= INPUT_LEFT; else if(keystate[SDLK_RIGHT]) input.pad[joynum] |= INPUT_RIGHT; break; } } if (system_hw == SYSTEM_PICO) { /* get mouse (absolute values) */ int x,y; int state = SDL_GetMouseState(&x,&y); /* Calculate X Y axis values */ input.analog[0][0] = 0x3c + (x * (0x17c-0x03c+1)) / VIDEO_WIDTH; input.analog[0][1] = 0x1fc + (y * (0x2f7-0x1fc+1)) / VIDEO_HEIGHT; /* Map mouse buttons to player #1 inputs */ if(state & SDL_BUTTON_MMASK) pico_current++; if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_B; if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_A; } free (keystate); return 1; } int main (int argc, char **argv) { int running = 1; /* Print help if no game specified */ if(argc < 2) { char caption[256]; sprintf(caption, "Genesis Plus\\SDL by Charles MacDonald\nWWW: http://cgfm2.emuviews.com\nusage: %s gamename\n", argv[0]); MessageBox(NULL, caption, "Information", 0); exit(1); } /* set default config */ error_init(); set_config_defaults(); /* Load ROM file */ cart.rom = malloc(10*1024*1024); memset(cart.rom, 0, 10*1024*1024); if(!load_rom(argv[1])) { char caption[256]; sprintf(caption, "Error loading file `%s'.", argv[1]); MessageBox(NULL, caption, "Error", 0); exit(1); } /* load BIOS */ memset(bios_rom, 0, sizeof(bios_rom)); FILE *f = fopen(OS_ROM, "rb"); if (f!=NULL) { fread(&bios_rom, 0x800,1,f); fclose(f); int i; for(i = 0; i < 0x800; i += 2) { uint8 temp = bios_rom[i]; bios_rom[i] = bios_rom[i+1]; bios_rom[i+1] = temp; } config.tmss |= 2; } /* initialize SDL */ if(SDL_Init(0) < 0) { char caption[256]; sprintf(caption, "SDL initialization failed"); MessageBox(NULL, caption, "Error", 0); exit(1); } sdl_video_init(); if (use_sound) sdl_sound_init(); sdl_sync_init(); /* initialize Genesis virtual system */ SDL_LockSurface(sdl_video.surf_bitmap); memset(&bitmap, 0, sizeof(t_bitmap)); bitmap.width = 720; bitmap.height = 576; bitmap.depth = 16; bitmap.granularity = 2; bitmap.pitch = (bitmap.width * bitmap.granularity); bitmap.data = sdl_video.surf_bitmap->pixels; SDL_UnlockSurface(sdl_video.surf_bitmap); bitmap.viewport.changed = 3; /* initialize emulation */ audio_init(SOUND_FREQUENCY, vdp_pal ? 50.0 : 60.0); system_init(); /* load SRAM */ f = fopen("./game.srm", "rb"); if (f!=NULL) { fread(sram.sram,0x10000,1, f); fclose(f); } /* reset emulation */ system_reset(); if(use_sound) SDL_PauseAudio(0); /* 3 frames = 50 ms (60hz) or 60 ms (50hz) */ if(sdl_sync.sem_sync) SDL_SetTimer(vdp_pal ? 60 : 50, sdl_sync_timer_callback); /* emulation loop */ while(running) { SDL_Event event; if (SDL_PollEvent(&event)) { switch(event.type) { case SDL_QUIT: running = 0; break; case SDL_KEYDOWN: running = sdl_control_update(event.key.keysym.sym); break; } } sdl_video_update(); sdl_sound_update(); if(!turbo_mode && sdl_sync.sem_sync && sdl_video.frames_rendered % 3 == 0) { SDL_SemWait(sdl_sync.sem_sync); } } /* save SRAM */ f = fopen("./game.srm", "wb"); if (f!=NULL) { fwrite(sram.sram,0x10000,1, f); fclose(f); } system_shutdown(); audio_shutdown(); error_shutdown(); free(cart.rom); sdl_video_close(); sdl_sound_close(); sdl_sync_close(); SDL_Quit(); return 0; }
zyking1987-genplus-droid
genplusgx/unused/win/main.c
C
gpl2
19,079
# Makefile for genplus SDL # # (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald # modified by Eke-Eke <eke_eke31@yahoo.fr> # # Defines : # -DLSB_FIRST : for little endian systems. # -DLOGERROR : enable message logging # -DLOGVDP : enable VDP debug messages # -DLOGSOUND : enable AUDIO debug messages NAME = gen_sdl.exe CC = gcc CFLAGS = `sdl-config --cflags` -march=i686 -O6 -fomit-frame-pointer -Wall -Wno-strict-aliasing #-g -ggdb -pg #-fomit-frame-pointer #LDFLAGS = -pg DEFINES = -DLSB_FIRST INCLUDES = -I. -I.. -I../z80 -I../m68k -I../sound -I../input_hw -I../cart_hw -I../cart_hw/svp -I../ntsc LIBS = `sdl-config --libs` -lz -lm OBJECTS = obj/z80.o OBJECTS += obj/m68kcpu.o \ obj/m68kops.o OBJECTS += obj/genesis.o \ obj/vdp_ctrl.o \ obj/vdp_render.o \ obj/system.o \ obj/io_ctrl.o \ obj/mem68k.o \ obj/memz80.o \ obj/membnk.o \ obj/state.o OBJECTS += obj/input.o \ obj/gamepad.o \ obj/lightgun.o \ obj/mouse.o \ obj/activator.o \ obj/xe_a1p.o \ obj/teamplayer.o \ obj/paddle.o \ obj/sportspad.o OBJECTS += obj/sound.o \ obj/sn76489.o \ obj/ym2612.o OBJECTS += obj/Fir_Resampler.o OBJECTS += obj/blip.o OBJECTS += obj/eq.o \ OBJECTS += obj/sram.o \ obj/eeprom.o \ obj/svp.o \ obj/ssp16.o \ obj/ggenie.o \ obj/areplay.o \ obj/md_cart.o \ obj/sms_cart.o OBJECTS += obj/main.o \ obj/config.o \ obj/error.o \ obj/unzip.o \ obj/fileio.o \ obj/loadrom.o OBJECTS += obj/sms_ntsc.o \ obj/md_ntsc.o OBJECTS += obj/icon.o all: $(NAME) $(NAME): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@ obj/%.o : ../%.c ../%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../asm/%.s $(AS) $< -o $@ obj/%.o : ../sound/%.c ../sound/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../sound/%.c $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../input_hw/%.c ../input_hw/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../cart_hw/%.c ../cart_hw/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../cart_hw/svp/%.c $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../cart_hw/svp/%.c ../cart_hw/svp/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../z80/%.c ../z80/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../m68k/%.c ../m68k/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ./%.c ./%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../ntsc/%.c ../ntsc/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/icon.o : windres icon.rc $@ pack : strip $(NAME) upx -9 $(NAME) clean: rm -f $(OBJECTS) $(NAME)
zyking1987-genplus-droid
genplusgx/unused/win/Makefile
Makefile
gpl2
2,910
/* unzip.c -- IO on .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Read unzip.h for more info */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "zlib.h" #include "unzip.h" #ifdef STDC # include <stddef.h> # include <string.h> # include <stdlib.h> #endif #ifdef NO_ERRNO_H extern int errno; #else #include <errno.h> #endif #ifndef local #define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ #if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ !defined(CASESENSITIVITYDEFAULT_NO) #define CASESENSITIVITYDEFAULT_NO #endif #ifndef UNZ_BUFSIZE #define UNZ_BUFSIZE (16384) #endif #ifndef UNZ_MAXFILENAMEINZIP #define UNZ_MAXFILENAMEINZIP (256) #endif #ifndef ALLOC # define ALLOC(size) (malloc(size)) #endif #ifndef TRYFREE # define TRYFREE(p) {if (p) free(p);} #endif #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif #ifndef SEEK_SET #define SEEK_SET 0 #endif const char unz_copyright[] = " unzip 0.15 Copyright 1998 Gilles Vollant "; /* unz_file_info_interntal contain internal info about a file in zipfile*/ typedef struct unz_file_info_internal_s { uLong offset_curfile;/* relative offset of local header 4 bytes */ } unz_file_info_internal; /* file_in_zip_read_info_s contain internal information about a file in zipfile, when reading and decompress it */ typedef struct { char *read_buffer; /* internal buffer for compressed data */ z_stream stream; /* zLib stream structure for inflate */ uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ uLong stream_initialised; /* flag set if stream structure is initialised*/ uLong offset_local_extrafield;/* offset of the local extra field */ uInt size_local_extrafield;/* size of the local extra field */ uLong pos_local_extrafield; /* position in the local extra field in read*/ uLong crc32; /* crc32 of all data uncompressed */ uLong crc32_wait; /* crc32 we must obtain after decompress all */ uLong rest_read_compressed; /* number of byte to be decompressed */ uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ FILE* file; /* io structore of the zipfile */ uLong compression_method; /* compression method (0==store) */ uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ } file_in_zip_read_info_s; /* unz_s contain internal information about the zipfile */ typedef struct { FILE* file; /* io structore of the zipfile */ unz_global_info gi; /* public global information */ uLong byte_before_the_zipfile; /* byte before the zipfile, (>0 for sfx)*/ uLong num_file; /* number of the current file in the zipfile*/ uLong pos_in_central_dir; /* pos of the current file in the central dir*/ uLong current_file_ok; /* flag about the usability of the current file*/ uLong central_pos; /* position of the beginning of the central dir*/ uLong size_central_dir; /* size of the central directory */ uLong offset_central_dir; /* offset of start of central directory with respect to the starting disk number */ unz_file_info cur_file_info; /* public info about the current file in zip*/ unz_file_info_internal cur_file_info_internal; /* private info about it*/ file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current file if we are decompressing it */ } unz_s; /* =========================================================================== Read a byte from a gz_stream; update next_in and avail_in. Return EOF for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ local int unzlocal_getByte(fin,pi) FILE *fin; int *pi; { unsigned char c; int err = fread(&c, 1, 1, fin); if (err==1) { *pi = (int)c; return UNZ_OK; } else { if (ferror(fin)) return UNZ_ERRNO; else return UNZ_EOF; } } /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ local int unzlocal_getShort (fin,pX) FILE* fin; uLong *pX; { uLong x ; int i = 0; int err; err = unzlocal_getByte(fin,&i); x = (uLong)i; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } local int unzlocal_getLong (fin,pX) FILE* fin; uLong *pX; { uLong x ; int i = 0; int err; err = unzlocal_getByte(fin,&i); x = (uLong)i; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<16; if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<24; if (err==UNZ_OK) *pX = x; else *pX = 0; return err; } /* My own strcmpi / strcasecmp */ local int strcmpcasenosensitive_internal (fileName1,fileName2) const char* fileName1; const char* fileName2; { for (;;) { char c1=*(fileName1++); char c2=*(fileName2++); if ((c1>='a') && (c1<='z')) c1 -= 0x20; if ((c2>='a') && (c2<='z')) c2 -= 0x20; if (c1=='\0') return ((c2=='\0') ? 0 : -1); if (c2=='\0') return 1; if (c1<c2) return -1; if (c1>c2) return 1; } } #ifdef CASESENSITIVITYDEFAULT_NO #define CASESENSITIVITYDEFAULTVALUE 2 #else #define CASESENSITIVITYDEFAULTVALUE 1 #endif #ifndef STRCMPCASENOSENTIVEFUNCTION #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal #endif /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) const char* fileName1; const char* fileName2; int iCaseSensitivity; { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; if (iCaseSensitivity==1) return strcmp(fileName1,fileName2); return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); } #define BUFREADCOMMENT (0x400) /* Locate the Central directory of a zipfile (at the end, just before the global comment) */ local uLong unzlocal_SearchCentralDir(fin) FILE *fin; { unsigned char* buf; uLong uSizeFile; uLong uBackRead; uLong uMaxBack=0xffff; /* maximum size of global comment */ uLong uPosFound=0; if (fseek(fin,0,SEEK_END) != 0) return 0; uSizeFile = ftell( fin ); if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); if (buf==NULL) return 0; uBackRead = 4; while (uBackRead<uMaxBack) { uLong uReadSize,uReadPos ; int i; if (uBackRead+BUFREADCOMMENT>uMaxBack) uBackRead = uMaxBack; else uBackRead+=BUFREADCOMMENT; uReadPos = uSizeFile-uBackRead ; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); if (fseek(fin,uReadPos,SEEK_SET)!=0) break; if (fread(buf,(uInt)uReadSize,1,fin)!=1) break; for (i=(int)uReadSize-3; (i--)>0;) if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { uPosFound = uReadPos+i; break; } if (uPosFound!=0) break; } TRYFREE(buf); return uPosFound; } /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer "zlib/zlib109.zip". If the zipfile cannot be opened (file don't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ extern unzFile ZEXPORT unzOpen (path) const char *path; { unz_s us; unz_s *s; uLong central_pos,uL; FILE * fin ; uLong number_disk; /* number of the current dist, used for spaning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used for spaning ZIP, unsupported, always 0*/ uLong number_entry_CD; /* total number of entries in the central dir (same than number_entry on nospan) */ int err=UNZ_OK; if (unz_copyright[0]!=' ') return NULL; fin=fopen(path,"rb"); if (fin==NULL) return NULL; central_pos = unzlocal_SearchCentralDir(fin); if (central_pos==0) err=UNZ_ERRNO; if (fseek(fin,central_pos,SEEK_SET)!=0) err=UNZ_ERRNO; /* the signature, already checked */ if (unzlocal_getLong(fin,&uL)!=UNZ_OK) err=UNZ_ERRNO; /* number of this disk */ if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) err=UNZ_ERRNO; /* number of the disk with the start of the central directory */ if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central dir on this disk */ if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) err=UNZ_ERRNO; /* total number of entries in the central dir */ if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) err=UNZ_ERRNO; if ((number_entry_CD!=us.gi.number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) err=UNZ_BADZIPFILE; /* size of the central directory */ if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) err=UNZ_ERRNO; /* offset of start of central directory with respect to the starting disk number */ if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) err=UNZ_ERRNO; /* zipfile comment length */ if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) err=UNZ_ERRNO; if ((central_pos<us.offset_central_dir+us.size_central_dir) && (err==UNZ_OK)) err=UNZ_BADZIPFILE; if (err!=UNZ_OK) { fclose(fin); return NULL; } us.file=fin; us.byte_before_the_zipfile = central_pos - (us.offset_central_dir+us.size_central_dir); us.central_pos = central_pos; us.pfile_in_zip_read = NULL; s=(unz_s*)ALLOC(sizeof(unz_s)); *s=us; unzGoToFirstFile((unzFile)s); return (unzFile)s; } /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzClose (file) unzFile file; { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (s->pfile_in_zip_read!=NULL) unzCloseCurrentFile(file); fclose(s->file); TRYFREE(s); return UNZ_OK; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) unzFile file; unz_global_info *pglobal_info; { unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; *pglobal_info=s->gi; return UNZ_OK; } /* Translate date/time from Dos format to tm_unz (readable more easilty) */ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) uLong ulDosDate; tm_unz* ptm; { uLong uDate; uDate = (uLong)(ulDosDate>>16); ptm->tm_mday = (uInt)(uDate&0x1f) ; ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; } /* Get Info about the current file in the zipfile, with internal only info */ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); local int unzlocal_GetCurrentFileInfoInternal (file, pfile_info, pfile_info_internal, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) unzFile file; unz_file_info *pfile_info; unz_file_info_internal *pfile_info_internal; char *szFileName; uLong fileNameBufferSize; void *extraField; uLong extraFieldBufferSize; char *szComment; uLong commentBufferSize; { unz_s* s; unz_file_info file_info; unz_file_info_internal file_info_internal; int err=UNZ_OK; uLong uMagic; long lSeek=0; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) err=UNZ_ERRNO; /* we check the magic */ if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x02014b50) err=UNZ_BADZIPFILE; } if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) err=UNZ_ERRNO; unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) err=UNZ_ERRNO; lSeek+=file_info.size_filename; if ((err==UNZ_OK) && (szFileName!=NULL)) { uLong uSizeRead ; if (file_info.size_filename<fileNameBufferSize) { *(szFileName+file_info.size_filename)='\0'; uSizeRead = file_info.size_filename; } else uSizeRead = fileNameBufferSize; if ((file_info.size_filename>0) && (fileNameBufferSize>0)) if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) err=UNZ_ERRNO; lSeek -= uSizeRead; } if ((err==UNZ_OK) && (extraField!=NULL)) { uLong uSizeRead ; if (file_info.size_file_extra<extraFieldBufferSize) uSizeRead = file_info.size_file_extra; else uSizeRead = extraFieldBufferSize; if (lSeek!=0) { if (fseek(s->file,lSeek,SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; } if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) err=UNZ_ERRNO; lSeek += file_info.size_file_extra - uSizeRead; } else lSeek+=file_info.size_file_extra; if ((err==UNZ_OK) && (szComment!=NULL)) { uLong uSizeRead ; if (file_info.size_file_comment<commentBufferSize) { *(szComment+file_info.size_file_comment)='\0'; uSizeRead = file_info.size_file_comment; } else uSizeRead = commentBufferSize; if (lSeek!=0) { if (fseek(s->file,lSeek,SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; } if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) err=UNZ_ERRNO; lSeek+=file_info.size_file_comment - uSizeRead; } else lSeek+=file_info.size_file_comment; if ((err==UNZ_OK) && (pfile_info!=NULL)) *pfile_info=file_info; if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) *pfile_info_internal=file_info_internal; return err; } /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetCurrentFileInfo (file, pfile_info, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize) unzFile file; unz_file_info *pfile_info; char *szFileName; uLong fileNameBufferSize; void *extraField; uLong extraFieldBufferSize; char *szComment; uLong commentBufferSize; { return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, szFileName,fileNameBufferSize, extraField,extraFieldBufferSize, szComment,commentBufferSize); } /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToFirstFile (file) unzFile file; { int err=UNZ_OK; unz_s* s; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; s->pos_in_central_dir=s->offset_central_dir; s->num_file=0; err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzGoToNextFile (file) unzFile file; { unz_s* s; int err; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; if (s->num_file+1==s->gi.number_entry) return UNZ_END_OF_LIST_OF_FILE; s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; s->num_file++; err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); return err; } /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzipStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) unzFile file; const char *szFileName; int iCaseSensitivity; { unz_s* s; int err; uLong num_fileSaved; uLong pos_in_central_dirSaved; if (file==NULL) return UNZ_PARAMERROR; if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; num_fileSaved = s->num_file; pos_in_central_dirSaved = s->pos_in_central_dir; err = unzGoToFirstFile(file); while (err == UNZ_OK) { char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; unzGetCurrentFileInfo(file,NULL, szCurrentFileName,sizeof(szCurrentFileName)-1, NULL,0,NULL,0); if (unzStringFileNameCompare(szCurrentFileName, szFileName,iCaseSensitivity)==0) return UNZ_OK; err = unzGoToNextFile(file); } s->num_file = num_fileSaved ; s->pos_in_central_dir = pos_in_central_dirSaved ; return err; } /* Read the local header of the current zipfile Check the coherency of the local header and info in the end of central directory about this file store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, poffset_local_extrafield, psize_local_extrafield) unz_s* s; uInt* piSizeVar; uLong *poffset_local_extrafield; uInt *psize_local_extrafield; { uLong uMagic,uData,uFlags; uLong size_filename; uLong size_extra_field; int err=UNZ_OK; *piSizeVar = 0; *poffset_local_extrafield = 0; *psize_local_extrafield = 0; if (fseek(s->file,s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile,SEEK_SET)!=0) return UNZ_ERRNO; if (err==UNZ_OK) { if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) err=UNZ_BADZIPFILE; } if (unzlocal_getShort(s->file,&uData) != UNZ_OK) err=UNZ_ERRNO; /* else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) err=UNZ_BADZIPFILE; */ if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) err=UNZ_ERRNO; if (unzlocal_getShort(s->file,&uData) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) err=UNZ_BADZIPFILE; if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ err=UNZ_ERRNO; if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) err=UNZ_BADZIPFILE; *piSizeVar += (uInt)size_filename; if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) err=UNZ_ERRNO; *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + size_filename; *psize_local_extrafield = (uInt)size_extra_field; *piSizeVar += (uInt)size_extra_field; return err; } /* Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ extern int ZEXPORT unzOpenCurrentFile (file) unzFile file; { int err=UNZ_OK; int Store; uInt iSizeVar; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uLong offset_local_extrafield; /* offset of the local extra field */ uInt size_local_extrafield; /* size of the local extra field */ if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; if (!s->current_file_ok) return UNZ_PARAMERROR; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) return UNZ_BADZIPFILE; pfile_in_zip_read_info = (file_in_zip_read_info_s*) ALLOC(sizeof(file_in_zip_read_info_s)); if (pfile_in_zip_read_info==NULL) return UNZ_INTERNALERROR; pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; pfile_in_zip_read_info->pos_local_extrafield=0; if (pfile_in_zip_read_info->read_buffer==NULL) { TRYFREE(pfile_in_zip_read_info); return UNZ_INTERNALERROR; } pfile_in_zip_read_info->stream_initialised=0; if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; Store = s->cur_file_info.compression_method==0; pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; pfile_in_zip_read_info->crc32=0; pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; pfile_in_zip_read_info->file=s->file; pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; pfile_in_zip_read_info->stream.total_out = 0; if (!Store) { pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; pfile_in_zip_read_info->stream.zfree = (free_func)0; pfile_in_zip_read_info->stream.opaque = (voidpf)0; err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); if (err == Z_OK) pfile_in_zip_read_info->stream_initialised=1; /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and * return Z_STREAM_END. * In unzip, i don't wait absolutely Z_STREAM_END because I known the * size of both compressed and uncompressed data */ } pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size ; pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size ; pfile_in_zip_read_info->pos_in_zipfile = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + iSizeVar; pfile_in_zip_read_info->stream.avail_in = (uInt)0; s->pfile_in_zip_read = pfile_in_zip_read_info; return UNZ_OK; } /* Read bytes from the current file. buf contain buffer where data must be copied len the size of buf. return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern int ZEXPORT unzReadCurrentFile (file, buf, len) unzFile file; voidp buf; unsigned len; { int err=UNZ_OK; uInt iRead = 0; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if ((pfile_in_zip_read_info->read_buffer == NULL)) return UNZ_END_OF_LIST_OF_FILE; if (len==0) return 0; pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; pfile_in_zip_read_info->stream.avail_out = (uInt)len; if (len>pfile_in_zip_read_info->rest_read_uncompressed) pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed; while (pfile_in_zip_read_info->stream.avail_out>0) { if ((pfile_in_zip_read_info->stream.avail_in==0) && (pfile_in_zip_read_info->rest_read_compressed>0)) { uInt uReadThis = UNZ_BUFSIZE; if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; if (uReadThis == 0) return UNZ_EOF; if (fseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) return UNZ_ERRNO; if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, pfile_in_zip_read_info->file)!=1) return UNZ_ERRNO; pfile_in_zip_read_info->pos_in_zipfile += uReadThis; pfile_in_zip_read_info->rest_read_compressed-=uReadThis; pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->read_buffer; pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; } if (pfile_in_zip_read_info->compression_method==0) { uInt uDoCopy,i ; if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) uDoCopy = pfile_in_zip_read_info->stream.avail_out ; else uDoCopy = pfile_in_zip_read_info->stream.avail_in ; for (i=0;i<uDoCopy;i++) *(pfile_in_zip_read_info->stream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, pfile_in_zip_read_info->stream.next_out, uDoCopy); pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; pfile_in_zip_read_info->stream.avail_in -= uDoCopy; pfile_in_zip_read_info->stream.avail_out -= uDoCopy; pfile_in_zip_read_info->stream.next_out += uDoCopy; pfile_in_zip_read_info->stream.next_in += uDoCopy; pfile_in_zip_read_info->stream.total_out += uDoCopy; iRead += uDoCopy; } else { uLong uTotalOutBefore,uTotalOutAfter; const Bytef *bufBefore; uLong uOutThis; int flush=Z_SYNC_FLUSH; uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; bufBefore = pfile_in_zip_read_info->stream.next_out; /* if ((pfile_in_zip_read_info->rest_read_uncompressed == pfile_in_zip_read_info->stream.avail_out) && (pfile_in_zip_read_info->rest_read_compressed == 0)) flush = Z_FINISH; */ err=inflate(&pfile_in_zip_read_info->stream,flush); uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uOutThis = uTotalOutAfter-uTotalOutBefore; pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); if (err==Z_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead; if (err!=Z_OK) break; } } if (err==Z_OK) return iRead; return err; } /* Give the current position in uncompressed data */ extern z_off_t ZEXPORT unztell (file) unzFile file; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; return (z_off_t)pfile_in_zip_read_info->stream.total_out; } /* return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzeof (file) unzFile file; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->rest_read_uncompressed == 0) return 1; else return 0; } /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field that can be read if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) unzFile file; voidp buf; unsigned len; { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uInt read_now; uLong size_to_read; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; size_to_read = (pfile_in_zip_read_info->size_local_extrafield - pfile_in_zip_read_info->pos_local_extrafield); if (buf==NULL) return (int)size_to_read; if (len>size_to_read) read_now = (uInt)size_to_read; else read_now = (uInt)len ; if (read_now==0) return 0; if (fseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) return UNZ_ERRNO; if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) return UNZ_ERRNO; return (int)read_now; } /* Close the file in zip opened with unzipOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzCloseCurrentFile (file) unzFile file; { int err=UNZ_OK; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->rest_read_uncompressed == 0) { if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) err=UNZ_CRCERROR; } TRYFREE(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; if (pfile_in_zip_read_info->stream_initialised) inflateEnd(&pfile_in_zip_read_info->stream); pfile_in_zip_read_info->stream_initialised = 0; TRYFREE(pfile_in_zip_read_info); s->pfile_in_zip_read=NULL; return err; } /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) unzFile file; char *szComment; uLong uSizeBuf; { /* int err=UNZ_OK; */ unz_s* s; uLong uReadThis ; if (file==NULL) return UNZ_PARAMERROR; s=(unz_s*)file; uReadThis = uSizeBuf; if (uReadThis>s->gi.size_comment) uReadThis = s->gi.size_comment; if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) return UNZ_ERRNO; if (uReadThis>0) { *szComment='\0'; if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) return UNZ_ERRNO; } if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) *(szComment+s->gi.size_comment)='\0'; return (int)uReadThis; }
zyking1987-genplus-droid
genplusgx/unused/win/unzip.c
C
gpl2
36,877
#ifndef _ERROR_H_ #define _ERROR_H_ /* Global variables */ FILE *error_log; /* Function prototypes */ void error_init(void); void error_shutdown(void); void error(char *format, ...); #endif /* _ERROR_H_ */
zyking1987-genplus-droid
genplusgx/unused/win/error.h
C
gpl2
223
/* unzip.h -- IO for uncompress .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Copyright (C) 1998 Gilles Vollant This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g WinZip, InfoZip tools and compatible. Encryption and multi volume ZipFile (span) are not supported. Old compressions used by old PKZip 1.x are not supported THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE CAN CHANGE IN FUTURE VERSION !! I WAIT FEEDBACK at mail info@winimage.com Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution Condition of use and distribution are the same than zlib : This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* for more info about .ZIP format, see ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip PkWare has also a specification at : ftp://ftp.pkware.com/probdesc.zip */ #ifndef _unz_H #define _unz_H #ifdef __cplusplus extern "C" { #endif #ifndef _ZLIB_H #include "zlib.h" #endif #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ typedef struct TagunzFile__ { int unused; } unzFile__; typedef unzFile__ *unzFile; #else typedef voidp unzFile; #endif #define UNZ_OK (0) #define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_ERRNO (Z_ERRNO) #define UNZ_EOF (0) #define UNZ_PARAMERROR (-102) #define UNZ_BADZIPFILE (-103) #define UNZ_INTERNALERROR (-104) #define UNZ_CRCERROR (-105) /* tm_unz contain date/time info */ typedef struct tm_unz_s { uInt tm_sec; /* seconds after the minute - [0,59] */ uInt tm_min; /* minutes after the hour - [0,59] */ uInt tm_hour; /* hours since midnight - [0,23] */ uInt tm_mday; /* day of the month - [1,31] */ uInt tm_mon; /* months since January - [0,11] */ uInt tm_year; /* years - [1980..2044] */ } tm_unz; /* unz_global_info structure contain global data about the ZIPfile These data comes from the end of central dir */ typedef struct unz_global_info_s { uLong number_entry; /* total number of entries in the central dir on this disk */ uLong size_comment; /* size of the global comment of the zipfile */ } unz_global_info; /* unz_file_info contain information about a file in the zipfile */ typedef struct unz_file_info_s { uLong version; /* version made by 2 bytes */ uLong version_needed; /* version needed to extract 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */ uLong compression_method; /* compression method 2 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ uLong crc; /* crc-32 4 bytes */ uLong compressed_size; /* compressed size 4 bytes */ uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong size_filename; /* filename length 2 bytes */ uLong size_file_extra; /* extra field length 2 bytes */ uLong size_file_comment; /* file comment length 2 bytes */ uLong disk_num_start; /* disk number start 2 bytes */ uLong internal_fa; /* internal file attributes 2 bytes */ uLong external_fa; /* external file attributes 4 bytes */ tm_unz tmu_date; } unz_file_info; extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, const char* fileName2, int iCaseSensitivity)); /* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is defaut of your operating system (like 1 on Unix, 2 on Windows) */ extern unzFile ZEXPORT unzOpen OF((const char *path)); /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer "zlib/zlib111.zip". If the zipfile cannot be opened (file don't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ extern int ZEXPORT unzClose OF((unzFile file)); /* Close a ZipFile opened with unzipOpen. If there is files inside the .Zip opened with unzOpenCurrentFile (see later), these files MUST be closed with unzipCloseCurrentFile before call unzipClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, unz_global_info *pglobal_info)); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalComment OF((unzFile file, char *szComment, uLong uSizeBuf)); /* Get the global comment string of the ZipFile, in the szComment buffer. uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ /***************************************************************************/ /* Unzip package allow you browse the directory of the zipfile */ extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ extern int ZEXPORT unzGoToNextFile OF((unzFile file)); /* Set the current file of the zipfile to the next file. return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ extern int ZEXPORT unzLocateFile OF((unzFile file, const char *szFileName, int iCaseSensitivity)); /* Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize)); /* Get Info about the current file if pfile_info!=NULL, the *pfile_info structure will contain somes info about the current file if szFileName!=NULL, the filemane string will be copied in szFileName (fileNameBufferSize is the size of the buffer) if extraField!=NULL, the extra field information will be copied in extraField (extraFieldBufferSize is the size of the buffer). This is the Central-header version of the extra field if szComment!=NULL, the comment string of the file will be copied in szComment (commentBufferSize is the size of the buffer) */ /***************************************************************************/ /* for reading the content of the current zipfile, you can open it, read data from it, and close it (you can close it before reading all the file) */ extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); /* Open for reading data the current file in the zipfile. If there is no error, the return value is UNZ_OK. */ extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); /* Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, voidp buf, unsigned len)); /* Read bytes from the current file (opened by unzOpenCurrentFile) buf contain buffer where data must be copied len the size of buf. return the number of byte copied if somes bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ extern z_off_t ZEXPORT unztell OF((unzFile file)); /* Give the current position in uncompressed data */ extern int ZEXPORT unzeof OF((unzFile file)); /* return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, voidp buf, unsigned len)); /* Read extra field from the current file (opened by unzOpenCurrentFile) This is the local-header version of the extra field (sometimes, there is more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. the return value is the number of bytes copied in buf, or (if <0) the error code */ #ifdef __cplusplus } #endif #endif /* _unz_H */
zyking1987-genplus-droid
genplusgx/unused/win/unzip.h
C
gpl2
10,294
#ifndef _MAIN_H_ #define _MAIN_H_ #define MAX_INPUTS 8 extern int debug_on; extern int log_error; #endif /* _MAIN_H_ */
zyking1987-genplus-droid
genplusgx/unused/win/main.h
C
gpl2
134
# Makefile for genplus SDL # # (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald # modified by Eke-Eke <eke_eke31@yahoo.fr> # # Defines : # LSB_FIRST : for little endian systems. # X86_ASM : enable x86 assembly optimizations # LOGERROR # LOGVDP # LOGSOUND NAME = gen_sdl.exe CC = gcc CFLAGS = `sdl-config --cflags` -O6 -march=i686 -fomit-frame-pointer #-g -ggdb -pg #-fomit-frame-pointer #LDFLAGS = -g -ggdb -pg DEFINES = -DLSB_FIRST -DX86_ASM INCLUDES = -I. -I.. -I../z80 -I../m68k -I../sound -I../cart_hw -I../cart_hw/svp -I../ntsc LIBS = `sdl-config --libs` -lz -lm OBJECTS = obj/z80.o OBJECTS += obj/m68kcpu.o \ obj/m68kops.o OBJECTS += obj/genesis.o \ obj/vdp.o \ obj/render.o \ obj/system.o \ obj/gen_io.o \ obj/gen_input.o \ obj/mem68k.o \ obj/memz80.o \ obj/membnk.o \ obj/state.o OBJECTS += obj/sound.o \ obj/sn76489.o \ obj/ym2612.o OBJECTS += obj/Fir_Resampler.o \ OBJECTS += obj/eq.o \ OBJECTS += obj/sram.o \ obj/eeprom.o \ obj/svp.o \ obj/ssp16.o \ obj/ggenie.o \ obj/datel.o \ obj/cart_hw.o OBJECTS += obj/main.o \ obj/config.o \ obj/error.o \ obj/unzip.o \ obj/fileio.o \ obj/loadrom.o OBJECTS += obj/sms_ntsc.o \ obj/md_ntsc.o OBJECTS += obj/icon.o all: $(NAME) $(NAME): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@ obj/%.o : ../%.c ../%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../asm/%.s $(AS) $< -o $@ obj/%.o : ../sound/%.c ../sound/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../sound/%.c $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../cart_hw/%.c ../cart_hw/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../cart_hw/svp/%.c $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../cart_hw/svp/%.c ../cart_hw/svp/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../z80/%.c ../z80/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../m68k/%.c ../m68k/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ./%.c ./%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/%.o : ../ntsc/%.c ../ntsc/%.h $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ obj/icon.o : windres icon.rc $@ pack : strip $(NAME) upx -9 $(NAME) clean: rm -f $(OBJECTS) $(NAME)
zyking1987-genplus-droid
genplusgx/unused/win/Makefilehtml.html
HTML
gpl2
2,511
#ifndef _OSD_H_ #define _OSD_H_ #include <stdio.h> #include <string.h> #include <stdarg.h> #include <time.h> #include <conio.h> #include <SDL.h> #include <stdlib.h> #include "shared.h" #include "main.h" #include "config.h" #include "error.h" #include "unzip.h" #include "fileio.h" #define osd_input_Update sdl_input_update #define GG_ROM "./ggenie.bin" #define AR_ROM "./areplay.bin" #define OS_ROM "./bios.bin" #define SK_ROM "./sk.bin" #define SK_UPMEM "./sk2chip.bin" #endif /* _OSD_H_ */
zyking1987-genplus-droid
genplusgx/unused/win/osd.h
C
gpl2
541
#include "shared.h" /* Load a normal file, or ZIP/GZ archive. Returns NULL if an error occured. */ uint8 *load_archive(char *filename, int *file_size) { int size = 0; uint8 *buf = NULL; if(check_zip(filename)) { unzFile *fd = NULL; unz_file_info info; int ret = 0; /* Attempt to open the archive */ fd = unzOpen(filename); if(!fd) return (NULL); /* Go to first file in archive */ ret = unzGoToFirstFile(fd); if(ret != UNZ_OK) { unzClose(fd); return (NULL); } ret = unzGetCurrentFileInfo(fd, &info, filename, 128, NULL, 0, NULL, 0); if(ret != UNZ_OK) { unzClose(fd); return (NULL); } /* Open the file for reading */ ret = unzOpenCurrentFile(fd); if(ret != UNZ_OK) { unzClose(fd); return (NULL); } /* Allocate file data buffer */ size = info.uncompressed_size; buf = malloc(size); if(!buf) { unzClose(fd); return (NULL); } /* Read (decompress) the file */ ret = unzReadCurrentFile(fd, buf, info.uncompressed_size); if(ret != info.uncompressed_size) { free(buf); unzCloseCurrentFile(fd); unzClose(fd); return (NULL); } /* Close the current file */ ret = unzCloseCurrentFile(fd); if(ret != UNZ_OK) { free(buf); unzClose(fd); return (NULL); } /* Close the archive */ ret = unzClose(fd); if(ret != UNZ_OK) { free(buf); return (NULL); } /* Update file size and return pointer to file data */ *file_size = size; return (buf); } else { gzFile *gd = NULL; /* Open file */ gd = gzopen(filename, "rb"); if(!gd) return (0); /* Get file size */ size = gzsize(gd); /* Allocate file data buffer */ buf = malloc(size); if(!buf) { gzclose(gd); return (0); } /* Read file data */ gzread(gd, buf, size); /* Close file */ gzclose(gd); /* Update file size and return pointer to file data */ *file_size = size; return (buf); } } /* Verifies if a file is a ZIP archive or not. Returns: 1= ZIP archive, 0= not a ZIP archive */ int check_zip(char *filename) { uint8 buf[2]; FILE *fd = NULL; fd = fopen(filename, "rb"); if(!fd) return (0); fread(buf, 2, 1, fd); fclose(fd); if(memcmp(buf, "PK", 2) == 0) return (1); return (0); } /* Returns the size of a GZ compressed file. */ int gzsize(gzFile *gd) { #define CHUNKSIZE (0x10000) int size = 0, length = 0; unsigned char buffer[CHUNKSIZE]; gzrewind(gd); do { size = gzread(gd, buffer, CHUNKSIZE); if(size <= 0) break; length += size; } while (!gzeof(gd)); gzrewind(gd); return (length); #undef CHUNKSIZE }
zyking1987-genplus-droid
genplusgx/unused/win/fileio.c
C
gpl2
3,371
#include "osd.h" t_config config; void set_config_defaults(void) { int i; /* sound options */ config.psg_preamp = 150; config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 0; config.filter = 1; config.low_freq = 200; config.high_freq = 8000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; config.lp_range = 60; config.rolloff = 0.995; config.dac_bits = 14; /* system options */ config.region_detect = 0; config.force_dtack = 0; config.addr_error = 1; config.tmss = 0; config.lock_on = 0;//TYPE_SK; config.romtype = 0; /* display options */ config.overscan = 1; config.render = 0; /* controllers options */ input.system[0] = SYSTEM_MD_GAMEPAD; input.system[1] = SYSTEM_MD_GAMEPAD; config.gun_cursor[0] = 1; config.gun_cursor[1] = 1; config.invert_mouse = 0; for (i=0;i<MAX_INPUTS;i++) { config.input[i].padtype = DEVICE_PAD6B; } }
zyking1987-genplus-droid
genplusgx/unused/win/config.c
C
gpl2
1,117
#ifndef _CONFIG_H_ #define _CONFIG_H_ /**************************************************************************** * Config Option * ****************************************************************************/ typedef struct { uint8 padtype; } t_input_config; typedef struct { uint8 hq_fm; uint8 filter; uint8 psgBoostNoise; uint8 dac_bits; int16 psg_preamp; int16 fm_preamp; int16 lp_range; int16 low_freq; int16 high_freq; int16 lg; int16 mg; int16 hg; float rolloff; uint8 region_detect; uint8 force_dtack; uint8 addr_error; uint8 tmss; uint8 lock_on; uint8 hot_swap; uint8 romtype; uint8 invert_mouse; uint8 gun_cursor[2]; uint8 overscan; uint8 ntsc; uint8 render; t_input_config input[MAX_INPUTS]; } t_config; /* Global variables */ extern t_config config; extern void set_config_defaults(void); #endif /* _CONFIG_H_ */
zyking1987-genplus-droid
genplusgx/unused/win/config.h
C
gpl2
942
#ifndef Z80_H_ #define Z80_H_ #include "osd_cpu.h" enum { /* line states */ CLEAR_LINE = 0, /* clear (a fired, held or pulsed) line */ ASSERT_LINE, /* assert an interrupt immediately */ HOLD_LINE, /* hold interrupt line until acknowledged */ PULSE_LINE /* pulse interrupt line for one instruction */ }; enum { Z80_PC, Z80_SP, Z80_A, Z80_B, Z80_C, Z80_D, Z80_E, Z80_H, Z80_L, Z80_AF, Z80_BC, Z80_DE, Z80_HL, Z80_IX, Z80_IY, Z80_AF2, Z80_BC2, Z80_DE2, Z80_HL2, Z80_R, Z80_I, Z80_IM, Z80_IFF1, Z80_IFF2, Z80_HALT, Z80_DC0, Z80_DC1, Z80_DC2, Z80_DC3, Z80_WZ }; enum { Z80_TABLE_op, Z80_TABLE_cb, Z80_TABLE_ed, Z80_TABLE_xy, Z80_TABLE_xycb, Z80_TABLE_ex /* cycles counts for taken jr/jp/call and interrupt latency (rst opcodes) */ }; /****************************************************************************/ /* The Z80 registers. HALT is set to 1 when the CPU is halted, the refresh */ /* register is calculated as follows: refresh=(Z80.r&127)|(Z80.r2&128) */ /****************************************************************************/ typedef struct { PAIR pc,sp,af,bc,de,hl,ix,iy,wz; PAIR af2,bc2,de2,hl2; UINT8 r,r2,iff1,iff2,halt,im,i; UINT8 nmi_state; /* nmi line state */ UINT8 nmi_pending; /* nmi pending */ UINT8 irq_state; /* irq line state */ UINT8 after_ei; /* are we in the EI shadow? */ const struct z80_irq_daisy_chain *daisy; int (*irq_callback)(int irqline); } Z80_Regs; extern Z80_Regs Z80; extern unsigned char *z80_readmap[64]; extern unsigned char *z80_writemap[64]; extern void (*z80_writemem)(unsigned int address, unsigned char data); extern unsigned char (*z80_readmem)(unsigned int port); extern void (*z80_writeport)(unsigned int port, unsigned char data); extern unsigned char (*z80_readport)(unsigned int port); extern void z80_init(const void *config, int (*irqcallback)(int)); extern void z80_reset (void); extern void z80_exit (void); extern void z80_run(unsigned int cycles); extern void z80_burn(unsigned int cycles); extern void z80_get_context (void *dst); extern void z80_set_context (void *src); extern void z80_set_nmi_line(int state); #endif
zyking1987-genplus-droid
genplusgx/z80/z80.h
C
gpl2
2,268
/******************************************************************************* * * * Define size independent data types and operations. * * * * The following types must be supported by all platforms: * * * * UINT8 - Unsigned 8-bit Integer INT8 - Signed 8-bit integer * * UINT16 - Unsigned 16-bit Integer INT16 - Signed 16-bit integer * * UINT32 - Unsigned 32-bit Integer INT32 - Signed 32-bit integer * * UINT64 - Unsigned 64-bit Integer INT64 - Signed 64-bit integer * * * * * * The macro names for the artithmatic operations are composed as follows: * * * * XXX_R_A_B, where XXX - 3 letter operation code (ADD, SUB, etc.) * * R - The type of the result * * A - The type of operand 1 * * B - The type of operand 2 (if binary operation) * * * * Each type is one of: U8,8,U16,16,U32,32,U64,64 * * * *******************************************************************************/ #ifndef OSD_CPU_H #define OSD_CPU_H #ifndef NGC #if 0 #ifndef DOS #include "basetsd.h" #endif #endif #undef TRUE #undef FALSE #define TRUE 1 #define FALSE 0 #endif typedef unsigned char UINT8; typedef unsigned short UINT16; typedef unsigned int UINT32; __extension__ typedef unsigned long long UINT64; typedef signed char INT8; typedef signed short INT16; typedef signed int INT32; __extension__ typedef signed long long INT64; /****************************************************************************** * Union of UINT8, UINT16 and UINT32 in native endianess of the target * This is used to access bytes and words in a machine independent manner. * The upper bytes h2 and h3 normally contain zero (16 bit CPU cores) * thus PAIR.d can be used to pass arguments to the memory system * which expects 'int' really. ******************************************************************************/ typedef union { #ifdef LSB_FIRST struct { UINT8 l,h,h2,h3; } b; struct { UINT16 l,h; } w; #else struct { UINT8 h3,h2,h,l; } b; struct { UINT16 h,l; } w; #endif UINT32 d; } PAIR; #endif /* defined OSD_CPU_H */
zyking1987-genplus-droid
genplusgx/z80/osd_cpu.h
C
gpl2
3,126
/***************************************************************************** * * z80.c * Portable Z80 emulator V3.9 * * Copyright Juergen Buchmueller, all rights reserved. * * - This source code is released as freeware for non-commercial purposes. * - You are free to use and redistribute this code in modified or * unmodified form, provided you list me in the credits. * - If you modify this source code, you must add a notice to each modified * source file that it has been changed. If you're a nice person, you * will clearly mark each change too. :) * - If you wish to use this for commercial purposes, please contact me at * pullmoll@t-online.de * - The author of this copywritten work reserves the right to change the * terms of its usage and license at any time, including retroactively * - This entire notice must remain in the source code. * * TODO: * - If LD A,I or LD A,R is interrupted, P/V flag gets reset, even if IFF2 * was set before this instruction * - Ideally, the tiny differences between Z80 types should be supported, * currently known differences: * - LD A,I/R P/V flag reset glitch is fixed on CMOS Z80 * - OUT (C),0 outputs 0 on NMOS Z80, $FF on CMOS Z80 * - SCF/CCF X/Y flags is ((flags | A) & 0x28) on SGS/SHARP/ZiLOG NMOS Z80, * (flags & A & 0x28) on NEC NMOS Z80, other models unknown. * However, people from the Speccy scene mention that SCF/CCF X/Y results * are inconsistant and may be influenced by I and R registers. * This Z80 emulator assumes a ZiLOG NMOS model. * * Additional changes [Eke-Eke]: * - Discarded multi-chip support (unused) * - Fixed cycle counting for FD and DD prefixed instructions * - Fixed behavior of chained FD and DD prefixes (R register should be only incremented by one * - Implemented cycle-accurate INI/IND (needed by SMS emulation) * - Fixed Z80 reset * Changes in 3.9: * - Fixed cycle counts for LD IYL/IXL/IYH/IXH,n [Marshmellow] * - Fixed X/Y flags in CCF/SCF/BIT, ZEXALL is happy now [hap] * - Simplified DAA, renamed MEMPTR (3.8) to WZ, added TODO [hap] * - Fixed IM2 interrupt cycles [eke] * Changes in 3.8 [Miodrag Milanovic]: * - Added MEMPTR register (according to informations provided * by Vladimir Kladov * - BIT n,(HL) now return valid values due to use of MEMPTR * - Fixed BIT 6,(XY+o) undocumented instructions * Changes in 3.7 [Aaron Giles]: * - Changed NMI handling. NMIs are now latched in set_irq_state * but are not taken there. Instead they are taken at the start of the * execute loop. * - Changed IRQ handling. IRQ state is set in set_irq_state but not taken * except during the inner execute loop. * - Removed x86 assembly hacks and obsolete timing loop catchers. * Changes in 3.6: * - Got rid of the code that would inexactly emulate a Z80, i.e. removed * all the #if Z80_EXACT #else branches. * - Removed leading underscores from local register name shortcuts as * this violates the C99 standard. * - Renamed the registers inside the Z80 context to lower case to avoid * ambiguities (shortcuts would have had the same names as the fields * of the structure). * Changes in 3.5: * - Implemented OTIR, INIR, etc. without look-up table for PF flag. * [Ramsoft, Sean Young] * Changes in 3.4: * - Removed Z80-MSX specific code as it's not needed any more. * - Implemented DAA without look-up table [Ramsoft, Sean Young] * Changes in 3.3: * - Fixed undocumented flags XF & YF in the non-asm versions of CP, * and all the 16 bit arithmetic instructions. [Sean Young] * Changes in 3.2: * - Fixed undocumented flags XF & YF of RRCA, and CF and HF of * INI/IND/OUTI/OUTD/INIR/INDR/OTIR/OTDR [Sean Young] * Changes in 3.1: * - removed the REPEAT_AT_ONCE execution of LDIR/CPIR etc. opcodes * for readabilities sake and because the implementation was buggy * (and I was not able to find the difference) * Changes in 3.0: * - 'finished' switch to dynamically overrideable cycle count tables * Changes in 2.9: * - added methods to access and override the cycle count tables * - fixed handling and timing of multiple DD/FD prefixed opcodes * Changes in 2.8: * - OUTI/OUTD/OTIR/OTDR also pre-decrement the B register now. * This was wrong because of a bug fix on the wrong side * (astrocade sound driver). * Changes in 2.7: * - removed z80_vm specific code, it's not needed (and never was). * Changes in 2.6: * - BUSY_LOOP_HACKS needed to call change_pc() earlier, before * checking the opcodes at the new address, because otherwise they * might access the old (wrong or even NULL) banked memory region. * Thanks to Sean Young for finding this nasty bug. * Changes in 2.5: * - Burning cycles always adjusts the ICount by a multiple of 4. * - In REPEAT_AT_ONCE cases the R register wasn't incremented twice * per repetition as it should have been. Those repeated opcodes * could also underflow the ICount. * - Simplified TIME_LOOP_HACKS for BC and added two more for DE + HL * timing loops. I think those hacks weren't endian safe before too. * Changes in 2.4: * - z80_reset zaps the entire context, sets IX and IY to 0xffff(!) and * sets the Z flag. With these changes the Tehkan World Cup driver * _seems_ to work again. * Changes in 2.3: * - External termination of the execution loop calls z80_burn() and * z80_vm_burn() to burn an amount of cycles (R adjustment) * - Shortcuts which burn CPU cycles (BUSY_LOOP_HACKS and TIME_LOOP_HACKS) * now also adjust the R register depending on the skipped opcodes. * Changes in 2.2: * - Fixed bugs in CPL, SCF and CCF instructions flag handling. * - Changed variable EA and ARG16() function to UINT32; this * produces slightly more efficient code. * - The DD/FD XY CB opcodes where XY is 40-7F and Y is not 6/E * are changed to calls to the X6/XE opcodes to reduce object size. * They're hardly ever used so this should not yield a speed penalty. * New in 2.0: * - Optional more exact Z80 emulation (#define Z80_EXACT 1) according * to a detailed description by Sean Young which can be found at: * http://www.msxnet.org/tech/z80-documented.pdf *****************************************************************************/ #include "../shared.h" #include "z80.h" /* execute main opcodes inside a big switch statement */ #define BIG_SWITCH 1 #define VERBOSE 0 #if VERBOSE #define LOG(x) logerror x #else #define LOG(x) #endif #define cpu_readop(a) z80_readmap[(a) >> 10][(a) & 0x03FF] #define cpu_readop_arg(a) z80_readmap[(a) >> 10][(a) & 0x03FF] #define CF 0x01 #define NF 0x02 #define PF 0x04 #define VF PF #define XF 0x08 #define HF 0x10 #define YF 0x20 #define ZF 0x40 #define SF 0x80 #define INT_IRQ 0x01 #define NMI_IRQ 0x02 #define PCD Z80.pc.d #define PC Z80.pc.w.l #define SPD Z80.sp.d #define SP Z80.sp.w.l #define AFD Z80.af.d #define AF Z80.af.w.l #define A Z80.af.b.h #define F Z80.af.b.l #define BCD Z80.bc.d #define BC Z80.bc.w.l #define B Z80.bc.b.h #define C Z80.bc.b.l #define DED Z80.de.d #define DE Z80.de.w.l #define D Z80.de.b.h #define E Z80.de.b.l #define HLD Z80.hl.d #define HL Z80.hl.w.l #define H Z80.hl.b.h #define L Z80.hl.b.l #define IXD Z80.ix.d #define IX Z80.ix.w.l #define HX Z80.ix.b.h #define LX Z80.ix.b.l #define IYD Z80.iy.d #define IY Z80.iy.w.l #define HY Z80.iy.b.h #define LY Z80.iy.b.l #define WZ Z80.wz.w.l #define WZ_H Z80.wz.b.h #define WZ_L Z80.wz.b.l #define I Z80.i #define R Z80.r #define R2 Z80.r2 #define IM Z80.im #define IFF1 Z80.iff1 #define IFF2 Z80.iff2 #define HALT Z80.halt extern unsigned int mcycles_z80; Z80_Regs Z80; unsigned char *z80_readmap[64]; unsigned char *z80_writemap[64]; void (*z80_writemem)(unsigned int address, unsigned char data); unsigned char (*z80_readmem)(unsigned int port); void (*z80_writeport)(unsigned int port, unsigned char data); unsigned char (*z80_readport)(unsigned int port); static UINT32 EA; static UINT8 SZ[256]; /* zero and sign flags */ static UINT8 SZ_BIT[256]; /* zero, sign and parity/overflow (=zero) flags for BIT opcode */ static UINT8 SZP[256]; /* zero, sign and parity flags */ static UINT8 SZHV_inc[256]; /* zero, sign, half carry and overflow flags INC r8 */ static UINT8 SZHV_dec[256]; /* zero, sign, half carry and overflow flags DEC r8 */ static UINT8 *SZHVC_add = 0; static UINT8 *SZHVC_sub = 0; static const UINT16 cc_op[0x100] = { 4*15,10*15, 7*15, 6*15, 4*15, 4*15, 7*15, 4*15, 4*15,11*15, 7*15, 6*15, 4*15, 4*15, 7*15, 4*15, 8*15,10*15, 7*15, 6*15, 4*15, 4*15, 7*15, 4*15,12*15,11*15, 7*15, 6*15, 4*15, 4*15, 7*15, 4*15, 7*15,10*15,16*15, 6*15, 4*15, 4*15, 7*15, 4*15, 7*15,11*15,16*15, 6*15, 4*15, 4*15, 7*15, 4*15, 7*15,10*15,13*15, 6*15,11*15,11*15,10*15, 4*15, 7*15,11*15,13*15, 6*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 7*15, 7*15, 7*15, 7*15, 7*15, 7*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 7*15, 4*15, 5*15,10*15,10*15,10*15,10*15,11*15, 7*15,11*15, 5*15,10*15,10*15, 0*15,10*15,17*15, 7*15,11*15, 5*15,10*15,10*15,11*15,10*15,11*15, 7*15,11*15, 5*15, 4*15,10*15,11*15,10*15, 0*15, 7*15,11*15, 5*15,10*15,10*15,19*15,10*15,11*15, 7*15,11*15, 5*15, 4*15,10*15, 4*15,10*15, 0*15, 7*15,11*15, 5*15,10*15,10*15, 4*15,10*15,11*15, 7*15,11*15, 5*15, 6*15,10*15, 4*15,10*15, 0*15, 7*15,11*15}; static const UINT16 cc_cb[0x100] = { 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,12*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,12*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,12*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,12*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,12*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,12*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,12*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,12*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15,15*15, 8*15}; static const UINT16 cc_ed[0x100] = { 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 12*15,12*15,15*15,20*15, 8*15,14*15, 8*15, 9*15,12*15,12*15,15*15,20*15, 8*15,14*15, 8*15, 9*15, 12*15,12*15,15*15,20*15, 8*15,14*15, 8*15, 9*15,12*15,12*15,15*15,20*15, 8*15,14*15, 8*15, 9*15, 12*15,12*15,15*15,20*15, 8*15,14*15, 8*15,18*15,12*15,12*15,15*15,20*15, 8*15,14*15, 8*15,18*15, 12*15,12*15,15*15,20*15, 8*15,14*15, 8*15, 8*15,12*15,12*15,15*15,20*15, 8*15,14*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 16*15,16*15,16*15,16*15, 8*15, 8*15, 8*15, 8*15,16*15,16*15,16*15,16*15, 8*15, 8*15, 8*15, 8*15, 16*15,16*15,16*15,16*15, 8*15, 8*15, 8*15, 8*15,16*15,16*15,16*15,16*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15, 8*15}; /*static const UINT8 cc_xy[0x100] = { 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15,15*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15,15*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15,14*15,20*15,10*15, 9*15, 9*15,11*15, 4*15, 4*15,15*15,20*15,10*15, 9*15, 9*15,11*15, 4*15, 4*15, 4*15, 4*15, 4*15,23*15,23*15,19*15, 4*15, 4*15,15*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 9*15, 9*15, 9*15, 9*15, 9*15, 9*15,19*15, 9*15, 9*15, 9*15, 9*15, 9*15, 9*15, 9*15,19*15, 9*15, 19*15,19*15,19*15,19*15,19*15,19*15, 4*15,19*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 9*15, 9*15,19*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 0*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15,14*15, 4*15,23*15, 4*15,15*15, 4*15, 4*15, 4*15, 8*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15,10*15, 4*15, 4*15, 4*15, 4*15, 4*15, 4*15}; */ /* illegal combo should return 4 + cc_op[i] */ static const UINT16 cc_xy[0x100] ={ 8*15,14*15,11*15,10*15, 8*15, 8*15,11*15, 8*15, 8*15,15*15,11*15,10*15, 8*15, 8*15,11*15, 8*15, 12*15,14*15,11*15,10*15, 8*15, 8*15,11*15, 8*15,16*15,15*15,11*15,10*15, 8*15, 8*15,11*15, 8*15, 11*15,14*15,20*15,10*15, 9*15, 9*15,12*15, 8*15,11*15,15*15,20*15,10*15, 9*15, 9*15,12*15, 8*15, 11*15,14*15,17*15,10*15,23*15,23*15,19*15, 8*15,11*15,15*15,17*15,10*15, 8*15, 8*15,11*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 9*15, 9*15, 9*15, 9*15, 9*15, 9*15,19*15, 9*15, 9*15, 9*15, 9*15, 9*15, 9*15, 9*15,19*15, 9*15, 19*15,19*15,19*15,19*15,19*15,19*15, 8*15,19*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 8*15, 8*15, 8*15, 8*15, 9*15, 9*15,19*15, 8*15, 9*15,14*15,14*15,14*15,14*15,15*15,11*15,15*15, 9*15,14*15,14*15, 0*15,14*15,21*15,11*15,15*15, 9*15,14*15,14*15,15*15,14*15,15*15,11*15,15*15, 9*15, 8*15,14*15,15*15,14*15, 4*15,11*15,15*15, 9*15,14*15,14*15,23*15,14*15,15*15,11*15,15*15, 9*15, 8*15,14*15, 8*15,14*15, 4*15,11*15,15*15, 9*15,14*15,14*15, 8*15,14*15,15*15,11*15,15*15, 9*15,10*15,14*15, 8*15,14*15, 4*15,11*15,15*15}; static const UINT16 cc_xycb[0x100] = { 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15, 20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15, 20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15, 20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15,20*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15, 23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15,23*15}; /* extra cycles if jr/jp/call taken and 'interrupt latency' on rst 0-7 */ static const UINT16 cc_ex[0x100] = { 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 5*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, /* DJNZ */ 5*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 5*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, /* JR NZ/JR Z */ 5*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 5*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, /* JR NC/JR C */ 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 4*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 0*15, 4*15, 0*15, 0*15, 0*15, 0*15, 0*15, /* INI/IND (cycle-accurate I/O port reads) */ 5*15, 5*15, 5*15, 5*15, 0*15, 0*15, 0*15, 0*15, 5*15, 5*15, 5*15, 5*15, 0*15, 0*15, 0*15, 0*15, /* LDIR/CPIR/INIR/OTIR LDDR/CPDR/INDR/OTDR */ 6*15, 0*15, 0*15, 0*15, 7*15, 0*15, 0*15, 2*15, 6*15, 0*15, 0*15, 0*15, 7*15, 0*15, 0*15, 2*15, 6*15, 0*15, 0*15, 0*15, 7*15, 0*15, 0*15, 2*15, 6*15, 0*15, 0*15, 0*15, 7*15, 0*15, 0*15, 2*15, 6*15, 0*15, 0*15, 0*15, 7*15, 0*15, 0*15, 2*15, 6*15, 0*15, 0*15, 0*15, 7*15, 0*15, 0*15, 2*15, 6*15, 0*15, 0*15, 0*15, 7*15, 0*15, 0*15, 2*15, 6*15, 0*15, 0*15, 0*15, 7*15, 0*15, 0*15, 2*15}; static const UINT16 *cc[6]; #define Z80_TABLE_dd Z80_TABLE_xy #define Z80_TABLE_fd Z80_TABLE_xy typedef void (*funcptr)(void); #define PROTOTYPES(tablename,prefix) \ INLINE void prefix##_00(void); INLINE void prefix##_01(void); INLINE void prefix##_02(void); INLINE void prefix##_03(void); \ INLINE void prefix##_04(void); INLINE void prefix##_05(void); INLINE void prefix##_06(void); INLINE void prefix##_07(void); \ INLINE void prefix##_08(void); INLINE void prefix##_09(void); INLINE void prefix##_0a(void); INLINE void prefix##_0b(void); \ INLINE void prefix##_0c(void); INLINE void prefix##_0d(void); INLINE void prefix##_0e(void); INLINE void prefix##_0f(void); \ INLINE void prefix##_10(void); INLINE void prefix##_11(void); INLINE void prefix##_12(void); INLINE void prefix##_13(void); \ INLINE void prefix##_14(void); INLINE void prefix##_15(void); INLINE void prefix##_16(void); INLINE void prefix##_17(void); \ INLINE void prefix##_18(void); INLINE void prefix##_19(void); INLINE void prefix##_1a(void); INLINE void prefix##_1b(void); \ INLINE void prefix##_1c(void); INLINE void prefix##_1d(void); INLINE void prefix##_1e(void); INLINE void prefix##_1f(void); \ INLINE void prefix##_20(void); INLINE void prefix##_21(void); INLINE void prefix##_22(void); INLINE void prefix##_23(void); \ INLINE void prefix##_24(void); INLINE void prefix##_25(void); INLINE void prefix##_26(void); INLINE void prefix##_27(void); \ INLINE void prefix##_28(void); INLINE void prefix##_29(void); INLINE void prefix##_2a(void); INLINE void prefix##_2b(void); \ INLINE void prefix##_2c(void); INLINE void prefix##_2d(void); INLINE void prefix##_2e(void); INLINE void prefix##_2f(void); \ INLINE void prefix##_30(void); INLINE void prefix##_31(void); INLINE void prefix##_32(void); INLINE void prefix##_33(void); \ INLINE void prefix##_34(void); INLINE void prefix##_35(void); INLINE void prefix##_36(void); INLINE void prefix##_37(void); \ INLINE void prefix##_38(void); INLINE void prefix##_39(void); INLINE void prefix##_3a(void); INLINE void prefix##_3b(void); \ INLINE void prefix##_3c(void); INLINE void prefix##_3d(void); INLINE void prefix##_3e(void); INLINE void prefix##_3f(void); \ INLINE void prefix##_40(void); INLINE void prefix##_41(void); INLINE void prefix##_42(void); INLINE void prefix##_43(void); \ INLINE void prefix##_44(void); INLINE void prefix##_45(void); INLINE void prefix##_46(void); INLINE void prefix##_47(void); \ INLINE void prefix##_48(void); INLINE void prefix##_49(void); INLINE void prefix##_4a(void); INLINE void prefix##_4b(void); \ INLINE void prefix##_4c(void); INLINE void prefix##_4d(void); INLINE void prefix##_4e(void); INLINE void prefix##_4f(void); \ INLINE void prefix##_50(void); INLINE void prefix##_51(void); INLINE void prefix##_52(void); INLINE void prefix##_53(void); \ INLINE void prefix##_54(void); INLINE void prefix##_55(void); INLINE void prefix##_56(void); INLINE void prefix##_57(void); \ INLINE void prefix##_58(void); INLINE void prefix##_59(void); INLINE void prefix##_5a(void); INLINE void prefix##_5b(void); \ INLINE void prefix##_5c(void); INLINE void prefix##_5d(void); INLINE void prefix##_5e(void); INLINE void prefix##_5f(void); \ INLINE void prefix##_60(void); INLINE void prefix##_61(void); INLINE void prefix##_62(void); INLINE void prefix##_63(void); \ INLINE void prefix##_64(void); INLINE void prefix##_65(void); INLINE void prefix##_66(void); INLINE void prefix##_67(void); \ INLINE void prefix##_68(void); INLINE void prefix##_69(void); INLINE void prefix##_6a(void); INLINE void prefix##_6b(void); \ INLINE void prefix##_6c(void); INLINE void prefix##_6d(void); INLINE void prefix##_6e(void); INLINE void prefix##_6f(void); \ INLINE void prefix##_70(void); INLINE void prefix##_71(void); INLINE void prefix##_72(void); INLINE void prefix##_73(void); \ INLINE void prefix##_74(void); INLINE void prefix##_75(void); INLINE void prefix##_76(void); INLINE void prefix##_77(void); \ INLINE void prefix##_78(void); INLINE void prefix##_79(void); INLINE void prefix##_7a(void); INLINE void prefix##_7b(void); \ INLINE void prefix##_7c(void); INLINE void prefix##_7d(void); INLINE void prefix##_7e(void); INLINE void prefix##_7f(void); \ INLINE void prefix##_80(void); INLINE void prefix##_81(void); INLINE void prefix##_82(void); INLINE void prefix##_83(void); \ INLINE void prefix##_84(void); INLINE void prefix##_85(void); INLINE void prefix##_86(void); INLINE void prefix##_87(void); \ INLINE void prefix##_88(void); INLINE void prefix##_89(void); INLINE void prefix##_8a(void); INLINE void prefix##_8b(void); \ INLINE void prefix##_8c(void); INLINE void prefix##_8d(void); INLINE void prefix##_8e(void); INLINE void prefix##_8f(void); \ INLINE void prefix##_90(void); INLINE void prefix##_91(void); INLINE void prefix##_92(void); INLINE void prefix##_93(void); \ INLINE void prefix##_94(void); INLINE void prefix##_95(void); INLINE void prefix##_96(void); INLINE void prefix##_97(void); \ INLINE void prefix##_98(void); INLINE void prefix##_99(void); INLINE void prefix##_9a(void); INLINE void prefix##_9b(void); \ INLINE void prefix##_9c(void); INLINE void prefix##_9d(void); INLINE void prefix##_9e(void); INLINE void prefix##_9f(void); \ INLINE void prefix##_a0(void); INLINE void prefix##_a1(void); INLINE void prefix##_a2(void); INLINE void prefix##_a3(void); \ INLINE void prefix##_a4(void); INLINE void prefix##_a5(void); INLINE void prefix##_a6(void); INLINE void prefix##_a7(void); \ INLINE void prefix##_a8(void); INLINE void prefix##_a9(void); INLINE void prefix##_aa(void); INLINE void prefix##_ab(void); \ INLINE void prefix##_ac(void); INLINE void prefix##_ad(void); INLINE void prefix##_ae(void); INLINE void prefix##_af(void); \ INLINE void prefix##_b0(void); INLINE void prefix##_b1(void); INLINE void prefix##_b2(void); INLINE void prefix##_b3(void); \ INLINE void prefix##_b4(void); INLINE void prefix##_b5(void); INLINE void prefix##_b6(void); INLINE void prefix##_b7(void); \ INLINE void prefix##_b8(void); INLINE void prefix##_b9(void); INLINE void prefix##_ba(void); INLINE void prefix##_bb(void); \ INLINE void prefix##_bc(void); INLINE void prefix##_bd(void); INLINE void prefix##_be(void); INLINE void prefix##_bf(void); \ INLINE void prefix##_c0(void); INLINE void prefix##_c1(void); INLINE void prefix##_c2(void); INLINE void prefix##_c3(void); \ INLINE void prefix##_c4(void); INLINE void prefix##_c5(void); INLINE void prefix##_c6(void); INLINE void prefix##_c7(void); \ INLINE void prefix##_c8(void); INLINE void prefix##_c9(void); INLINE void prefix##_ca(void); INLINE void prefix##_cb(void); \ INLINE void prefix##_cc(void); INLINE void prefix##_cd(void); INLINE void prefix##_ce(void); INLINE void prefix##_cf(void); \ INLINE void prefix##_d0(void); INLINE void prefix##_d1(void); INLINE void prefix##_d2(void); INLINE void prefix##_d3(void); \ INLINE void prefix##_d4(void); INLINE void prefix##_d5(void); INLINE void prefix##_d6(void); INLINE void prefix##_d7(void); \ INLINE void prefix##_d8(void); INLINE void prefix##_d9(void); INLINE void prefix##_da(void); INLINE void prefix##_db(void); \ INLINE void prefix##_dc(void); INLINE void prefix##_dd(void); INLINE void prefix##_de(void); INLINE void prefix##_df(void); \ INLINE void prefix##_e0(void); INLINE void prefix##_e1(void); INLINE void prefix##_e2(void); INLINE void prefix##_e3(void); \ INLINE void prefix##_e4(void); INLINE void prefix##_e5(void); INLINE void prefix##_e6(void); INLINE void prefix##_e7(void); \ INLINE void prefix##_e8(void); INLINE void prefix##_e9(void); INLINE void prefix##_ea(void); INLINE void prefix##_eb(void); \ INLINE void prefix##_ec(void); INLINE void prefix##_ed(void); INLINE void prefix##_ee(void); INLINE void prefix##_ef(void); \ INLINE void prefix##_f0(void); INLINE void prefix##_f1(void); INLINE void prefix##_f2(void); INLINE void prefix##_f3(void); \ INLINE void prefix##_f4(void); INLINE void prefix##_f5(void); INLINE void prefix##_f6(void); INLINE void prefix##_f7(void); \ INLINE void prefix##_f8(void); INLINE void prefix##_f9(void); INLINE void prefix##_fa(void); INLINE void prefix##_fb(void); \ INLINE void prefix##_fc(void); INLINE void prefix##_fd(void); INLINE void prefix##_fe(void); INLINE void prefix##_ff(void); \ static const funcptr tablename[0x100] = { \ prefix##_00,prefix##_01,prefix##_02,prefix##_03,prefix##_04,prefix##_05,prefix##_06,prefix##_07, \ prefix##_08,prefix##_09,prefix##_0a,prefix##_0b,prefix##_0c,prefix##_0d,prefix##_0e,prefix##_0f, \ prefix##_10,prefix##_11,prefix##_12,prefix##_13,prefix##_14,prefix##_15,prefix##_16,prefix##_17, \ prefix##_18,prefix##_19,prefix##_1a,prefix##_1b,prefix##_1c,prefix##_1d,prefix##_1e,prefix##_1f, \ prefix##_20,prefix##_21,prefix##_22,prefix##_23,prefix##_24,prefix##_25,prefix##_26,prefix##_27, \ prefix##_28,prefix##_29,prefix##_2a,prefix##_2b,prefix##_2c,prefix##_2d,prefix##_2e,prefix##_2f, \ prefix##_30,prefix##_31,prefix##_32,prefix##_33,prefix##_34,prefix##_35,prefix##_36,prefix##_37, \ prefix##_38,prefix##_39,prefix##_3a,prefix##_3b,prefix##_3c,prefix##_3d,prefix##_3e,prefix##_3f, \ prefix##_40,prefix##_41,prefix##_42,prefix##_43,prefix##_44,prefix##_45,prefix##_46,prefix##_47, \ prefix##_48,prefix##_49,prefix##_4a,prefix##_4b,prefix##_4c,prefix##_4d,prefix##_4e,prefix##_4f, \ prefix##_50,prefix##_51,prefix##_52,prefix##_53,prefix##_54,prefix##_55,prefix##_56,prefix##_57, \ prefix##_58,prefix##_59,prefix##_5a,prefix##_5b,prefix##_5c,prefix##_5d,prefix##_5e,prefix##_5f, \ prefix##_60,prefix##_61,prefix##_62,prefix##_63,prefix##_64,prefix##_65,prefix##_66,prefix##_67, \ prefix##_68,prefix##_69,prefix##_6a,prefix##_6b,prefix##_6c,prefix##_6d,prefix##_6e,prefix##_6f, \ prefix##_70,prefix##_71,prefix##_72,prefix##_73,prefix##_74,prefix##_75,prefix##_76,prefix##_77, \ prefix##_78,prefix##_79,prefix##_7a,prefix##_7b,prefix##_7c,prefix##_7d,prefix##_7e,prefix##_7f, \ prefix##_80,prefix##_81,prefix##_82,prefix##_83,prefix##_84,prefix##_85,prefix##_86,prefix##_87, \ prefix##_88,prefix##_89,prefix##_8a,prefix##_8b,prefix##_8c,prefix##_8d,prefix##_8e,prefix##_8f, \ prefix##_90,prefix##_91,prefix##_92,prefix##_93,prefix##_94,prefix##_95,prefix##_96,prefix##_97, \ prefix##_98,prefix##_99,prefix##_9a,prefix##_9b,prefix##_9c,prefix##_9d,prefix##_9e,prefix##_9f, \ prefix##_a0,prefix##_a1,prefix##_a2,prefix##_a3,prefix##_a4,prefix##_a5,prefix##_a6,prefix##_a7, \ prefix##_a8,prefix##_a9,prefix##_aa,prefix##_ab,prefix##_ac,prefix##_ad,prefix##_ae,prefix##_af, \ prefix##_b0,prefix##_b1,prefix##_b2,prefix##_b3,prefix##_b4,prefix##_b5,prefix##_b6,prefix##_b7, \ prefix##_b8,prefix##_b9,prefix##_ba,prefix##_bb,prefix##_bc,prefix##_bd,prefix##_be,prefix##_bf, \ prefix##_c0,prefix##_c1,prefix##_c2,prefix##_c3,prefix##_c4,prefix##_c5,prefix##_c6,prefix##_c7, \ prefix##_c8,prefix##_c9,prefix##_ca,prefix##_cb,prefix##_cc,prefix##_cd,prefix##_ce,prefix##_cf, \ prefix##_d0,prefix##_d1,prefix##_d2,prefix##_d3,prefix##_d4,prefix##_d5,prefix##_d6,prefix##_d7, \ prefix##_d8,prefix##_d9,prefix##_da,prefix##_db,prefix##_dc,prefix##_dd,prefix##_de,prefix##_df, \ prefix##_e0,prefix##_e1,prefix##_e2,prefix##_e3,prefix##_e4,prefix##_e5,prefix##_e6,prefix##_e7, \ prefix##_e8,prefix##_e9,prefix##_ea,prefix##_eb,prefix##_ec,prefix##_ed,prefix##_ee,prefix##_ef, \ prefix##_f0,prefix##_f1,prefix##_f2,prefix##_f3,prefix##_f4,prefix##_f5,prefix##_f6,prefix##_f7, \ prefix##_f8,prefix##_f9,prefix##_fa,prefix##_fb,prefix##_fc,prefix##_fd,prefix##_fe,prefix##_ff \ } PROTOTYPES(Z80op,op); PROTOTYPES(Z80cb,cb); PROTOTYPES(Z80dd,dd); PROTOTYPES(Z80ed,ed); PROTOTYPES(Z80fd,fd); PROTOTYPES(Z80xycb,xycb); /****************************************************************************/ /* Burn an odd amount of cycles, that is instructions taking something */ /* different from 4 T-states per opcode (and R increment) */ /****************************************************************************/ INLINE void BURNODD(int cycles, int opcodes, int cyclesum) { if( cycles > 0 ) { R += (cycles / cyclesum) * opcodes; mcycles_z80 += (cycles / cyclesum) * cyclesum * 15; } } /*************************************************************** * define an opcode function ***************************************************************/ #define OP(prefix,opcode) INLINE void prefix##_##opcode(void) /*************************************************************** * adjust cycle count by n T-states ***************************************************************/ #define CC(prefix,opcode) mcycles_z80 += cc[Z80_TABLE_##prefix][opcode] /*************************************************************** * execute an opcode ***************************************************************/ #define EXEC(prefix,opcode) \ { \ unsigned op = opcode; \ CC(prefix,op); \ (*Z80##prefix[op])(); \ } #if BIG_SWITCH #define EXEC_INLINE(prefix,opcode) \ { \ unsigned op = opcode; \ CC(prefix,op); \ switch(op) \ { \ case 0x00:prefix##_##00();break; case 0x01:prefix##_##01();break; case 0x02:prefix##_##02();break; case 0x03:prefix##_##03();break; \ case 0x04:prefix##_##04();break; case 0x05:prefix##_##05();break; case 0x06:prefix##_##06();break; case 0x07:prefix##_##07();break; \ case 0x08:prefix##_##08();break; case 0x09:prefix##_##09();break; case 0x0a:prefix##_##0a();break; case 0x0b:prefix##_##0b();break; \ case 0x0c:prefix##_##0c();break; case 0x0d:prefix##_##0d();break; case 0x0e:prefix##_##0e();break; case 0x0f:prefix##_##0f();break; \ case 0x10:prefix##_##10();break; case 0x11:prefix##_##11();break; case 0x12:prefix##_##12();break; case 0x13:prefix##_##13();break; \ case 0x14:prefix##_##14();break; case 0x15:prefix##_##15();break; case 0x16:prefix##_##16();break; case 0x17:prefix##_##17();break; \ case 0x18:prefix##_##18();break; case 0x19:prefix##_##19();break; case 0x1a:prefix##_##1a();break; case 0x1b:prefix##_##1b();break; \ case 0x1c:prefix##_##1c();break; case 0x1d:prefix##_##1d();break; case 0x1e:prefix##_##1e();break; case 0x1f:prefix##_##1f();break; \ case 0x20:prefix##_##20();break; case 0x21:prefix##_##21();break; case 0x22:prefix##_##22();break; case 0x23:prefix##_##23();break; \ case 0x24:prefix##_##24();break; case 0x25:prefix##_##25();break; case 0x26:prefix##_##26();break; case 0x27:prefix##_##27();break; \ case 0x28:prefix##_##28();break; case 0x29:prefix##_##29();break; case 0x2a:prefix##_##2a();break; case 0x2b:prefix##_##2b();break; \ case 0x2c:prefix##_##2c();break; case 0x2d:prefix##_##2d();break; case 0x2e:prefix##_##2e();break; case 0x2f:prefix##_##2f();break; \ case 0x30:prefix##_##30();break; case 0x31:prefix##_##31();break; case 0x32:prefix##_##32();break; case 0x33:prefix##_##33();break; \ case 0x34:prefix##_##34();break; case 0x35:prefix##_##35();break; case 0x36:prefix##_##36();break; case 0x37:prefix##_##37();break; \ case 0x38:prefix##_##38();break; case 0x39:prefix##_##39();break; case 0x3a:prefix##_##3a();break; case 0x3b:prefix##_##3b();break; \ case 0x3c:prefix##_##3c();break; case 0x3d:prefix##_##3d();break; case 0x3e:prefix##_##3e();break; case 0x3f:prefix##_##3f();break; \ case 0x40:prefix##_##40();break; case 0x41:prefix##_##41();break; case 0x42:prefix##_##42();break; case 0x43:prefix##_##43();break; \ case 0x44:prefix##_##44();break; case 0x45:prefix##_##45();break; case 0x46:prefix##_##46();break; case 0x47:prefix##_##47();break; \ case 0x48:prefix##_##48();break; case 0x49:prefix##_##49();break; case 0x4a:prefix##_##4a();break; case 0x4b:prefix##_##4b();break; \ case 0x4c:prefix##_##4c();break; case 0x4d:prefix##_##4d();break; case 0x4e:prefix##_##4e();break; case 0x4f:prefix##_##4f();break; \ case 0x50:prefix##_##50();break; case 0x51:prefix##_##51();break; case 0x52:prefix##_##52();break; case 0x53:prefix##_##53();break; \ case 0x54:prefix##_##54();break; case 0x55:prefix##_##55();break; case 0x56:prefix##_##56();break; case 0x57:prefix##_##57();break; \ case 0x58:prefix##_##58();break; case 0x59:prefix##_##59();break; case 0x5a:prefix##_##5a();break; case 0x5b:prefix##_##5b();break; \ case 0x5c:prefix##_##5c();break; case 0x5d:prefix##_##5d();break; case 0x5e:prefix##_##5e();break; case 0x5f:prefix##_##5f();break; \ case 0x60:prefix##_##60();break; case 0x61:prefix##_##61();break; case 0x62:prefix##_##62();break; case 0x63:prefix##_##63();break; \ case 0x64:prefix##_##64();break; case 0x65:prefix##_##65();break; case 0x66:prefix##_##66();break; case 0x67:prefix##_##67();break; \ case 0x68:prefix##_##68();break; case 0x69:prefix##_##69();break; case 0x6a:prefix##_##6a();break; case 0x6b:prefix##_##6b();break; \ case 0x6c:prefix##_##6c();break; case 0x6d:prefix##_##6d();break; case 0x6e:prefix##_##6e();break; case 0x6f:prefix##_##6f();break; \ case 0x70:prefix##_##70();break; case 0x71:prefix##_##71();break; case 0x72:prefix##_##72();break; case 0x73:prefix##_##73();break; \ case 0x74:prefix##_##74();break; case 0x75:prefix##_##75();break; case 0x76:prefix##_##76();break; case 0x77:prefix##_##77();break; \ case 0x78:prefix##_##78();break; case 0x79:prefix##_##79();break; case 0x7a:prefix##_##7a();break; case 0x7b:prefix##_##7b();break; \ case 0x7c:prefix##_##7c();break; case 0x7d:prefix##_##7d();break; case 0x7e:prefix##_##7e();break; case 0x7f:prefix##_##7f();break; \ case 0x80:prefix##_##80();break; case 0x81:prefix##_##81();break; case 0x82:prefix##_##82();break; case 0x83:prefix##_##83();break; \ case 0x84:prefix##_##84();break; case 0x85:prefix##_##85();break; case 0x86:prefix##_##86();break; case 0x87:prefix##_##87();break; \ case 0x88:prefix##_##88();break; case 0x89:prefix##_##89();break; case 0x8a:prefix##_##8a();break; case 0x8b:prefix##_##8b();break; \ case 0x8c:prefix##_##8c();break; case 0x8d:prefix##_##8d();break; case 0x8e:prefix##_##8e();break; case 0x8f:prefix##_##8f();break; \ case 0x90:prefix##_##90();break; case 0x91:prefix##_##91();break; case 0x92:prefix##_##92();break; case 0x93:prefix##_##93();break; \ case 0x94:prefix##_##94();break; case 0x95:prefix##_##95();break; case 0x96:prefix##_##96();break; case 0x97:prefix##_##97();break; \ case 0x98:prefix##_##98();break; case 0x99:prefix##_##99();break; case 0x9a:prefix##_##9a();break; case 0x9b:prefix##_##9b();break; \ case 0x9c:prefix##_##9c();break; case 0x9d:prefix##_##9d();break; case 0x9e:prefix##_##9e();break; case 0x9f:prefix##_##9f();break; \ case 0xa0:prefix##_##a0();break; case 0xa1:prefix##_##a1();break; case 0xa2:prefix##_##a2();break; case 0xa3:prefix##_##a3();break; \ case 0xa4:prefix##_##a4();break; case 0xa5:prefix##_##a5();break; case 0xa6:prefix##_##a6();break; case 0xa7:prefix##_##a7();break; \ case 0xa8:prefix##_##a8();break; case 0xa9:prefix##_##a9();break; case 0xaa:prefix##_##aa();break; case 0xab:prefix##_##ab();break; \ case 0xac:prefix##_##ac();break; case 0xad:prefix##_##ad();break; case 0xae:prefix##_##ae();break; case 0xaf:prefix##_##af();break; \ case 0xb0:prefix##_##b0();break; case 0xb1:prefix##_##b1();break; case 0xb2:prefix##_##b2();break; case 0xb3:prefix##_##b3();break; \ case 0xb4:prefix##_##b4();break; case 0xb5:prefix##_##b5();break; case 0xb6:prefix##_##b6();break; case 0xb7:prefix##_##b7();break; \ case 0xb8:prefix##_##b8();break; case 0xb9:prefix##_##b9();break; case 0xba:prefix##_##ba();break; case 0xbb:prefix##_##bb();break; \ case 0xbc:prefix##_##bc();break; case 0xbd:prefix##_##bd();break; case 0xbe:prefix##_##be();break; case 0xbf:prefix##_##bf();break; \ case 0xc0:prefix##_##c0();break; case 0xc1:prefix##_##c1();break; case 0xc2:prefix##_##c2();break; case 0xc3:prefix##_##c3();break; \ case 0xc4:prefix##_##c4();break; case 0xc5:prefix##_##c5();break; case 0xc6:prefix##_##c6();break; case 0xc7:prefix##_##c7();break; \ case 0xc8:prefix##_##c8();break; case 0xc9:prefix##_##c9();break; case 0xca:prefix##_##ca();break; case 0xcb:prefix##_##cb();break; \ case 0xcc:prefix##_##cc();break; case 0xcd:prefix##_##cd();break; case 0xce:prefix##_##ce();break; case 0xcf:prefix##_##cf();break; \ case 0xd0:prefix##_##d0();break; case 0xd1:prefix##_##d1();break; case 0xd2:prefix##_##d2();break; case 0xd3:prefix##_##d3();break; \ case 0xd4:prefix##_##d4();break; case 0xd5:prefix##_##d5();break; case 0xd6:prefix##_##d6();break; case 0xd7:prefix##_##d7();break; \ case 0xd8:prefix##_##d8();break; case 0xd9:prefix##_##d9();break; case 0xda:prefix##_##da();break; case 0xdb:prefix##_##db();break; \ case 0xdc:prefix##_##dc();break; case 0xdd:prefix##_##dd();break; case 0xde:prefix##_##de();break; case 0xdf:prefix##_##df();break; \ case 0xe0:prefix##_##e0();break; case 0xe1:prefix##_##e1();break; case 0xe2:prefix##_##e2();break; case 0xe3:prefix##_##e3();break; \ case 0xe4:prefix##_##e4();break; case 0xe5:prefix##_##e5();break; case 0xe6:prefix##_##e6();break; case 0xe7:prefix##_##e7();break; \ case 0xe8:prefix##_##e8();break; case 0xe9:prefix##_##e9();break; case 0xea:prefix##_##ea();break; case 0xeb:prefix##_##eb();break; \ case 0xec:prefix##_##ec();break; case 0xed:prefix##_##ed();break; case 0xee:prefix##_##ee();break; case 0xef:prefix##_##ef();break; \ case 0xf0:prefix##_##f0();break; case 0xf1:prefix##_##f1();break; case 0xf2:prefix##_##f2();break; case 0xf3:prefix##_##f3();break; \ case 0xf4:prefix##_##f4();break; case 0xf5:prefix##_##f5();break; case 0xf6:prefix##_##f6();break; case 0xf7:prefix##_##f7();break; \ case 0xf8:prefix##_##f8();break; case 0xf9:prefix##_##f9();break; case 0xfa:prefix##_##fa();break; case 0xfb:prefix##_##fb();break; \ case 0xfc:prefix##_##fc();break; case 0xfd:prefix##_##fd();break; case 0xfe:prefix##_##fe();break; case 0xff:prefix##_##ff();break; \ } \ } #else #define EXEC_INLINE EXEC #endif /*************************************************************** * Enter HALT state; write 1 to fake port on first execution ***************************************************************/ #define ENTER_HALT { \ PC--; \ HALT = 1; \ } /*************************************************************** * Leave HALT state; write 0 to fake port ***************************************************************/ #define LEAVE_HALT { \ if( HALT ) \ { \ HALT = 0; \ PC++; \ } \ } /*************************************************************** * Input a byte from given I/O port ***************************************************************/ #define IN(port) z80_readport(port) /*************************************************************** * Output a byte to given I/O port ***************************************************************/ #define OUT(port,value) z80_writeport(port,value) /*************************************************************** * Read a byte from given memory location ***************************************************************/ #define RM(addr) z80_readmem(addr) /*************************************************************** * Write a byte to given memory location ***************************************************************/ #define WM(addr,value) z80_writemem(addr,value) /*************************************************************** * Read a word from given memory location ***************************************************************/ INLINE void RM16( UINT32 addr, PAIR *r ) { r->b.l = RM(addr); r->b.h = RM((addr+1)&0xffff); } /*************************************************************** * Write a word to given memory location ***************************************************************/ INLINE void WM16( UINT32 addr, PAIR *r ) { WM(addr,r->b.l); WM((addr+1)&0xffff,r->b.h); } /*************************************************************** * ROP() is identical to RM() except it is used for * reading opcodes. In case of system with memory mapped I/O, * this function can be used to greatly speed up emulation ***************************************************************/ INLINE UINT8 ROP(void) { unsigned pc = PCD; PC++; return cpu_readop(pc); } /**************************************************************** * ARG() is identical to ROP() except it is used * for reading opcode arguments. This difference can be used to * support systems that use different encoding mechanisms for * opcodes and opcode arguments ***************************************************************/ INLINE UINT8 ARG(void) { unsigned pc = PCD; PC++; return cpu_readop_arg(pc); } INLINE UINT32 ARG16(void) { unsigned pc = PCD; PC += 2; return cpu_readop_arg(pc) | (cpu_readop_arg((pc+1)&0xffff) << 8); } /*************************************************************** * Calculate the effective address EA of an opcode using * IX+offset resp. IY+offset addressing. ***************************************************************/ #define EAX do { EA = (UINT32)(UINT16)(IX + (INT8)ARG()); WZ = EA; } while (0) #define EAY do { EA = (UINT32)(UINT16)(IY + (INT8)ARG()); WZ = EA; } while (0) /*************************************************************** * POP ***************************************************************/ #define POP(DR) do { RM16( SPD, &Z80.DR ); SP += 2; } while (0) /*************************************************************** * PUSH ***************************************************************/ #define PUSH(SR) do { SP -= 2; WM16( SPD, &Z80.SR ); } while (0) /*************************************************************** * JP ***************************************************************/ #define JP { \ PCD = ARG16(); \ WZ = PCD; \ } /*************************************************************** * JP_COND ***************************************************************/ #define JP_COND(cond) { \ if (cond) \ { \ PCD = ARG16(); \ WZ = PCD; \ } \ else \ { \ WZ = ARG16(); /* implicit do PC += 2 */ \ } \ } /*************************************************************** * JR ***************************************************************/ #define JR() { \ INT8 arg = (INT8)ARG(); /* ARG() also increments PC */ \ PC += arg; /* so don't do PC += ARG() */ \ WZ = PC; \ } /*************************************************************** * JR_COND ***************************************************************/ #define JR_COND(cond, opcode) { \ if (cond) \ { \ JR(); \ CC(ex, opcode); \ } \ else PC++; \ } /*************************************************************** * CALL ***************************************************************/ #define CALL() { \ EA = ARG16(); \ WZ = EA; \ PUSH(pc); \ PCD = EA; \ } /*************************************************************** * CALL_COND ***************************************************************/ #define CALL_COND(cond, opcode) { \ if (cond) \ { \ EA = ARG16(); \ WZ = EA; \ PUSH(pc); \ PCD = EA; \ CC(ex, opcode); \ } \ else \ { \ WZ = ARG16(); /* implicit call PC+=2; */ \ } \ } /*************************************************************** * RET_COND ***************************************************************/ #define RET_COND(cond, opcode) do { \ if (cond) \ { \ POP(pc); \ WZ = PC; \ CC(ex, opcode); \ } \ } while (0) /*************************************************************** * RETN ***************************************************************/ #define RETN do { \ LOG(("Z80 #%d RETN IFF1:%d IFF2:%d\n", cpu_getactivecpu(), IFF1, IFF2)); \ POP( pc ); \ WZ = PC; \ IFF1 = IFF2; \ } while (0) /*************************************************************** * RETI ***************************************************************/ #define RETI { \ POP( pc ); \ WZ = PC; \ /* according to http://www.msxnet.org/tech/z80-documented.pdf */ \ IFF1 = IFF2; \ } /*************************************************************** * LD R,A ***************************************************************/ #define LD_R_A { \ R = A; \ R2 = A & 0x80; /* keep bit 7 of R */ \ } /*************************************************************** * LD A,R ***************************************************************/ #define LD_A_R { \ A = (R & 0x7f) | R2; \ F = (F & CF) | SZ[A] | ( IFF2 << 2 ); \ } /*************************************************************** * LD I,A ***************************************************************/ #define LD_I_A { \ I = A; \ } /*************************************************************** * LD A,I ***************************************************************/ #define LD_A_I { \ A = I; \ F = (F & CF) | SZ[A] | ( IFF2 << 2 ); \ } /*************************************************************** * RST ***************************************************************/ #define RST(addr) \ PUSH( pc ); \ PCD = addr; \ WZ = PC; \ /*************************************************************** * INC r8 ***************************************************************/ INLINE UINT8 INC(UINT8 value) { UINT8 res = value + 1; F = (F & CF) | SZHV_inc[res]; return (UINT8)res; } /*************************************************************** * DEC r8 ***************************************************************/ INLINE UINT8 DEC(UINT8 value) { UINT8 res = value - 1; F = (F & CF) | SZHV_dec[res]; return res; } /*************************************************************** * RLCA ***************************************************************/ #define RLCA \ A = (A << 1) | (A >> 7); \ F = (F & (SF | ZF | PF)) | (A & (YF | XF | CF)) /*************************************************************** * RRCA ***************************************************************/ #define RRCA \ F = (F & (SF | ZF | PF)) | (A & CF); \ A = (A >> 1) | (A << 7); \ F |= (A & (YF | XF) ) /*************************************************************** * RLA ***************************************************************/ #define RLA { \ UINT8 res = (A << 1) | (F & CF); \ UINT8 c = (A & 0x80) ? CF : 0; \ F = (F & (SF | ZF | PF)) | c | (res & (YF | XF)); \ A = res; \ } /*************************************************************** * RRA ***************************************************************/ #define RRA { \ UINT8 res = (A >> 1) | (F << 7); \ UINT8 c = (A & 0x01) ? CF : 0; \ F = (F & (SF | ZF | PF)) | c | (res & (YF | XF)); \ A = res; \ } /*************************************************************** * RRD ***************************************************************/ #define RRD { \ UINT8 n = RM(HL); \ WZ = HL+1; \ WM( HL, (n >> 4) | (A << 4) ); \ A = (A & 0xf0) | (n & 0x0f); \ F = (F & CF) | SZP[A]; \ } /*************************************************************** * RLD ***************************************************************/ #define RLD { \ UINT8 n = RM(HL); \ WZ = HL+1; \ WM( HL, (n << 4) | (A & 0x0f) ); \ A = (A & 0xf0) | (n >> 4); \ F = (F & CF) | SZP[A]; \ } /*************************************************************** * ADD A,n ***************************************************************/ #define ADD(value) \ { \ UINT32 ah = AFD & 0xff00; \ UINT32 res = (UINT8)((ah >> 8) + value); \ F = SZHVC_add[ah | res]; \ A = res; \ } /*************************************************************** * ADC A,n ***************************************************************/ #define ADC(value) \ { \ UINT32 ah = AFD & 0xff00, c = AFD & 1; \ UINT32 res = (UINT8)((ah >> 8) + value + c); \ F = SZHVC_add[(c << 16) | ah | res]; \ A = res; \ } /*************************************************************** * SUB n ***************************************************************/ #define SUB(value) \ { \ UINT32 ah = AFD & 0xff00; \ UINT32 res = (UINT8)((ah >> 8) - value); \ F = SZHVC_sub[ah | res]; \ A = res; \ } /*************************************************************** * SBC A,n ***************************************************************/ #define SBC(value) \ { \ UINT32 ah = AFD & 0xff00, c = AFD & 1; \ UINT32 res = (UINT8)((ah >> 8) - value - c); \ F = SZHVC_sub[(c<<16) | ah | res]; \ A = res; \ } /*************************************************************** * NEG ***************************************************************/ #define NEG { \ UINT8 value = A; \ A = 0; \ SUB(value); \ } /*************************************************************** * DAA ***************************************************************/ #define DAA { \ UINT8 a = A; \ if (F & NF) { \ if ((F&HF) | ((A&0xf)>9)) a-=6; \ if ((F&CF) | (A>0x99)) a-=0x60; \ } \ else { \ if ((F&HF) | ((A&0xf)>9)) a+=6; \ if ((F&CF) | (A>0x99)) a+=0x60; \ } \ \ F = (F&(CF|NF)) | (A>0x99) | ((A^a)&HF) | SZP[a]; \ A = a; \ } /*************************************************************** * AND n ***************************************************************/ #define AND(value) \ A &= value; \ F = SZP[A] | HF /*************************************************************** * OR n ***************************************************************/ #define OR(value) \ A |= value; \ F = SZP[A] /*************************************************************** * XOR n ***************************************************************/ #define XOR(value) \ A ^= value; \ F = SZP[A] /*************************************************************** * CP n ***************************************************************/ #define CP(value) \ { \ unsigned val = value; \ UINT32 ah = AFD & 0xff00; \ UINT32 res = (UINT8)((ah >> 8) - val); \ F = (SZHVC_sub[ah | res] & ~(YF | XF)) | (val & (YF | XF)); \ } /*************************************************************** * EX AF,AF' ***************************************************************/ #define EX_AF \ { \ PAIR tmp; \ tmp = Z80.af; Z80.af = Z80.af2; Z80.af2 = tmp; \ } /*************************************************************** * EX DE,HL ***************************************************************/ #define EX_DE_HL \ { \ PAIR tmp; \ tmp = Z80.de; Z80.de = Z80.hl; Z80.hl = tmp; \ } /*************************************************************** * EXX ***************************************************************/ #define EXX \ { \ PAIR tmp; \ tmp = Z80.bc; Z80.bc = Z80.bc2; Z80.bc2 = tmp; \ tmp = Z80.de; Z80.de = Z80.de2; Z80.de2 = tmp; \ tmp = Z80.hl; Z80.hl = Z80.hl2; Z80.hl2 = tmp; \ } /*************************************************************** * EX (SP),r16 ***************************************************************/ #define EXSP(DR) \ { \ PAIR tmp = { { 0, 0, 0, 0 } }; \ RM16( SPD, &tmp ); \ WM16( SPD, &Z80.DR ); \ Z80.DR = tmp; \ WZ = Z80.DR.d; \ } /*************************************************************** * ADD16 ***************************************************************/ #define ADD16(DR,SR) \ { \ UINT32 res = Z80.DR.d + Z80.SR.d; \ WZ = Z80.DR.d + 1; \ F = (F & (SF | ZF | VF)) | \ (((Z80.DR.d ^ res ^ Z80.SR.d) >> 8) & HF) | \ ((res >> 16) & CF) | ((res >> 8) & (YF | XF)); \ Z80.DR.w.l = (UINT16)res; \ } /*************************************************************** * ADC r16,r16 ***************************************************************/ #define ADC16(Reg) \ { \ UINT32 res = HLD + Z80.Reg.d + (F & CF); \ WZ = HL + 1; \ F = (((HLD ^ res ^ Z80.Reg.d) >> 8) & HF) | \ ((res >> 16) & CF) | \ ((res >> 8) & (SF | YF | XF)) | \ ((res & 0xffff) ? 0 : ZF) | \ (((Z80.Reg.d ^ HLD ^ 0x8000) & (Z80.Reg.d ^ res) & 0x8000) >> 13); \ HL = (UINT16)res; \ } /*************************************************************** * SBC r16,r16 ***************************************************************/ #define SBC16(Reg) \ { \ UINT32 res = HLD - Z80.Reg.d - (F & CF); \ WZ = HL + 1; \ F = (((HLD ^ res ^ Z80.Reg.d) >> 8) & HF) | NF | \ ((res >> 16) & CF) | \ ((res >> 8) & (SF | YF | XF)) | \ ((res & 0xffff) ? 0 : ZF) | \ (((Z80.Reg.d ^ HLD) & (HLD ^ res) &0x8000) >> 13); \ HL = (UINT16)res; \ } /*************************************************************** * RLC r8 ***************************************************************/ INLINE UINT8 RLC(UINT8 value) { unsigned res = value; unsigned c = (res & 0x80) ? CF : 0; res = ((res << 1) | (res >> 7)) & 0xff; F = SZP[res] | c; return res; } /*************************************************************** * RRC r8 ***************************************************************/ INLINE UINT8 RRC(UINT8 value) { unsigned res = value; unsigned c = (res & 0x01) ? CF : 0; res = ((res >> 1) | (res << 7)) & 0xff; F = SZP[res] | c; return res; } /*************************************************************** * RL r8 ***************************************************************/ INLINE UINT8 RL(UINT8 value) { unsigned res = value; unsigned c = (res & 0x80) ? CF : 0; res = ((res << 1) | (F & CF)) & 0xff; F = SZP[res] | c; return res; } /*************************************************************** * RR r8 ***************************************************************/ INLINE UINT8 RR(UINT8 value) { unsigned res = value; unsigned c = (res & 0x01) ? CF : 0; res = ((res >> 1) | (F << 7)) & 0xff; F = SZP[res] | c; return res; } /*************************************************************** * SLA r8 ***************************************************************/ INLINE UINT8 SLA(UINT8 value) { unsigned res = value; unsigned c = (res & 0x80) ? CF : 0; res = (res << 1) & 0xff; F = SZP[res] | c; return res; } /*************************************************************** * SRA r8 ***************************************************************/ INLINE UINT8 SRA(UINT8 value) { unsigned res = value; unsigned c = (res & 0x01) ? CF : 0; res = ((res >> 1) | (res & 0x80)) & 0xff; F = SZP[res] | c; return res; } /*************************************************************** * SLL r8 ***************************************************************/ INLINE UINT8 SLL(UINT8 value) { unsigned res = value; unsigned c = (res & 0x80) ? CF : 0; res = ((res << 1) | 0x01) & 0xff; F = SZP[res] | c; return res; } /*************************************************************** * SRL r8 ***************************************************************/ INLINE UINT8 SRL(UINT8 value) { unsigned res = value; unsigned c = (res & 0x01) ? CF : 0; res = (res >> 1) & 0xff; F = SZP[res] | c; return res; } /*************************************************************** * BIT bit,r8 ***************************************************************/ #undef BIT #define BIT(bit,reg) \ F = (F & CF) | HF | (SZ_BIT[reg & (1<<bit)] & ~(YF|XF)) | (reg & (YF|XF)) /*************************************************************** * BIT bit,(HL) ***************************************************************/ #define BIT_HL(bit,reg) \ F = (F & CF) | HF | (SZ_BIT[reg & (1<<bit)] & ~(YF|XF)) | (WZ_H & (YF|XF)) /*************************************************************** * BIT bit,(IX/Y+o) ***************************************************************/ #define BIT_XY(bit,reg) \ F = (F & CF) | HF | (SZ_BIT[reg & (1<<bit)] & ~(YF|XF)) | ((EA>>8) & (YF|XF)) /*************************************************************** * RES bit,r8 ***************************************************************/ INLINE UINT8 RES(UINT8 bit, UINT8 value) { return value & ~(1<<bit); } /*************************************************************** * SET bit,r8 ***************************************************************/ INLINE UINT8 SET(UINT8 bit, UINT8 value) { return value | (1<<bit); } /*************************************************************** * LDI ***************************************************************/ #define LDI { \ UINT8 io = RM(HL); \ WM( DE, io ); \ F &= SF | ZF | CF; \ if( (A + io) & 0x02 ) F |= YF; /* bit 1 -> flag 5 */ \ if( (A + io) & 0x08 ) F |= XF; /* bit 3 -> flag 3 */ \ HL++; DE++; BC--; \ if( BC ) F |= VF; \ } /*************************************************************** * CPI ***************************************************************/ #define CPI { \ UINT8 val = RM(HL); \ UINT8 res = A - val; \ WZ++; \ HL++; BC--; \ F = (F & CF) | (SZ[res]&~(YF|XF)) | ((A^val^res)&HF) | NF; \ if( F & HF ) res -= 1; \ if( res & 0x02 ) F |= YF; /* bit 1 -> flag 5 */ \ if( res & 0x08 ) F |= XF; /* bit 3 -> flag 3 */ \ if( BC ) F |= VF; \ } /*************************************************************** * INI ***************************************************************/ #define INI { \ unsigned t; \ UINT8 io = IN(BC); \ WZ = BC + 1; \ CC(ex,0xa2); \ B--; \ WM( HL, io ); \ HL++; \ F = SZ[B]; \ t = (unsigned)((C + 1) & 0xff) + (unsigned)io; \ if( io & SF ) F |= NF; \ if( t & 0x100 ) F |= HF | CF; \ F |= SZP[(UINT8)(t & 0x07) ^ B] & PF; \ } /*************************************************************** * OUTI ***************************************************************/ #define OUTI { \ unsigned t; \ UINT8 io = RM(HL); \ B--; \ WZ = BC + 1; \ OUT( BC, io ); \ HL++; \ F = SZ[B]; \ t = (unsigned)L + (unsigned)io; \ if( io & SF ) F |= NF; \ if( t & 0x100 ) F |= HF | CF; \ F |= SZP[(UINT8)(t & 0x07) ^ B] & PF; \ } /*************************************************************** * LDD ***************************************************************/ #define LDD { \ UINT8 io = RM(HL); \ WM( DE, io ); \ F &= SF | ZF | CF; \ if( (A + io) & 0x02 ) F |= YF; /* bit 1 -> flag 5 */ \ if( (A + io) & 0x08 ) F |= XF; /* bit 3 -> flag 3 */ \ HL--; DE--; BC--; \ if( BC ) F |= VF; \ } /*************************************************************** * CPD ***************************************************************/ #define CPD { \ UINT8 val = RM(HL); \ UINT8 res = A - val; \ WZ--; \ HL--; BC--; \ F = (F & CF) | (SZ[res]&~(YF|XF)) | ((A^val^res)&HF) | NF; \ if( F & HF ) res -= 1; \ if( res & 0x02 ) F |= YF; /* bit 1 -> flag 5 */ \ if( res & 0x08 ) F |= XF; /* bit 3 -> flag 3 */ \ if( BC ) F |= VF; \ } /*************************************************************** * IND ***************************************************************/ #define IND { \ unsigned t; \ UINT8 io = IN(BC); \ WZ = BC - 1; \ CC(ex,0xaa); \ B--; \ WM( HL, io ); \ HL--; \ F = SZ[B]; \ t = ((unsigned)(C - 1) & 0xff) + (unsigned)io; \ if( io & SF ) F |= NF; \ if( t & 0x100 ) F |= HF | CF; \ F |= SZP[(UINT8)(t & 0x07) ^ B] & PF; \ } /*************************************************************** * OUTD ***************************************************************/ #define OUTD { \ unsigned t; \ UINT8 io = RM(HL); \ B--; \ WZ = BC - 1; \ OUT( BC, io ); \ HL--; \ F = SZ[B]; \ t = (unsigned)L + (unsigned)io; \ if( io & SF ) F |= NF; \ if( t & 0x100 ) F |= HF | CF; \ F |= SZP[(UINT8)(t & 0x07) ^ B] & PF; \ } /*************************************************************** * LDIR ***************************************************************/ #define LDIR \ LDI; \ if( BC ) \ { \ PC -= 2; \ WZ = PC + 1; \ CC(ex,0xb0); \ } /*************************************************************** * CPIR ***************************************************************/ #define CPIR \ CPI; \ if( BC && !(F & ZF) ) \ { \ PC -= 2; \ WZ = PC + 1; \ CC(ex,0xb1); \ } /*************************************************************** * INIR ***************************************************************/ #define INIR \ INI; \ if( B ) \ { \ PC -= 2; \ CC(ex,0xb2); \ } /*************************************************************** * OTIR ***************************************************************/ #define OTIR \ OUTI; \ if( B ) \ { \ PC -= 2; \ CC(ex,0xb3); \ } /*************************************************************** * LDDR ***************************************************************/ #define LDDR \ LDD; \ if( BC ) \ { \ PC -= 2; \ WZ = PC + 1; \ CC(ex,0xb8); \ } /*************************************************************** * CPDR ***************************************************************/ #define CPDR \ CPD; \ if( BC && !(F & ZF) ) \ { \ PC -= 2; \ WZ = PC + 1; \ CC(ex,0xb9); \ } /*************************************************************** * INDR ***************************************************************/ #define INDR \ IND; \ if( B ) \ { \ PC -= 2; \ CC(ex,0xba); \ } /*************************************************************** * OTDR ***************************************************************/ #define OTDR \ OUTD; \ if( B ) \ { \ PC -= 2; \ CC(ex,0xbb); \ } /*************************************************************** * EI ***************************************************************/ #define EI { \ IFF1 = IFF2 = 1; \ Z80.after_ei = TRUE; \ } /********************************************************** * opcodes with CB prefix * rotate, shift and bit operations **********************************************************/ OP(cb,00) { B = RLC(B); } /* RLC B */ OP(cb,01) { C = RLC(C); } /* RLC C */ OP(cb,02) { D = RLC(D); } /* RLC D */ OP(cb,03) { E = RLC(E); } /* RLC E */ OP(cb,04) { H = RLC(H); } /* RLC H */ OP(cb,05) { L = RLC(L); } /* RLC L */ OP(cb,06) { WM( HL, RLC(RM(HL)) ); } /* RLC (HL) */ OP(cb,07) { A = RLC(A); } /* RLC A */ OP(cb,08) { B = RRC(B); } /* RRC B */ OP(cb,09) { C = RRC(C); } /* RRC C */ OP(cb,0a) { D = RRC(D); } /* RRC D */ OP(cb,0b) { E = RRC(E); } /* RRC E */ OP(cb,0c) { H = RRC(H); } /* RRC H */ OP(cb,0d) { L = RRC(L); } /* RRC L */ OP(cb,0e) { WM( HL, RRC(RM(HL)) ); } /* RRC (HL) */ OP(cb,0f) { A = RRC(A); } /* RRC A */ OP(cb,10) { B = RL(B); } /* RL B */ OP(cb,11) { C = RL(C); } /* RL C */ OP(cb,12) { D = RL(D); } /* RL D */ OP(cb,13) { E = RL(E); } /* RL E */ OP(cb,14) { H = RL(H); } /* RL H */ OP(cb,15) { L = RL(L); } /* RL L */ OP(cb,16) { WM( HL, RL(RM(HL)) ); } /* RL (HL) */ OP(cb,17) { A = RL(A); } /* RL A */ OP(cb,18) { B = RR(B); } /* RR B */ OP(cb,19) { C = RR(C); } /* RR C */ OP(cb,1a) { D = RR(D); } /* RR D */ OP(cb,1b) { E = RR(E); } /* RR E */ OP(cb,1c) { H = RR(H); } /* RR H */ OP(cb,1d) { L = RR(L); } /* RR L */ OP(cb,1e) { WM( HL, RR(RM(HL)) ); } /* RR (HL) */ OP(cb,1f) { A = RR(A); } /* RR A */ OP(cb,20) { B = SLA(B); } /* SLA B */ OP(cb,21) { C = SLA(C); } /* SLA C */ OP(cb,22) { D = SLA(D); } /* SLA D */ OP(cb,23) { E = SLA(E); } /* SLA E */ OP(cb,24) { H = SLA(H); } /* SLA H */ OP(cb,25) { L = SLA(L); } /* SLA L */ OP(cb,26) { WM( HL, SLA(RM(HL)) ); } /* SLA (HL) */ OP(cb,27) { A = SLA(A); } /* SLA A */ OP(cb,28) { B = SRA(B); } /* SRA B */ OP(cb,29) { C = SRA(C); } /* SRA C */ OP(cb,2a) { D = SRA(D); } /* SRA D */ OP(cb,2b) { E = SRA(E); } /* SRA E */ OP(cb,2c) { H = SRA(H); } /* SRA H */ OP(cb,2d) { L = SRA(L); } /* SRA L */ OP(cb,2e) { WM( HL, SRA(RM(HL)) ); } /* SRA (HL) */ OP(cb,2f) { A = SRA(A); } /* SRA A */ OP(cb,30) { B = SLL(B); } /* SLL B */ OP(cb,31) { C = SLL(C); } /* SLL C */ OP(cb,32) { D = SLL(D); } /* SLL D */ OP(cb,33) { E = SLL(E); } /* SLL E */ OP(cb,34) { H = SLL(H); } /* SLL H */ OP(cb,35) { L = SLL(L); } /* SLL L */ OP(cb,36) { WM( HL, SLL(RM(HL)) ); } /* SLL (HL) */ OP(cb,37) { A = SLL(A); } /* SLL A */ OP(cb,38) { B = SRL(B); } /* SRL B */ OP(cb,39) { C = SRL(C); } /* SRL C */ OP(cb,3a) { D = SRL(D); } /* SRL D */ OP(cb,3b) { E = SRL(E); } /* SRL E */ OP(cb,3c) { H = SRL(H); } /* SRL H */ OP(cb,3d) { L = SRL(L); } /* SRL L */ OP(cb,3e) { WM( HL, SRL(RM(HL)) ); } /* SRL (HL) */ OP(cb,3f) { A = SRL(A); } /* SRL A */ OP(cb,40) { BIT(0,B); } /* BIT 0,B */ OP(cb,41) { BIT(0,C); } /* BIT 0,C */ OP(cb,42) { BIT(0,D); } /* BIT 0,D */ OP(cb,43) { BIT(0,E); } /* BIT 0,E */ OP(cb,44) { BIT(0,H); } /* BIT 0,H */ OP(cb,45) { BIT(0,L); } /* BIT 0,L */ OP(cb,46) { BIT_HL(0,RM(HL)); } /* BIT 0,(HL) */ OP(cb,47) { BIT(0,A); } /* BIT 0,A */ OP(cb,48) { BIT(1,B); } /* BIT 1,B */ OP(cb,49) { BIT(1,C); } /* BIT 1,C */ OP(cb,4a) { BIT(1,D); } /* BIT 1,D */ OP(cb,4b) { BIT(1,E); } /* BIT 1,E */ OP(cb,4c) { BIT(1,H); } /* BIT 1,H */ OP(cb,4d) { BIT(1,L); } /* BIT 1,L */ OP(cb,4e) { BIT_HL(1,RM(HL)); } /* BIT 1,(HL) */ OP(cb,4f) { BIT(1,A); } /* BIT 1,A */ OP(cb,50) { BIT(2,B); } /* BIT 2,B */ OP(cb,51) { BIT(2,C); } /* BIT 2,C */ OP(cb,52) { BIT(2,D); } /* BIT 2,D */ OP(cb,53) { BIT(2,E); } /* BIT 2,E */ OP(cb,54) { BIT(2,H); } /* BIT 2,H */ OP(cb,55) { BIT(2,L); } /* BIT 2,L */ OP(cb,56) { BIT_HL(2,RM(HL)); } /* BIT 2,(HL) */ OP(cb,57) { BIT(2,A); } /* BIT 2,A */ OP(cb,58) { BIT(3,B); } /* BIT 3,B */ OP(cb,59) { BIT(3,C); } /* BIT 3,C */ OP(cb,5a) { BIT(3,D); } /* BIT 3,D */ OP(cb,5b) { BIT(3,E); } /* BIT 3,E */ OP(cb,5c) { BIT(3,H); } /* BIT 3,H */ OP(cb,5d) { BIT(3,L); } /* BIT 3,L */ OP(cb,5e) { BIT_HL(3,RM(HL)); } /* BIT 3,(HL) */ OP(cb,5f) { BIT(3,A); } /* BIT 3,A */ OP(cb,60) { BIT(4,B); } /* BIT 4,B */ OP(cb,61) { BIT(4,C); } /* BIT 4,C */ OP(cb,62) { BIT(4,D); } /* BIT 4,D */ OP(cb,63) { BIT(4,E); } /* BIT 4,E */ OP(cb,64) { BIT(4,H); } /* BIT 4,H */ OP(cb,65) { BIT(4,L); } /* BIT 4,L */ OP(cb,66) { BIT_HL(4,RM(HL)); } /* BIT 4,(HL) */ OP(cb,67) { BIT(4,A); } /* BIT 4,A */ OP(cb,68) { BIT(5,B); } /* BIT 5,B */ OP(cb,69) { BIT(5,C); } /* BIT 5,C */ OP(cb,6a) { BIT(5,D); } /* BIT 5,D */ OP(cb,6b) { BIT(5,E); } /* BIT 5,E */ OP(cb,6c) { BIT(5,H); } /* BIT 5,H */ OP(cb,6d) { BIT(5,L); } /* BIT 5,L */ OP(cb,6e) { BIT_HL(5,RM(HL)); } /* BIT 5,(HL) */ OP(cb,6f) { BIT(5,A); } /* BIT 5,A */ OP(cb,70) { BIT(6,B); } /* BIT 6,B */ OP(cb,71) { BIT(6,C); } /* BIT 6,C */ OP(cb,72) { BIT(6,D); } /* BIT 6,D */ OP(cb,73) { BIT(6,E); } /* BIT 6,E */ OP(cb,74) { BIT(6,H); } /* BIT 6,H */ OP(cb,75) { BIT(6,L); } /* BIT 6,L */ OP(cb,76) { BIT_HL(6,RM(HL)); } /* BIT 6,(HL) */ OP(cb,77) { BIT(6,A); } /* BIT 6,A */ OP(cb,78) { BIT(7,B); } /* BIT 7,B */ OP(cb,79) { BIT(7,C); } /* BIT 7,C */ OP(cb,7a) { BIT(7,D); } /* BIT 7,D */ OP(cb,7b) { BIT(7,E); } /* BIT 7,E */ OP(cb,7c) { BIT(7,H); } /* BIT 7,H */ OP(cb,7d) { BIT(7,L); } /* BIT 7,L */ OP(cb,7e) { BIT_HL(7,RM(HL)); } /* BIT 7,(HL) */ OP(cb,7f) { BIT(7,A); } /* BIT 7,A */ OP(cb,80) { B = RES(0,B); } /* RES 0,B */ OP(cb,81) { C = RES(0,C); } /* RES 0,C */ OP(cb,82) { D = RES(0,D); } /* RES 0,D */ OP(cb,83) { E = RES(0,E); } /* RES 0,E */ OP(cb,84) { H = RES(0,H); } /* RES 0,H */ OP(cb,85) { L = RES(0,L); } /* RES 0,L */ OP(cb,86) { WM( HL, RES(0,RM(HL)) ); } /* RES 0,(HL) */ OP(cb,87) { A = RES(0,A); } /* RES 0,A */ OP(cb,88) { B = RES(1,B); } /* RES 1,B */ OP(cb,89) { C = RES(1,C); } /* RES 1,C */ OP(cb,8a) { D = RES(1,D); } /* RES 1,D */ OP(cb,8b) { E = RES(1,E); } /* RES 1,E */ OP(cb,8c) { H = RES(1,H); } /* RES 1,H */ OP(cb,8d) { L = RES(1,L); } /* RES 1,L */ OP(cb,8e) { WM( HL, RES(1,RM(HL)) ); } /* RES 1,(HL) */ OP(cb,8f) { A = RES(1,A); } /* RES 1,A */ OP(cb,90) { B = RES(2,B); } /* RES 2,B */ OP(cb,91) { C = RES(2,C); } /* RES 2,C */ OP(cb,92) { D = RES(2,D); } /* RES 2,D */ OP(cb,93) { E = RES(2,E); } /* RES 2,E */ OP(cb,94) { H = RES(2,H); } /* RES 2,H */ OP(cb,95) { L = RES(2,L); } /* RES 2,L */ OP(cb,96) { WM( HL, RES(2,RM(HL)) ); } /* RES 2,(HL) */ OP(cb,97) { A = RES(2,A); } /* RES 2,A */ OP(cb,98) { B = RES(3,B); } /* RES 3,B */ OP(cb,99) { C = RES(3,C); } /* RES 3,C */ OP(cb,9a) { D = RES(3,D); } /* RES 3,D */ OP(cb,9b) { E = RES(3,E); } /* RES 3,E */ OP(cb,9c) { H = RES(3,H); } /* RES 3,H */ OP(cb,9d) { L = RES(3,L); } /* RES 3,L */ OP(cb,9e) { WM( HL, RES(3,RM(HL)) ); } /* RES 3,(HL) */ OP(cb,9f) { A = RES(3,A); } /* RES 3,A */ OP(cb,a0) { B = RES(4,B); } /* RES 4,B */ OP(cb,a1) { C = RES(4,C); } /* RES 4,C */ OP(cb,a2) { D = RES(4,D); } /* RES 4,D */ OP(cb,a3) { E = RES(4,E); } /* RES 4,E */ OP(cb,a4) { H = RES(4,H); } /* RES 4,H */ OP(cb,a5) { L = RES(4,L); } /* RES 4,L */ OP(cb,a6) { WM( HL, RES(4,RM(HL)) ); } /* RES 4,(HL) */ OP(cb,a7) { A = RES(4,A); } /* RES 4,A */ OP(cb,a8) { B = RES(5,B); } /* RES 5,B */ OP(cb,a9) { C = RES(5,C); } /* RES 5,C */ OP(cb,aa) { D = RES(5,D); } /* RES 5,D */ OP(cb,ab) { E = RES(5,E); } /* RES 5,E */ OP(cb,ac) { H = RES(5,H); } /* RES 5,H */ OP(cb,ad) { L = RES(5,L); } /* RES 5,L */ OP(cb,ae) { WM( HL, RES(5,RM(HL)) ); } /* RES 5,(HL) */ OP(cb,af) { A = RES(5,A); } /* RES 5,A */ OP(cb,b0) { B = RES(6,B); } /* RES 6,B */ OP(cb,b1) { C = RES(6,C); } /* RES 6,C */ OP(cb,b2) { D = RES(6,D); } /* RES 6,D */ OP(cb,b3) { E = RES(6,E); } /* RES 6,E */ OP(cb,b4) { H = RES(6,H); } /* RES 6,H */ OP(cb,b5) { L = RES(6,L); } /* RES 6,L */ OP(cb,b6) { WM( HL, RES(6,RM(HL)) ); } /* RES 6,(HL) */ OP(cb,b7) { A = RES(6,A); } /* RES 6,A */ OP(cb,b8) { B = RES(7,B); } /* RES 7,B */ OP(cb,b9) { C = RES(7,C); } /* RES 7,C */ OP(cb,ba) { D = RES(7,D); } /* RES 7,D */ OP(cb,bb) { E = RES(7,E); } /* RES 7,E */ OP(cb,bc) { H = RES(7,H); } /* RES 7,H */ OP(cb,bd) { L = RES(7,L); } /* RES 7,L */ OP(cb,be) { WM( HL, RES(7,RM(HL)) ); } /* RES 7,(HL) */ OP(cb,bf) { A = RES(7,A); } /* RES 7,A */ OP(cb,c0) { B = SET(0,B); } /* SET 0,B */ OP(cb,c1) { C = SET(0,C); } /* SET 0,C */ OP(cb,c2) { D = SET(0,D); } /* SET 0,D */ OP(cb,c3) { E = SET(0,E); } /* SET 0,E */ OP(cb,c4) { H = SET(0,H); } /* SET 0,H */ OP(cb,c5) { L = SET(0,L); } /* SET 0,L */ OP(cb,c6) { WM( HL, SET(0,RM(HL)) ); } /* SET 0,(HL) */ OP(cb,c7) { A = SET(0,A); } /* SET 0,A */ OP(cb,c8) { B = SET(1,B); } /* SET 1,B */ OP(cb,c9) { C = SET(1,C); } /* SET 1,C */ OP(cb,ca) { D = SET(1,D); } /* SET 1,D */ OP(cb,cb) { E = SET(1,E); } /* SET 1,E */ OP(cb,cc) { H = SET(1,H); } /* SET 1,H */ OP(cb,cd) { L = SET(1,L); } /* SET 1,L */ OP(cb,ce) { WM( HL, SET(1,RM(HL)) ); } /* SET 1,(HL) */ OP(cb,cf) { A = SET(1,A); } /* SET 1,A */ OP(cb,d0) { B = SET(2,B); } /* SET 2,B */ OP(cb,d1) { C = SET(2,C); } /* SET 2,C */ OP(cb,d2) { D = SET(2,D); } /* SET 2,D */ OP(cb,d3) { E = SET(2,E); } /* SET 2,E */ OP(cb,d4) { H = SET(2,H); } /* SET 2,H */ OP(cb,d5) { L = SET(2,L); } /* SET 2,L */ OP(cb,d6) { WM( HL, SET(2,RM(HL)) ); } /* SET 2,(HL) */ OP(cb,d7) { A = SET(2,A); } /* SET 2,A */ OP(cb,d8) { B = SET(3,B); } /* SET 3,B */ OP(cb,d9) { C = SET(3,C); } /* SET 3,C */ OP(cb,da) { D = SET(3,D); } /* SET 3,D */ OP(cb,db) { E = SET(3,E); } /* SET 3,E */ OP(cb,dc) { H = SET(3,H); } /* SET 3,H */ OP(cb,dd) { L = SET(3,L); } /* SET 3,L */ OP(cb,de) { WM( HL, SET(3,RM(HL)) ); } /* SET 3,(HL) */ OP(cb,df) { A = SET(3,A); } /* SET 3,A */ OP(cb,e0) { B = SET(4,B); } /* SET 4,B */ OP(cb,e1) { C = SET(4,C); } /* SET 4,C */ OP(cb,e2) { D = SET(4,D); } /* SET 4,D */ OP(cb,e3) { E = SET(4,E); } /* SET 4,E */ OP(cb,e4) { H = SET(4,H); } /* SET 4,H */ OP(cb,e5) { L = SET(4,L); } /* SET 4,L */ OP(cb,e6) { WM( HL, SET(4,RM(HL)) ); } /* SET 4,(HL) */ OP(cb,e7) { A = SET(4,A); } /* SET 4,A */ OP(cb,e8) { B = SET(5,B); } /* SET 5,B */ OP(cb,e9) { C = SET(5,C); } /* SET 5,C */ OP(cb,ea) { D = SET(5,D); } /* SET 5,D */ OP(cb,eb) { E = SET(5,E); } /* SET 5,E */ OP(cb,ec) { H = SET(5,H); } /* SET 5,H */ OP(cb,ed) { L = SET(5,L); } /* SET 5,L */ OP(cb,ee) { WM( HL, SET(5,RM(HL)) ); } /* SET 5,(HL) */ OP(cb,ef) { A = SET(5,A); } /* SET 5,A */ OP(cb,f0) { B = SET(6,B); } /* SET 6,B */ OP(cb,f1) { C = SET(6,C); } /* SET 6,C */ OP(cb,f2) { D = SET(6,D); } /* SET 6,D */ OP(cb,f3) { E = SET(6,E); } /* SET 6,E */ OP(cb,f4) { H = SET(6,H); } /* SET 6,H */ OP(cb,f5) { L = SET(6,L); } /* SET 6,L */ OP(cb,f6) { WM( HL, SET(6,RM(HL)) ); } /* SET 6,(HL) */ OP(cb,f7) { A = SET(6,A); } /* SET 6,A */ OP(cb,f8) { B = SET(7,B); } /* SET 7,B */ OP(cb,f9) { C = SET(7,C); } /* SET 7,C */ OP(cb,fa) { D = SET(7,D); } /* SET 7,D */ OP(cb,fb) { E = SET(7,E); } /* SET 7,E */ OP(cb,fc) { H = SET(7,H); } /* SET 7,H */ OP(cb,fd) { L = SET(7,L); } /* SET 7,L */ OP(cb,fe) { WM( HL, SET(7,RM(HL)) ); } /* SET 7,(HL) */ OP(cb,ff) { A = SET(7,A); } /* SET 7,A */ /********************************************************** * opcodes with DD/FD CB prefix * rotate, shift and bit operations with (IX+o) **********************************************************/ OP(xycb,00) { B = RLC( RM(EA) ); WM( EA,B ); } /* RLC B=(XY+o) */ OP(xycb,01) { C = RLC( RM(EA) ); WM( EA,C ); } /* RLC C=(XY+o) */ OP(xycb,02) { D = RLC( RM(EA) ); WM( EA,D ); } /* RLC D=(XY+o) */ OP(xycb,03) { E = RLC( RM(EA) ); WM( EA,E ); } /* RLC E=(XY+o) */ OP(xycb,04) { H = RLC( RM(EA) ); WM( EA,H ); } /* RLC H=(XY+o) */ OP(xycb,05) { L = RLC( RM(EA) ); WM( EA,L ); } /* RLC L=(XY+o) */ OP(xycb,06) { WM( EA, RLC( RM(EA) ) ); } /* RLC (XY+o) */ OP(xycb,07) { A = RLC( RM(EA) ); WM( EA,A ); } /* RLC A=(XY+o) */ OP(xycb,08) { B = RRC( RM(EA) ); WM( EA,B ); } /* RRC B=(XY+o) */ OP(xycb,09) { C = RRC( RM(EA) ); WM( EA,C ); } /* RRC C=(XY+o) */ OP(xycb,0a) { D = RRC( RM(EA) ); WM( EA,D ); } /* RRC D=(XY+o) */ OP(xycb,0b) { E = RRC( RM(EA) ); WM( EA,E ); } /* RRC E=(XY+o) */ OP(xycb,0c) { H = RRC( RM(EA) ); WM( EA,H ); } /* RRC H=(XY+o) */ OP(xycb,0d) { L = RRC( RM(EA) ); WM( EA,L ); } /* RRC L=(XY+o) */ OP(xycb,0e) { WM( EA,RRC( RM(EA) ) ); } /* RRC (XY+o) */ OP(xycb,0f) { A = RRC( RM(EA) ); WM( EA,A ); } /* RRC A=(XY+o) */ OP(xycb,10) { B = RL( RM(EA) ); WM( EA,B ); } /* RL B=(XY+o) */ OP(xycb,11) { C = RL( RM(EA) ); WM( EA,C ); } /* RL C=(XY+o) */ OP(xycb,12) { D = RL( RM(EA) ); WM( EA,D ); } /* RL D=(XY+o) */ OP(xycb,13) { E = RL( RM(EA) ); WM( EA,E ); } /* RL E=(XY+o) */ OP(xycb,14) { H = RL( RM(EA) ); WM( EA,H ); } /* RL H=(XY+o) */ OP(xycb,15) { L = RL( RM(EA) ); WM( EA,L ); } /* RL L=(XY+o) */ OP(xycb,16) { WM( EA,RL( RM(EA) ) ); } /* RL (XY+o) */ OP(xycb,17) { A = RL( RM(EA) ); WM( EA,A ); } /* RL A=(XY+o) */ OP(xycb,18) { B = RR( RM(EA) ); WM( EA,B ); } /* RR B=(XY+o) */ OP(xycb,19) { C = RR( RM(EA) ); WM( EA,C ); } /* RR C=(XY+o) */ OP(xycb,1a) { D = RR( RM(EA) ); WM( EA,D ); } /* RR D=(XY+o) */ OP(xycb,1b) { E = RR( RM(EA) ); WM( EA,E ); } /* RR E=(XY+o) */ OP(xycb,1c) { H = RR( RM(EA) ); WM( EA,H ); } /* RR H=(XY+o) */ OP(xycb,1d) { L = RR( RM(EA) ); WM( EA,L ); } /* RR L=(XY+o) */ OP(xycb,1e) { WM( EA,RR( RM(EA) ) ); } /* RR (XY+o) */ OP(xycb,1f) { A = RR( RM(EA) ); WM( EA,A ); } /* RR A=(XY+o) */ OP(xycb,20) { B = SLA( RM(EA) ); WM( EA,B ); } /* SLA B=(XY+o) */ OP(xycb,21) { C = SLA( RM(EA) ); WM( EA,C ); } /* SLA C=(XY+o) */ OP(xycb,22) { D = SLA( RM(EA) ); WM( EA,D ); } /* SLA D=(XY+o) */ OP(xycb,23) { E = SLA( RM(EA) ); WM( EA,E ); } /* SLA E=(XY+o) */ OP(xycb,24) { H = SLA( RM(EA) ); WM( EA,H ); } /* SLA H=(XY+o) */ OP(xycb,25) { L = SLA( RM(EA) ); WM( EA,L ); } /* SLA L=(XY+o) */ OP(xycb,26) { WM( EA,SLA( RM(EA) ) ); } /* SLA (XY+o) */ OP(xycb,27) { A = SLA( RM(EA) ); WM( EA,A ); } /* SLA A=(XY+o) */ OP(xycb,28) { B = SRA( RM(EA) ); WM( EA,B ); } /* SRA B=(XY+o) */ OP(xycb,29) { C = SRA( RM(EA) ); WM( EA,C ); } /* SRA C=(XY+o) */ OP(xycb,2a) { D = SRA( RM(EA) ); WM( EA,D ); } /* SRA D=(XY+o) */ OP(xycb,2b) { E = SRA( RM(EA) ); WM( EA,E ); } /* SRA E=(XY+o) */ OP(xycb,2c) { H = SRA( RM(EA) ); WM( EA,H ); } /* SRA H=(XY+o) */ OP(xycb,2d) { L = SRA( RM(EA) ); WM( EA,L ); } /* SRA L=(XY+o) */ OP(xycb,2e) { WM( EA,SRA( RM(EA) ) ); } /* SRA (XY+o) */ OP(xycb,2f) { A = SRA( RM(EA) ); WM( EA,A ); } /* SRA A=(XY+o) */ OP(xycb,30) { B = SLL( RM(EA) ); WM( EA,B ); } /* SLL B=(XY+o) */ OP(xycb,31) { C = SLL( RM(EA) ); WM( EA,C ); } /* SLL C=(XY+o) */ OP(xycb,32) { D = SLL( RM(EA) ); WM( EA,D ); } /* SLL D=(XY+o) */ OP(xycb,33) { E = SLL( RM(EA) ); WM( EA,E ); } /* SLL E=(XY+o) */ OP(xycb,34) { H = SLL( RM(EA) ); WM( EA,H ); } /* SLL H=(XY+o) */ OP(xycb,35) { L = SLL( RM(EA) ); WM( EA,L ); } /* SLL L=(XY+o) */ OP(xycb,36) { WM( EA,SLL( RM(EA) ) ); } /* SLL (XY+o) */ OP(xycb,37) { A = SLL( RM(EA) ); WM( EA,A ); } /* SLL A=(XY+o) */ OP(xycb,38) { B = SRL( RM(EA) ); WM( EA,B ); } /* SRL B=(XY+o) */ OP(xycb,39) { C = SRL( RM(EA) ); WM( EA,C ); } /* SRL C=(XY+o) */ OP(xycb,3a) { D = SRL( RM(EA) ); WM( EA,D ); } /* SRL D=(XY+o) */ OP(xycb,3b) { E = SRL( RM(EA) ); WM( EA,E ); } /* SRL E=(XY+o) */ OP(xycb,3c) { H = SRL( RM(EA) ); WM( EA,H ); } /* SRL H=(XY+o) */ OP(xycb,3d) { L = SRL( RM(EA) ); WM( EA,L ); } /* SRL L=(XY+o) */ OP(xycb,3e) { WM( EA,SRL( RM(EA) ) ); } /* SRL (XY+o) */ OP(xycb,3f) { A = SRL( RM(EA) ); WM( EA,A ); } /* SRL A=(XY+o) */ OP(xycb,40) { xycb_46(); } /* BIT 0,(XY+o) */ OP(xycb,41) { xycb_46(); } /* BIT 0,(XY+o) */ OP(xycb,42) { xycb_46(); } /* BIT 0,(XY+o) */ OP(xycb,43) { xycb_46(); } /* BIT 0,(XY+o) */ OP(xycb,44) { xycb_46(); } /* BIT 0,(XY+o) */ OP(xycb,45) { xycb_46(); } /* BIT 0,(XY+o) */ OP(xycb,46) { BIT_XY(0,RM(EA)); } /* BIT 0,(XY+o) */ OP(xycb,47) { xycb_46(); } /* BIT 0,(XY+o) */ OP(xycb,48) { xycb_4e(); } /* BIT 1,(XY+o) */ OP(xycb,49) { xycb_4e(); } /* BIT 1,(XY+o) */ OP(xycb,4a) { xycb_4e(); } /* BIT 1,(XY+o) */ OP(xycb,4b) { xycb_4e(); } /* BIT 1,(XY+o) */ OP(xycb,4c) { xycb_4e(); } /* BIT 1,(XY+o) */ OP(xycb,4d) { xycb_4e(); } /* BIT 1,(XY+o) */ OP(xycb,4e) { BIT_XY(1,RM(EA)); } /* BIT 1,(XY+o) */ OP(xycb,4f) { xycb_4e(); } /* BIT 1,(XY+o) */ OP(xycb,50) { xycb_56(); } /* BIT 2,(XY+o) */ OP(xycb,51) { xycb_56(); } /* BIT 2,(XY+o) */ OP(xycb,52) { xycb_56(); } /* BIT 2,(XY+o) */ OP(xycb,53) { xycb_56(); } /* BIT 2,(XY+o) */ OP(xycb,54) { xycb_56(); } /* BIT 2,(XY+o) */ OP(xycb,55) { xycb_56(); } /* BIT 2,(XY+o) */ OP(xycb,56) { BIT_XY(2,RM(EA)); } /* BIT 2,(XY+o) */ OP(xycb,57) { xycb_56(); } /* BIT 2,(XY+o) */ OP(xycb,58) { xycb_5e(); } /* BIT 3,(XY+o) */ OP(xycb,59) { xycb_5e(); } /* BIT 3,(XY+o) */ OP(xycb,5a) { xycb_5e(); } /* BIT 3,(XY+o) */ OP(xycb,5b) { xycb_5e(); } /* BIT 3,(XY+o) */ OP(xycb,5c) { xycb_5e(); } /* BIT 3,(XY+o) */ OP(xycb,5d) { xycb_5e(); } /* BIT 3,(XY+o) */ OP(xycb,5e) { BIT_XY(3,RM(EA)); } /* BIT 3,(XY+o) */ OP(xycb,5f) { xycb_5e(); } /* BIT 3,(XY+o) */ OP(xycb,60) { xycb_66(); } /* BIT 4,(XY+o) */ OP(xycb,61) { xycb_66(); } /* BIT 4,(XY+o) */ OP(xycb,62) { xycb_66(); } /* BIT 4,(XY+o) */ OP(xycb,63) { xycb_66(); } /* BIT 4,(XY+o) */ OP(xycb,64) { xycb_66(); } /* BIT 4,(XY+o) */ OP(xycb,65) { xycb_66(); } /* BIT 4,(XY+o) */ OP(xycb,66) { BIT_XY(4,RM(EA)); } /* BIT 4,(XY+o) */ OP(xycb,67) { xycb_66(); } /* BIT 4,(XY+o) */ OP(xycb,68) { xycb_6e(); } /* BIT 5,(XY+o) */ OP(xycb,69) { xycb_6e(); } /* BIT 5,(XY+o) */ OP(xycb,6a) { xycb_6e(); } /* BIT 5,(XY+o) */ OP(xycb,6b) { xycb_6e(); } /* BIT 5,(XY+o) */ OP(xycb,6c) { xycb_6e(); } /* BIT 5,(XY+o) */ OP(xycb,6d) { xycb_6e(); } /* BIT 5,(XY+o) */ OP(xycb,6e) { BIT_XY(5,RM(EA)); } /* BIT 5,(XY+o) */ OP(xycb,6f) { xycb_6e(); } /* BIT 5,(XY+o) */ OP(xycb,70) { xycb_76(); } /* BIT 6,(XY+o) */ OP(xycb,71) { xycb_76(); } /* BIT 6,(XY+o) */ OP(xycb,72) { xycb_76(); } /* BIT 6,(XY+o) */ OP(xycb,73) { xycb_76(); } /* BIT 6,(XY+o) */ OP(xycb,74) { xycb_76(); } /* BIT 6,(XY+o) */ OP(xycb,75) { xycb_76(); } /* BIT 6,(XY+o) */ OP(xycb,76) { BIT_XY(6,RM(EA)); } /* BIT 6,(XY+o) */ OP(xycb,77) { xycb_76(); } /* BIT 6,(XY+o) */ OP(xycb,78) { xycb_7e(); } /* BIT 7,(XY+o) */ OP(xycb,79) { xycb_7e(); } /* BIT 7,(XY+o) */ OP(xycb,7a) { xycb_7e(); } /* BIT 7,(XY+o) */ OP(xycb,7b) { xycb_7e(); } /* BIT 7,(XY+o) */ OP(xycb,7c) { xycb_7e(); } /* BIT 7,(XY+o) */ OP(xycb,7d) { xycb_7e(); } /* BIT 7,(XY+o) */ OP(xycb,7e) { BIT_XY(7,RM(EA)); } /* BIT 7,(XY+o) */ OP(xycb,7f) { xycb_7e(); } /* BIT 7,(XY+o) */ OP(xycb,80) { B = RES(0, RM(EA) ); WM( EA,B ); } /* RES 0,B=(XY+o) */ OP(xycb,81) { C = RES(0, RM(EA) ); WM( EA,C ); } /* RES 0,C=(XY+o) */ OP(xycb,82) { D = RES(0, RM(EA) ); WM( EA,D ); } /* RES 0,D=(XY+o) */ OP(xycb,83) { E = RES(0, RM(EA) ); WM( EA,E ); } /* RES 0,E=(XY+o) */ OP(xycb,84) { H = RES(0, RM(EA) ); WM( EA,H ); } /* RES 0,H=(XY+o) */ OP(xycb,85) { L = RES(0, RM(EA) ); WM( EA,L ); } /* RES 0,L=(XY+o) */ OP(xycb,86) { WM( EA, RES(0,RM(EA)) ); } /* RES 0,(XY+o) */ OP(xycb,87) { A = RES(0, RM(EA) ); WM( EA,A ); } /* RES 0,A=(XY+o) */ OP(xycb,88) { B = RES(1, RM(EA) ); WM( EA,B ); } /* RES 1,B=(XY+o) */ OP(xycb,89) { C = RES(1, RM(EA) ); WM( EA,C ); } /* RES 1,C=(XY+o) */ OP(xycb,8a) { D = RES(1, RM(EA) ); WM( EA,D ); } /* RES 1,D=(XY+o) */ OP(xycb,8b) { E = RES(1, RM(EA) ); WM( EA,E ); } /* RES 1,E=(XY+o) */ OP(xycb,8c) { H = RES(1, RM(EA) ); WM( EA,H ); } /* RES 1,H=(XY+o) */ OP(xycb,8d) { L = RES(1, RM(EA) ); WM( EA,L ); } /* RES 1,L=(XY+o) */ OP(xycb,8e) { WM( EA, RES(1,RM(EA)) ); } /* RES 1,(XY+o) */ OP(xycb,8f) { A = RES(1, RM(EA) ); WM( EA,A ); } /* RES 1,A=(XY+o) */ OP(xycb,90) { B = RES(2, RM(EA) ); WM( EA,B ); } /* RES 2,B=(XY+o) */ OP(xycb,91) { C = RES(2, RM(EA) ); WM( EA,C ); } /* RES 2,C=(XY+o) */ OP(xycb,92) { D = RES(2, RM(EA) ); WM( EA,D ); } /* RES 2,D=(XY+o) */ OP(xycb,93) { E = RES(2, RM(EA) ); WM( EA,E ); } /* RES 2,E=(XY+o) */ OP(xycb,94) { H = RES(2, RM(EA) ); WM( EA,H ); } /* RES 2,H=(XY+o) */ OP(xycb,95) { L = RES(2, RM(EA) ); WM( EA,L ); } /* RES 2,L=(XY+o) */ OP(xycb,96) { WM( EA, RES(2,RM(EA)) ); } /* RES 2,(XY+o) */ OP(xycb,97) { A = RES(2, RM(EA) ); WM( EA,A ); } /* RES 2,A=(XY+o) */ OP(xycb,98) { B = RES(3, RM(EA) ); WM( EA,B ); } /* RES 3,B=(XY+o) */ OP(xycb,99) { C = RES(3, RM(EA) ); WM( EA,C ); } /* RES 3,C=(XY+o) */ OP(xycb,9a) { D = RES(3, RM(EA) ); WM( EA,D ); } /* RES 3,D=(XY+o) */ OP(xycb,9b) { E = RES(3, RM(EA) ); WM( EA,E ); } /* RES 3,E=(XY+o) */ OP(xycb,9c) { H = RES(3, RM(EA) ); WM( EA,H ); } /* RES 3,H=(XY+o) */ OP(xycb,9d) { L = RES(3, RM(EA) ); WM( EA,L ); } /* RES 3,L=(XY+o) */ OP(xycb,9e) { WM( EA, RES(3,RM(EA)) ); } /* RES 3,(XY+o) */ OP(xycb,9f) { A = RES(3, RM(EA) ); WM( EA,A ); } /* RES 3,A=(XY+o) */ OP(xycb,a0) { B = RES(4, RM(EA) ); WM( EA,B ); } /* RES 4,B=(XY+o) */ OP(xycb,a1) { C = RES(4, RM(EA) ); WM( EA,C ); } /* RES 4,C=(XY+o) */ OP(xycb,a2) { D = RES(4, RM(EA) ); WM( EA,D ); } /* RES 4,D=(XY+o) */ OP(xycb,a3) { E = RES(4, RM(EA) ); WM( EA,E ); } /* RES 4,E=(XY+o) */ OP(xycb,a4) { H = RES(4, RM(EA) ); WM( EA,H ); } /* RES 4,H=(XY+o) */ OP(xycb,a5) { L = RES(4, RM(EA) ); WM( EA,L ); } /* RES 4,L=(XY+o) */ OP(xycb,a6) { WM( EA, RES(4,RM(EA)) ); } /* RES 4,(XY+o) */ OP(xycb,a7) { A = RES(4, RM(EA) ); WM( EA,A ); } /* RES 4,A=(XY+o) */ OP(xycb,a8) { B = RES(5, RM(EA) ); WM( EA,B ); } /* RES 5,B=(XY+o) */ OP(xycb,a9) { C = RES(5, RM(EA) ); WM( EA,C ); } /* RES 5,C=(XY+o) */ OP(xycb,aa) { D = RES(5, RM(EA) ); WM( EA,D ); } /* RES 5,D=(XY+o) */ OP(xycb,ab) { E = RES(5, RM(EA) ); WM( EA,E ); } /* RES 5,E=(XY+o) */ OP(xycb,ac) { H = RES(5, RM(EA) ); WM( EA,H ); } /* RES 5,H=(XY+o) */ OP(xycb,ad) { L = RES(5, RM(EA) ); WM( EA,L ); } /* RES 5,L=(XY+o) */ OP(xycb,ae) { WM( EA, RES(5,RM(EA)) ); } /* RES 5,(XY+o) */ OP(xycb,af) { A = RES(5, RM(EA) ); WM( EA,A ); } /* RES 5,A=(XY+o) */ OP(xycb,b0) { B = RES(6, RM(EA) ); WM( EA,B ); } /* RES 6,B=(XY+o) */ OP(xycb,b1) { C = RES(6, RM(EA) ); WM( EA,C ); } /* RES 6,C=(XY+o) */ OP(xycb,b2) { D = RES(6, RM(EA) ); WM( EA,D ); } /* RES 6,D=(XY+o) */ OP(xycb,b3) { E = RES(6, RM(EA) ); WM( EA,E ); } /* RES 6,E=(XY+o) */ OP(xycb,b4) { H = RES(6, RM(EA) ); WM( EA,H ); } /* RES 6,H=(XY+o) */ OP(xycb,b5) { L = RES(6, RM(EA) ); WM( EA,L ); } /* RES 6,L=(XY+o) */ OP(xycb,b6) { WM( EA, RES(6,RM(EA)) ); } /* RES 6,(XY+o) */ OP(xycb,b7) { A = RES(6, RM(EA) ); WM( EA,A ); } /* RES 6,A=(XY+o) */ OP(xycb,b8) { B = RES(7, RM(EA) ); WM( EA,B ); } /* RES 7,B=(XY+o) */ OP(xycb,b9) { C = RES(7, RM(EA) ); WM( EA,C ); } /* RES 7,C=(XY+o) */ OP(xycb,ba) { D = RES(7, RM(EA) ); WM( EA,D ); } /* RES 7,D=(XY+o) */ OP(xycb,bb) { E = RES(7, RM(EA) ); WM( EA,E ); } /* RES 7,E=(XY+o) */ OP(xycb,bc) { H = RES(7, RM(EA) ); WM( EA,H ); } /* RES 7,H=(XY+o) */ OP(xycb,bd) { L = RES(7, RM(EA) ); WM( EA,L ); } /* RES 7,L=(XY+o) */ OP(xycb,be) { WM( EA, RES(7,RM(EA)) ); } /* RES 7,(XY+o) */ OP(xycb,bf) { A = RES(7, RM(EA) ); WM( EA,A ); } /* RES 7,A=(XY+o) */ OP(xycb,c0) { B = SET(0, RM(EA) ); WM( EA,B ); } /* SET 0,B=(XY+o) */ OP(xycb,c1) { C = SET(0, RM(EA) ); WM( EA,C ); } /* SET 0,C=(XY+o) */ OP(xycb,c2) { D = SET(0, RM(EA) ); WM( EA,D ); } /* SET 0,D=(XY+o) */ OP(xycb,c3) { E = SET(0, RM(EA) ); WM( EA,E ); } /* SET 0,E=(XY+o) */ OP(xycb,c4) { H = SET(0, RM(EA) ); WM( EA,H ); } /* SET 0,H=(XY+o) */ OP(xycb,c5) { L = SET(0, RM(EA) ); WM( EA,L ); } /* SET 0,L=(XY+o) */ OP(xycb,c6) { WM( EA, SET(0,RM(EA)) ); } /* SET 0,(XY+o) */ OP(xycb,c7) { A = SET(0, RM(EA) ); WM( EA,A ); } /* SET 0,A=(XY+o) */ OP(xycb,c8) { B = SET(1, RM(EA) ); WM( EA,B ); } /* SET 1,B=(XY+o) */ OP(xycb,c9) { C = SET(1, RM(EA) ); WM( EA,C ); } /* SET 1,C=(XY+o) */ OP(xycb,ca) { D = SET(1, RM(EA) ); WM( EA,D ); } /* SET 1,D=(XY+o) */ OP(xycb,cb) { E = SET(1, RM(EA) ); WM( EA,E ); } /* SET 1,E=(XY+o) */ OP(xycb,cc) { H = SET(1, RM(EA) ); WM( EA,H ); } /* SET 1,H=(XY+o) */ OP(xycb,cd) { L = SET(1, RM(EA) ); WM( EA,L ); } /* SET 1,L=(XY+o) */ OP(xycb,ce) { WM( EA, SET(1,RM(EA)) ); } /* SET 1,(XY+o) */ OP(xycb,cf) { A = SET(1, RM(EA) ); WM( EA,A ); } /* SET 1,A=(XY+o) */ OP(xycb,d0) { B = SET(2, RM(EA) ); WM( EA,B ); } /* SET 2,B=(XY+o) */ OP(xycb,d1) { C = SET(2, RM(EA) ); WM( EA,C ); } /* SET 2,C=(XY+o) */ OP(xycb,d2) { D = SET(2, RM(EA) ); WM( EA,D ); } /* SET 2,D=(XY+o) */ OP(xycb,d3) { E = SET(2, RM(EA) ); WM( EA,E ); } /* SET 2,E=(XY+o) */ OP(xycb,d4) { H = SET(2, RM(EA) ); WM( EA,H ); } /* SET 2,H=(XY+o) */ OP(xycb,d5) { L = SET(2, RM(EA) ); WM( EA,L ); } /* SET 2,L=(XY+o) */ OP(xycb,d6) { WM( EA, SET(2,RM(EA)) ); } /* SET 2,(XY+o) */ OP(xycb,d7) { A = SET(2, RM(EA) ); WM( EA,A ); } /* SET 2,A=(XY+o) */ OP(xycb,d8) { B = SET(3, RM(EA) ); WM( EA,B ); } /* SET 3,B=(XY+o) */ OP(xycb,d9) { C = SET(3, RM(EA) ); WM( EA,C ); } /* SET 3,C=(XY+o) */ OP(xycb,da) { D = SET(3, RM(EA) ); WM( EA,D ); } /* SET 3,D=(XY+o) */ OP(xycb,db) { E = SET(3, RM(EA) ); WM( EA,E ); } /* SET 3,E=(XY+o) */ OP(xycb,dc) { H = SET(3, RM(EA) ); WM( EA,H ); } /* SET 3,H=(XY+o) */ OP(xycb,dd) { L = SET(3, RM(EA) ); WM( EA,L ); } /* SET 3,L=(XY+o) */ OP(xycb,de) { WM( EA, SET(3,RM(EA)) ); } /* SET 3,(XY+o) */ OP(xycb,df) { A = SET(3, RM(EA) ); WM( EA,A ); } /* SET 3,A=(XY+o) */ OP(xycb,e0) { B = SET(4, RM(EA) ); WM( EA,B ); } /* SET 4,B=(XY+o) */ OP(xycb,e1) { C = SET(4, RM(EA) ); WM( EA,C ); } /* SET 4,C=(XY+o) */ OP(xycb,e2) { D = SET(4, RM(EA) ); WM( EA,D ); } /* SET 4,D=(XY+o) */ OP(xycb,e3) { E = SET(4, RM(EA) ); WM( EA,E ); } /* SET 4,E=(XY+o) */ OP(xycb,e4) { H = SET(4, RM(EA) ); WM( EA,H ); } /* SET 4,H=(XY+o) */ OP(xycb,e5) { L = SET(4, RM(EA) ); WM( EA,L ); } /* SET 4,L=(XY+o) */ OP(xycb,e6) { WM( EA, SET(4,RM(EA)) ); } /* SET 4,(XY+o) */ OP(xycb,e7) { A = SET(4, RM(EA) ); WM( EA,A ); } /* SET 4,A=(XY+o) */ OP(xycb,e8) { B = SET(5, RM(EA) ); WM( EA,B ); } /* SET 5,B=(XY+o) */ OP(xycb,e9) { C = SET(5, RM(EA) ); WM( EA,C ); } /* SET 5,C=(XY+o) */ OP(xycb,ea) { D = SET(5, RM(EA) ); WM( EA,D ); } /* SET 5,D=(XY+o) */ OP(xycb,eb) { E = SET(5, RM(EA) ); WM( EA,E ); } /* SET 5,E=(XY+o) */ OP(xycb,ec) { H = SET(5, RM(EA) ); WM( EA,H ); } /* SET 5,H=(XY+o) */ OP(xycb,ed) { L = SET(5, RM(EA) ); WM( EA,L ); } /* SET 5,L=(XY+o) */ OP(xycb,ee) { WM( EA, SET(5,RM(EA)) ); } /* SET 5,(XY+o) */ OP(xycb,ef) { A = SET(5, RM(EA) ); WM( EA,A ); } /* SET 5,A=(XY+o) */ OP(xycb,f0) { B = SET(6, RM(EA) ); WM( EA,B ); } /* SET 6,B=(XY+o) */ OP(xycb,f1) { C = SET(6, RM(EA) ); WM( EA,C ); } /* SET 6,C=(XY+o) */ OP(xycb,f2) { D = SET(6, RM(EA) ); WM( EA,D ); } /* SET 6,D=(XY+o) */ OP(xycb,f3) { E = SET(6, RM(EA) ); WM( EA,E ); } /* SET 6,E=(XY+o) */ OP(xycb,f4) { H = SET(6, RM(EA) ); WM( EA,H ); } /* SET 6,H=(XY+o) */ OP(xycb,f5) { L = SET(6, RM(EA) ); WM( EA,L ); } /* SET 6,L=(XY+o) */ OP(xycb,f6) { WM( EA, SET(6,RM(EA)) ); } /* SET 6,(XY+o) */ OP(xycb,f7) { A = SET(6, RM(EA) ); WM( EA,A ); } /* SET 6,A=(XY+o) */ OP(xycb,f8) { B = SET(7, RM(EA) ); WM( EA,B ); } /* SET 7,B=(XY+o) */ OP(xycb,f9) { C = SET(7, RM(EA) ); WM( EA,C ); } /* SET 7,C=(XY+o) */ OP(xycb,fa) { D = SET(7, RM(EA) ); WM( EA,D ); } /* SET 7,D=(XY+o) */ OP(xycb,fb) { E = SET(7, RM(EA) ); WM( EA,E ); } /* SET 7,E=(XY+o) */ OP(xycb,fc) { H = SET(7, RM(EA) ); WM( EA,H ); } /* SET 7,H=(XY+o) */ OP(xycb,fd) { L = SET(7, RM(EA) ); WM( EA,L ); } /* SET 7,L=(XY+o) */ OP(xycb,fe) { WM( EA, SET(7,RM(EA)) ); } /* SET 7,(XY+o) */ OP(xycb,ff) { A = SET(7, RM(EA) ); WM( EA,A ); } /* SET 7,A=(XY+o) */ OP(illegal,1) { #if VERBOSE logerror("Z80 #%d ill. opcode $%02x $%02x\n", cpu_getactivecpu(), cpu_readop((PCD-1)&0xffff), cpu_readop(PCD)); #endif } /********************************************************** * IX register related opcodes (DD prefix) **********************************************************/ OP(dd,00) { illegal_1(); op_00(); } /* DB DD */ OP(dd,01) { illegal_1(); op_01(); } /* DB DD */ OP(dd,02) { illegal_1(); op_02(); } /* DB DD */ OP(dd,03) { illegal_1(); op_03(); } /* DB DD */ OP(dd,04) { illegal_1(); op_04(); } /* DB DD */ OP(dd,05) { illegal_1(); op_05(); } /* DB DD */ OP(dd,06) { illegal_1(); op_06(); } /* DB DD */ OP(dd,07) { illegal_1(); op_07(); } /* DB DD */ OP(dd,08) { illegal_1(); op_08(); } /* DB DD */ OP(dd,09) { ADD16(ix,bc); } /* ADD IX,BC */ OP(dd,0a) { illegal_1(); op_0a(); } /* DB DD */ OP(dd,0b) { illegal_1(); op_0b(); } /* DB DD */ OP(dd,0c) { illegal_1(); op_0c(); } /* DB DD */ OP(dd,0d) { illegal_1(); op_0d(); } /* DB DD */ OP(dd,0e) { illegal_1(); op_0e(); } /* DB DD */ OP(dd,0f) { illegal_1(); op_0f(); } /* DB DD */ OP(dd,10) { illegal_1(); op_10(); } /* DB DD */ OP(dd,11) { illegal_1(); op_11(); } /* DB DD */ OP(dd,12) { illegal_1(); op_12(); } /* DB DD */ OP(dd,13) { illegal_1(); op_13(); } /* DB DD */ OP(dd,14) { illegal_1(); op_14(); } /* DB DD */ OP(dd,15) { illegal_1(); op_15(); } /* DB DD */ OP(dd,16) { illegal_1(); op_16(); } /* DB DD */ OP(dd,17) { illegal_1(); op_17(); } /* DB DD */ OP(dd,18) { illegal_1(); op_18(); } /* DB DD */ OP(dd,19) { ADD16(ix,de); } /* ADD IX,DE */ OP(dd,1a) { illegal_1(); op_1a(); } /* DB DD */ OP(dd,1b) { illegal_1(); op_1b(); } /* DB DD */ OP(dd,1c) { illegal_1(); op_1c(); } /* DB DD */ OP(dd,1d) { illegal_1(); op_1d(); } /* DB DD */ OP(dd,1e) { illegal_1(); op_1e(); } /* DB DD */ OP(dd,1f) { illegal_1(); op_1f(); } /* DB DD */ OP(dd,20) { illegal_1(); op_20(); } /* DB DD */ OP(dd,21) { IX = ARG16(); } /* LD IX,w */ OP(dd,22) { EA = ARG16(); WM16( EA, &Z80.ix ); WZ = EA+1; } /* LD (w),IX */ OP(dd,23) { IX++; } /* INC IX */ OP(dd,24) { HX = INC(HX); } /* INC HX */ OP(dd,25) { HX = DEC(HX); } /* DEC HX */ OP(dd,26) { HX = ARG(); } /* LD HX,n */ OP(dd,27) { illegal_1(); op_27(); } /* DB DD */ OP(dd,28) { illegal_1(); op_28(); } /* DB DD */ OP(dd,29) { ADD16(ix,ix); } /* ADD IX,IX */ OP(dd,2a) { EA = ARG16(); RM16( EA, &Z80.ix ); WZ = EA+1; } /* LD IX,(w) */ OP(dd,2b) { IX--; } /* DEC IX */ OP(dd,2c) { LX = INC(LX); } /* INC LX */ OP(dd,2d) { LX = DEC(LX); } /* DEC LX */ OP(dd,2e) { LX = ARG(); } /* LD LX,n */ OP(dd,2f) { illegal_1(); op_2f(); } /* DB DD */ OP(dd,30) { illegal_1(); op_30(); } /* DB DD */ OP(dd,31) { illegal_1(); op_31(); } /* DB DD */ OP(dd,32) { illegal_1(); op_32(); } /* DB DD */ OP(dd,33) { illegal_1(); op_33(); } /* DB DD */ OP(dd,34) { EAX; WM( EA, INC(RM(EA)) ); } /* INC (IX+o) */ OP(dd,35) { EAX; WM( EA, DEC(RM(EA)) ); } /* DEC (IX+o) */ OP(dd,36) { EAX; WM( EA, ARG() ); } /* LD (IX+o),n */ OP(dd,37) { illegal_1(); op_37(); } /* DB DD */ OP(dd,38) { illegal_1(); op_38(); } /* DB DD */ OP(dd,39) { ADD16(ix,sp); } /* ADD IX,SP */ OP(dd,3a) { illegal_1(); op_3a(); } /* DB DD */ OP(dd,3b) { illegal_1(); op_3b(); } /* DB DD */ OP(dd,3c) { illegal_1(); op_3c(); } /* DB DD */ OP(dd,3d) { illegal_1(); op_3d(); } /* DB DD */ OP(dd,3e) { illegal_1(); op_3e(); } /* DB DD */ OP(dd,3f) { illegal_1(); op_3f(); } /* DB DD */ OP(dd,40) { illegal_1(); op_40(); } /* DB DD */ OP(dd,41) { illegal_1(); op_41(); } /* DB DD */ OP(dd,42) { illegal_1(); op_42(); } /* DB DD */ OP(dd,43) { illegal_1(); op_43(); } /* DB DD */ OP(dd,44) { B = HX; } /* LD B,HX */ OP(dd,45) { B = LX; } /* LD B,LX */ OP(dd,46) { EAX; B = RM(EA); } /* LD B,(IX+o) */ OP(dd,47) { illegal_1(); op_47(); } /* DB DD */ OP(dd,48) { illegal_1(); op_48(); } /* DB DD */ OP(dd,49) { illegal_1(); op_49(); } /* DB DD */ OP(dd,4a) { illegal_1(); op_4a(); } /* DB DD */ OP(dd,4b) { illegal_1(); op_4b(); } /* DB DD */ OP(dd,4c) { C = HX; } /* LD C,HX */ OP(dd,4d) { C = LX; } /* LD C,LX */ OP(dd,4e) { EAX; C = RM(EA); } /* LD C,(IX+o) */ OP(dd,4f) { illegal_1(); op_4f(); } /* DB DD */ OP(dd,50) { illegal_1(); op_50(); } /* DB DD */ OP(dd,51) { illegal_1(); op_51(); } /* DB DD */ OP(dd,52) { illegal_1(); op_52(); } /* DB DD */ OP(dd,53) { illegal_1(); op_53(); } /* DB DD */ OP(dd,54) { D = HX; } /* LD D,HX */ OP(dd,55) { D = LX; } /* LD D,LX */ OP(dd,56) { EAX; D = RM(EA); } /* LD D,(IX+o) */ OP(dd,57) { illegal_1(); op_57(); } /* DB DD */ OP(dd,58) { illegal_1(); op_58(); } /* DB DD */ OP(dd,59) { illegal_1(); op_59(); } /* DB DD */ OP(dd,5a) { illegal_1(); op_5a(); } /* DB DD */ OP(dd,5b) { illegal_1(); op_5b(); } /* DB DD */ OP(dd,5c) { E = HX; } /* LD E,HX */ OP(dd,5d) { E = LX; } /* LD E,LX */ OP(dd,5e) { EAX; E = RM(EA); } /* LD E,(IX+o) */ OP(dd,5f) { illegal_1(); op_5f(); } /* DB DD */ OP(dd,60) { HX = B; } /* LD HX,B */ OP(dd,61) { HX = C; } /* LD HX,C */ OP(dd,62) { HX = D; } /* LD HX,D */ OP(dd,63) { HX = E; } /* LD HX,E */ OP(dd,64) { } /* LD HX,HX */ OP(dd,65) { HX = LX; } /* LD HX,LX */ OP(dd,66) { EAX; H = RM(EA); } /* LD H,(IX+o) */ OP(dd,67) { HX = A; } /* LD HX,A */ OP(dd,68) { LX = B; } /* LD LX,B */ OP(dd,69) { LX = C; } /* LD LX,C */ OP(dd,6a) { LX = D; } /* LD LX,D */ OP(dd,6b) { LX = E; } /* LD LX,E */ OP(dd,6c) { LX = HX; } /* LD LX,HX */ OP(dd,6d) { } /* LD LX,LX */ OP(dd,6e) { EAX; L = RM(EA); } /* LD L,(IX+o) */ OP(dd,6f) { LX = A; } /* LD LX,A */ OP(dd,70) { EAX; WM( EA, B ); } /* LD (IX+o),B */ OP(dd,71) { EAX; WM( EA, C ); } /* LD (IX+o),C */ OP(dd,72) { EAX; WM( EA, D ); } /* LD (IX+o),D */ OP(dd,73) { EAX; WM( EA, E ); } /* LD (IX+o),E */ OP(dd,74) { EAX; WM( EA, H ); } /* LD (IX+o),H */ OP(dd,75) { EAX; WM( EA, L ); } /* LD (IX+o),L */ OP(dd,76) { illegal_1(); op_76(); } /* DB DD */ OP(dd,77) { EAX; WM( EA, A ); } /* LD (IX+o),A */ OP(dd,78) { illegal_1(); op_78(); } /* DB DD */ OP(dd,79) { illegal_1(); op_79(); } /* DB DD */ OP(dd,7a) { illegal_1(); op_7a(); } /* DB DD */ OP(dd,7b) { illegal_1(); op_7b(); } /* DB DD */ OP(dd,7c) { A = HX; } /* LD A,HX */ OP(dd,7d) { A = LX; } /* LD A,LX */ OP(dd,7e) { EAX; A = RM(EA); } /* LD A,(IX+o) */ OP(dd,7f) { illegal_1(); op_7f(); } /* DB DD */ OP(dd,80) { illegal_1(); op_80(); } /* DB DD */ OP(dd,81) { illegal_1(); op_81(); } /* DB DD */ OP(dd,82) { illegal_1(); op_82(); } /* DB DD */ OP(dd,83) { illegal_1(); op_83(); } /* DB DD */ OP(dd,84) { ADD(HX); } /* ADD A,HX */ OP(dd,85) { ADD(LX); } /* ADD A,LX */ OP(dd,86) { EAX; ADD(RM(EA)); } /* ADD A,(IX+o) */ OP(dd,87) { illegal_1(); op_87(); } /* DB DD */ OP(dd,88) { illegal_1(); op_88(); } /* DB DD */ OP(dd,89) { illegal_1(); op_89(); } /* DB DD */ OP(dd,8a) { illegal_1(); op_8a(); } /* DB DD */ OP(dd,8b) { illegal_1(); op_8b(); } /* DB DD */ OP(dd,8c) { ADC(HX); } /* ADC A,HX */ OP(dd,8d) { ADC(LX); } /* ADC A,LX */ OP(dd,8e) { EAX; ADC(RM(EA)); } /* ADC A,(IX+o) */ OP(dd,8f) { illegal_1(); op_8f(); } /* DB DD */ OP(dd,90) { illegal_1(); op_90(); } /* DB DD */ OP(dd,91) { illegal_1(); op_91(); } /* DB DD */ OP(dd,92) { illegal_1(); op_92(); } /* DB DD */ OP(dd,93) { illegal_1(); op_93(); } /* DB DD */ OP(dd,94) { SUB(HX); } /* SUB HX */ OP(dd,95) { SUB(LX); } /* SUB LX */ OP(dd,96) { EAX; SUB(RM(EA)); } /* SUB (IX+o) */ OP(dd,97) { illegal_1(); op_97(); } /* DB DD */ OP(dd,98) { illegal_1(); op_98(); } /* DB DD */ OP(dd,99) { illegal_1(); op_99(); } /* DB DD */ OP(dd,9a) { illegal_1(); op_9a(); } /* DB DD */ OP(dd,9b) { illegal_1(); op_9b(); } /* DB DD */ OP(dd,9c) { SBC(HX); } /* SBC A,HX */ OP(dd,9d) { SBC(LX); } /* SBC A,LX */ OP(dd,9e) { EAX; SBC(RM(EA)); } /* SBC A,(IX+o) */ OP(dd,9f) { illegal_1(); op_9f(); } /* DB DD */ OP(dd,a0) { illegal_1(); op_a0(); } /* DB DD */ OP(dd,a1) { illegal_1(); op_a1(); } /* DB DD */ OP(dd,a2) { illegal_1(); op_a2(); } /* DB DD */ OP(dd,a3) { illegal_1(); op_a3(); } /* DB DD */ OP(dd,a4) { AND(HX); } /* AND HX */ OP(dd,a5) { AND(LX); } /* AND LX */ OP(dd,a6) { EAX; AND(RM(EA)); } /* AND (IX+o) */ OP(dd,a7) { illegal_1(); op_a7(); } /* DB DD */ OP(dd,a8) { illegal_1(); op_a8(); } /* DB DD */ OP(dd,a9) { illegal_1(); op_a9(); } /* DB DD */ OP(dd,aa) { illegal_1(); op_aa(); } /* DB DD */ OP(dd,ab) { illegal_1(); op_ab(); } /* DB DD */ OP(dd,ac) { XOR(HX); } /* XOR HX */ OP(dd,ad) { XOR(LX); } /* XOR LX */ OP(dd,ae) { EAX; XOR(RM(EA)); } /* XOR (IX+o) */ OP(dd,af) { illegal_1(); op_af(); } /* DB DD */ OP(dd,b0) { illegal_1(); op_b0(); } /* DB DD */ OP(dd,b1) { illegal_1(); op_b1(); } /* DB DD */ OP(dd,b2) { illegal_1(); op_b2(); } /* DB DD */ OP(dd,b3) { illegal_1(); op_b3(); } /* DB DD */ OP(dd,b4) { OR(HX); } /* OR HX */ OP(dd,b5) { OR(LX); } /* OR LX */ OP(dd,b6) { EAX; OR(RM(EA)); } /* OR (IX+o) */ OP(dd,b7) { illegal_1(); op_b7(); } /* DB DD */ OP(dd,b8) { illegal_1(); op_b8(); } /* DB DD */ OP(dd,b9) { illegal_1(); op_b9(); } /* DB DD */ OP(dd,ba) { illegal_1(); op_ba(); } /* DB DD */ OP(dd,bb) { illegal_1(); op_bb(); } /* DB DD */ OP(dd,bc) { CP(HX); } /* CP HX */ OP(dd,bd) { CP(LX); } /* CP LX */ OP(dd,be) { EAX; CP(RM(EA)); } /* CP (IX+o) */ OP(dd,bf) { illegal_1(); op_bf(); } /* DB DD */ OP(dd,c0) { illegal_1(); op_c0(); } /* DB DD */ OP(dd,c1) { illegal_1(); op_c1(); } /* DB DD */ OP(dd,c2) { illegal_1(); op_c2(); } /* DB DD */ OP(dd,c3) { illegal_1(); op_c3(); } /* DB DD */ OP(dd,c4) { illegal_1(); op_c4(); } /* DB DD */ OP(dd,c5) { illegal_1(); op_c5(); } /* DB DD */ OP(dd,c6) { illegal_1(); op_c6(); } /* DB DD */ OP(dd,c7) { illegal_1(); op_c7(); } /* DB DD */ OP(dd,c8) { illegal_1(); op_c8(); } /* DB DD */ OP(dd,c9) { illegal_1(); op_c9(); } /* DB DD */ OP(dd,ca) { illegal_1(); op_ca(); } /* DB DD */ OP(dd,cb) { EAX; EXEC(xycb,ARG()); } /* **** DD CB xx */ OP(dd,cc) { illegal_1(); op_cc(); } /* DB DD */ OP(dd,cd) { illegal_1(); op_cd(); } /* DB DD */ OP(dd,ce) { illegal_1(); op_ce(); } /* DB DD */ OP(dd,cf) { illegal_1(); op_cf(); } /* DB DD */ OP(dd,d0) { illegal_1(); op_d0(); } /* DB DD */ OP(dd,d1) { illegal_1(); op_d1(); } /* DB DD */ OP(dd,d2) { illegal_1(); op_d2(); } /* DB DD */ OP(dd,d3) { illegal_1(); op_d3(); } /* DB DD */ OP(dd,d4) { illegal_1(); op_d4(); } /* DB DD */ OP(dd,d5) { illegal_1(); op_d5(); } /* DB DD */ OP(dd,d6) { illegal_1(); op_d6(); } /* DB DD */ OP(dd,d7) { illegal_1(); op_d7(); } /* DB DD */ OP(dd,d8) { illegal_1(); op_d8(); } /* DB DD */ OP(dd,d9) { illegal_1(); op_d9(); } /* DB DD */ OP(dd,da) { illegal_1(); op_da(); } /* DB DD */ OP(dd,db) { illegal_1(); op_db(); } /* DB DD */ OP(dd,dc) { illegal_1(); op_dc(); } /* DB DD */ OP(dd,dd) { EXEC(dd,ROP()); } /* **** DD DD xx */ OP(dd,de) { illegal_1(); op_de(); } /* DB DD */ OP(dd,df) { illegal_1(); op_df(); } /* DB DD */ OP(dd,e0) { illegal_1(); op_e0(); } /* DB DD */ OP(dd,e1) { POP( ix ); } /* POP IX */ OP(dd,e2) { illegal_1(); op_e2(); } /* DB DD */ OP(dd,e3) { EXSP( ix ); } /* EX (SP),IX */ OP(dd,e4) { illegal_1(); op_e4(); } /* DB DD */ OP(dd,e5) { PUSH( ix ); } /* PUSH IX */ OP(dd,e6) { illegal_1(); op_e6(); } /* DB DD */ OP(dd,e7) { illegal_1(); op_e7(); } /* DB DD */ OP(dd,e8) { illegal_1(); op_e8(); } /* DB DD */ OP(dd,e9) { PC = IX; } /* JP (IX) */ OP(dd,ea) { illegal_1(); op_ea(); } /* DB DD */ OP(dd,eb) { illegal_1(); op_eb(); } /* DB DD */ OP(dd,ec) { illegal_1(); op_ec(); } /* DB DD */ OP(dd,ed) { illegal_1(); op_ed(); } /* DB DD */ OP(dd,ee) { illegal_1(); op_ee(); } /* DB DD */ OP(dd,ef) { illegal_1(); op_ef(); } /* DB DD */ OP(dd,f0) { illegal_1(); op_f0(); } /* DB DD */ OP(dd,f1) { illegal_1(); op_f1(); } /* DB DD */ OP(dd,f2) { illegal_1(); op_f2(); } /* DB DD */ OP(dd,f3) { illegal_1(); op_f3(); } /* DB DD */ OP(dd,f4) { illegal_1(); op_f4(); } /* DB DD */ OP(dd,f5) { illegal_1(); op_f5(); } /* DB DD */ OP(dd,f6) { illegal_1(); op_f6(); } /* DB DD */ OP(dd,f7) { illegal_1(); op_f7(); } /* DB DD */ OP(dd,f8) { illegal_1(); op_f8(); } /* DB DD */ OP(dd,f9) { SP = IX; } /* LD SP,IX */ OP(dd,fa) { illegal_1(); op_fa(); } /* DB DD */ OP(dd,fb) { illegal_1(); op_fb(); } /* DB DD */ OP(dd,fc) { illegal_1(); op_fc(); } /* DB DD */ OP(dd,fd) { EXEC(fd,ROP()); } /* **** DD FD xx */ OP(dd,fe) { illegal_1(); op_fe(); } /* DB DD */ OP(dd,ff) { illegal_1(); op_ff(); } /* DB DD */ /********************************************************** * IY register related opcodes (FD prefix) **********************************************************/ OP(fd,00) { illegal_1(); op_00(); } /* DB FD */ OP(fd,01) { illegal_1(); op_01(); } /* DB FD */ OP(fd,02) { illegal_1(); op_02(); } /* DB FD */ OP(fd,03) { illegal_1(); op_03(); } /* DB FD */ OP(fd,04) { illegal_1(); op_04(); } /* DB FD */ OP(fd,05) { illegal_1(); op_05(); } /* DB FD */ OP(fd,06) { illegal_1(); op_06(); } /* DB FD */ OP(fd,07) { illegal_1(); op_07(); } /* DB FD */ OP(fd,08) { illegal_1(); op_08(); } /* DB FD */ OP(fd,09) { ADD16(iy,bc); } /* ADD IY,BC */ OP(fd,0a) { illegal_1(); op_0a(); } /* DB FD */ OP(fd,0b) { illegal_1(); op_0b(); } /* DB FD */ OP(fd,0c) { illegal_1(); op_0c(); } /* DB FD */ OP(fd,0d) { illegal_1(); op_0d(); } /* DB FD */ OP(fd,0e) { illegal_1(); op_0e(); } /* DB FD */ OP(fd,0f) { illegal_1(); op_0f(); } /* DB FD */ OP(fd,10) { illegal_1(); op_10(); } /* DB FD */ OP(fd,11) { illegal_1(); op_11(); } /* DB FD */ OP(fd,12) { illegal_1(); op_12(); } /* DB FD */ OP(fd,13) { illegal_1(); op_13(); } /* DB FD */ OP(fd,14) { illegal_1(); op_14(); } /* DB FD */ OP(fd,15) { illegal_1(); op_15(); } /* DB FD */ OP(fd,16) { illegal_1(); op_16(); } /* DB FD */ OP(fd,17) { illegal_1(); op_17(); } /* DB FD */ OP(fd,18) { illegal_1(); op_18(); } /* DB FD */ OP(fd,19) { ADD16(iy,de); } /* ADD IY,DE */ OP(fd,1a) { illegal_1(); op_1a(); } /* DB FD */ OP(fd,1b) { illegal_1(); op_1b(); } /* DB FD */ OP(fd,1c) { illegal_1(); op_1c(); } /* DB FD */ OP(fd,1d) { illegal_1(); op_1d(); } /* DB FD */ OP(fd,1e) { illegal_1(); op_1e(); } /* DB FD */ OP(fd,1f) { illegal_1(); op_1f(); } /* DB FD */ OP(fd,20) { illegal_1(); op_20(); } /* DB FD */ OP(fd,21) { IY = ARG16(); } /* LD IY,w */ OP(fd,22) { EA = ARG16(); WM16( EA, &Z80.iy ); WZ = EA+1; } /* LD (w),IY */ OP(fd,23) { IY++; } /* INC IY */ OP(fd,24) { HY = INC(HY); } /* INC HY */ OP(fd,25) { HY = DEC(HY); } /* DEC HY */ OP(fd,26) { HY = ARG(); } /* LD HY,n */ OP(fd,27) { illegal_1(); op_27(); } /* DB FD */ OP(fd,28) { illegal_1(); op_28(); } /* DB FD */ OP(fd,29) { ADD16(iy,iy); } /* ADD IY,IY */ OP(fd,2a) { EA = ARG16(); RM16( EA, &Z80.iy ); WZ = EA+1; } /* LD IY,(w) */ OP(fd,2b) { IY--; } /* DEC IY */ OP(fd,2c) { LY = INC(LY); } /* INC LY */ OP(fd,2d) { LY = DEC(LY); } /* DEC LY */ OP(fd,2e) { LY = ARG(); } /* LD LY,n */ OP(fd,2f) { illegal_1(); op_2f(); } /* DB FD */ OP(fd,30) { illegal_1(); op_30(); } /* DB FD */ OP(fd,31) { illegal_1(); op_31(); } /* DB FD */ OP(fd,32) { illegal_1(); op_32(); } /* DB FD */ OP(fd,33) { illegal_1(); op_33(); } /* DB FD */ OP(fd,34) { EAY; WM( EA, INC(RM(EA)) ); } /* INC (IY+o) */ OP(fd,35) { EAY; WM( EA, DEC(RM(EA)) ); } /* DEC (IY+o) */ OP(fd,36) { EAY; WM( EA, ARG() ); } /* LD (IY+o),n */ OP(fd,37) { illegal_1(); op_37(); } /* DB FD */ OP(fd,38) { illegal_1(); op_38(); } /* DB FD */ OP(fd,39) { ADD16(iy,sp); } /* ADD IY,SP */ OP(fd,3a) { illegal_1(); op_3a(); } /* DB FD */ OP(fd,3b) { illegal_1(); op_3b(); } /* DB FD */ OP(fd,3c) { illegal_1(); op_3c(); } /* DB FD */ OP(fd,3d) { illegal_1(); op_3d(); } /* DB FD */ OP(fd,3e) { illegal_1(); op_3e(); } /* DB FD */ OP(fd,3f) { illegal_1(); op_3f(); } /* DB FD */ OP(fd,40) { illegal_1(); op_40(); } /* DB FD */ OP(fd,41) { illegal_1(); op_41(); } /* DB FD */ OP(fd,42) { illegal_1(); op_42(); } /* DB FD */ OP(fd,43) { illegal_1(); op_43(); } /* DB FD */ OP(fd,44) { B = HY; } /* LD B,HY */ OP(fd,45) { B = LY; } /* LD B,LY */ OP(fd,46) { EAY; B = RM(EA); } /* LD B,(IY+o) */ OP(fd,47) { illegal_1(); op_47(); } /* DB FD */ OP(fd,48) { illegal_1(); op_48(); } /* DB FD */ OP(fd,49) { illegal_1(); op_49(); } /* DB FD */ OP(fd,4a) { illegal_1(); op_4a(); } /* DB FD */ OP(fd,4b) { illegal_1(); op_4b(); } /* DB FD */ OP(fd,4c) { C = HY; } /* LD C,HY */ OP(fd,4d) { C = LY; } /* LD C,LY */ OP(fd,4e) { EAY; C = RM(EA); } /* LD C,(IY+o) */ OP(fd,4f) { illegal_1(); op_4f(); } /* DB FD */ OP(fd,50) { illegal_1(); op_50(); } /* DB FD */ OP(fd,51) { illegal_1(); op_51(); } /* DB FD */ OP(fd,52) { illegal_1(); op_52(); } /* DB FD */ OP(fd,53) { illegal_1(); op_53(); } /* DB FD */ OP(fd,54) { D = HY; } /* LD D,HY */ OP(fd,55) { D = LY; } /* LD D,LY */ OP(fd,56) { EAY; D = RM(EA); } /* LD D,(IY+o) */ OP(fd,57) { illegal_1(); op_57(); } /* DB FD */ OP(fd,58) { illegal_1(); op_58(); } /* DB FD */ OP(fd,59) { illegal_1(); op_59(); } /* DB FD */ OP(fd,5a) { illegal_1(); op_5a(); } /* DB FD */ OP(fd,5b) { illegal_1(); op_5b(); } /* DB FD */ OP(fd,5c) { E = HY; } /* LD E,HY */ OP(fd,5d) { E = LY; } /* LD E,LY */ OP(fd,5e) { EAY; E = RM(EA); } /* LD E,(IY+o) */ OP(fd,5f) { illegal_1(); op_5f(); } /* DB FD */ OP(fd,60) { HY = B; } /* LD HY,B */ OP(fd,61) { HY = C; } /* LD HY,C */ OP(fd,62) { HY = D; } /* LD HY,D */ OP(fd,63) { HY = E; } /* LD HY,E */ OP(fd,64) { } /* LD HY,HY */ OP(fd,65) { HY = LY; } /* LD HY,LY */ OP(fd,66) { EAY; H = RM(EA); } /* LD H,(IY+o) */ OP(fd,67) { HY = A; } /* LD HY,A */ OP(fd,68) { LY = B; } /* LD LY,B */ OP(fd,69) { LY = C; } /* LD LY,C */ OP(fd,6a) { LY = D; } /* LD LY,D */ OP(fd,6b) { LY = E; } /* LD LY,E */ OP(fd,6c) { LY = HY; } /* LD LY,HY */ OP(fd,6d) { } /* LD LY,LY */ OP(fd,6e) { EAY; L = RM(EA); } /* LD L,(IY+o) */ OP(fd,6f) { LY = A; } /* LD LY,A */ OP(fd,70) { EAY; WM( EA, B ); } /* LD (IY+o),B */ OP(fd,71) { EAY; WM( EA, C ); } /* LD (IY+o),C */ OP(fd,72) { EAY; WM( EA, D ); } /* LD (IY+o),D */ OP(fd,73) { EAY; WM( EA, E ); } /* LD (IY+o),E */ OP(fd,74) { EAY; WM( EA, H ); } /* LD (IY+o),H */ OP(fd,75) { EAY; WM( EA, L ); } /* LD (IY+o),L */ OP(fd,76) { illegal_1(); op_76(); } /* DB FD */ OP(fd,77) { EAY; WM( EA, A ); } /* LD (IY+o),A */ OP(fd,78) { illegal_1(); op_78(); } /* DB FD */ OP(fd,79) { illegal_1(); op_79(); } /* DB FD */ OP(fd,7a) { illegal_1(); op_7a(); } /* DB FD */ OP(fd,7b) { illegal_1(); op_7b(); } /* DB FD */ OP(fd,7c) { A = HY; } /* LD A,HY */ OP(fd,7d) { A = LY; } /* LD A,LY */ OP(fd,7e) { EAY; A = RM(EA); } /* LD A,(IY+o) */ OP(fd,7f) { illegal_1(); op_7f(); } /* DB FD */ OP(fd,80) { illegal_1(); op_80(); } /* DB FD */ OP(fd,81) { illegal_1(); op_81(); } /* DB FD */ OP(fd,82) { illegal_1(); op_82(); } /* DB FD */ OP(fd,83) { illegal_1(); op_83(); } /* DB FD */ OP(fd,84) { ADD(HY); } /* ADD A,HY */ OP(fd,85) { ADD(LY); } /* ADD A,LY */ OP(fd,86) { EAY; ADD(RM(EA)); } /* ADD A,(IY+o) */ OP(fd,87) { illegal_1(); op_87(); } /* DB FD */ OP(fd,88) { illegal_1(); op_88(); } /* DB FD */ OP(fd,89) { illegal_1(); op_89(); } /* DB FD */ OP(fd,8a) { illegal_1(); op_8a(); } /* DB FD */ OP(fd,8b) { illegal_1(); op_8b(); } /* DB FD */ OP(fd,8c) { ADC(HY); } /* ADC A,HY */ OP(fd,8d) { ADC(LY); } /* ADC A,LY */ OP(fd,8e) { EAY; ADC(RM(EA)); } /* ADC A,(IY+o) */ OP(fd,8f) { illegal_1(); op_8f(); } /* DB FD */ OP(fd,90) { illegal_1(); op_90(); } /* DB FD */ OP(fd,91) { illegal_1(); op_91(); } /* DB FD */ OP(fd,92) { illegal_1(); op_92(); } /* DB FD */ OP(fd,93) { illegal_1(); op_93(); } /* DB FD */ OP(fd,94) { SUB(HY); } /* SUB HY */ OP(fd,95) { SUB(LY); } /* SUB LY */ OP(fd,96) { EAY; SUB(RM(EA)); } /* SUB (IY+o) */ OP(fd,97) { illegal_1(); op_97(); } /* DB FD */ OP(fd,98) { illegal_1(); op_98(); } /* DB FD */ OP(fd,99) { illegal_1(); op_99(); } /* DB FD */ OP(fd,9a) { illegal_1(); op_9a(); } /* DB FD */ OP(fd,9b) { illegal_1(); op_9b(); } /* DB FD */ OP(fd,9c) { SBC(HY); } /* SBC A,HY */ OP(fd,9d) { SBC(LY); } /* SBC A,LY */ OP(fd,9e) { EAY; SBC(RM(EA)); } /* SBC A,(IY+o) */ OP(fd,9f) { illegal_1(); op_9f(); } /* DB FD */ OP(fd,a0) { illegal_1(); op_a0(); } /* DB FD */ OP(fd,a1) { illegal_1(); op_a1(); } /* DB FD */ OP(fd,a2) { illegal_1(); op_a2(); } /* DB FD */ OP(fd,a3) { illegal_1(); op_a3(); } /* DB FD */ OP(fd,a4) { AND(HY); } /* AND HY */ OP(fd,a5) { AND(LY); } /* AND LY */ OP(fd,a6) { EAY; AND(RM(EA)); } /* AND (IY+o) */ OP(fd,a7) { illegal_1(); op_a7(); } /* DB FD */ OP(fd,a8) { illegal_1(); op_a8(); } /* DB FD */ OP(fd,a9) { illegal_1(); op_a9(); } /* DB FD */ OP(fd,aa) { illegal_1(); op_aa(); } /* DB FD */ OP(fd,ab) { illegal_1(); op_ab(); } /* DB FD */ OP(fd,ac) { XOR(HY); } /* XOR HY */ OP(fd,ad) { XOR(LY); } /* XOR LY */ OP(fd,ae) { EAY; XOR(RM(EA)); } /* XOR (IY+o) */ OP(fd,af) { illegal_1(); op_af(); } /* DB FD */ OP(fd,b0) { illegal_1(); op_b0(); } /* DB FD */ OP(fd,b1) { illegal_1(); op_b1(); } /* DB FD */ OP(fd,b2) { illegal_1(); op_b2(); } /* DB FD */ OP(fd,b3) { illegal_1(); op_b3(); } /* DB FD */ OP(fd,b4) { OR(HY); } /* OR HY */ OP(fd,b5) { OR(LY); } /* OR LY */ OP(fd,b6) { EAY; OR(RM(EA)); } /* OR (IY+o) */ OP(fd,b7) { illegal_1(); op_b7(); } /* DB FD */ OP(fd,b8) { illegal_1(); op_b8(); } /* DB FD */ OP(fd,b9) { illegal_1(); op_b9(); } /* DB FD */ OP(fd,ba) { illegal_1(); op_ba(); } /* DB FD */ OP(fd,bb) { illegal_1(); op_bb(); } /* DB FD */ OP(fd,bc) { CP(HY); } /* CP HY */ OP(fd,bd) { CP(LY); } /* CP LY */ OP(fd,be) { EAY; CP(RM(EA)); } /* CP (IY+o) */ OP(fd,bf) { illegal_1(); op_bf(); } /* DB FD */ OP(fd,c0) { illegal_1(); op_c0(); } /* DB FD */ OP(fd,c1) { illegal_1(); op_c1(); } /* DB FD */ OP(fd,c2) { illegal_1(); op_c2(); } /* DB FD */ OP(fd,c3) { illegal_1(); op_c3(); } /* DB FD */ OP(fd,c4) { illegal_1(); op_c4(); } /* DB FD */ OP(fd,c5) { illegal_1(); op_c5(); } /* DB FD */ OP(fd,c6) { illegal_1(); op_c6(); } /* DB FD */ OP(fd,c7) { illegal_1(); op_c7(); } /* DB FD */ OP(fd,c8) { illegal_1(); op_c8(); } /* DB FD */ OP(fd,c9) { illegal_1(); op_c9(); } /* DB FD */ OP(fd,ca) { illegal_1(); op_ca(); } /* DB FD */ OP(fd,cb) { EAY; EXEC(xycb,ARG()); } /* **** FD CB xx */ OP(fd,cc) { illegal_1(); op_cc(); } /* DB FD */ OP(fd,cd) { illegal_1(); op_cd(); } /* DB FD */ OP(fd,ce) { illegal_1(); op_ce(); } /* DB FD */ OP(fd,cf) { illegal_1(); op_cf(); } /* DB FD */ OP(fd,d0) { illegal_1(); op_d0(); } /* DB FD */ OP(fd,d1) { illegal_1(); op_d1(); } /* DB FD */ OP(fd,d2) { illegal_1(); op_d2(); } /* DB FD */ OP(fd,d3) { illegal_1(); op_d3(); } /* DB FD */ OP(fd,d4) { illegal_1(); op_d4(); } /* DB FD */ OP(fd,d5) { illegal_1(); op_d5(); } /* DB FD */ OP(fd,d6) { illegal_1(); op_d6(); } /* DB FD */ OP(fd,d7) { illegal_1(); op_d7(); } /* DB FD */ OP(fd,d8) { illegal_1(); op_d8(); } /* DB FD */ OP(fd,d9) { illegal_1(); op_d9(); } /* DB FD */ OP(fd,da) { illegal_1(); op_da(); } /* DB FD */ OP(fd,db) { illegal_1(); op_db(); } /* DB FD */ OP(fd,dc) { illegal_1(); op_dc(); } /* DB FD */ OP(fd,dd) { EXEC(dd,ROP()); } /* **** FD DD xx */ OP(fd,de) { illegal_1(); op_de(); } /* DB FD */ OP(fd,df) { illegal_1(); op_df(); } /* DB FD */ OP(fd,e0) { illegal_1(); op_e0(); } /* DB FD */ OP(fd,e1) { POP( iy ); } /* POP IY */ OP(fd,e2) { illegal_1(); op_e2(); } /* DB FD */ OP(fd,e3) { EXSP( iy ); } /* EX (SP),IY */ OP(fd,e4) { illegal_1(); op_e4(); } /* DB FD */ OP(fd,e5) { PUSH( iy ); } /* PUSH IY */ OP(fd,e6) { illegal_1(); op_e6(); } /* DB FD */ OP(fd,e7) { illegal_1(); op_e7(); } /* DB FD */ OP(fd,e8) { illegal_1(); op_e8(); } /* DB FD */ OP(fd,e9) { PC = IY; } /* JP (IY) */ OP(fd,ea) { illegal_1(); op_ea(); } /* DB FD */ OP(fd,eb) { illegal_1(); op_eb(); } /* DB FD */ OP(fd,ec) { illegal_1(); op_ec(); } /* DB FD */ OP(fd,ed) { illegal_1(); op_ed(); } /* DB FD */ OP(fd,ee) { illegal_1(); op_ee(); } /* DB FD */ OP(fd,ef) { illegal_1(); op_ef(); } /* DB FD */ OP(fd,f0) { illegal_1(); op_f0(); } /* DB FD */ OP(fd,f1) { illegal_1(); op_f1(); } /* DB FD */ OP(fd,f2) { illegal_1(); op_f2(); } /* DB FD */ OP(fd,f3) { illegal_1(); op_f3(); } /* DB FD */ OP(fd,f4) { illegal_1(); op_f4(); } /* DB FD */ OP(fd,f5) { illegal_1(); op_f5(); } /* DB FD */ OP(fd,f6) { illegal_1(); op_f6(); } /* DB FD */ OP(fd,f7) { illegal_1(); op_f7(); } /* DB FD */ OP(fd,f8) { illegal_1(); op_f8(); } /* DB FD */ OP(fd,f9) { SP = IY; } /* LD SP,IY */ OP(fd,fa) { illegal_1(); op_fa(); } /* DB FD */ OP(fd,fb) { illegal_1(); op_fb(); } /* DB FD */ OP(fd,fc) { illegal_1(); op_fc(); } /* DB FD */ OP(fd,fd) { EXEC(fd,ROP()); } /* **** FD FD xx */ OP(fd,fe) { illegal_1(); op_fe(); } /* DB FD */ OP(fd,ff) { illegal_1(); op_ff(); } /* DB FD */ OP(illegal,2) { #if VERBOSE logerror("Z80 #%d ill. opcode $ed $%02x\n", cpu_getactivecpu(), cpu_readop((PCD-1)&0xffff)); #endif } /********************************************************** * special opcodes (ED prefix) **********************************************************/ OP(ed,00) { illegal_2(); } /* DB ED */ OP(ed,01) { illegal_2(); } /* DB ED */ OP(ed,02) { illegal_2(); } /* DB ED */ OP(ed,03) { illegal_2(); } /* DB ED */ OP(ed,04) { illegal_2(); } /* DB ED */ OP(ed,05) { illegal_2(); } /* DB ED */ OP(ed,06) { illegal_2(); } /* DB ED */ OP(ed,07) { illegal_2(); } /* DB ED */ OP(ed,08) { illegal_2(); } /* DB ED */ OP(ed,09) { illegal_2(); } /* DB ED */ OP(ed,0a) { illegal_2(); } /* DB ED */ OP(ed,0b) { illegal_2(); } /* DB ED */ OP(ed,0c) { illegal_2(); } /* DB ED */ OP(ed,0d) { illegal_2(); } /* DB ED */ OP(ed,0e) { illegal_2(); } /* DB ED */ OP(ed,0f) { illegal_2(); } /* DB ED */ OP(ed,10) { illegal_2(); } /* DB ED */ OP(ed,11) { illegal_2(); } /* DB ED */ OP(ed,12) { illegal_2(); } /* DB ED */ OP(ed,13) { illegal_2(); } /* DB ED */ OP(ed,14) { illegal_2(); } /* DB ED */ OP(ed,15) { illegal_2(); } /* DB ED */ OP(ed,16) { illegal_2(); } /* DB ED */ OP(ed,17) { illegal_2(); } /* DB ED */ OP(ed,18) { illegal_2(); } /* DB ED */ OP(ed,19) { illegal_2(); } /* DB ED */ OP(ed,1a) { illegal_2(); } /* DB ED */ OP(ed,1b) { illegal_2(); } /* DB ED */ OP(ed,1c) { illegal_2(); } /* DB ED */ OP(ed,1d) { illegal_2(); } /* DB ED */ OP(ed,1e) { illegal_2(); } /* DB ED */ OP(ed,1f) { illegal_2(); } /* DB ED */ OP(ed,20) { illegal_2(); } /* DB ED */ OP(ed,21) { illegal_2(); } /* DB ED */ OP(ed,22) { illegal_2(); } /* DB ED */ OP(ed,23) { illegal_2(); } /* DB ED */ OP(ed,24) { illegal_2(); } /* DB ED */ OP(ed,25) { illegal_2(); } /* DB ED */ OP(ed,26) { illegal_2(); } /* DB ED */ OP(ed,27) { illegal_2(); } /* DB ED */ OP(ed,28) { illegal_2(); } /* DB ED */ OP(ed,29) { illegal_2(); } /* DB ED */ OP(ed,2a) { illegal_2(); } /* DB ED */ OP(ed,2b) { illegal_2(); } /* DB ED */ OP(ed,2c) { illegal_2(); } /* DB ED */ OP(ed,2d) { illegal_2(); } /* DB ED */ OP(ed,2e) { illegal_2(); } /* DB ED */ OP(ed,2f) { illegal_2(); } /* DB ED */ OP(ed,30) { illegal_2(); } /* DB ED */ OP(ed,31) { illegal_2(); } /* DB ED */ OP(ed,32) { illegal_2(); } /* DB ED */ OP(ed,33) { illegal_2(); } /* DB ED */ OP(ed,34) { illegal_2(); } /* DB ED */ OP(ed,35) { illegal_2(); } /* DB ED */ OP(ed,36) { illegal_2(); } /* DB ED */ OP(ed,37) { illegal_2(); } /* DB ED */ OP(ed,38) { illegal_2(); } /* DB ED */ OP(ed,39) { illegal_2(); } /* DB ED */ OP(ed,3a) { illegal_2(); } /* DB ED */ OP(ed,3b) { illegal_2(); } /* DB ED */ OP(ed,3c) { illegal_2(); } /* DB ED */ OP(ed,3d) { illegal_2(); } /* DB ED */ OP(ed,3e) { illegal_2(); } /* DB ED */ OP(ed,3f) { illegal_2(); } /* DB ED */ OP(ed,40) { B = IN(BC); F = (F & CF) | SZP[B]; } /* IN B,(C) */ OP(ed,41) { OUT(BC, B); } /* OUT (C),B */ OP(ed,42) { SBC16( bc ); } /* SBC HL,BC */ OP(ed,43) { EA = ARG16(); WM16( EA, &Z80.bc ); WZ = EA+1; } /* LD (w),BC */ OP(ed,44) { NEG; } /* NEG */ OP(ed,45) { RETN; } /* RETN; */ OP(ed,46) { IM = 0; } /* IM 0 */ OP(ed,47) { LD_I_A; } /* LD I,A */ OP(ed,48) { C = IN(BC); F = (F & CF) | SZP[C]; } /* IN C,(C) */ OP(ed,49) { OUT(BC, C); } /* OUT (C),C */ OP(ed,4a) { ADC16( bc ); } /* ADC HL,BC */ OP(ed,4b) { EA = ARG16(); RM16( EA, &Z80.bc ); WZ = EA+1; } /* LD BC,(w) */ OP(ed,4c) { NEG; } /* NEG */ OP(ed,4d) { RETI; } /* RETI */ OP(ed,4e) { IM = 0; } /* IM 0 */ OP(ed,4f) { LD_R_A; } /* LD R,A */ OP(ed,50) { D = IN(BC); F = (F & CF) | SZP[D]; } /* IN D,(C) */ OP(ed,51) { OUT(BC, D); } /* OUT (C),D */ OP(ed,52) { SBC16( de ); } /* SBC HL,DE */ OP(ed,53) { EA = ARG16(); WM16( EA, &Z80.de ); WZ = EA+1; } /* LD (w),DE */ OP(ed,54) { NEG; } /* NEG */ OP(ed,55) { RETN; } /* RETN; */ OP(ed,56) { IM = 1; } /* IM 1 */ OP(ed,57) { LD_A_I; } /* LD A,I */ OP(ed,58) { E = IN(BC); F = (F & CF) | SZP[E]; } /* IN E,(C) */ OP(ed,59) { OUT(BC, E); } /* OUT (C),E */ OP(ed,5a) { ADC16( de ); } /* ADC HL,DE */ OP(ed,5b) { EA = ARG16(); RM16( EA, &Z80.de ); WZ = EA+1; } /* LD DE,(w) */ OP(ed,5c) { NEG; } /* NEG */ OP(ed,5d) { RETI; } /* RETI */ OP(ed,5e) { IM = 2; } /* IM 2 */ OP(ed,5f) { LD_A_R; } /* LD A,R */ OP(ed,60) { H = IN(BC); F = (F & CF) | SZP[H]; } /* IN H,(C) */ OP(ed,61) { OUT(BC, H); } /* OUT (C),H */ OP(ed,62) { SBC16( hl ); } /* SBC HL,HL */ OP(ed,63) { EA = ARG16(); WM16( EA, &Z80.hl ); WZ = EA+1; } /* LD (w),HL */ OP(ed,64) { NEG; } /* NEG */ OP(ed,65) { RETN; } /* RETN; */ OP(ed,66) { IM = 0; } /* IM 0 */ OP(ed,67) { RRD; } /* RRD (HL) */ OP(ed,68) { L = IN(BC); F = (F & CF) | SZP[L]; } /* IN L,(C) */ OP(ed,69) { OUT(BC, L); } /* OUT (C),L */ OP(ed,6a) { ADC16( hl ); } /* ADC HL,HL */ OP(ed,6b) { EA = ARG16(); RM16( EA, &Z80.hl ); WZ = EA+1; } /* LD HL,(w) */ OP(ed,6c) { NEG; } /* NEG */ OP(ed,6d) { RETI; } /* RETI */ OP(ed,6e) { IM = 0; } /* IM 0 */ OP(ed,6f) { RLD; } /* RLD (HL) */ OP(ed,70) { UINT8 res = IN(BC); F = (F & CF) | SZP[res]; } /* IN 0,(C) */ OP(ed,71) { OUT(BC, 0); } /* OUT (C),0 */ OP(ed,72) { SBC16( sp ); } /* SBC HL,SP */ OP(ed,73) { EA = ARG16(); WM16( EA, &Z80.sp ); WZ = EA+1; } /* LD (w),SP */ OP(ed,74) { NEG; } /* NEG */ OP(ed,75) { RETN; } /* RETN; */ OP(ed,76) { IM = 1; } /* IM 1 */ OP(ed,77) { illegal_2(); } /* DB ED,77 */ OP(ed,78) { A = IN(BC); F = (F & CF) | SZP[A]; WZ = BC+1; } /* IN E,(C) */ OP(ed,79) { OUT(BC, A); WZ = BC + 1; } /* OUT (C),A */ OP(ed,7a) { ADC16( sp ); } /* ADC HL,SP */ OP(ed,7b) { EA = ARG16(); RM16( EA, &Z80.sp ); WZ = EA+1; } /* LD SP,(w) */ OP(ed,7c) { NEG; } /* NEG */ OP(ed,7d) { RETI; } /* RETI */ OP(ed,7e) { IM = 2; } /* IM 2 */ OP(ed,7f) { illegal_2(); } /* DB ED,7F */ OP(ed,80) { illegal_2(); } /* DB ED */ OP(ed,81) { illegal_2(); } /* DB ED */ OP(ed,82) { illegal_2(); } /* DB ED */ OP(ed,83) { illegal_2(); } /* DB ED */ OP(ed,84) { illegal_2(); } /* DB ED */ OP(ed,85) { illegal_2(); } /* DB ED */ OP(ed,86) { illegal_2(); } /* DB ED */ OP(ed,87) { illegal_2(); } /* DB ED */ OP(ed,88) { illegal_2(); } /* DB ED */ OP(ed,89) { illegal_2(); } /* DB ED */ OP(ed,8a) { illegal_2(); } /* DB ED */ OP(ed,8b) { illegal_2(); } /* DB ED */ OP(ed,8c) { illegal_2(); } /* DB ED */ OP(ed,8d) { illegal_2(); } /* DB ED */ OP(ed,8e) { illegal_2(); } /* DB ED */ OP(ed,8f) { illegal_2(); } /* DB ED */ OP(ed,90) { illegal_2(); } /* DB ED */ OP(ed,91) { illegal_2(); } /* DB ED */ OP(ed,92) { illegal_2(); } /* DB ED */ OP(ed,93) { illegal_2(); } /* DB ED */ OP(ed,94) { illegal_2(); } /* DB ED */ OP(ed,95) { illegal_2(); } /* DB ED */ OP(ed,96) { illegal_2(); } /* DB ED */ OP(ed,97) { illegal_2(); } /* DB ED */ OP(ed,98) { illegal_2(); } /* DB ED */ OP(ed,99) { illegal_2(); } /* DB ED */ OP(ed,9a) { illegal_2(); } /* DB ED */ OP(ed,9b) { illegal_2(); } /* DB ED */ OP(ed,9c) { illegal_2(); } /* DB ED */ OP(ed,9d) { illegal_2(); } /* DB ED */ OP(ed,9e) { illegal_2(); } /* DB ED */ OP(ed,9f) { illegal_2(); } /* DB ED */ OP(ed,a0) { LDI; } /* LDI */ OP(ed,a1) { CPI; } /* CPI */ OP(ed,a2) { INI; } /* INI */ OP(ed,a3) { OUTI; } /* OUTI */ OP(ed,a4) { illegal_2(); } /* DB ED */ OP(ed,a5) { illegal_2(); } /* DB ED */ OP(ed,a6) { illegal_2(); } /* DB ED */ OP(ed,a7) { illegal_2(); } /* DB ED */ OP(ed,a8) { LDD; } /* LDD */ OP(ed,a9) { CPD; } /* CPD */ OP(ed,aa) { IND; } /* IND */ OP(ed,ab) { OUTD; } /* OUTD */ OP(ed,ac) { illegal_2(); } /* DB ED */ OP(ed,ad) { illegal_2(); } /* DB ED */ OP(ed,ae) { illegal_2(); } /* DB ED */ OP(ed,af) { illegal_2(); } /* DB ED */ OP(ed,b0) { LDIR; } /* LDIR */ OP(ed,b1) { CPIR; } /* CPIR */ OP(ed,b2) { INIR; } /* INIR */ OP(ed,b3) { OTIR; } /* OTIR */ OP(ed,b4) { illegal_2(); } /* DB ED */ OP(ed,b5) { illegal_2(); } /* DB ED */ OP(ed,b6) { illegal_2(); } /* DB ED */ OP(ed,b7) { illegal_2(); } /* DB ED */ OP(ed,b8) { LDDR; } /* LDDR */ OP(ed,b9) { CPDR; } /* CPDR */ OP(ed,ba) { INDR; } /* INDR */ OP(ed,bb) { OTDR; } /* OTDR */ OP(ed,bc) { illegal_2(); } /* DB ED */ OP(ed,bd) { illegal_2(); } /* DB ED */ OP(ed,be) { illegal_2(); } /* DB ED */ OP(ed,bf) { illegal_2(); } /* DB ED */ OP(ed,c0) { illegal_2(); } /* DB ED */ OP(ed,c1) { illegal_2(); } /* DB ED */ OP(ed,c2) { illegal_2(); } /* DB ED */ OP(ed,c3) { illegal_2(); } /* DB ED */ OP(ed,c4) { illegal_2(); } /* DB ED */ OP(ed,c5) { illegal_2(); } /* DB ED */ OP(ed,c6) { illegal_2(); } /* DB ED */ OP(ed,c7) { illegal_2(); } /* DB ED */ OP(ed,c8) { illegal_2(); } /* DB ED */ OP(ed,c9) { illegal_2(); } /* DB ED */ OP(ed,ca) { illegal_2(); } /* DB ED */ OP(ed,cb) { illegal_2(); } /* DB ED */ OP(ed,cc) { illegal_2(); } /* DB ED */ OP(ed,cd) { illegal_2(); } /* DB ED */ OP(ed,ce) { illegal_2(); } /* DB ED */ OP(ed,cf) { illegal_2(); } /* DB ED */ OP(ed,d0) { illegal_2(); } /* DB ED */ OP(ed,d1) { illegal_2(); } /* DB ED */ OP(ed,d2) { illegal_2(); } /* DB ED */ OP(ed,d3) { illegal_2(); } /* DB ED */ OP(ed,d4) { illegal_2(); } /* DB ED */ OP(ed,d5) { illegal_2(); } /* DB ED */ OP(ed,d6) { illegal_2(); } /* DB ED */ OP(ed,d7) { illegal_2(); } /* DB ED */ OP(ed,d8) { illegal_2(); } /* DB ED */ OP(ed,d9) { illegal_2(); } /* DB ED */ OP(ed,da) { illegal_2(); } /* DB ED */ OP(ed,db) { illegal_2(); } /* DB ED */ OP(ed,dc) { illegal_2(); } /* DB ED */ OP(ed,dd) { illegal_2(); } /* DB ED */ OP(ed,de) { illegal_2(); } /* DB ED */ OP(ed,df) { illegal_2(); } /* DB ED */ OP(ed,e0) { illegal_2(); } /* DB ED */ OP(ed,e1) { illegal_2(); } /* DB ED */ OP(ed,e2) { illegal_2(); } /* DB ED */ OP(ed,e3) { illegal_2(); } /* DB ED */ OP(ed,e4) { illegal_2(); } /* DB ED */ OP(ed,e5) { illegal_2(); } /* DB ED */ OP(ed,e6) { illegal_2(); } /* DB ED */ OP(ed,e7) { illegal_2(); } /* DB ED */ OP(ed,e8) { illegal_2(); } /* DB ED */ OP(ed,e9) { illegal_2(); } /* DB ED */ OP(ed,ea) { illegal_2(); } /* DB ED */ OP(ed,eb) { illegal_2(); } /* DB ED */ OP(ed,ec) { illegal_2(); } /* DB ED */ OP(ed,ed) { illegal_2(); } /* DB ED */ OP(ed,ee) { illegal_2(); } /* DB ED */ OP(ed,ef) { illegal_2(); } /* DB ED */ OP(ed,f0) { illegal_2(); } /* DB ED */ OP(ed,f1) { illegal_2(); } /* DB ED */ OP(ed,f2) { illegal_2(); } /* DB ED */ OP(ed,f3) { illegal_2(); } /* DB ED */ OP(ed,f4) { illegal_2(); } /* DB ED */ OP(ed,f5) { illegal_2(); } /* DB ED */ OP(ed,f6) { illegal_2(); } /* DB ED */ OP(ed,f7) { illegal_2(); } /* DB ED */ OP(ed,f8) { illegal_2(); } /* DB ED */ OP(ed,f9) { illegal_2(); } /* DB ED */ OP(ed,fa) { illegal_2(); } /* DB ED */ OP(ed,fb) { illegal_2(); } /* DB ED */ OP(ed,fc) { illegal_2(); } /* DB ED */ OP(ed,fd) { illegal_2(); } /* DB ED */ OP(ed,fe) { illegal_2(); } /* DB ED */ OP(ed,ff) { illegal_2(); } /* DB ED */ /********************************************************** * main opcodes **********************************************************/ OP(op,00) { } /* NOP */ OP(op,01) { BC = ARG16(); } /* LD BC,w */ OP(op,02) { WM( BC, A ); WZ_L = (BC + 1) & 0xFF; WZ_H = A; } /* LD (BC),A */ OP(op,03) { BC++; } /* INC BC */ OP(op,04) { B = INC(B); } /* INC B */ OP(op,05) { B = DEC(B); } /* DEC B */ OP(op,06) { B = ARG(); } /* LD B,n */ OP(op,07) { RLCA; } /* RLCA */ OP(op,08) { EX_AF; } /* EX AF,AF' */ OP(op,09) { ADD16(hl, bc); } /* ADD HL,BC */ OP(op,0a) { A = RM( BC ); WZ=BC+1; } /* LD A,(BC) */ OP(op,0b) { BC--; } /* DEC BC */ OP(op,0c) { C = INC(C); } /* INC C */ OP(op,0d) { C = DEC(C); } /* DEC C */ OP(op,0e) { C = ARG(); } /* LD C,n */ OP(op,0f) { RRCA; } /* RRCA */ OP(op,10) { B--; JR_COND( B, 0x10 ); } /* DJNZ o */ OP(op,11) { DE = ARG16(); } /* LD DE,w */ OP(op,12) { WM( DE, A ); WZ_L = (DE + 1) & 0xFF; WZ_H = A; } /* LD (DE),A */ OP(op,13) { DE++; } /* INC DE */ OP(op,14) { D = INC(D); } /* INC D */ OP(op,15) { D = DEC(D); } /* DEC D */ OP(op,16) { D = ARG(); } /* LD D,n */ OP(op,17) { RLA; } /* RLA */ OP(op,18) { JR(); } /* JR o */ OP(op,19) { ADD16(hl, de); } /* ADD HL,DE */ OP(op,1a) { A = RM( DE ); WZ=DE+1; } /* LD A,(DE) */ OP(op,1b) { DE--; } /* DEC DE */ OP(op,1c) { E = INC(E); } /* INC E */ OP(op,1d) { E = DEC(E); } /* DEC E */ OP(op,1e) { E = ARG(); } /* LD E,n */ OP(op,1f) { RRA; } /* RRA */ OP(op,20) { JR_COND( !(F & ZF), 0x20 ); } /* JR NZ,o */ OP(op,21) { HL = ARG16(); } /* LD HL,w */ OP(op,22) { EA = ARG16(); WM16( EA, &Z80.hl ); WZ = EA+1; } /* LD (w),HL */ OP(op,23) { HL++; } /* INC HL */ OP(op,24) { H = INC(H); } /* INC H */ OP(op,25) { H = DEC(H); } /* DEC H */ OP(op,26) { H = ARG(); } /* LD H,n */ OP(op,27) { DAA; } /* DAA */ OP(op,28) { JR_COND( F & ZF, 0x28 ); } /* JR Z,o */ OP(op,29) { ADD16(hl, hl); } /* ADD HL,HL */ OP(op,2a) { EA = ARG16(); RM16( EA, &Z80.hl ); WZ = EA+1; } /* LD HL,(w) */ OP(op,2b) { HL--; } /* DEC HL */ OP(op,2c) { L = INC(L); } /* INC L */ OP(op,2d) { L = DEC(L); } /* DEC L */ OP(op,2e) { L = ARG(); } /* LD L,n */ OP(op,2f) { A ^= 0xff; F = (F&(SF|ZF|PF|CF))|HF|NF|(A&(YF|XF)); } /* CPL */ OP(op,30) { JR_COND( !(F & CF), 0x30 ); } /* JR NC,o */ OP(op,31) { SP = ARG16(); } /* LD SP,w */ OP(op,32) { EA = ARG16(); WM( EA, A ); WZ_L=(EA+1)&0xFF;WZ_H=A; } /* LD (w),A */ OP(op,33) { SP++; } /* INC SP */ OP(op,34) { WM( HL, INC(RM(HL)) ); } /* INC (HL) */ OP(op,35) { WM( HL, DEC(RM(HL)) ); } /* DEC (HL) */ OP(op,36) { WM( HL, ARG() ); } /* LD (HL),n */ OP(op,37) { F = (F & (SF|ZF|YF|XF|PF)) | CF | (A & (YF|XF)); } /* SCF */ OP(op,38) { JR_COND( F & CF, 0x38 ); } /* JR C,o */ OP(op,39) { ADD16(hl, sp); } /* ADD HL,SP */ OP(op,3a) { EA = ARG16(); A = RM( EA ); WZ = EA+1; } /* LD A,(w) */ OP(op,3b) { SP--; } /* DEC SP */ OP(op,3c) { A = INC(A); } /* INC A */ OP(op,3d) { A = DEC(A); } /* DEC A */ OP(op,3e) { A = ARG(); } /* LD A,n */ OP(op,3f) { F = ((F&(SF|ZF|YF|XF|PF|CF))|((F&CF)<<4)|(A&(YF|XF)))^CF; } /* CCF */ OP(op,40) { } /* LD B,B */ OP(op,41) { B = C; } /* LD B,C */ OP(op,42) { B = D; } /* LD B,D */ OP(op,43) { B = E; } /* LD B,E */ OP(op,44) { B = H; } /* LD B,H */ OP(op,45) { B = L; } /* LD B,L */ OP(op,46) { B = RM(HL); } /* LD B,(HL) */ OP(op,47) { B = A; } /* LD B,A */ OP(op,48) { C = B; } /* LD C,B */ OP(op,49) { } /* LD C,C */ OP(op,4a) { C = D; } /* LD C,D */ OP(op,4b) { C = E; } /* LD C,E */ OP(op,4c) { C = H; } /* LD C,H */ OP(op,4d) { C = L; } /* LD C,L */ OP(op,4e) { C = RM(HL); } /* LD C,(HL) */ OP(op,4f) { C = A; } /* LD C,A */ OP(op,50) { D = B; } /* LD D,B */ OP(op,51) { D = C; } /* LD D,C */ OP(op,52) { } /* LD D,D */ OP(op,53) { D = E; } /* LD D,E */ OP(op,54) { D = H; } /* LD D,H */ OP(op,55) { D = L; } /* LD D,L */ OP(op,56) { D = RM(HL); } /* LD D,(HL) */ OP(op,57) { D = A; } /* LD D,A */ OP(op,58) { E = B; } /* LD E,B */ OP(op,59) { E = C; } /* LD E,C */ OP(op,5a) { E = D; } /* LD E,D */ OP(op,5b) { } /* LD E,E */ OP(op,5c) { E = H; } /* LD E,H */ OP(op,5d) { E = L; } /* LD E,L */ OP(op,5e) { E = RM(HL); } /* LD E,(HL) */ OP(op,5f) { E = A; } /* LD E,A */ OP(op,60) { H = B; } /* LD H,B */ OP(op,61) { H = C; } /* LD H,C */ OP(op,62) { H = D; } /* LD H,D */ OP(op,63) { H = E; } /* LD H,E */ OP(op,64) { } /* LD H,H */ OP(op,65) { H = L; } /* LD H,L */ OP(op,66) { H = RM(HL); } /* LD H,(HL) */ OP(op,67) { H = A; } /* LD H,A */ OP(op,68) { L = B; } /* LD L,B */ OP(op,69) { L = C; } /* LD L,C */ OP(op,6a) { L = D; } /* LD L,D */ OP(op,6b) { L = E; } /* LD L,E */ OP(op,6c) { L = H; } /* LD L,H */ OP(op,6d) { } /* LD L,L */ OP(op,6e) { L = RM(HL); } /* LD L,(HL) */ OP(op,6f) { L = A; } /* LD L,A */ OP(op,70) { WM( HL, B ); } /* LD (HL),B */ OP(op,71) { WM( HL, C ); } /* LD (HL),C */ OP(op,72) { WM( HL, D ); } /* LD (HL),D */ OP(op,73) { WM( HL, E ); } /* LD (HL),E */ OP(op,74) { WM( HL, H ); } /* LD (HL),H */ OP(op,75) { WM( HL, L ); } /* LD (HL),L */ OP(op,76) { ENTER_HALT; } /* HALT */ OP(op,77) { WM( HL, A ); } /* LD (HL),A */ OP(op,78) { A = B; } /* LD A,B */ OP(op,79) { A = C; } /* LD A,C */ OP(op,7a) { A = D; } /* LD A,D */ OP(op,7b) { A = E; } /* LD A,E */ OP(op,7c) { A = H; } /* LD A,H */ OP(op,7d) { A = L; } /* LD A,L */ OP(op,7e) { A = RM(HL); } /* LD A,(HL) */ OP(op,7f) { } /* LD A,A */ OP(op,80) { ADD(B); } /* ADD A,B */ OP(op,81) { ADD(C); } /* ADD A,C */ OP(op,82) { ADD(D); } /* ADD A,D */ OP(op,83) { ADD(E); } /* ADD A,E */ OP(op,84) { ADD(H); } /* ADD A,H */ OP(op,85) { ADD(L); } /* ADD A,L */ OP(op,86) { ADD(RM(HL)); } /* ADD A,(HL) */ OP(op,87) { ADD(A); } /* ADD A,A */ OP(op,88) { ADC(B); } /* ADC A,B */ OP(op,89) { ADC(C); } /* ADC A,C */ OP(op,8a) { ADC(D); } /* ADC A,D */ OP(op,8b) { ADC(E); } /* ADC A,E */ OP(op,8c) { ADC(H); } /* ADC A,H */ OP(op,8d) { ADC(L); } /* ADC A,L */ OP(op,8e) { ADC(RM(HL)); } /* ADC A,(HL) */ OP(op,8f) { ADC(A); } /* ADC A,A */ OP(op,90) { SUB(B); } /* SUB B */ OP(op,91) { SUB(C); } /* SUB C */ OP(op,92) { SUB(D); } /* SUB D */ OP(op,93) { SUB(E); } /* SUB E */ OP(op,94) { SUB(H); } /* SUB H */ OP(op,95) { SUB(L); } /* SUB L */ OP(op,96) { SUB(RM(HL)); } /* SUB (HL) */ OP(op,97) { SUB(A); } /* SUB A */ OP(op,98) { SBC(B); } /* SBC A,B */ OP(op,99) { SBC(C); } /* SBC A,C */ OP(op,9a) { SBC(D); } /* SBC A,D */ OP(op,9b) { SBC(E); } /* SBC A,E */ OP(op,9c) { SBC(H); } /* SBC A,H */ OP(op,9d) { SBC(L); } /* SBC A,L */ OP(op,9e) { SBC(RM(HL)); } /* SBC A,(HL) */ OP(op,9f) { SBC(A); } /* SBC A,A */ OP(op,a0) { AND(B); } /* AND B */ OP(op,a1) { AND(C); } /* AND C */ OP(op,a2) { AND(D); } /* AND D */ OP(op,a3) { AND(E); } /* AND E */ OP(op,a4) { AND(H); } /* AND H */ OP(op,a5) { AND(L); } /* AND L */ OP(op,a6) { AND(RM(HL)); } /* AND (HL) */ OP(op,a7) { AND(A); } /* AND A */ OP(op,a8) { XOR(B); } /* XOR B */ OP(op,a9) { XOR(C); } /* XOR C */ OP(op,aa) { XOR(D); } /* XOR D */ OP(op,ab) { XOR(E); } /* XOR E */ OP(op,ac) { XOR(H); } /* XOR H */ OP(op,ad) { XOR(L); } /* XOR L */ OP(op,ae) { XOR(RM(HL)); } /* XOR (HL) */ OP(op,af) { XOR(A); } /* XOR A */ OP(op,b0) { OR(B); } /* OR B */ OP(op,b1) { OR(C); } /* OR C */ OP(op,b2) { OR(D); } /* OR D */ OP(op,b3) { OR(E); } /* OR E */ OP(op,b4) { OR(H); } /* OR H */ OP(op,b5) { OR(L); } /* OR L */ OP(op,b6) { OR(RM(HL)); } /* OR (HL) */ OP(op,b7) { OR(A); } /* OR A */ OP(op,b8) { CP(B); } /* CP B */ OP(op,b9) { CP(C); } /* CP C */ OP(op,ba) { CP(D); } /* CP D */ OP(op,bb) { CP(E); } /* CP E */ OP(op,bc) { CP(H); } /* CP H */ OP(op,bd) { CP(L); } /* CP L */ OP(op,be) { CP(RM(HL)); } /* CP (HL) */ OP(op,bf) { CP(A); } /* CP A */ OP(op,c0) { RET_COND( !(F & ZF), 0xc0 ); } /* RET NZ */ OP(op,c1) { POP( bc ); } /* POP BC */ OP(op,c2) { JP_COND( !(F & ZF) ); } /* JP NZ,a */ OP(op,c3) { JP; } /* JP a */ OP(op,c4) { CALL_COND( !(F & ZF), 0xc4 ); } /* CALL NZ,a */ OP(op,c5) { PUSH( bc ); } /* PUSH BC */ OP(op,c6) { ADD(ARG()); } /* ADD A,n */ OP(op,c7) { RST(0x00); } /* RST 0 */ OP(op,c8) { RET_COND( F & ZF, 0xc8 ); } /* RET Z */ OP(op,c9) { POP( pc ); WZ=PCD; } /* RET */ OP(op,ca) { JP_COND( F & ZF ); } /* JP Z,a */ OP(op,cb) { R++; EXEC(cb,ROP()); } /* **** CB xx */ OP(op,cc) { CALL_COND( F & ZF, 0xcc ); } /* CALL Z,a */ OP(op,cd) { CALL(); } /* CALL a */ OP(op,ce) { ADC(ARG()); } /* ADC A,n */ OP(op,cf) { RST(0x08); } /* RST 1 */ OP(op,d0) { RET_COND( !(F & CF), 0xd0 ); } /* RET NC */ OP(op,d1) { POP( de ); } /* POP DE */ OP(op,d2) { JP_COND( !(F & CF) ); } /* JP NC,a */ OP(op,d3) { unsigned n = ARG() | (A << 8); OUT( n, A ); WZ_L = ((n & 0xff) + 1) & 0xff; WZ_H = A; } /* OUT (n),A */ OP(op,d4) { CALL_COND( !(F & CF), 0xd4 ); } /* CALL NC,a */ OP(op,d5) { PUSH( de ); } /* PUSH DE */ OP(op,d6) { SUB(ARG()); } /* SUB n */ OP(op,d7) { RST(0x10); } /* RST 2 */ OP(op,d8) { RET_COND( F & CF, 0xd8 ); } /* RET C */ OP(op,d9) { EXX; } /* EXX */ OP(op,da) { JP_COND( F & CF ); } /* JP C,a */ OP(op,db) { unsigned n = ARG() | (A << 8); A = IN( n ); WZ = n + 1; } /* IN A,(n) */ OP(op,dc) { CALL_COND( F & CF, 0xdc ); } /* CALL C,a */ OP(op,dd) { R++; EXEC(dd,ROP()); } /* **** DD xx */ OP(op,de) { SBC(ARG()); } /* SBC A,n */ OP(op,df) { RST(0x18); } /* RST 3 */ OP(op,e0) { RET_COND( !(F & PF), 0xe0 ); } /* RET PO */ OP(op,e1) { POP( hl ); } /* POP HL */ OP(op,e2) { JP_COND( !(F & PF) ); } /* JP PO,a */ OP(op,e3) { EXSP( hl ); } /* EX HL,(SP) */ OP(op,e4) { CALL_COND( !(F & PF), 0xe4 ); } /* CALL PO,a */ OP(op,e5) { PUSH( hl ); } /* PUSH HL */ OP(op,e6) { AND(ARG()); } /* AND n */ OP(op,e7) { RST(0x20); } /* RST 4 */ OP(op,e8) { RET_COND( F & PF, 0xe8 ); } /* RET PE */ OP(op,e9) { PC = HL; } /* JP (HL) */ OP(op,ea) { JP_COND( F & PF ); } /* JP PE,a */ OP(op,eb) { EX_DE_HL; } /* EX DE,HL */ OP(op,ec) { CALL_COND( F & PF, 0xec ); } /* CALL PE,a */ OP(op,ed) { R++; EXEC(ed,ROP()); } /* **** ED xx */ OP(op,ee) { XOR(ARG()); } /* XOR n */ OP(op,ef) { RST(0x28); } /* RST 5 */ OP(op,f0) { RET_COND( !(F & SF), 0xf0 ); } /* RET P */ OP(op,f1) { POP( af ); } /* POP AF */ OP(op,f2) { JP_COND( !(F & SF) ); } /* JP P,a */ OP(op,f3) { IFF1 = IFF2 = 0; } /* DI */ OP(op,f4) { CALL_COND( !(F & SF), 0xf4 ); } /* CALL P,a */ OP(op,f5) { PUSH( af ); } /* PUSH AF */ OP(op,f6) { OR(ARG()); } /* OR n */ OP(op,f7) { RST(0x30); } /* RST 6 */ OP(op,f8) { RET_COND( F & SF, 0xf8 ); } /* RET M */ OP(op,f9) { SP = HL; } /* LD SP,HL */ OP(op,fa) { JP_COND(F & SF); } /* JP M,a */ OP(op,fb) { EI; } /* EI */ OP(op,fc) { CALL_COND( F & SF, 0xfc ); } /* CALL M,a */ OP(op,fd) { R++; EXEC(fd,ROP()); } /* **** FD xx */ OP(op,fe) { CP(ARG()); } /* CP n */ OP(op,ff) { RST(0x38); } /* RST 7 */ static void take_interrupt(void) { /* Check if processor was halted */ LEAVE_HALT; /* Clear both interrupt flip flops */ IFF1 = IFF2 = 0; LOG(("Z80 #%d single int. irq_vector $%02x\n", cpu_getactivecpu(), irq_vector)); /* Interrupt mode 1. RST 38h */ if( IM == 1 ) { LOG(("Z80 #%d IM1 $0038\n",cpu_getactivecpu() )); PUSH( pc ); PCD = 0x0038; /* RST $38 + 'interrupt latency' cycles */ mcycles_z80 += cc[Z80_TABLE_op][0xff] + cc[Z80_TABLE_ex][0xff]; } else { /* call back the cpu interface to retrieve the vector */ int irq_vector = (*Z80.irq_callback)(0); /* Interrupt mode 2. Call [Z80.i:databyte] */ if( IM == 2 ) { irq_vector = (irq_vector & 0xff) | (I << 8); PUSH( pc ); RM16( irq_vector, &Z80.pc ); LOG(("Z80 #%d IM2 [$%04x] = $%04x\n",cpu_getactivecpu() , irq_vector, PCD)); /* CALL $xxxx + 'interrupt latency' cycles */ mcycles_z80 += cc[Z80_TABLE_op][0xcd] + cc[Z80_TABLE_ex][0xff]; } else { /* Interrupt mode 0. We check for CALL and JP instructions, */ /* if neither of these were found we assume a 1 byte opcode */ /* was placed on the databus */ LOG(("Z80 #%d IM0 $%04x\n",cpu_getactivecpu() , irq_vector)); switch (irq_vector & 0xff0000) { case 0xcd0000: /* call */ PUSH( pc ); PCD = irq_vector & 0xffff; /* CALL $xxxx + 'interrupt latency' cycles */ mcycles_z80 += cc[Z80_TABLE_op][0xcd] + cc[Z80_TABLE_ex][0xff]; break; case 0xc30000: /* jump */ PCD = irq_vector & 0xffff; /* JP $xxxx + 2 cycles */ mcycles_z80 += cc[Z80_TABLE_op][0xc3] + cc[Z80_TABLE_ex][0xff]; break; default: /* rst (or other opcodes?) */ PUSH( pc ); PCD = irq_vector & 0x0038; /* RST $xx + 2 cycles */ mcycles_z80 += cc[Z80_TABLE_op][0xff] + cc[Z80_TABLE_ex][0xff]; break; } } } WZ=PCD; } /**************************************************************************** * Processor initialization ****************************************************************************/ void z80_init(const void *config, int (*irqcallback)(int)) { int i, p; if( !SZHVC_add || !SZHVC_sub ) { int oldval, newval, val; UINT8 *padd, *padc, *psub, *psbc; /* allocate big flag arrays once */ SZHVC_add = (UINT8 *)malloc(2*256*256); SZHVC_sub = (UINT8 *)malloc(2*256*256); if( !SZHVC_add || !SZHVC_sub ) { return; } padd = &SZHVC_add[ 0*256]; padc = &SZHVC_add[256*256]; psub = &SZHVC_sub[ 0*256]; psbc = &SZHVC_sub[256*256]; for (oldval = 0; oldval < 256; oldval++) { for (newval = 0; newval < 256; newval++) { /* add or adc w/o carry set */ val = newval - oldval; *padd = (newval) ? ((newval & 0x80) ? SF : 0) : ZF; *padd |= (newval & (YF | XF)); /* undocumented flag bits 5+3 */ if( (newval & 0x0f) < (oldval & 0x0f) ) *padd |= HF; if( newval < oldval ) *padd |= CF; if( (val^oldval^0x80) & (val^newval) & 0x80 ) *padd |= VF; padd++; /* adc with carry set */ val = newval - oldval - 1; *padc = (newval) ? ((newval & 0x80) ? SF : 0) : ZF; *padc |= (newval & (YF | XF)); /* undocumented flag bits 5+3 */ if( (newval & 0x0f) <= (oldval & 0x0f) ) *padc |= HF; if( newval <= oldval ) *padc |= CF; if( (val^oldval^0x80) & (val^newval) & 0x80 ) *padc |= VF; padc++; /* cp, sub or sbc w/o carry set */ val = oldval - newval; *psub = NF | ((newval) ? ((newval & 0x80) ? SF : 0) : ZF); *psub |= (newval & (YF | XF)); /* undocumented flag bits 5+3 */ if( (newval & 0x0f) > (oldval & 0x0f) ) *psub |= HF; if( newval > oldval ) *psub |= CF; if( (val^oldval) & (oldval^newval) & 0x80 ) *psub |= VF; psub++; /* sbc with carry set */ val = oldval - newval - 1; *psbc = NF | ((newval) ? ((newval & 0x80) ? SF : 0) : ZF); *psbc |= (newval & (YF | XF)); /* undocumented flag bits 5+3 */ if( (newval & 0x0f) >= (oldval & 0x0f) ) *psbc |= HF; if( newval >= oldval ) *psbc |= CF; if( (val^oldval) & (oldval^newval) & 0x80 ) *psbc |= VF; psbc++; } } } for (i = 0; i < 256; i++) { p = 0; if( i&0x01 ) ++p; if( i&0x02 ) ++p; if( i&0x04 ) ++p; if( i&0x08 ) ++p; if( i&0x10 ) ++p; if( i&0x20 ) ++p; if( i&0x40 ) ++p; if( i&0x80 ) ++p; SZ[i] = i ? i & SF : ZF; SZ[i] |= (i & (YF | XF)); /* undocumented flag bits 5+3 */ SZ_BIT[i] = i ? i & SF : ZF | PF; SZ_BIT[i] |= (i & (YF | XF)); /* undocumented flag bits 5+3 */ SZP[i] = SZ[i] | ((p & 1) ? 0 : PF); SZHV_inc[i] = SZ[i]; if( i == 0x80 ) SZHV_inc[i] |= VF; if( (i & 0x0f) == 0x00 ) SZHV_inc[i] |= HF; SZHV_dec[i] = SZ[i] | NF; if( i == 0x7f ) SZHV_dec[i] |= VF; if( (i & 0x0f) == 0x0f ) SZHV_dec[i] |= HF; } /* Initialize Z80 */ memset(&Z80, 0, sizeof(Z80)); Z80.daisy = config; Z80.irq_callback = irqcallback; /* Reset registers to their initial values (NB: should be random on real hardware) */ AF = BC = DE = HL = 0; F = ZF; /* Zero flag is set */ IX = IY = 0xffff; /* IX and IY are FFFF after a reset! (from MAME) */ SP = 0xdfff; /* required by some SMS games that don't initialize SP */ /* setup cycle tables */ cc[Z80_TABLE_op] = cc_op; cc[Z80_TABLE_cb] = cc_cb; cc[Z80_TABLE_ed] = cc_ed; cc[Z80_TABLE_xy] = cc_xy; cc[Z80_TABLE_xycb] = cc_xycb; cc[Z80_TABLE_ex] = cc_ex; } /**************************************************************************** * Do a reset ****************************************************************************/ void z80_reset(void) { PC = 0x0000; I = 0; R = 0; R2 = 0; IM = 0; IFF1 = IFF2 = 0; HALT = 0; Z80.after_ei = FALSE; WZ=PCD; } void z80_exit(void) { if (SZHVC_add) free(SZHVC_add); SZHVC_add = NULL; if (SZHVC_sub) free(SZHVC_sub); SZHVC_sub = NULL; } /**************************************************************************** * Run until given cycle count ****************************************************************************/ void z80_run(unsigned int cycles) { while( mcycles_z80 < cycles ) { /* check for IRQs before each instruction */ if ((Z80.irq_state & 7) && IFF1 && !Z80.after_ei) { take_interrupt(); if (mcycles_z80 >= cycles) return; } Z80.after_ei = FALSE; R++; EXEC_INLINE(op,ROP()); } } /**************************************************************************** * Burn 'cycles' T-states. Adjust R register for the lost time ****************************************************************************/ void z80_burn(unsigned int cycles) { if( cycles > 0 ) { /* NOP takes 4 cycles per instruction */ int n = (cycles + 3) / 4; R += n; mcycles_z80 += 4 * n * 15; } } /**************************************************************************** * Get all registers in given buffer ****************************************************************************/ void z80_get_context (void *dst) { if( dst ) *(Z80_Regs*)dst = Z80; } /**************************************************************************** * Set all registers to given values ****************************************************************************/ void z80_set_context (void *src) { if( src ) Z80 = *(Z80_Regs*)src; } /**************************************************************************** * Set IRQ line state ****************************************************************************/ void z80_set_nmi_line(int state) { /* mark an NMI pending on the rising edge */ if (Z80.nmi_state == CLEAR_LINE && state != CLEAR_LINE) { LOG(("Z80 #%d take NMI\n", cpu_getactivecpu())); LEAVE_HALT; /* Check if processor was halted */ IFF1 = 0; PUSH( pc ); PCD = 0x0066; WZ=PCD; mcycles_z80 += 11*15; } Z80.nmi_state = state; }
zyking1987-genplus-droid
genplusgx/z80/z80.c
C
gpl2
224,383
/*************************************************************************************** * Genesis Plus * Z80 bus controller (MD & MS compatibility modes) * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ****************************************************************************************/ #include "shared.h" /*--------------------------------------------------------------------------*/ /* Handlers for access to unused addresses and those which make the */ /* machine lock up. */ /*--------------------------------------------------------------------------*/ static inline void z80_unused_w(unsigned int address, unsigned char data) { #ifdef LOGERROR error("Z80 unused write %04X = %02X (%x)\n", address, data, Z80.pc.w.l); #endif } static inline unsigned char z80_unused_r(unsigned int address) { #ifdef LOGERROR error("Z80 unused read %04X (%x)\n", address, Z80.pc.w.l); #endif return 0xFF; } static inline void z80_lockup_w(unsigned int address, unsigned char data) { #ifdef LOGERROR error("Z80 lockup write %04X = %02X (%x)\n", address, data, Z80.pc.w.l); #endif if (!config.force_dtack) { mcycles_z80 = 0xFFFFFFFF; zstate = 0; } } static inline unsigned char z80_lockup_r(unsigned int address) { #ifdef LOGERROR error("Z80 lockup read %04X (%x)\n", address, Z80.pc.w.l); #endif if (!config.force_dtack) { mcycles_z80 = 0xFFFFFFFF; zstate = 0; } return 0xFF; } /*--------------------------------------------------------------------------*/ /* Z80 Memory handlers (Genesis mode) */ /*--------------------------------------------------------------------------*/ unsigned char z80_md_memory_r(unsigned int address) { switch((address >> 13) & 7) { case 0: /* $0000-$3FFF: Z80 RAM (8K mirrored) */ case 1: { return zram[address & 0x1FFF]; } case 2: /* $4000-$5FFF: YM2612 */ { return fm_read(mcycles_z80, address & 3); } case 3: /* $7F00-$7FFF: VDP */ { if ((address >> 8) == 0x7F) { return (*zbank_memory_map[0xc0].read)(address); } return z80_unused_r(address); } default: /* $8000-$FFFF: 68k bank (32K) */ { address = zbank | (address & 0x7FFF); unsigned int slot = address >> 16; if (zbank_memory_map[slot].read) { return (*zbank_memory_map[slot].read)(address); } return READ_BYTE(m68k_memory_map[slot].base, address & 0xFFFF); } } } void z80_md_memory_w(unsigned int address, unsigned char data) { switch((address >> 13) & 7) { case 0: /* $0000-$3FFF: Z80 RAM (8K mirrored) */ case 1: { zram[address & 0x1FFF] = data; return; } case 2: /* $4000-$5FFF: YM2612 */ { fm_write(mcycles_z80, address & 3, data); return; } case 3: /* Bank register and VDP */ { switch(address >> 8) { case 0x60: /* $6000-$60FF: Bank register */ { gen_zbank_w(data & 1); return; } case 0x7F: /* $7F00-$7FFF: VDP */ { (*zbank_memory_map[0xc0].write)(address, data); return; } default: { z80_unused_w(address, data); return; } } } default: /* $8000-$FFFF: 68k bank (32K) */ { address = zbank | (address & 0x7FFF); unsigned int slot = address >> 16; if (zbank_memory_map[slot].write) { (*zbank_memory_map[slot].write)(address, data); return; } WRITE_BYTE(m68k_memory_map[slot].base, address & 0xFFFF, data); return; } } } /*--------------------------------------------------------------------------*/ /* Z80 Memory handlers (Master System mode) */ /*--------------------------------------------------------------------------*/ unsigned char z80_sms_memory_r(unsigned int address) { return z80_readmap[(address) >> 10][(address) & 0x03FF]; } /*--------------------------------------------------------------------------*/ /* Z80 Port handlers */ /*--------------------------------------------------------------------------*/ /* Ports are unused when not in Mark III compatibility mode. Genesis games that access ports anyway: Thunder Force IV reads port $BF in it's interrupt handler. */ unsigned char z80_unused_port_r(unsigned int port) { #if LOGERROR error("Z80 unused read from port %04X (%x)\n", port, Z80.pc.w.l); #endif return 0xFF; } void z80_unused_port_w(unsigned int port, unsigned char data) { #if LOGERROR error("Z80 unused write to port %04X = %02X (%x)\n", port, data, Z80.pc.w.l); #endif } void z80_sms_port_w(unsigned int port, unsigned char data) { switch (port & 0xC1) { case 0x01: { io_z80_write(data); return; } case 0x40: case 0x41: { psg_write(mcycles_z80, data); return; } case 0x80: { vdp_z80_data_w(data); return; } case 0x81: { vdp_z80_ctrl_w(data); return; } default: { if ((port & 0xFF) == 0x3E) { /* Memory Control Register */ /* NB: this register does not exist on MD hardware but is partially emulated to support BIOS ROM image files */ if (data & 0x40) { /* Assume only BIOS would disable Cartridge ROM */ if (data & 0x08) { /* BIOS ROM disabled */ sms_cart_switch(0); } else { /* BIOS ROM enabled */ sms_cart_switch(1); } } return; } z80_unused_port_w(port, data); return; } } } unsigned char z80_sms_port_r(unsigned int port) { switch (port & 0xC1) { case 0x40: { return ((vdp_hvc_r(mcycles_z80) >> 8) & 0xFF); } case 0x41: { return (vdp_hvc_r(mcycles_z80) & 0xFF); } case 0x80: { return vdp_z80_data_r(); } case 0x81: { return (vdp_ctrl_r(mcycles_z80) & 0xFF); } default: { port &= 0xFF; if ((port == 0xC0) || (port == 0xC1) || (port == 0xDC) || (port == 0xDD) || (port == 0xDE) || (port == 0xDF)) { return io_z80_read(port & 1); } return z80_unused_port_r(port); } } }
zyking1987-genplus-droid
genplusgx/memz80.c
C
gpl2
7,598
#include "m68kcpu.h" #include "m68kCycleAccurate.h" extern void m68040_fpu_op0(void); extern void m68040_fpu_op1(void); /* ======================================================================== */ /* ========================= INSTRUCTION HANDLERS ========================= */ /* ======================================================================== */ static void m68k_op_1010(void) { m68ki_exception_1010(); } static void m68k_op_1111(void) { m68ki_exception_1111(); } #if M68K_EMULATE_040 static void m68k_op_040fpu0_32(void) { if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { m68040_fpu_op0(); return; } m68ki_exception_1111(); } static void m68k_op_040fpu1_32(void) { if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { m68040_fpu_op1(); return; } m68ki_exception_1111(); } #endif static void m68k_op_abcd_8_rr(void) { uint* r_dst = &DX; uint src = DY; uint dst = *r_dst; uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); FLAG_V = ~res; /* Undefined V behavior */ if(res > 9) res += 6; res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); FLAG_X = FLAG_C = (res > 0x99) << 8; if(FLAG_C) res -= 0xa0; FLAG_V &= res; /* Undefined V behavior part II */ FLAG_N = NFLAG_8(res); /* Undefined N behavior */ res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; } static void m68k_op_abcd_8_mm_ax7(void) { uint src = OPER_AY_PD_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); FLAG_V = ~res; /* Undefined V behavior */ if(res > 9) res += 6; res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); FLAG_X = FLAG_C = (res > 0x99) << 8; if(FLAG_C) res -= 0xa0; FLAG_V &= res; /* Undefined V behavior part II */ FLAG_N = NFLAG_8(res); /* Undefined N behavior */ res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_abcd_8_mm_ay7(void) { uint src = OPER_A7_PD_8(); uint ea = EA_AX_PD_8(); uint dst = m68ki_read_8(ea); uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); FLAG_V = ~res; /* Undefined V behavior */ if(res > 9) res += 6; res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); FLAG_X = FLAG_C = (res > 0x99) << 8; if(FLAG_C) res -= 0xa0; FLAG_V &= res; /* Undefined V behavior part II */ FLAG_N = NFLAG_8(res); /* Undefined N behavior */ res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_abcd_8_mm_axy7(void) { uint src = OPER_A7_PD_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); FLAG_V = ~res; /* Undefined V behavior */ if(res > 9) res += 6; res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); FLAG_X = FLAG_C = (res > 0x99) << 8; if(FLAG_C) res -= 0xa0; FLAG_V &= res; /* Undefined V behavior part II */ FLAG_N = NFLAG_8(res); /* Undefined N behavior */ res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_abcd_8_mm(void) { uint src = OPER_AY_PD_8(); uint ea = EA_AX_PD_8(); uint dst = m68ki_read_8(ea); uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); FLAG_V = ~res; /* Undefined V behavior */ if(res > 9) res += 6; res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); FLAG_X = FLAG_C = (res > 0x99) << 8; if(FLAG_C) res -= 0xa0; FLAG_V &= res; /* Undefined V behavior part II */ FLAG_N = NFLAG_8(res); /* Undefined N behavior */ res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_add_8_er_d(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_8(DY); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_ai(void) { uint* r_dst = &DX; uint src = OPER_AY_AI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_pi(void) { uint* r_dst = &DX; uint src = OPER_AY_PI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_pi7(void) { uint* r_dst = &DX; uint src = OPER_A7_PI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_pd(void) { uint* r_dst = &DX; uint src = OPER_AY_PD_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_pd7(void) { uint* r_dst = &DX; uint src = OPER_A7_PD_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_di(void) { uint* r_dst = &DX; uint src = OPER_AY_DI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_ix(void) { uint* r_dst = &DX; uint src = OPER_AY_IX_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_aw(void) { uint* r_dst = &DX; uint src = OPER_AW_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_al(void) { uint* r_dst = &DX; uint src = OPER_AL_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_pcdi(void) { uint* r_dst = &DX; uint src = OPER_PCDI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_pcix(void) { uint* r_dst = &DX; uint src = OPER_PCIX_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_8_er_i(void) { uint* r_dst = &DX; uint src = OPER_I_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_d(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_16(DY); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_a(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_16(AY); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_ai(void) { uint* r_dst = &DX; uint src = OPER_AY_AI_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_pi(void) { uint* r_dst = &DX; uint src = OPER_AY_PI_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_pd(void) { uint* r_dst = &DX; uint src = OPER_AY_PD_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_di(void) { uint* r_dst = &DX; uint src = OPER_AY_DI_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_ix(void) { uint* r_dst = &DX; uint src = OPER_AY_IX_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_aw(void) { uint* r_dst = &DX; uint src = OPER_AW_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_al(void) { uint* r_dst = &DX; uint src = OPER_AL_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_pcdi(void) { uint* r_dst = &DX; uint src = OPER_PCDI_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_pcix(void) { uint* r_dst = &DX; uint src = OPER_PCIX_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_16_er_i(void) { uint* r_dst = &DX; uint src = OPER_I_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_add_32_er_d(void) { uint* r_dst = &DX; uint src = DY; uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_a(void) { uint* r_dst = &DX; uint src = AY; uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_ai(void) { uint* r_dst = &DX; uint src = OPER_AY_AI_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_pi(void) { uint* r_dst = &DX; uint src = OPER_AY_PI_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_pd(void) { uint* r_dst = &DX; uint src = OPER_AY_PD_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_di(void) { uint* r_dst = &DX; uint src = OPER_AY_DI_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_ix(void) { uint* r_dst = &DX; uint src = OPER_AY_IX_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_aw(void) { uint* r_dst = &DX; uint src = OPER_AW_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_al(void) { uint* r_dst = &DX; uint src = OPER_AL_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_pcdi(void) { uint* r_dst = &DX; uint src = OPER_PCDI_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_pcix(void) { uint* r_dst = &DX; uint src = OPER_PCIX_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_32_er_i(void) { uint* r_dst = &DX; uint src = OPER_I_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_add_8_re_ai(void) { uint ea = EA_AY_AI_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_8_re_pi(void) { uint ea = EA_AY_PI_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_8_re_pi7(void) { uint ea = EA_A7_PI_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_8_re_pd(void) { uint ea = EA_AY_PD_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_8_re_pd7(void) { uint ea = EA_A7_PD_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_8_re_di(void) { uint ea = EA_AY_DI_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_8_re_ix(void) { uint ea = EA_AY_IX_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_8_re_aw(void) { uint ea = EA_AW_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_8_re_al(void) { uint ea = EA_AL_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_add_16_re_ai(void) { uint ea = EA_AY_AI_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_add_16_re_pi(void) { uint ea = EA_AY_PI_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_add_16_re_pd(void) { uint ea = EA_AY_PD_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_add_16_re_di(void) { uint ea = EA_AY_DI_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_add_16_re_ix(void) { uint ea = EA_AY_IX_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_add_16_re_aw(void) { uint ea = EA_AW_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_add_16_re_al(void) { uint ea = EA_AL_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_add_32_re_ai(void) { uint ea = EA_AY_AI_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_add_32_re_pi(void) { uint ea = EA_AY_PI_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_add_32_re_pd(void) { uint ea = EA_AY_PD_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_add_32_re_di(void) { uint ea = EA_AY_DI_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_add_32_re_ix(void) { uint ea = EA_AY_IX_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_add_32_re_aw(void) { uint ea = EA_AW_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_add_32_re_al(void) { uint ea = EA_AL_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_adda_16_d(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(DY)); } static void m68k_op_adda_16_a(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(AY)); } static void m68k_op_adda_16_ai(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_AI_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_pi(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_PI_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_pd(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_PD_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_di(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_DI_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_ix(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_IX_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_aw(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AW_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_al(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AL_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_pcdi(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_PCDI_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_pcix(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_PCIX_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_16_i(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_I_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); } static void m68k_op_adda_32_d(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(*r_dst + DY); } static void m68k_op_adda_32_a(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(*r_dst + AY); } static void m68k_op_adda_32_ai(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_AY_AI_32() + *r_dst); } static void m68k_op_adda_32_pi(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_AY_PI_32() + *r_dst); } static void m68k_op_adda_32_pd(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_AY_PD_32() + *r_dst); } static void m68k_op_adda_32_di(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_AY_DI_32() + *r_dst); } static void m68k_op_adda_32_ix(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_AY_IX_32() + *r_dst); } static void m68k_op_adda_32_aw(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_AW_32() + *r_dst); } static void m68k_op_adda_32_al(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_AL_32() + *r_dst); } static void m68k_op_adda_32_pcdi(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_PCDI_32() + *r_dst); } static void m68k_op_adda_32_pcix(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_PCIX_32() + *r_dst); } static void m68k_op_adda_32_i(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(OPER_I_32() + *r_dst); } static void m68k_op_addi_8_d(void) { uint* r_dst = &DY; uint src = OPER_I_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_addi_8_ai(void) { uint src = OPER_I_8(); uint ea = EA_AY_AI_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_8_pi(void) { uint src = OPER_I_8(); uint ea = EA_AY_PI_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_8_pi7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PI_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_8_pd(void) { uint src = OPER_I_8(); uint ea = EA_AY_PD_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_8_pd7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_8_di(void) { uint src = OPER_I_8(); uint ea = EA_AY_DI_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_8_ix(void) { uint src = OPER_I_8(); uint ea = EA_AY_IX_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_8_aw(void) { uint src = OPER_I_8(); uint ea = EA_AW_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_8_al(void) { uint src = OPER_I_8(); uint ea = EA_AL_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addi_16_d(void) { uint* r_dst = &DY; uint src = OPER_I_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_addi_16_ai(void) { uint src = OPER_I_16(); uint ea = EA_AY_AI_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addi_16_pi(void) { uint src = OPER_I_16(); uint ea = EA_AY_PI_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addi_16_pd(void) { uint src = OPER_I_16(); uint ea = EA_AY_PD_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addi_16_di(void) { uint src = OPER_I_16(); uint ea = EA_AY_DI_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addi_16_ix(void) { uint src = OPER_I_16(); uint ea = EA_AY_IX_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addi_16_aw(void) { uint src = OPER_I_16(); uint ea = EA_AW_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addi_16_al(void) { uint src = OPER_I_16(); uint ea = EA_AL_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addi_32_d(void) { uint* r_dst = &DY; uint src = OPER_I_32(); uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_addi_32_ai(void) { uint src = OPER_I_32(); uint ea = EA_AY_AI_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addi_32_pi(void) { uint src = OPER_I_32(); uint ea = EA_AY_PI_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addi_32_pd(void) { uint src = OPER_I_32(); uint ea = EA_AY_PD_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addi_32_di(void) { uint src = OPER_I_32(); uint ea = EA_AY_DI_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addi_32_ix(void) { uint src = OPER_I_32(); uint ea = EA_AY_IX_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addi_32_aw(void) { uint src = OPER_I_32(); uint ea = EA_AW_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addi_32_al(void) { uint src = OPER_I_32(); uint ea = EA_AL_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addq_8_d(void) { uint* r_dst = &DY; uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_addq_8_ai(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_AI_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_8_pi(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PI_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_8_pi7(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_A7_PI_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_8_pd(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PD_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_8_pd7(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_8_di(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_DI_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_8_ix(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_IX_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_8_aw(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AW_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_8_al(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AL_8(); uint dst = m68ki_read_8(ea); uint res = src + dst; FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_addq_16_d(void) { uint* r_dst = &DY; uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_addq_16_a(void) { uint* r_dst = &AY; *r_dst = MASK_OUT_ABOVE_32(*r_dst + (((REG_IR >> 9) - 1) & 7) + 1); } static void m68k_op_addq_16_ai(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_AI_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addq_16_pi(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PI_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addq_16_pd(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PD_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addq_16_di(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_DI_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addq_16_ix(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_IX_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addq_16_aw(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AW_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addq_16_al(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AL_16(); uint dst = m68ki_read_16(ea); uint res = src + dst; FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_addq_32_d(void) { uint* r_dst = &DY; uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint dst = *r_dst; uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_addq_32_a(void) { uint* r_dst = &AY; *r_dst = MASK_OUT_ABOVE_32(*r_dst + (((REG_IR >> 9) - 1) & 7) + 1); } static void m68k_op_addq_32_ai(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_AI_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addq_32_pi(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PI_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addq_32_pd(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PD_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addq_32_di(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_DI_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addq_32_ix(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_IX_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addq_32_aw(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AW_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addq_32_al(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AL_32(); uint dst = m68ki_read_32(ea); uint res = src + dst; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_addx_8_rr(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_8(DY); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; } static void m68k_op_addx_16_rr(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_16(DY); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; } static void m68k_op_addx_32_rr(void) { uint* r_dst = &DX; uint src = DY; uint dst = *r_dst; uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; *r_dst = res; } static void m68k_op_addx_8_mm_ax7(void) { uint src = OPER_AY_PD_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_addx_8_mm_ay7(void) { uint src = OPER_A7_PD_8(); uint ea = EA_AX_PD_8(); uint dst = m68ki_read_8(ea); uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_addx_8_mm_axy7(void) { uint src = OPER_A7_PD_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_addx_8_mm(void) { uint src = OPER_AY_PD_8(); uint ea = EA_AX_PD_8(); uint dst = m68ki_read_8(ea); uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_V = VFLAG_ADD_8(src, dst, res); FLAG_X = FLAG_C = CFLAG_8(res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_addx_16_mm(void) { uint src = OPER_AY_PD_16(); uint ea = EA_AX_PD_16(); uint dst = m68ki_read_16(ea); uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_V = VFLAG_ADD_16(src, dst, res); FLAG_X = FLAG_C = CFLAG_16(res); res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_addx_32_mm(void) { uint src = OPER_AY_PD_32(); uint ea = EA_AX_PD_32(); uint dst = m68ki_read_32(ea); uint res = src + dst + XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_ADD_32(src, dst, res); FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_and_8_er_d(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (DY | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_ai(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_AI_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_pi(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_PI_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_pi7(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_A7_PI_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_pd(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_PD_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_pd7(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_A7_PD_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_di(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_DI_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_ix(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_IX_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_aw(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AW_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_al(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AL_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_pcdi(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_PCDI_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_pcix(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_PCIX_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_er_i(void) { FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_I_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_d(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (DY | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_ai(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_AI_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_pi(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_PI_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_pd(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_PD_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_di(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_DI_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_ix(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_IX_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_aw(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AW_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_al(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AL_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_pcdi(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_PCDI_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_pcix(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_PCIX_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_16_er_i(void) { FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_I_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_d(void) { FLAG_Z = DX &= DY; FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_ai(void) { FLAG_Z = DX &= OPER_AY_AI_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_pi(void) { FLAG_Z = DX &= OPER_AY_PI_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_pd(void) { FLAG_Z = DX &= OPER_AY_PD_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_di(void) { FLAG_Z = DX &= OPER_AY_DI_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_ix(void) { FLAG_Z = DX &= OPER_AY_IX_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_aw(void) { FLAG_Z = DX &= OPER_AW_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_al(void) { FLAG_Z = DX &= OPER_AL_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_pcdi(void) { FLAG_Z = DX &= OPER_PCDI_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_pcix(void) { FLAG_Z = DX &= OPER_PCIX_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_32_er_i(void) { FLAG_Z = DX &= OPER_I_32(); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_and_8_re_ai(void) { uint ea = EA_AY_AI_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_8_re_pi(void) { uint ea = EA_AY_PI_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_8_re_pi7(void) { uint ea = EA_A7_PI_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_8_re_pd(void) { uint ea = EA_AY_PD_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_8_re_pd7(void) { uint ea = EA_A7_PD_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_8_re_di(void) { uint ea = EA_AY_DI_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_8_re_ix(void) { uint ea = EA_AY_IX_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_8_re_aw(void) { uint ea = EA_AW_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_8_re_al(void) { uint ea = EA_AL_8(); uint res = DX & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_and_16_re_ai(void) { uint ea = EA_AY_AI_16(); uint res = DX & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_and_16_re_pi(void) { uint ea = EA_AY_PI_16(); uint res = DX & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_and_16_re_pd(void) { uint ea = EA_AY_PD_16(); uint res = DX & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_and_16_re_di(void) { uint ea = EA_AY_DI_16(); uint res = DX & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_and_16_re_ix(void) { uint ea = EA_AY_IX_16(); uint res = DX & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_and_16_re_aw(void) { uint ea = EA_AW_16(); uint res = DX & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_and_16_re_al(void) { uint ea = EA_AL_16(); uint res = DX & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_and_32_re_ai(void) { uint ea = EA_AY_AI_32(); uint res = DX & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_and_32_re_pi(void) { uint ea = EA_AY_PI_32(); uint res = DX & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_and_32_re_pd(void) { uint ea = EA_AY_PD_32(); uint res = DX & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_and_32_re_di(void) { uint ea = EA_AY_DI_32(); uint res = DX & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_and_32_re_ix(void) { uint ea = EA_AY_IX_32(); uint res = DX & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_and_32_re_aw(void) { uint ea = EA_AW_32(); uint res = DX & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_and_32_re_al(void) { uint ea = EA_AL_32(); uint res = DX & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_andi_8_d(void) { FLAG_Z = MASK_OUT_ABOVE_8(DY &= (OPER_I_8() | 0xffffff00)); FLAG_N = NFLAG_8(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_andi_8_ai(void) { uint src = OPER_I_8(); uint ea = EA_AY_AI_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_8_pi(void) { uint src = OPER_I_8(); uint ea = EA_AY_PI_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_8_pi7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PI_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_8_pd(void) { uint src = OPER_I_8(); uint ea = EA_AY_PD_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_8_pd7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PD_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_8_di(void) { uint src = OPER_I_8(); uint ea = EA_AY_DI_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_8_ix(void) { uint src = OPER_I_8(); uint ea = EA_AY_IX_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_8_aw(void) { uint src = OPER_I_8(); uint ea = EA_AW_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_8_al(void) { uint src = OPER_I_8(); uint ea = EA_AL_8(); uint res = src & m68ki_read_8(ea); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_8(ea, res); } static void m68k_op_andi_16_d(void) { FLAG_Z = MASK_OUT_ABOVE_16(DY &= (OPER_I_16() | 0xffff0000)); FLAG_N = NFLAG_16(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_andi_16_ai(void) { uint src = OPER_I_16(); uint ea = EA_AY_AI_16(); uint res = src & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_16(ea, res); } static void m68k_op_andi_16_pi(void) { uint src = OPER_I_16(); uint ea = EA_AY_PI_16(); uint res = src & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_16(ea, res); } static void m68k_op_andi_16_pd(void) { uint src = OPER_I_16(); uint ea = EA_AY_PD_16(); uint res = src & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_16(ea, res); } static void m68k_op_andi_16_di(void) { uint src = OPER_I_16(); uint ea = EA_AY_DI_16(); uint res = src & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_16(ea, res); } static void m68k_op_andi_16_ix(void) { uint src = OPER_I_16(); uint ea = EA_AY_IX_16(); uint res = src & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_16(ea, res); } static void m68k_op_andi_16_aw(void) { uint src = OPER_I_16(); uint ea = EA_AW_16(); uint res = src & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_16(ea, res); } static void m68k_op_andi_16_al(void) { uint src = OPER_I_16(); uint ea = EA_AL_16(); uint res = src & m68ki_read_16(ea); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_16(ea, res); } static void m68k_op_andi_32_d(void) { FLAG_Z = DY &= (OPER_I_32()); FLAG_N = NFLAG_32(FLAG_Z); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_andi_32_ai(void) { uint src = OPER_I_32(); uint ea = EA_AY_AI_32(); uint res = src & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_andi_32_pi(void) { uint src = OPER_I_32(); uint ea = EA_AY_PI_32(); uint res = src & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_andi_32_pd(void) { uint src = OPER_I_32(); uint ea = EA_AY_PD_32(); uint res = src & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_andi_32_di(void) { uint src = OPER_I_32(); uint ea = EA_AY_DI_32(); uint res = src & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_andi_32_ix(void) { uint src = OPER_I_32(); uint ea = EA_AY_IX_32(); uint res = src & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_andi_32_aw(void) { uint src = OPER_I_32(); uint ea = EA_AW_32(); uint res = src & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_andi_32_al(void) { uint src = OPER_I_32(); uint ea = EA_AL_32(); uint res = src & m68ki_read_32(ea); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; m68ki_write_32(ea, res); } static void m68k_op_andi_16_toc(void) { m68ki_set_ccr(m68ki_get_ccr() & OPER_I_16()); } static void m68k_op_andi_16_tos(void) { if(FLAG_S) { uint src = OPER_I_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(m68ki_get_sr() & src); return; } m68ki_exception_privilege_violation(); } static void m68k_op_asr_8_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = src >> shift; if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); if(GET_MSB_8(src)) res |= m68ki_shift_8_table[shift]; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_X = FLAG_C = src << (9-shift); } static void m68k_op_asr_16_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = src >> shift; if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); if(GET_MSB_16(src)) res |= m68ki_shift_16_table[shift]; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_X = FLAG_C = src << (9-shift); } static void m68k_op_asr_32_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = *r_dst; uint res = src >> shift; if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); if(GET_MSB_32(src)) res |= m68ki_shift_32_table[shift]; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_X = FLAG_C = src << (9-shift); } static void m68k_op_asr_8_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = src >> shift; if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift < 8) { if(GET_MSB_8(src)) res |= m68ki_shift_8_table[shift]; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_X = FLAG_C = src << (9-shift); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } if(GET_MSB_8(src)) { *r_dst |= 0xff; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; return; } *r_dst &= 0xffffff00; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_8(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_asr_16_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = src >> shift; if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift < 16) { if(GET_MSB_16(src)) res |= m68ki_shift_16_table[shift]; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_C = FLAG_X = (src >> (shift - 1))<<8; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } if(GET_MSB_16(src)) { *r_dst |= 0xffff; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; return; } *r_dst &= 0xffff0000; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_16(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_asr_32_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = *r_dst; uint res = src >> shift; if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift < 32) { if(GET_MSB_32(src)) res |= m68ki_shift_32_table[shift]; *r_dst = res; FLAG_C = FLAG_X = (src >> (shift - 1))<<8; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } if(GET_MSB_32(src)) { *r_dst = 0xffffffff; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; return; } *r_dst = 0; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_32(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_asr_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; if(GET_MSB_16(src)) res |= 0x8000; m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = FLAG_X = src << 8; } static void m68k_op_asr_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; if(GET_MSB_16(src)) res |= 0x8000; m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = FLAG_X = src << 8; } static void m68k_op_asr_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; if(GET_MSB_16(src)) res |= 0x8000; m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = FLAG_X = src << 8; } static void m68k_op_asr_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; if(GET_MSB_16(src)) res |= 0x8000; m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = FLAG_X = src << 8; } static void m68k_op_asr_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; if(GET_MSB_16(src)) res |= 0x8000; m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = FLAG_X = src << 8; } static void m68k_op_asr_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; if(GET_MSB_16(src)) res |= 0x8000; m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = FLAG_X = src << 8; } static void m68k_op_asr_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; if(GET_MSB_16(src)) res |= 0x8000; m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = FLAG_X = src << 8; } static void m68k_op_asl_8_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = MASK_OUT_ABOVE_8(src << shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_X = FLAG_C = src << shift; FLAG_N = NFLAG_8(res); FLAG_Z = res; src &= m68ki_shift_8_table[shift + 1]; FLAG_V = (!(src == 0 || (src == m68ki_shift_8_table[shift + 1] && shift < 8)))<<7; } static void m68k_op_asl_16_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = MASK_OUT_ABOVE_16(src << shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> (8-shift); src &= m68ki_shift_16_table[shift + 1]; FLAG_V = (!(src == 0 || src == m68ki_shift_16_table[shift + 1]))<<7; } static void m68k_op_asl_32_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = *r_dst; uint res = MASK_OUT_ABOVE_32(src << shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> (24-shift); src &= m68ki_shift_32_table[shift + 1]; FLAG_V = (!(src == 0 || src == m68ki_shift_32_table[shift + 1]))<<7; } static void m68k_op_asl_8_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = MASK_OUT_ABOVE_8(src << shift); if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift < 8) { *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_X = FLAG_C = src << shift; FLAG_N = NFLAG_8(res); FLAG_Z = res; src &= m68ki_shift_8_table[shift + 1]; FLAG_V = (!(src == 0 || src == m68ki_shift_8_table[shift + 1]))<<7; return; } *r_dst &= 0xffffff00; FLAG_X = FLAG_C = ((shift == 8 ? src & 1 : 0))<<8; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = (!(src == 0))<<7; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_8(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_asl_16_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = MASK_OUT_ABOVE_16(src << shift); if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift < 16) { *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_X = FLAG_C = (src << shift) >> 8; FLAG_N = NFLAG_16(res); FLAG_Z = res; src &= m68ki_shift_16_table[shift + 1]; FLAG_V = (!(src == 0 || src == m68ki_shift_16_table[shift + 1]))<<7; return; } *r_dst &= 0xffff0000; FLAG_X = FLAG_C = ((shift == 16 ? src & 1 : 0))<<8; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = (!(src == 0))<<7; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_16(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_asl_32_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = *r_dst; uint res = MASK_OUT_ABOVE_32(src << shift); if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift < 32) { *r_dst = res; FLAG_X = FLAG_C = (src >> (32 - shift)) << 8; FLAG_N = NFLAG_32(res); FLAG_Z = res; src &= m68ki_shift_32_table[shift + 1]; FLAG_V = (!(src == 0 || src == m68ki_shift_32_table[shift + 1]))<<7; return; } *r_dst = 0; FLAG_X = FLAG_C = ((shift == 32 ? src & 1 : 0))<<8; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = (!(src == 0))<<7; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_32(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_asl_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; src &= 0xc000; FLAG_V = (!(src == 0 || src == 0xc000))<<7; } static void m68k_op_asl_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; src &= 0xc000; FLAG_V = (!(src == 0 || src == 0xc000))<<7; } static void m68k_op_asl_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; src &= 0xc000; FLAG_V = (!(src == 0 || src == 0xc000))<<7; } static void m68k_op_asl_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; src &= 0xc000; FLAG_V = (!(src == 0 || src == 0xc000))<<7; } static void m68k_op_asl_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; src &= 0xc000; FLAG_V = (!(src == 0 || src == 0xc000))<<7; } static void m68k_op_asl_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; src &= 0xc000; FLAG_V = (!(src == 0 || src == 0xc000))<<7; } static void m68k_op_asl_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; src &= 0xc000; FLAG_V = (!(src == 0 || src == 0xc000))<<7; } static void m68k_op_bhi_8(void) { if(COND_HI()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bls_8(void) { if(COND_LS()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bcc_8(void) { if(COND_CC()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bcs_8(void) { if(COND_CS()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bne_8(void) { if(COND_NE()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_beq_8(void) { if(COND_EQ()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bvc_8(void) { if(COND_VC()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bvs_8(void) { if(COND_VS()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bpl_8(void) { if(COND_PL()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bmi_8(void) { if(COND_MI()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bge_8(void) { if(COND_GE()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_blt_8(void) { if(COND_LT()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bgt_8(void) { if(COND_GT()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_ble_8(void) { if(COND_LE()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } static void m68k_op_bhi_16(void) { if(COND_HI()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bls_16(void) { if(COND_LS()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bcc_16(void) { if(COND_CC()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bcs_16(void) { if(COND_CS()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bne_16(void) { if(COND_NE()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_beq_16(void) { if(COND_EQ()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bvc_16(void) { if(COND_VC()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bvs_16(void) { if(COND_VS()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bpl_16(void) { if(COND_PL()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bmi_16(void) { if(COND_MI()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bge_16(void) { if(COND_GE()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_blt_16(void) { if(COND_LT()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bgt_16(void) { if(COND_GT()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_ble_16(void) { if(COND_LE()) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); return; } REG_PC += 2; USE_CYCLES(CYC_BCC_NOTAKE_W); } static void m68k_op_bhi_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_HI()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_HI()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bls_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LS()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_LS()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bcc_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_CC()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_CC()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bcs_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_CS()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_CS()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bne_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_NE()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_NE()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_beq_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_EQ()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_EQ()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bvc_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_VC()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_VC()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bvs_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_VS()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_VS()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bpl_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_PL()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_PL()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bmi_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_MI()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_MI()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bge_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_GE()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_GE()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_blt_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LT()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_LT()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bgt_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_GT()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_GT()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_ble_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LE()) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); return; } REG_PC += 4; return; } else { if(COND_LE()) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); return; } USE_CYCLES(CYC_BCC_NOTAKE_B); } } static void m68k_op_bchg_32_r_d(void) { uint* r_dst = &DY; uint mask = 1 << (DX & 0x1f); FLAG_Z = *r_dst & mask; *r_dst ^= mask; } static void m68k_op_bchg_8_r_ai(void) { uint ea = EA_AY_AI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_r_pi(void) { uint ea = EA_AY_PI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_r_pi7(void) { uint ea = EA_A7_PI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_r_pd(void) { uint ea = EA_AY_PD_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_r_pd7(void) { uint ea = EA_A7_PD_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_r_di(void) { uint ea = EA_AY_DI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_r_ix(void) { uint ea = EA_AY_IX_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_r_aw(void) { uint ea = EA_AW_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_r_al(void) { uint ea = EA_AL_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_32_s_d(void) { uint* r_dst = &DY; uint mask = 1 << (OPER_I_8() & 0x1f); FLAG_Z = *r_dst & mask; *r_dst ^= mask; } static void m68k_op_bchg_8_s_ai(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_AI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_s_pi(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_PI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_s_pi7(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_A7_PI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_s_pd(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_PD_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_s_pd7(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_A7_PD_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_s_di(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_DI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_s_ix(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_IX_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_s_aw(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AW_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bchg_8_s_al(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AL_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src ^ mask); } static void m68k_op_bclr_32_r_d(void) { uint* r_dst = &DY; uint mask = 1 << (DX & 0x1f); FLAG_Z = *r_dst & mask; *r_dst &= ~mask; } static void m68k_op_bclr_8_r_ai(void) { uint ea = EA_AY_AI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_r_pi(void) { uint ea = EA_AY_PI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_r_pi7(void) { uint ea = EA_A7_PI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_r_pd(void) { uint ea = EA_AY_PD_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_r_pd7(void) { uint ea = EA_A7_PD_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_r_di(void) { uint ea = EA_AY_DI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_r_ix(void) { uint ea = EA_AY_IX_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_r_aw(void) { uint ea = EA_AW_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_r_al(void) { uint ea = EA_AL_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_32_s_d(void) { uint* r_dst = &DY; uint mask = 1 << (OPER_I_8() & 0x1f); FLAG_Z = *r_dst & mask; *r_dst &= ~mask; } static void m68k_op_bclr_8_s_ai(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_AI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_s_pi(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_PI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_s_pi7(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_A7_PI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_s_pd(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_PD_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_s_pd7(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_A7_PD_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_s_di(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_DI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_s_ix(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_IX_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_s_aw(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AW_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } static void m68k_op_bclr_8_s_al(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AL_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src & ~mask); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_bfchg_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint offset = (word2>>6)&31; uint width = word2; uint* data = &DY; uint64 mask; if(BIT_B(word2)) offset = REG_D[offset&7]; if(BIT_5(word2)) width = REG_D[width&7]; offset &= 31; width = ((width-1) & 31) + 1; mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask = ROR_32(mask, offset); FLAG_N = NFLAG_32(*data<<offset); FLAG_Z = *data & mask; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *data ^= mask; return; } m68ki_exception_illegal(); } static void m68k_op_bfchg_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_AI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long ^ mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte ^ mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfchg_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_DI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long ^ mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte ^ mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfchg_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_IX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long ^ mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte ^ mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfchg_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AW_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long ^ mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte ^ mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfchg_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AL_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long ^ mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte ^ mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfclr_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint offset = (word2>>6)&31; uint width = word2; uint* data = &DY; uint64 mask; if(BIT_B(word2)) offset = REG_D[offset&7]; if(BIT_5(word2)) width = REG_D[width&7]; offset &= 31; width = ((width-1) & 31) + 1; mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask = ROR_32(mask, offset); FLAG_N = NFLAG_32(*data<<offset); FLAG_Z = *data & mask; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *data &= ~mask; return; } m68ki_exception_illegal(); } static void m68k_op_bfclr_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_AI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long & ~mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte & ~mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfclr_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_DI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long & ~mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte & ~mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfclr_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_IX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long & ~mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte & ~mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfclr_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AW_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long & ~mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte & ~mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfclr_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AL_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long & ~mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte & ~mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfexts_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint offset = (word2>>6)&31; uint width = word2; uint64 data = DY; if(BIT_B(word2)) offset = REG_D[offset&7]; if(BIT_5(word2)) width = REG_D[width&7]; offset &= 31; width = ((width-1) & 31) + 1; data = ROL_32(data, offset); FLAG_N = NFLAG_32(data); data = MAKE_INT_32(data) >> (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2>>12)&7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfexts_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AY_AI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data = MAKE_INT_32(data) >> (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfexts_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AY_DI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data = MAKE_INT_32(data) >> (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfexts_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AY_IX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data = MAKE_INT_32(data) >> (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfexts_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AW_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data = MAKE_INT_32(data) >> (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfexts_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AL_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data = MAKE_INT_32(data) >> (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfexts_32_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_PCDI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data = MAKE_INT_32(data) >> (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfexts_32_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_PCIX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data = MAKE_INT_32(data) >> (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfextu_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint offset = (word2>>6)&31; uint width = word2; uint64 data = DY; if(BIT_B(word2)) offset = REG_D[offset&7]; if(BIT_5(word2)) width = REG_D[width&7]; offset &= 31; width = ((width-1) & 31) + 1; data = ROL_32(data, offset); FLAG_N = NFLAG_32(data); data >>= 32 - width; FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2>>12)&7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfextu_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AY_AI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfextu_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AY_DI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfextu_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AY_IX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfextu_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AW_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfextu_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_AL_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfextu_32_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_PCDI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfextu_32_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint data; uint ea = EA_PCIX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<offset); if((offset+width) > 32) data |= (m68ki_read_8(ea+4) << offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = data; return; } m68ki_exception_illegal(); } static void m68k_op_bfffo_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint offset = (word2>>6)&31; uint width = word2; uint64 data = DY; uint bit; if(BIT_B(word2)) offset = REG_D[offset&7]; if(BIT_5(word2)) width = REG_D[width&7]; offset &= 31; width = ((width-1) & 31) + 1; data = ROL_32(data, offset); FLAG_N = NFLAG_32(data); data >>= 32 - width; FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) offset++; REG_D[(word2>>12)&7] = offset; return; } m68ki_exception_illegal(); } static void m68k_op_bfffo_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; sint local_offset; uint width = word2; uint data; uint bit; uint ea = EA_AY_AI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; local_offset = offset % 8; if(local_offset < 0) { local_offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<local_offset); if((local_offset+width) > 32) data |= (m68ki_read_8(ea+4) << local_offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) offset++; REG_D[(word2>>12)&7] = offset; return; } m68ki_exception_illegal(); } static void m68k_op_bfffo_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; sint local_offset; uint width = word2; uint data; uint bit; uint ea = EA_AY_DI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; local_offset = offset % 8; if(local_offset < 0) { local_offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<local_offset); if((local_offset+width) > 32) data |= (m68ki_read_8(ea+4) << local_offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) offset++; REG_D[(word2>>12)&7] = offset; return; } m68ki_exception_illegal(); } static void m68k_op_bfffo_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; sint local_offset; uint width = word2; uint data; uint bit; uint ea = EA_AY_IX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; local_offset = offset % 8; if(local_offset < 0) { local_offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<local_offset); if((local_offset+width) > 32) data |= (m68ki_read_8(ea+4) << local_offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) offset++; REG_D[(word2>>12)&7] = offset; return; } m68ki_exception_illegal(); } static void m68k_op_bfffo_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; sint local_offset; uint width = word2; uint data; uint bit; uint ea = EA_AW_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; local_offset = offset % 8; if(local_offset < 0) { local_offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<local_offset); if((local_offset+width) > 32) data |= (m68ki_read_8(ea+4) << local_offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) offset++; REG_D[(word2>>12)&7] = offset; return; } m68ki_exception_illegal(); } static void m68k_op_bfffo_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; sint local_offset; uint width = word2; uint data; uint bit; uint ea = EA_AL_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; local_offset = offset % 8; if(local_offset < 0) { local_offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<local_offset); if((local_offset+width) > 32) data |= (m68ki_read_8(ea+4) << local_offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) offset++; REG_D[(word2>>12)&7] = offset; return; } m68ki_exception_illegal(); } static void m68k_op_bfffo_32_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; sint local_offset; uint width = word2; uint data; uint bit; uint ea = EA_PCDI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; local_offset = offset % 8; if(local_offset < 0) { local_offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<local_offset); if((local_offset+width) > 32) data |= (m68ki_read_8(ea+4) << local_offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) offset++; REG_D[(word2>>12)&7] = offset; return; } m68ki_exception_illegal(); } static void m68k_op_bfffo_32_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; sint local_offset; uint width = word2; uint data; uint bit; uint ea = EA_PCIX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; local_offset = offset % 8; if(local_offset < 0) { local_offset += 8; ea--; } width = ((width-1) & 31) + 1; data = m68ki_read_32(ea); data = MASK_OUT_ABOVE_32(data<<local_offset); if((local_offset+width) > 32) data |= (m68ki_read_8(ea+4) << local_offset) >> 8; FLAG_N = NFLAG_32(data); data >>= (32 - width); FLAG_Z = data; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) offset++; REG_D[(word2>>12)&7] = offset; return; } m68ki_exception_illegal(); } static void m68k_op_bfins_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint offset = (word2>>6)&31; uint width = word2; uint* data = &DY; uint64 mask; uint64 insert = REG_D[(word2>>12)&7]; if(BIT_B(word2)) offset = REG_D[offset&7]; if(BIT_5(word2)) width = REG_D[width&7]; offset &= 31; width = ((width-1) & 31) + 1; mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask = ROR_32(mask, offset); insert = MASK_OUT_ABOVE_32(insert << (32 - width)); FLAG_N = NFLAG_32(insert); FLAG_Z = insert; insert = ROR_32(insert, offset); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *data &= ~mask; *data |= insert; return; } m68ki_exception_illegal(); } static void m68k_op_bfins_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint insert_base = REG_D[(word2>>12)&7]; uint insert_long; uint insert_byte; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_AI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); FLAG_N = NFLAG_32(insert_base); FLAG_Z = insert_base; insert_long = insert_base >> offset; data_long = m68ki_read_32(ea); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); insert_byte = MASK_OUT_ABOVE_8(insert_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfins_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint insert_base = REG_D[(word2>>12)&7]; uint insert_long; uint insert_byte; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_DI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); FLAG_N = NFLAG_32(insert_base); FLAG_Z = insert_base; insert_long = insert_base >> offset; data_long = m68ki_read_32(ea); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); insert_byte = MASK_OUT_ABOVE_8(insert_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfins_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint insert_base = REG_D[(word2>>12)&7]; uint insert_long; uint insert_byte; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_IX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); FLAG_N = NFLAG_32(insert_base); FLAG_Z = insert_base; insert_long = insert_base >> offset; data_long = m68ki_read_32(ea); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); insert_byte = MASK_OUT_ABOVE_8(insert_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfins_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint insert_base = REG_D[(word2>>12)&7]; uint insert_long; uint insert_byte; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AW_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); FLAG_N = NFLAG_32(insert_base); FLAG_Z = insert_base; insert_long = insert_base >> offset; data_long = m68ki_read_32(ea); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); insert_byte = MASK_OUT_ABOVE_8(insert_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfins_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint insert_base = REG_D[(word2>>12)&7]; uint insert_long; uint insert_byte; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AL_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); FLAG_N = NFLAG_32(insert_base); FLAG_Z = insert_base; insert_long = insert_base >> offset; data_long = m68ki_read_32(ea); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); insert_byte = MASK_OUT_ABOVE_8(insert_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfset_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint offset = (word2>>6)&31; uint width = word2; uint* data = &DY; uint64 mask; if(BIT_B(word2)) offset = REG_D[offset&7]; if(BIT_5(word2)) width = REG_D[width&7]; offset &= 31; width = ((width-1) & 31) + 1; mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask = ROR_32(mask, offset); FLAG_N = NFLAG_32(*data<<offset); FLAG_Z = *data & mask; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *data |= mask; return; } m68ki_exception_illegal(); } static void m68k_op_bfset_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_AI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long | mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte | mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfset_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_DI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long | mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte | mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfset_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_IX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long | mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte | mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfset_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AW_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long | mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte | mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bfset_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AL_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = NFLAG_32(data_long << offset); FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; m68ki_write_32(ea, data_long | mask_long); if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); m68ki_write_8(ea+4, data_byte | mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bftst_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint offset = (word2>>6)&31; uint width = word2; uint* data = &DY; uint64 mask; if(BIT_B(word2)) offset = REG_D[offset&7]; if(BIT_5(word2)) width = REG_D[width&7]; offset &= 31; width = ((width-1) & 31) + 1; mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask = ROR_32(mask, offset); FLAG_N = NFLAG_32(*data<<offset); FLAG_Z = *data & mask; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } static void m68k_op_bftst_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_AI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = ((data_long & (0x80000000 >> offset))<<offset)>>24; FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bftst_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_DI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = ((data_long & (0x80000000 >> offset))<<offset)>>24; FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bftst_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AY_IX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = ((data_long & (0x80000000 >> offset))<<offset)>>24; FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bftst_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AW_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = ((data_long & (0x80000000 >> offset))<<offset)>>24; FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bftst_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_AL_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = ((data_long & (0x80000000 >> offset))<<offset)>>24; FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bftst_32_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_PCDI_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = ((data_long & (0x80000000 >> offset))<<offset)>>24; FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); } return; } m68ki_exception_illegal(); } static void m68k_op_bftst_32_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); sint offset = (word2>>6)&31; uint width = word2; uint mask_base; uint data_long; uint mask_long; uint data_byte = 0; uint mask_byte = 0; uint ea = EA_PCIX_8(); if(BIT_B(word2)) offset = MAKE_INT_32(REG_D[offset&7]); if(BIT_5(word2)) width = REG_D[width&7]; /* Offset is signed so we have to use ugly math =( */ ea += offset / 8; offset %= 8; if(offset < 0) { offset += 8; ea--; } width = ((width-1) & 31) + 1; mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); mask_long = mask_base >> offset; data_long = m68ki_read_32(ea); FLAG_N = ((data_long & (0x80000000 >> offset))<<offset)>>24; FLAG_Z = data_long & mask_long; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; if((width + offset) > 32) { mask_byte = MASK_OUT_ABOVE_8(mask_base); data_byte = m68ki_read_8(ea+4); FLAG_Z |= (data_byte & mask_byte); } return; } m68ki_exception_illegal(); } #endif #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_bkpt(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { m68ki_bkpt_ack(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE) ? REG_IR & 7 : 0); /* auto-disable (see m68kcpu.h) */ } m68ki_exception_illegal(); } #endif static void m68k_op_bra_8(void) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_bra_16(void) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_bra_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint offset = OPER_I_32(); REG_PC -= 4; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_32(offset); m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ return; } else { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } } static void m68k_op_bset_32_r_d(void) { uint* r_dst = &DY; uint mask = 1 << (DX & 0x1f); FLAG_Z = *r_dst & mask; *r_dst |= mask; } static void m68k_op_bset_8_r_ai(void) { uint ea = EA_AY_AI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_r_pi(void) { uint ea = EA_AY_PI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_r_pi7(void) { uint ea = EA_A7_PI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_r_pd(void) { uint ea = EA_AY_PD_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_r_pd7(void) { uint ea = EA_A7_PD_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_r_di(void) { uint ea = EA_AY_DI_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_r_ix(void) { uint ea = EA_AY_IX_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_r_aw(void) { uint ea = EA_AW_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_r_al(void) { uint ea = EA_AL_8(); uint src = m68ki_read_8(ea); uint mask = 1 << (DX & 7); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_32_s_d(void) { uint* r_dst = &DY; uint mask = 1 << (OPER_I_8() & 0x1f); FLAG_Z = *r_dst & mask; *r_dst |= mask; } static void m68k_op_bset_8_s_ai(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_AI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_s_pi(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_PI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_s_pi7(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_A7_PI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_s_pd(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_PD_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_s_pd7(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_A7_PD_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_s_di(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_DI_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_s_ix(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AY_IX_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_s_aw(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AW_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bset_8_s_al(void) { uint mask = 1 << (OPER_I_8() & 7); uint ea = EA_AL_8(); uint src = m68ki_read_8(ea); FLAG_Z = src & mask; m68ki_write_8(ea, src | mask); } static void m68k_op_bsr_8(void) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); } static void m68k_op_bsr_16(void) { uint offset = OPER_I_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); REG_PC -= 2; m68ki_branch_16(offset); } static void m68k_op_bsr_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint offset = OPER_I_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); REG_PC -= 4; m68ki_branch_32(offset); return; } else { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); } } static void m68k_op_btst_32_r_d(void) { FLAG_Z = DY & (1 << (DX & 0x1f)); } static void m68k_op_btst_8_r_ai(void) { FLAG_Z = OPER_AY_AI_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_pi(void) { FLAG_Z = OPER_AY_PI_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_pi7(void) { FLAG_Z = OPER_A7_PI_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_pd(void) { FLAG_Z = OPER_AY_PD_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_pd7(void) { FLAG_Z = OPER_A7_PD_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_di(void) { FLAG_Z = OPER_AY_DI_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_ix(void) { FLAG_Z = OPER_AY_IX_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_aw(void) { FLAG_Z = OPER_AW_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_al(void) { FLAG_Z = OPER_AL_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_pcdi(void) { FLAG_Z = OPER_PCDI_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_pcix(void) { FLAG_Z = OPER_PCIX_8() & (1 << (DX & 7)); } static void m68k_op_btst_8_r_i(void) { FLAG_Z = OPER_I_8() & (1 << (DX & 7)); } static void m68k_op_btst_32_s_d(void) { FLAG_Z = DY & (1 << (OPER_I_8() & 0x1f)); } static void m68k_op_btst_8_s_ai(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_AY_AI_8() & (1 << bit); } static void m68k_op_btst_8_s_pi(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_AY_PI_8() & (1 << bit); } static void m68k_op_btst_8_s_pi7(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_A7_PI_8() & (1 << bit); } static void m68k_op_btst_8_s_pd(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_AY_PD_8() & (1 << bit); } static void m68k_op_btst_8_s_pd7(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_A7_PD_8() & (1 << bit); } static void m68k_op_btst_8_s_di(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_AY_DI_8() & (1 << bit); } static void m68k_op_btst_8_s_ix(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_AY_IX_8() & (1 << bit); } static void m68k_op_btst_8_s_aw(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_AW_8() & (1 << bit); } static void m68k_op_btst_8_s_al(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_AL_8() & (1 << bit); } static void m68k_op_btst_8_s_pcdi(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_PCDI_8() & (1 << bit); } static void m68k_op_btst_8_s_pcix(void) { uint bit = OPER_I_8() & 7; FLAG_Z = OPER_PCIX_8() & (1 << bit); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_callm_32_ai(void) { /* note: watch out for pcrelative modes */ if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) { uint ea = EA_AY_AI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_PC += 2; (void)ea; /* just to avoid an 'unused variable' warning */ M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_illegal(); } static void m68k_op_callm_32_di(void) { /* note: watch out for pcrelative modes */ if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) { uint ea = EA_AY_DI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_PC += 2; (void)ea; /* just to avoid an 'unused variable' warning */ M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_illegal(); } static void m68k_op_callm_32_ix(void) { /* note: watch out for pcrelative modes */ if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) { uint ea = EA_AY_IX_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_PC += 2; (void)ea; /* just to avoid an 'unused variable' warning */ M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_illegal(); } static void m68k_op_callm_32_aw(void) { /* note: watch out for pcrelative modes */ if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) { uint ea = EA_AW_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_PC += 2; (void)ea; /* just to avoid an 'unused variable' warning */ M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_illegal(); } static void m68k_op_callm_32_al(void) { /* note: watch out for pcrelative modes */ if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) { uint ea = EA_AL_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_PC += 2; (void)ea; /* just to avoid an 'unused variable' warning */ M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_illegal(); } static void m68k_op_callm_32_pcdi(void) { /* note: watch out for pcrelative modes */ if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) { uint ea = EA_PCDI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_PC += 2; (void)ea; /* just to avoid an 'unused variable' warning */ M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_illegal(); } static void m68k_op_callm_32_pcix(void) { /* note: watch out for pcrelative modes */ if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) { uint ea = EA_PCIX_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_PC += 2; (void)ea; /* just to avoid an 'unused variable' warning */ M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_AI_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_pi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_PI_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_pi7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_A7_PI_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_pd(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_PD_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_pd7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_A7_PD_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_DI_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_IX_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AW_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_8_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AL_8(); uint dest = m68ki_read_8(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_8(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(*compare, dest, res); FLAG_C = CFLAG_8(res); if(COND_NE()) *compare = MASK_OUT_BELOW_8(*compare) | dest; else { USE_CYCLES(21); m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_16_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_AI_16(); uint dest = m68ki_read_16(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_16(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(*compare, dest, res); FLAG_C = CFLAG_16(res); if(COND_NE()) *compare = MASK_OUT_BELOW_16(*compare) | dest; else { USE_CYCLES(21); m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_16_pi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_PI_16(); uint dest = m68ki_read_16(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_16(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(*compare, dest, res); FLAG_C = CFLAG_16(res); if(COND_NE()) *compare = MASK_OUT_BELOW_16(*compare) | dest; else { USE_CYCLES(21); m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_16_pd(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_PD_16(); uint dest = m68ki_read_16(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_16(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(*compare, dest, res); FLAG_C = CFLAG_16(res); if(COND_NE()) *compare = MASK_OUT_BELOW_16(*compare) | dest; else { USE_CYCLES(21); m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_16_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_DI_16(); uint dest = m68ki_read_16(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_16(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(*compare, dest, res); FLAG_C = CFLAG_16(res); if(COND_NE()) *compare = MASK_OUT_BELOW_16(*compare) | dest; else { USE_CYCLES(21); m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_16_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_IX_16(); uint dest = m68ki_read_16(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_16(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(*compare, dest, res); FLAG_C = CFLAG_16(res); if(COND_NE()) *compare = MASK_OUT_BELOW_16(*compare) | dest; else { USE_CYCLES(21); m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_16_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AW_16(); uint dest = m68ki_read_16(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_16(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(*compare, dest, res); FLAG_C = CFLAG_16(res); if(COND_NE()) *compare = MASK_OUT_BELOW_16(*compare) | dest; else { USE_CYCLES(21); m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_16_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AL_16(); uint dest = m68ki_read_16(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - MASK_OUT_ABOVE_16(*compare); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(*compare, dest, res); FLAG_C = CFLAG_16(res); if(COND_NE()) *compare = MASK_OUT_BELOW_16(*compare) | dest; else { USE_CYCLES(21); m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_AI_32(); uint dest = m68ki_read_32(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - *compare; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(*compare, dest, res); FLAG_C = CFLAG_SUB_32(*compare, dest, res); if(COND_NE()) *compare = dest; else { USE_CYCLES(21); m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_32_pi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_PI_32(); uint dest = m68ki_read_32(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - *compare; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(*compare, dest, res); FLAG_C = CFLAG_SUB_32(*compare, dest, res); if(COND_NE()) *compare = dest; else { USE_CYCLES(21); m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_32_pd(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_PD_32(); uint dest = m68ki_read_32(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - *compare; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(*compare, dest, res); FLAG_C = CFLAG_SUB_32(*compare, dest, res); if(COND_NE()) *compare = dest; else { USE_CYCLES(21); m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_DI_32(); uint dest = m68ki_read_32(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - *compare; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(*compare, dest, res); FLAG_C = CFLAG_SUB_32(*compare, dest, res); if(COND_NE()) *compare = dest; else { USE_CYCLES(21); m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AY_IX_32(); uint dest = m68ki_read_32(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - *compare; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(*compare, dest, res); FLAG_C = CFLAG_SUB_32(*compare, dest, res); if(COND_NE()) *compare = dest; else { USE_CYCLES(21); m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AW_32(); uint dest = m68ki_read_32(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - *compare; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(*compare, dest, res); FLAG_C = CFLAG_SUB_32(*compare, dest, res); if(COND_NE()) *compare = dest; else { USE_CYCLES(21); m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); } return; } m68ki_exception_illegal(); } static void m68k_op_cas_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint ea = EA_AL_32(); uint dest = m68ki_read_32(ea); uint* compare = &REG_D[word2 & 7]; uint res = dest - *compare; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(*compare, dest, res); FLAG_C = CFLAG_SUB_32(*compare, dest, res); if(COND_NE()) *compare = dest; else { USE_CYCLES(21); m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); } return; } m68ki_exception_illegal(); } static void m68k_op_cas2_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_32(); uint* compare1 = &REG_D[(word2 >> 16) & 7]; uint ea1 = REG_DA[(word2 >> 28) & 15]; uint dest1 = m68ki_read_16(ea1); uint res1 = dest1 - MASK_OUT_ABOVE_16(*compare1); uint* compare2 = &REG_D[word2 & 7]; uint ea2 = REG_DA[(word2 >> 12) & 15]; uint dest2 = m68ki_read_16(ea2); uint res2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_16(res1); FLAG_Z = MASK_OUT_ABOVE_16(res1); FLAG_V = VFLAG_SUB_16(*compare1, dest1, res1); FLAG_C = CFLAG_16(res1); if(COND_EQ()) { res2 = dest2 - MASK_OUT_ABOVE_16(*compare2); FLAG_N = NFLAG_16(res2); FLAG_Z = MASK_OUT_ABOVE_16(res2); FLAG_V = VFLAG_SUB_16(*compare2, dest2, res2); FLAG_C = CFLAG_16(res2); if(COND_EQ()) { USE_CYCLES(21); m68ki_write_16(ea1, REG_D[(word2 >> 22) & 7]); m68ki_write_16(ea2, REG_D[(word2 >> 6) & 7]); return; } } *compare1 = BIT_1F(word2) ? MAKE_INT_16(dest1) : MASK_OUT_BELOW_16(*compare1) | dest1; *compare2 = BIT_F(word2) ? MAKE_INT_16(dest2) : MASK_OUT_BELOW_16(*compare2) | dest2; return; } m68ki_exception_illegal(); } static void m68k_op_cas2_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_32(); uint* compare1 = &REG_D[(word2 >> 16) & 7]; uint ea1 = REG_DA[(word2 >> 28) & 15]; uint dest1 = m68ki_read_32(ea1); uint res1 = dest1 - *compare1; uint* compare2 = &REG_D[word2 & 7]; uint ea2 = REG_DA[(word2 >> 12) & 15]; uint dest2 = m68ki_read_32(ea2); uint res2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res1); FLAG_Z = MASK_OUT_ABOVE_32(res1); FLAG_V = VFLAG_SUB_32(*compare1, dest1, res1); FLAG_C = CFLAG_SUB_32(*compare1, dest1, res1); if(COND_EQ()) { res2 = dest2 - *compare2; FLAG_N = NFLAG_32(res2); FLAG_Z = MASK_OUT_ABOVE_32(res2); FLAG_V = VFLAG_SUB_32(*compare2, dest2, res2); FLAG_C = CFLAG_SUB_32(*compare2, dest2, res2); if(COND_EQ()) { USE_CYCLES(21); m68ki_write_32(ea1, REG_D[(word2 >> 22) & 7]); m68ki_write_32(ea2, REG_D[(word2 >> 6) & 7]); return; } } *compare1 = dest1; *compare2 = dest2; return; } m68ki_exception_illegal(); } #endif static void m68k_op_chk_16_d(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(DY); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_ai(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_AY_AI_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_pi(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_AY_PI_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_pd(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_AY_PD_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_di(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_AY_DI_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_ix(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_AY_IX_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_aw(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_AW_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_al(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_AL_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_pcdi(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_PCDI_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_pcix(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_PCIX_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } static void m68k_op_chk_16_i(void) { sint src = MAKE_INT_16(DX); sint bound = MAKE_INT_16(OPER_I_16()); FLAG_Z = ZFLAG_16(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_chk_32_d(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(DY); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_AY_AI_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_pi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_AY_PI_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_pd(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_AY_PD_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_AY_DI_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_AY_IX_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_AW_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_AL_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_PCDI_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_PCIX_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk_32_i(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { sint src = MAKE_INT_32(DX); sint bound = MAKE_INT_32(OPER_I_32()); FLAG_Z = ZFLAG_32(src); /* Undocumented */ FLAG_V = VFLAG_CLEAR; /* Undocumented */ FLAG_C = CFLAG_CLEAR; /* Undocumented */ if(src >= 0 && src <= bound) { return; } FLAG_N = (src < 0)<<7; m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_8_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xff; uint ea = EA_PCDI_8(); uint lower_bound = m68ki_read_pcrel_8(ea); uint upper_bound = m68ki_read_pcrel_8(ea + 1); if(!BIT_F(word2)) FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_8_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xff; uint ea = EA_PCIX_8(); uint lower_bound = m68ki_read_pcrel_8(ea); uint upper_bound = m68ki_read_pcrel_8(ea + 1); if(!BIT_F(word2)) FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_8_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xff; uint ea = EA_AY_AI_8(); uint lower_bound = m68ki_read_8(ea); uint upper_bound = m68ki_read_8(ea + 1); if(!BIT_F(word2)) FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_8_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xff; uint ea = EA_AY_DI_8(); uint lower_bound = m68ki_read_8(ea); uint upper_bound = m68ki_read_8(ea + 1); if(!BIT_F(word2)) FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_8_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xff; uint ea = EA_AY_IX_8(); uint lower_bound = m68ki_read_8(ea); uint upper_bound = m68ki_read_8(ea + 1); if(!BIT_F(word2)) FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_8_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xff; uint ea = EA_AW_8(); uint lower_bound = m68ki_read_8(ea); uint upper_bound = m68ki_read_8(ea + 1); if(!BIT_F(word2)) FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_8_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xff; uint ea = EA_AL_8(); uint lower_bound = m68ki_read_8(ea); uint upper_bound = m68ki_read_8(ea + 1); if(!BIT_F(word2)) FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_16_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; uint ea = EA_PCDI_16(); uint lower_bound = m68ki_read_pcrel_16(ea); uint upper_bound = m68ki_read_pcrel_16(ea + 2); if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_16(FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); else FLAG_C = upper_bound - compare; FLAG_C = CFLAG_16(FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_16_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; uint ea = EA_PCIX_16(); uint lower_bound = m68ki_read_pcrel_16(ea); uint upper_bound = m68ki_read_pcrel_16(ea + 2); if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_16(FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); else FLAG_C = upper_bound - compare; FLAG_C = CFLAG_16(FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_16_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; uint ea = EA_AY_AI_16(); uint lower_bound = m68ki_read_16(ea); uint upper_bound = m68ki_read_16(ea + 2); if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_16(FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); else FLAG_C = upper_bound - compare; FLAG_C = CFLAG_16(FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_16_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; uint ea = EA_AY_DI_16(); uint lower_bound = m68ki_read_16(ea); uint upper_bound = m68ki_read_16(ea + 2); if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_16(FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); else FLAG_C = upper_bound - compare; FLAG_C = CFLAG_16(FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_16_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; uint ea = EA_AY_IX_16(); uint lower_bound = m68ki_read_16(ea); uint upper_bound = m68ki_read_16(ea + 2); if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_16(FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); else FLAG_C = upper_bound - compare; FLAG_C = CFLAG_16(FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_16_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; uint ea = EA_AW_16(); uint lower_bound = m68ki_read_16(ea); uint upper_bound = m68ki_read_16(ea + 2); if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_16(FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); else FLAG_C = upper_bound - compare; FLAG_C = CFLAG_16(FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_16_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; uint ea = EA_AL_16(); uint lower_bound = m68ki_read_16(ea); uint upper_bound = m68ki_read_16(ea + 2); if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); else FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_16(FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } if(!BIT_F(word2)) FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); else FLAG_C = upper_bound - compare; FLAG_C = CFLAG_16(FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_32_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]; uint ea = EA_PCDI_32(); uint lower_bound = m68ki_read_pcrel_32(ea); uint upper_bound = m68ki_read_pcrel_32(ea + 4); FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_32_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]; uint ea = EA_PCIX_32(); uint lower_bound = m68ki_read_pcrel_32(ea); uint upper_bound = m68ki_read_pcrel_32(ea + 4); FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_32_ai(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]; uint ea = EA_AY_AI_32(); uint lower_bound = m68ki_read_32(ea); uint upper_bound = m68ki_read_32(ea + 4); FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_32_di(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]; uint ea = EA_AY_DI_32(); uint lower_bound = m68ki_read_32(ea); uint upper_bound = m68ki_read_32(ea + 4); FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_32_ix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]; uint ea = EA_AY_IX_32(); uint lower_bound = m68ki_read_32(ea); uint upper_bound = m68ki_read_32(ea + 4); FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_32_aw(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]; uint ea = EA_AW_32(); uint lower_bound = m68ki_read_32(ea); uint upper_bound = m68ki_read_32(ea + 4); FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } static void m68k_op_chk2cmp2_32_al(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint compare = REG_DA[(word2 >> 12) & 15]; uint ea = EA_AL_32(); uint lower_bound = m68ki_read_32(ea); uint upper_bound = m68ki_read_32(ea + 4); FLAG_C = compare - lower_bound; FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); if(COND_CS()) { if(BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } FLAG_C = upper_bound - compare; FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); if(COND_CS() && BIT_B(word2)) m68ki_exception_trap(EXCEPTION_CHK); return; } m68ki_exception_illegal(); } #endif static void m68k_op_clr_8_d(void) { DY &= 0xffffff00; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_di(void) { m68ki_write_8(EA_AY_DI_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_aw(void) { m68ki_write_8(EA_AW_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_8_al(void) { m68ki_write_8(EA_AL_8(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_16_d(void) { DY &= 0xffff0000; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_16_ai(void) { m68ki_write_16(EA_AY_AI_16(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_16_pi(void) { m68ki_write_16(EA_AY_PI_16(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_16_pd(void) { m68ki_write_16(EA_AY_PD_16(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_16_di(void) { m68ki_write_16(EA_AY_DI_16(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_16_ix(void) { m68ki_write_16(EA_AY_IX_16(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_16_aw(void) { m68ki_write_16(EA_AW_16(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_16_al(void) { m68ki_write_16(EA_AL_16(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_32_d(void) { DY = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_32_ai(void) { m68ki_write_32(EA_AY_AI_32(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_32_pi(void) { m68ki_write_32(EA_AY_PI_32(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_32_pd(void) { m68ki_write_32(EA_AY_PD_32(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_32_di(void) { m68ki_write_32(EA_AY_DI_32(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_32_ix(void) { m68ki_write_32(EA_AY_IX_32(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_32_aw(void) { m68ki_write_32(EA_AW_32(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_clr_32_al(void) { m68ki_write_32(EA_AL_32(), 0); FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_Z = ZFLAG_SET; } static void m68k_op_cmp_8_d(void) { uint src = MASK_OUT_ABOVE_8(DY); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_ai(void) { uint src = OPER_AY_AI_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_pi(void) { uint src = OPER_AY_PI_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_pi7(void) { uint src = OPER_A7_PI_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_pd(void) { uint src = OPER_AY_PD_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_pd7(void) { uint src = OPER_A7_PD_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_di(void) { uint src = OPER_AY_DI_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_ix(void) { uint src = OPER_AY_IX_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_aw(void) { uint src = OPER_AW_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_al(void) { uint src = OPER_AL_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_pcdi(void) { uint src = OPER_PCDI_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_pcix(void) { uint src = OPER_PCIX_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_8_i(void) { uint src = OPER_I_8(); uint dst = MASK_OUT_ABOVE_8(DX); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmp_16_d(void) { uint src = MASK_OUT_ABOVE_16(DY); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_a(void) { uint src = MASK_OUT_ABOVE_16(AY); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_ai(void) { uint src = OPER_AY_AI_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_pi(void) { uint src = OPER_AY_PI_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_pd(void) { uint src = OPER_AY_PD_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_di(void) { uint src = OPER_AY_DI_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_ix(void) { uint src = OPER_AY_IX_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_aw(void) { uint src = OPER_AW_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_al(void) { uint src = OPER_AL_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_pcdi(void) { uint src = OPER_PCDI_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_pcix(void) { uint src = OPER_PCIX_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_16_i(void) { uint src = OPER_I_16(); uint dst = MASK_OUT_ABOVE_16(DX); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmp_32_d(void) { uint src = DY; uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_a(void) { uint src = AY; uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_ai(void) { uint src = OPER_AY_AI_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_pi(void) { uint src = OPER_AY_PI_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_pd(void) { uint src = OPER_AY_PD_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_di(void) { uint src = OPER_AY_DI_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_ix(void) { uint src = OPER_AY_IX_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_aw(void) { uint src = OPER_AW_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_al(void) { uint src = OPER_AL_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_pcdi(void) { uint src = OPER_PCDI_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_pcix(void) { uint src = OPER_PCIX_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmp_32_i(void) { uint src = OPER_I_32(); uint dst = DX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_d(void) { uint src = MAKE_INT_16(DY); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_a(void) { uint src = MAKE_INT_16(AY); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_ai(void) { uint src = MAKE_INT_16(OPER_AY_AI_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_pi(void) { uint src = MAKE_INT_16(OPER_AY_PI_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_pd(void) { uint src = MAKE_INT_16(OPER_AY_PD_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_di(void) { uint src = MAKE_INT_16(OPER_AY_DI_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_ix(void) { uint src = MAKE_INT_16(OPER_AY_IX_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_aw(void) { uint src = MAKE_INT_16(OPER_AW_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_al(void) { uint src = MAKE_INT_16(OPER_AL_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_pcdi(void) { uint src = MAKE_INT_16(OPER_PCDI_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_pcix(void) { uint src = MAKE_INT_16(OPER_PCIX_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_16_i(void) { uint src = MAKE_INT_16(OPER_I_16()); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_d(void) { uint src = DY; uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_a(void) { uint src = AY; uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_ai(void) { uint src = OPER_AY_AI_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_pi(void) { uint src = OPER_AY_PI_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_pd(void) { uint src = OPER_AY_PD_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_di(void) { uint src = OPER_AY_DI_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_ix(void) { uint src = OPER_AY_IX_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_aw(void) { uint src = OPER_AW_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_al(void) { uint src = OPER_AL_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_pcdi(void) { uint src = OPER_PCDI_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_pcix(void) { uint src = OPER_PCIX_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpa_32_i(void) { uint src = OPER_I_32(); uint dst = AX; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpi_8_d(void) { uint src = OPER_I_8(); uint dst = MASK_OUT_ABOVE_8(DY); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_ai(void) { uint src = OPER_I_8(); uint dst = OPER_AY_AI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_pi(void) { uint src = OPER_I_8(); uint dst = OPER_AY_PI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_pi7(void) { uint src = OPER_I_8(); uint dst = OPER_A7_PI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_pd(void) { uint src = OPER_I_8(); uint dst = OPER_AY_PD_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_pd7(void) { uint src = OPER_I_8(); uint dst = OPER_A7_PD_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_di(void) { uint src = OPER_I_8(); uint dst = OPER_AY_DI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_ix(void) { uint src = OPER_I_8(); uint dst = OPER_AY_IX_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_aw(void) { uint src = OPER_I_8(); uint dst = OPER_AW_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpi_8_al(void) { uint src = OPER_I_8(); uint dst = OPER_AL_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_cmpi_8_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint src = OPER_I_8(); uint dst = OPER_PCDI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); return; } m68ki_exception_illegal(); } static void m68k_op_cmpi_8_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint src = OPER_I_8(); uint dst = OPER_PCIX_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); return; } m68ki_exception_illegal(); } #endif static void m68k_op_cmpi_16_d(void) { uint src = OPER_I_16(); uint dst = MASK_OUT_ABOVE_16(DY); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmpi_16_ai(void) { uint src = OPER_I_16(); uint dst = OPER_AY_AI_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmpi_16_pi(void) { uint src = OPER_I_16(); uint dst = OPER_AY_PI_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmpi_16_pd(void) { uint src = OPER_I_16(); uint dst = OPER_AY_PD_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmpi_16_di(void) { uint src = OPER_I_16(); uint dst = OPER_AY_DI_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmpi_16_ix(void) { uint src = OPER_I_16(); uint dst = OPER_AY_IX_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmpi_16_aw(void) { uint src = OPER_I_16(); uint dst = OPER_AW_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmpi_16_al(void) { uint src = OPER_I_16(); uint dst = OPER_AL_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_cmpi_16_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint src = OPER_I_16(); uint dst = OPER_PCDI_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); return; } m68ki_exception_illegal(); } static void m68k_op_cmpi_16_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint src = OPER_I_16(); uint dst = OPER_PCIX_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); return; } m68ki_exception_illegal(); } #endif static void m68k_op_cmpi_32_d(void) { uint src = OPER_I_32(); uint dst = DY; uint res = dst - src; m68ki_cmpild_callback(src, REG_IR & 7); /* auto-disable (see m68kcpu.h) */ FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpi_32_ai(void) { uint src = OPER_I_32(); uint dst = OPER_AY_AI_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpi_32_pi(void) { uint src = OPER_I_32(); uint dst = OPER_AY_PI_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpi_32_pd(void) { uint src = OPER_I_32(); uint dst = OPER_AY_PD_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpi_32_di(void) { uint src = OPER_I_32(); uint dst = OPER_AY_DI_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpi_32_ix(void) { uint src = OPER_I_32(); uint dst = OPER_AY_IX_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpi_32_aw(void) { uint src = OPER_I_32(); uint dst = OPER_AW_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } static void m68k_op_cmpi_32_al(void) { uint src = OPER_I_32(); uint dst = OPER_AL_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_cmpi_32_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint src = OPER_I_32(); uint dst = OPER_PCDI_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); return; } m68ki_exception_illegal(); } static void m68k_op_cmpi_32_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint src = OPER_I_32(); uint dst = OPER_PCIX_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); return; } m68ki_exception_illegal(); } #endif static void m68k_op_cmpm_8_ax7(void) { uint src = OPER_AY_PI_8(); uint dst = OPER_A7_PI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpm_8_ay7(void) { uint src = OPER_A7_PI_8(); uint dst = OPER_AX_PI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpm_8_axy7(void) { uint src = OPER_A7_PI_8(); uint dst = OPER_A7_PI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpm_8(void) { uint src = OPER_AY_PI_8(); uint dst = OPER_AX_PI_8(); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_C = CFLAG_8(res); } static void m68k_op_cmpm_16(void) { uint src = OPER_AY_PI_16(); uint dst = OPER_AX_PI_16(); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_C = CFLAG_16(res); } static void m68k_op_cmpm_32(void) { uint src = OPER_AY_PI_32(); uint dst = OPER_AX_PI_32(); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_C = CFLAG_SUB_32(src, dst, res); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_cpbcc_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_1111(); } static void m68k_op_cpdbcc_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_1111(); } static void m68k_op_cpgen_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_1111(); } static void m68k_op_cpscc_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_1111(); } static void m68k_op_cptrapcc_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_1111(); } #endif static void m68k_op_dbt_16(void) { REG_PC += 2; } static void m68k_op_dbf_16(void) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); } static void m68k_op_dbhi_16(void) { if(COND_NOT_HI()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbls_16(void) { if(COND_NOT_LS()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbcc_16(void) { if(COND_NOT_CC()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbcs_16(void) { if(COND_NOT_CS()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbne_16(void) { if(COND_NOT_NE()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbeq_16(void) { if(COND_NOT_EQ()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbvc_16(void) { if(COND_NOT_VC()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbvs_16(void) { if(COND_NOT_VS()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbpl_16(void) { if(COND_NOT_PL()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbmi_16(void) { if(COND_NOT_MI()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbge_16(void) { if(COND_NOT_GE()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dblt_16(void) { if(COND_NOT_LT()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dbgt_16(void) { if(COND_NOT_GT()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_dble_16(void) { if(COND_NOT_LE()) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(*r_dst - 1); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; if(res != 0xffff) { uint offset = OPER_I_16(); REG_PC -= 2; m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_branch_16(offset); USE_CYCLES(CYC_DBCC_F_NOEXP); return; } REG_PC += 2; USE_CYCLES(CYC_DBCC_F_EXP); return; } REG_PC += 2; } static void m68k_op_divs_16_d(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(DY); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_ai(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_AY_AI_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_pi(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_AY_PI_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_pd(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_AY_PD_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_di(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_AY_DI_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_ix(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_AY_IX_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_aw(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_AW_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_al(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_AL_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_pcdi(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_PCDI_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_pcix(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_PCIX_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divs_16_i(void) { uint* r_dst = &DX; sint src = MAKE_INT_16(OPER_I_16()); sint quotient; sint remainder; if(src != 0) { int cyc = getDivs68kCycles(*r_dst,src); USE_CYCLES(cyc); if((uint32)*r_dst == 0x80000000 && src == -1) { FLAG_Z = 0; FLAG_N = NFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = 0; return; } quotient = MAKE_INT_32(*r_dst) / src; remainder = MAKE_INT_32(*r_dst) % src; if(quotient == MAKE_INT_16(quotient)) { FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_d(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_16(DY); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_ai(void) { uint* r_dst = &DX; uint src = OPER_AY_AI_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_pi(void) { uint* r_dst = &DX; uint src = OPER_AY_PI_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_pd(void) { uint* r_dst = &DX; uint src = OPER_AY_PD_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_di(void) { uint* r_dst = &DX; uint src = OPER_AY_DI_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_ix(void) { uint* r_dst = &DX; uint src = OPER_AY_IX_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_aw(void) { uint* r_dst = &DX; uint src = OPER_AW_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_al(void) { uint* r_dst = &DX; uint src = OPER_AL_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_pcdi(void) { uint* r_dst = &DX; uint src = OPER_PCDI_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_pcix(void) { uint* r_dst = &DX; uint src = OPER_PCIX_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } static void m68k_op_divu_16_i(void) { uint* r_dst = &DX; uint src = OPER_I_16(); if(src != 0) { uint quotient = *r_dst / src; uint remainder = *r_dst % src; if(quotient < 0x10000) { int cyc = getDivu68kCycles(*r_dst,src); USE_CYCLES(cyc); FLAG_Z = quotient; FLAG_N = NFLAG_16(quotient); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); return; } USE_CYCLES(70); FLAG_V = VFLAG_SET; FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ FLAG_C = CFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_divl_32_d(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = DY; uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = DY; uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_ai(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_AY_AI_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_AY_AI_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_pi(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_AY_PI_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_AY_PI_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_pd(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_AY_PD_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_AY_PD_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_di(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_AY_DI_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_AY_DI_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_ix(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_AY_IX_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_AY_IX_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_aw(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_AW_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_AW_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_al(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_AL_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_AL_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_pcdi(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_PCDI_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_PCDI_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_pcix(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_PCIX_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_PCIX_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } static void m68k_op_divl_32_i(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 divisor = OPER_I_32(); uint64 dividend = 0; uint64 quotient = 0; uint64 remainder = 0; if(divisor != 0) { if(BIT_A(word2)) /* 64 bit */ { dividend = REG_D[word2 & 7]; dividend <<= 32; dividend |= REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); if((sint64)quotient != (sint64)((sint32)quotient)) { FLAG_V = VFLAG_SET; return; } } else /* unsigned */ { quotient = dividend / divisor; if(quotient > 0xffffffff) { FLAG_V = VFLAG_SET; return; } remainder = dividend % divisor; } } else /* 32 bit */ { dividend = REG_D[(word2 >> 12) & 7]; if(BIT_B(word2)) /* signed */ { quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); } else /* unsigned */ { quotient = dividend / divisor; remainder = dividend % divisor; } } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint divisor = OPER_I_32(); uint dividend_hi = REG_D[word2 & 7]; uint dividend_lo = REG_D[(word2 >> 12) & 7]; uint quotient = 0; uint remainder = 0; uint dividend_neg = 0; uint divisor_neg = 0; sint i; uint overflow; if(divisor != 0) { /* quad / long : long quotient, long remainder */ if(BIT_A(word2)) { if(BIT_B(word2)) /* signed */ { /* special case in signed divide */ if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) { REG_D[word2 & 7] = 0; REG_D[(word2 >> 12) & 7] = 0x80000000; FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } if(GET_MSB_32(dividend_hi)) { dividend_neg = 1; dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); } if(GET_MSB_32(divisor)) { divisor_neg = 1; divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); } } /* if the upper long is greater than the divisor, we're overflowing. */ if(dividend_hi >= divisor) { FLAG_V = VFLAG_SET; return; } for(i = 31; i >= 0; i--) { quotient <<= 1; remainder = (remainder << 1) + ((dividend_hi >> i) & 1); if(remainder >= divisor) { remainder -= divisor; quotient++; } } for(i = 31; i >= 0; i--) { quotient <<= 1; overflow = GET_MSB_32(remainder); remainder = (remainder << 1) + ((dividend_lo >> i) & 1); if(remainder >= divisor || overflow) { remainder -= divisor; quotient++; } } if(BIT_B(word2)) /* signed */ { if(quotient > 0x7fffffff) { FLAG_V = VFLAG_SET; return; } if(dividend_neg) { remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } if(divisor_neg) quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); } REG_D[word2 & 7] = remainder; REG_D[(word2 >> 12) & 7] = quotient; FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } /* long / long: long quotient, maybe long remainder */ if(BIT_B(word2)) /* signed */ { /* Special case in divide */ if(dividend_lo == 0x80000000 && divisor == 0xffffffff) { FLAG_N = NFLAG_SET; FLAG_Z = ZFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; REG_D[(word2 >> 12) & 7] = 0x80000000; REG_D[word2 & 7] = 0; return; } REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); } else { REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); } FLAG_N = NFLAG_32(quotient); FLAG_Z = quotient; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); return; } m68ki_exception_illegal(); #endif } #endif static void m68k_op_eor_8_d(void) { uint res = MASK_OUT_ABOVE_8(DY ^= MASK_OUT_ABOVE_8(DX)); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_ai(void) { uint ea = EA_AY_AI_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_pi(void) { uint ea = EA_AY_PI_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_pi7(void) { uint ea = EA_A7_PI_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_pd(void) { uint ea = EA_AY_PD_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_pd7(void) { uint ea = EA_A7_PD_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_di(void) { uint ea = EA_AY_DI_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_ix(void) { uint ea = EA_AY_IX_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_aw(void) { uint ea = EA_AW_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_8_al(void) { uint ea = EA_AL_8(); uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_16_d(void) { uint res = MASK_OUT_ABOVE_16(DY ^= MASK_OUT_ABOVE_16(DX)); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_16_ai(void) { uint ea = EA_AY_AI_16(); uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_16_pi(void) { uint ea = EA_AY_PI_16(); uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_16_pd(void) { uint ea = EA_AY_PD_16(); uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_16_di(void) { uint ea = EA_AY_DI_16(); uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_16_ix(void) { uint ea = EA_AY_IX_16(); uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_16_aw(void) { uint ea = EA_AW_16(); uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_16_al(void) { uint ea = EA_AL_16(); uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_32_d(void) { uint res = DY ^= DX; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_32_ai(void) { uint ea = EA_AY_AI_32(); uint res = DX ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_32_pi(void) { uint ea = EA_AY_PI_32(); uint res = DX ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_32_pd(void) { uint ea = EA_AY_PD_32(); uint res = DX ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_32_di(void) { uint ea = EA_AY_DI_32(); uint res = DX ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_32_ix(void) { uint ea = EA_AY_IX_32(); uint res = DX ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_32_aw(void) { uint ea = EA_AW_32(); uint res = DX ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eor_32_al(void) { uint ea = EA_AL_32(); uint res = DX ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_d(void) { uint res = MASK_OUT_ABOVE_8(DY ^= OPER_I_8()); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_ai(void) { uint src = OPER_I_8(); uint ea = EA_AY_AI_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_pi(void) { uint src = OPER_I_8(); uint ea = EA_AY_PI_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_pi7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PI_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_pd(void) { uint src = OPER_I_8(); uint ea = EA_AY_PD_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_pd7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PD_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_di(void) { uint src = OPER_I_8(); uint ea = EA_AY_DI_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_ix(void) { uint src = OPER_I_8(); uint ea = EA_AY_IX_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_aw(void) { uint src = OPER_I_8(); uint ea = EA_AW_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_8_al(void) { uint src = OPER_I_8(); uint ea = EA_AL_8(); uint res = src ^ m68ki_read_8(ea); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_d(void) { uint res = MASK_OUT_ABOVE_16(DY ^= OPER_I_16()); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_ai(void) { uint src = OPER_I_16(); uint ea = EA_AY_AI_16(); uint res = src ^ m68ki_read_16(ea); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_pi(void) { uint src = OPER_I_16(); uint ea = EA_AY_PI_16(); uint res = src ^ m68ki_read_16(ea); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_pd(void) { uint src = OPER_I_16(); uint ea = EA_AY_PD_16(); uint res = src ^ m68ki_read_16(ea); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_di(void) { uint src = OPER_I_16(); uint ea = EA_AY_DI_16(); uint res = src ^ m68ki_read_16(ea); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_ix(void) { uint src = OPER_I_16(); uint ea = EA_AY_IX_16(); uint res = src ^ m68ki_read_16(ea); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_aw(void) { uint src = OPER_I_16(); uint ea = EA_AW_16(); uint res = src ^ m68ki_read_16(ea); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_al(void) { uint src = OPER_I_16(); uint ea = EA_AL_16(); uint res = src ^ m68ki_read_16(ea); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_32_d(void) { uint res = DY ^= OPER_I_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_32_ai(void) { uint src = OPER_I_32(); uint ea = EA_AY_AI_32(); uint res = src ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_32_pi(void) { uint src = OPER_I_32(); uint ea = EA_AY_PI_32(); uint res = src ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_32_pd(void) { uint src = OPER_I_32(); uint ea = EA_AY_PD_32(); uint res = src ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_32_di(void) { uint src = OPER_I_32(); uint ea = EA_AY_DI_32(); uint res = src ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_32_ix(void) { uint src = OPER_I_32(); uint ea = EA_AY_IX_32(); uint res = src ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_32_aw(void) { uint src = OPER_I_32(); uint ea = EA_AW_32(); uint res = src ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_32_al(void) { uint src = OPER_I_32(); uint ea = EA_AL_32(); uint res = src ^ m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_eori_16_toc(void) { m68ki_set_ccr(m68ki_get_ccr() ^ OPER_I_16()); } static void m68k_op_eori_16_tos(void) { if(FLAG_S) { uint src = OPER_I_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(m68ki_get_sr() ^ src); return; } m68ki_exception_privilege_violation(); } static void m68k_op_exg_32_dd(void) { uint* reg_a = &DX; uint* reg_b = &DY; uint tmp = *reg_a; *reg_a = *reg_b; *reg_b = tmp; } static void m68k_op_exg_32_aa(void) { uint* reg_a = &AX; uint* reg_b = &AY; uint tmp = *reg_a; *reg_a = *reg_b; *reg_b = tmp; } static void m68k_op_exg_32_da(void) { uint* reg_a = &DX; uint* reg_b = &AY; uint tmp = *reg_a; *reg_a = *reg_b; *reg_b = tmp; } static void m68k_op_ext_16(void) { uint* r_dst = &DY; *r_dst = MASK_OUT_BELOW_16(*r_dst) | MASK_OUT_ABOVE_8(*r_dst) | (GET_MSB_8(*r_dst) ? 0xff00 : 0); FLAG_N = NFLAG_16(*r_dst); FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_ext_32(void) { uint* r_dst = &DY; *r_dst = MASK_OUT_ABOVE_16(*r_dst) | (GET_MSB_16(*r_dst) ? 0xffff0000 : 0); FLAG_N = NFLAG_32(*r_dst); FLAG_Z = *r_dst; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_extb_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint* r_dst = &DY; *r_dst = MASK_OUT_ABOVE_8(*r_dst) | (GET_MSB_8(*r_dst) ? 0xffffff00 : 0); FLAG_N = NFLAG_32(*r_dst); FLAG_Z = *r_dst; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } #endif static void m68k_op_illegal(void) { m68ki_exception_illegal(); } static void m68k_op_jmp_32_ai(void) { m68ki_jump(EA_AY_AI_32()); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_jmp_32_di(void) { m68ki_jump(EA_AY_DI_32()); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_jmp_32_ix(void) { m68ki_jump(EA_AY_IX_32()); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_jmp_32_aw(void) { m68ki_jump(EA_AW_32()); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_jmp_32_al(void) { m68ki_jump(EA_AL_32()); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_jmp_32_pcdi(void) { m68ki_jump(EA_PCDI_32()); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_jmp_32_pcix(void) { m68ki_jump(EA_PCIX_32()); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_jsr_32_ai(void) { uint ea = EA_AY_AI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_jump(ea); } static void m68k_op_jsr_32_di(void) { uint ea = EA_AY_DI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_jump(ea); } static void m68k_op_jsr_32_ix(void) { uint ea = EA_AY_IX_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_jump(ea); } static void m68k_op_jsr_32_aw(void) { uint ea = EA_AW_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_jump(ea); } static void m68k_op_jsr_32_al(void) { uint ea = EA_AL_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_jump(ea); } static void m68k_op_jsr_32_pcdi(void) { uint ea = EA_PCDI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_jump(ea); } static void m68k_op_jsr_32_pcix(void) { uint ea = EA_PCIX_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_push_32(REG_PC); m68ki_jump(ea); } static void m68k_op_lea_32_ai(void) { AX = EA_AY_AI_32(); } static void m68k_op_lea_32_di(void) { AX = EA_AY_DI_32(); } static void m68k_op_lea_32_ix(void) { AX = EA_AY_IX_32(); } static void m68k_op_lea_32_aw(void) { AX = EA_AW_32(); } static void m68k_op_lea_32_al(void) { AX = EA_AL_32(); } static void m68k_op_lea_32_pcdi(void) { AX = EA_PCDI_32(); } static void m68k_op_lea_32_pcix(void) { AX = EA_PCIX_32(); } static void m68k_op_link_16_a7(void) { REG_A[7] -= 4; m68ki_write_32(REG_A[7], REG_A[7]); REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16())); } static void m68k_op_link_16(void) { uint* r_dst = &AY; m68ki_push_32(*r_dst); *r_dst = REG_A[7]; REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16())); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_link_32_a7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { REG_A[7] -= 4; m68ki_write_32(REG_A[7], REG_A[7]); REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + OPER_I_32()); return; } m68ki_exception_illegal(); } static void m68k_op_link_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint* r_dst = &AY; m68ki_push_32(*r_dst); *r_dst = REG_A[7]; REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + OPER_I_32()); return; } m68ki_exception_illegal(); } #endif static void m68k_op_lsr_8_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = src >> shift; if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_X = FLAG_C = src << (9-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = src >> shift; if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_X = FLAG_C = src << (9-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_32_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = *r_dst; uint res = src >> shift; if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = res; FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_X = FLAG_C = src << (9-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_8_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = src >> shift; if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift <= 8) { *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_X = FLAG_C = src << (9-shift); FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } *r_dst &= 0xffffff00; FLAG_X = XFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_8(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = src >> shift; if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift <= 16) { *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_C = FLAG_X = (src >> (shift - 1))<<8; FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } *r_dst &= 0xffff0000; FLAG_X = XFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_16(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_32_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = *r_dst; uint res = src >> shift; if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift < 32) { *r_dst = res; FLAG_C = FLAG_X = (src >> (shift - 1))<<8; FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } *r_dst = 0; FLAG_X = FLAG_C = (shift == 32 ? GET_MSB_32(src)>>23 : 0); FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_32(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; m68ki_write_16(ea, res); FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_C = FLAG_X = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; m68ki_write_16(ea, res); FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_C = FLAG_X = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; m68ki_write_16(ea, res); FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_C = FLAG_X = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; m68ki_write_16(ea, res); FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_C = FLAG_X = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; m68ki_write_16(ea, res); FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_C = FLAG_X = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; m68ki_write_16(ea, res); FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_C = FLAG_X = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsr_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = src >> 1; m68ki_write_16(ea, res); FLAG_N = NFLAG_CLEAR; FLAG_Z = res; FLAG_C = FLAG_X = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_8_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = MASK_OUT_ABOVE_8(src << shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_X = FLAG_C = src << shift; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = MASK_OUT_ABOVE_16(src << shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> (8-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_32_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = *r_dst; uint res = MASK_OUT_ABOVE_32(src << shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> (24-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_8_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = MASK_OUT_ABOVE_8(src << shift); if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift <= 8) { *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_X = FLAG_C = src << shift; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } *r_dst &= 0xffffff00; FLAG_X = XFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_8(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = MASK_OUT_ABOVE_16(src << shift); if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift <= 16) { *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_X = FLAG_C = (src << shift) >> 8; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } *r_dst &= 0xffff0000; FLAG_X = XFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_16(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_32_r(void) { uint* r_dst = &DY; uint shift = DX & 0x3f; uint src = *r_dst; uint res = MASK_OUT_ABOVE_32(src << shift); if(shift != 0) { USE_CYCLES(shift * CYC_SHIFT); if(shift < 32) { *r_dst = res; FLAG_X = FLAG_C = (src >> (32 - shift)) << 8; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } *r_dst = 0; FLAG_X = FLAG_C = ((shift == 32 ? src & 1 : 0))<<8; FLAG_N = NFLAG_CLEAR; FLAG_Z = ZFLAG_SET; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_32(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_lsl_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(src << 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_X = FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_move_8_d_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_ai(void) { uint res = OPER_AY_AI_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_pi(void) { uint res = OPER_AY_PI_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_pi7(void) { uint res = OPER_A7_PI_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_pd(void) { uint res = OPER_AY_PD_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_pd7(void) { uint res = OPER_A7_PD_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_di(void) { uint res = OPER_AY_DI_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_ix(void) { uint res = OPER_AY_IX_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_aw(void) { uint res = OPER_AW_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_al(void) { uint res = OPER_AL_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_pcdi(void) { uint res = OPER_PCDI_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_pcix(void) { uint res = OPER_PCIX_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_d_i(void) { uint res = OPER_I_8(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_aw(void) { uint res = OPER_AW_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_al(void) { uint res = OPER_AL_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ai_i(void) { uint res = OPER_I_8(); uint ea = EA_AX_AI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_aw(void) { uint res = OPER_AW_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_al(void) { uint res = OPER_AL_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi7_i(void) { uint res = OPER_I_8(); uint ea = EA_A7_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_aw(void) { uint res = OPER_AW_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_al(void) { uint res = OPER_AL_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pi_i(void) { uint res = OPER_I_8(); uint ea = EA_AX_PI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_aw(void) { uint res = OPER_AW_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_al(void) { uint res = OPER_AL_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd7_i(void) { uint res = OPER_I_8(); uint ea = EA_A7_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_aw(void) { uint res = OPER_AW_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_al(void) { uint res = OPER_AL_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_pd_i(void) { uint res = OPER_I_8(); uint ea = EA_AX_PD_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_aw(void) { uint res = OPER_AW_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_al(void) { uint res = OPER_AL_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_di_i(void) { uint res = OPER_I_8(); uint ea = EA_AX_DI_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_aw(void) { uint res = OPER_AW_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_al(void) { uint res = OPER_AL_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_ix_i(void) { uint res = OPER_I_8(); uint ea = EA_AX_IX_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_aw(void) { uint res = OPER_AW_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_al(void) { uint res = OPER_AL_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_aw_i(void) { uint res = OPER_I_8(); uint ea = EA_AW_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_d(void) { uint res = MASK_OUT_ABOVE_8(DY); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_ai(void) { uint res = OPER_AY_AI_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_pi(void) { uint res = OPER_AY_PI_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_pi7(void) { uint res = OPER_A7_PI_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_pd(void) { uint res = OPER_AY_PD_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_pd7(void) { uint res = OPER_A7_PD_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_di(void) { uint res = OPER_AY_DI_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_ix(void) { uint res = OPER_AY_IX_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_aw(void) { uint res = OPER_AW_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_al(void) { uint res = OPER_AL_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_pcdi(void) { uint res = OPER_PCDI_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_pcix(void) { uint res = OPER_PCIX_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_8_al_i(void) { uint res = OPER_I_8(); uint ea = EA_AL_8(); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_d(void) { uint res = MASK_OUT_ABOVE_16(DY); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_a(void) { uint res = MASK_OUT_ABOVE_16(AY); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_ai(void) { uint res = OPER_AY_AI_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_pi(void) { uint res = OPER_AY_PI_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_pd(void) { uint res = OPER_AY_PD_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_di(void) { uint res = OPER_AY_DI_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_ix(void) { uint res = OPER_AY_IX_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_aw(void) { uint res = OPER_AW_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_al(void) { uint res = OPER_AL_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_pcdi(void) { uint res = OPER_PCDI_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_pcix(void) { uint res = OPER_PCIX_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_d_i(void) { uint res = OPER_I_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_d(void) { uint res = MASK_OUT_ABOVE_16(DY); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_a(void) { uint res = MASK_OUT_ABOVE_16(AY); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_ai(void) { uint res = OPER_AY_AI_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_pi(void) { uint res = OPER_AY_PI_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_pd(void) { uint res = OPER_AY_PD_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_di(void) { uint res = OPER_AY_DI_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_ix(void) { uint res = OPER_AY_IX_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_aw(void) { uint res = OPER_AW_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_al(void) { uint res = OPER_AL_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_pcdi(void) { uint res = OPER_PCDI_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_pcix(void) { uint res = OPER_PCIX_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ai_i(void) { uint res = OPER_I_16(); uint ea = EA_AX_AI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_d(void) { uint res = MASK_OUT_ABOVE_16(DY); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_a(void) { uint res = MASK_OUT_ABOVE_16(AY); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_ai(void) { uint res = OPER_AY_AI_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_pi(void) { uint res = OPER_AY_PI_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_pd(void) { uint res = OPER_AY_PD_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_di(void) { uint res = OPER_AY_DI_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_ix(void) { uint res = OPER_AY_IX_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_aw(void) { uint res = OPER_AW_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_al(void) { uint res = OPER_AL_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_pcdi(void) { uint res = OPER_PCDI_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_pcix(void) { uint res = OPER_PCIX_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pi_i(void) { uint res = OPER_I_16(); uint ea = EA_AX_PI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_d(void) { uint res = MASK_OUT_ABOVE_16(DY); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_a(void) { uint res = MASK_OUT_ABOVE_16(AY); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_ai(void) { uint res = OPER_AY_AI_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_pi(void) { uint res = OPER_AY_PI_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_pd(void) { uint res = OPER_AY_PD_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_di(void) { uint res = OPER_AY_DI_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_ix(void) { uint res = OPER_AY_IX_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_aw(void) { uint res = OPER_AW_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_al(void) { uint res = OPER_AL_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_pcdi(void) { uint res = OPER_PCDI_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_pcix(void) { uint res = OPER_PCIX_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_pd_i(void) { uint res = OPER_I_16(); uint ea = EA_AX_PD_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_d(void) { uint res = MASK_OUT_ABOVE_16(DY); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_a(void) { uint res = MASK_OUT_ABOVE_16(AY); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_ai(void) { uint res = OPER_AY_AI_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_pi(void) { uint res = OPER_AY_PI_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_pd(void) { uint res = OPER_AY_PD_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_di(void) { uint res = OPER_AY_DI_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_ix(void) { uint res = OPER_AY_IX_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_aw(void) { uint res = OPER_AW_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_al(void) { uint res = OPER_AL_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_pcdi(void) { uint res = OPER_PCDI_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_pcix(void) { uint res = OPER_PCIX_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_di_i(void) { uint res = OPER_I_16(); uint ea = EA_AX_DI_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_d(void) { uint res = MASK_OUT_ABOVE_16(DY); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_a(void) { uint res = MASK_OUT_ABOVE_16(AY); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_ai(void) { uint res = OPER_AY_AI_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_pi(void) { uint res = OPER_AY_PI_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_pd(void) { uint res = OPER_AY_PD_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_di(void) { uint res = OPER_AY_DI_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_ix(void) { uint res = OPER_AY_IX_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_aw(void) { uint res = OPER_AW_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_al(void) { uint res = OPER_AL_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_pcdi(void) { uint res = OPER_PCDI_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_pcix(void) { uint res = OPER_PCIX_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_ix_i(void) { uint res = OPER_I_16(); uint ea = EA_AX_IX_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_d(void) { uint res = MASK_OUT_ABOVE_16(DY); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_a(void) { uint res = MASK_OUT_ABOVE_16(AY); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_ai(void) { uint res = OPER_AY_AI_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_pi(void) { uint res = OPER_AY_PI_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_pd(void) { uint res = OPER_AY_PD_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_di(void) { uint res = OPER_AY_DI_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_ix(void) { uint res = OPER_AY_IX_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_aw(void) { uint res = OPER_AW_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_al(void) { uint res = OPER_AL_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_pcdi(void) { uint res = OPER_PCDI_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_pcix(void) { uint res = OPER_PCIX_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_aw_i(void) { uint res = OPER_I_16(); uint ea = EA_AW_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_d(void) { uint res = MASK_OUT_ABOVE_16(DY); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_a(void) { uint res = MASK_OUT_ABOVE_16(AY); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_ai(void) { uint res = OPER_AY_AI_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_pi(void) { uint res = OPER_AY_PI_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_pd(void) { uint res = OPER_AY_PD_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_di(void) { uint res = OPER_AY_DI_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_ix(void) { uint res = OPER_AY_IX_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_aw(void) { uint res = OPER_AW_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_al(void) { uint res = OPER_AL_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_pcdi(void) { uint res = OPER_PCDI_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_pcix(void) { uint res = OPER_PCIX_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_16_al_i(void) { uint res = OPER_I_16(); uint ea = EA_AL_16(); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_d(void) { uint res = DY; uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_a(void) { uint res = AY; uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_ai(void) { uint res = OPER_AY_AI_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_pi(void) { uint res = OPER_AY_PI_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_pd(void) { uint res = OPER_AY_PD_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_di(void) { uint res = OPER_AY_DI_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_ix(void) { uint res = OPER_AY_IX_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_aw(void) { uint res = OPER_AW_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_al(void) { uint res = OPER_AL_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_pcdi(void) { uint res = OPER_PCDI_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_pcix(void) { uint res = OPER_PCIX_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_d_i(void) { uint res = OPER_I_32(); uint* r_dst = &DX; *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_d(void) { uint res = DY; uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_a(void) { uint res = AY; uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_ai(void) { uint res = OPER_AY_AI_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_pi(void) { uint res = OPER_AY_PI_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_pd(void) { uint res = OPER_AY_PD_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_di(void) { uint res = OPER_AY_DI_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_ix(void) { uint res = OPER_AY_IX_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_aw(void) { uint res = OPER_AW_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_al(void) { uint res = OPER_AL_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_pcdi(void) { uint res = OPER_PCDI_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_pcix(void) { uint res = OPER_PCIX_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ai_i(void) { uint res = OPER_I_32(); uint ea = EA_AX_AI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_d(void) { uint res = DY; uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_a(void) { uint res = AY; uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_ai(void) { uint res = OPER_AY_AI_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_pi(void) { uint res = OPER_AY_PI_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_pd(void) { uint res = OPER_AY_PD_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_di(void) { uint res = OPER_AY_DI_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_ix(void) { uint res = OPER_AY_IX_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_aw(void) { uint res = OPER_AW_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_al(void) { uint res = OPER_AL_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_pcdi(void) { uint res = OPER_PCDI_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_pcix(void) { uint res = OPER_PCIX_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pi_i(void) { uint res = OPER_I_32(); uint ea = EA_AX_PI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_d(void) { uint res = DY; uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_a(void) { uint res = AY; uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_ai(void) { uint res = OPER_AY_AI_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_pi(void) { uint res = OPER_AY_PI_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_pd(void) { uint res = OPER_AY_PD_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_di(void) { uint res = OPER_AY_DI_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_ix(void) { uint res = OPER_AY_IX_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_aw(void) { uint res = OPER_AW_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_al(void) { uint res = OPER_AL_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_pcdi(void) { uint res = OPER_PCDI_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_pcix(void) { uint res = OPER_PCIX_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_pd_i(void) { uint res = OPER_I_32(); uint ea = EA_AX_PD_32(); m68ki_write_16(ea+2, res & 0xFFFF ); m68ki_write_16(ea, (res >> 16) & 0xFFFF ); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_d(void) { uint res = DY; uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_a(void) { uint res = AY; uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_ai(void) { uint res = OPER_AY_AI_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_pi(void) { uint res = OPER_AY_PI_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_pd(void) { uint res = OPER_AY_PD_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_di(void) { uint res = OPER_AY_DI_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_ix(void) { uint res = OPER_AY_IX_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_aw(void) { uint res = OPER_AW_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_al(void) { uint res = OPER_AL_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_pcdi(void) { uint res = OPER_PCDI_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_pcix(void) { uint res = OPER_PCIX_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_di_i(void) { uint res = OPER_I_32(); uint ea = EA_AX_DI_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_d(void) { uint res = DY; uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_a(void) { uint res = AY; uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_ai(void) { uint res = OPER_AY_AI_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_pi(void) { uint res = OPER_AY_PI_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_pd(void) { uint res = OPER_AY_PD_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_di(void) { uint res = OPER_AY_DI_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_ix(void) { uint res = OPER_AY_IX_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_aw(void) { uint res = OPER_AW_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_al(void) { uint res = OPER_AL_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_pcdi(void) { uint res = OPER_PCDI_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_pcix(void) { uint res = OPER_PCIX_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_ix_i(void) { uint res = OPER_I_32(); uint ea = EA_AX_IX_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_d(void) { uint res = DY; uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_a(void) { uint res = AY; uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_ai(void) { uint res = OPER_AY_AI_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_pi(void) { uint res = OPER_AY_PI_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_pd(void) { uint res = OPER_AY_PD_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_di(void) { uint res = OPER_AY_DI_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_ix(void) { uint res = OPER_AY_IX_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_aw(void) { uint res = OPER_AW_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_al(void) { uint res = OPER_AL_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_pcdi(void) { uint res = OPER_PCDI_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_pcix(void) { uint res = OPER_PCIX_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_aw_i(void) { uint res = OPER_I_32(); uint ea = EA_AW_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_d(void) { uint res = DY; uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_a(void) { uint res = AY; uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_ai(void) { uint res = OPER_AY_AI_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_pi(void) { uint res = OPER_AY_PI_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_pd(void) { uint res = OPER_AY_PD_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_di(void) { uint res = OPER_AY_DI_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_ix(void) { uint res = OPER_AY_IX_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_aw(void) { uint res = OPER_AW_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_al(void) { uint res = OPER_AL_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_pcdi(void) { uint res = OPER_PCDI_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_pcix(void) { uint res = OPER_PCIX_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move_32_al_i(void) { uint res = OPER_I_32(); uint ea = EA_AL_32(); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_movea_16_d(void) { AX = MAKE_INT_16(DY); } static void m68k_op_movea_16_a(void) { AX = MAKE_INT_16(AY); } static void m68k_op_movea_16_ai(void) { AX = MAKE_INT_16(OPER_AY_AI_16()); } static void m68k_op_movea_16_pi(void) { AX = MAKE_INT_16(OPER_AY_PI_16()); } static void m68k_op_movea_16_pd(void) { AX = MAKE_INT_16(OPER_AY_PD_16()); } static void m68k_op_movea_16_di(void) { AX = MAKE_INT_16(OPER_AY_DI_16()); } static void m68k_op_movea_16_ix(void) { AX = MAKE_INT_16(OPER_AY_IX_16()); } static void m68k_op_movea_16_aw(void) { AX = MAKE_INT_16(OPER_AW_16()); } static void m68k_op_movea_16_al(void) { AX = MAKE_INT_16(OPER_AL_16()); } static void m68k_op_movea_16_pcdi(void) { AX = MAKE_INT_16(OPER_PCDI_16()); } static void m68k_op_movea_16_pcix(void) { AX = MAKE_INT_16(OPER_PCIX_16()); } static void m68k_op_movea_16_i(void) { AX = MAKE_INT_16(OPER_I_16()); } static void m68k_op_movea_32_d(void) { AX = DY; } static void m68k_op_movea_32_a(void) { AX = AY; } static void m68k_op_movea_32_ai(void) { AX = OPER_AY_AI_32(); } static void m68k_op_movea_32_pi(void) { AX = OPER_AY_PI_32(); } static void m68k_op_movea_32_pd(void) { AX = OPER_AY_PD_32(); } static void m68k_op_movea_32_di(void) { AX = OPER_AY_DI_32(); } static void m68k_op_movea_32_ix(void) { AX = OPER_AY_IX_32(); } static void m68k_op_movea_32_aw(void) { AX = OPER_AW_32(); } static void m68k_op_movea_32_al(void) { AX = OPER_AL_32(); } static void m68k_op_movea_32_pcdi(void) { AX = OPER_PCDI_32(); } static void m68k_op_movea_32_pcix(void) { AX = OPER_PCIX_32(); } static void m68k_op_movea_32_i(void) { AX = OPER_I_32(); } #if M68K_EMULATE_010 ||M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_move_16_frc_d(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { DY = MASK_OUT_BELOW_16(DY) | m68ki_get_ccr(); return; } m68ki_exception_illegal(); } static void m68k_op_move_16_frc_ai(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { m68ki_write_16(EA_AY_AI_16(), m68ki_get_ccr()); return; } m68ki_exception_illegal(); } static void m68k_op_move_16_frc_pi(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { m68ki_write_16(EA_AY_PI_16(), m68ki_get_ccr()); return; } m68ki_exception_illegal(); } static void m68k_op_move_16_frc_pd(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { m68ki_write_16(EA_AY_PD_16(), m68ki_get_ccr()); return; } m68ki_exception_illegal(); } static void m68k_op_move_16_frc_di(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { m68ki_write_16(EA_AY_DI_16(), m68ki_get_ccr()); return; } m68ki_exception_illegal(); } static void m68k_op_move_16_frc_ix(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { m68ki_write_16(EA_AY_IX_16(), m68ki_get_ccr()); return; } m68ki_exception_illegal(); } static void m68k_op_move_16_frc_aw(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { m68ki_write_16(EA_AW_16(), m68ki_get_ccr()); return; } m68ki_exception_illegal(); } static void m68k_op_move_16_frc_al(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { m68ki_write_16(EA_AL_16(), m68ki_get_ccr()); return; } m68ki_exception_illegal(); } #endif static void m68k_op_move_16_toc_d(void) { m68ki_set_ccr(DY); } static void m68k_op_move_16_toc_ai(void) { m68ki_set_ccr(OPER_AY_AI_16()); } static void m68k_op_move_16_toc_pi(void) { m68ki_set_ccr(OPER_AY_PI_16()); } static void m68k_op_move_16_toc_pd(void) { m68ki_set_ccr(OPER_AY_PD_16()); } static void m68k_op_move_16_toc_di(void) { m68ki_set_ccr(OPER_AY_DI_16()); } static void m68k_op_move_16_toc_ix(void) { m68ki_set_ccr(OPER_AY_IX_16()); } static void m68k_op_move_16_toc_aw(void) { m68ki_set_ccr(OPER_AW_16()); } static void m68k_op_move_16_toc_al(void) { m68ki_set_ccr(OPER_AL_16()); } static void m68k_op_move_16_toc_pcdi(void) { m68ki_set_ccr(OPER_PCDI_16()); } static void m68k_op_move_16_toc_pcix(void) { m68ki_set_ccr(OPER_PCIX_16()); } static void m68k_op_move_16_toc_i(void) { m68ki_set_ccr(OPER_I_16()); } static void m68k_op_move_16_frs_d(void) { if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ { DY = MASK_OUT_BELOW_16(DY) | m68ki_get_sr(); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_frs_ai(void) { if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ { uint ea = EA_AY_AI_16(); m68ki_write_16(ea, m68ki_get_sr()); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_frs_pi(void) { if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ { uint ea = EA_AY_PI_16(); m68ki_write_16(ea, m68ki_get_sr()); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_frs_pd(void) { if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ { uint ea = EA_AY_PD_16(); m68ki_write_16(ea, m68ki_get_sr()); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_frs_di(void) { if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ { uint ea = EA_AY_DI_16(); m68ki_write_16(ea, m68ki_get_sr()); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_frs_ix(void) { if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ { uint ea = EA_AY_IX_16(); m68ki_write_16(ea, m68ki_get_sr()); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_frs_aw(void) { if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ { uint ea = EA_AW_16(); m68ki_write_16(ea, m68ki_get_sr()); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_frs_al(void) { if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ { uint ea = EA_AL_16(); m68ki_write_16(ea, m68ki_get_sr()); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_d(void) { if(FLAG_S) { m68ki_set_sr(DY); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_ai(void) { if(FLAG_S) { uint new_sr = OPER_AY_AI_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_pi(void) { if(FLAG_S) { uint new_sr = OPER_AY_PI_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_pd(void) { if(FLAG_S) { uint new_sr = OPER_AY_PD_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_di(void) { if(FLAG_S) { uint new_sr = OPER_AY_DI_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_ix(void) { if(FLAG_S) { uint new_sr = OPER_AY_IX_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_aw(void) { if(FLAG_S) { uint new_sr = OPER_AW_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_al(void) { if(FLAG_S) { uint new_sr = OPER_AL_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_pcdi(void) { if(FLAG_S) { uint new_sr = OPER_PCDI_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_pcix(void) { if(FLAG_S) { uint new_sr = OPER_PCIX_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_16_tos_i(void) { if(FLAG_S) { uint new_sr = OPER_I_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(new_sr); return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_32_fru(void) { if(FLAG_S) { AY = REG_USP; return; } m68ki_exception_privilege_violation(); } static void m68k_op_move_32_tou(void) { if(FLAG_S) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_USP = AY; return; } m68ki_exception_privilege_violation(); } #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_movec_32_cr(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ switch (word2 & 0xfff) { case 0x000: /* SFC */ REG_DA[(word2 >> 12) & 15] = REG_SFC; return; case 0x001: /* DFC */ REG_DA[(word2 >> 12) & 15] = REG_DFC; return; case 0x002: /* CACR */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { REG_DA[(word2 >> 12) & 15] = REG_CACR; return; } return; case 0x800: /* USP */ REG_DA[(word2 >> 12) & 15] = REG_USP; return; case 0x801: /* VBR */ REG_DA[(word2 >> 12) & 15] = REG_VBR; return; case 0x802: /* CAAR */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { REG_DA[(word2 >> 12) & 15] = REG_CAAR; return; } m68ki_exception_illegal(); break; case 0x803: /* MSP */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { REG_DA[(word2 >> 12) & 15] = FLAG_M ? REG_SP : REG_MSP; return; } m68ki_exception_illegal(); return; case 0x804: /* ISP */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { REG_DA[(word2 >> 12) & 15] = FLAG_M ? REG_ISP : REG_SP; return; } m68ki_exception_illegal(); return; case 0x003: /* TC */ if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x004: /* ITT0 */ if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x005: /* ITT1 */ if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x006: /* DTT0 */ if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x007: /* DTT1 */ if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x805: /* MMUSR */ if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x806: /* URP */ if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x807: /* SRP */ if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; default: m68ki_exception_illegal(); return; } } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_movec_32_rc(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ switch (word2 & 0xfff) { case 0x000: /* SFC */ REG_SFC = REG_DA[(word2 >> 12) & 15] & 7; return; case 0x001: /* DFC */ REG_DFC = REG_DA[(word2 >> 12) & 15] & 7; return; case 0x002: /* CACR */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { REG_CACR = REG_DA[(word2 >> 12) & 15]; } else { /* non 68040 can only set the lower 4 bits (C,CE,F,E) */ REG_CACR = REG_DA[(word2 >> 12) & 15] & 0x0f; } return; } m68ki_exception_illegal(); return; case 0x800: /* USP */ REG_USP = REG_DA[(word2 >> 12) & 15]; return; case 0x801: /* VBR */ REG_VBR = REG_DA[(word2 >> 12) & 15]; return; case 0x802: /* CAAR */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { REG_CAAR = REG_DA[(word2 >> 12) & 15]; return; } m68ki_exception_illegal(); return; case 0x803: /* MSP */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* we are in supervisor mode so just check for M flag */ if(!FLAG_M) { REG_MSP = REG_DA[(word2 >> 12) & 15]; return; } REG_SP = REG_DA[(word2 >> 12) & 15]; return; } m68ki_exception_illegal(); return; case 0x804: /* ISP */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(!FLAG_M) { REG_SP = REG_DA[(word2 >> 12) & 15]; return; } REG_ISP = REG_DA[(word2 >> 12) & 15]; return; } m68ki_exception_illegal(); return; case 0x003: /* TC */ if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x004: /* ITT0 */ if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x005: /* ITT1 */ if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x006: /* DTT0 */ if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x007: /* DTT1 */ if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x805: /* MMUSR */ if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x806: /* URP */ if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; case 0x807: /* SRP */ if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { /* TODO */ return; } m68ki_exception_illegal(); return; default: m68ki_exception_illegal(); return; } } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } #endif static void m68k_op_movem_16_re_pd(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = AY; uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { ea -= 2; m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[15-i])); count++; } AY = ea; USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_re_ai(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_AI_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_re_di(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_DI_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_re_ix(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_IX_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_re_aw(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AW_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_re_al(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AL_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_32_re_pd(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = AY; uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { ea -= 4; m68ki_write_16(ea+2, REG_DA[15-i] & 0xFFFF ); m68ki_write_16(ea, (REG_DA[15-i] >> 16) & 0xFFFF ); count++; } AY = ea; USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_re_ai(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_AI_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_32(ea, REG_DA[i]); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_re_di(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_DI_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_32(ea, REG_DA[i]); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_re_ix(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_IX_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_32(ea, REG_DA[i]); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_re_aw(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AW_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_32(ea, REG_DA[i]); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_re_al(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AL_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { m68ki_write_32(ea, REG_DA[i]); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_16_er_pi(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = AY; uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); ea += 2; count++; } AY = ea; USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_er_pcdi(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_PCDI_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_pcrel_16(ea))); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_er_pcix(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_PCIX_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_pcrel_16(ea))); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_er_ai(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_AI_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_er_di(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_DI_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_er_ix(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_IX_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_er_aw(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AW_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_16_er_al(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AL_16(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); ea += 2; count++; } USE_CYCLES(count * CYC_MOVEM_W); } static void m68k_op_movem_32_er_pi(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = AY; uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = m68ki_read_32(ea); ea += 4; count++; } AY = ea; USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_er_pcdi(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_PCDI_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = m68ki_read_pcrel_32(ea); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_er_pcix(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_PCIX_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = m68ki_read_pcrel_32(ea); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_er_ai(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_AI_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = m68ki_read_32(ea); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_er_di(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_DI_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = m68ki_read_32(ea); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_er_ix(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AY_IX_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = m68ki_read_32(ea); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_er_aw(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AW_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = m68ki_read_32(ea); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movem_32_er_al(void) { uint i = 0; uint register_list = OPER_I_16(); uint ea = EA_AL_32(); uint count = 0; for(; i < 16; i++) if(register_list & (1 << i)) { REG_DA[i] = m68ki_read_32(ea); ea += 4; count++; } USE_CYCLES(count * CYC_MOVEM_L); } static void m68k_op_movep_16_re(void) { uint ea = EA_AY_DI_16(); uint src = DX; m68ki_write_8(ea, MASK_OUT_ABOVE_8(src >> 8)); m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src)); } static void m68k_op_movep_32_re(void) { uint ea = EA_AY_DI_32(); uint src = DX; m68ki_write_8(ea, MASK_OUT_ABOVE_8(src >> 24)); m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src >> 16)); m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src >> 8)); m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src)); } static void m68k_op_movep_16_er(void) { uint ea = EA_AY_DI_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | ((m68ki_read_8(ea) << 8) + m68ki_read_8(ea + 2)); } static void m68k_op_movep_32_er(void) { uint ea = EA_AY_DI_32(); DX = (m68ki_read_8(ea) << 24) + (m68ki_read_8(ea + 2) << 16) + (m68ki_read_8(ea + 4) << 8) + m68ki_read_8(ea + 6); } #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_moves_8_ai(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_AI_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_8_pi(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_PI_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_8_pi7(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_A7_PI_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_8_pd(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_PD_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_8_pd7(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_A7_PD_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_8_di(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_DI_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_8_ix(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_IX_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_8_aw(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AW_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_8_al(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AL_8(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_16_ai(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_AI_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_16_pi(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_PI_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_16_pd(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_PD_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_16_di(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_DI_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_16_ix(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_IX_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_16_aw(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AW_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_16_al(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AL_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); return; } if(BIT_F(word2)) /* Memory to address register */ { REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to data register */ REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_32_ai(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_AI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to register */ REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_32_pi(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_PI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to register */ REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_32_pd(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_PD_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to register */ REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_32_di(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_DI_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to register */ REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_32_ix(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AY_IX_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to register */ REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_32_aw(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AW_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to register */ REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } static void m68k_op_moves_32_al(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { if(FLAG_S) { uint word2 = OPER_I_16(); uint ea = EA_AL_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(BIT_B(word2)) /* Register to memory */ { m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } /* Memory to register */ REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) USE_CYCLES(14); return; } m68ki_exception_privilege_violation(); return; } m68ki_exception_illegal(); } #endif static void m68k_op_moveq_32(void) { uint res = DX = MAKE_INT_8(MASK_OUT_ABOVE_8(REG_IR)); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_move16_32(void) { uint16 w2 = OPER_I_16(); int ax = REG_IR & 7; int ay = (w2 >> 12) & 7; m68ki_write_32(REG_A[ay], m68ki_read_32(REG_A[ax])); m68ki_write_32(REG_A[ay]+4, m68ki_read_32(REG_A[ax]+4)); m68ki_write_32(REG_A[ay]+8, m68ki_read_32(REG_A[ax]+8)); m68ki_write_32(REG_A[ay]+12, m68ki_read_32(REG_A[ax]+12)); REG_A[ax] += 16; REG_A[ay] += 16; } static void m68k_op_muls_16_d(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(DY); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_ai(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_AY_AI_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_pi(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_AY_PI_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_pd(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_AY_PD_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_di(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_AY_DI_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_ix(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_AY_IX_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_aw(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_AW_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_al(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_AL_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_pcdi(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_PCDI_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_pcix(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_PCIX_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_muls_16_i(void) { uint* r_dst = &DX; uint src = MAKE_INT_16(OPER_I_16()); uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); uint cyc = getMuls68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_d(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_16(DY); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_ai(void) { uint* r_dst = &DX; uint src = OPER_AY_AI_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_pi(void) { uint* r_dst = &DX; uint src = OPER_AY_PI_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_pd(void) { uint* r_dst = &DX; uint src = OPER_AY_PD_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_di(void) { uint* r_dst = &DX; uint src = OPER_AY_DI_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_ix(void) { uint* r_dst = &DX; uint src = OPER_AY_IX_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_aw(void) { uint* r_dst = &DX; uint src = OPER_AW_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_al(void) { uint* r_dst = &DX; uint src = OPER_AL_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_pcdi(void) { uint* r_dst = &DX; uint src = OPER_PCDI_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_pcix(void) { uint* r_dst = &DX; uint src = OPER_PCIX_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_mulu_16_i(void) { uint* r_dst = &DX; uint src = OPER_I_16(); uint res = src * MASK_OUT_ABOVE_16(*r_dst); uint cyc = getMulu68kCycles(src); USE_CYCLES(cyc); *r_dst = res; FLAG_Z = res; FLAG_N = NFLAG_32(res); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_mull_32_d(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = DY; uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = DY; uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_ai(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_AY_AI_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_AY_AI_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_pi(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_AY_PI_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_AY_PI_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_pd(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_AY_PD_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_AY_PD_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_di(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_AY_DI_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_AY_DI_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_ix(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_AY_IX_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_AY_IX_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_aw(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_AW_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_AW_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_al(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_AL_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_AL_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_pcdi(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_PCDI_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_PCDI_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_pcix(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_PCIX_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_PCIX_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } static void m68k_op_mull_32_i(void) { #if M68K_USE_64_BIT if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint64 src = OPER_I_32(); uint64 dst = REG_D[(word2 >> 12) & 7]; uint64 res; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { res = (sint64)((sint32)src) * (sint64)((sint32)dst); if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = ((sint64)res != (sint32)res)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } res = src * dst; if(!BIT_A(word2)) { FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_N = NFLAG_32(res); FLAG_V = (res > 0xffffffff)<<7; REG_D[(word2 >> 12) & 7] = FLAG_Z; return; } FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); FLAG_N = NFLAG_64(res); FLAG_V = VFLAG_CLEAR; REG_D[word2 & 7] = (res >> 32); REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); return; } m68ki_exception_illegal(); #else if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint word2 = OPER_I_16(); uint src = OPER_I_32(); uint dst = REG_D[(word2 >> 12) & 7]; uint neg = GET_MSB_32(src ^ dst); uint src1; uint src2; uint dst1; uint dst2; uint r1; uint r2; uint r3; uint r4; uint lo; uint hi; FLAG_C = CFLAG_CLEAR; if(BIT_B(word2)) /* signed */ { if(GET_MSB_32(src)) src = (uint)MASK_OUT_ABOVE_32(-(sint)src); if(GET_MSB_32(dst)) dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); } src1 = MASK_OUT_ABOVE_16(src); src2 = src>>16; dst1 = MASK_OUT_ABOVE_16(dst); dst2 = dst>>16; r1 = src1 * dst1; r2 = src1 * dst2; r3 = src2 * dst1; r4 = src2 * dst2; lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); if(BIT_B(word2) && neg) { hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); } if(BIT_A(word2)) { REG_D[word2 & 7] = hi; REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(hi); FLAG_Z = hi | lo; FLAG_V = VFLAG_CLEAR; return; } REG_D[(word2 >> 12) & 7] = lo; FLAG_N = NFLAG_32(lo); FLAG_Z = lo; if(BIT_B(word2)) FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; else FLAG_V = (hi != 0) << 7; return; } m68ki_exception_illegal(); #endif } #endif static void m68k_op_nbcd_8_d(void) { uint* r_dst = &DY; uint dst = *r_dst; uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_ai(void) { uint ea = EA_AY_AI_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_pi(void) { uint ea = EA_AY_PI_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_pi7(void) { uint ea = EA_A7_PI_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_pd(void) { uint ea = EA_AY_PD_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_pd7(void) { uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_di(void) { uint ea = EA_AY_DI_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_ix(void) { uint ea = EA_AY_IX_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_aw(void) { uint ea = EA_AW_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_nbcd_8_al(void) { uint ea = EA_AL_8(); uint dst = m68ki_read_8(ea); uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); if(res != 0x9a) { FLAG_V = ~res; /* Undefined V behavior */ if((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; res = MASK_OUT_ABOVE_8(res); FLAG_V &= res; /* Undefined V behavior part II */ m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); FLAG_Z |= res; FLAG_C = CFLAG_SET; FLAG_X = XFLAG_SET; } else { FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; FLAG_X = XFLAG_CLEAR; } FLAG_N = NFLAG_8(res); /* Undefined N behavior */ } static void m68k_op_neg_8_d(void) { uint* r_dst = &DY; uint res = 0 - MASK_OUT_ABOVE_8(*r_dst); FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = *r_dst & res; FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_neg_8_ai(void) { uint ea = EA_AY_AI_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_8_pi(void) { uint ea = EA_AY_PI_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_8_pi7(void) { uint ea = EA_A7_PI_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_8_pd(void) { uint ea = EA_AY_PD_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_8_pd7(void) { uint ea = EA_A7_PD_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_8_di(void) { uint ea = EA_AY_DI_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_8_ix(void) { uint ea = EA_AY_IX_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_8_aw(void) { uint ea = EA_AW_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_8_al(void) { uint ea = EA_AL_8(); uint src = m68ki_read_8(ea); uint res = 0 - src; FLAG_N = NFLAG_8(res); FLAG_C = FLAG_X = CFLAG_8(res); FLAG_V = src & res; FLAG_Z = MASK_OUT_ABOVE_8(res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_neg_16_d(void) { uint* r_dst = &DY; uint res = 0 - MASK_OUT_ABOVE_16(*r_dst); FLAG_N = NFLAG_16(res); FLAG_C = FLAG_X = CFLAG_16(res); FLAG_V = (*r_dst & res)>>8; FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_neg_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = 0 - src; FLAG_N = NFLAG_16(res); FLAG_C = FLAG_X = CFLAG_16(res); FLAG_V = (src & res)>>8; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_neg_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = 0 - src; FLAG_N = NFLAG_16(res); FLAG_C = FLAG_X = CFLAG_16(res); FLAG_V = (src & res)>>8; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_neg_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = 0 - src; FLAG_N = NFLAG_16(res); FLAG_C = FLAG_X = CFLAG_16(res); FLAG_V = (src & res)>>8; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_neg_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = 0 - src; FLAG_N = NFLAG_16(res); FLAG_C = FLAG_X = CFLAG_16(res); FLAG_V = (src & res)>>8; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_neg_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = 0 - src; FLAG_N = NFLAG_16(res); FLAG_C = FLAG_X = CFLAG_16(res); FLAG_V = (src & res)>>8; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_neg_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = 0 - src; FLAG_N = NFLAG_16(res); FLAG_C = FLAG_X = CFLAG_16(res); FLAG_V = (src & res)>>8; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_neg_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = 0 - src; FLAG_N = NFLAG_16(res); FLAG_C = FLAG_X = CFLAG_16(res); FLAG_V = (src & res)>>8; FLAG_Z = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_neg_32_d(void) { uint* r_dst = &DY; uint res = 0 - *r_dst; FLAG_N = NFLAG_32(res); FLAG_C = FLAG_X = CFLAG_SUB_32(*r_dst, 0, res); FLAG_V = (*r_dst & res)>>24; FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_neg_32_ai(void) { uint ea = EA_AY_AI_32(); uint src = m68ki_read_32(ea); uint res = 0 - src; FLAG_N = NFLAG_32(res); FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_neg_32_pi(void) { uint ea = EA_AY_PI_32(); uint src = m68ki_read_32(ea); uint res = 0 - src; FLAG_N = NFLAG_32(res); FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_neg_32_pd(void) { uint ea = EA_AY_PD_32(); uint src = m68ki_read_32(ea); uint res = 0 - src; FLAG_N = NFLAG_32(res); FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_neg_32_di(void) { uint ea = EA_AY_DI_32(); uint src = m68ki_read_32(ea); uint res = 0 - src; FLAG_N = NFLAG_32(res); FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_neg_32_ix(void) { uint ea = EA_AY_IX_32(); uint src = m68ki_read_32(ea); uint res = 0 - src; FLAG_N = NFLAG_32(res); FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_neg_32_aw(void) { uint ea = EA_AW_32(); uint src = m68ki_read_32(ea); uint res = 0 - src; FLAG_N = NFLAG_32(res); FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_neg_32_al(void) { uint ea = EA_AL_32(); uint src = m68ki_read_32(ea); uint res = 0 - src; FLAG_N = NFLAG_32(res); FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; FLAG_Z = MASK_OUT_ABOVE_32(res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_negx_8_d(void) { uint* r_dst = &DY; uint res = 0 - MASK_OUT_ABOVE_8(*r_dst) - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = *r_dst & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; } static void m68k_op_negx_8_ai(void) { uint ea = EA_AY_AI_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_8_pi(void) { uint ea = EA_AY_PI_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_8_pi7(void) { uint ea = EA_A7_PI_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_8_pd(void) { uint ea = EA_AY_PD_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_8_pd7(void) { uint ea = EA_A7_PD_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_8_di(void) { uint ea = EA_AY_DI_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_8_ix(void) { uint ea = EA_AY_IX_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_8_aw(void) { uint ea = EA_AW_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_8_al(void) { uint ea = EA_AL_8(); uint src = m68ki_read_8(ea); uint res = 0 - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = src & res; res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_negx_16_d(void) { uint* r_dst = &DY; uint res = 0 - MASK_OUT_ABOVE_16(*r_dst) - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = (*r_dst & res)>>8; res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; } static void m68k_op_negx_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = (src & res)>>8; res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_negx_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = (src & res)>>8; res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_negx_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = (src & res)>>8; res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_negx_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = (src & res)>>8; res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_negx_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = (src & res)>>8; res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_negx_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = (src & res)>>8; res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_negx_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = (src & res)>>8; res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_negx_32_d(void) { uint* r_dst = &DY; uint res = 0 - MASK_OUT_ABOVE_32(*r_dst) - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(*r_dst, 0, res); FLAG_V = (*r_dst & res)>>24; res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; *r_dst = res; } static void m68k_op_negx_32_ai(void) { uint ea = EA_AY_AI_32(); uint src = m68ki_read_32(ea); uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_negx_32_pi(void) { uint ea = EA_AY_PI_32(); uint src = m68ki_read_32(ea); uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_negx_32_pd(void) { uint ea = EA_AY_PD_32(); uint src = m68ki_read_32(ea); uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_negx_32_di(void) { uint ea = EA_AY_DI_32(); uint src = m68ki_read_32(ea); uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_negx_32_ix(void) { uint ea = EA_AY_IX_32(); uint src = m68ki_read_32(ea); uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_negx_32_aw(void) { uint ea = EA_AW_32(); uint src = m68ki_read_32(ea); uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_negx_32_al(void) { uint ea = EA_AL_32(); uint src = m68ki_read_32(ea); uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); FLAG_V = (src & res)>>24; res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_nop(void) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ } static void m68k_op_not_8_d(void) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_8(~*r_dst); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_ai(void) { uint ea = EA_AY_AI_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_pi(void) { uint ea = EA_AY_PI_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_pi7(void) { uint ea = EA_A7_PI_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_pd(void) { uint ea = EA_AY_PD_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_pd7(void) { uint ea = EA_A7_PD_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_di(void) { uint ea = EA_AY_DI_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_ix(void) { uint ea = EA_AY_IX_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_aw(void) { uint ea = EA_AW_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_8_al(void) { uint ea = EA_AL_8(); uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_16_d(void) { uint* r_dst = &DY; uint res = MASK_OUT_ABOVE_16(~*r_dst); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_16_ai(void) { uint ea = EA_AY_AI_16(); uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_16_pi(void) { uint ea = EA_AY_PI_16(); uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_16_pd(void) { uint ea = EA_AY_PD_16(); uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_16_di(void) { uint ea = EA_AY_DI_16(); uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_16_ix(void) { uint ea = EA_AY_IX_16(); uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_16_aw(void) { uint ea = EA_AW_16(); uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_16_al(void) { uint ea = EA_AL_16(); uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_32_d(void) { uint* r_dst = &DY; uint res = *r_dst = MASK_OUT_ABOVE_32(~*r_dst); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_32_ai(void) { uint ea = EA_AY_AI_32(); uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_32_pi(void) { uint ea = EA_AY_PI_32(); uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_32_pd(void) { uint ea = EA_AY_PD_32(); uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_32_di(void) { uint ea = EA_AY_DI_32(); uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_32_ix(void) { uint ea = EA_AY_IX_32(); uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_32_aw(void) { uint ea = EA_AW_32(); uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_not_32_al(void) { uint ea = EA_AL_32(); uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_d(void) { uint res = MASK_OUT_ABOVE_8((DX |= MASK_OUT_ABOVE_8(DY))); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_ai(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_AI_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_pi(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_PI_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_pi7(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_A7_PI_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_pd(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_PD_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_pd7(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_A7_PD_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_di(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_DI_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_ix(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_IX_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_aw(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_AW_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_al(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_AL_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_pcdi(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_PCDI_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_pcix(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_PCIX_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_er_i(void) { uint res = MASK_OUT_ABOVE_8((DX |= OPER_I_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_d(void) { uint res = MASK_OUT_ABOVE_16((DX |= MASK_OUT_ABOVE_16(DY))); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_ai(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_AI_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_pi(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_PI_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_pd(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_PD_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_di(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_DI_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_ix(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_IX_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_aw(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_AW_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_al(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_AL_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_pcdi(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_PCDI_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_pcix(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_PCIX_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_er_i(void) { uint res = MASK_OUT_ABOVE_16((DX |= OPER_I_16())); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_d(void) { uint res = DX |= DY; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_ai(void) { uint res = DX |= OPER_AY_AI_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_pi(void) { uint res = DX |= OPER_AY_PI_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_pd(void) { uint res = DX |= OPER_AY_PD_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_di(void) { uint res = DX |= OPER_AY_DI_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_ix(void) { uint res = DX |= OPER_AY_IX_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_aw(void) { uint res = DX |= OPER_AW_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_al(void) { uint res = DX |= OPER_AL_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_pcdi(void) { uint res = DX |= OPER_PCDI_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_pcix(void) { uint res = DX |= OPER_PCIX_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_er_i(void) { uint res = DX |= OPER_I_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_ai(void) { uint ea = EA_AY_AI_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_pi(void) { uint ea = EA_AY_PI_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_pi7(void) { uint ea = EA_A7_PI_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_pd(void) { uint ea = EA_AY_PD_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_pd7(void) { uint ea = EA_A7_PD_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_di(void) { uint ea = EA_AY_DI_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_ix(void) { uint ea = EA_AY_IX_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_aw(void) { uint ea = EA_AW_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_8_re_al(void) { uint ea = EA_AL_8(); uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_re_ai(void) { uint ea = EA_AY_AI_16(); uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_re_pi(void) { uint ea = EA_AY_PI_16(); uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_re_pd(void) { uint ea = EA_AY_PD_16(); uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_re_di(void) { uint ea = EA_AY_DI_16(); uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_re_ix(void) { uint ea = EA_AY_IX_16(); uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_re_aw(void) { uint ea = EA_AW_16(); uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_16_re_al(void) { uint ea = EA_AL_16(); uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_re_ai(void) { uint ea = EA_AY_AI_32(); uint res = DX | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_re_pi(void) { uint ea = EA_AY_PI_32(); uint res = DX | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_re_pd(void) { uint ea = EA_AY_PD_32(); uint res = DX | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_re_di(void) { uint ea = EA_AY_DI_32(); uint res = DX | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_re_ix(void) { uint ea = EA_AY_IX_32(); uint res = DX | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_re_aw(void) { uint ea = EA_AW_32(); uint res = DX | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_or_32_re_al(void) { uint ea = EA_AL_32(); uint res = DX | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_d(void) { uint res = MASK_OUT_ABOVE_8((DY |= OPER_I_8())); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_ai(void) { uint src = OPER_I_8(); uint ea = EA_AY_AI_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_pi(void) { uint src = OPER_I_8(); uint ea = EA_AY_PI_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_pi7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PI_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_pd(void) { uint src = OPER_I_8(); uint ea = EA_AY_PD_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_pd7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PD_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_di(void) { uint src = OPER_I_8(); uint ea = EA_AY_DI_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_ix(void) { uint src = OPER_I_8(); uint ea = EA_AY_IX_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_aw(void) { uint src = OPER_I_8(); uint ea = EA_AW_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_8_al(void) { uint src = OPER_I_8(); uint ea = EA_AL_8(); uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); m68ki_write_8(ea, res); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_d(void) { uint res = MASK_OUT_ABOVE_16(DY |= OPER_I_16()); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_ai(void) { uint src = OPER_I_16(); uint ea = EA_AY_AI_16(); uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_pi(void) { uint src = OPER_I_16(); uint ea = EA_AY_PI_16(); uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_pd(void) { uint src = OPER_I_16(); uint ea = EA_AY_PD_16(); uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_di(void) { uint src = OPER_I_16(); uint ea = EA_AY_DI_16(); uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_ix(void) { uint src = OPER_I_16(); uint ea = EA_AY_IX_16(); uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_aw(void) { uint src = OPER_I_16(); uint ea = EA_AW_16(); uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_al(void) { uint src = OPER_I_16(); uint ea = EA_AL_16(); uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_32_d(void) { uint res = DY |= OPER_I_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_32_ai(void) { uint src = OPER_I_32(); uint ea = EA_AY_AI_32(); uint res = src | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_32_pi(void) { uint src = OPER_I_32(); uint ea = EA_AY_PI_32(); uint res = src | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_32_pd(void) { uint src = OPER_I_32(); uint ea = EA_AY_PD_32(); uint res = src | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_32_di(void) { uint src = OPER_I_32(); uint ea = EA_AY_DI_32(); uint res = src | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_32_ix(void) { uint src = OPER_I_32(); uint ea = EA_AY_IX_32(); uint res = src | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_32_aw(void) { uint src = OPER_I_32(); uint ea = EA_AW_32(); uint res = src | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_32_al(void) { uint src = OPER_I_32(); uint ea = EA_AL_32(); uint res = src | m68ki_read_32(ea); m68ki_write_32(ea, res); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ori_16_toc(void) { m68ki_set_ccr(m68ki_get_ccr() | OPER_I_16()); } static void m68k_op_ori_16_tos(void) { if(FLAG_S) { uint src = OPER_I_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_sr(m68ki_get_sr() | src); return; } m68ki_exception_privilege_violation(); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_pack_16_rr(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Note: DX and DY are reversed in Motorola's docs */ uint src = DY + OPER_I_16(); uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_8(*r_dst) | ((src >> 4) & 0x00f0) | (src & 0x000f); return; } m68ki_exception_illegal(); } static void m68k_op_pack_16_mm_ax7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Note: AX and AY are reversed in Motorola's docs */ uint ea_src = EA_AY_PD_8(); uint src = m68ki_read_8(ea_src); ea_src = EA_AY_PD_8(); src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16(); m68ki_write_8(EA_A7_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f)); return; } m68ki_exception_illegal(); } static void m68k_op_pack_16_mm_ay7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Note: AX and AY are reversed in Motorola's docs */ uint ea_src = EA_A7_PD_8(); uint src = m68ki_read_8(ea_src); ea_src = EA_A7_PD_8(); src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16(); m68ki_write_8(EA_AX_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f)); return; } m68ki_exception_illegal(); } static void m68k_op_pack_16_mm_axy7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint ea_src = EA_A7_PD_8(); uint src = m68ki_read_8(ea_src); ea_src = EA_A7_PD_8(); src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16(); m68ki_write_8(EA_A7_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f)); return; } m68ki_exception_illegal(); } static void m68k_op_pack_16_mm(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Note: AX and AY are reversed in Motorola's docs */ uint ea_src = EA_AY_PD_8(); uint src = m68ki_read_8(ea_src); ea_src = EA_AY_PD_8(); src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16(); m68ki_write_8(EA_AX_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f)); return; } m68ki_exception_illegal(); } #endif static void m68k_op_pea_32_ai(void) { uint ea = EA_AY_AI_32(); m68ki_push_32(ea); } static void m68k_op_pea_32_di(void) { uint ea = EA_AY_DI_32(); m68ki_push_32(ea); } static void m68k_op_pea_32_ix(void) { uint ea = EA_AY_IX_32(); m68ki_push_32(ea); } static void m68k_op_pea_32_aw(void) { uint ea = EA_AW_32(); m68ki_push_32(ea); } static void m68k_op_pea_32_al(void) { uint ea = EA_AL_32(); m68ki_push_32(ea); } static void m68k_op_pea_32_pcdi(void) { uint ea = EA_PCDI_32(); m68ki_push_32(ea); } static void m68k_op_pea_32_pcix(void) { uint ea = EA_PCIX_32(); m68ki_push_32(ea); } #if M68K_EMULATE_040 static void m68k_op_pflush_32(void) { if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) { // Nothing to do, unless address translation cache is emulated return; } m68ki_exception_illegal(); } #endif static void m68k_op_reset(void) { if(FLAG_S) { m68ki_output_reset(); /* auto-disable (see m68kcpu.h) */ USE_CYCLES(CYC_RESET); return; } m68ki_exception_privilege_violation(); } static void m68k_op_ror_8_s(void) { uint* r_dst = &DY; uint orig_shift = (((REG_IR >> 9) - 1) & 7) + 1; uint shift = orig_shift & 7; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = ROR_8(src, shift); if(orig_shift != 0) USE_CYCLES(orig_shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = src << (9-orig_shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = ROR_16(src, shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src << (9-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_32_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint64 src = *r_dst; uint res = ROR_32(src, shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = src << (9-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_8_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; uint shift = orig_shift & 7; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = ROR_8(src, shift); if(orig_shift != 0) { USE_CYCLES(orig_shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_C = src << (8-((shift-1)&7)); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_8(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; uint shift = orig_shift & 15; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = ROR_16(src, shift); if(orig_shift != 0) { USE_CYCLES(orig_shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_C = (src >> ((shift - 1) & 15)) << 8; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_16(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_32_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; uint shift = orig_shift & 31; uint64 src = *r_dst; uint res = ROR_32(src, shift); if(orig_shift != 0) { USE_CYCLES(orig_shift * CYC_SHIFT); *r_dst = res; FLAG_C = (src >> ((shift - 1) & 31)) << 8; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_32(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = ROR_16(src, 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = ROR_16(src, 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = ROR_16(src, 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = ROR_16(src, 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = ROR_16(src, 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = ROR_16(src, 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_ror_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = ROR_16(src, 1); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src << 8; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_8_s(void) { uint* r_dst = &DY; uint orig_shift = (((REG_IR >> 9) - 1) & 7) + 1; uint shift = orig_shift & 7; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = ROL_8(src, shift); if(orig_shift != 0) USE_CYCLES(orig_shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_C = src << orig_shift; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = ROL_16(src, shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src >> (8-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_32_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint64 src = *r_dst; uint res = ROL_32(src, shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_C = src >> (24-shift); FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_8_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; uint shift = orig_shift & 7; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = ROL_8(src, shift); if(orig_shift != 0) { USE_CYCLES(orig_shift * CYC_SHIFT); if(shift != 0) { *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_C = src << shift; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = (src & 1)<<8; FLAG_N = NFLAG_8(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_8(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; uint shift = orig_shift & 15; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = MASK_OUT_ABOVE_16(ROL_16(src, shift)); if(orig_shift != 0) { USE_CYCLES(orig_shift * CYC_SHIFT); if(shift != 0) { *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_C = (src << shift) >> 8; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = (src & 1)<<8; FLAG_N = NFLAG_16(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_16(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_32_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; uint shift = orig_shift & 31; uint64 src = *r_dst; uint res = ROL_32(src, shift); if(orig_shift != 0) { USE_CYCLES(orig_shift * CYC_SHIFT); *r_dst = res; FLAG_C = (src >> ((32 - shift) & 0x1f)) << 8; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = CFLAG_CLEAR; FLAG_N = NFLAG_32(src); FLAG_Z = src; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_rol_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_C = src >> 7; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_8_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = ROR_9(src | (XFLAG_AS_1() << 8), shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); FLAG_C = FLAG_X = res; res = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_16_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = ROR_17(src | (XFLAG_AS_1() << 16), shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_32_s(void) { #if M68K_USE_64_BIT uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint64 src = *r_dst; uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); res = ROR_33_64(res, shift); FLAG_C = FLAG_X = res >> 24; res = MASK_OUT_ABOVE_32(res); *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; #else uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = *r_dst; uint res = MASK_OUT_ABOVE_32((ROR_33(src, shift) & ~(1 << (32 - shift))) | (XFLAG_AS_1() << (32 - shift))); uint new_x_flag = src & (1 << (shift - 1)); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = res; FLAG_C = FLAG_X = (new_x_flag != 0)<<8; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; #endif } static void m68k_op_roxr_8_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; if(orig_shift != 0) { uint shift = orig_shift % 9; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = ROR_9(src | (XFLAG_AS_1() << 8), shift); USE_CYCLES(orig_shift * CYC_SHIFT); FLAG_C = FLAG_X = res; res = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = FLAG_X; FLAG_N = NFLAG_8(*r_dst); FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_16_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; if(orig_shift != 0) { uint shift = orig_shift % 17; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = ROR_17(src | (XFLAG_AS_1() << 16), shift); USE_CYCLES(orig_shift * CYC_SHIFT); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = FLAG_X; FLAG_N = NFLAG_16(*r_dst); FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_32_r(void) { #if M68K_USE_64_BIT uint* r_dst = &DY; uint orig_shift = DX & 0x3f; if(orig_shift != 0) { uint shift = orig_shift % 33; uint64 src = *r_dst; uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); res = ROR_33_64(res, shift); USE_CYCLES(orig_shift * CYC_SHIFT); FLAG_C = FLAG_X = res >> 24; res = MASK_OUT_ABOVE_32(res); *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = FLAG_X; FLAG_N = NFLAG_32(*r_dst); FLAG_Z = *r_dst; FLAG_V = VFLAG_CLEAR; #else uint* r_dst = &DY; uint orig_shift = DX & 0x3f; uint shift = orig_shift % 33; uint src = *r_dst; uint res = MASK_OUT_ABOVE_32((ROR_33(src, shift) & ~(1 << (32 - shift))) | (XFLAG_AS_1() << (32 - shift))); uint new_x_flag = src & (1 << (shift - 1)); if(orig_shift != 0) USE_CYCLES(orig_shift * CYC_SHIFT); if(shift != 0) { *r_dst = res; FLAG_X = (new_x_flag != 0)<<8; } else res = src; FLAG_C = FLAG_X; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; #endif } static void m68k_op_roxr_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxr_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_8_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = ROL_9(src | (XFLAG_AS_1() << 8), shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); FLAG_C = FLAG_X = res; res = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_16_s(void) { uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = ROL_17(src | (XFLAG_AS_1() << 16), shift); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_32_s(void) { #if M68K_USE_64_BIT uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint64 src = *r_dst; uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); res = ROL_33_64(res, shift); FLAG_C = FLAG_X = res >> 24; res = MASK_OUT_ABOVE_32(res); *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; #else uint* r_dst = &DY; uint shift = (((REG_IR >> 9) - 1) & 7) + 1; uint src = *r_dst; uint res = MASK_OUT_ABOVE_32((ROL_33(src, shift) & ~(1 << (shift - 1))) | (XFLAG_AS_1() << (shift - 1))); uint new_x_flag = src & (1 << (32 - shift)); if(shift != 0) USE_CYCLES(shift * CYC_SHIFT); *r_dst = res; FLAG_C = FLAG_X = (new_x_flag != 0)<<8; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; #endif } static void m68k_op_roxl_8_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; if(orig_shift != 0) { uint shift = orig_shift % 9; uint src = MASK_OUT_ABOVE_8(*r_dst); uint res = ROL_9(src | (XFLAG_AS_1() << 8), shift); USE_CYCLES(orig_shift * CYC_SHIFT); FLAG_C = FLAG_X = res; res = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = FLAG_X; FLAG_N = NFLAG_8(*r_dst); FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_16_r(void) { uint* r_dst = &DY; uint orig_shift = DX & 0x3f; if(orig_shift != 0) { uint shift = orig_shift % 17; uint src = MASK_OUT_ABOVE_16(*r_dst); uint res = ROL_17(src | (XFLAG_AS_1() << 16), shift); USE_CYCLES(orig_shift * CYC_SHIFT); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = FLAG_X; FLAG_N = NFLAG_16(*r_dst); FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_32_r(void) { #if M68K_USE_64_BIT uint* r_dst = &DY; uint orig_shift = DX & 0x3f; if(orig_shift != 0) { uint shift = orig_shift % 33; uint64 src = *r_dst; uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); res = ROL_33_64(res, shift); USE_CYCLES(orig_shift * CYC_SHIFT); FLAG_C = FLAG_X = res >> 24; res = MASK_OUT_ABOVE_32(res); *r_dst = res; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; return; } FLAG_C = FLAG_X; FLAG_N = NFLAG_32(*r_dst); FLAG_Z = *r_dst; FLAG_V = VFLAG_CLEAR; #else uint* r_dst = &DY; uint orig_shift = DX & 0x3f; uint shift = orig_shift % 33; uint src = *r_dst; uint res = MASK_OUT_ABOVE_32((ROL_33(src, shift) & ~(1 << (shift - 1))) | (XFLAG_AS_1() << (shift - 1))); uint new_x_flag = src & (1 << (32 - shift)); if(orig_shift != 0) USE_CYCLES(orig_shift * CYC_SHIFT); if(shift != 0) { *r_dst = res; FLAG_X = (new_x_flag != 0)<<8; } else res = src; FLAG_C = FLAG_X; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; #endif } static void m68k_op_roxl_16_ai(void) { uint ea = EA_AY_AI_16(); uint src = m68ki_read_16(ea); uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_16_pi(void) { uint ea = EA_AY_PI_16(); uint src = m68ki_read_16(ea); uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_16_pd(void) { uint ea = EA_AY_PD_16(); uint src = m68ki_read_16(ea); uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_16_di(void) { uint ea = EA_AY_DI_16(); uint src = m68ki_read_16(ea); uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_16_ix(void) { uint ea = EA_AY_IX_16(); uint src = m68ki_read_16(ea); uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_16_aw(void) { uint ea = EA_AW_16(); uint src = m68ki_read_16(ea); uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } static void m68k_op_roxl_16_al(void) { uint ea = EA_AL_16(); uint src = m68ki_read_16(ea); uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); FLAG_C = FLAG_X = res >> 8; res = MASK_OUT_ABOVE_16(res); m68ki_write_16(ea, res); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; } #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_rtd_32(void) { if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) { uint new_pc = m68ki_pull_32(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16())); m68ki_jump(new_pc); return; } m68ki_exception_illegal(); } #endif static void m68k_op_rte_32(void) { if(FLAG_S) { uint new_sr; uint new_pc; uint format_word; m68ki_rte_callback(); /* auto-disable (see m68kcpu.h) */ m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ if(CPU_TYPE_IS_000(CPU_TYPE)) { new_sr = m68ki_pull_16(); new_pc = m68ki_pull_32(); m68ki_jump(new_pc); m68ki_set_sr(new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; return; } if(CPU_TYPE_IS_010(CPU_TYPE)) { format_word = m68ki_read_16(REG_A[7]+6) >> 12; if(format_word == 0) { new_sr = m68ki_pull_16(); new_pc = m68ki_pull_32(); m68ki_fake_pull_16(); /* format word */ m68ki_jump(new_pc); m68ki_set_sr(new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; return; } CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; /* Not handling bus fault (9) */ m68ki_exception_format_error(); return; } /* Otherwise it's 020 */ rte_loop: format_word = m68ki_read_16(REG_A[7]+6) >> 12; switch(format_word) { case 0: /* Normal */ new_sr = m68ki_pull_16(); new_pc = m68ki_pull_32(); m68ki_fake_pull_16(); /* format word */ m68ki_jump(new_pc); m68ki_set_sr(new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; return; case 1: /* Throwaway */ new_sr = m68ki_pull_16(); m68ki_fake_pull_32(); /* program counter */ m68ki_fake_pull_16(); /* format word */ m68ki_set_sr_noint(new_sr); goto rte_loop; case 2: /* Trap */ new_sr = m68ki_pull_16(); new_pc = m68ki_pull_32(); m68ki_fake_pull_16(); /* format word */ m68ki_fake_pull_32(); /* address */ m68ki_jump(new_pc); m68ki_set_sr(new_sr); CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; return; } /* Not handling long or short bus fault */ CPU_INSTR_MODE = INSTRUCTION_YES; CPU_RUN_MODE = RUN_MODE_NORMAL; m68ki_exception_format_error(); return; } m68ki_exception_privilege_violation(); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_rtm_32(void) { if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); return; } m68ki_exception_illegal(); } #endif static void m68k_op_rtr_32(void) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_set_ccr(m68ki_pull_16()); m68ki_jump(m68ki_pull_32()); } static void m68k_op_rts_32(void) { m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ m68ki_jump(m68ki_pull_32()); } static void m68k_op_sbcd_8_rr(void) { uint* r_dst = &DX; uint src = DY; uint dst = *r_dst; uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); // FLAG_V = ~res; /* Undefined V behavior */ FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to assume cleared. */ if(res > 9) res -= 6; res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); if(res > 0x99) { res += 0xa0; FLAG_X = FLAG_C = CFLAG_SET; FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ } else FLAG_N = FLAG_X = FLAG_C = 0; res = MASK_OUT_ABOVE_8(res); // FLAG_V &= res; /* Undefined V behavior part II */ // FLAG_N = NFLAG_8(res); /* Undefined N behavior */ FLAG_Z |= res; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; } static void m68k_op_sbcd_8_mm_ax7(void) { uint src = OPER_AY_PD_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); // FLAG_V = ~res; /* Undefined V behavior */ FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ if(res > 9) res -= 6; res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); if(res > 0x99) { res += 0xa0; FLAG_X = FLAG_C = CFLAG_SET; FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ } else FLAG_N = FLAG_X = FLAG_C = 0; res = MASK_OUT_ABOVE_8(res); // FLAG_V &= res; /* Undefined V behavior part II */ // FLAG_N = NFLAG_8(res); /* Undefined N behavior */ FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_sbcd_8_mm_ay7(void) { uint src = OPER_A7_PD_8(); uint ea = EA_AX_PD_8(); uint dst = m68ki_read_8(ea); uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); // FLAG_V = ~res; /* Undefined V behavior */ FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ if(res > 9) res -= 6; res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); if(res > 0x99) { res += 0xa0; FLAG_X = FLAG_C = CFLAG_SET; FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ } else FLAG_N = FLAG_X = FLAG_C = 0; res = MASK_OUT_ABOVE_8(res); // FLAG_V &= res; /* Undefined V behavior part II */ // FLAG_N = NFLAG_8(res); /* Undefined N behavior */ FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_sbcd_8_mm_axy7(void) { uint src = OPER_A7_PD_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); // FLAG_V = ~res; /* Undefined V behavior */ FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ if(res > 9) res -= 6; res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); if(res > 0x99) { res += 0xa0; FLAG_X = FLAG_C = CFLAG_SET; FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ } else FLAG_N = FLAG_X = FLAG_C = 0; res = MASK_OUT_ABOVE_8(res); // FLAG_V &= res; /* Undefined V behavior part II */ // FLAG_N = NFLAG_8(res); /* Undefined N behavior */ FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_sbcd_8_mm(void) { uint src = OPER_AY_PD_8(); uint ea = EA_AX_PD_8(); uint dst = m68ki_read_8(ea); uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); // FLAG_V = ~res; /* Undefined V behavior */ FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ if(res > 9) res -= 6; res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); if(res > 0x99) { res += 0xa0; FLAG_X = FLAG_C = CFLAG_SET; FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ } else FLAG_N = FLAG_X = FLAG_C = 0; res = MASK_OUT_ABOVE_8(res); // FLAG_V &= res; /* Undefined V behavior part II */ // FLAG_N = NFLAG_8(res); /* Undefined N behavior */ FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_st_8_d(void) { DY |= 0xff; } static void m68k_op_st_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), 0xff); } static void m68k_op_st_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), 0xff); } static void m68k_op_st_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), 0xff); } static void m68k_op_st_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), 0xff); } static void m68k_op_st_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), 0xff); } static void m68k_op_st_8_di(void) { m68ki_write_8(EA_AY_DI_8(), 0xff); } static void m68k_op_st_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), 0xff); } static void m68k_op_st_8_aw(void) { m68ki_write_8(EA_AW_8(), 0xff); } static void m68k_op_st_8_al(void) { m68ki_write_8(EA_AL_8(), 0xff); } static void m68k_op_sf_8_d(void) { DY &= 0xffffff00; } static void m68k_op_sf_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), 0); } static void m68k_op_sf_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), 0); } static void m68k_op_sf_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), 0); } static void m68k_op_sf_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), 0); } static void m68k_op_sf_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), 0); } static void m68k_op_sf_8_di(void) { m68ki_write_8(EA_AY_DI_8(), 0); } static void m68k_op_sf_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), 0); } static void m68k_op_sf_8_aw(void) { m68ki_write_8(EA_AW_8(), 0); } static void m68k_op_sf_8_al(void) { m68ki_write_8(EA_AL_8(), 0); } static void m68k_op_shi_8_d(void) { if(COND_HI()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_sls_8_d(void) { if(COND_LS()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_scc_8_d(void) { if(COND_CC()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_scs_8_d(void) { if(COND_CS()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_sne_8_d(void) { if(COND_NE()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_seq_8_d(void) { if(COND_EQ()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_svc_8_d(void) { if(COND_VC()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_svs_8_d(void) { if(COND_VS()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_spl_8_d(void) { if(COND_PL()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_smi_8_d(void) { if(COND_MI()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_sge_8_d(void) { if(COND_GE()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_slt_8_d(void) { if(COND_LT()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_sgt_8_d(void) { if(COND_GT()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_sle_8_d(void) { if(COND_LE()) { DY |= 0xff; USE_CYCLES(CYC_SCC_R_TRUE); return; } DY &= 0xffffff00; } static void m68k_op_shi_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_HI() ? 0xff : 0); } static void m68k_op_shi_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_HI() ? 0xff : 0); } static void m68k_op_shi_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_HI() ? 0xff : 0); } static void m68k_op_shi_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_HI() ? 0xff : 0); } static void m68k_op_shi_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_HI() ? 0xff : 0); } static void m68k_op_shi_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_HI() ? 0xff : 0); } static void m68k_op_shi_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_HI() ? 0xff : 0); } static void m68k_op_shi_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_HI() ? 0xff : 0); } static void m68k_op_shi_8_al(void) { m68ki_write_8(EA_AL_8(), COND_HI() ? 0xff : 0); } static void m68k_op_sls_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_LS() ? 0xff : 0); } static void m68k_op_sls_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_LS() ? 0xff : 0); } static void m68k_op_sls_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_LS() ? 0xff : 0); } static void m68k_op_sls_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_LS() ? 0xff : 0); } static void m68k_op_sls_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_LS() ? 0xff : 0); } static void m68k_op_sls_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_LS() ? 0xff : 0); } static void m68k_op_sls_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_LS() ? 0xff : 0); } static void m68k_op_sls_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_LS() ? 0xff : 0); } static void m68k_op_sls_8_al(void) { m68ki_write_8(EA_AL_8(), COND_LS() ? 0xff : 0); } static void m68k_op_scc_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scc_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scc_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scc_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scc_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scc_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scc_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scc_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scc_8_al(void) { m68ki_write_8(EA_AL_8(), COND_CC() ? 0xff : 0); } static void m68k_op_scs_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_CS() ? 0xff : 0); } static void m68k_op_scs_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_CS() ? 0xff : 0); } static void m68k_op_scs_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_CS() ? 0xff : 0); } static void m68k_op_scs_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_CS() ? 0xff : 0); } static void m68k_op_scs_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_CS() ? 0xff : 0); } static void m68k_op_scs_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_CS() ? 0xff : 0); } static void m68k_op_scs_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_CS() ? 0xff : 0); } static void m68k_op_scs_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_CS() ? 0xff : 0); } static void m68k_op_scs_8_al(void) { m68ki_write_8(EA_AL_8(), COND_CS() ? 0xff : 0); } static void m68k_op_sne_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_NE() ? 0xff : 0); } static void m68k_op_sne_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_NE() ? 0xff : 0); } static void m68k_op_sne_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_NE() ? 0xff : 0); } static void m68k_op_sne_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_NE() ? 0xff : 0); } static void m68k_op_sne_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_NE() ? 0xff : 0); } static void m68k_op_sne_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_NE() ? 0xff : 0); } static void m68k_op_sne_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_NE() ? 0xff : 0); } static void m68k_op_sne_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_NE() ? 0xff : 0); } static void m68k_op_sne_8_al(void) { m68ki_write_8(EA_AL_8(), COND_NE() ? 0xff : 0); } static void m68k_op_seq_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_seq_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_seq_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_seq_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_seq_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_seq_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_seq_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_seq_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_seq_8_al(void) { m68ki_write_8(EA_AL_8(), COND_EQ() ? 0xff : 0); } static void m68k_op_svc_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svc_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svc_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svc_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svc_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svc_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svc_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svc_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svc_8_al(void) { m68ki_write_8(EA_AL_8(), COND_VC() ? 0xff : 0); } static void m68k_op_svs_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_VS() ? 0xff : 0); } static void m68k_op_svs_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_VS() ? 0xff : 0); } static void m68k_op_svs_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_VS() ? 0xff : 0); } static void m68k_op_svs_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_VS() ? 0xff : 0); } static void m68k_op_svs_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_VS() ? 0xff : 0); } static void m68k_op_svs_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_VS() ? 0xff : 0); } static void m68k_op_svs_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_VS() ? 0xff : 0); } static void m68k_op_svs_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_VS() ? 0xff : 0); } static void m68k_op_svs_8_al(void) { m68ki_write_8(EA_AL_8(), COND_VS() ? 0xff : 0); } static void m68k_op_spl_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_PL() ? 0xff : 0); } static void m68k_op_spl_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_PL() ? 0xff : 0); } static void m68k_op_spl_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_PL() ? 0xff : 0); } static void m68k_op_spl_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_PL() ? 0xff : 0); } static void m68k_op_spl_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_PL() ? 0xff : 0); } static void m68k_op_spl_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_PL() ? 0xff : 0); } static void m68k_op_spl_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_PL() ? 0xff : 0); } static void m68k_op_spl_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_PL() ? 0xff : 0); } static void m68k_op_spl_8_al(void) { m68ki_write_8(EA_AL_8(), COND_PL() ? 0xff : 0); } static void m68k_op_smi_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_MI() ? 0xff : 0); } static void m68k_op_smi_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_MI() ? 0xff : 0); } static void m68k_op_smi_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_MI() ? 0xff : 0); } static void m68k_op_smi_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_MI() ? 0xff : 0); } static void m68k_op_smi_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_MI() ? 0xff : 0); } static void m68k_op_smi_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_MI() ? 0xff : 0); } static void m68k_op_smi_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_MI() ? 0xff : 0); } static void m68k_op_smi_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_MI() ? 0xff : 0); } static void m68k_op_smi_8_al(void) { m68ki_write_8(EA_AL_8(), COND_MI() ? 0xff : 0); } static void m68k_op_sge_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_GE() ? 0xff : 0); } static void m68k_op_sge_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_GE() ? 0xff : 0); } static void m68k_op_sge_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_GE() ? 0xff : 0); } static void m68k_op_sge_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_GE() ? 0xff : 0); } static void m68k_op_sge_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_GE() ? 0xff : 0); } static void m68k_op_sge_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_GE() ? 0xff : 0); } static void m68k_op_sge_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_GE() ? 0xff : 0); } static void m68k_op_sge_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_GE() ? 0xff : 0); } static void m68k_op_sge_8_al(void) { m68ki_write_8(EA_AL_8(), COND_GE() ? 0xff : 0); } static void m68k_op_slt_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_LT() ? 0xff : 0); } static void m68k_op_slt_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_LT() ? 0xff : 0); } static void m68k_op_slt_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_LT() ? 0xff : 0); } static void m68k_op_slt_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_LT() ? 0xff : 0); } static void m68k_op_slt_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_LT() ? 0xff : 0); } static void m68k_op_slt_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_LT() ? 0xff : 0); } static void m68k_op_slt_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_LT() ? 0xff : 0); } static void m68k_op_slt_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_LT() ? 0xff : 0); } static void m68k_op_slt_8_al(void) { m68ki_write_8(EA_AL_8(), COND_LT() ? 0xff : 0); } static void m68k_op_sgt_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sgt_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sgt_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sgt_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sgt_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sgt_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sgt_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sgt_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sgt_8_al(void) { m68ki_write_8(EA_AL_8(), COND_GT() ? 0xff : 0); } static void m68k_op_sle_8_ai(void) { m68ki_write_8(EA_AY_AI_8(), COND_LE() ? 0xff : 0); } static void m68k_op_sle_8_pi(void) { m68ki_write_8(EA_AY_PI_8(), COND_LE() ? 0xff : 0); } static void m68k_op_sle_8_pi7(void) { m68ki_write_8(EA_A7_PI_8(), COND_LE() ? 0xff : 0); } static void m68k_op_sle_8_pd(void) { m68ki_write_8(EA_AY_PD_8(), COND_LE() ? 0xff : 0); } static void m68k_op_sle_8_pd7(void) { m68ki_write_8(EA_A7_PD_8(), COND_LE() ? 0xff : 0); } static void m68k_op_sle_8_di(void) { m68ki_write_8(EA_AY_DI_8(), COND_LE() ? 0xff : 0); } static void m68k_op_sle_8_ix(void) { m68ki_write_8(EA_AY_IX_8(), COND_LE() ? 0xff : 0); } static void m68k_op_sle_8_aw(void) { m68ki_write_8(EA_AW_8(), COND_LE() ? 0xff : 0); } static void m68k_op_sle_8_al(void) { m68ki_write_8(EA_AL_8(), COND_LE() ? 0xff : 0); } static void m68k_op_stop(void) { if(FLAG_S) { uint new_sr = OPER_I_16(); m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ CPU_STOPPED |= STOP_LEVEL_STOP; m68ki_set_sr(new_sr); //m68ki_remaining_cycles = 0; return; } m68ki_exception_privilege_violation(); } static void m68k_op_sub_8_er_d(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_8(DY); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_ai(void) { uint* r_dst = &DX; uint src = OPER_AY_AI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_pi(void) { uint* r_dst = &DX; uint src = OPER_AY_PI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_pi7(void) { uint* r_dst = &DX; uint src = OPER_A7_PI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_pd(void) { uint* r_dst = &DX; uint src = OPER_AY_PD_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_pd7(void) { uint* r_dst = &DX; uint src = OPER_A7_PD_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_di(void) { uint* r_dst = &DX; uint src = OPER_AY_DI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_ix(void) { uint* r_dst = &DX; uint src = OPER_AY_IX_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_aw(void) { uint* r_dst = &DX; uint src = OPER_AW_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_al(void) { uint* r_dst = &DX; uint src = OPER_AL_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_pcdi(void) { uint* r_dst = &DX; uint src = OPER_PCDI_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_pcix(void) { uint* r_dst = &DX; uint src = OPER_PCIX_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_8_er_i(void) { uint* r_dst = &DX; uint src = OPER_I_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_8(res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_d(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_16(DY); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_a(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_16(AY); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_ai(void) { uint* r_dst = &DX; uint src = OPER_AY_AI_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_pi(void) { uint* r_dst = &DX; uint src = OPER_AY_PI_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_pd(void) { uint* r_dst = &DX; uint src = OPER_AY_PD_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_di(void) { uint* r_dst = &DX; uint src = OPER_AY_DI_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_ix(void) { uint* r_dst = &DX; uint src = OPER_AY_IX_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_aw(void) { uint* r_dst = &DX; uint src = OPER_AW_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_al(void) { uint* r_dst = &DX; uint src = OPER_AL_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_pcdi(void) { uint* r_dst = &DX; uint src = OPER_PCDI_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_pcix(void) { uint* r_dst = &DX; uint src = OPER_PCIX_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_16_er_i(void) { uint* r_dst = &DX; uint src = OPER_I_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_16(res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_sub_32_er_d(void) { uint* r_dst = &DX; uint src = DY; uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_a(void) { uint* r_dst = &DX; uint src = AY; uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_ai(void) { uint* r_dst = &DX; uint src = OPER_AY_AI_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_pi(void) { uint* r_dst = &DX; uint src = OPER_AY_PI_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_pd(void) { uint* r_dst = &DX; uint src = OPER_AY_PD_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_di(void) { uint* r_dst = &DX; uint src = OPER_AY_DI_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_ix(void) { uint* r_dst = &DX; uint src = OPER_AY_IX_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_aw(void) { uint* r_dst = &DX; uint src = OPER_AW_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_al(void) { uint* r_dst = &DX; uint src = OPER_AL_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_pcdi(void) { uint* r_dst = &DX; uint src = OPER_PCDI_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_pcix(void) { uint* r_dst = &DX; uint src = OPER_PCIX_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_32_er_i(void) { uint* r_dst = &DX; uint src = OPER_I_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); FLAG_Z = MASK_OUT_ABOVE_32(res); *r_dst = FLAG_Z; } static void m68k_op_sub_8_re_ai(void) { uint ea = EA_AY_AI_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_8_re_pi(void) { uint ea = EA_AY_PI_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_8_re_pi7(void) { uint ea = EA_A7_PI_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_8_re_pd(void) { uint ea = EA_AY_PD_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_8_re_pd7(void) { uint ea = EA_A7_PD_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_8_re_di(void) { uint ea = EA_AY_DI_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_8_re_ix(void) { uint ea = EA_AY_IX_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_8_re_aw(void) { uint ea = EA_AW_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_8_re_al(void) { uint ea = EA_AL_8(); uint src = MASK_OUT_ABOVE_8(DX); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_sub_16_re_ai(void) { uint ea = EA_AY_AI_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_sub_16_re_pi(void) { uint ea = EA_AY_PI_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_sub_16_re_pd(void) { uint ea = EA_AY_PD_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_sub_16_re_di(void) { uint ea = EA_AY_DI_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_sub_16_re_ix(void) { uint ea = EA_AY_IX_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_sub_16_re_aw(void) { uint ea = EA_AW_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_sub_16_re_al(void) { uint ea = EA_AL_16(); uint src = MASK_OUT_ABOVE_16(DX); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_sub_32_re_ai(void) { uint ea = EA_AY_AI_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_sub_32_re_pi(void) { uint ea = EA_AY_PI_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_sub_32_re_pd(void) { uint ea = EA_AY_PD_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_sub_32_re_di(void) { uint ea = EA_AY_DI_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_sub_32_re_ix(void) { uint ea = EA_AY_IX_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_sub_32_re_aw(void) { uint ea = EA_AW_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_sub_32_re_al(void) { uint ea = EA_AL_32(); uint src = DX; uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_suba_16_d(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(DY)); } static void m68k_op_suba_16_a(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(AY)); } static void m68k_op_suba_16_ai(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_AI_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_pi(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_PI_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_pd(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_PD_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_di(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_DI_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_ix(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AY_IX_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_aw(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AW_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_al(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_AL_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_pcdi(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_PCDI_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_pcix(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_PCIX_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_16_i(void) { uint* r_dst = &AX; uint src = MAKE_INT_16(OPER_I_16()); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_d(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(*r_dst - DY); } static void m68k_op_suba_32_a(void) { uint* r_dst = &AX; *r_dst = MASK_OUT_ABOVE_32(*r_dst - AY); } static void m68k_op_suba_32_ai(void) { uint* r_dst = &AX; uint src = OPER_AY_AI_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_pi(void) { uint* r_dst = &AX; uint src = OPER_AY_PI_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_pd(void) { uint* r_dst = &AX; uint src = OPER_AY_PD_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_di(void) { uint* r_dst = &AX; uint src = OPER_AY_DI_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_ix(void) { uint* r_dst = &AX; uint src = OPER_AY_IX_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_aw(void) { uint* r_dst = &AX; uint src = OPER_AW_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_al(void) { uint* r_dst = &AX; uint src = OPER_AL_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_pcdi(void) { uint* r_dst = &AX; uint src = OPER_PCDI_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_pcix(void) { uint* r_dst = &AX; uint src = OPER_PCIX_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_suba_32_i(void) { uint* r_dst = &AX; uint src = OPER_I_32(); *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); } static void m68k_op_subi_8_d(void) { uint* r_dst = &DY; uint src = OPER_I_8(); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_subi_8_ai(void) { uint src = OPER_I_8(); uint ea = EA_AY_AI_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_8_pi(void) { uint src = OPER_I_8(); uint ea = EA_AY_PI_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_8_pi7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PI_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_8_pd(void) { uint src = OPER_I_8(); uint ea = EA_AY_PD_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_8_pd7(void) { uint src = OPER_I_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_8_di(void) { uint src = OPER_I_8(); uint ea = EA_AY_DI_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_8_ix(void) { uint src = OPER_I_8(); uint ea = EA_AY_IX_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_8_aw(void) { uint src = OPER_I_8(); uint ea = EA_AW_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_8_al(void) { uint src = OPER_I_8(); uint ea = EA_AL_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subi_16_d(void) { uint* r_dst = &DY; uint src = OPER_I_16(); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_subi_16_ai(void) { uint src = OPER_I_16(); uint ea = EA_AY_AI_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subi_16_pi(void) { uint src = OPER_I_16(); uint ea = EA_AY_PI_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subi_16_pd(void) { uint src = OPER_I_16(); uint ea = EA_AY_PD_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subi_16_di(void) { uint src = OPER_I_16(); uint ea = EA_AY_DI_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subi_16_ix(void) { uint src = OPER_I_16(); uint ea = EA_AY_IX_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subi_16_aw(void) { uint src = OPER_I_16(); uint ea = EA_AW_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subi_16_al(void) { uint src = OPER_I_16(); uint ea = EA_AL_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subi_32_d(void) { uint* r_dst = &DY; uint src = OPER_I_32(); uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); *r_dst = FLAG_Z; } static void m68k_op_subi_32_ai(void) { uint src = OPER_I_32(); uint ea = EA_AY_AI_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subi_32_pi(void) { uint src = OPER_I_32(); uint ea = EA_AY_PI_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subi_32_pd(void) { uint src = OPER_I_32(); uint ea = EA_AY_PD_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subi_32_di(void) { uint src = OPER_I_32(); uint ea = EA_AY_DI_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subi_32_ix(void) { uint src = OPER_I_32(); uint ea = EA_AY_IX_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subi_32_aw(void) { uint src = OPER_I_32(); uint ea = EA_AW_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subi_32_al(void) { uint src = OPER_I_32(); uint ea = EA_AL_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subq_8_d(void) { uint* r_dst = &DY; uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; } static void m68k_op_subq_8_ai(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_AI_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_8_pi(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PI_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_8_pi7(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_A7_PI_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_8_pd(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PD_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_8_pd7(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_8_di(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_DI_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_8_ix(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_IX_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_8_aw(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AW_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_8_al(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AL_8(); uint dst = m68ki_read_8(ea); uint res = dst - src; FLAG_N = NFLAG_8(res); FLAG_Z = MASK_OUT_ABOVE_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); m68ki_write_8(ea, FLAG_Z); } static void m68k_op_subq_16_d(void) { uint* r_dst = &DY; uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; } static void m68k_op_subq_16_a(void) { uint* r_dst = &AY; *r_dst = MASK_OUT_ABOVE_32(*r_dst - ((((REG_IR >> 9) - 1) & 7) + 1)); } static void m68k_op_subq_16_ai(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_AI_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subq_16_pi(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PI_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subq_16_pd(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PD_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subq_16_di(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_DI_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subq_16_ix(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_IX_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subq_16_aw(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AW_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subq_16_al(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AL_16(); uint dst = m68ki_read_16(ea); uint res = dst - src; FLAG_N = NFLAG_16(res); FLAG_Z = MASK_OUT_ABOVE_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); m68ki_write_16(ea, FLAG_Z); } static void m68k_op_subq_32_d(void) { uint* r_dst = &DY; uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint dst = *r_dst; uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); *r_dst = FLAG_Z; } static void m68k_op_subq_32_a(void) { uint* r_dst = &AY; *r_dst = MASK_OUT_ABOVE_32(*r_dst - ((((REG_IR >> 9) - 1) & 7) + 1)); } static void m68k_op_subq_32_ai(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_AI_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subq_32_pi(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PI_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subq_32_pd(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_PD_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subq_32_di(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_DI_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subq_32_ix(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AY_IX_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subq_32_aw(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AW_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subq_32_al(void) { uint src = (((REG_IR >> 9) - 1) & 7) + 1; uint ea = EA_AL_32(); uint dst = m68ki_read_32(ea); uint res = dst - src; FLAG_N = NFLAG_32(res); FLAG_Z = MASK_OUT_ABOVE_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); m68ki_write_32(ea, FLAG_Z); } static void m68k_op_subx_8_rr(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_8(DY); uint dst = MASK_OUT_ABOVE_8(*r_dst); uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; } static void m68k_op_subx_16_rr(void) { uint* r_dst = &DX; uint src = MASK_OUT_ABOVE_16(DY); uint dst = MASK_OUT_ABOVE_16(*r_dst); uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; } static void m68k_op_subx_32_rr(void) { uint* r_dst = &DX; uint src = DY; uint dst = *r_dst; uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; *r_dst = res; } static void m68k_op_subx_8_mm_ax7(void) { uint src = OPER_AY_PD_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_subx_8_mm_ay7(void) { uint src = OPER_A7_PD_8(); uint ea = EA_AX_PD_8(); uint dst = m68ki_read_8(ea); uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_subx_8_mm_axy7(void) { uint src = OPER_A7_PD_8(); uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_subx_8_mm(void) { uint src = OPER_AY_PD_8(); uint ea = EA_AX_PD_8(); uint dst = m68ki_read_8(ea); uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_8(res); FLAG_X = FLAG_C = CFLAG_8(res); FLAG_V = VFLAG_SUB_8(src, dst, res); res = MASK_OUT_ABOVE_8(res); FLAG_Z |= res; m68ki_write_8(ea, res); } static void m68k_op_subx_16_mm(void) { uint src = OPER_AY_PD_16(); uint ea = EA_AX_PD_16(); uint dst = m68ki_read_16(ea); uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_16(res); FLAG_X = FLAG_C = CFLAG_16(res); FLAG_V = VFLAG_SUB_16(src, dst, res); res = MASK_OUT_ABOVE_16(res); FLAG_Z |= res; m68ki_write_16(ea, res); } static void m68k_op_subx_32_mm(void) { uint src = OPER_AY_PD_32(); uint ea = EA_AX_PD_32(); uint dst = m68ki_read_32(ea); uint res = dst - src - XFLAG_AS_1(); FLAG_N = NFLAG_32(res); FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); FLAG_V = VFLAG_SUB_32(src, dst, res); res = MASK_OUT_ABOVE_32(res); FLAG_Z |= res; m68ki_write_32(ea, res); } static void m68k_op_swap_32(void) { uint* r_dst = &DY; FLAG_Z = MASK_OUT_ABOVE_32(*r_dst<<16); *r_dst = (*r_dst>>16) | FLAG_Z; FLAG_Z = *r_dst; FLAG_N = NFLAG_32(*r_dst); FLAG_C = CFLAG_CLEAR; FLAG_V = VFLAG_CLEAR; } static void m68k_op_tas_8_d(void) { uint* r_dst = &DY; FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); FLAG_N = NFLAG_8(*r_dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; *r_dst |= 0x80; } static void m68k_op_tas_8_ai(void) { uint ea = EA_AY_AI_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_tas_8_pi(void) { uint ea = EA_AY_PI_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_tas_8_pi7(void) { uint ea = EA_A7_PI_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_tas_8_pd(void) { uint ea = EA_AY_PD_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_tas_8_pd7(void) { uint ea = EA_A7_PD_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_tas_8_di(void) { uint ea = EA_AY_DI_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_tas_8_ix(void) { uint ea = EA_AY_IX_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_tas_8_aw(void) { uint ea = EA_AW_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_tas_8_al(void) { uint ea = EA_AL_8(); uint dst = m68ki_read_8(ea); uint allow_writeback; FLAG_Z = dst; FLAG_N = NFLAG_8(dst); FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback disabled in order to function properly. Some Amiga software may also rely on this, but only when accessing specific addresses so additional functionality will be needed. */ allow_writeback = m68ki_tas_callback(); if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); } static void m68k_op_trap(void) { /* Trap#n stacks exception frame type 0 */ m68ki_exception_trapN(EXCEPTION_TRAP_BASE + (REG_IR & 0xf)); /* HJB 990403 */ } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_trapt(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapt_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapt_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapf(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { return; } m68ki_exception_illegal(); } static void m68k_op_trapf_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapf_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_traphi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_HI()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapls(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LS()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapcc(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_CC()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapcs(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_CS()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapne(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_NE()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapeq(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_EQ()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapvc(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_VC()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapvs(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_VS()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trappl(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_PL()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapmi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_MI()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapge(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_GE()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_traplt(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LT()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_trapgt(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_GT()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_traple(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LE()) m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } m68ki_exception_illegal(); } static void m68k_op_traphi_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_HI()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapls_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LS()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapcc_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_CC()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapcs_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_CS()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapne_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_NE()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapeq_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_EQ()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapvc_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_VC()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapvs_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_VS()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trappl_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_PL()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapmi_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_MI()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapge_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_GE()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_traplt_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LT()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_trapgt_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_GT()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_traple_16(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LE()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 2; return; } m68ki_exception_illegal(); } static void m68k_op_traphi_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_HI()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapls_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LS()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapcc_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_CC()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapcs_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_CS()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapne_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_NE()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapeq_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_EQ()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapvc_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_VC()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapvs_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_VS()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trappl_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_PL()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapmi_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_MI()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapge_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_GE()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_traplt_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LT()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_trapgt_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_GT()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } static void m68k_op_traple_32(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { if(COND_LE()) { m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ return; } REG_PC += 4; return; } m68ki_exception_illegal(); } #endif static void m68k_op_trapv(void) { if(COND_VC()) { return; } m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ } static void m68k_op_tst_8_d(void) { uint res = MASK_OUT_ABOVE_8(DY); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_ai(void) { uint res = OPER_AY_AI_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_pi(void) { uint res = OPER_AY_PI_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_pi7(void) { uint res = OPER_A7_PI_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_pd(void) { uint res = OPER_AY_PD_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_pd7(void) { uint res = OPER_A7_PD_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_di(void) { uint res = OPER_AY_DI_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_ix(void) { uint res = OPER_AY_IX_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_aw(void) { uint res = OPER_AW_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_8_al(void) { uint res = OPER_AL_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_tst_8_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_PCDI_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } static void m68k_op_tst_8_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_PCIX_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } static void m68k_op_tst_8_i(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_I_8(); FLAG_N = NFLAG_8(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } #endif static void m68k_op_tst_16_d(void) { uint res = MASK_OUT_ABOVE_16(DY); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_tst_16_a(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = MAKE_INT_16(AY); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } #endif static void m68k_op_tst_16_ai(void) { uint res = OPER_AY_AI_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_16_pi(void) { uint res = OPER_AY_PI_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_16_pd(void) { uint res = OPER_AY_PD_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_16_di(void) { uint res = OPER_AY_DI_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_16_ix(void) { uint res = OPER_AY_IX_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_16_aw(void) { uint res = OPER_AW_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_16_al(void) { uint res = OPER_AL_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_tst_16_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_PCDI_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } static void m68k_op_tst_16_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_PCIX_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } static void m68k_op_tst_16_i(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_I_16(); FLAG_N = NFLAG_16(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } #endif static void m68k_op_tst_32_d(void) { uint res = DY; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_tst_32_a(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = AY; FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } #endif static void m68k_op_tst_32_ai(void) { uint res = OPER_AY_AI_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_32_pi(void) { uint res = OPER_AY_PI_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_32_pd(void) { uint res = OPER_AY_PD_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_32_di(void) { uint res = OPER_AY_DI_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_32_ix(void) { uint res = OPER_AY_IX_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_32_aw(void) { uint res = OPER_AW_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } static void m68k_op_tst_32_al(void) { uint res = OPER_AL_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_tst_32_pcdi(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_PCDI_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } static void m68k_op_tst_32_pcix(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_PCIX_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } static void m68k_op_tst_32_i(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint res = OPER_I_32(); FLAG_N = NFLAG_32(res); FLAG_Z = res; FLAG_V = VFLAG_CLEAR; FLAG_C = CFLAG_CLEAR; return; } m68ki_exception_illegal(); } #endif static void m68k_op_unlk_32_a7(void) { REG_A[7] = m68ki_read_32(REG_A[7]); } static void m68k_op_unlk_32(void) { uint* r_dst = &AY; REG_A[7] = *r_dst; *r_dst = m68ki_pull_32(); } #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 static void m68k_op_unpk_16_rr(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Note: DX and DY are reversed in Motorola's docs */ uint src = DY; uint* r_dst = &DX; *r_dst = MASK_OUT_BELOW_16(*r_dst) | (((((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16()) & 0xffff); return; } m68ki_exception_illegal(); } static void m68k_op_unpk_16_mm_ax7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Note: AX and AY are reversed in Motorola's docs */ uint src = OPER_AY_PD_8(); uint ea_dst; src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16(); ea_dst = EA_A7_PD_8(); m68ki_write_8(ea_dst, (src >> 8) & 0xff); ea_dst = EA_A7_PD_8(); m68ki_write_8(ea_dst, src & 0xff); return; } m68ki_exception_illegal(); } static void m68k_op_unpk_16_mm_ay7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Note: AX and AY are reversed in Motorola's docs */ uint src = OPER_A7_PD_8(); uint ea_dst; src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16(); ea_dst = EA_AX_PD_8(); m68ki_write_8(ea_dst, (src >> 8) & 0xff); ea_dst = EA_AX_PD_8(); m68ki_write_8(ea_dst, src & 0xff); return; } m68ki_exception_illegal(); } static void m68k_op_unpk_16_mm_axy7(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { uint src = OPER_A7_PD_8(); uint ea_dst; src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16(); ea_dst = EA_A7_PD_8(); m68ki_write_8(ea_dst, (src >> 8) & 0xff); ea_dst = EA_A7_PD_8(); m68ki_write_8(ea_dst, src & 0xff); return; } m68ki_exception_illegal(); } static void m68k_op_unpk_16_mm(void) { if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Note: AX and AY are reversed in Motorola's docs */ uint src = OPER_AY_PD_8(); uint ea_dst; src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16(); ea_dst = EA_AX_PD_8(); m68ki_write_8(ea_dst, (src >> 8) & 0xff); ea_dst = EA_AX_PD_8(); m68ki_write_8(ea_dst, src & 0xff); return; } m68ki_exception_illegal(); } #endif /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */ /* ======================================================================== */ /* ========================= OPCODE TABLE BUILDER ========================= */ /* ======================================================================== */ #include "m68kops.h" void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */ unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */ /* This is used to generate the opcode handler jump table */ typedef struct { void (*opcode_handler)(void); /* handler function */ unsigned int mask; /* mask on opcode */ unsigned int match; /* what to match after masking */ unsigned char cycles[4]; /* cycles each cpu type takes */ } opcode_handler_struct; /* Opcode handler table */ static const opcode_handler_struct m68k_opcode_handler_table[] = { /* function mask match 000 010 020 040 */ {m68k_op_1010 , 0xf000, 0xa000, { 4, 4, 4, 4}}, {m68k_op_1111 , 0xf000, 0xf000, { 4, 4, 4, 4}}, {m68k_op_moveq_32 , 0xf100, 0x7000, { 4, 4, 2, 2}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cpbcc_32 , 0xf180, 0xf080, { 0, 0, 4, 0}}, {m68k_op_cpgen_32 , 0xf1c0, 0xf000, { 0, 0, 4, 0}}, {m68k_op_cpscc_32 , 0xf1c0, 0xf040, { 0, 0, 4, 0}}, #endif {m68k_op_bra_8 , 0xff00, 0x6000, { 10, 10, 10, 10}}, {m68k_op_bsr_8 , 0xff00, 0x6100, { 18, 18, 7, 7}}, {m68k_op_bhi_8 , 0xff00, 0x6200, { 10, 10, 6, 6}}, {m68k_op_bls_8 , 0xff00, 0x6300, { 10, 10, 6, 6}}, {m68k_op_bcc_8 , 0xff00, 0x6400, { 10, 10, 6, 6}}, {m68k_op_bcs_8 , 0xff00, 0x6500, { 10, 10, 6, 6}}, {m68k_op_bne_8 , 0xff00, 0x6600, { 10, 10, 6, 6}}, {m68k_op_beq_8 , 0xff00, 0x6700, { 10, 10, 6, 6}}, {m68k_op_bvc_8 , 0xff00, 0x6800, { 10, 10, 6, 6}}, {m68k_op_bvs_8 , 0xff00, 0x6900, { 10, 10, 6, 6}}, {m68k_op_bpl_8 , 0xff00, 0x6a00, { 10, 10, 6, 6}}, {m68k_op_bmi_8 , 0xff00, 0x6b00, { 10, 10, 6, 6}}, {m68k_op_bge_8 , 0xff00, 0x6c00, { 10, 10, 6, 6}}, {m68k_op_blt_8 , 0xff00, 0x6d00, { 10, 10, 6, 6}}, {m68k_op_bgt_8 , 0xff00, 0x6e00, { 10, 10, 6, 6}}, {m68k_op_ble_8 , 0xff00, 0x6f00, { 10, 10, 6, 6}}, #if M68K_EMULATE_040 {m68k_op_040fpu0_32 , 0xff00, 0xf200, { 0, 0, 0, 0}}, {m68k_op_040fpu1_32 , 0xff00, 0xf300, { 0, 0, 0, 0}}, #endif {m68k_op_btst_32_r_d , 0xf1f8, 0x0100, { 6, 6, 4, 4}}, {m68k_op_movep_16_er , 0xf1f8, 0x0108, { 16, 16, 12, 12}}, {m68k_op_btst_8_r_ai , 0xf1f8, 0x0110, { 8, 8, 8, 8}}, {m68k_op_btst_8_r_pi , 0xf1f8, 0x0118, { 8, 8, 8, 8}}, {m68k_op_btst_8_r_pd , 0xf1f8, 0x0120, { 10, 10, 9, 9}}, {m68k_op_btst_8_r_di , 0xf1f8, 0x0128, { 12, 12, 9, 9}}, {m68k_op_btst_8_r_ix , 0xf1f8, 0x0130, { 14, 14, 11, 11}}, {m68k_op_bchg_32_r_d , 0xf1f8, 0x0140, { 8, 8, 4, 4}}, {m68k_op_movep_32_er , 0xf1f8, 0x0148, { 24, 24, 18, 18}}, {m68k_op_bchg_8_r_ai , 0xf1f8, 0x0150, { 12, 12, 8, 8}}, {m68k_op_bchg_8_r_pi , 0xf1f8, 0x0158, { 12, 12, 8, 8}}, {m68k_op_bchg_8_r_pd , 0xf1f8, 0x0160, { 14, 14, 9, 9}}, {m68k_op_bchg_8_r_di , 0xf1f8, 0x0168, { 16, 16, 9, 9}}, {m68k_op_bchg_8_r_ix , 0xf1f8, 0x0170, { 18, 18, 11, 11}}, {m68k_op_bclr_32_r_d , 0xf1f8, 0x0180, { 10, 10, 4, 4}}, {m68k_op_movep_16_re , 0xf1f8, 0x0188, { 16, 16, 11, 11}}, {m68k_op_bclr_8_r_ai , 0xf1f8, 0x0190, { 12, 14, 8, 8}}, {m68k_op_bclr_8_r_pi , 0xf1f8, 0x0198, { 12, 14, 8, 8}}, {m68k_op_bclr_8_r_pd , 0xf1f8, 0x01a0, { 14, 16, 9, 9}}, {m68k_op_bclr_8_r_di , 0xf1f8, 0x01a8, { 16, 18, 9, 9}}, {m68k_op_bclr_8_r_ix , 0xf1f8, 0x01b0, { 18, 20, 11, 11}}, {m68k_op_bset_32_r_d , 0xf1f8, 0x01c0, { 8, 8, 4, 4}}, {m68k_op_movep_32_re , 0xf1f8, 0x01c8, { 24, 24, 17, 17}}, {m68k_op_bset_8_r_ai , 0xf1f8, 0x01d0, { 12, 12, 8, 8}}, {m68k_op_bset_8_r_pi , 0xf1f8, 0x01d8, { 12, 12, 8, 8}}, {m68k_op_bset_8_r_pd , 0xf1f8, 0x01e0, { 14, 14, 9, 9}}, {m68k_op_bset_8_r_di , 0xf1f8, 0x01e8, { 16, 16, 9, 9}}, {m68k_op_bset_8_r_ix , 0xf1f8, 0x01f0, { 18, 18, 11, 11}}, {m68k_op_move_8_d_d , 0xf1f8, 0x1000, { 4, 4, 2, 2}}, {m68k_op_move_8_d_ai , 0xf1f8, 0x1010, { 8, 8, 6, 6}}, {m68k_op_move_8_d_pi , 0xf1f8, 0x1018, { 8, 8, 6, 6}}, {m68k_op_move_8_d_pd , 0xf1f8, 0x1020, { 10, 10, 7, 7}}, {m68k_op_move_8_d_di , 0xf1f8, 0x1028, { 12, 12, 7, 7}}, {m68k_op_move_8_d_ix , 0xf1f8, 0x1030, { 14, 14, 9, 9}}, {m68k_op_move_8_ai_d , 0xf1f8, 0x1080, { 8, 8, 4, 4}}, {m68k_op_move_8_ai_ai , 0xf1f8, 0x1090, { 12, 12, 8, 8}}, {m68k_op_move_8_ai_pi , 0xf1f8, 0x1098, { 12, 12, 8, 8}}, {m68k_op_move_8_ai_pd , 0xf1f8, 0x10a0, { 14, 14, 9, 9}}, {m68k_op_move_8_ai_di , 0xf1f8, 0x10a8, { 16, 16, 9, 9}}, {m68k_op_move_8_ai_ix , 0xf1f8, 0x10b0, { 18, 18, 11, 11}}, {m68k_op_move_8_pi_d , 0xf1f8, 0x10c0, { 8, 8, 4, 4}}, {m68k_op_move_8_pi_ai , 0xf1f8, 0x10d0, { 12, 12, 8, 8}}, {m68k_op_move_8_pi_pi , 0xf1f8, 0x10d8, { 12, 12, 8, 8}}, {m68k_op_move_8_pi_pd , 0xf1f8, 0x10e0, { 14, 14, 9, 9}}, {m68k_op_move_8_pi_di , 0xf1f8, 0x10e8, { 16, 16, 9, 9}}, {m68k_op_move_8_pi_ix , 0xf1f8, 0x10f0, { 18, 18, 11, 11}}, {m68k_op_move_8_pd_d , 0xf1f8, 0x1100, { 8, 8, 5, 5}}, {m68k_op_move_8_pd_ai , 0xf1f8, 0x1110, { 12, 12, 9, 9}}, {m68k_op_move_8_pd_pi , 0xf1f8, 0x1118, { 12, 12, 9, 9}}, {m68k_op_move_8_pd_pd , 0xf1f8, 0x1120, { 14, 14, 10, 10}}, {m68k_op_move_8_pd_di , 0xf1f8, 0x1128, { 16, 16, 10, 10}}, {m68k_op_move_8_pd_ix , 0xf1f8, 0x1130, { 18, 18, 12, 12}}, {m68k_op_move_8_di_d , 0xf1f8, 0x1140, { 12, 12, 5, 5}}, {m68k_op_move_8_di_ai , 0xf1f8, 0x1150, { 16, 16, 9, 9}}, {m68k_op_move_8_di_pi , 0xf1f8, 0x1158, { 16, 16, 9, 9}}, {m68k_op_move_8_di_pd , 0xf1f8, 0x1160, { 18, 18, 10, 10}}, {m68k_op_move_8_di_di , 0xf1f8, 0x1168, { 20, 20, 10, 10}}, {m68k_op_move_8_di_ix , 0xf1f8, 0x1170, { 22, 22, 12, 12}}, {m68k_op_move_8_ix_d , 0xf1f8, 0x1180, { 14, 14, 7, 7}}, {m68k_op_move_8_ix_ai , 0xf1f8, 0x1190, { 18, 18, 11, 11}}, {m68k_op_move_8_ix_pi , 0xf1f8, 0x1198, { 18, 18, 11, 11}}, {m68k_op_move_8_ix_pd , 0xf1f8, 0x11a0, { 20, 20, 12, 12}}, {m68k_op_move_8_ix_di , 0xf1f8, 0x11a8, { 22, 22, 12, 12}}, {m68k_op_move_8_ix_ix , 0xf1f8, 0x11b0, { 24, 24, 14, 14}}, {m68k_op_move_32_d_d , 0xf1f8, 0x2000, { 4, 4, 2, 2}}, {m68k_op_move_32_d_a , 0xf1f8, 0x2008, { 4, 4, 2, 2}}, {m68k_op_move_32_d_ai , 0xf1f8, 0x2010, { 12, 12, 6, 6}}, {m68k_op_move_32_d_pi , 0xf1f8, 0x2018, { 12, 12, 6, 6}}, {m68k_op_move_32_d_pd , 0xf1f8, 0x2020, { 14, 14, 7, 7}}, {m68k_op_move_32_d_di , 0xf1f8, 0x2028, { 16, 16, 7, 7}}, {m68k_op_move_32_d_ix , 0xf1f8, 0x2030, { 18, 18, 9, 9}}, {m68k_op_movea_32_d , 0xf1f8, 0x2040, { 4, 4, 2, 2}}, {m68k_op_movea_32_a , 0xf1f8, 0x2048, { 4, 4, 2, 2}}, {m68k_op_movea_32_ai , 0xf1f8, 0x2050, { 12, 12, 6, 6}}, {m68k_op_movea_32_pi , 0xf1f8, 0x2058, { 12, 12, 6, 6}}, {m68k_op_movea_32_pd , 0xf1f8, 0x2060, { 14, 14, 7, 7}}, {m68k_op_movea_32_di , 0xf1f8, 0x2068, { 16, 16, 7, 7}}, {m68k_op_movea_32_ix , 0xf1f8, 0x2070, { 18, 18, 9, 9}}, {m68k_op_move_32_ai_d , 0xf1f8, 0x2080, { 12, 12, 4, 4}}, {m68k_op_move_32_ai_a , 0xf1f8, 0x2088, { 12, 12, 4, 4}}, {m68k_op_move_32_ai_ai , 0xf1f8, 0x2090, { 20, 20, 8, 8}}, {m68k_op_move_32_ai_pi , 0xf1f8, 0x2098, { 20, 20, 8, 8}}, {m68k_op_move_32_ai_pd , 0xf1f8, 0x20a0, { 22, 22, 9, 9}}, {m68k_op_move_32_ai_di , 0xf1f8, 0x20a8, { 24, 24, 9, 9}}, {m68k_op_move_32_ai_ix , 0xf1f8, 0x20b0, { 26, 26, 11, 11}}, {m68k_op_move_32_pi_d , 0xf1f8, 0x20c0, { 12, 12, 4, 4}}, {m68k_op_move_32_pi_a , 0xf1f8, 0x20c8, { 12, 12, 4, 4}}, {m68k_op_move_32_pi_ai , 0xf1f8, 0x20d0, { 20, 20, 8, 8}}, {m68k_op_move_32_pi_pi , 0xf1f8, 0x20d8, { 20, 20, 8, 8}}, {m68k_op_move_32_pi_pd , 0xf1f8, 0x20e0, { 22, 22, 9, 9}}, {m68k_op_move_32_pi_di , 0xf1f8, 0x20e8, { 24, 24, 9, 9}}, {m68k_op_move_32_pi_ix , 0xf1f8, 0x20f0, { 26, 26, 11, 11}}, {m68k_op_move_32_pd_d , 0xf1f8, 0x2100, { 12, 14, 5, 5}}, {m68k_op_move_32_pd_a , 0xf1f8, 0x2108, { 12, 14, 5, 5}}, {m68k_op_move_32_pd_ai , 0xf1f8, 0x2110, { 20, 22, 9, 9}}, {m68k_op_move_32_pd_pi , 0xf1f8, 0x2118, { 20, 22, 9, 9}}, {m68k_op_move_32_pd_pd , 0xf1f8, 0x2120, { 22, 24, 10, 10}}, {m68k_op_move_32_pd_di , 0xf1f8, 0x2128, { 24, 26, 10, 10}}, {m68k_op_move_32_pd_ix , 0xf1f8, 0x2130, { 26, 28, 12, 12}}, {m68k_op_move_32_di_d , 0xf1f8, 0x2140, { 16, 16, 5, 5}}, {m68k_op_move_32_di_a , 0xf1f8, 0x2148, { 16, 16, 5, 5}}, {m68k_op_move_32_di_ai , 0xf1f8, 0x2150, { 24, 24, 9, 9}}, {m68k_op_move_32_di_pi , 0xf1f8, 0x2158, { 24, 24, 9, 9}}, {m68k_op_move_32_di_pd , 0xf1f8, 0x2160, { 26, 26, 10, 10}}, {m68k_op_move_32_di_di , 0xf1f8, 0x2168, { 28, 28, 10, 10}}, {m68k_op_move_32_di_ix , 0xf1f8, 0x2170, { 30, 30, 12, 12}}, {m68k_op_move_32_ix_d , 0xf1f8, 0x2180, { 18, 18, 7, 7}}, {m68k_op_move_32_ix_a , 0xf1f8, 0x2188, { 18, 18, 7, 7}}, {m68k_op_move_32_ix_ai , 0xf1f8, 0x2190, { 26, 26, 11, 11}}, {m68k_op_move_32_ix_pi , 0xf1f8, 0x2198, { 26, 26, 11, 11}}, {m68k_op_move_32_ix_pd , 0xf1f8, 0x21a0, { 28, 28, 12, 12}}, {m68k_op_move_32_ix_di , 0xf1f8, 0x21a8, { 30, 30, 12, 12}}, {m68k_op_move_32_ix_ix , 0xf1f8, 0x21b0, { 32, 32, 14, 14}}, {m68k_op_move_16_d_d , 0xf1f8, 0x3000, { 4, 4, 2, 2}}, {m68k_op_move_16_d_a , 0xf1f8, 0x3008, { 4, 4, 2, 2}}, {m68k_op_move_16_d_ai , 0xf1f8, 0x3010, { 8, 8, 6, 6}}, {m68k_op_move_16_d_pi , 0xf1f8, 0x3018, { 8, 8, 6, 6}}, {m68k_op_move_16_d_pd , 0xf1f8, 0x3020, { 10, 10, 7, 7}}, {m68k_op_move_16_d_di , 0xf1f8, 0x3028, { 12, 12, 7, 7}}, {m68k_op_move_16_d_ix , 0xf1f8, 0x3030, { 14, 14, 9, 9}}, {m68k_op_movea_16_d , 0xf1f8, 0x3040, { 4, 4, 2, 2}}, {m68k_op_movea_16_a , 0xf1f8, 0x3048, { 4, 4, 2, 2}}, {m68k_op_movea_16_ai , 0xf1f8, 0x3050, { 8, 8, 6, 6}}, {m68k_op_movea_16_pi , 0xf1f8, 0x3058, { 8, 8, 6, 6}}, {m68k_op_movea_16_pd , 0xf1f8, 0x3060, { 10, 10, 7, 7}}, {m68k_op_movea_16_di , 0xf1f8, 0x3068, { 12, 12, 7, 7}}, {m68k_op_movea_16_ix , 0xf1f8, 0x3070, { 14, 14, 9, 9}}, {m68k_op_move_16_ai_d , 0xf1f8, 0x3080, { 8, 8, 4, 4}}, {m68k_op_move_16_ai_a , 0xf1f8, 0x3088, { 8, 8, 4, 4}}, {m68k_op_move_16_ai_ai , 0xf1f8, 0x3090, { 12, 12, 8, 8}}, {m68k_op_move_16_ai_pi , 0xf1f8, 0x3098, { 12, 12, 8, 8}}, {m68k_op_move_16_ai_pd , 0xf1f8, 0x30a0, { 14, 14, 9, 9}}, {m68k_op_move_16_ai_di , 0xf1f8, 0x30a8, { 16, 16, 9, 9}}, {m68k_op_move_16_ai_ix , 0xf1f8, 0x30b0, { 18, 18, 11, 11}}, {m68k_op_move_16_pi_d , 0xf1f8, 0x30c0, { 8, 8, 4, 4}}, {m68k_op_move_16_pi_a , 0xf1f8, 0x30c8, { 8, 8, 4, 4}}, {m68k_op_move_16_pi_ai , 0xf1f8, 0x30d0, { 12, 12, 8, 8}}, {m68k_op_move_16_pi_pi , 0xf1f8, 0x30d8, { 12, 12, 8, 8}}, {m68k_op_move_16_pi_pd , 0xf1f8, 0x30e0, { 14, 14, 9, 9}}, {m68k_op_move_16_pi_di , 0xf1f8, 0x30e8, { 16, 16, 9, 9}}, {m68k_op_move_16_pi_ix , 0xf1f8, 0x30f0, { 18, 18, 11, 11}}, {m68k_op_move_16_pd_d , 0xf1f8, 0x3100, { 8, 8, 5, 5}}, {m68k_op_move_16_pd_a , 0xf1f8, 0x3108, { 8, 8, 5, 5}}, {m68k_op_move_16_pd_ai , 0xf1f8, 0x3110, { 12, 12, 9, 9}}, {m68k_op_move_16_pd_pi , 0xf1f8, 0x3118, { 12, 12, 9, 9}}, {m68k_op_move_16_pd_pd , 0xf1f8, 0x3120, { 14, 14, 10, 10}}, {m68k_op_move_16_pd_di , 0xf1f8, 0x3128, { 16, 16, 10, 10}}, {m68k_op_move_16_pd_ix , 0xf1f8, 0x3130, { 18, 18, 12, 12}}, {m68k_op_move_16_di_d , 0xf1f8, 0x3140, { 12, 12, 5, 5}}, {m68k_op_move_16_di_a , 0xf1f8, 0x3148, { 12, 12, 5, 5}}, {m68k_op_move_16_di_ai , 0xf1f8, 0x3150, { 16, 16, 9, 9}}, {m68k_op_move_16_di_pi , 0xf1f8, 0x3158, { 16, 16, 9, 9}}, {m68k_op_move_16_di_pd , 0xf1f8, 0x3160, { 18, 18, 10, 10}}, {m68k_op_move_16_di_di , 0xf1f8, 0x3168, { 20, 20, 10, 10}}, {m68k_op_move_16_di_ix , 0xf1f8, 0x3170, { 22, 22, 12, 12}}, {m68k_op_move_16_ix_d , 0xf1f8, 0x3180, { 14, 14, 7, 7}}, {m68k_op_move_16_ix_a , 0xf1f8, 0x3188, { 14, 14, 7, 7}}, {m68k_op_move_16_ix_ai , 0xf1f8, 0x3190, { 18, 18, 11, 11}}, {m68k_op_move_16_ix_pi , 0xf1f8, 0x3198, { 18, 18, 11, 11}}, {m68k_op_move_16_ix_pd , 0xf1f8, 0x31a0, { 20, 20, 12, 12}}, {m68k_op_move_16_ix_di , 0xf1f8, 0x31a8, { 22, 22, 12, 12}}, {m68k_op_move_16_ix_ix , 0xf1f8, 0x31b0, { 24, 24, 14, 14}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_chk_32_d , 0xf1f8, 0x4100, { 0, 0, 8, 8}}, {m68k_op_chk_32_ai , 0xf1f8, 0x4110, { 0, 0, 12, 12}}, {m68k_op_chk_32_pi , 0xf1f8, 0x4118, { 0, 0, 12, 12}}, {m68k_op_chk_32_pd , 0xf1f8, 0x4120, { 0, 0, 13, 13}}, {m68k_op_chk_32_di , 0xf1f8, 0x4128, { 0, 0, 13, 13}}, {m68k_op_chk_32_ix , 0xf1f8, 0x4130, { 0, 0, 15, 15}}, #endif {m68k_op_chk_16_d , 0xf1f8, 0x4180, { 10, 8, 8, 8}}, {m68k_op_chk_16_ai , 0xf1f8, 0x4190, { 14, 12, 12, 12}}, {m68k_op_chk_16_pi , 0xf1f8, 0x4198, { 14, 12, 12, 12}}, {m68k_op_chk_16_pd , 0xf1f8, 0x41a0, { 16, 14, 13, 13}}, {m68k_op_chk_16_di , 0xf1f8, 0x41a8, { 18, 16, 13, 13}}, {m68k_op_chk_16_ix , 0xf1f8, 0x41b0, { 20, 18, 15, 15}}, {m68k_op_lea_32_ai , 0xf1f8, 0x41d0, { 4, 4, 6, 6}}, {m68k_op_lea_32_di , 0xf1f8, 0x41e8, { 8, 8, 7, 7}}, {m68k_op_lea_32_ix , 0xf1f8, 0x41f0, { 12, 12, 9, 9}}, {m68k_op_addq_8_d , 0xf1f8, 0x5000, { 4, 4, 2, 2}}, {m68k_op_addq_8_ai , 0xf1f8, 0x5010, { 12, 12, 8, 8}}, {m68k_op_addq_8_pi , 0xf1f8, 0x5018, { 12, 12, 8, 8}}, {m68k_op_addq_8_pd , 0xf1f8, 0x5020, { 14, 14, 9, 9}}, {m68k_op_addq_8_di , 0xf1f8, 0x5028, { 16, 16, 9, 9}}, {m68k_op_addq_8_ix , 0xf1f8, 0x5030, { 18, 18, 11, 11}}, {m68k_op_addq_16_d , 0xf1f8, 0x5040, { 4, 4, 2, 2}}, {m68k_op_addq_16_a , 0xf1f8, 0x5048, { 4, 4, 2, 2}}, {m68k_op_addq_16_ai , 0xf1f8, 0x5050, { 12, 12, 8, 8}}, {m68k_op_addq_16_pi , 0xf1f8, 0x5058, { 12, 12, 8, 8}}, {m68k_op_addq_16_pd , 0xf1f8, 0x5060, { 14, 14, 9, 9}}, {m68k_op_addq_16_di , 0xf1f8, 0x5068, { 16, 16, 9, 9}}, {m68k_op_addq_16_ix , 0xf1f8, 0x5070, { 18, 18, 11, 11}}, {m68k_op_addq_32_d , 0xf1f8, 0x5080, { 8, 8, 2, 2}}, {m68k_op_addq_32_a , 0xf1f8, 0x5088, { 8, 8, 2, 2}}, {m68k_op_addq_32_ai , 0xf1f8, 0x5090, { 20, 20, 8, 8}}, {m68k_op_addq_32_pi , 0xf1f8, 0x5098, { 20, 20, 8, 8}}, {m68k_op_addq_32_pd , 0xf1f8, 0x50a0, { 22, 22, 9, 9}}, {m68k_op_addq_32_di , 0xf1f8, 0x50a8, { 24, 24, 9, 9}}, {m68k_op_addq_32_ix , 0xf1f8, 0x50b0, { 26, 26, 11, 11}}, {m68k_op_subq_8_d , 0xf1f8, 0x5100, { 4, 4, 2, 2}}, {m68k_op_subq_8_ai , 0xf1f8, 0x5110, { 12, 12, 8, 8}}, {m68k_op_subq_8_pi , 0xf1f8, 0x5118, { 12, 12, 8, 8}}, {m68k_op_subq_8_pd , 0xf1f8, 0x5120, { 14, 14, 9, 9}}, {m68k_op_subq_8_di , 0xf1f8, 0x5128, { 16, 16, 9, 9}}, {m68k_op_subq_8_ix , 0xf1f8, 0x5130, { 18, 18, 11, 11}}, {m68k_op_subq_16_d , 0xf1f8, 0x5140, { 4, 4, 2, 2}}, {m68k_op_subq_16_a , 0xf1f8, 0x5148, { 8, 4, 2, 2}}, {m68k_op_subq_16_ai , 0xf1f8, 0x5150, { 12, 12, 8, 8}}, {m68k_op_subq_16_pi , 0xf1f8, 0x5158, { 12, 12, 8, 8}}, {m68k_op_subq_16_pd , 0xf1f8, 0x5160, { 14, 14, 9, 9}}, {m68k_op_subq_16_di , 0xf1f8, 0x5168, { 16, 16, 9, 9}}, {m68k_op_subq_16_ix , 0xf1f8, 0x5170, { 18, 18, 11, 11}}, {m68k_op_subq_32_d , 0xf1f8, 0x5180, { 8, 8, 2, 2}}, {m68k_op_subq_32_a , 0xf1f8, 0x5188, { 8, 8, 2, 2}}, {m68k_op_subq_32_ai , 0xf1f8, 0x5190, { 20, 20, 8, 8}}, {m68k_op_subq_32_pi , 0xf1f8, 0x5198, { 20, 20, 8, 8}}, {m68k_op_subq_32_pd , 0xf1f8, 0x51a0, { 22, 22, 9, 9}}, {m68k_op_subq_32_di , 0xf1f8, 0x51a8, { 24, 24, 9, 9}}, {m68k_op_subq_32_ix , 0xf1f8, 0x51b0, { 26, 26, 11, 11}}, {m68k_op_or_8_er_d , 0xf1f8, 0x8000, { 4, 4, 2, 2}}, {m68k_op_or_8_er_ai , 0xf1f8, 0x8010, { 8, 8, 6, 6}}, {m68k_op_or_8_er_pi , 0xf1f8, 0x8018, { 8, 8, 6, 6}}, {m68k_op_or_8_er_pd , 0xf1f8, 0x8020, { 10, 10, 7, 7}}, {m68k_op_or_8_er_di , 0xf1f8, 0x8028, { 12, 12, 7, 7}}, {m68k_op_or_8_er_ix , 0xf1f8, 0x8030, { 14, 14, 9, 9}}, {m68k_op_or_16_er_d , 0xf1f8, 0x8040, { 4, 4, 2, 2}}, {m68k_op_or_16_er_ai , 0xf1f8, 0x8050, { 8, 8, 6, 6}}, {m68k_op_or_16_er_pi , 0xf1f8, 0x8058, { 8, 8, 6, 6}}, {m68k_op_or_16_er_pd , 0xf1f8, 0x8060, { 10, 10, 7, 7}}, {m68k_op_or_16_er_di , 0xf1f8, 0x8068, { 12, 12, 7, 7}}, {m68k_op_or_16_er_ix , 0xf1f8, 0x8070, { 14, 14, 9, 9}}, {m68k_op_or_32_er_d , 0xf1f8, 0x8080, { 8, 6, 2, 2}}, {m68k_op_or_32_er_ai , 0xf1f8, 0x8090, { 14, 14, 6, 6}}, {m68k_op_or_32_er_pi , 0xf1f8, 0x8098, { 14, 14, 6, 6}}, {m68k_op_or_32_er_pd , 0xf1f8, 0x80a0, { 16, 16, 7, 7}}, {m68k_op_or_32_er_di , 0xf1f8, 0x80a8, { 18, 18, 7, 7}}, {m68k_op_or_32_er_ix , 0xf1f8, 0x80b0, { 20, 20, 9, 9}}, {m68k_op_divu_16_d , 0xf1f8, 0x80c0, { 0, 108, 44, 44}}, {m68k_op_divu_16_ai , 0xf1f8, 0x80d0, { 4, 112, 48, 48}}, {m68k_op_divu_16_pi , 0xf1f8, 0x80d8, { 4, 112, 48, 48}}, {m68k_op_divu_16_pd , 0xf1f8, 0x80e0, { 6, 114, 49, 49}}, {m68k_op_divu_16_di , 0xf1f8, 0x80e8, { 8, 116, 49, 49}}, {m68k_op_divu_16_ix , 0xf1f8, 0x80f0, { 10, 118, 51, 51}}, {m68k_op_sbcd_8_rr , 0xf1f8, 0x8100, { 6, 6, 4, 4}}, {m68k_op_sbcd_8_mm , 0xf1f8, 0x8108, { 18, 18, 16, 16}}, {m68k_op_or_8_re_ai , 0xf1f8, 0x8110, { 12, 12, 8, 8}}, {m68k_op_or_8_re_pi , 0xf1f8, 0x8118, { 12, 12, 8, 8}}, {m68k_op_or_8_re_pd , 0xf1f8, 0x8120, { 14, 14, 9, 9}}, {m68k_op_or_8_re_di , 0xf1f8, 0x8128, { 16, 16, 9, 9}}, {m68k_op_or_8_re_ix , 0xf1f8, 0x8130, { 18, 18, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_pack_16_rr , 0xf1f8, 0x8140, { 0, 0, 6, 6}}, {m68k_op_pack_16_mm , 0xf1f8, 0x8148, { 0, 0, 13, 13}}, #endif {m68k_op_or_16_re_ai , 0xf1f8, 0x8150, { 12, 12, 8, 8}}, {m68k_op_or_16_re_pi , 0xf1f8, 0x8158, { 12, 12, 8, 8}}, {m68k_op_or_16_re_pd , 0xf1f8, 0x8160, { 14, 14, 9, 9}}, {m68k_op_or_16_re_di , 0xf1f8, 0x8168, { 16, 16, 9, 9}}, {m68k_op_or_16_re_ix , 0xf1f8, 0x8170, { 18, 18, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_unpk_16_rr , 0xf1f8, 0x8180, { 0, 0, 8, 8}}, {m68k_op_unpk_16_mm , 0xf1f8, 0x8188, { 0, 0, 13, 13}}, #endif {m68k_op_or_32_re_ai , 0xf1f8, 0x8190, { 20, 20, 8, 8}}, {m68k_op_or_32_re_pi , 0xf1f8, 0x8198, { 20, 20, 8, 8}}, {m68k_op_or_32_re_pd , 0xf1f8, 0x81a0, { 22, 22, 9, 9}}, {m68k_op_or_32_re_di , 0xf1f8, 0x81a8, { 24, 24, 9, 9}}, {m68k_op_or_32_re_ix , 0xf1f8, 0x81b0, { 26, 26, 11, 11}}, {m68k_op_divs_16_d , 0xf1f8, 0x81c0, { 0, 122, 56, 56}}, {m68k_op_divs_16_ai , 0xf1f8, 0x81d0, { 4, 126, 60, 60}}, {m68k_op_divs_16_pi , 0xf1f8, 0x81d8, { 4, 126, 60, 60}}, {m68k_op_divs_16_pd , 0xf1f8, 0x81e0, { 6, 128, 61, 61}}, {m68k_op_divs_16_di , 0xf1f8, 0x81e8, { 8, 130, 61, 61}}, {m68k_op_divs_16_ix , 0xf1f8, 0x81f0, { 10, 132, 63, 63}}, {m68k_op_sub_8_er_d , 0xf1f8, 0x9000, { 4, 4, 2, 2}}, {m68k_op_sub_8_er_ai , 0xf1f8, 0x9010, { 8, 8, 6, 6}}, {m68k_op_sub_8_er_pi , 0xf1f8, 0x9018, { 8, 8, 6, 6}}, {m68k_op_sub_8_er_pd , 0xf1f8, 0x9020, { 10, 10, 7, 7}}, {m68k_op_sub_8_er_di , 0xf1f8, 0x9028, { 12, 12, 7, 7}}, {m68k_op_sub_8_er_ix , 0xf1f8, 0x9030, { 14, 14, 9, 9}}, {m68k_op_sub_16_er_d , 0xf1f8, 0x9040, { 4, 4, 2, 2}}, {m68k_op_sub_16_er_a , 0xf1f8, 0x9048, { 4, 4, 2, 2}}, {m68k_op_sub_16_er_ai , 0xf1f8, 0x9050, { 8, 8, 6, 6}}, {m68k_op_sub_16_er_pi , 0xf1f8, 0x9058, { 8, 8, 6, 6}}, {m68k_op_sub_16_er_pd , 0xf1f8, 0x9060, { 10, 10, 7, 7}}, {m68k_op_sub_16_er_di , 0xf1f8, 0x9068, { 12, 12, 7, 7}}, {m68k_op_sub_16_er_ix , 0xf1f8, 0x9070, { 14, 14, 9, 9}}, {m68k_op_sub_32_er_d , 0xf1f8, 0x9080, { 8, 6, 2, 2}}, {m68k_op_sub_32_er_a , 0xf1f8, 0x9088, { 8, 6, 2, 2}}, {m68k_op_sub_32_er_ai , 0xf1f8, 0x9090, { 14, 14, 6, 6}}, {m68k_op_sub_32_er_pi , 0xf1f8, 0x9098, { 14, 14, 6, 6}}, {m68k_op_sub_32_er_pd , 0xf1f8, 0x90a0, { 16, 16, 7, 7}}, {m68k_op_sub_32_er_di , 0xf1f8, 0x90a8, { 18, 18, 7, 7}}, {m68k_op_sub_32_er_ix , 0xf1f8, 0x90b0, { 20, 20, 9, 9}}, {m68k_op_suba_16_d , 0xf1f8, 0x90c0, { 8, 8, 2, 2}}, {m68k_op_suba_16_a , 0xf1f8, 0x90c8, { 8, 8, 2, 2}}, {m68k_op_suba_16_ai , 0xf1f8, 0x90d0, { 12, 12, 6, 6}}, {m68k_op_suba_16_pi , 0xf1f8, 0x90d8, { 12, 12, 6, 6}}, {m68k_op_suba_16_pd , 0xf1f8, 0x90e0, { 14, 14, 7, 7}}, {m68k_op_suba_16_di , 0xf1f8, 0x90e8, { 16, 16, 7, 7}}, {m68k_op_suba_16_ix , 0xf1f8, 0x90f0, { 18, 18, 9, 9}}, {m68k_op_subx_8_rr , 0xf1f8, 0x9100, { 4, 4, 2, 2}}, {m68k_op_subx_8_mm , 0xf1f8, 0x9108, { 18, 18, 12, 12}}, {m68k_op_sub_8_re_ai , 0xf1f8, 0x9110, { 12, 12, 8, 8}}, {m68k_op_sub_8_re_pi , 0xf1f8, 0x9118, { 12, 12, 8, 8}}, {m68k_op_sub_8_re_pd , 0xf1f8, 0x9120, { 14, 14, 9, 9}}, {m68k_op_sub_8_re_di , 0xf1f8, 0x9128, { 16, 16, 9, 9}}, {m68k_op_sub_8_re_ix , 0xf1f8, 0x9130, { 18, 18, 11, 11}}, {m68k_op_subx_16_rr , 0xf1f8, 0x9140, { 4, 4, 2, 2}}, {m68k_op_subx_16_mm , 0xf1f8, 0x9148, { 18, 18, 12, 12}}, {m68k_op_sub_16_re_ai , 0xf1f8, 0x9150, { 12, 12, 8, 8}}, {m68k_op_sub_16_re_pi , 0xf1f8, 0x9158, { 12, 12, 8, 8}}, {m68k_op_sub_16_re_pd , 0xf1f8, 0x9160, { 14, 14, 9, 9}}, {m68k_op_sub_16_re_di , 0xf1f8, 0x9168, { 16, 16, 9, 9}}, {m68k_op_sub_16_re_ix , 0xf1f8, 0x9170, { 18, 18, 11, 11}}, {m68k_op_subx_32_rr , 0xf1f8, 0x9180, { 8, 6, 2, 2}}, {m68k_op_subx_32_mm , 0xf1f8, 0x9188, { 30, 30, 12, 12}}, {m68k_op_sub_32_re_ai , 0xf1f8, 0x9190, { 20, 20, 8, 8}}, {m68k_op_sub_32_re_pi , 0xf1f8, 0x9198, { 20, 20, 8, 8}}, {m68k_op_sub_32_re_pd , 0xf1f8, 0x91a0, { 22, 22, 9, 9}}, {m68k_op_sub_32_re_di , 0xf1f8, 0x91a8, { 24, 24, 9, 9}}, {m68k_op_sub_32_re_ix , 0xf1f8, 0x91b0, { 26, 26, 11, 11}}, {m68k_op_suba_32_d , 0xf1f8, 0x91c0, { 8, 6, 2, 2}}, {m68k_op_suba_32_a , 0xf1f8, 0x91c8, { 8, 6, 2, 2}}, {m68k_op_suba_32_ai , 0xf1f8, 0x91d0, { 14, 14, 6, 6}}, {m68k_op_suba_32_pi , 0xf1f8, 0x91d8, { 14, 14, 6, 6}}, {m68k_op_suba_32_pd , 0xf1f8, 0x91e0, { 16, 16, 7, 7}}, {m68k_op_suba_32_di , 0xf1f8, 0x91e8, { 18, 18, 7, 7}}, {m68k_op_suba_32_ix , 0xf1f8, 0x91f0, { 20, 20, 9, 9}}, {m68k_op_cmp_8_d , 0xf1f8, 0xb000, { 4, 4, 2, 2}}, {m68k_op_cmp_8_ai , 0xf1f8, 0xb010, { 8, 8, 6, 6}}, {m68k_op_cmp_8_pi , 0xf1f8, 0xb018, { 8, 8, 6, 6}}, {m68k_op_cmp_8_pd , 0xf1f8, 0xb020, { 10, 10, 7, 7}}, {m68k_op_cmp_8_di , 0xf1f8, 0xb028, { 12, 12, 7, 7}}, {m68k_op_cmp_8_ix , 0xf1f8, 0xb030, { 14, 14, 9, 9}}, {m68k_op_cmp_16_d , 0xf1f8, 0xb040, { 4, 4, 2, 2}}, {m68k_op_cmp_16_a , 0xf1f8, 0xb048, { 4, 4, 2, 2}}, {m68k_op_cmp_16_ai , 0xf1f8, 0xb050, { 8, 8, 6, 6}}, {m68k_op_cmp_16_pi , 0xf1f8, 0xb058, { 8, 8, 6, 6}}, {m68k_op_cmp_16_pd , 0xf1f8, 0xb060, { 10, 10, 7, 7}}, {m68k_op_cmp_16_di , 0xf1f8, 0xb068, { 12, 12, 7, 7}}, {m68k_op_cmp_16_ix , 0xf1f8, 0xb070, { 14, 14, 9, 9}}, {m68k_op_cmp_32_d , 0xf1f8, 0xb080, { 6, 6, 2, 2}}, {m68k_op_cmp_32_a , 0xf1f8, 0xb088, { 6, 6, 2, 2}}, {m68k_op_cmp_32_ai , 0xf1f8, 0xb090, { 14, 14, 6, 6}}, {m68k_op_cmp_32_pi , 0xf1f8, 0xb098, { 14, 14, 6, 6}}, {m68k_op_cmp_32_pd , 0xf1f8, 0xb0a0, { 16, 16, 7, 7}}, {m68k_op_cmp_32_di , 0xf1f8, 0xb0a8, { 18, 18, 7, 7}}, {m68k_op_cmp_32_ix , 0xf1f8, 0xb0b0, { 20, 20, 9, 9}}, {m68k_op_cmpa_16_d , 0xf1f8, 0xb0c0, { 6, 6, 4, 4}}, {m68k_op_cmpa_16_a , 0xf1f8, 0xb0c8, { 6, 6, 4, 4}}, {m68k_op_cmpa_16_ai , 0xf1f8, 0xb0d0, { 10, 10, 8, 8}}, {m68k_op_cmpa_16_pi , 0xf1f8, 0xb0d8, { 10, 10, 8, 8}}, {m68k_op_cmpa_16_pd , 0xf1f8, 0xb0e0, { 12, 12, 9, 9}}, {m68k_op_cmpa_16_di , 0xf1f8, 0xb0e8, { 14, 14, 9, 9}}, {m68k_op_cmpa_16_ix , 0xf1f8, 0xb0f0, { 16, 16, 11, 11}}, {m68k_op_eor_8_d , 0xf1f8, 0xb100, { 4, 4, 2, 2}}, {m68k_op_cmpm_8 , 0xf1f8, 0xb108, { 12, 12, 9, 9}}, {m68k_op_eor_8_ai , 0xf1f8, 0xb110, { 12, 12, 8, 8}}, {m68k_op_eor_8_pi , 0xf1f8, 0xb118, { 12, 12, 8, 8}}, {m68k_op_eor_8_pd , 0xf1f8, 0xb120, { 14, 14, 9, 9}}, {m68k_op_eor_8_di , 0xf1f8, 0xb128, { 16, 16, 9, 9}}, {m68k_op_eor_8_ix , 0xf1f8, 0xb130, { 18, 18, 11, 11}}, {m68k_op_eor_16_d , 0xf1f8, 0xb140, { 4, 4, 2, 2}}, {m68k_op_cmpm_16 , 0xf1f8, 0xb148, { 12, 12, 9, 9}}, {m68k_op_eor_16_ai , 0xf1f8, 0xb150, { 12, 12, 8, 8}}, {m68k_op_eor_16_pi , 0xf1f8, 0xb158, { 12, 12, 8, 8}}, {m68k_op_eor_16_pd , 0xf1f8, 0xb160, { 14, 14, 9, 9}}, {m68k_op_eor_16_di , 0xf1f8, 0xb168, { 16, 16, 9, 9}}, {m68k_op_eor_16_ix , 0xf1f8, 0xb170, { 18, 18, 11, 11}}, {m68k_op_eor_32_d , 0xf1f8, 0xb180, { 8, 6, 2, 2}}, {m68k_op_cmpm_32 , 0xf1f8, 0xb188, { 20, 20, 9, 9}}, {m68k_op_eor_32_ai , 0xf1f8, 0xb190, { 20, 20, 8, 8}}, {m68k_op_eor_32_pi , 0xf1f8, 0xb198, { 20, 20, 8, 8}}, {m68k_op_eor_32_pd , 0xf1f8, 0xb1a0, { 22, 22, 9, 9}}, {m68k_op_eor_32_di , 0xf1f8, 0xb1a8, { 24, 24, 9, 9}}, {m68k_op_eor_32_ix , 0xf1f8, 0xb1b0, { 26, 26, 11, 11}}, {m68k_op_cmpa_32_d , 0xf1f8, 0xb1c0, { 6, 6, 4, 4}}, {m68k_op_cmpa_32_a , 0xf1f8, 0xb1c8, { 6, 6, 4, 4}}, {m68k_op_cmpa_32_ai , 0xf1f8, 0xb1d0, { 14, 14, 8, 8}}, {m68k_op_cmpa_32_pi , 0xf1f8, 0xb1d8, { 14, 14, 8, 8}}, {m68k_op_cmpa_32_pd , 0xf1f8, 0xb1e0, { 16, 16, 9, 9}}, {m68k_op_cmpa_32_di , 0xf1f8, 0xb1e8, { 18, 18, 9, 9}}, {m68k_op_cmpa_32_ix , 0xf1f8, 0xb1f0, { 20, 20, 11, 11}}, {m68k_op_and_8_er_d , 0xf1f8, 0xc000, { 4, 4, 2, 2}}, {m68k_op_and_8_er_ai , 0xf1f8, 0xc010, { 8, 8, 6, 6}}, {m68k_op_and_8_er_pi , 0xf1f8, 0xc018, { 8, 8, 6, 6}}, {m68k_op_and_8_er_pd , 0xf1f8, 0xc020, { 10, 10, 7, 7}}, {m68k_op_and_8_er_di , 0xf1f8, 0xc028, { 12, 12, 7, 7}}, {m68k_op_and_8_er_ix , 0xf1f8, 0xc030, { 14, 14, 9, 9}}, {m68k_op_and_16_er_d , 0xf1f8, 0xc040, { 4, 4, 2, 2}}, {m68k_op_and_16_er_ai , 0xf1f8, 0xc050, { 8, 8, 6, 6}}, {m68k_op_and_16_er_pi , 0xf1f8, 0xc058, { 8, 8, 6, 6}}, {m68k_op_and_16_er_pd , 0xf1f8, 0xc060, { 10, 10, 7, 7}}, {m68k_op_and_16_er_di , 0xf1f8, 0xc068, { 12, 12, 7, 7}}, {m68k_op_and_16_er_ix , 0xf1f8, 0xc070, { 14, 14, 9, 9}}, {m68k_op_and_32_er_d , 0xf1f8, 0xc080, { 8, 6, 2, 2}}, {m68k_op_and_32_er_ai , 0xf1f8, 0xc090, { 14, 14, 6, 6}}, {m68k_op_and_32_er_pi , 0xf1f8, 0xc098, { 14, 14, 6, 6}}, {m68k_op_and_32_er_pd , 0xf1f8, 0xc0a0, { 16, 16, 7, 7}}, {m68k_op_and_32_er_di , 0xf1f8, 0xc0a8, { 18, 18, 7, 7}}, {m68k_op_and_32_er_ix , 0xf1f8, 0xc0b0, { 20, 20, 9, 9}}, {m68k_op_mulu_16_d , 0xf1f8, 0xc0c0, { 0, 30, 27, 27}}, {m68k_op_mulu_16_ai , 0xf1f8, 0xc0d0, { 4, 34, 31, 31}}, {m68k_op_mulu_16_pi , 0xf1f8, 0xc0d8, { 4, 34, 31, 31}}, {m68k_op_mulu_16_pd , 0xf1f8, 0xc0e0, { 6, 36, 32, 32}}, {m68k_op_mulu_16_di , 0xf1f8, 0xc0e8, { 8, 38, 32, 32}}, {m68k_op_mulu_16_ix , 0xf1f8, 0xc0f0, { 10, 40, 34, 34}}, {m68k_op_abcd_8_rr , 0xf1f8, 0xc100, { 6, 6, 4, 4}}, {m68k_op_abcd_8_mm , 0xf1f8, 0xc108, { 18, 18, 16, 16}}, {m68k_op_and_8_re_ai , 0xf1f8, 0xc110, { 12, 12, 8, 8}}, {m68k_op_and_8_re_pi , 0xf1f8, 0xc118, { 12, 12, 8, 8}}, {m68k_op_and_8_re_pd , 0xf1f8, 0xc120, { 14, 14, 9, 9}}, {m68k_op_and_8_re_di , 0xf1f8, 0xc128, { 16, 16, 9, 9}}, {m68k_op_and_8_re_ix , 0xf1f8, 0xc130, { 18, 18, 11, 11}}, {m68k_op_exg_32_dd , 0xf1f8, 0xc140, { 6, 6, 2, 2}}, {m68k_op_exg_32_aa , 0xf1f8, 0xc148, { 6, 6, 2, 2}}, {m68k_op_and_16_re_ai , 0xf1f8, 0xc150, { 12, 12, 8, 8}}, {m68k_op_and_16_re_pi , 0xf1f8, 0xc158, { 12, 12, 8, 8}}, {m68k_op_and_16_re_pd , 0xf1f8, 0xc160, { 14, 14, 9, 9}}, {m68k_op_and_16_re_di , 0xf1f8, 0xc168, { 16, 16, 9, 9}}, {m68k_op_and_16_re_ix , 0xf1f8, 0xc170, { 18, 18, 11, 11}}, {m68k_op_exg_32_da , 0xf1f8, 0xc188, { 6, 6, 2, 2}}, {m68k_op_and_32_re_ai , 0xf1f8, 0xc190, { 20, 20, 8, 8}}, {m68k_op_and_32_re_pi , 0xf1f8, 0xc198, { 20, 20, 8, 8}}, {m68k_op_and_32_re_pd , 0xf1f8, 0xc1a0, { 22, 22, 9, 9}}, {m68k_op_and_32_re_di , 0xf1f8, 0xc1a8, { 24, 24, 9, 9}}, {m68k_op_and_32_re_ix , 0xf1f8, 0xc1b0, { 26, 26, 11, 11}}, {m68k_op_muls_16_d , 0xf1f8, 0xc1c0, { 0, 32, 27, 27}}, {m68k_op_muls_16_ai , 0xf1f8, 0xc1d0, { 4, 36, 31, 31}}, {m68k_op_muls_16_pi , 0xf1f8, 0xc1d8, { 4, 36, 31, 31}}, {m68k_op_muls_16_pd , 0xf1f8, 0xc1e0, { 6, 38, 32, 32}}, {m68k_op_muls_16_di , 0xf1f8, 0xc1e8, { 8, 40, 32, 32}}, {m68k_op_muls_16_ix , 0xf1f8, 0xc1f0, { 10, 42, 34, 34}}, {m68k_op_add_8_er_d , 0xf1f8, 0xd000, { 4, 4, 2, 2}}, {m68k_op_add_8_er_ai , 0xf1f8, 0xd010, { 8, 8, 6, 6}}, {m68k_op_add_8_er_pi , 0xf1f8, 0xd018, { 8, 8, 6, 6}}, {m68k_op_add_8_er_pd , 0xf1f8, 0xd020, { 10, 10, 7, 7}}, {m68k_op_add_8_er_di , 0xf1f8, 0xd028, { 12, 12, 7, 7}}, {m68k_op_add_8_er_ix , 0xf1f8, 0xd030, { 14, 14, 9, 9}}, {m68k_op_add_16_er_d , 0xf1f8, 0xd040, { 4, 4, 2, 2}}, {m68k_op_add_16_er_a , 0xf1f8, 0xd048, { 4, 4, 2, 2}}, {m68k_op_add_16_er_ai , 0xf1f8, 0xd050, { 8, 8, 6, 6}}, {m68k_op_add_16_er_pi , 0xf1f8, 0xd058, { 8, 8, 6, 6}}, {m68k_op_add_16_er_pd , 0xf1f8, 0xd060, { 10, 10, 7, 7}}, {m68k_op_add_16_er_di , 0xf1f8, 0xd068, { 12, 12, 7, 7}}, {m68k_op_add_16_er_ix , 0xf1f8, 0xd070, { 14, 14, 9, 9}}, {m68k_op_add_32_er_d , 0xf1f8, 0xd080, { 8, 6, 2, 2}}, {m68k_op_add_32_er_a , 0xf1f8, 0xd088, { 8, 6, 2, 2}}, {m68k_op_add_32_er_ai , 0xf1f8, 0xd090, { 14, 14, 6, 6}}, {m68k_op_add_32_er_pi , 0xf1f8, 0xd098, { 14, 14, 6, 6}}, {m68k_op_add_32_er_pd , 0xf1f8, 0xd0a0, { 16, 16, 7, 7}}, {m68k_op_add_32_er_di , 0xf1f8, 0xd0a8, { 18, 18, 7, 7}}, {m68k_op_add_32_er_ix , 0xf1f8, 0xd0b0, { 20, 20, 9, 9}}, {m68k_op_adda_16_d , 0xf1f8, 0xd0c0, { 8, 8, 2, 2}}, {m68k_op_adda_16_a , 0xf1f8, 0xd0c8, { 8, 8, 2, 2}}, {m68k_op_adda_16_ai , 0xf1f8, 0xd0d0, { 12, 12, 6, 6}}, {m68k_op_adda_16_pi , 0xf1f8, 0xd0d8, { 12, 12, 6, 6}}, {m68k_op_adda_16_pd , 0xf1f8, 0xd0e0, { 14, 14, 7, 7}}, {m68k_op_adda_16_di , 0xf1f8, 0xd0e8, { 16, 16, 7, 7}}, {m68k_op_adda_16_ix , 0xf1f8, 0xd0f0, { 18, 18, 9, 9}}, {m68k_op_addx_8_rr , 0xf1f8, 0xd100, { 4, 4, 2, 2}}, {m68k_op_addx_8_mm , 0xf1f8, 0xd108, { 18, 18, 12, 12}}, {m68k_op_add_8_re_ai , 0xf1f8, 0xd110, { 12, 12, 8, 8}}, {m68k_op_add_8_re_pi , 0xf1f8, 0xd118, { 12, 12, 8, 8}}, {m68k_op_add_8_re_pd , 0xf1f8, 0xd120, { 14, 14, 9, 9}}, {m68k_op_add_8_re_di , 0xf1f8, 0xd128, { 16, 16, 9, 9}}, {m68k_op_add_8_re_ix , 0xf1f8, 0xd130, { 18, 18, 11, 11}}, {m68k_op_addx_16_rr , 0xf1f8, 0xd140, { 4, 4, 2, 2}}, {m68k_op_addx_16_mm , 0xf1f8, 0xd148, { 18, 18, 12, 12}}, {m68k_op_add_16_re_ai , 0xf1f8, 0xd150, { 12, 12, 8, 8}}, {m68k_op_add_16_re_pi , 0xf1f8, 0xd158, { 12, 12, 8, 8}}, {m68k_op_add_16_re_pd , 0xf1f8, 0xd160, { 14, 14, 9, 9}}, {m68k_op_add_16_re_di , 0xf1f8, 0xd168, { 16, 16, 9, 9}}, {m68k_op_add_16_re_ix , 0xf1f8, 0xd170, { 18, 18, 11, 11}}, {m68k_op_addx_32_rr , 0xf1f8, 0xd180, { 8, 6, 2, 2}}, {m68k_op_addx_32_mm , 0xf1f8, 0xd188, { 30, 30, 12, 12}}, {m68k_op_add_32_re_ai , 0xf1f8, 0xd190, { 20, 20, 8, 8}}, {m68k_op_add_32_re_pi , 0xf1f8, 0xd198, { 20, 20, 8, 8}}, {m68k_op_add_32_re_pd , 0xf1f8, 0xd1a0, { 22, 22, 9, 9}}, {m68k_op_add_32_re_di , 0xf1f8, 0xd1a8, { 24, 24, 9, 9}}, {m68k_op_add_32_re_ix , 0xf1f8, 0xd1b0, { 26, 26, 11, 11}}, {m68k_op_adda_32_d , 0xf1f8, 0xd1c0, { 8, 6, 2, 2}}, {m68k_op_adda_32_a , 0xf1f8, 0xd1c8, { 8, 6, 2, 2}}, {m68k_op_adda_32_ai , 0xf1f8, 0xd1d0, { 14, 14, 6, 6}}, {m68k_op_adda_32_pi , 0xf1f8, 0xd1d8, { 14, 14, 6, 6}}, {m68k_op_adda_32_pd , 0xf1f8, 0xd1e0, { 16, 16, 7, 7}}, {m68k_op_adda_32_di , 0xf1f8, 0xd1e8, { 18, 18, 7, 7}}, {m68k_op_adda_32_ix , 0xf1f8, 0xd1f0, { 20, 20, 9, 9}}, {m68k_op_asr_8_s , 0xf1f8, 0xe000, { 6, 6, 6, 6}}, {m68k_op_lsr_8_s , 0xf1f8, 0xe008, { 6, 6, 4, 4}}, {m68k_op_roxr_8_s , 0xf1f8, 0xe010, { 6, 6, 12, 12}}, {m68k_op_ror_8_s , 0xf1f8, 0xe018, { 6, 6, 8, 8}}, {m68k_op_asr_8_r , 0xf1f8, 0xe020, { 6, 6, 6, 6}}, {m68k_op_lsr_8_r , 0xf1f8, 0xe028, { 6, 6, 6, 6}}, {m68k_op_roxr_8_r , 0xf1f8, 0xe030, { 6, 6, 12, 12}}, {m68k_op_ror_8_r , 0xf1f8, 0xe038, { 6, 6, 8, 8}}, {m68k_op_asr_16_s , 0xf1f8, 0xe040, { 6, 6, 6, 6}}, {m68k_op_lsr_16_s , 0xf1f8, 0xe048, { 6, 6, 4, 4}}, {m68k_op_roxr_16_s , 0xf1f8, 0xe050, { 6, 6, 12, 12}}, {m68k_op_ror_16_s , 0xf1f8, 0xe058, { 6, 6, 8, 8}}, {m68k_op_asr_16_r , 0xf1f8, 0xe060, { 6, 6, 6, 6}}, {m68k_op_lsr_16_r , 0xf1f8, 0xe068, { 6, 6, 6, 6}}, {m68k_op_roxr_16_r , 0xf1f8, 0xe070, { 6, 6, 12, 12}}, {m68k_op_ror_16_r , 0xf1f8, 0xe078, { 6, 6, 8, 8}}, {m68k_op_asr_32_s , 0xf1f8, 0xe080, { 8, 8, 6, 6}}, {m68k_op_lsr_32_s , 0xf1f8, 0xe088, { 8, 8, 4, 4}}, {m68k_op_roxr_32_s , 0xf1f8, 0xe090, { 8, 8, 12, 12}}, {m68k_op_ror_32_s , 0xf1f8, 0xe098, { 8, 8, 8, 8}}, {m68k_op_asr_32_r , 0xf1f8, 0xe0a0, { 8, 8, 6, 6}}, {m68k_op_lsr_32_r , 0xf1f8, 0xe0a8, { 8, 8, 6, 6}}, {m68k_op_roxr_32_r , 0xf1f8, 0xe0b0, { 8, 8, 12, 12}}, {m68k_op_ror_32_r , 0xf1f8, 0xe0b8, { 8, 8, 8, 8}}, {m68k_op_asl_8_s , 0xf1f8, 0xe100, { 6, 6, 8, 8}}, {m68k_op_lsl_8_s , 0xf1f8, 0xe108, { 6, 6, 4, 4}}, {m68k_op_roxl_8_s , 0xf1f8, 0xe110, { 6, 6, 12, 12}}, {m68k_op_rol_8_s , 0xf1f8, 0xe118, { 6, 6, 8, 8}}, {m68k_op_asl_8_r , 0xf1f8, 0xe120, { 6, 6, 8, 8}}, {m68k_op_lsl_8_r , 0xf1f8, 0xe128, { 6, 6, 6, 6}}, {m68k_op_roxl_8_r , 0xf1f8, 0xe130, { 6, 6, 12, 12}}, {m68k_op_rol_8_r , 0xf1f8, 0xe138, { 6, 6, 8, 8}}, {m68k_op_asl_16_s , 0xf1f8, 0xe140, { 6, 6, 8, 8}}, {m68k_op_lsl_16_s , 0xf1f8, 0xe148, { 6, 6, 4, 4}}, {m68k_op_roxl_16_s , 0xf1f8, 0xe150, { 6, 6, 12, 12}}, {m68k_op_rol_16_s , 0xf1f8, 0xe158, { 6, 6, 8, 8}}, {m68k_op_asl_16_r , 0xf1f8, 0xe160, { 6, 6, 8, 8}}, {m68k_op_lsl_16_r , 0xf1f8, 0xe168, { 6, 6, 6, 6}}, {m68k_op_roxl_16_r , 0xf1f8, 0xe170, { 6, 6, 12, 12}}, {m68k_op_rol_16_r , 0xf1f8, 0xe178, { 6, 6, 8, 8}}, {m68k_op_asl_32_s , 0xf1f8, 0xe180, { 8, 8, 8, 8}}, {m68k_op_lsl_32_s , 0xf1f8, 0xe188, { 8, 8, 4, 4}}, {m68k_op_roxl_32_s , 0xf1f8, 0xe190, { 8, 8, 12, 12}}, {m68k_op_rol_32_s , 0xf1f8, 0xe198, { 8, 8, 8, 8}}, {m68k_op_asl_32_r , 0xf1f8, 0xe1a0, { 8, 8, 8, 8}}, {m68k_op_lsl_32_r , 0xf1f8, 0xe1a8, { 8, 8, 6, 6}}, {m68k_op_roxl_32_r , 0xf1f8, 0xe1b0, { 8, 8, 12, 12}}, {m68k_op_rol_32_r , 0xf1f8, 0xe1b8, { 8, 8, 8, 8}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cpdbcc_32 , 0xf1f8, 0xf048, { 0, 0, 4, 0}}, {m68k_op_cptrapcc_32 , 0xf1f8, 0xf078, { 0, 0, 4, 0}}, {m68k_op_rtm_32 , 0xfff0, 0x06c0, { 0, 0, 19, 19}}, #endif {m68k_op_trap , 0xfff0, 0x4e40, { 4, 4, 4, 4}}, {m68k_op_btst_8_r_pi7 , 0xf1ff, 0x011f, { 8, 8, 8, 8}}, {m68k_op_btst_8_r_pd7 , 0xf1ff, 0x0127, { 10, 10, 9, 9}}, {m68k_op_btst_8_r_aw , 0xf1ff, 0x0138, { 12, 12, 8, 8}}, {m68k_op_btst_8_r_al , 0xf1ff, 0x0139, { 16, 16, 8, 8}}, {m68k_op_btst_8_r_pcdi , 0xf1ff, 0x013a, { 12, 12, 9, 9}}, {m68k_op_btst_8_r_pcix , 0xf1ff, 0x013b, { 14, 14, 11, 11}}, {m68k_op_btst_8_r_i , 0xf1ff, 0x013c, { 8, 8, 6, 6}}, {m68k_op_bchg_8_r_pi7 , 0xf1ff, 0x015f, { 12, 12, 8, 8}}, {m68k_op_bchg_8_r_pd7 , 0xf1ff, 0x0167, { 14, 14, 9, 9}}, {m68k_op_bchg_8_r_aw , 0xf1ff, 0x0178, { 16, 16, 8, 8}}, {m68k_op_bchg_8_r_al , 0xf1ff, 0x0179, { 20, 20, 8, 8}}, {m68k_op_bclr_8_r_pi7 , 0xf1ff, 0x019f, { 12, 14, 8, 8}}, {m68k_op_bclr_8_r_pd7 , 0xf1ff, 0x01a7, { 14, 16, 9, 9}}, {m68k_op_bclr_8_r_aw , 0xf1ff, 0x01b8, { 16, 18, 8, 8}}, {m68k_op_bclr_8_r_al , 0xf1ff, 0x01b9, { 20, 22, 8, 8}}, {m68k_op_bset_8_r_pi7 , 0xf1ff, 0x01df, { 12, 12, 8, 8}}, {m68k_op_bset_8_r_pd7 , 0xf1ff, 0x01e7, { 14, 14, 9, 9}}, {m68k_op_bset_8_r_aw , 0xf1ff, 0x01f8, { 16, 16, 8, 8}}, {m68k_op_bset_8_r_al , 0xf1ff, 0x01f9, { 20, 20, 8, 8}}, {m68k_op_move_8_d_pi7 , 0xf1ff, 0x101f, { 8, 8, 6, 6}}, {m68k_op_move_8_d_pd7 , 0xf1ff, 0x1027, { 10, 10, 7, 7}}, {m68k_op_move_8_d_aw , 0xf1ff, 0x1038, { 12, 12, 6, 6}}, {m68k_op_move_8_d_al , 0xf1ff, 0x1039, { 16, 16, 6, 6}}, {m68k_op_move_8_d_pcdi , 0xf1ff, 0x103a, { 12, 12, 7, 7}}, {m68k_op_move_8_d_pcix , 0xf1ff, 0x103b, { 14, 14, 9, 9}}, {m68k_op_move_8_d_i , 0xf1ff, 0x103c, { 8, 8, 4, 4}}, {m68k_op_move_8_ai_pi7 , 0xf1ff, 0x109f, { 12, 12, 8, 8}}, {m68k_op_move_8_ai_pd7 , 0xf1ff, 0x10a7, { 14, 14, 9, 9}}, {m68k_op_move_8_ai_aw , 0xf1ff, 0x10b8, { 16, 16, 8, 8}}, {m68k_op_move_8_ai_al , 0xf1ff, 0x10b9, { 20, 20, 8, 8}}, {m68k_op_move_8_ai_pcdi , 0xf1ff, 0x10ba, { 16, 16, 9, 9}}, {m68k_op_move_8_ai_pcix , 0xf1ff, 0x10bb, { 18, 18, 11, 11}}, {m68k_op_move_8_ai_i , 0xf1ff, 0x10bc, { 12, 12, 6, 6}}, {m68k_op_move_8_pi_pi7 , 0xf1ff, 0x10df, { 12, 12, 8, 8}}, {m68k_op_move_8_pi_pd7 , 0xf1ff, 0x10e7, { 14, 14, 9, 9}}, {m68k_op_move_8_pi_aw , 0xf1ff, 0x10f8, { 16, 16, 8, 8}}, {m68k_op_move_8_pi_al , 0xf1ff, 0x10f9, { 20, 20, 8, 8}}, {m68k_op_move_8_pi_pcdi , 0xf1ff, 0x10fa, { 16, 16, 9, 9}}, {m68k_op_move_8_pi_pcix , 0xf1ff, 0x10fb, { 18, 18, 11, 11}}, {m68k_op_move_8_pi_i , 0xf1ff, 0x10fc, { 12, 12, 6, 6}}, {m68k_op_move_8_pd_pi7 , 0xf1ff, 0x111f, { 12, 12, 9, 9}}, {m68k_op_move_8_pd_pd7 , 0xf1ff, 0x1127, { 14, 14, 10, 10}}, {m68k_op_move_8_pd_aw , 0xf1ff, 0x1138, { 16, 16, 9, 9}}, {m68k_op_move_8_pd_al , 0xf1ff, 0x1139, { 20, 20, 9, 9}}, {m68k_op_move_8_pd_pcdi , 0xf1ff, 0x113a, { 16, 16, 10, 10}}, {m68k_op_move_8_pd_pcix , 0xf1ff, 0x113b, { 18, 18, 12, 12}}, {m68k_op_move_8_pd_i , 0xf1ff, 0x113c, { 12, 12, 7, 7}}, {m68k_op_move_8_di_pi7 , 0xf1ff, 0x115f, { 16, 16, 9, 9}}, {m68k_op_move_8_di_pd7 , 0xf1ff, 0x1167, { 18, 18, 10, 10}}, {m68k_op_move_8_di_aw , 0xf1ff, 0x1178, { 20, 20, 9, 9}}, {m68k_op_move_8_di_al , 0xf1ff, 0x1179, { 24, 24, 9, 9}}, {m68k_op_move_8_di_pcdi , 0xf1ff, 0x117a, { 20, 20, 10, 10}}, {m68k_op_move_8_di_pcix , 0xf1ff, 0x117b, { 22, 22, 12, 12}}, {m68k_op_move_8_di_i , 0xf1ff, 0x117c, { 16, 16, 7, 7}}, {m68k_op_move_8_ix_pi7 , 0xf1ff, 0x119f, { 18, 18, 11, 11}}, {m68k_op_move_8_ix_pd7 , 0xf1ff, 0x11a7, { 20, 20, 12, 12}}, {m68k_op_move_8_ix_aw , 0xf1ff, 0x11b8, { 22, 22, 11, 11}}, {m68k_op_move_8_ix_al , 0xf1ff, 0x11b9, { 26, 26, 11, 11}}, {m68k_op_move_8_ix_pcdi , 0xf1ff, 0x11ba, { 22, 22, 12, 12}}, {m68k_op_move_8_ix_pcix , 0xf1ff, 0x11bb, { 24, 24, 14, 14}}, {m68k_op_move_8_ix_i , 0xf1ff, 0x11bc, { 18, 18, 9, 9}}, {m68k_op_move_32_d_aw , 0xf1ff, 0x2038, { 16, 16, 6, 6}}, {m68k_op_move_32_d_al , 0xf1ff, 0x2039, { 20, 20, 6, 6}}, {m68k_op_move_32_d_pcdi , 0xf1ff, 0x203a, { 16, 16, 7, 7}}, {m68k_op_move_32_d_pcix , 0xf1ff, 0x203b, { 18, 18, 9, 9}}, {m68k_op_move_32_d_i , 0xf1ff, 0x203c, { 12, 12, 6, 6}}, {m68k_op_movea_32_aw , 0xf1ff, 0x2078, { 16, 16, 6, 6}}, {m68k_op_movea_32_al , 0xf1ff, 0x2079, { 20, 20, 6, 6}}, {m68k_op_movea_32_pcdi , 0xf1ff, 0x207a, { 16, 16, 7, 7}}, {m68k_op_movea_32_pcix , 0xf1ff, 0x207b, { 18, 18, 9, 9}}, {m68k_op_movea_32_i , 0xf1ff, 0x207c, { 12, 12, 6, 6}}, {m68k_op_move_32_ai_aw , 0xf1ff, 0x20b8, { 24, 24, 8, 8}}, {m68k_op_move_32_ai_al , 0xf1ff, 0x20b9, { 28, 28, 8, 8}}, {m68k_op_move_32_ai_pcdi , 0xf1ff, 0x20ba, { 24, 24, 9, 9}}, {m68k_op_move_32_ai_pcix , 0xf1ff, 0x20bb, { 26, 26, 11, 11}}, {m68k_op_move_32_ai_i , 0xf1ff, 0x20bc, { 20, 20, 8, 8}}, {m68k_op_move_32_pi_aw , 0xf1ff, 0x20f8, { 24, 24, 8, 8}}, {m68k_op_move_32_pi_al , 0xf1ff, 0x20f9, { 28, 28, 8, 8}}, {m68k_op_move_32_pi_pcdi , 0xf1ff, 0x20fa, { 24, 24, 9, 9}}, {m68k_op_move_32_pi_pcix , 0xf1ff, 0x20fb, { 26, 26, 11, 11}}, {m68k_op_move_32_pi_i , 0xf1ff, 0x20fc, { 20, 20, 8, 8}}, {m68k_op_move_32_pd_aw , 0xf1ff, 0x2138, { 24, 26, 9, 9}}, {m68k_op_move_32_pd_al , 0xf1ff, 0x2139, { 28, 30, 9, 9}}, {m68k_op_move_32_pd_pcdi , 0xf1ff, 0x213a, { 24, 26, 10, 10}}, {m68k_op_move_32_pd_pcix , 0xf1ff, 0x213b, { 26, 28, 12, 12}}, {m68k_op_move_32_pd_i , 0xf1ff, 0x213c, { 20, 22, 9, 9}}, {m68k_op_move_32_di_aw , 0xf1ff, 0x2178, { 28, 28, 9, 9}}, {m68k_op_move_32_di_al , 0xf1ff, 0x2179, { 32, 32, 9, 9}}, {m68k_op_move_32_di_pcdi , 0xf1ff, 0x217a, { 28, 28, 10, 10}}, {m68k_op_move_32_di_pcix , 0xf1ff, 0x217b, { 30, 30, 12, 12}}, {m68k_op_move_32_di_i , 0xf1ff, 0x217c, { 24, 24, 9, 9}}, {m68k_op_move_32_ix_aw , 0xf1ff, 0x21b8, { 30, 30, 11, 11}}, {m68k_op_move_32_ix_al , 0xf1ff, 0x21b9, { 34, 34, 11, 11}}, {m68k_op_move_32_ix_pcdi , 0xf1ff, 0x21ba, { 30, 30, 12, 12}}, {m68k_op_move_32_ix_pcix , 0xf1ff, 0x21bb, { 32, 32, 14, 14}}, {m68k_op_move_32_ix_i , 0xf1ff, 0x21bc, { 26, 26, 11, 11}}, {m68k_op_move_16_d_aw , 0xf1ff, 0x3038, { 12, 12, 6, 6}}, {m68k_op_move_16_d_al , 0xf1ff, 0x3039, { 16, 16, 6, 6}}, {m68k_op_move_16_d_pcdi , 0xf1ff, 0x303a, { 12, 12, 7, 7}}, {m68k_op_move_16_d_pcix , 0xf1ff, 0x303b, { 14, 14, 9, 9}}, {m68k_op_move_16_d_i , 0xf1ff, 0x303c, { 8, 8, 4, 4}}, {m68k_op_movea_16_aw , 0xf1ff, 0x3078, { 12, 12, 6, 6}}, {m68k_op_movea_16_al , 0xf1ff, 0x3079, { 16, 16, 6, 6}}, {m68k_op_movea_16_pcdi , 0xf1ff, 0x307a, { 12, 12, 7, 7}}, {m68k_op_movea_16_pcix , 0xf1ff, 0x307b, { 14, 14, 9, 9}}, {m68k_op_movea_16_i , 0xf1ff, 0x307c, { 8, 8, 4, 4}}, {m68k_op_move_16_ai_aw , 0xf1ff, 0x30b8, { 16, 16, 8, 8}}, {m68k_op_move_16_ai_al , 0xf1ff, 0x30b9, { 20, 20, 8, 8}}, {m68k_op_move_16_ai_pcdi , 0xf1ff, 0x30ba, { 16, 16, 9, 9}}, {m68k_op_move_16_ai_pcix , 0xf1ff, 0x30bb, { 18, 18, 11, 11}}, {m68k_op_move_16_ai_i , 0xf1ff, 0x30bc, { 12, 12, 6, 6}}, {m68k_op_move_16_pi_aw , 0xf1ff, 0x30f8, { 16, 16, 8, 8}}, {m68k_op_move_16_pi_al , 0xf1ff, 0x30f9, { 20, 20, 8, 8}}, {m68k_op_move_16_pi_pcdi , 0xf1ff, 0x30fa, { 16, 16, 9, 9}}, {m68k_op_move_16_pi_pcix , 0xf1ff, 0x30fb, { 18, 18, 11, 11}}, {m68k_op_move_16_pi_i , 0xf1ff, 0x30fc, { 12, 12, 6, 6}}, {m68k_op_move_16_pd_aw , 0xf1ff, 0x3138, { 16, 16, 9, 9}}, {m68k_op_move_16_pd_al , 0xf1ff, 0x3139, { 20, 20, 9, 9}}, {m68k_op_move_16_pd_pcdi , 0xf1ff, 0x313a, { 16, 16, 10, 10}}, {m68k_op_move_16_pd_pcix , 0xf1ff, 0x313b, { 18, 18, 12, 12}}, {m68k_op_move_16_pd_i , 0xf1ff, 0x313c, { 12, 12, 7, 7}}, {m68k_op_move_16_di_aw , 0xf1ff, 0x3178, { 20, 20, 9, 9}}, {m68k_op_move_16_di_al , 0xf1ff, 0x3179, { 24, 24, 9, 9}}, {m68k_op_move_16_di_pcdi , 0xf1ff, 0x317a, { 20, 20, 10, 10}}, {m68k_op_move_16_di_pcix , 0xf1ff, 0x317b, { 22, 22, 12, 12}}, {m68k_op_move_16_di_i , 0xf1ff, 0x317c, { 16, 16, 7, 7}}, {m68k_op_move_16_ix_aw , 0xf1ff, 0x31b8, { 22, 22, 11, 11}}, {m68k_op_move_16_ix_al , 0xf1ff, 0x31b9, { 26, 26, 11, 11}}, {m68k_op_move_16_ix_pcdi , 0xf1ff, 0x31ba, { 22, 22, 12, 12}}, {m68k_op_move_16_ix_pcix , 0xf1ff, 0x31bb, { 24, 24, 14, 14}}, {m68k_op_move_16_ix_i , 0xf1ff, 0x31bc, { 18, 18, 9, 9}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_chk_32_aw , 0xf1ff, 0x4138, { 0, 0, 12, 12}}, {m68k_op_chk_32_al , 0xf1ff, 0x4139, { 0, 0, 12, 12}}, {m68k_op_chk_32_pcdi , 0xf1ff, 0x413a, { 0, 0, 13, 13}}, {m68k_op_chk_32_pcix , 0xf1ff, 0x413b, { 0, 0, 15, 15}}, {m68k_op_chk_32_i , 0xf1ff, 0x413c, { 0, 0, 12, 12}}, #endif {m68k_op_chk_16_aw , 0xf1ff, 0x41b8, { 18, 16, 12, 12}}, {m68k_op_chk_16_al , 0xf1ff, 0x41b9, { 22, 20, 12, 12}}, {m68k_op_chk_16_pcdi , 0xf1ff, 0x41ba, { 18, 16, 13, 13}}, {m68k_op_chk_16_pcix , 0xf1ff, 0x41bb, { 20, 18, 15, 15}}, {m68k_op_chk_16_i , 0xf1ff, 0x41bc, { 14, 12, 10, 10}}, {m68k_op_lea_32_aw , 0xf1ff, 0x41f8, { 8, 8, 6, 6}}, {m68k_op_lea_32_al , 0xf1ff, 0x41f9, { 12, 12, 6, 6}}, {m68k_op_lea_32_pcdi , 0xf1ff, 0x41fa, { 8, 8, 7, 7}}, {m68k_op_lea_32_pcix , 0xf1ff, 0x41fb, { 12, 12, 9, 9}}, {m68k_op_addq_8_pi7 , 0xf1ff, 0x501f, { 12, 12, 8, 8}}, {m68k_op_addq_8_pd7 , 0xf1ff, 0x5027, { 14, 14, 9, 9}}, {m68k_op_addq_8_aw , 0xf1ff, 0x5038, { 16, 16, 8, 8}}, {m68k_op_addq_8_al , 0xf1ff, 0x5039, { 20, 20, 8, 8}}, {m68k_op_addq_16_aw , 0xf1ff, 0x5078, { 16, 16, 8, 8}}, {m68k_op_addq_16_al , 0xf1ff, 0x5079, { 20, 20, 8, 8}}, {m68k_op_addq_32_aw , 0xf1ff, 0x50b8, { 24, 24, 8, 8}}, {m68k_op_addq_32_al , 0xf1ff, 0x50b9, { 28, 28, 8, 8}}, {m68k_op_subq_8_pi7 , 0xf1ff, 0x511f, { 12, 12, 8, 8}}, {m68k_op_subq_8_pd7 , 0xf1ff, 0x5127, { 14, 14, 9, 9}}, {m68k_op_subq_8_aw , 0xf1ff, 0x5138, { 16, 16, 8, 8}}, {m68k_op_subq_8_al , 0xf1ff, 0x5139, { 20, 20, 8, 8}}, {m68k_op_subq_16_aw , 0xf1ff, 0x5178, { 16, 16, 8, 8}}, {m68k_op_subq_16_al , 0xf1ff, 0x5179, { 20, 20, 8, 8}}, {m68k_op_subq_32_aw , 0xf1ff, 0x51b8, { 24, 24, 8, 8}}, {m68k_op_subq_32_al , 0xf1ff, 0x51b9, { 28, 28, 8, 8}}, {m68k_op_or_8_er_pi7 , 0xf1ff, 0x801f, { 8, 8, 6, 6}}, {m68k_op_or_8_er_pd7 , 0xf1ff, 0x8027, { 10, 10, 7, 7}}, {m68k_op_or_8_er_aw , 0xf1ff, 0x8038, { 12, 12, 6, 6}}, {m68k_op_or_8_er_al , 0xf1ff, 0x8039, { 16, 16, 6, 6}}, {m68k_op_or_8_er_pcdi , 0xf1ff, 0x803a, { 12, 12, 7, 7}}, {m68k_op_or_8_er_pcix , 0xf1ff, 0x803b, { 14, 14, 9, 9}}, {m68k_op_or_8_er_i , 0xf1ff, 0x803c, { 8, 8, 4, 4}}, {m68k_op_or_16_er_aw , 0xf1ff, 0x8078, { 12, 12, 6, 6}}, {m68k_op_or_16_er_al , 0xf1ff, 0x8079, { 16, 16, 6, 6}}, {m68k_op_or_16_er_pcdi , 0xf1ff, 0x807a, { 12, 12, 7, 7}}, {m68k_op_or_16_er_pcix , 0xf1ff, 0x807b, { 14, 14, 9, 9}}, {m68k_op_or_16_er_i , 0xf1ff, 0x807c, { 8, 8, 4, 4}}, {m68k_op_or_32_er_aw , 0xf1ff, 0x80b8, { 18, 18, 6, 6}}, {m68k_op_or_32_er_al , 0xf1ff, 0x80b9, { 22, 22, 6, 6}}, {m68k_op_or_32_er_pcdi , 0xf1ff, 0x80ba, { 18, 18, 7, 7}}, {m68k_op_or_32_er_pcix , 0xf1ff, 0x80bb, { 20, 20, 9, 9}}, {m68k_op_or_32_er_i , 0xf1ff, 0x80bc, { 16, 14, 6, 6}}, {m68k_op_divu_16_aw , 0xf1ff, 0x80f8, { 8, 116, 48, 48}}, {m68k_op_divu_16_al , 0xf1ff, 0x80f9, { 12, 120, 48, 48}}, {m68k_op_divu_16_pcdi , 0xf1ff, 0x80fa, { 8, 116, 49, 49}}, {m68k_op_divu_16_pcix , 0xf1ff, 0x80fb, { 10, 118, 51, 51}}, {m68k_op_divu_16_i , 0xf1ff, 0x80fc, { 4, 112, 46, 46}}, {m68k_op_sbcd_8_mm_ay7 , 0xf1ff, 0x810f, { 18, 18, 16, 16}}, {m68k_op_or_8_re_pi7 , 0xf1ff, 0x811f, { 12, 12, 8, 8}}, {m68k_op_or_8_re_pd7 , 0xf1ff, 0x8127, { 14, 14, 9, 9}}, {m68k_op_or_8_re_aw , 0xf1ff, 0x8138, { 16, 16, 8, 8}}, {m68k_op_or_8_re_al , 0xf1ff, 0x8139, { 20, 20, 8, 8}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_pack_16_mm_ay7 , 0xf1ff, 0x814f, { 0, 0, 13, 13}}, #endif {m68k_op_or_16_re_aw , 0xf1ff, 0x8178, { 16, 16, 8, 8}}, {m68k_op_or_16_re_al , 0xf1ff, 0x8179, { 20, 20, 8, 8}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_unpk_16_mm_ay7 , 0xf1ff, 0x818f, { 0, 0, 13, 13}}, #endif {m68k_op_or_32_re_aw , 0xf1ff, 0x81b8, { 24, 24, 8, 8}}, {m68k_op_or_32_re_al , 0xf1ff, 0x81b9, { 28, 28, 8, 8}}, {m68k_op_divs_16_aw , 0xf1ff, 0x81f8, { 8, 130, 60, 60}}, {m68k_op_divs_16_al , 0xf1ff, 0x81f9, { 12, 134, 60, 60}}, {m68k_op_divs_16_pcdi , 0xf1ff, 0x81fa, { 8, 130, 61, 61}}, {m68k_op_divs_16_pcix , 0xf1ff, 0x81fb, { 10, 132, 63, 63}}, {m68k_op_divs_16_i , 0xf1ff, 0x81fc, { 4, 126, 58, 58}}, {m68k_op_sub_8_er_pi7 , 0xf1ff, 0x901f, { 8, 8, 6, 6}}, {m68k_op_sub_8_er_pd7 , 0xf1ff, 0x9027, { 10, 10, 7, 7}}, {m68k_op_sub_8_er_aw , 0xf1ff, 0x9038, { 12, 12, 6, 6}}, {m68k_op_sub_8_er_al , 0xf1ff, 0x9039, { 16, 16, 6, 6}}, {m68k_op_sub_8_er_pcdi , 0xf1ff, 0x903a, { 12, 12, 7, 7}}, {m68k_op_sub_8_er_pcix , 0xf1ff, 0x903b, { 14, 14, 9, 9}}, {m68k_op_sub_8_er_i , 0xf1ff, 0x903c, { 8, 8, 4, 4}}, {m68k_op_sub_16_er_aw , 0xf1ff, 0x9078, { 12, 12, 6, 6}}, {m68k_op_sub_16_er_al , 0xf1ff, 0x9079, { 16, 16, 6, 6}}, {m68k_op_sub_16_er_pcdi , 0xf1ff, 0x907a, { 12, 12, 7, 7}}, {m68k_op_sub_16_er_pcix , 0xf1ff, 0x907b, { 14, 14, 9, 9}}, {m68k_op_sub_16_er_i , 0xf1ff, 0x907c, { 8, 8, 4, 4}}, {m68k_op_sub_32_er_aw , 0xf1ff, 0x90b8, { 18, 18, 6, 6}}, {m68k_op_sub_32_er_al , 0xf1ff, 0x90b9, { 22, 22, 6, 6}}, {m68k_op_sub_32_er_pcdi , 0xf1ff, 0x90ba, { 18, 18, 7, 7}}, {m68k_op_sub_32_er_pcix , 0xf1ff, 0x90bb, { 20, 20, 9, 9}}, {m68k_op_sub_32_er_i , 0xf1ff, 0x90bc, { 16, 14, 6, 6}}, {m68k_op_suba_16_aw , 0xf1ff, 0x90f8, { 16, 16, 6, 6}}, {m68k_op_suba_16_al , 0xf1ff, 0x90f9, { 20, 20, 6, 6}}, {m68k_op_suba_16_pcdi , 0xf1ff, 0x90fa, { 16, 16, 7, 7}}, {m68k_op_suba_16_pcix , 0xf1ff, 0x90fb, { 18, 18, 9, 9}}, {m68k_op_suba_16_i , 0xf1ff, 0x90fc, { 12, 12, 4, 4}}, {m68k_op_subx_8_mm_ay7 , 0xf1ff, 0x910f, { 18, 18, 12, 12}}, {m68k_op_sub_8_re_pi7 , 0xf1ff, 0x911f, { 12, 12, 8, 8}}, {m68k_op_sub_8_re_pd7 , 0xf1ff, 0x9127, { 14, 14, 9, 9}}, {m68k_op_sub_8_re_aw , 0xf1ff, 0x9138, { 16, 16, 8, 8}}, {m68k_op_sub_8_re_al , 0xf1ff, 0x9139, { 20, 20, 8, 8}}, {m68k_op_sub_16_re_aw , 0xf1ff, 0x9178, { 16, 16, 8, 8}}, {m68k_op_sub_16_re_al , 0xf1ff, 0x9179, { 20, 20, 8, 8}}, {m68k_op_sub_32_re_aw , 0xf1ff, 0x91b8, { 24, 24, 8, 8}}, {m68k_op_sub_32_re_al , 0xf1ff, 0x91b9, { 28, 28, 8, 8}}, {m68k_op_suba_32_aw , 0xf1ff, 0x91f8, { 18, 18, 6, 6}}, {m68k_op_suba_32_al , 0xf1ff, 0x91f9, { 22, 22, 6, 6}}, {m68k_op_suba_32_pcdi , 0xf1ff, 0x91fa, { 18, 18, 7, 7}}, {m68k_op_suba_32_pcix , 0xf1ff, 0x91fb, { 20, 20, 9, 9}}, {m68k_op_suba_32_i , 0xf1ff, 0x91fc, { 16, 14, 6, 6}}, {m68k_op_cmp_8_pi7 , 0xf1ff, 0xb01f, { 8, 8, 6, 6}}, {m68k_op_cmp_8_pd7 , 0xf1ff, 0xb027, { 10, 10, 7, 7}}, {m68k_op_cmp_8_aw , 0xf1ff, 0xb038, { 12, 12, 6, 6}}, {m68k_op_cmp_8_al , 0xf1ff, 0xb039, { 16, 16, 6, 6}}, {m68k_op_cmp_8_pcdi , 0xf1ff, 0xb03a, { 12, 12, 7, 7}}, {m68k_op_cmp_8_pcix , 0xf1ff, 0xb03b, { 14, 14, 9, 9}}, {m68k_op_cmp_8_i , 0xf1ff, 0xb03c, { 8, 8, 4, 4}}, {m68k_op_cmp_16_aw , 0xf1ff, 0xb078, { 12, 12, 6, 6}}, {m68k_op_cmp_16_al , 0xf1ff, 0xb079, { 16, 16, 6, 6}}, {m68k_op_cmp_16_pcdi , 0xf1ff, 0xb07a, { 12, 12, 7, 7}}, {m68k_op_cmp_16_pcix , 0xf1ff, 0xb07b, { 14, 14, 9, 9}}, {m68k_op_cmp_16_i , 0xf1ff, 0xb07c, { 8, 8, 4, 4}}, {m68k_op_cmp_32_aw , 0xf1ff, 0xb0b8, { 18, 18, 6, 6}}, {m68k_op_cmp_32_al , 0xf1ff, 0xb0b9, { 22, 22, 6, 6}}, {m68k_op_cmp_32_pcdi , 0xf1ff, 0xb0ba, { 18, 18, 7, 7}}, {m68k_op_cmp_32_pcix , 0xf1ff, 0xb0bb, { 20, 20, 9, 9}}, {m68k_op_cmp_32_i , 0xf1ff, 0xb0bc, { 14, 14, 6, 6}}, {m68k_op_cmpa_16_aw , 0xf1ff, 0xb0f8, { 14, 14, 8, 8}}, {m68k_op_cmpa_16_al , 0xf1ff, 0xb0f9, { 18, 18, 8, 8}}, {m68k_op_cmpa_16_pcdi , 0xf1ff, 0xb0fa, { 14, 14, 9, 9}}, {m68k_op_cmpa_16_pcix , 0xf1ff, 0xb0fb, { 16, 16, 11, 11}}, {m68k_op_cmpa_16_i , 0xf1ff, 0xb0fc, { 10, 10, 6, 6}}, {m68k_op_cmpm_8_ay7 , 0xf1ff, 0xb10f, { 12, 12, 9, 9}}, {m68k_op_eor_8_pi7 , 0xf1ff, 0xb11f, { 12, 12, 8, 8}}, {m68k_op_eor_8_pd7 , 0xf1ff, 0xb127, { 14, 14, 9, 9}}, {m68k_op_eor_8_aw , 0xf1ff, 0xb138, { 16, 16, 8, 8}}, {m68k_op_eor_8_al , 0xf1ff, 0xb139, { 20, 20, 8, 8}}, {m68k_op_eor_16_aw , 0xf1ff, 0xb178, { 16, 16, 8, 8}}, {m68k_op_eor_16_al , 0xf1ff, 0xb179, { 20, 20, 8, 8}}, {m68k_op_eor_32_aw , 0xf1ff, 0xb1b8, { 24, 24, 8, 8}}, {m68k_op_eor_32_al , 0xf1ff, 0xb1b9, { 28, 28, 8, 8}}, {m68k_op_cmpa_32_aw , 0xf1ff, 0xb1f8, { 18, 18, 8, 8}}, {m68k_op_cmpa_32_al , 0xf1ff, 0xb1f9, { 22, 22, 8, 8}}, {m68k_op_cmpa_32_pcdi , 0xf1ff, 0xb1fa, { 18, 18, 9, 9}}, {m68k_op_cmpa_32_pcix , 0xf1ff, 0xb1fb, { 20, 20, 11, 11}}, {m68k_op_cmpa_32_i , 0xf1ff, 0xb1fc, { 14, 14, 8, 8}}, {m68k_op_and_8_er_pi7 , 0xf1ff, 0xc01f, { 8, 8, 6, 6}}, {m68k_op_and_8_er_pd7 , 0xf1ff, 0xc027, { 10, 10, 7, 7}}, {m68k_op_and_8_er_aw , 0xf1ff, 0xc038, { 12, 12, 6, 6}}, {m68k_op_and_8_er_al , 0xf1ff, 0xc039, { 16, 16, 6, 6}}, {m68k_op_and_8_er_pcdi , 0xf1ff, 0xc03a, { 12, 12, 7, 7}}, {m68k_op_and_8_er_pcix , 0xf1ff, 0xc03b, { 14, 14, 9, 9}}, {m68k_op_and_8_er_i , 0xf1ff, 0xc03c, { 8, 8, 4, 4}}, {m68k_op_and_16_er_aw , 0xf1ff, 0xc078, { 12, 12, 6, 6}}, {m68k_op_and_16_er_al , 0xf1ff, 0xc079, { 16, 16, 6, 6}}, {m68k_op_and_16_er_pcdi , 0xf1ff, 0xc07a, { 12, 12, 7, 7}}, {m68k_op_and_16_er_pcix , 0xf1ff, 0xc07b, { 14, 14, 9, 9}}, {m68k_op_and_16_er_i , 0xf1ff, 0xc07c, { 8, 8, 4, 4}}, {m68k_op_and_32_er_aw , 0xf1ff, 0xc0b8, { 18, 18, 6, 6}}, {m68k_op_and_32_er_al , 0xf1ff, 0xc0b9, { 22, 22, 6, 6}}, {m68k_op_and_32_er_pcdi , 0xf1ff, 0xc0ba, { 18, 18, 7, 7}}, {m68k_op_and_32_er_pcix , 0xf1ff, 0xc0bb, { 20, 20, 9, 9}}, {m68k_op_and_32_er_i , 0xf1ff, 0xc0bc, { 16, 14, 6, 6}}, {m68k_op_mulu_16_aw , 0xf1ff, 0xc0f8, { 8, 38, 31, 31}}, {m68k_op_mulu_16_al , 0xf1ff, 0xc0f9, { 12, 42, 31, 31}}, {m68k_op_mulu_16_pcdi , 0xf1ff, 0xc0fa, { 8, 38, 32, 32}}, {m68k_op_mulu_16_pcix , 0xf1ff, 0xc0fb, { 10, 40, 34, 34}}, {m68k_op_mulu_16_i , 0xf1ff, 0xc0fc, { 4, 34, 29, 29}}, {m68k_op_abcd_8_mm_ay7 , 0xf1ff, 0xc10f, { 18, 18, 16, 16}}, {m68k_op_and_8_re_pi7 , 0xf1ff, 0xc11f, { 12, 12, 8, 8}}, {m68k_op_and_8_re_pd7 , 0xf1ff, 0xc127, { 14, 14, 9, 9}}, {m68k_op_and_8_re_aw , 0xf1ff, 0xc138, { 16, 16, 8, 8}}, {m68k_op_and_8_re_al , 0xf1ff, 0xc139, { 20, 20, 8, 8}}, {m68k_op_and_16_re_aw , 0xf1ff, 0xc178, { 16, 16, 8, 8}}, {m68k_op_and_16_re_al , 0xf1ff, 0xc179, { 20, 20, 8, 8}}, {m68k_op_and_32_re_aw , 0xf1ff, 0xc1b8, { 24, 24, 8, 8}}, {m68k_op_and_32_re_al , 0xf1ff, 0xc1b9, { 28, 28, 8, 8}}, {m68k_op_muls_16_aw , 0xf1ff, 0xc1f8, { 8, 40, 31, 31}}, {m68k_op_muls_16_al , 0xf1ff, 0xc1f9, { 12, 44, 31, 31}}, {m68k_op_muls_16_pcdi , 0xf1ff, 0xc1fa, { 8, 40, 32, 32}}, {m68k_op_muls_16_pcix , 0xf1ff, 0xc1fb, { 10, 42, 34, 34}}, {m68k_op_muls_16_i , 0xf1ff, 0xc1fc, { 4, 36, 29, 29}}, {m68k_op_add_8_er_pi7 , 0xf1ff, 0xd01f, { 8, 8, 6, 6}}, {m68k_op_add_8_er_pd7 , 0xf1ff, 0xd027, { 10, 10, 7, 7}}, {m68k_op_add_8_er_aw , 0xf1ff, 0xd038, { 12, 12, 6, 6}}, {m68k_op_add_8_er_al , 0xf1ff, 0xd039, { 16, 16, 6, 6}}, {m68k_op_add_8_er_pcdi , 0xf1ff, 0xd03a, { 12, 12, 7, 7}}, {m68k_op_add_8_er_pcix , 0xf1ff, 0xd03b, { 14, 14, 9, 9}}, {m68k_op_add_8_er_i , 0xf1ff, 0xd03c, { 8, 8, 4, 4}}, {m68k_op_add_16_er_aw , 0xf1ff, 0xd078, { 12, 12, 6, 6}}, {m68k_op_add_16_er_al , 0xf1ff, 0xd079, { 16, 16, 6, 6}}, {m68k_op_add_16_er_pcdi , 0xf1ff, 0xd07a, { 12, 12, 7, 7}}, {m68k_op_add_16_er_pcix , 0xf1ff, 0xd07b, { 14, 14, 9, 9}}, {m68k_op_add_16_er_i , 0xf1ff, 0xd07c, { 8, 8, 4, 4}}, {m68k_op_add_32_er_aw , 0xf1ff, 0xd0b8, { 18, 18, 6, 6}}, {m68k_op_add_32_er_al , 0xf1ff, 0xd0b9, { 22, 22, 6, 6}}, {m68k_op_add_32_er_pcdi , 0xf1ff, 0xd0ba, { 18, 18, 7, 7}}, {m68k_op_add_32_er_pcix , 0xf1ff, 0xd0bb, { 20, 20, 9, 9}}, {m68k_op_add_32_er_i , 0xf1ff, 0xd0bc, { 16, 14, 6, 6}}, {m68k_op_adda_16_aw , 0xf1ff, 0xd0f8, { 16, 16, 6, 6}}, {m68k_op_adda_16_al , 0xf1ff, 0xd0f9, { 20, 20, 6, 6}}, {m68k_op_adda_16_pcdi , 0xf1ff, 0xd0fa, { 16, 16, 7, 7}}, {m68k_op_adda_16_pcix , 0xf1ff, 0xd0fb, { 18, 18, 9, 9}}, {m68k_op_adda_16_i , 0xf1ff, 0xd0fc, { 12, 12, 4, 4}}, {m68k_op_addx_8_mm_ay7 , 0xf1ff, 0xd10f, { 18, 18, 12, 12}}, {m68k_op_add_8_re_pi7 , 0xf1ff, 0xd11f, { 12, 12, 8, 8}}, {m68k_op_add_8_re_pd7 , 0xf1ff, 0xd127, { 14, 14, 9, 9}}, {m68k_op_add_8_re_aw , 0xf1ff, 0xd138, { 16, 16, 8, 8}}, {m68k_op_add_8_re_al , 0xf1ff, 0xd139, { 20, 20, 8, 8}}, {m68k_op_add_16_re_aw , 0xf1ff, 0xd178, { 16, 16, 8, 8}}, {m68k_op_add_16_re_al , 0xf1ff, 0xd179, { 20, 20, 8, 8}}, {m68k_op_add_32_re_aw , 0xf1ff, 0xd1b8, { 24, 24, 8, 8}}, {m68k_op_add_32_re_al , 0xf1ff, 0xd1b9, { 28, 28, 8, 8}}, {m68k_op_adda_32_aw , 0xf1ff, 0xd1f8, { 18, 18, 6, 6}}, {m68k_op_adda_32_al , 0xf1ff, 0xd1f9, { 22, 22, 6, 6}}, {m68k_op_adda_32_pcdi , 0xf1ff, 0xd1fa, { 18, 18, 7, 7}}, {m68k_op_adda_32_pcix , 0xf1ff, 0xd1fb, { 20, 20, 9, 9}}, {m68k_op_adda_32_i , 0xf1ff, 0xd1fc, { 16, 14, 6, 6}}, {m68k_op_ori_8_d , 0xfff8, 0x0000, { 8, 8, 2, 2}}, {m68k_op_ori_8_ai , 0xfff8, 0x0010, { 16, 16, 8, 8}}, {m68k_op_ori_8_pi , 0xfff8, 0x0018, { 16, 16, 8, 8}}, {m68k_op_ori_8_pd , 0xfff8, 0x0020, { 18, 18, 9, 9}}, {m68k_op_ori_8_di , 0xfff8, 0x0028, { 20, 20, 9, 9}}, {m68k_op_ori_8_ix , 0xfff8, 0x0030, { 22, 22, 11, 11}}, {m68k_op_ori_16_d , 0xfff8, 0x0040, { 8, 8, 2, 2}}, {m68k_op_ori_16_ai , 0xfff8, 0x0050, { 16, 16, 8, 8}}, {m68k_op_ori_16_pi , 0xfff8, 0x0058, { 16, 16, 8, 8}}, {m68k_op_ori_16_pd , 0xfff8, 0x0060, { 18, 18, 9, 9}}, {m68k_op_ori_16_di , 0xfff8, 0x0068, { 20, 20, 9, 9}}, {m68k_op_ori_16_ix , 0xfff8, 0x0070, { 22, 22, 11, 11}}, {m68k_op_ori_32_d , 0xfff8, 0x0080, { 16, 14, 2, 2}}, {m68k_op_ori_32_ai , 0xfff8, 0x0090, { 28, 28, 8, 8}}, {m68k_op_ori_32_pi , 0xfff8, 0x0098, { 28, 28, 8, 8}}, {m68k_op_ori_32_pd , 0xfff8, 0x00a0, { 30, 30, 9, 9}}, {m68k_op_ori_32_di , 0xfff8, 0x00a8, { 32, 32, 9, 9}}, {m68k_op_ori_32_ix , 0xfff8, 0x00b0, { 34, 34, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_chk2cmp2_8_ai , 0xfff8, 0x00d0, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_8_di , 0xfff8, 0x00e8, { 0, 0, 23, 23}}, {m68k_op_chk2cmp2_8_ix , 0xfff8, 0x00f0, { 0, 0, 25, 25}}, #endif {m68k_op_andi_8_d , 0xfff8, 0x0200, { 8, 8, 2, 2}}, {m68k_op_andi_8_ai , 0xfff8, 0x0210, { 16, 16, 8, 8}}, {m68k_op_andi_8_pi , 0xfff8, 0x0218, { 16, 16, 8, 8}}, {m68k_op_andi_8_pd , 0xfff8, 0x0220, { 18, 18, 9, 9}}, {m68k_op_andi_8_di , 0xfff8, 0x0228, { 20, 20, 9, 9}}, {m68k_op_andi_8_ix , 0xfff8, 0x0230, { 22, 22, 11, 11}}, {m68k_op_andi_16_d , 0xfff8, 0x0240, { 8, 8, 2, 2}}, {m68k_op_andi_16_ai , 0xfff8, 0x0250, { 16, 16, 8, 8}}, {m68k_op_andi_16_pi , 0xfff8, 0x0258, { 16, 16, 8, 8}}, {m68k_op_andi_16_pd , 0xfff8, 0x0260, { 18, 18, 9, 9}}, {m68k_op_andi_16_di , 0xfff8, 0x0268, { 20, 20, 9, 9}}, {m68k_op_andi_16_ix , 0xfff8, 0x0270, { 22, 22, 11, 11}}, {m68k_op_andi_32_d , 0xfff8, 0x0280, { 14, 14, 2, 2}}, {m68k_op_andi_32_ai , 0xfff8, 0x0290, { 28, 28, 8, 8}}, {m68k_op_andi_32_pi , 0xfff8, 0x0298, { 28, 28, 8, 8}}, {m68k_op_andi_32_pd , 0xfff8, 0x02a0, { 30, 30, 9, 9}}, {m68k_op_andi_32_di , 0xfff8, 0x02a8, { 32, 32, 9, 9}}, {m68k_op_andi_32_ix , 0xfff8, 0x02b0, { 34, 34, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_chk2cmp2_16_ai , 0xfff8, 0x02d0, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_16_di , 0xfff8, 0x02e8, { 0, 0, 23, 23}}, {m68k_op_chk2cmp2_16_ix , 0xfff8, 0x02f0, { 0, 0, 25, 25}}, #endif {m68k_op_subi_8_d , 0xfff8, 0x0400, { 8, 8, 2, 2}}, {m68k_op_subi_8_ai , 0xfff8, 0x0410, { 16, 16, 8, 8}}, {m68k_op_subi_8_pi , 0xfff8, 0x0418, { 16, 16, 8, 8}}, {m68k_op_subi_8_pd , 0xfff8, 0x0420, { 18, 18, 9, 9}}, {m68k_op_subi_8_di , 0xfff8, 0x0428, { 20, 20, 9, 9}}, {m68k_op_subi_8_ix , 0xfff8, 0x0430, { 22, 22, 11, 11}}, {m68k_op_subi_16_d , 0xfff8, 0x0440, { 8, 8, 2, 2}}, {m68k_op_subi_16_ai , 0xfff8, 0x0450, { 16, 16, 8, 8}}, {m68k_op_subi_16_pi , 0xfff8, 0x0458, { 16, 16, 8, 8}}, {m68k_op_subi_16_pd , 0xfff8, 0x0460, { 18, 18, 9, 9}}, {m68k_op_subi_16_di , 0xfff8, 0x0468, { 20, 20, 9, 9}}, {m68k_op_subi_16_ix , 0xfff8, 0x0470, { 22, 22, 11, 11}}, {m68k_op_subi_32_d , 0xfff8, 0x0480, { 16, 14, 2, 2}}, {m68k_op_subi_32_ai , 0xfff8, 0x0490, { 28, 28, 8, 8}}, {m68k_op_subi_32_pi , 0xfff8, 0x0498, { 28, 28, 8, 8}}, {m68k_op_subi_32_pd , 0xfff8, 0x04a0, { 30, 30, 9, 9}}, {m68k_op_subi_32_di , 0xfff8, 0x04a8, { 32, 32, 9, 9}}, {m68k_op_subi_32_ix , 0xfff8, 0x04b0, { 34, 34, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_chk2cmp2_32_ai , 0xfff8, 0x04d0, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_32_di , 0xfff8, 0x04e8, { 0, 0, 23, 23}}, {m68k_op_chk2cmp2_32_ix , 0xfff8, 0x04f0, { 0, 0, 25, 25}}, #endif {m68k_op_addi_8_d , 0xfff8, 0x0600, { 8, 8, 2, 2}}, {m68k_op_addi_8_ai , 0xfff8, 0x0610, { 16, 16, 8, 8}}, {m68k_op_addi_8_pi , 0xfff8, 0x0618, { 16, 16, 8, 8}}, {m68k_op_addi_8_pd , 0xfff8, 0x0620, { 18, 18, 9, 9}}, {m68k_op_addi_8_di , 0xfff8, 0x0628, { 20, 20, 9, 9}}, {m68k_op_addi_8_ix , 0xfff8, 0x0630, { 22, 22, 11, 11}}, {m68k_op_addi_16_d , 0xfff8, 0x0640, { 8, 8, 2, 2}}, {m68k_op_addi_16_ai , 0xfff8, 0x0650, { 16, 16, 8, 8}}, {m68k_op_addi_16_pi , 0xfff8, 0x0658, { 16, 16, 8, 8}}, {m68k_op_addi_16_pd , 0xfff8, 0x0660, { 18, 18, 9, 9}}, {m68k_op_addi_16_di , 0xfff8, 0x0668, { 20, 20, 9, 9}}, {m68k_op_addi_16_ix , 0xfff8, 0x0670, { 22, 22, 11, 11}}, {m68k_op_addi_32_d , 0xfff8, 0x0680, { 16, 14, 2, 2}}, {m68k_op_addi_32_ai , 0xfff8, 0x0690, { 28, 28, 8, 8}}, {m68k_op_addi_32_pi , 0xfff8, 0x0698, { 28, 28, 8, 8}}, {m68k_op_addi_32_pd , 0xfff8, 0x06a0, { 30, 30, 9, 9}}, {m68k_op_addi_32_di , 0xfff8, 0x06a8, { 32, 32, 9, 9}}, {m68k_op_addi_32_ix , 0xfff8, 0x06b0, { 34, 34, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_callm_32_ai , 0xfff8, 0x06d0, { 0, 0, 64, 64}}, {m68k_op_callm_32_di , 0xfff8, 0x06e8, { 0, 0, 65, 65}}, {m68k_op_callm_32_ix , 0xfff8, 0x06f0, { 0, 0, 67, 67}}, #endif {m68k_op_btst_32_s_d , 0xfff8, 0x0800, { 10, 10, 4, 4}}, {m68k_op_btst_8_s_ai , 0xfff8, 0x0810, { 12, 12, 8, 8}}, {m68k_op_btst_8_s_pi , 0xfff8, 0x0818, { 12, 12, 8, 8}}, {m68k_op_btst_8_s_pd , 0xfff8, 0x0820, { 14, 14, 9, 9}}, {m68k_op_btst_8_s_di , 0xfff8, 0x0828, { 16, 16, 9, 9}}, {m68k_op_btst_8_s_ix , 0xfff8, 0x0830, { 18, 18, 11, 11}}, {m68k_op_bchg_32_s_d , 0xfff8, 0x0840, { 12, 12, 4, 4}}, {m68k_op_bchg_8_s_ai , 0xfff8, 0x0850, { 16, 16, 8, 8}}, {m68k_op_bchg_8_s_pi , 0xfff8, 0x0858, { 16, 16, 8, 8}}, {m68k_op_bchg_8_s_pd , 0xfff8, 0x0860, { 18, 18, 9, 9}}, {m68k_op_bchg_8_s_di , 0xfff8, 0x0868, { 20, 20, 9, 9}}, {m68k_op_bchg_8_s_ix , 0xfff8, 0x0870, { 22, 22, 11, 11}}, {m68k_op_bclr_32_s_d , 0xfff8, 0x0880, { 14, 14, 4, 4}}, {m68k_op_bclr_8_s_ai , 0xfff8, 0x0890, { 16, 16, 8, 8}}, {m68k_op_bclr_8_s_pi , 0xfff8, 0x0898, { 16, 16, 8, 8}}, {m68k_op_bclr_8_s_pd , 0xfff8, 0x08a0, { 18, 18, 9, 9}}, {m68k_op_bclr_8_s_di , 0xfff8, 0x08a8, { 20, 20, 9, 9}}, {m68k_op_bclr_8_s_ix , 0xfff8, 0x08b0, { 22, 22, 11, 11}}, {m68k_op_bset_32_s_d , 0xfff8, 0x08c0, { 12, 12, 4, 4}}, {m68k_op_bset_8_s_ai , 0xfff8, 0x08d0, { 16, 16, 8, 8}}, {m68k_op_bset_8_s_pi , 0xfff8, 0x08d8, { 16, 16, 8, 8}}, {m68k_op_bset_8_s_pd , 0xfff8, 0x08e0, { 18, 18, 9, 9}}, {m68k_op_bset_8_s_di , 0xfff8, 0x08e8, { 20, 20, 9, 9}}, {m68k_op_bset_8_s_ix , 0xfff8, 0x08f0, { 22, 22, 11, 11}}, {m68k_op_eori_8_d , 0xfff8, 0x0a00, { 8, 8, 2, 2}}, {m68k_op_eori_8_ai , 0xfff8, 0x0a10, { 16, 16, 8, 8}}, {m68k_op_eori_8_pi , 0xfff8, 0x0a18, { 16, 16, 8, 8}}, {m68k_op_eori_8_pd , 0xfff8, 0x0a20, { 18, 18, 9, 9}}, {m68k_op_eori_8_di , 0xfff8, 0x0a28, { 20, 20, 9, 9}}, {m68k_op_eori_8_ix , 0xfff8, 0x0a30, { 22, 22, 11, 11}}, {m68k_op_eori_16_d , 0xfff8, 0x0a40, { 8, 8, 2, 2}}, {m68k_op_eori_16_ai , 0xfff8, 0x0a50, { 16, 16, 8, 8}}, {m68k_op_eori_16_pi , 0xfff8, 0x0a58, { 16, 16, 8, 8}}, {m68k_op_eori_16_pd , 0xfff8, 0x0a60, { 18, 18, 9, 9}}, {m68k_op_eori_16_di , 0xfff8, 0x0a68, { 20, 20, 9, 9}}, {m68k_op_eori_16_ix , 0xfff8, 0x0a70, { 22, 22, 11, 11}}, {m68k_op_eori_32_d , 0xfff8, 0x0a80, { 16, 14, 2, 2}}, {m68k_op_eori_32_ai , 0xfff8, 0x0a90, { 28, 28, 8, 8}}, {m68k_op_eori_32_pi , 0xfff8, 0x0a98, { 28, 28, 8, 8}}, {m68k_op_eori_32_pd , 0xfff8, 0x0aa0, { 30, 30, 9, 9}}, {m68k_op_eori_32_di , 0xfff8, 0x0aa8, { 32, 32, 9, 9}}, {m68k_op_eori_32_ix , 0xfff8, 0x0ab0, { 34, 34, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cas_8_ai , 0xfff8, 0x0ad0, { 0, 0, 16, 16}}, {m68k_op_cas_8_pi , 0xfff8, 0x0ad8, { 0, 0, 16, 16}}, {m68k_op_cas_8_pd , 0xfff8, 0x0ae0, { 0, 0, 17, 17}}, {m68k_op_cas_8_di , 0xfff8, 0x0ae8, { 0, 0, 17, 17}}, {m68k_op_cas_8_ix , 0xfff8, 0x0af0, { 0, 0, 19, 19}}, #endif {m68k_op_cmpi_8_d , 0xfff8, 0x0c00, { 8, 8, 2, 2}}, {m68k_op_cmpi_8_ai , 0xfff8, 0x0c10, { 12, 12, 6, 6}}, {m68k_op_cmpi_8_pi , 0xfff8, 0x0c18, { 12, 12, 6, 6}}, {m68k_op_cmpi_8_pd , 0xfff8, 0x0c20, { 14, 14, 7, 7}}, {m68k_op_cmpi_8_di , 0xfff8, 0x0c28, { 16, 16, 7, 7}}, {m68k_op_cmpi_8_ix , 0xfff8, 0x0c30, { 18, 18, 9, 9}}, {m68k_op_cmpi_16_d , 0xfff8, 0x0c40, { 8, 8, 2, 2}}, {m68k_op_cmpi_16_ai , 0xfff8, 0x0c50, { 12, 12, 6, 6}}, {m68k_op_cmpi_16_pi , 0xfff8, 0x0c58, { 12, 12, 6, 6}}, {m68k_op_cmpi_16_pd , 0xfff8, 0x0c60, { 14, 14, 7, 7}}, {m68k_op_cmpi_16_di , 0xfff8, 0x0c68, { 16, 16, 7, 7}}, {m68k_op_cmpi_16_ix , 0xfff8, 0x0c70, { 18, 18, 9, 9}}, {m68k_op_cmpi_32_d , 0xfff8, 0x0c80, { 14, 12, 2, 2}}, {m68k_op_cmpi_32_ai , 0xfff8, 0x0c90, { 20, 20, 6, 6}}, {m68k_op_cmpi_32_pi , 0xfff8, 0x0c98, { 20, 20, 6, 6}}, {m68k_op_cmpi_32_pd , 0xfff8, 0x0ca0, { 22, 22, 7, 7}}, {m68k_op_cmpi_32_di , 0xfff8, 0x0ca8, { 24, 24, 7, 7}}, {m68k_op_cmpi_32_ix , 0xfff8, 0x0cb0, { 26, 26, 9, 9}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cas_16_ai , 0xfff8, 0x0cd0, { 0, 0, 16, 16}}, {m68k_op_cas_16_pi , 0xfff8, 0x0cd8, { 0, 0, 16, 16}}, {m68k_op_cas_16_pd , 0xfff8, 0x0ce0, { 0, 0, 17, 17}}, {m68k_op_cas_16_di , 0xfff8, 0x0ce8, { 0, 0, 17, 17}}, {m68k_op_cas_16_ix , 0xfff8, 0x0cf0, { 0, 0, 19, 19}}, #endif #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_moves_8_ai , 0xfff8, 0x0e10, { 0, 18, 9, 9}}, {m68k_op_moves_8_pi , 0xfff8, 0x0e18, { 0, 18, 9, 9}}, {m68k_op_moves_8_pd , 0xfff8, 0x0e20, { 0, 20, 10, 10}}, {m68k_op_moves_8_di , 0xfff8, 0x0e28, { 0, 26, 10, 10}}, {m68k_op_moves_8_ix , 0xfff8, 0x0e30, { 0, 30, 12, 12}}, {m68k_op_moves_16_ai , 0xfff8, 0x0e50, { 0, 18, 9, 9}}, {m68k_op_moves_16_pi , 0xfff8, 0x0e58, { 0, 18, 9, 9}}, {m68k_op_moves_16_pd , 0xfff8, 0x0e60, { 0, 20, 10, 10}}, {m68k_op_moves_16_di , 0xfff8, 0x0e68, { 0, 26, 10, 10}}, {m68k_op_moves_16_ix , 0xfff8, 0x0e70, { 0, 30, 12, 12}}, {m68k_op_moves_32_ai , 0xfff8, 0x0e90, { 0, 22, 9, 9}}, {m68k_op_moves_32_pi , 0xfff8, 0x0e98, { 0, 22, 9, 9}}, {m68k_op_moves_32_pd , 0xfff8, 0x0ea0, { 0, 28, 10, 10}}, {m68k_op_moves_32_di , 0xfff8, 0x0ea8, { 0, 32, 10, 10}}, {m68k_op_moves_32_ix , 0xfff8, 0x0eb0, { 0, 36, 12, 12}}, #endif #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cas_32_ai , 0xfff8, 0x0ed0, { 0, 0, 16, 16}}, {m68k_op_cas_32_pi , 0xfff8, 0x0ed8, { 0, 0, 16, 16}}, {m68k_op_cas_32_pd , 0xfff8, 0x0ee0, { 0, 0, 17, 17}}, {m68k_op_cas_32_di , 0xfff8, 0x0ee8, { 0, 0, 17, 17}}, {m68k_op_cas_32_ix , 0xfff8, 0x0ef0, { 0, 0, 19, 19}}, #endif {m68k_op_move_8_aw_d , 0xfff8, 0x11c0, { 12, 12, 4, 4}}, {m68k_op_move_8_aw_ai , 0xfff8, 0x11d0, { 16, 16, 8, 8}}, {m68k_op_move_8_aw_pi , 0xfff8, 0x11d8, { 16, 16, 8, 8}}, {m68k_op_move_8_aw_pd , 0xfff8, 0x11e0, { 18, 18, 9, 9}}, {m68k_op_move_8_aw_di , 0xfff8, 0x11e8, { 20, 20, 9, 9}}, {m68k_op_move_8_aw_ix , 0xfff8, 0x11f0, { 22, 22, 11, 11}}, {m68k_op_move_8_al_d , 0xfff8, 0x13c0, { 16, 16, 6, 6}}, {m68k_op_move_8_al_ai , 0xfff8, 0x13d0, { 20, 20, 10, 10}}, {m68k_op_move_8_al_pi , 0xfff8, 0x13d8, { 20, 20, 10, 10}}, {m68k_op_move_8_al_pd , 0xfff8, 0x13e0, { 22, 22, 11, 11}}, {m68k_op_move_8_al_di , 0xfff8, 0x13e8, { 24, 24, 11, 11}}, {m68k_op_move_8_al_ix , 0xfff8, 0x13f0, { 26, 26, 13, 13}}, {m68k_op_move_8_pi7_d , 0xfff8, 0x1ec0, { 8, 8, 4, 4}}, {m68k_op_move_8_pi7_ai , 0xfff8, 0x1ed0, { 12, 12, 8, 8}}, {m68k_op_move_8_pi7_pi , 0xfff8, 0x1ed8, { 12, 12, 8, 8}}, {m68k_op_move_8_pi7_pd , 0xfff8, 0x1ee0, { 14, 14, 9, 9}}, {m68k_op_move_8_pi7_di , 0xfff8, 0x1ee8, { 16, 16, 9, 9}}, {m68k_op_move_8_pi7_ix , 0xfff8, 0x1ef0, { 18, 18, 11, 11}}, {m68k_op_move_8_pd7_d , 0xfff8, 0x1f00, { 8, 8, 5, 5}}, {m68k_op_move_8_pd7_ai , 0xfff8, 0x1f10, { 12, 12, 9, 9}}, {m68k_op_move_8_pd7_pi , 0xfff8, 0x1f18, { 12, 12, 9, 9}}, {m68k_op_move_8_pd7_pd , 0xfff8, 0x1f20, { 14, 14, 10, 10}}, {m68k_op_move_8_pd7_di , 0xfff8, 0x1f28, { 16, 16, 10, 10}}, {m68k_op_move_8_pd7_ix , 0xfff8, 0x1f30, { 18, 18, 12, 12}}, {m68k_op_move_32_aw_d , 0xfff8, 0x21c0, { 16, 16, 4, 4}}, {m68k_op_move_32_aw_a , 0xfff8, 0x21c8, { 16, 16, 4, 4}}, {m68k_op_move_32_aw_ai , 0xfff8, 0x21d0, { 24, 24, 8, 8}}, {m68k_op_move_32_aw_pi , 0xfff8, 0x21d8, { 24, 24, 8, 8}}, {m68k_op_move_32_aw_pd , 0xfff8, 0x21e0, { 26, 26, 9, 9}}, {m68k_op_move_32_aw_di , 0xfff8, 0x21e8, { 28, 28, 9, 9}}, {m68k_op_move_32_aw_ix , 0xfff8, 0x21f0, { 30, 30, 11, 11}}, {m68k_op_move_32_al_d , 0xfff8, 0x23c0, { 20, 20, 6, 6}}, {m68k_op_move_32_al_a , 0xfff8, 0x23c8, { 20, 20, 6, 6}}, {m68k_op_move_32_al_ai , 0xfff8, 0x23d0, { 28, 28, 10, 10}}, {m68k_op_move_32_al_pi , 0xfff8, 0x23d8, { 28, 28, 10, 10}}, {m68k_op_move_32_al_pd , 0xfff8, 0x23e0, { 30, 30, 11, 11}}, {m68k_op_move_32_al_di , 0xfff8, 0x23e8, { 32, 32, 11, 11}}, {m68k_op_move_32_al_ix , 0xfff8, 0x23f0, { 34, 34, 13, 13}}, {m68k_op_move_16_aw_d , 0xfff8, 0x31c0, { 12, 12, 4, 4}}, {m68k_op_move_16_aw_a , 0xfff8, 0x31c8, { 12, 12, 4, 4}}, {m68k_op_move_16_aw_ai , 0xfff8, 0x31d0, { 16, 16, 8, 8}}, {m68k_op_move_16_aw_pi , 0xfff8, 0x31d8, { 16, 16, 8, 8}}, {m68k_op_move_16_aw_pd , 0xfff8, 0x31e0, { 18, 18, 9, 9}}, {m68k_op_move_16_aw_di , 0xfff8, 0x31e8, { 20, 20, 9, 9}}, {m68k_op_move_16_aw_ix , 0xfff8, 0x31f0, { 22, 22, 11, 11}}, {m68k_op_move_16_al_d , 0xfff8, 0x33c0, { 16, 16, 6, 6}}, {m68k_op_move_16_al_a , 0xfff8, 0x33c8, { 16, 16, 6, 6}}, {m68k_op_move_16_al_ai , 0xfff8, 0x33d0, { 20, 20, 10, 10}}, {m68k_op_move_16_al_pi , 0xfff8, 0x33d8, { 20, 20, 10, 10}}, {m68k_op_move_16_al_pd , 0xfff8, 0x33e0, { 22, 22, 11, 11}}, {m68k_op_move_16_al_di , 0xfff8, 0x33e8, { 24, 24, 11, 11}}, {m68k_op_move_16_al_ix , 0xfff8, 0x33f0, { 26, 26, 13, 13}}, {m68k_op_negx_8_d , 0xfff8, 0x4000, { 4, 4, 2, 2}}, {m68k_op_negx_8_ai , 0xfff8, 0x4010, { 12, 12, 8, 8}}, {m68k_op_negx_8_pi , 0xfff8, 0x4018, { 12, 12, 8, 8}}, {m68k_op_negx_8_pd , 0xfff8, 0x4020, { 14, 14, 9, 9}}, {m68k_op_negx_8_di , 0xfff8, 0x4028, { 16, 16, 9, 9}}, {m68k_op_negx_8_ix , 0xfff8, 0x4030, { 18, 18, 11, 11}}, {m68k_op_negx_16_d , 0xfff8, 0x4040, { 4, 4, 2, 2}}, {m68k_op_negx_16_ai , 0xfff8, 0x4050, { 12, 12, 8, 8}}, {m68k_op_negx_16_pi , 0xfff8, 0x4058, { 12, 12, 8, 8}}, {m68k_op_negx_16_pd , 0xfff8, 0x4060, { 14, 14, 9, 9}}, {m68k_op_negx_16_di , 0xfff8, 0x4068, { 16, 16, 9, 9}}, {m68k_op_negx_16_ix , 0xfff8, 0x4070, { 18, 18, 11, 11}}, {m68k_op_negx_32_d , 0xfff8, 0x4080, { 6, 6, 2, 2}}, {m68k_op_negx_32_ai , 0xfff8, 0x4090, { 20, 20, 8, 8}}, {m68k_op_negx_32_pi , 0xfff8, 0x4098, { 20, 20, 8, 8}}, {m68k_op_negx_32_pd , 0xfff8, 0x40a0, { 22, 22, 9, 9}}, {m68k_op_negx_32_di , 0xfff8, 0x40a8, { 24, 24, 9, 9}}, {m68k_op_negx_32_ix , 0xfff8, 0x40b0, { 26, 26, 11, 11}}, {m68k_op_move_16_frs_d , 0xfff8, 0x40c0, { 6, 4, 8, 8}}, {m68k_op_move_16_frs_ai , 0xfff8, 0x40d0, { 12, 12, 12, 12}}, {m68k_op_move_16_frs_pi , 0xfff8, 0x40d8, { 12, 12, 12, 12}}, {m68k_op_move_16_frs_pd , 0xfff8, 0x40e0, { 14, 14, 13, 13}}, {m68k_op_move_16_frs_di , 0xfff8, 0x40e8, { 16, 16, 13, 13}}, {m68k_op_move_16_frs_ix , 0xfff8, 0x40f0, { 18, 18, 15, 15}}, {m68k_op_clr_8_d , 0xfff8, 0x4200, { 4, 4, 2, 2}}, {m68k_op_clr_8_ai , 0xfff8, 0x4210, { 12, 8, 8, 8}}, {m68k_op_clr_8_pi , 0xfff8, 0x4218, { 12, 8, 8, 8}}, {m68k_op_clr_8_pd , 0xfff8, 0x4220, { 14, 10, 9, 9}}, {m68k_op_clr_8_di , 0xfff8, 0x4228, { 16, 12, 9, 9}}, {m68k_op_clr_8_ix , 0xfff8, 0x4230, { 18, 14, 11, 11}}, {m68k_op_clr_16_d , 0xfff8, 0x4240, { 4, 4, 2, 2}}, {m68k_op_clr_16_ai , 0xfff8, 0x4250, { 12, 8, 8, 8}}, {m68k_op_clr_16_pi , 0xfff8, 0x4258, { 12, 8, 8, 8}}, {m68k_op_clr_16_pd , 0xfff8, 0x4260, { 14, 10, 9, 9}}, {m68k_op_clr_16_di , 0xfff8, 0x4268, { 16, 12, 9, 9}}, {m68k_op_clr_16_ix , 0xfff8, 0x4270, { 18, 14, 11, 11}}, {m68k_op_clr_32_d , 0xfff8, 0x4280, { 6, 6, 2, 2}}, {m68k_op_clr_32_ai , 0xfff8, 0x4290, { 20, 12, 8, 8}}, {m68k_op_clr_32_pi , 0xfff8, 0x4298, { 20, 12, 8, 8}}, {m68k_op_clr_32_pd , 0xfff8, 0x42a0, { 22, 14, 9, 9}}, {m68k_op_clr_32_di , 0xfff8, 0x42a8, { 24, 16, 9, 9}}, {m68k_op_clr_32_ix , 0xfff8, 0x42b0, { 26, 20, 11, 11}}, #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_move_16_frc_d , 0xfff8, 0x42c0, { 0, 4, 4, 4}}, {m68k_op_move_16_frc_ai , 0xfff8, 0x42d0, { 0, 12, 8, 8}}, {m68k_op_move_16_frc_pi , 0xfff8, 0x42d8, { 0, 12, 8, 8}}, {m68k_op_move_16_frc_pd , 0xfff8, 0x42e0, { 0, 14, 9, 9}}, {m68k_op_move_16_frc_di , 0xfff8, 0x42e8, { 0, 16, 9, 9}}, {m68k_op_move_16_frc_ix , 0xfff8, 0x42f0, { 0, 18, 11, 11}}, #endif {m68k_op_neg_8_d , 0xfff8, 0x4400, { 4, 4, 2, 2}}, {m68k_op_neg_8_ai , 0xfff8, 0x4410, { 12, 12, 8, 8}}, {m68k_op_neg_8_pi , 0xfff8, 0x4418, { 12, 12, 8, 8}}, {m68k_op_neg_8_pd , 0xfff8, 0x4420, { 14, 14, 9, 9}}, {m68k_op_neg_8_di , 0xfff8, 0x4428, { 16, 16, 9, 9}}, {m68k_op_neg_8_ix , 0xfff8, 0x4430, { 18, 18, 11, 11}}, {m68k_op_neg_16_d , 0xfff8, 0x4440, { 4, 4, 2, 2}}, {m68k_op_neg_16_ai , 0xfff8, 0x4450, { 12, 12, 8, 8}}, {m68k_op_neg_16_pi , 0xfff8, 0x4458, { 12, 12, 8, 8}}, {m68k_op_neg_16_pd , 0xfff8, 0x4460, { 14, 14, 9, 9}}, {m68k_op_neg_16_di , 0xfff8, 0x4468, { 16, 16, 9, 9}}, {m68k_op_neg_16_ix , 0xfff8, 0x4470, { 18, 18, 11, 11}}, {m68k_op_neg_32_d , 0xfff8, 0x4480, { 6, 6, 2, 2}}, {m68k_op_neg_32_ai , 0xfff8, 0x4490, { 20, 20, 8, 8}}, {m68k_op_neg_32_pi , 0xfff8, 0x4498, { 20, 20, 8, 8}}, {m68k_op_neg_32_pd , 0xfff8, 0x44a0, { 22, 22, 9, 9}}, {m68k_op_neg_32_di , 0xfff8, 0x44a8, { 24, 24, 9, 9}}, {m68k_op_neg_32_ix , 0xfff8, 0x44b0, { 26, 26, 11, 11}}, {m68k_op_move_16_toc_d , 0xfff8, 0x44c0, { 12, 12, 4, 4}}, {m68k_op_move_16_toc_ai , 0xfff8, 0x44d0, { 16, 16, 8, 8}}, {m68k_op_move_16_toc_pi , 0xfff8, 0x44d8, { 16, 16, 8, 8}}, {m68k_op_move_16_toc_pd , 0xfff8, 0x44e0, { 18, 18, 9, 9}}, {m68k_op_move_16_toc_di , 0xfff8, 0x44e8, { 20, 20, 9, 9}}, {m68k_op_move_16_toc_ix , 0xfff8, 0x44f0, { 22, 22, 11, 11}}, {m68k_op_not_8_d , 0xfff8, 0x4600, { 4, 4, 2, 2}}, {m68k_op_not_8_ai , 0xfff8, 0x4610, { 12, 12, 8, 8}}, {m68k_op_not_8_pi , 0xfff8, 0x4618, { 12, 12, 8, 8}}, {m68k_op_not_8_pd , 0xfff8, 0x4620, { 14, 14, 9, 9}}, {m68k_op_not_8_di , 0xfff8, 0x4628, { 16, 16, 9, 9}}, {m68k_op_not_8_ix , 0xfff8, 0x4630, { 18, 18, 11, 11}}, {m68k_op_not_16_d , 0xfff8, 0x4640, { 4, 4, 2, 2}}, {m68k_op_not_16_ai , 0xfff8, 0x4650, { 12, 12, 8, 8}}, {m68k_op_not_16_pi , 0xfff8, 0x4658, { 12, 12, 8, 8}}, {m68k_op_not_16_pd , 0xfff8, 0x4660, { 14, 14, 9, 9}}, {m68k_op_not_16_di , 0xfff8, 0x4668, { 16, 16, 9, 9}}, {m68k_op_not_16_ix , 0xfff8, 0x4670, { 18, 18, 11, 11}}, {m68k_op_not_32_d , 0xfff8, 0x4680, { 6, 6, 2, 2}}, {m68k_op_not_32_ai , 0xfff8, 0x4690, { 20, 20, 8, 8}}, {m68k_op_not_32_pi , 0xfff8, 0x4698, { 20, 20, 8, 8}}, {m68k_op_not_32_pd , 0xfff8, 0x46a0, { 22, 22, 9, 9}}, {m68k_op_not_32_di , 0xfff8, 0x46a8, { 24, 24, 9, 9}}, {m68k_op_not_32_ix , 0xfff8, 0x46b0, { 26, 26, 11, 11}}, {m68k_op_move_16_tos_d , 0xfff8, 0x46c0, { 12, 12, 8, 8}}, {m68k_op_move_16_tos_ai , 0xfff8, 0x46d0, { 16, 16, 12, 12}}, {m68k_op_move_16_tos_pi , 0xfff8, 0x46d8, { 16, 16, 12, 12}}, {m68k_op_move_16_tos_pd , 0xfff8, 0x46e0, { 18, 18, 13, 13}}, {m68k_op_move_16_tos_di , 0xfff8, 0x46e8, { 20, 20, 13, 13}}, {m68k_op_move_16_tos_ix , 0xfff8, 0x46f0, { 22, 22, 15, 15}}, {m68k_op_nbcd_8_d , 0xfff8, 0x4800, { 6, 6, 6, 6}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_link_32 , 0xfff8, 0x4808, { 0, 0, 6, 6}}, #endif {m68k_op_nbcd_8_ai , 0xfff8, 0x4810, { 12, 12, 10, 10}}, {m68k_op_nbcd_8_pi , 0xfff8, 0x4818, { 12, 12, 10, 10}}, {m68k_op_nbcd_8_pd , 0xfff8, 0x4820, { 14, 14, 11, 11}}, {m68k_op_nbcd_8_di , 0xfff8, 0x4828, { 16, 16, 11, 11}}, {m68k_op_nbcd_8_ix , 0xfff8, 0x4830, { 18, 18, 13, 13}}, {m68k_op_swap_32 , 0xfff8, 0x4840, { 4, 4, 4, 4}}, #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_bkpt , 0xfff8, 0x4848, { 0, 10, 10, 10}}, #endif {m68k_op_pea_32_ai , 0xfff8, 0x4850, { 12, 12, 9, 9}}, {m68k_op_pea_32_di , 0xfff8, 0x4868, { 16, 16, 10, 10}}, {m68k_op_pea_32_ix , 0xfff8, 0x4870, { 20, 20, 12, 12}}, {m68k_op_ext_16 , 0xfff8, 0x4880, { 4, 4, 4, 4}}, {m68k_op_movem_16_re_ai , 0xfff8, 0x4890, { 8, 8, 8, 8}}, {m68k_op_movem_16_re_pd , 0xfff8, 0x48a0, { 8, 8, 4, 4}}, {m68k_op_movem_16_re_di , 0xfff8, 0x48a8, { 12, 12, 9, 9}}, {m68k_op_movem_16_re_ix , 0xfff8, 0x48b0, { 14, 14, 11, 11}}, {m68k_op_ext_32 , 0xfff8, 0x48c0, { 4, 4, 4, 4}}, {m68k_op_movem_32_re_ai , 0xfff8, 0x48d0, { 8, 8, 8, 8}}, {m68k_op_movem_32_re_pd , 0xfff8, 0x48e0, { 8, 8, 4, 4}}, {m68k_op_movem_32_re_di , 0xfff8, 0x48e8, { 12, 12, 9, 9}}, {m68k_op_movem_32_re_ix , 0xfff8, 0x48f0, { 14, 14, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_extb_32 , 0xfff8, 0x49c0, { 0, 0, 4, 4}}, #endif {m68k_op_tst_8_d , 0xfff8, 0x4a00, { 4, 4, 2, 2}}, {m68k_op_tst_8_ai , 0xfff8, 0x4a10, { 8, 8, 6, 6}}, {m68k_op_tst_8_pi , 0xfff8, 0x4a18, { 8, 8, 6, 6}}, {m68k_op_tst_8_pd , 0xfff8, 0x4a20, { 10, 10, 7, 7}}, {m68k_op_tst_8_di , 0xfff8, 0x4a28, { 12, 12, 7, 7}}, {m68k_op_tst_8_ix , 0xfff8, 0x4a30, { 14, 14, 9, 9}}, {m68k_op_tst_16_d , 0xfff8, 0x4a40, { 4, 4, 2, 2}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_tst_16_a , 0xfff8, 0x4a48, { 0, 0, 2, 2}}, #endif {m68k_op_tst_16_ai , 0xfff8, 0x4a50, { 8, 8, 6, 6}}, {m68k_op_tst_16_pi , 0xfff8, 0x4a58, { 8, 8, 6, 6}}, {m68k_op_tst_16_pd , 0xfff8, 0x4a60, { 10, 10, 7, 7}}, {m68k_op_tst_16_di , 0xfff8, 0x4a68, { 12, 12, 7, 7}}, {m68k_op_tst_16_ix , 0xfff8, 0x4a70, { 14, 14, 9, 9}}, {m68k_op_tst_32_d , 0xfff8, 0x4a80, { 4, 4, 2, 2}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_tst_32_a , 0xfff8, 0x4a88, { 0, 0, 2, 2}}, #endif {m68k_op_tst_32_ai , 0xfff8, 0x4a90, { 12, 12, 6, 6}}, {m68k_op_tst_32_pi , 0xfff8, 0x4a98, { 12, 12, 6, 6}}, {m68k_op_tst_32_pd , 0xfff8, 0x4aa0, { 14, 14, 7, 7}}, {m68k_op_tst_32_di , 0xfff8, 0x4aa8, { 16, 16, 7, 7}}, {m68k_op_tst_32_ix , 0xfff8, 0x4ab0, { 18, 18, 9, 9}}, {m68k_op_tas_8_d , 0xfff8, 0x4ac0, { 4, 4, 4, 4}}, {m68k_op_tas_8_ai , 0xfff8, 0x4ad0, { 18, 18, 16, 16}}, {m68k_op_tas_8_pi , 0xfff8, 0x4ad8, { 18, 18, 16, 16}}, {m68k_op_tas_8_pd , 0xfff8, 0x4ae0, { 20, 20, 17, 17}}, {m68k_op_tas_8_di , 0xfff8, 0x4ae8, { 22, 22, 17, 17}}, {m68k_op_tas_8_ix , 0xfff8, 0x4af0, { 24, 24, 19, 19}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_mull_32_d , 0xfff8, 0x4c00, { 0, 0, 43, 43}}, {m68k_op_mull_32_ai , 0xfff8, 0x4c10, { 0, 0, 47, 47}}, {m68k_op_mull_32_pi , 0xfff8, 0x4c18, { 0, 0, 47, 47}}, {m68k_op_mull_32_pd , 0xfff8, 0x4c20, { 0, 0, 48, 48}}, {m68k_op_mull_32_di , 0xfff8, 0x4c28, { 0, 0, 48, 48}}, {m68k_op_mull_32_ix , 0xfff8, 0x4c30, { 0, 0, 50, 50}}, {m68k_op_divl_32_d , 0xfff8, 0x4c40, { 0, 0, 84, 84}}, {m68k_op_divl_32_ai , 0xfff8, 0x4c50, { 0, 0, 88, 88}}, {m68k_op_divl_32_pi , 0xfff8, 0x4c58, { 0, 0, 88, 88}}, {m68k_op_divl_32_pd , 0xfff8, 0x4c60, { 0, 0, 89, 89}}, {m68k_op_divl_32_di , 0xfff8, 0x4c68, { 0, 0, 89, 89}}, {m68k_op_divl_32_ix , 0xfff8, 0x4c70, { 0, 0, 91, 91}}, #endif {m68k_op_movem_16_er_ai , 0xfff8, 0x4c90, { 12, 12, 12, 12}}, {m68k_op_movem_16_er_pi , 0xfff8, 0x4c98, { 12, 12, 8, 8}}, {m68k_op_movem_16_er_di , 0xfff8, 0x4ca8, { 16, 16, 13, 13}}, {m68k_op_movem_16_er_ix , 0xfff8, 0x4cb0, { 18, 18, 15, 15}}, {m68k_op_movem_32_er_ai , 0xfff8, 0x4cd0, { 12, 12, 12, 12}}, {m68k_op_movem_32_er_pi , 0xfff8, 0x4cd8, { 12, 12, 8, 8}}, {m68k_op_movem_32_er_di , 0xfff8, 0x4ce8, { 16, 16, 13, 13}}, {m68k_op_movem_32_er_ix , 0xfff8, 0x4cf0, { 18, 18, 15, 15}}, {m68k_op_link_16 , 0xfff8, 0x4e50, { 16, 16, 5, 5}}, {m68k_op_unlk_32 , 0xfff8, 0x4e58, { 12, 12, 6, 6}}, {m68k_op_move_32_tou , 0xfff8, 0x4e60, { 4, 6, 2, 2}}, {m68k_op_move_32_fru , 0xfff8, 0x4e68, { 4, 6, 2, 2}}, {m68k_op_jsr_32_ai , 0xfff8, 0x4e90, { 16, 16, 4, 4}}, {m68k_op_jsr_32_di , 0xfff8, 0x4ea8, { 18, 18, 5, 5}}, {m68k_op_jsr_32_ix , 0xfff8, 0x4eb0, { 22, 22, 7, 7}}, {m68k_op_jmp_32_ai , 0xfff8, 0x4ed0, { 8, 8, 4, 4}}, {m68k_op_jmp_32_di , 0xfff8, 0x4ee8, { 10, 10, 5, 5}}, {m68k_op_jmp_32_ix , 0xfff8, 0x4ef0, { 14, 14, 7, 7}}, {m68k_op_st_8_d , 0xfff8, 0x50c0, { 6, 4, 4, 4}}, {m68k_op_dbt_16 , 0xfff8, 0x50c8, { 12, 12, 6, 6}}, {m68k_op_st_8_ai , 0xfff8, 0x50d0, { 12, 12, 10, 10}}, {m68k_op_st_8_pi , 0xfff8, 0x50d8, { 12, 12, 10, 10}}, {m68k_op_st_8_pd , 0xfff8, 0x50e0, { 14, 14, 11, 11}}, {m68k_op_st_8_di , 0xfff8, 0x50e8, { 16, 16, 11, 11}}, {m68k_op_st_8_ix , 0xfff8, 0x50f0, { 18, 18, 13, 13}}, {m68k_op_sf_8_d , 0xfff8, 0x51c0, { 4, 4, 4, 4}}, {m68k_op_dbf_16 , 0xfff8, 0x51c8, { 12, 12, 6, 6}}, {m68k_op_sf_8_ai , 0xfff8, 0x51d0, { 12, 12, 10, 10}}, {m68k_op_sf_8_pi , 0xfff8, 0x51d8, { 12, 12, 10, 10}}, {m68k_op_sf_8_pd , 0xfff8, 0x51e0, { 14, 14, 11, 11}}, {m68k_op_sf_8_di , 0xfff8, 0x51e8, { 16, 16, 11, 11}}, {m68k_op_sf_8_ix , 0xfff8, 0x51f0, { 18, 18, 13, 13}}, {m68k_op_shi_8_d , 0xfff8, 0x52c0, { 4, 4, 4, 4}}, {m68k_op_dbhi_16 , 0xfff8, 0x52c8, { 12, 12, 6, 6}}, {m68k_op_shi_8_ai , 0xfff8, 0x52d0, { 12, 12, 10, 10}}, {m68k_op_shi_8_pi , 0xfff8, 0x52d8, { 12, 12, 10, 10}}, {m68k_op_shi_8_pd , 0xfff8, 0x52e0, { 14, 14, 11, 11}}, {m68k_op_shi_8_di , 0xfff8, 0x52e8, { 16, 16, 11, 11}}, {m68k_op_shi_8_ix , 0xfff8, 0x52f0, { 18, 18, 13, 13}}, {m68k_op_sls_8_d , 0xfff8, 0x53c0, { 4, 4, 4, 4}}, {m68k_op_dbls_16 , 0xfff8, 0x53c8, { 12, 12, 6, 6}}, {m68k_op_sls_8_ai , 0xfff8, 0x53d0, { 12, 12, 10, 10}}, {m68k_op_sls_8_pi , 0xfff8, 0x53d8, { 12, 12, 10, 10}}, {m68k_op_sls_8_pd , 0xfff8, 0x53e0, { 14, 14, 11, 11}}, {m68k_op_sls_8_di , 0xfff8, 0x53e8, { 16, 16, 11, 11}}, {m68k_op_sls_8_ix , 0xfff8, 0x53f0, { 18, 18, 13, 13}}, {m68k_op_scc_8_d , 0xfff8, 0x54c0, { 4, 4, 4, 4}}, {m68k_op_dbcc_16 , 0xfff8, 0x54c8, { 12, 12, 6, 6}}, {m68k_op_scc_8_ai , 0xfff8, 0x54d0, { 12, 12, 10, 10}}, {m68k_op_scc_8_pi , 0xfff8, 0x54d8, { 12, 12, 10, 10}}, {m68k_op_scc_8_pd , 0xfff8, 0x54e0, { 14, 14, 11, 11}}, {m68k_op_scc_8_di , 0xfff8, 0x54e8, { 16, 16, 11, 11}}, {m68k_op_scc_8_ix , 0xfff8, 0x54f0, { 18, 18, 13, 13}}, {m68k_op_scs_8_d , 0xfff8, 0x55c0, { 4, 4, 4, 4}}, {m68k_op_dbcs_16 , 0xfff8, 0x55c8, { 12, 12, 6, 6}}, {m68k_op_scs_8_ai , 0xfff8, 0x55d0, { 12, 12, 10, 10}}, {m68k_op_scs_8_pi , 0xfff8, 0x55d8, { 12, 12, 10, 10}}, {m68k_op_scs_8_pd , 0xfff8, 0x55e0, { 14, 14, 11, 11}}, {m68k_op_scs_8_di , 0xfff8, 0x55e8, { 16, 16, 11, 11}}, {m68k_op_scs_8_ix , 0xfff8, 0x55f0, { 18, 18, 13, 13}}, {m68k_op_sne_8_d , 0xfff8, 0x56c0, { 4, 4, 4, 4}}, {m68k_op_dbne_16 , 0xfff8, 0x56c8, { 12, 12, 6, 6}}, {m68k_op_sne_8_ai , 0xfff8, 0x56d0, { 12, 12, 10, 10}}, {m68k_op_sne_8_pi , 0xfff8, 0x56d8, { 12, 12, 10, 10}}, {m68k_op_sne_8_pd , 0xfff8, 0x56e0, { 14, 14, 11, 11}}, {m68k_op_sne_8_di , 0xfff8, 0x56e8, { 16, 16, 11, 11}}, {m68k_op_sne_8_ix , 0xfff8, 0x56f0, { 18, 18, 13, 13}}, {m68k_op_seq_8_d , 0xfff8, 0x57c0, { 4, 4, 4, 4}}, {m68k_op_dbeq_16 , 0xfff8, 0x57c8, { 12, 12, 6, 6}}, {m68k_op_seq_8_ai , 0xfff8, 0x57d0, { 12, 12, 10, 10}}, {m68k_op_seq_8_pi , 0xfff8, 0x57d8, { 12, 12, 10, 10}}, {m68k_op_seq_8_pd , 0xfff8, 0x57e0, { 14, 14, 11, 11}}, {m68k_op_seq_8_di , 0xfff8, 0x57e8, { 16, 16, 11, 11}}, {m68k_op_seq_8_ix , 0xfff8, 0x57f0, { 18, 18, 13, 13}}, {m68k_op_svc_8_d , 0xfff8, 0x58c0, { 4, 4, 4, 4}}, {m68k_op_dbvc_16 , 0xfff8, 0x58c8, { 12, 12, 6, 6}}, {m68k_op_svc_8_ai , 0xfff8, 0x58d0, { 12, 12, 10, 10}}, {m68k_op_svc_8_pi , 0xfff8, 0x58d8, { 12, 12, 10, 10}}, {m68k_op_svc_8_pd , 0xfff8, 0x58e0, { 14, 14, 11, 11}}, {m68k_op_svc_8_di , 0xfff8, 0x58e8, { 16, 16, 11, 11}}, {m68k_op_svc_8_ix , 0xfff8, 0x58f0, { 18, 18, 13, 13}}, {m68k_op_svs_8_d , 0xfff8, 0x59c0, { 4, 4, 4, 4}}, {m68k_op_dbvs_16 , 0xfff8, 0x59c8, { 12, 12, 6, 6}}, {m68k_op_svs_8_ai , 0xfff8, 0x59d0, { 12, 12, 10, 10}}, {m68k_op_svs_8_pi , 0xfff8, 0x59d8, { 12, 12, 10, 10}}, {m68k_op_svs_8_pd , 0xfff8, 0x59e0, { 14, 14, 11, 11}}, {m68k_op_svs_8_di , 0xfff8, 0x59e8, { 16, 16, 11, 11}}, {m68k_op_svs_8_ix , 0xfff8, 0x59f0, { 18, 18, 13, 13}}, {m68k_op_spl_8_d , 0xfff8, 0x5ac0, { 4, 4, 4, 4}}, {m68k_op_dbpl_16 , 0xfff8, 0x5ac8, { 12, 12, 6, 6}}, {m68k_op_spl_8_ai , 0xfff8, 0x5ad0, { 12, 12, 10, 10}}, {m68k_op_spl_8_pi , 0xfff8, 0x5ad8, { 12, 12, 10, 10}}, {m68k_op_spl_8_pd , 0xfff8, 0x5ae0, { 14, 14, 11, 11}}, {m68k_op_spl_8_di , 0xfff8, 0x5ae8, { 16, 16, 11, 11}}, {m68k_op_spl_8_ix , 0xfff8, 0x5af0, { 18, 18, 13, 13}}, {m68k_op_smi_8_d , 0xfff8, 0x5bc0, { 4, 4, 4, 4}}, {m68k_op_dbmi_16 , 0xfff8, 0x5bc8, { 12, 12, 6, 6}}, {m68k_op_smi_8_ai , 0xfff8, 0x5bd0, { 12, 12, 10, 10}}, {m68k_op_smi_8_pi , 0xfff8, 0x5bd8, { 12, 12, 10, 10}}, {m68k_op_smi_8_pd , 0xfff8, 0x5be0, { 14, 14, 11, 11}}, {m68k_op_smi_8_di , 0xfff8, 0x5be8, { 16, 16, 11, 11}}, {m68k_op_smi_8_ix , 0xfff8, 0x5bf0, { 18, 18, 13, 13}}, {m68k_op_sge_8_d , 0xfff8, 0x5cc0, { 4, 4, 4, 4}}, {m68k_op_dbge_16 , 0xfff8, 0x5cc8, { 12, 12, 6, 6}}, {m68k_op_sge_8_ai , 0xfff8, 0x5cd0, { 12, 12, 10, 10}}, {m68k_op_sge_8_pi , 0xfff8, 0x5cd8, { 12, 12, 10, 10}}, {m68k_op_sge_8_pd , 0xfff8, 0x5ce0, { 14, 14, 11, 11}}, {m68k_op_sge_8_di , 0xfff8, 0x5ce8, { 16, 16, 11, 11}}, {m68k_op_sge_8_ix , 0xfff8, 0x5cf0, { 18, 18, 13, 13}}, {m68k_op_slt_8_d , 0xfff8, 0x5dc0, { 4, 4, 4, 4}}, {m68k_op_dblt_16 , 0xfff8, 0x5dc8, { 12, 12, 6, 6}}, {m68k_op_slt_8_ai , 0xfff8, 0x5dd0, { 12, 12, 10, 10}}, {m68k_op_slt_8_pi , 0xfff8, 0x5dd8, { 12, 12, 10, 10}}, {m68k_op_slt_8_pd , 0xfff8, 0x5de0, { 14, 14, 11, 11}}, {m68k_op_slt_8_di , 0xfff8, 0x5de8, { 16, 16, 11, 11}}, {m68k_op_slt_8_ix , 0xfff8, 0x5df0, { 18, 18, 13, 13}}, {m68k_op_sgt_8_d , 0xfff8, 0x5ec0, { 4, 4, 4, 4}}, {m68k_op_dbgt_16 , 0xfff8, 0x5ec8, { 12, 12, 6, 6}}, {m68k_op_sgt_8_ai , 0xfff8, 0x5ed0, { 12, 12, 10, 10}}, {m68k_op_sgt_8_pi , 0xfff8, 0x5ed8, { 12, 12, 10, 10}}, {m68k_op_sgt_8_pd , 0xfff8, 0x5ee0, { 14, 14, 11, 11}}, {m68k_op_sgt_8_di , 0xfff8, 0x5ee8, { 16, 16, 11, 11}}, {m68k_op_sgt_8_ix , 0xfff8, 0x5ef0, { 18, 18, 13, 13}}, {m68k_op_sle_8_d , 0xfff8, 0x5fc0, { 4, 4, 4, 4}}, {m68k_op_dble_16 , 0xfff8, 0x5fc8, { 12, 12, 6, 6}}, {m68k_op_sle_8_ai , 0xfff8, 0x5fd0, { 12, 12, 10, 10}}, {m68k_op_sle_8_pi , 0xfff8, 0x5fd8, { 12, 12, 10, 10}}, {m68k_op_sle_8_pd , 0xfff8, 0x5fe0, { 14, 14, 11, 11}}, {m68k_op_sle_8_di , 0xfff8, 0x5fe8, { 16, 16, 11, 11}}, {m68k_op_sle_8_ix , 0xfff8, 0x5ff0, { 18, 18, 13, 13}}, {m68k_op_sbcd_8_mm_ax7 , 0xfff8, 0x8f08, { 18, 18, 16, 16}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_pack_16_mm_ax7 , 0xfff8, 0x8f48, { 0, 0, 13, 13}}, {m68k_op_unpk_16_mm_ax7 , 0xfff8, 0x8f88, { 0, 0, 13, 13}}, #endif {m68k_op_subx_8_mm_ax7 , 0xfff8, 0x9f08, { 18, 18, 12, 12}}, {m68k_op_cmpm_8_ax7 , 0xfff8, 0xbf08, { 12, 12, 9, 9}}, {m68k_op_abcd_8_mm_ax7 , 0xfff8, 0xcf08, { 18, 18, 16, 16}}, {m68k_op_addx_8_mm_ax7 , 0xfff8, 0xdf08, { 18, 18, 12, 12}}, {m68k_op_asr_16_ai , 0xfff8, 0xe0d0, { 12, 12, 9, 9}}, {m68k_op_asr_16_pi , 0xfff8, 0xe0d8, { 12, 12, 9, 9}}, {m68k_op_asr_16_pd , 0xfff8, 0xe0e0, { 14, 14, 10, 10}}, {m68k_op_asr_16_di , 0xfff8, 0xe0e8, { 16, 16, 10, 10}}, {m68k_op_asr_16_ix , 0xfff8, 0xe0f0, { 18, 18, 12, 12}}, {m68k_op_asl_16_ai , 0xfff8, 0xe1d0, { 12, 12, 10, 10}}, {m68k_op_asl_16_pi , 0xfff8, 0xe1d8, { 12, 12, 10, 10}}, {m68k_op_asl_16_pd , 0xfff8, 0xe1e0, { 14, 14, 11, 11}}, {m68k_op_asl_16_di , 0xfff8, 0xe1e8, { 16, 16, 11, 11}}, {m68k_op_asl_16_ix , 0xfff8, 0xe1f0, { 18, 18, 13, 13}}, {m68k_op_lsr_16_ai , 0xfff8, 0xe2d0, { 12, 12, 9, 9}}, {m68k_op_lsr_16_pi , 0xfff8, 0xe2d8, { 12, 12, 9, 9}}, {m68k_op_lsr_16_pd , 0xfff8, 0xe2e0, { 14, 14, 10, 10}}, {m68k_op_lsr_16_di , 0xfff8, 0xe2e8, { 16, 16, 10, 10}}, {m68k_op_lsr_16_ix , 0xfff8, 0xe2f0, { 18, 18, 12, 12}}, {m68k_op_lsl_16_ai , 0xfff8, 0xe3d0, { 12, 12, 9, 9}}, {m68k_op_lsl_16_pi , 0xfff8, 0xe3d8, { 12, 12, 9, 9}}, {m68k_op_lsl_16_pd , 0xfff8, 0xe3e0, { 14, 14, 10, 10}}, {m68k_op_lsl_16_di , 0xfff8, 0xe3e8, { 16, 16, 10, 10}}, {m68k_op_lsl_16_ix , 0xfff8, 0xe3f0, { 18, 18, 12, 12}}, {m68k_op_roxr_16_ai , 0xfff8, 0xe4d0, { 12, 12, 9, 9}}, {m68k_op_roxr_16_pi , 0xfff8, 0xe4d8, { 12, 12, 9, 9}}, {m68k_op_roxr_16_pd , 0xfff8, 0xe4e0, { 14, 14, 10, 10}}, {m68k_op_roxr_16_di , 0xfff8, 0xe4e8, { 16, 16, 10, 10}}, {m68k_op_roxr_16_ix , 0xfff8, 0xe4f0, { 18, 18, 12, 12}}, {m68k_op_roxl_16_ai , 0xfff8, 0xe5d0, { 12, 12, 9, 9}}, {m68k_op_roxl_16_pi , 0xfff8, 0xe5d8, { 12, 12, 9, 9}}, {m68k_op_roxl_16_pd , 0xfff8, 0xe5e0, { 14, 14, 10, 10}}, {m68k_op_roxl_16_di , 0xfff8, 0xe5e8, { 16, 16, 10, 10}}, {m68k_op_roxl_16_ix , 0xfff8, 0xe5f0, { 18, 18, 12, 12}}, {m68k_op_ror_16_ai , 0xfff8, 0xe6d0, { 12, 12, 11, 11}}, {m68k_op_ror_16_pi , 0xfff8, 0xe6d8, { 12, 12, 11, 11}}, {m68k_op_ror_16_pd , 0xfff8, 0xe6e0, { 14, 14, 12, 12}}, {m68k_op_ror_16_di , 0xfff8, 0xe6e8, { 16, 16, 12, 12}}, {m68k_op_ror_16_ix , 0xfff8, 0xe6f0, { 18, 18, 14, 14}}, {m68k_op_rol_16_ai , 0xfff8, 0xe7d0, { 12, 12, 11, 11}}, {m68k_op_rol_16_pi , 0xfff8, 0xe7d8, { 12, 12, 11, 11}}, {m68k_op_rol_16_pd , 0xfff8, 0xe7e0, { 14, 14, 12, 12}}, {m68k_op_rol_16_di , 0xfff8, 0xe7e8, { 16, 16, 12, 12}}, {m68k_op_rol_16_ix , 0xfff8, 0xe7f0, { 18, 18, 14, 14}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_bftst_32_d , 0xfff8, 0xe8c0, { 0, 0, 6, 6}}, {m68k_op_bftst_32_ai , 0xfff8, 0xe8d0, { 0, 0, 17, 17}}, {m68k_op_bftst_32_di , 0xfff8, 0xe8e8, { 0, 0, 18, 18}}, {m68k_op_bftst_32_ix , 0xfff8, 0xe8f0, { 0, 0, 20, 20}}, {m68k_op_bfextu_32_d , 0xfff8, 0xe9c0, { 0, 0, 8, 8}}, {m68k_op_bfextu_32_ai , 0xfff8, 0xe9d0, { 0, 0, 19, 19}}, {m68k_op_bfextu_32_di , 0xfff8, 0xe9e8, { 0, 0, 20, 20}}, {m68k_op_bfextu_32_ix , 0xfff8, 0xe9f0, { 0, 0, 22, 22}}, {m68k_op_bfchg_32_d , 0xfff8, 0xeac0, { 0, 0, 12, 12}}, {m68k_op_bfchg_32_ai , 0xfff8, 0xead0, { 0, 0, 24, 24}}, {m68k_op_bfchg_32_di , 0xfff8, 0xeae8, { 0, 0, 25, 25}}, {m68k_op_bfchg_32_ix , 0xfff8, 0xeaf0, { 0, 0, 27, 27}}, {m68k_op_bfexts_32_d , 0xfff8, 0xebc0, { 0, 0, 8, 8}}, {m68k_op_bfexts_32_ai , 0xfff8, 0xebd0, { 0, 0, 19, 19}}, {m68k_op_bfexts_32_di , 0xfff8, 0xebe8, { 0, 0, 20, 20}}, {m68k_op_bfexts_32_ix , 0xfff8, 0xebf0, { 0, 0, 22, 22}}, {m68k_op_bfclr_32_d , 0xfff8, 0xecc0, { 0, 0, 12, 12}}, {m68k_op_bfclr_32_ai , 0xfff8, 0xecd0, { 0, 0, 24, 24}}, {m68k_op_bfclr_32_di , 0xfff8, 0xece8, { 0, 0, 25, 25}}, {m68k_op_bfclr_32_ix , 0xfff8, 0xecf0, { 0, 0, 27, 27}}, {m68k_op_bfffo_32_d , 0xfff8, 0xedc0, { 0, 0, 18, 18}}, {m68k_op_bfffo_32_ai , 0xfff8, 0xedd0, { 0, 0, 32, 32}}, {m68k_op_bfffo_32_di , 0xfff8, 0xede8, { 0, 0, 33, 33}}, {m68k_op_bfffo_32_ix , 0xfff8, 0xedf0, { 0, 0, 35, 35}}, {m68k_op_bfset_32_d , 0xfff8, 0xeec0, { 0, 0, 12, 12}}, {m68k_op_bfset_32_ai , 0xfff8, 0xeed0, { 0, 0, 24, 24}}, {m68k_op_bfset_32_di , 0xfff8, 0xeee8, { 0, 0, 25, 25}}, {m68k_op_bfset_32_ix , 0xfff8, 0xeef0, { 0, 0, 27, 27}}, {m68k_op_bfins_32_d , 0xfff8, 0xefc0, { 0, 0, 10, 10}}, {m68k_op_bfins_32_ai , 0xfff8, 0xefd0, { 0, 0, 21, 21}}, {m68k_op_bfins_32_di , 0xfff8, 0xefe8, { 0, 0, 22, 22}}, {m68k_op_bfins_32_ix , 0xfff8, 0xeff0, { 0, 0, 24, 24}}, #endif {m68k_op_move16_32 , 0xfff8, 0xf620, { 0, 0, 0, 4}}, /* ???????? */ {m68k_op_ori_8_pi7 , 0xffff, 0x001f, { 16, 16, 8, 8}}, {m68k_op_ori_8_pd7 , 0xffff, 0x0027, { 18, 18, 9, 9}}, {m68k_op_ori_8_aw , 0xffff, 0x0038, { 20, 20, 8, 8}}, {m68k_op_ori_8_al , 0xffff, 0x0039, { 24, 24, 8, 8}}, {m68k_op_ori_16_toc , 0xffff, 0x003c, { 20, 16, 12, 12}}, {m68k_op_ori_16_aw , 0xffff, 0x0078, { 20, 20, 8, 8}}, {m68k_op_ori_16_al , 0xffff, 0x0079, { 24, 24, 8, 8}}, {m68k_op_ori_16_tos , 0xffff, 0x007c, { 20, 16, 12, 12}}, {m68k_op_ori_32_aw , 0xffff, 0x00b8, { 32, 32, 8, 8}}, {m68k_op_ori_32_al , 0xffff, 0x00b9, { 36, 36, 8, 8}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_chk2cmp2_8_aw , 0xffff, 0x00f8, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_8_al , 0xffff, 0x00f9, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_8_pcdi , 0xffff, 0x00fa, { 0, 0, 23, 23}}, {m68k_op_chk2cmp2_8_pcix , 0xffff, 0x00fb, { 0, 0, 23, 23}}, #endif {m68k_op_andi_8_pi7 , 0xffff, 0x021f, { 16, 16, 8, 8}}, {m68k_op_andi_8_pd7 , 0xffff, 0x0227, { 18, 18, 9, 9}}, {m68k_op_andi_8_aw , 0xffff, 0x0238, { 20, 20, 8, 8}}, {m68k_op_andi_8_al , 0xffff, 0x0239, { 24, 24, 8, 8}}, {m68k_op_andi_16_toc , 0xffff, 0x023c, { 20, 16, 12, 12}}, {m68k_op_andi_16_aw , 0xffff, 0x0278, { 20, 20, 8, 8}}, {m68k_op_andi_16_al , 0xffff, 0x0279, { 24, 24, 8, 8}}, {m68k_op_andi_16_tos , 0xffff, 0x027c, { 20, 16, 12, 12}}, {m68k_op_andi_32_aw , 0xffff, 0x02b8, { 32, 32, 8, 8}}, {m68k_op_andi_32_al , 0xffff, 0x02b9, { 36, 36, 8, 8}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_chk2cmp2_16_aw , 0xffff, 0x02f8, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_16_al , 0xffff, 0x02f9, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_16_pcdi , 0xffff, 0x02fa, { 0, 0, 23, 23}}, {m68k_op_chk2cmp2_16_pcix , 0xffff, 0x02fb, { 0, 0, 23, 23}}, #endif {m68k_op_subi_8_pi7 , 0xffff, 0x041f, { 16, 16, 8, 8}}, {m68k_op_subi_8_pd7 , 0xffff, 0x0427, { 18, 18, 9, 9}}, {m68k_op_subi_8_aw , 0xffff, 0x0438, { 20, 20, 8, 8}}, {m68k_op_subi_8_al , 0xffff, 0x0439, { 24, 24, 8, 8}}, {m68k_op_subi_16_aw , 0xffff, 0x0478, { 20, 20, 8, 8}}, {m68k_op_subi_16_al , 0xffff, 0x0479, { 24, 24, 8, 8}}, {m68k_op_subi_32_aw , 0xffff, 0x04b8, { 32, 32, 8, 8}}, {m68k_op_subi_32_al , 0xffff, 0x04b9, { 36, 36, 8, 8}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_chk2cmp2_32_aw , 0xffff, 0x04f8, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_32_al , 0xffff, 0x04f9, { 0, 0, 22, 22}}, {m68k_op_chk2cmp2_32_pcdi , 0xffff, 0x04fa, { 0, 0, 23, 23}}, {m68k_op_chk2cmp2_32_pcix , 0xffff, 0x04fb, { 0, 0, 23, 23}}, #endif {m68k_op_addi_8_pi7 , 0xffff, 0x061f, { 16, 16, 8, 8}}, {m68k_op_addi_8_pd7 , 0xffff, 0x0627, { 18, 18, 9, 9}}, {m68k_op_addi_8_aw , 0xffff, 0x0638, { 20, 20, 8, 8}}, {m68k_op_addi_8_al , 0xffff, 0x0639, { 24, 24, 8, 8}}, {m68k_op_addi_16_aw , 0xffff, 0x0678, { 20, 20, 8, 8}}, {m68k_op_addi_16_al , 0xffff, 0x0679, { 24, 24, 8, 8}}, {m68k_op_addi_32_aw , 0xffff, 0x06b8, { 32, 32, 8, 8}}, {m68k_op_addi_32_al , 0xffff, 0x06b9, { 36, 36, 8, 8}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_callm_32_aw , 0xffff, 0x06f8, { 0, 0, 64, 64}}, {m68k_op_callm_32_al , 0xffff, 0x06f9, { 0, 0, 64, 64}}, {m68k_op_callm_32_pcdi , 0xffff, 0x06fa, { 0, 0, 65, 65}}, {m68k_op_callm_32_pcix , 0xffff, 0x06fb, { 0, 0, 67, 67}}, #endif {m68k_op_btst_8_s_pi7 , 0xffff, 0x081f, { 12, 12, 8, 8}}, {m68k_op_btst_8_s_pd7 , 0xffff, 0x0827, { 14, 14, 9, 9}}, {m68k_op_btst_8_s_aw , 0xffff, 0x0838, { 16, 16, 8, 8}}, {m68k_op_btst_8_s_al , 0xffff, 0x0839, { 20, 20, 8, 8}}, {m68k_op_btst_8_s_pcdi , 0xffff, 0x083a, { 16, 16, 9, 9}}, {m68k_op_btst_8_s_pcix , 0xffff, 0x083b, { 18, 18, 11, 11}}, {m68k_op_bchg_8_s_pi7 , 0xffff, 0x085f, { 16, 16, 8, 8}}, {m68k_op_bchg_8_s_pd7 , 0xffff, 0x0867, { 18, 18, 9, 9}}, {m68k_op_bchg_8_s_aw , 0xffff, 0x0878, { 20, 20, 8, 8}}, {m68k_op_bchg_8_s_al , 0xffff, 0x0879, { 24, 24, 8, 8}}, {m68k_op_bclr_8_s_pi7 , 0xffff, 0x089f, { 16, 16, 8, 8}}, {m68k_op_bclr_8_s_pd7 , 0xffff, 0x08a7, { 18, 18, 9, 9}}, {m68k_op_bclr_8_s_aw , 0xffff, 0x08b8, { 20, 20, 8, 8}}, {m68k_op_bclr_8_s_al , 0xffff, 0x08b9, { 24, 24, 8, 8}}, {m68k_op_bset_8_s_pi7 , 0xffff, 0x08df, { 16, 16, 8, 8}}, {m68k_op_bset_8_s_pd7 , 0xffff, 0x08e7, { 18, 18, 9, 9}}, {m68k_op_bset_8_s_aw , 0xffff, 0x08f8, { 20, 20, 8, 8}}, {m68k_op_bset_8_s_al , 0xffff, 0x08f9, { 24, 24, 8, 8}}, {m68k_op_eori_8_pi7 , 0xffff, 0x0a1f, { 16, 16, 8, 8}}, {m68k_op_eori_8_pd7 , 0xffff, 0x0a27, { 18, 18, 9, 9}}, {m68k_op_eori_8_aw , 0xffff, 0x0a38, { 20, 20, 8, 8}}, {m68k_op_eori_8_al , 0xffff, 0x0a39, { 24, 24, 8, 8}}, {m68k_op_eori_16_toc , 0xffff, 0x0a3c, { 20, 16, 12, 12}}, {m68k_op_eori_16_aw , 0xffff, 0x0a78, { 20, 20, 8, 8}}, {m68k_op_eori_16_al , 0xffff, 0x0a79, { 24, 24, 8, 8}}, {m68k_op_eori_16_tos , 0xffff, 0x0a7c, { 20, 16, 12, 12}}, {m68k_op_eori_32_aw , 0xffff, 0x0ab8, { 32, 32, 8, 8}}, {m68k_op_eori_32_al , 0xffff, 0x0ab9, { 36, 36, 8, 8}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cas_8_pi7 , 0xffff, 0x0adf, { 0, 0, 16, 16}}, {m68k_op_cas_8_pd7 , 0xffff, 0x0ae7, { 0, 0, 17, 17}}, {m68k_op_cas_8_aw , 0xffff, 0x0af8, { 0, 0, 16, 16}}, {m68k_op_cas_8_al , 0xffff, 0x0af9, { 0, 0, 16, 16}}, #endif {m68k_op_cmpi_8_pi7 , 0xffff, 0x0c1f, { 12, 12, 6, 6}}, {m68k_op_cmpi_8_pd7 , 0xffff, 0x0c27, { 14, 14, 7, 7}}, {m68k_op_cmpi_8_aw , 0xffff, 0x0c38, { 16, 16, 6, 6}}, {m68k_op_cmpi_8_al , 0xffff, 0x0c39, { 20, 20, 6, 6}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cmpi_8_pcdi , 0xffff, 0x0c3a, { 0, 0, 7, 7}}, {m68k_op_cmpi_8_pcix , 0xffff, 0x0c3b, { 0, 0, 9, 9}}, #endif {m68k_op_cmpi_16_aw , 0xffff, 0x0c78, { 16, 16, 6, 6}}, {m68k_op_cmpi_16_al , 0xffff, 0x0c79, { 20, 20, 6, 6}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cmpi_16_pcdi , 0xffff, 0x0c7a, { 0, 0, 7, 7}}, {m68k_op_cmpi_16_pcix , 0xffff, 0x0c7b, { 0, 0, 9, 9}}, #endif {m68k_op_cmpi_32_aw , 0xffff, 0x0cb8, { 24, 24, 6, 6}}, {m68k_op_cmpi_32_al , 0xffff, 0x0cb9, { 28, 28, 6, 6}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cmpi_32_pcdi , 0xffff, 0x0cba, { 0, 0, 7, 7}}, {m68k_op_cmpi_32_pcix , 0xffff, 0x0cbb, { 0, 0, 9, 9}}, {m68k_op_cas_16_aw , 0xffff, 0x0cf8, { 0, 0, 16, 16}}, {m68k_op_cas_16_al , 0xffff, 0x0cf9, { 0, 0, 16, 16}}, {m68k_op_cas2_16 , 0xffff, 0x0cfc, { 0, 0, 12, 12}}, #endif #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_moves_8_pi7 , 0xffff, 0x0e1f, { 0, 18, 9, 9}}, {m68k_op_moves_8_pd7 , 0xffff, 0x0e27, { 0, 20, 10, 10}}, {m68k_op_moves_8_aw , 0xffff, 0x0e38, { 0, 26, 9, 9}}, {m68k_op_moves_8_al , 0xffff, 0x0e39, { 0, 30, 9, 9}}, {m68k_op_moves_16_aw , 0xffff, 0x0e78, { 0, 26, 9, 9}}, {m68k_op_moves_16_al , 0xffff, 0x0e79, { 0, 30, 9, 9}}, {m68k_op_moves_32_aw , 0xffff, 0x0eb8, { 0, 32, 9, 9}}, {m68k_op_moves_32_al , 0xffff, 0x0eb9, { 0, 36, 9, 9}}, #endif #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_cas_32_aw , 0xffff, 0x0ef8, { 0, 0, 16, 16}}, {m68k_op_cas_32_al , 0xffff, 0x0ef9, { 0, 0, 16, 16}}, {m68k_op_cas2_32 , 0xffff, 0x0efc, { 0, 0, 12, 12}}, #endif {m68k_op_move_8_aw_pi7 , 0xffff, 0x11df, { 16, 16, 8, 8}}, {m68k_op_move_8_aw_pd7 , 0xffff, 0x11e7, { 18, 18, 9, 9}}, {m68k_op_move_8_aw_aw , 0xffff, 0x11f8, { 20, 20, 8, 8}}, {m68k_op_move_8_aw_al , 0xffff, 0x11f9, { 24, 24, 8, 8}}, {m68k_op_move_8_aw_pcdi , 0xffff, 0x11fa, { 20, 20, 9, 9}}, {m68k_op_move_8_aw_pcix , 0xffff, 0x11fb, { 22, 22, 11, 11}}, {m68k_op_move_8_aw_i , 0xffff, 0x11fc, { 16, 16, 6, 6}}, {m68k_op_move_8_al_pi7 , 0xffff, 0x13df, { 20, 20, 10, 10}}, {m68k_op_move_8_al_pd7 , 0xffff, 0x13e7, { 22, 22, 11, 11}}, {m68k_op_move_8_al_aw , 0xffff, 0x13f8, { 24, 24, 10, 10}}, {m68k_op_move_8_al_al , 0xffff, 0x13f9, { 28, 28, 10, 10}}, {m68k_op_move_8_al_pcdi , 0xffff, 0x13fa, { 24, 24, 11, 11}}, {m68k_op_move_8_al_pcix , 0xffff, 0x13fb, { 26, 26, 13, 13}}, {m68k_op_move_8_al_i , 0xffff, 0x13fc, { 20, 20, 8, 8}}, {m68k_op_move_8_pi7_pi7 , 0xffff, 0x1edf, { 12, 12, 8, 8}}, {m68k_op_move_8_pi7_pd7 , 0xffff, 0x1ee7, { 14, 14, 9, 9}}, {m68k_op_move_8_pi7_aw , 0xffff, 0x1ef8, { 16, 16, 8, 8}}, {m68k_op_move_8_pi7_al , 0xffff, 0x1ef9, { 20, 20, 8, 8}}, {m68k_op_move_8_pi7_pcdi , 0xffff, 0x1efa, { 16, 16, 9, 9}}, {m68k_op_move_8_pi7_pcix , 0xffff, 0x1efb, { 18, 18, 11, 11}}, {m68k_op_move_8_pi7_i , 0xffff, 0x1efc, { 12, 12, 6, 6}}, {m68k_op_move_8_pd7_pi7 , 0xffff, 0x1f1f, { 12, 12, 9, 9}}, {m68k_op_move_8_pd7_pd7 , 0xffff, 0x1f27, { 14, 14, 10, 10}}, {m68k_op_move_8_pd7_aw , 0xffff, 0x1f38, { 16, 16, 9, 9}}, {m68k_op_move_8_pd7_al , 0xffff, 0x1f39, { 20, 20, 9, 9}}, {m68k_op_move_8_pd7_pcdi , 0xffff, 0x1f3a, { 16, 16, 10, 10}}, {m68k_op_move_8_pd7_pcix , 0xffff, 0x1f3b, { 18, 18, 12, 12}}, {m68k_op_move_8_pd7_i , 0xffff, 0x1f3c, { 12, 12, 7, 7}}, {m68k_op_move_32_aw_aw , 0xffff, 0x21f8, { 28, 28, 8, 8}}, {m68k_op_move_32_aw_al , 0xffff, 0x21f9, { 32, 32, 8, 8}}, {m68k_op_move_32_aw_pcdi , 0xffff, 0x21fa, { 28, 28, 9, 9}}, {m68k_op_move_32_aw_pcix , 0xffff, 0x21fb, { 30, 30, 11, 11}}, {m68k_op_move_32_aw_i , 0xffff, 0x21fc, { 24, 24, 8, 8}}, {m68k_op_move_32_al_aw , 0xffff, 0x23f8, { 32, 32, 10, 10}}, {m68k_op_move_32_al_al , 0xffff, 0x23f9, { 36, 36, 10, 10}}, {m68k_op_move_32_al_pcdi , 0xffff, 0x23fa, { 32, 32, 11, 11}}, {m68k_op_move_32_al_pcix , 0xffff, 0x23fb, { 34, 34, 13, 13}}, {m68k_op_move_32_al_i , 0xffff, 0x23fc, { 28, 28, 10, 10}}, {m68k_op_move_16_aw_aw , 0xffff, 0x31f8, { 20, 20, 8, 8}}, {m68k_op_move_16_aw_al , 0xffff, 0x31f9, { 24, 24, 8, 8}}, {m68k_op_move_16_aw_pcdi , 0xffff, 0x31fa, { 20, 20, 9, 9}}, {m68k_op_move_16_aw_pcix , 0xffff, 0x31fb, { 22, 22, 11, 11}}, {m68k_op_move_16_aw_i , 0xffff, 0x31fc, { 16, 16, 6, 6}}, {m68k_op_move_16_al_aw , 0xffff, 0x33f8, { 24, 24, 10, 10}}, {m68k_op_move_16_al_al , 0xffff, 0x33f9, { 28, 28, 10, 10}}, {m68k_op_move_16_al_pcdi , 0xffff, 0x33fa, { 24, 24, 11, 11}}, {m68k_op_move_16_al_pcix , 0xffff, 0x33fb, { 26, 26, 13, 13}}, {m68k_op_move_16_al_i , 0xffff, 0x33fc, { 20, 20, 8, 8}}, {m68k_op_negx_8_pi7 , 0xffff, 0x401f, { 12, 12, 8, 8}}, {m68k_op_negx_8_pd7 , 0xffff, 0x4027, { 14, 14, 9, 9}}, {m68k_op_negx_8_aw , 0xffff, 0x4038, { 16, 16, 8, 8}}, {m68k_op_negx_8_al , 0xffff, 0x4039, { 20, 20, 8, 8}}, {m68k_op_negx_16_aw , 0xffff, 0x4078, { 16, 16, 8, 8}}, {m68k_op_negx_16_al , 0xffff, 0x4079, { 20, 20, 8, 8}}, {m68k_op_negx_32_aw , 0xffff, 0x40b8, { 24, 24, 8, 8}}, {m68k_op_negx_32_al , 0xffff, 0x40b9, { 28, 28, 8, 8}}, {m68k_op_move_16_frs_aw , 0xffff, 0x40f8, { 16, 16, 12, 12}}, {m68k_op_move_16_frs_al , 0xffff, 0x40f9, { 20, 20, 12, 12}}, {m68k_op_clr_8_pi7 , 0xffff, 0x421f, { 12, 8, 8, 8}}, {m68k_op_clr_8_pd7 , 0xffff, 0x4227, { 14, 10, 9, 9}}, {m68k_op_clr_8_aw , 0xffff, 0x4238, { 16, 12, 8, 8}}, {m68k_op_clr_8_al , 0xffff, 0x4239, { 20, 14, 8, 8}}, {m68k_op_clr_16_aw , 0xffff, 0x4278, { 16, 12, 8, 8}}, {m68k_op_clr_16_al , 0xffff, 0x4279, { 20, 14, 8, 8}}, {m68k_op_clr_32_aw , 0xffff, 0x42b8, { 24, 16, 8, 8}}, {m68k_op_clr_32_al , 0xffff, 0x42b9, { 28, 20, 8, 8}}, #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_move_16_frc_aw , 0xffff, 0x42f8, { 0, 16, 8, 8}}, {m68k_op_move_16_frc_al , 0xffff, 0x42f9, { 0, 20, 8, 8}}, #endif {m68k_op_neg_8_pi7 , 0xffff, 0x441f, { 12, 12, 8, 8}}, {m68k_op_neg_8_pd7 , 0xffff, 0x4427, { 14, 14, 9, 9}}, {m68k_op_neg_8_aw , 0xffff, 0x4438, { 16, 16, 8, 8}}, {m68k_op_neg_8_al , 0xffff, 0x4439, { 20, 20, 8, 8}}, {m68k_op_neg_16_aw , 0xffff, 0x4478, { 16, 16, 8, 8}}, {m68k_op_neg_16_al , 0xffff, 0x4479, { 20, 20, 8, 8}}, {m68k_op_neg_32_aw , 0xffff, 0x44b8, { 24, 24, 8, 8}}, {m68k_op_neg_32_al , 0xffff, 0x44b9, { 28, 28, 8, 8}}, {m68k_op_move_16_toc_aw , 0xffff, 0x44f8, { 20, 20, 8, 8}}, {m68k_op_move_16_toc_al , 0xffff, 0x44f9, { 24, 24, 8, 8}}, {m68k_op_move_16_toc_pcdi , 0xffff, 0x44fa, { 20, 20, 9, 9}}, {m68k_op_move_16_toc_pcix , 0xffff, 0x44fb, { 22, 22, 11, 11}}, {m68k_op_move_16_toc_i , 0xffff, 0x44fc, { 16, 16, 6, 6}}, {m68k_op_not_8_pi7 , 0xffff, 0x461f, { 12, 12, 8, 8}}, {m68k_op_not_8_pd7 , 0xffff, 0x4627, { 14, 14, 9, 9}}, {m68k_op_not_8_aw , 0xffff, 0x4638, { 16, 16, 8, 8}}, {m68k_op_not_8_al , 0xffff, 0x4639, { 20, 20, 8, 8}}, {m68k_op_not_16_aw , 0xffff, 0x4678, { 16, 16, 8, 8}}, {m68k_op_not_16_al , 0xffff, 0x4679, { 20, 20, 8, 8}}, {m68k_op_not_32_aw , 0xffff, 0x46b8, { 24, 24, 8, 8}}, {m68k_op_not_32_al , 0xffff, 0x46b9, { 28, 28, 8, 8}}, {m68k_op_move_16_tos_aw , 0xffff, 0x46f8, { 20, 20, 12, 12}}, {m68k_op_move_16_tos_al , 0xffff, 0x46f9, { 24, 24, 12, 12}}, {m68k_op_move_16_tos_pcdi , 0xffff, 0x46fa, { 20, 20, 13, 13}}, {m68k_op_move_16_tos_pcix , 0xffff, 0x46fb, { 22, 22, 15, 15}}, {m68k_op_move_16_tos_i , 0xffff, 0x46fc, { 16, 16, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_link_32_a7 , 0xffff, 0x480f, { 0, 0, 6, 6}}, #endif {m68k_op_nbcd_8_pi7 , 0xffff, 0x481f, { 12, 12, 10, 10}}, {m68k_op_nbcd_8_pd7 , 0xffff, 0x4827, { 14, 14, 11, 11}}, {m68k_op_nbcd_8_aw , 0xffff, 0x4838, { 16, 16, 10, 10}}, {m68k_op_nbcd_8_al , 0xffff, 0x4839, { 20, 20, 10, 10}}, {m68k_op_pea_32_aw , 0xffff, 0x4878, { 16, 16, 9, 9}}, {m68k_op_pea_32_al , 0xffff, 0x4879, { 20, 20, 9, 9}}, {m68k_op_pea_32_pcdi , 0xffff, 0x487a, { 16, 16, 10, 10}}, {m68k_op_pea_32_pcix , 0xffff, 0x487b, { 20, 20, 12, 12}}, {m68k_op_movem_16_re_aw , 0xffff, 0x48b8, { 12, 12, 8, 8}}, {m68k_op_movem_16_re_al , 0xffff, 0x48b9, { 16, 16, 8, 8}}, {m68k_op_movem_32_re_aw , 0xffff, 0x48f8, { 12, 12, 8, 8}}, {m68k_op_movem_32_re_al , 0xffff, 0x48f9, { 16, 16, 8, 8}}, {m68k_op_tst_8_pi7 , 0xffff, 0x4a1f, { 8, 8, 6, 6}}, {m68k_op_tst_8_pd7 , 0xffff, 0x4a27, { 10, 10, 7, 7}}, {m68k_op_tst_8_aw , 0xffff, 0x4a38, { 12, 12, 6, 6}}, {m68k_op_tst_8_al , 0xffff, 0x4a39, { 16, 16, 6, 6}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_tst_8_pcdi , 0xffff, 0x4a3a, { 0, 0, 7, 7}}, {m68k_op_tst_8_pcix , 0xffff, 0x4a3b, { 0, 0, 9, 9}}, {m68k_op_tst_8_i , 0xffff, 0x4a3c, { 0, 0, 6, 6}}, #endif {m68k_op_tst_16_aw , 0xffff, 0x4a78, { 12, 12, 6, 6}}, {m68k_op_tst_16_al , 0xffff, 0x4a79, { 16, 16, 6, 6}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_tst_16_pcdi , 0xffff, 0x4a7a, { 0, 0, 7, 7}}, {m68k_op_tst_16_pcix , 0xffff, 0x4a7b, { 0, 0, 9, 9}}, {m68k_op_tst_16_i , 0xffff, 0x4a7c, { 0, 0, 6, 6}}, #endif {m68k_op_tst_32_aw , 0xffff, 0x4ab8, { 16, 16, 6, 6}}, {m68k_op_tst_32_al , 0xffff, 0x4ab9, { 20, 20, 6, 6}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_tst_32_pcdi , 0xffff, 0x4aba, { 0, 0, 7, 7}}, {m68k_op_tst_32_pcix , 0xffff, 0x4abb, { 0, 0, 9, 9}}, {m68k_op_tst_32_i , 0xffff, 0x4abc, { 0, 0, 6, 6}}, #endif {m68k_op_tas_8_pi7 , 0xffff, 0x4adf, { 18, 18, 16, 16}}, {m68k_op_tas_8_pd7 , 0xffff, 0x4ae7, { 20, 20, 17, 17}}, {m68k_op_tas_8_aw , 0xffff, 0x4af8, { 22, 22, 16, 16}}, {m68k_op_tas_8_al , 0xffff, 0x4af9, { 26, 26, 16, 16}}, {m68k_op_illegal , 0xffff, 0x4afc, { 4, 4, 4, 4}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_mull_32_aw , 0xffff, 0x4c38, { 0, 0, 47, 47}}, {m68k_op_mull_32_al , 0xffff, 0x4c39, { 0, 0, 47, 47}}, {m68k_op_mull_32_pcdi , 0xffff, 0x4c3a, { 0, 0, 48, 48}}, {m68k_op_mull_32_pcix , 0xffff, 0x4c3b, { 0, 0, 50, 50}}, {m68k_op_mull_32_i , 0xffff, 0x4c3c, { 0, 0, 47, 47}}, {m68k_op_divl_32_aw , 0xffff, 0x4c78, { 0, 0, 88, 88}}, {m68k_op_divl_32_al , 0xffff, 0x4c79, { 0, 0, 88, 88}}, {m68k_op_divl_32_pcdi , 0xffff, 0x4c7a, { 0, 0, 89, 89}}, {m68k_op_divl_32_pcix , 0xffff, 0x4c7b, { 0, 0, 91, 91}}, {m68k_op_divl_32_i , 0xffff, 0x4c7c, { 0, 0, 88, 88}}, #endif {m68k_op_movem_16_er_aw , 0xffff, 0x4cb8, { 16, 16, 12, 12}}, {m68k_op_movem_16_er_al , 0xffff, 0x4cb9, { 20, 20, 12, 12}}, {m68k_op_movem_16_er_pcdi , 0xffff, 0x4cba, { 16, 16, 9, 9}}, {m68k_op_movem_16_er_pcix , 0xffff, 0x4cbb, { 18, 18, 11, 11}}, {m68k_op_movem_32_er_aw , 0xffff, 0x4cf8, { 16, 16, 12, 12}}, {m68k_op_movem_32_er_al , 0xffff, 0x4cf9, { 20, 20, 12, 12}}, {m68k_op_movem_32_er_pcdi , 0xffff, 0x4cfa, { 16, 16, 9, 9}}, {m68k_op_movem_32_er_pcix , 0xffff, 0x4cfb, { 18, 18, 11, 11}}, {m68k_op_link_16_a7 , 0xffff, 0x4e57, { 16, 16, 5, 5}}, {m68k_op_unlk_32_a7 , 0xffff, 0x4e5f, { 12, 12, 6, 6}}, {m68k_op_reset , 0xffff, 0x4e70, { 0, 0, 0, 0}}, {m68k_op_nop , 0xffff, 0x4e71, { 4, 4, 2, 2}}, {m68k_op_stop , 0xffff, 0x4e72, { 4, 4, 8, 8}}, {m68k_op_rte_32 , 0xffff, 0x4e73, { 20, 24, 20, 20}}, #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_rtd_32 , 0xffff, 0x4e74, { 0, 16, 10, 10}}, #endif {m68k_op_rts_32 , 0xffff, 0x4e75, { 16, 16, 10, 10}}, {m68k_op_trapv , 0xffff, 0x4e76, { 4, 4, 4, 4}}, {m68k_op_rtr_32 , 0xffff, 0x4e77, { 20, 20, 14, 14}}, #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_movec_32_cr , 0xffff, 0x4e7a, { 0, 12, 6, 6}}, {m68k_op_movec_32_rc , 0xffff, 0x4e7b, { 0, 10, 12, 12}}, #endif {m68k_op_jsr_32_aw , 0xffff, 0x4eb8, { 18, 18, 4, 4}}, {m68k_op_jsr_32_al , 0xffff, 0x4eb9, { 20, 20, 4, 4}}, {m68k_op_jsr_32_pcdi , 0xffff, 0x4eba, { 18, 18, 5, 5}}, {m68k_op_jsr_32_pcix , 0xffff, 0x4ebb, { 22, 22, 7, 7}}, {m68k_op_jmp_32_aw , 0xffff, 0x4ef8, { 10, 10, 4, 4}}, {m68k_op_jmp_32_al , 0xffff, 0x4ef9, { 12, 12, 4, 4}}, {m68k_op_jmp_32_pcdi , 0xffff, 0x4efa, { 10, 10, 5, 5}}, {m68k_op_jmp_32_pcix , 0xffff, 0x4efb, { 14, 14, 7, 7}}, {m68k_op_st_8_pi7 , 0xffff, 0x50df, { 12, 12, 10, 10}}, {m68k_op_st_8_pd7 , 0xffff, 0x50e7, { 14, 14, 11, 11}}, {m68k_op_st_8_aw , 0xffff, 0x50f8, { 16, 16, 10, 10}}, {m68k_op_st_8_al , 0xffff, 0x50f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapt_16 , 0xffff, 0x50fa, { 0, 0, 6, 6}}, {m68k_op_trapt_32 , 0xffff, 0x50fb, { 0, 0, 8, 8}}, {m68k_op_trapt , 0xffff, 0x50fc, { 0, 0, 4, 4}}, #endif {m68k_op_sf_8_pi7 , 0xffff, 0x51df, { 12, 12, 10, 10}}, {m68k_op_sf_8_pd7 , 0xffff, 0x51e7, { 14, 14, 11, 11}}, {m68k_op_sf_8_aw , 0xffff, 0x51f8, { 16, 16, 10, 10}}, {m68k_op_sf_8_al , 0xffff, 0x51f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapf_16 , 0xffff, 0x51fa, { 0, 0, 6, 6}}, {m68k_op_trapf_32 , 0xffff, 0x51fb, { 0, 0, 8, 8}}, {m68k_op_trapf , 0xffff, 0x51fc, { 0, 0, 4, 4}}, #endif {m68k_op_shi_8_pi7 , 0xffff, 0x52df, { 12, 12, 10, 10}}, {m68k_op_shi_8_pd7 , 0xffff, 0x52e7, { 14, 14, 11, 11}}, {m68k_op_shi_8_aw , 0xffff, 0x52f8, { 16, 16, 10, 10}}, {m68k_op_shi_8_al , 0xffff, 0x52f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_traphi_16 , 0xffff, 0x52fa, { 0, 0, 6, 6}}, {m68k_op_traphi_32 , 0xffff, 0x52fb, { 0, 0, 8, 8}}, {m68k_op_traphi , 0xffff, 0x52fc, { 0, 0, 4, 4}}, #endif {m68k_op_sls_8_pi7 , 0xffff, 0x53df, { 12, 12, 10, 10}}, {m68k_op_sls_8_pd7 , 0xffff, 0x53e7, { 14, 14, 11, 11}}, {m68k_op_sls_8_aw , 0xffff, 0x53f8, { 16, 16, 10, 10}}, {m68k_op_sls_8_al , 0xffff, 0x53f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapls_16 , 0xffff, 0x53fa, { 0, 0, 6, 6}}, {m68k_op_trapls_32 , 0xffff, 0x53fb, { 0, 0, 8, 8}}, {m68k_op_trapls , 0xffff, 0x53fc, { 0, 0, 4, 4}}, #endif {m68k_op_scc_8_pi7 , 0xffff, 0x54df, { 12, 12, 10, 10}}, {m68k_op_scc_8_pd7 , 0xffff, 0x54e7, { 14, 14, 11, 11}}, {m68k_op_scc_8_aw , 0xffff, 0x54f8, { 16, 16, 10, 10}}, {m68k_op_scc_8_al , 0xffff, 0x54f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapcc_16 , 0xffff, 0x54fa, { 0, 0, 6, 6}}, {m68k_op_trapcc_32 , 0xffff, 0x54fb, { 0, 0, 8, 8}}, {m68k_op_trapcc , 0xffff, 0x54fc, { 0, 0, 4, 4}}, #endif {m68k_op_scs_8_pi7 , 0xffff, 0x55df, { 12, 12, 10, 10}}, {m68k_op_scs_8_pd7 , 0xffff, 0x55e7, { 14, 14, 11, 11}}, {m68k_op_scs_8_aw , 0xffff, 0x55f8, { 16, 16, 10, 10}}, {m68k_op_scs_8_al , 0xffff, 0x55f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapcs_16 , 0xffff, 0x55fa, { 0, 0, 6, 6}}, {m68k_op_trapcs_32 , 0xffff, 0x55fb, { 0, 0, 8, 8}}, {m68k_op_trapcs , 0xffff, 0x55fc, { 0, 0, 4, 4}}, #endif {m68k_op_sne_8_pi7 , 0xffff, 0x56df, { 12, 12, 10, 10}}, {m68k_op_sne_8_pd7 , 0xffff, 0x56e7, { 14, 14, 11, 11}}, {m68k_op_sne_8_aw , 0xffff, 0x56f8, { 16, 16, 10, 10}}, {m68k_op_sne_8_al , 0xffff, 0x56f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapne_16 , 0xffff, 0x56fa, { 0, 0, 6, 6}}, {m68k_op_trapne_32 , 0xffff, 0x56fb, { 0, 0, 8, 8}}, {m68k_op_trapne , 0xffff, 0x56fc, { 0, 0, 4, 4}}, #endif {m68k_op_seq_8_pi7 , 0xffff, 0x57df, { 12, 12, 10, 10}}, {m68k_op_seq_8_pd7 , 0xffff, 0x57e7, { 14, 14, 11, 11}}, {m68k_op_seq_8_aw , 0xffff, 0x57f8, { 16, 16, 10, 10}}, {m68k_op_seq_8_al , 0xffff, 0x57f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapeq_16 , 0xffff, 0x57fa, { 0, 0, 6, 6}}, {m68k_op_trapeq_32 , 0xffff, 0x57fb, { 0, 0, 8, 8}}, {m68k_op_trapeq , 0xffff, 0x57fc, { 0, 0, 4, 4}}, #endif {m68k_op_svc_8_pi7 , 0xffff, 0x58df, { 12, 12, 10, 10}}, {m68k_op_svc_8_pd7 , 0xffff, 0x58e7, { 14, 14, 11, 11}}, {m68k_op_svc_8_aw , 0xffff, 0x58f8, { 16, 16, 10, 10}}, {m68k_op_svc_8_al , 0xffff, 0x58f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapvc_16 , 0xffff, 0x58fa, { 0, 0, 6, 6}}, {m68k_op_trapvc_32 , 0xffff, 0x58fb, { 0, 0, 8, 8}}, {m68k_op_trapvc , 0xffff, 0x58fc, { 0, 0, 4, 4}}, #endif {m68k_op_svs_8_pi7 , 0xffff, 0x59df, { 12, 12, 10, 10}}, {m68k_op_svs_8_pd7 , 0xffff, 0x59e7, { 14, 14, 11, 11}}, {m68k_op_svs_8_aw , 0xffff, 0x59f8, { 16, 16, 10, 10}}, {m68k_op_svs_8_al , 0xffff, 0x59f9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapvs_16 , 0xffff, 0x59fa, { 0, 0, 6, 6}}, {m68k_op_trapvs_32 , 0xffff, 0x59fb, { 0, 0, 8, 8}}, {m68k_op_trapvs , 0xffff, 0x59fc, { 0, 0, 4, 4}}, #endif {m68k_op_spl_8_pi7 , 0xffff, 0x5adf, { 12, 12, 10, 10}}, {m68k_op_spl_8_pd7 , 0xffff, 0x5ae7, { 14, 14, 11, 11}}, {m68k_op_spl_8_aw , 0xffff, 0x5af8, { 16, 16, 10, 10}}, {m68k_op_spl_8_al , 0xffff, 0x5af9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trappl_16 , 0xffff, 0x5afa, { 0, 0, 6, 6}}, {m68k_op_trappl_32 , 0xffff, 0x5afb, { 0, 0, 8, 8}}, {m68k_op_trappl , 0xffff, 0x5afc, { 0, 0, 4, 4}}, #endif {m68k_op_smi_8_pi7 , 0xffff, 0x5bdf, { 12, 12, 10, 10}}, {m68k_op_smi_8_pd7 , 0xffff, 0x5be7, { 14, 14, 11, 11}}, {m68k_op_smi_8_aw , 0xffff, 0x5bf8, { 16, 16, 10, 10}}, {m68k_op_smi_8_al , 0xffff, 0x5bf9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapmi_16 , 0xffff, 0x5bfa, { 0, 0, 6, 6}}, {m68k_op_trapmi_32 , 0xffff, 0x5bfb, { 0, 0, 8, 8}}, {m68k_op_trapmi , 0xffff, 0x5bfc, { 0, 0, 4, 4}}, #endif {m68k_op_sge_8_pi7 , 0xffff, 0x5cdf, { 12, 12, 10, 10}}, {m68k_op_sge_8_pd7 , 0xffff, 0x5ce7, { 14, 14, 11, 11}}, {m68k_op_sge_8_aw , 0xffff, 0x5cf8, { 16, 16, 10, 10}}, {m68k_op_sge_8_al , 0xffff, 0x5cf9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapge_16 , 0xffff, 0x5cfa, { 0, 0, 6, 6}}, {m68k_op_trapge_32 , 0xffff, 0x5cfb, { 0, 0, 8, 8}}, {m68k_op_trapge , 0xffff, 0x5cfc, { 0, 0, 4, 4}}, #endif {m68k_op_slt_8_pi7 , 0xffff, 0x5ddf, { 12, 12, 10, 10}}, {m68k_op_slt_8_pd7 , 0xffff, 0x5de7, { 14, 14, 11, 11}}, {m68k_op_slt_8_aw , 0xffff, 0x5df8, { 16, 16, 10, 10}}, {m68k_op_slt_8_al , 0xffff, 0x5df9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_traplt_16 , 0xffff, 0x5dfa, { 0, 0, 6, 6}}, {m68k_op_traplt_32 , 0xffff, 0x5dfb, { 0, 0, 8, 8}}, {m68k_op_traplt , 0xffff, 0x5dfc, { 0, 0, 4, 4}}, #endif {m68k_op_sgt_8_pi7 , 0xffff, 0x5edf, { 12, 12, 10, 10}}, {m68k_op_sgt_8_pd7 , 0xffff, 0x5ee7, { 14, 14, 11, 11}}, {m68k_op_sgt_8_aw , 0xffff, 0x5ef8, { 16, 16, 10, 10}}, {m68k_op_sgt_8_al , 0xffff, 0x5ef9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_trapgt_16 , 0xffff, 0x5efa, { 0, 0, 6, 6}}, {m68k_op_trapgt_32 , 0xffff, 0x5efb, { 0, 0, 8, 8}}, {m68k_op_trapgt , 0xffff, 0x5efc, { 0, 0, 4, 4}}, #endif {m68k_op_sle_8_pi7 , 0xffff, 0x5fdf, { 12, 12, 10, 10}}, {m68k_op_sle_8_pd7 , 0xffff, 0x5fe7, { 14, 14, 11, 11}}, {m68k_op_sle_8_aw , 0xffff, 0x5ff8, { 16, 16, 10, 10}}, {m68k_op_sle_8_al , 0xffff, 0x5ff9, { 20, 20, 10, 10}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_traple_16 , 0xffff, 0x5ffa, { 0, 0, 6, 6}}, {m68k_op_traple_32 , 0xffff, 0x5ffb, { 0, 0, 8, 8}}, {m68k_op_traple , 0xffff, 0x5ffc, { 0, 0, 4, 4}}, #endif {m68k_op_bra_16 , 0xffff, 0x6000, { 10, 10, 10, 10}}, {m68k_op_bra_32 , 0xffff, 0x60ff, { 10, 10, 10, 10}}, {m68k_op_bsr_16 , 0xffff, 0x6100, { 18, 18, 7, 7}}, {m68k_op_bsr_32 , 0xffff, 0x61ff, { 18, 18, 7, 7}}, {m68k_op_bhi_16 , 0xffff, 0x6200, { 10, 10, 6, 6}}, {m68k_op_bhi_32 , 0xffff, 0x62ff, { 10, 10, 6, 6}}, {m68k_op_bls_16 , 0xffff, 0x6300, { 10, 10, 6, 6}}, {m68k_op_bls_32 , 0xffff, 0x63ff, { 10, 10, 6, 6}}, {m68k_op_bcc_16 , 0xffff, 0x6400, { 10, 10, 6, 6}}, {m68k_op_bcc_32 , 0xffff, 0x64ff, { 10, 10, 6, 6}}, {m68k_op_bcs_16 , 0xffff, 0x6500, { 10, 10, 6, 6}}, {m68k_op_bcs_32 , 0xffff, 0x65ff, { 10, 10, 6, 6}}, {m68k_op_bne_16 , 0xffff, 0x6600, { 10, 10, 6, 6}}, {m68k_op_bne_32 , 0xffff, 0x66ff, { 10, 10, 6, 6}}, {m68k_op_beq_16 , 0xffff, 0x6700, { 10, 10, 6, 6}}, {m68k_op_beq_32 , 0xffff, 0x67ff, { 10, 10, 6, 6}}, {m68k_op_bvc_16 , 0xffff, 0x6800, { 10, 10, 6, 6}}, {m68k_op_bvc_32 , 0xffff, 0x68ff, { 10, 10, 6, 6}}, {m68k_op_bvs_16 , 0xffff, 0x6900, { 10, 10, 6, 6}}, {m68k_op_bvs_32 , 0xffff, 0x69ff, { 10, 10, 6, 6}}, {m68k_op_bpl_16 , 0xffff, 0x6a00, { 10, 10, 6, 6}}, {m68k_op_bpl_32 , 0xffff, 0x6aff, { 10, 10, 6, 6}}, {m68k_op_bmi_16 , 0xffff, 0x6b00, { 10, 10, 6, 6}}, {m68k_op_bmi_32 , 0xffff, 0x6bff, { 10, 10, 6, 6}}, {m68k_op_bge_16 , 0xffff, 0x6c00, { 10, 10, 6, 6}}, {m68k_op_bge_32 , 0xffff, 0x6cff, { 10, 10, 6, 6}}, {m68k_op_blt_16 , 0xffff, 0x6d00, { 10, 10, 6, 6}}, {m68k_op_blt_32 , 0xffff, 0x6dff, { 10, 10, 6, 6}}, {m68k_op_bgt_16 , 0xffff, 0x6e00, { 10, 10, 6, 6}}, {m68k_op_bgt_32 , 0xffff, 0x6eff, { 10, 10, 6, 6}}, {m68k_op_ble_16 , 0xffff, 0x6f00, { 10, 10, 6, 6}}, {m68k_op_ble_32 , 0xffff, 0x6fff, { 10, 10, 6, 6}}, {m68k_op_sbcd_8_mm_axy7 , 0xffff, 0x8f0f, { 18, 18, 16, 16}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_pack_16_mm_axy7 , 0xffff, 0x8f4f, { 0, 0, 13, 13}}, {m68k_op_unpk_16_mm_axy7 , 0xffff, 0x8f8f, { 0, 0, 13, 13}}, #endif {m68k_op_subx_8_mm_axy7 , 0xffff, 0x9f0f, { 18, 18, 12, 12}}, {m68k_op_cmpm_8_axy7 , 0xffff, 0xbf0f, { 12, 12, 9, 9}}, {m68k_op_abcd_8_mm_axy7 , 0xffff, 0xcf0f, { 18, 18, 16, 16}}, {m68k_op_addx_8_mm_axy7 , 0xffff, 0xdf0f, { 18, 18, 12, 12}}, {m68k_op_asr_16_aw , 0xffff, 0xe0f8, { 16, 16, 9, 9}}, {m68k_op_asr_16_al , 0xffff, 0xe0f9, { 20, 20, 9, 9}}, {m68k_op_asl_16_aw , 0xffff, 0xe1f8, { 16, 16, 10, 10}}, {m68k_op_asl_16_al , 0xffff, 0xe1f9, { 20, 20, 10, 10}}, {m68k_op_lsr_16_aw , 0xffff, 0xe2f8, { 16, 16, 9, 9}}, {m68k_op_lsr_16_al , 0xffff, 0xe2f9, { 20, 20, 9, 9}}, {m68k_op_lsl_16_aw , 0xffff, 0xe3f8, { 16, 16, 9, 9}}, {m68k_op_lsl_16_al , 0xffff, 0xe3f9, { 20, 20, 9, 9}}, {m68k_op_roxr_16_aw , 0xffff, 0xe4f8, { 16, 16, 9, 9}}, {m68k_op_roxr_16_al , 0xffff, 0xe4f9, { 20, 20, 9, 9}}, {m68k_op_roxl_16_aw , 0xffff, 0xe5f8, { 16, 16, 9, 9}}, {m68k_op_roxl_16_al , 0xffff, 0xe5f9, { 20, 20, 9, 9}}, {m68k_op_ror_16_aw , 0xffff, 0xe6f8, { 16, 16, 11, 11}}, {m68k_op_ror_16_al , 0xffff, 0xe6f9, { 20, 20, 11, 11}}, {m68k_op_rol_16_aw , 0xffff, 0xe7f8, { 16, 16, 11, 11}}, {m68k_op_rol_16_al , 0xffff, 0xe7f9, { 20, 20, 11, 11}}, #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 {m68k_op_bftst_32_aw , 0xffff, 0xe8f8, { 0, 0, 17, 17}}, {m68k_op_bftst_32_al , 0xffff, 0xe8f9, { 0, 0, 17, 17}}, {m68k_op_bftst_32_pcdi , 0xffff, 0xe8fa, { 0, 0, 18, 18}}, {m68k_op_bftst_32_pcix , 0xffff, 0xe8fb, { 0, 0, 20, 20}}, {m68k_op_bfextu_32_aw , 0xffff, 0xe9f8, { 0, 0, 19, 19}}, {m68k_op_bfextu_32_al , 0xffff, 0xe9f9, { 0, 0, 19, 19}}, {m68k_op_bfextu_32_pcdi , 0xffff, 0xe9fa, { 0, 0, 20, 20}}, {m68k_op_bfextu_32_pcix , 0xffff, 0xe9fb, { 0, 0, 22, 22}}, {m68k_op_bfchg_32_aw , 0xffff, 0xeaf8, { 0, 0, 24, 24}}, {m68k_op_bfchg_32_al , 0xffff, 0xeaf9, { 0, 0, 24, 24}}, {m68k_op_bfexts_32_aw , 0xffff, 0xebf8, { 0, 0, 19, 19}}, {m68k_op_bfexts_32_al , 0xffff, 0xebf9, { 0, 0, 19, 19}}, {m68k_op_bfexts_32_pcdi , 0xffff, 0xebfa, { 0, 0, 20, 20}}, {m68k_op_bfexts_32_pcix , 0xffff, 0xebfb, { 0, 0, 22, 22}}, {m68k_op_bfclr_32_aw , 0xffff, 0xecf8, { 0, 0, 24, 24}}, {m68k_op_bfclr_32_al , 0xffff, 0xecf9, { 0, 0, 24, 24}}, {m68k_op_bfffo_32_aw , 0xffff, 0xedf8, { 0, 0, 32, 32}}, {m68k_op_bfffo_32_al , 0xffff, 0xedf9, { 0, 0, 32, 32}}, {m68k_op_bfffo_32_pcdi , 0xffff, 0xedfa, { 0, 0, 33, 33}}, {m68k_op_bfffo_32_pcix , 0xffff, 0xedfb, { 0, 0, 35, 35}}, {m68k_op_bfset_32_aw , 0xffff, 0xeef8, { 0, 0, 24, 24}}, {m68k_op_bfset_32_al , 0xffff, 0xeef9, { 0, 0, 24, 24}}, {m68k_op_bfins_32_aw , 0xffff, 0xeff8, { 0, 0, 21, 21}}, {m68k_op_bfins_32_al , 0xffff, 0xeff9, { 0, 0, 21, 21}}, #endif #if M68K_EMULATE_040 {m68k_op_pflush_32 , 0xffff, 0xf518, { 0, 0, 0, 4}}, #endif {0, 0, 0, {0, 0, 0, 0}} }; /* Build the opcode handler jump table */ void m68ki_build_opcode_table(void) { const opcode_handler_struct *ostruct; int instr; int i; int j; int k; for(i = 0; i < 256; i++) for(k=0;k<NUM_CPU_TYPES;k++) m68ki_exception_cycle_table[k][i] = m68ki_exception_cycle_table[k][i] * 7; for(i = 0; i < 0x10000; i++) { /* default to illegal */ m68ki_instruction_jump_table[i] = m68k_op_illegal; for(k=0;k<NUM_CPU_TYPES;k++) m68ki_cycles[k][i] = 0; } ostruct = m68k_opcode_handler_table; while(ostruct->mask != 0xff00) { for(i = 0;i < 0x10000;i++) { if((i & ostruct->mask) == ostruct->match) { m68ki_instruction_jump_table[i] = ostruct->opcode_handler; for(k=0;k<NUM_CPU_TYPES;k++) m68ki_cycles[k][i] = ostruct->cycles[k]*7; } } ostruct++; } while(ostruct->mask == 0xff00) { for(i = 0;i <= 0xff;i++) { m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; for(k=0;k<NUM_CPU_TYPES;k++) m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k]*7; } ostruct++; } while(ostruct->mask == 0xf1f8) { for(i = 0;i < 8;i++) { for(j = 0;j < 8;j++) { instr = ostruct->match | (i << 9) | j; m68ki_instruction_jump_table[instr] = ostruct->opcode_handler; for(k=0;k<NUM_CPU_TYPES;k++) m68ki_cycles[k][instr] = ostruct->cycles[k]*7; } } ostruct++; } while(ostruct->mask == 0xfff0) { for(i = 0;i <= 0x0f;i++) { m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; for(k=0;k<NUM_CPU_TYPES;k++) m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k]*7; } ostruct++; } while(ostruct->mask == 0xf1ff) { for(i = 0;i <= 0x07;i++) { m68ki_instruction_jump_table[ostruct->match | (i << 9)] = ostruct->opcode_handler; for(k=0;k<NUM_CPU_TYPES;k++) m68ki_cycles[k][ostruct->match | (i << 9)] = ostruct->cycles[k]*7; } ostruct++; } while(ostruct->mask == 0xfff8) { for(i = 0;i <= 0x07;i++) { m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; for(k=0;k<NUM_CPU_TYPES;k++) m68ki_cycles[k][ostruct->match | i] = ostruct->cycles[k]*7; } ostruct++; } while(ostruct->mask == 0xffff) { m68ki_instruction_jump_table[ostruct->match] = ostruct->opcode_handler; for(k=0;k<NUM_CPU_TYPES;k++) m68ki_cycles[k][ostruct->match] = ostruct->cycles[k]*7; ostruct++; } } /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */
zyking1987-genplus-droid
genplusgx/m68k/m68kops.c
C
gpl2
873,442
#ifndef M68K__HEADER #define M68K__HEADER /* ======================================================================== */ /* ========================= LICENSING & COPYRIGHT ======================== */ /* ======================================================================== */ /* * MUSASHI * Version 3.32 * * A portable Motorola M680x0 processor emulation engine. * Copyright Karl Stenerud. All rights reserved. * * This code may be freely used for non-commercial purposes as long as this * copyright notice remains unaltered in the source code and any binary files * containing this code in compiled form. * * All other licensing terms must be negotiated with the author * (Karl Stenerud). * * The latest version of this code can be obtained at: * http://kstenerud.cjb.net */ /* ======================================================================== */ /* ============================= CONFIGURATION ============================ */ /* ======================================================================== */ /* Import the configuration for this build */ #include "m68kconf.h" /* ======================================================================== */ /* ============================ GENERAL DEFINES =========================== */ /* ======================================================================== */ /* There are 7 levels of interrupt to the 68K. * A transition from < 7 to 7 will cause a non-maskable interrupt (NMI). */ #define M68K_IRQ_NONE 0 #define M68K_IRQ_1 1 #define M68K_IRQ_2 2 #define M68K_IRQ_3 3 #define M68K_IRQ_4 4 #define M68K_IRQ_5 5 #define M68K_IRQ_6 6 #define M68K_IRQ_7 7 /* Special interrupt acknowledge values. * Use these as special returns from the interrupt acknowledge callback * (specified later in this header). */ /* Causes an interrupt autovector (0x18 + interrupt level) to be taken. * This happens in a real 68K if VPA or AVEC is asserted during an interrupt * acknowledge cycle instead of DTACK. */ #define M68K_INT_ACK_AUTOVECTOR 0xffffffff /* Causes the spurious interrupt vector (0x18) to be taken * This happens in a real 68K if BERR is asserted during the interrupt * acknowledge cycle (i.e. no devices responded to the acknowledge). */ #define M68K_INT_ACK_SPURIOUS 0xfffffffe /* CPU types for use in m68k_set_cpu_type() */ enum { M68K_CPU_TYPE_INVALID, M68K_CPU_TYPE_68000, M68K_CPU_TYPE_68008, M68K_CPU_TYPE_68010, M68K_CPU_TYPE_68EC020, M68K_CPU_TYPE_68020, M68K_CPU_TYPE_68030, /* Supported by disassembler ONLY */ M68K_CPU_TYPE_68040 /* Supported by disassembler ONLY */ }; /* Registers used by m68k_get_reg() and m68k_set_reg() */ typedef enum { /* Real registers */ M68K_REG_D0, /* Data registers */ M68K_REG_D1, M68K_REG_D2, M68K_REG_D3, M68K_REG_D4, M68K_REG_D5, M68K_REG_D6, M68K_REG_D7, M68K_REG_A0, /* Address registers */ M68K_REG_A1, M68K_REG_A2, M68K_REG_A3, M68K_REG_A4, M68K_REG_A5, M68K_REG_A6, M68K_REG_A7, M68K_REG_PC, /* Program Counter */ M68K_REG_SR, /* Status Register */ M68K_REG_SP, /* The current Stack Pointer (located in A7) */ M68K_REG_USP, /* User Stack Pointer */ M68K_REG_ISP, /* Interrupt Stack Pointer */ M68K_REG_MSP, /* Master Stack Pointer */ M68K_REG_SFC, /* Source Function Code */ M68K_REG_DFC, /* Destination Function Code */ M68K_REG_VBR, /* Vector Base Register */ M68K_REG_CACR, /* Cache Control Register */ M68K_REG_CAAR, /* Cache Address Register */ /* Assumed registers */ /* These are cheat registers which emulate the 1-longword prefetch * present in the 68000 and 68010. */ M68K_REG_PREF_ADDR, /* Last prefetch address */ M68K_REG_PREF_DATA, /* Last prefetch data */ /* Convenience registers */ M68K_REG_PPC, /* Previous value in the program counter */ M68K_REG_IR, /* Instruction register */ M68K_REG_CPU_TYPE /* Type of CPU being run */ } m68k_register_t; /* ======================================================================== */ /* ====================== FUNCTIONS CALLED BY THE CPU ===================== */ /* ======================================================================== */ /* You will have to implement these functions */ /* read/write functions called by the CPU to access memory. * while values used are 32 bits, only the appropriate number * of bits are relevant (i.e. in write_memory_8, only the lower 8 bits * of value should be written to memory). * * NOTE: I have separated the immediate and PC-relative memory fetches * from the other memory fetches because some systems require * differentiation between PROGRAM and DATA fetches (usually * for security setups such as encryption). * This separation can either be achieved by setting * M68K_SEPARATE_READS in m68kconf.h and defining * the read functions, or by setting M68K_EMULATE_FC and * making a function code callback function. * Using the callback offers better emulation coverage * because you can also monitor whether the CPU is in SYSTEM or * USER mode, but it is also slower. */ /* Read from anywhere */ unsigned int m68k_read_memory_8(unsigned int address); unsigned int m68k_read_memory_16(unsigned int address); unsigned int m68k_read_memory_32(unsigned int address); /* Memory access for the disassembler */ unsigned int m68k_read_disassembler_8 (unsigned int address); unsigned int m68k_read_disassembler_16 (unsigned int address); unsigned int m68k_read_disassembler_32 (unsigned int address); /* Write to anywhere */ void m68k_write_memory_8(unsigned int address, unsigned int value); void m68k_write_memory_16(unsigned int address, unsigned int value); void m68k_write_memory_32(unsigned int address, unsigned int value); #include "../macros.h" typedef struct { unsigned char *base; unsigned int (*read8)(unsigned int address); unsigned int (*read16)(unsigned int address); void (*write8)(unsigned int address, unsigned int data); void (*write16)(unsigned int address, unsigned int data); } _m68k_memory_map; _m68k_memory_map m68k_memory_map[256]; /* Read data immediately following the PC */ #define m68k_read_immediate_16(address) *(uint16 *)(m68k_memory_map[((address)>>16)&0xff].base + ((address) & 0xffff)) #define m68k_read_immediate_32(address) (m68k_read_immediate_16(address) << 16) | (m68k_read_immediate_16(address+2)) /* Read data relative to the PC */ #define m68k_read_pcrelative_8(address) READ_BYTE(m68k_memory_map[((address)>>16)&0xff].base, (address) & 0xffff) #define m68k_read_pcrelative_16(address) m68k_read_immediate_16(address) #define m68k_read_pcrelative_32(address) m68k_read_immediate_32(address) /* Special call to simulate undocumented 68k behavior when move.l with a * predecrement destination mode is executed. * To simulate real 68k behavior, first write the high word to * [address+2], and then write the low word to [address]. * * Enable this functionality with M68K_SIMULATE_PD_WRITES in m68kconf.h. */ void m68k_write_memory_32_pd(unsigned int address, unsigned int value); /* ======================================================================== */ /* ============================== CALLBACKS =============================== */ /* ======================================================================== */ /* These functions allow you to set callbacks to the host when specific events * occur. Note that you must enable the corresponding value in m68kconf.h * in order for these to do anything useful. * Note: I have defined default callbacks which are used if you have enabled * the corresponding #define in m68kconf.h but either haven't assigned a * callback or have assigned a callback of NULL. */ /* Set the callback for an interrupt acknowledge. * You must enable M68K_EMULATE_INT_ACK in m68kconf.h. * The CPU will call the callback with the interrupt level being acknowledged. * The host program must return either a vector from 0x02-0xff, or one of the * special interrupt acknowledge values specified earlier in this header. * If this is not implemented, the CPU will always assume an autovectored * interrupt, and will automatically clear the interrupt request when it * services the interrupt. * Default behavior: return M68K_INT_ACK_AUTOVECTOR. */ void m68k_set_int_ack_callback(int (*callback)(int int_level)); /* Set the callback for a breakpoint acknowledge (68010+). * You must enable M68K_EMULATE_BKPT_ACK in m68kconf.h. * The CPU will call the callback with whatever was in the data field of the * BKPT instruction for 68020+, or 0 for 68010. * Default behavior: do nothing. */ void m68k_set_bkpt_ack_callback(void (*callback)(unsigned int data)); /* Set the callback for the RESET instruction. * You must enable M68K_EMULATE_RESET in m68kconf.h. * The CPU calls this callback every time it encounters a RESET instruction. * Default behavior: do nothing. */ void m68k_set_reset_instr_callback(void (*callback)(void)); /* Set the callback for the CMPI.L #v, Dn instruction. * You must enable M68K_CMPILD_HAS_CALLBACK in m68kconf.h. * The CPU calls this callback every time it encounters a CMPI.L #v, Dn instruction. * Default behavior: do nothing. */ void m68k_set_cmpild_instr_callback(void (*callback)(unsigned int val, int reg)); /* Set the callback for the RTE instruction. * You must enable M68K_RTE_HAS_CALLBACK in m68kconf.h. * The CPU calls this callback every time it encounters a RTE instruction. * Default behavior: do nothing. */ void m68k_set_rte_instr_callback(void (*callback)(void)); /* Set the callback for the TAS instruction. * You must enable M68K_TAS_HAS_CALLBACK in m68kconf.h. * The CPU calls this callback every time it encounters a TAS instruction. * Default behavior: return 1, allow writeback. */ void m68k_set_tas_instr_callback(int (*callback)(void)); /* Set the callback for informing of a large PC change. * You must enable M68K_MONITOR_PC in m68kconf.h. * The CPU calls this callback with the new PC value every time the PC changes * by a large value (currently set for changes by longwords). * Default behavior: do nothing. */ void m68k_set_pc_changed_callback(void (*callback)(unsigned int new_pc)); /* Set the callback for CPU function code changes. * You must enable M68K_EMULATE_FC in m68kconf.h. * The CPU calls this callback with the function code before every memory * access to set the CPU's function code according to what kind of memory * access it is (supervisor/user, program/data and such). * Default behavior: do nothing. */ void m68k_set_fc_callback(void (*callback)(unsigned int new_fc)); /* Set a callback for the instruction cycle of the CPU. * You must enable M68K_INSTRUCTION_HOOK in m68kconf.h. * The CPU calls this callback just before fetching the opcode in the * instruction cycle. * Default behavior: do nothing. */ void m68k_set_instr_hook_callback(void (*callback)(unsigned int pc)); /* ======================================================================== */ /* ====================== FUNCTIONS TO ACCESS THE CPU ===================== */ /* ======================================================================== */ /* Use this function to set the CPU type you want to emulate. * Currently supported types are: M68K_CPU_TYPE_68000, M68K_CPU_TYPE_68008, * M68K_CPU_TYPE_68010, M68K_CPU_TYPE_EC020, and M68K_CPU_TYPE_68020. */ void m68k_set_cpu_type(unsigned int cpu_type); /* Do whatever initialisations the core requires. Should be called * at least once at init time. */ void m68k_init(void); /* Pulse the RESET pin on the CPU. * You *MUST* reset the CPU at least once to initialize the emulation * Note: If you didn't call m68k_set_cpu_type() before resetting * the CPU for the first time, the CPU will be set to * M68K_CPU_TYPE_68000. */ void m68k_pulse_reset(void); /* execute num_cycles worth of instructions. returns number of cycles used */ //int m68k_execute(int num_cycles); /* run until global cycle count is reached */ void m68k_run(unsigned int cycles); /* These functions let you read/write/modify the number of cycles left to run * while m68k_execute() is running. * These are useful if the 68k accesses a memory-mapped port on another device * that requires immediate processing by another CPU. */ //int m68k_cycles_run(void); /* Number of cycles run so far */ //int m68k_cycles_remaining(void); /* Number of cycles left */ //void m68k_modify_timeslice(int cycles); /* Modify cycles left */ //void m68k_end_timeslice(void); /* End timeslice now */ /* Set the IPL0-IPL2 pins on the CPU (IRQ). * A transition from < 7 to 7 will cause a non-maskable interrupt (NMI). * Setting IRQ to 0 will clear an interrupt request. */ void m68k_set_irq(unsigned int int_level); /* Halt the CPU as if you pulsed the HALT pin. */ void m68k_pulse_halt(void); /* Context switching to allow multiple CPUs */ /* Get the size of the cpu context in bytes */ unsigned int m68k_context_size(void); /* Get a cpu context */ unsigned int m68k_get_context(void* dst); /* set the current cpu context */ void m68k_set_context(void* dst); /* Register the CPU state information */ void m68k_state_register(const char *type, int index); /* Peek at the internals of a CPU context. This can either be a context * retrieved using m68k_get_context() or the currently running context. * If context is NULL, the currently running CPU context will be used. */ unsigned int m68k_get_reg(void* context, m68k_register_t reg); /* Poke values into the internals of the currently running CPU context */ void m68k_set_reg(m68k_register_t reg, unsigned int value); /* Check if an instruction is valid for the specified CPU type */ unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type); /* Disassemble 1 instruction using the epecified CPU type at pc. Stores * disassembly in str_buff and returns the size of the instruction in bytes. */ unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_type); /* Same as above but accepts raw opcode data directly rather than fetching * via the read/write interfaces. */ unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type); /*** Not really required, but makes for clean compile under DevkitPPC ***/ extern int vdp_68k_irq_ack(int int_level); /* ======================================================================== */ /* ============================== MAME STUFF ============================== */ /* ======================================================================== */ #if M68K_COMPILE_FOR_MAME == OPT_ON #include "m68kmame.h" #endif /* M68K_COMPILE_FOR_MAME */ /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */ #endif /* M68K__HEADER */
zyking1987-genplus-droid
genplusgx/m68k/m68k.h
C
gpl2
15,607
#include <stdio.h> /* ======================================================================== */ /* ========================= LICENSING & COPYRIGHT ======================== */ /* ======================================================================== */ /* * MUSASHI * Version 3.32 * * A portable Motorola M680x0 processor emulation engine. * Copyright Karl Stenerud. All rights reserved. * * This code may be freely used for non-commercial purposes as long as this * copyright notice remains unaltered in the source code and any binary files * containing this code in compiled form. * * All other licensing terms must be negotiated with the author * (Karl Stenerud). * * The latest version of this code can be obtained at: * http://kstenerud.cjb.net */ #ifndef M68KCPU__HEADER #define M68KCPU__HEADER #include "m68k.h" #include <limits.h> #if M68K_EMULATE_ADDRESS_ERROR #include <setjmp.h> #endif /* M68K_EMULATE_ADDRESS_ERROR */ /* ======================================================================== */ /* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */ /* ======================================================================== */ /* Check for > 32bit sizes */ #if UINT_MAX > 0xffffffff #define M68K_INT_GT_32_BIT 1 #else #define M68K_INT_GT_32_BIT 0 #endif /* Data types used in this emulation core */ #undef sint8 #undef sint16 #undef sint32 #undef sint64 #undef uint8 #undef uint16 #undef uint32 #undef uint64 #undef sint #undef uint #define sint8 signed char /* ASG: changed from char to signed char */ #define sint16 signed short #define sint32 signed int /* AWJ: changed from long to int */ #define uint8 unsigned char #define uint16 unsigned short #define uint32 unsigned int /* AWJ: changed from long to int */ /* signed and unsigned int must be at least 32 bits wide */ #define sint signed int #define uint unsigned int #if M68K_USE_64_BIT #define sint64 signed long long #define uint64 unsigned long long #else #define sint64 sint32 #define uint64 uint32 #endif /* M68K_USE_64_BIT */ /* Allow for architectures that don't have 8-bit sizes */ #if UCHAR_MAX == 0xff #define MAKE_INT_8(A) (sint8)(A) #else #undef sint8 #define sint8 signed int #undef uint8 #define uint8 unsigned int INLINE sint MAKE_INT_8(uint value) { return (value & 0x80) ? value | ~0xff : value & 0xff; } #endif /* UCHAR_MAX == 0xff */ /* Allow for architectures that don't have 16-bit sizes */ #if USHRT_MAX == 0xffff #define MAKE_INT_16(A) (sint16)(A) #else #undef sint16 #define sint16 signed int #undef uint16 #define uint16 unsigned int INLINE sint MAKE_INT_16(uint value) { return (value & 0x8000) ? value | ~0xffff : value & 0xffff; } #endif /* USHRT_MAX == 0xffff */ /* Allow for architectures that don't have 32-bit sizes */ #if UINT_MAX == 0xffffffff #define MAKE_INT_32(A) (sint32)(A) #else #undef sint32 #define sint32 signed int #undef uint32 #define uint32 unsigned int INLINE sint MAKE_INT_32(uint value) { return (value & 0x80000000) ? value | ~0xffffffff : value & 0xffffffff; } #endif /* UINT_MAX == 0xffffffff */ /* ======================================================================== */ /* ============================ GENERAL DEFINES =========================== */ /* ======================================================================== */ /* Exception Vectors handled by emulation */ #define EXCEPTION_RESET 0 #define EXCEPTION_BUS_ERROR 2 /* This one is not emulated! */ #define EXCEPTION_ADDRESS_ERROR 3 /* This one is partially emulated (doesn't stack a proper frame yet) */ #define EXCEPTION_ILLEGAL_INSTRUCTION 4 #define EXCEPTION_ZERO_DIVIDE 5 #define EXCEPTION_CHK 6 #define EXCEPTION_TRAPV 7 #define EXCEPTION_PRIVILEGE_VIOLATION 8 #define EXCEPTION_TRACE 9 #define EXCEPTION_1010 10 #define EXCEPTION_1111 11 #define EXCEPTION_FORMAT_ERROR 14 #define EXCEPTION_UNINITIALIZED_INTERRUPT 15 #define EXCEPTION_SPURIOUS_INTERRUPT 24 #define EXCEPTION_INTERRUPT_AUTOVECTOR 24 #define EXCEPTION_TRAP_BASE 32 /* Function codes set by CPU during data/address bus activity */ #define FUNCTION_CODE_USER_DATA 1 #define FUNCTION_CODE_USER_PROGRAM 2 #define FUNCTION_CODE_SUPERVISOR_DATA 5 #define FUNCTION_CODE_SUPERVISOR_PROGRAM 6 #define FUNCTION_CODE_CPU_SPACE 7 /* CPU types for deciding what to emulate */ #define CPU_TYPE_000 1 #define CPU_TYPE_008 2 #define CPU_TYPE_010 4 #define CPU_TYPE_EC020 8 #define CPU_TYPE_020 16 #define CPU_TYPE_040 32 /* Different ways to stop the CPU */ #define STOP_LEVEL_STOP 1 #define STOP_LEVEL_HALT 2 /* Used for 68000 address error processing */ #define INSTRUCTION_YES 0 #define INSTRUCTION_NO 0x08 #define MODE_READ 0x10 #define MODE_WRITE 0 #define RUN_MODE_NORMAL 0 #define RUN_MODE_BERR_AERR_RESET 1 #ifndef NULL #define NULL ((void*)0) #endif /* ======================================================================== */ /* ================================ MACROS ================================ */ /* ======================================================================== */ /* ---------------------------- General Macros ---------------------------- */ /* Bit Isolation Macros */ #define BIT_0(A) ((A) & 0x00000001) #define BIT_1(A) ((A) & 0x00000002) #define BIT_2(A) ((A) & 0x00000004) #define BIT_3(A) ((A) & 0x00000008) #define BIT_4(A) ((A) & 0x00000010) #define BIT_5(A) ((A) & 0x00000020) #define BIT_6(A) ((A) & 0x00000040) #define BIT_7(A) ((A) & 0x00000080) #define BIT_8(A) ((A) & 0x00000100) #define BIT_9(A) ((A) & 0x00000200) #define BIT_A(A) ((A) & 0x00000400) #define BIT_B(A) ((A) & 0x00000800) #define BIT_C(A) ((A) & 0x00001000) #define BIT_D(A) ((A) & 0x00002000) #define BIT_E(A) ((A) & 0x00004000) #define BIT_F(A) ((A) & 0x00008000) #define BIT_10(A) ((A) & 0x00010000) #define BIT_11(A) ((A) & 0x00020000) #define BIT_12(A) ((A) & 0x00040000) #define BIT_13(A) ((A) & 0x00080000) #define BIT_14(A) ((A) & 0x00100000) #define BIT_15(A) ((A) & 0x00200000) #define BIT_16(A) ((A) & 0x00400000) #define BIT_17(A) ((A) & 0x00800000) #define BIT_18(A) ((A) & 0x01000000) #define BIT_19(A) ((A) & 0x02000000) #define BIT_1A(A) ((A) & 0x04000000) #define BIT_1B(A) ((A) & 0x08000000) #define BIT_1C(A) ((A) & 0x10000000) #define BIT_1D(A) ((A) & 0x20000000) #define BIT_1E(A) ((A) & 0x40000000) #define BIT_1F(A) ((A) & 0x80000000) /* Get the most significant bit for specific sizes */ #define GET_MSB_8(A) ((A) & 0x80) #define GET_MSB_9(A) ((A) & 0x100) #define GET_MSB_16(A) ((A) & 0x8000) #define GET_MSB_17(A) ((A) & 0x10000) #define GET_MSB_32(A) ((A) & 0x80000000) #if M68K_USE_64_BIT #define GET_MSB_33(A) ((A) & 0x100000000) #endif /* M68K_USE_64_BIT */ /* Isolate nibbles */ #define LOW_NIBBLE(A) ((A) & 0x0f) #define HIGH_NIBBLE(A) ((A) & 0xf0) /* These are used to isolate 8, 16, and 32 bit sizes */ #define MASK_OUT_ABOVE_2(A) ((A) & 3) #define MASK_OUT_ABOVE_8(A) ((A) & 0xff) #define MASK_OUT_ABOVE_16(A) ((A) & 0xffff) #define MASK_OUT_BELOW_2(A) ((A) & ~3) #define MASK_OUT_BELOW_8(A) ((A) & ~0xff) #define MASK_OUT_BELOW_16(A) ((A) & ~0xffff) /* No need to mask if we are 32 bit */ #if M68K_INT_GT_32_BIT || M68K_USE_64_BIT #define MASK_OUT_ABOVE_32(A) ((A) & 0xffffffff) #define MASK_OUT_BELOW_32(A) ((A) & ~0xffffffff) #else #define MASK_OUT_ABOVE_32(A) (A) #define MASK_OUT_BELOW_32(A) 0 #endif /* M68K_INT_GT_32_BIT || M68K_USE_64_BIT */ /* Simulate address lines of 68k family */ #define ADDRESS_68K(A) ((A)&CPU_ADDRESS_MASK) /* Shift & Rotate Macros. */ #define LSL(A, C) ((A) << (C)) #define LSR(A, C) ((A) >> (C)) /* Some > 32-bit optimizations */ #if M68K_INT_GT_32_BIT /* Shift left and right */ #define LSR_32(A, C) ((A) >> (C)) #define LSL_32(A, C) ((A) << (C)) #else /* We have to do this because the morons at ANSI decided that shifts * by >= data size are undefined. */ #define LSR_32(A, C) ((C) < 32 ? (A) >> (C) : 0) #define LSL_32(A, C) ((C) < 32 ? (A) << (C) : 0) #endif /* M68K_INT_GT_32_BIT */ #if M68K_USE_64_BIT #define LSL_32_64(A, C) ((A) << (C)) #define LSR_32_64(A, C) ((A) >> (C)) #define ROL_33_64(A, C) (LSL_32_64(A, C) | LSR_32_64(A, 33-(C))) #define ROR_33_64(A, C) (LSR_32_64(A, C) | LSL_32_64(A, 33-(C))) #endif /* M68K_USE_64_BIT */ #define ROL_8(A, C) MASK_OUT_ABOVE_8(LSL(A, C) | LSR(A, 8-(C))) #define ROL_9(A, C) (LSL(A, C) | LSR(A, 9-(C))) #define ROL_16(A, C) MASK_OUT_ABOVE_16(LSL(A, C) | LSR(A, 16-(C))) #define ROL_17(A, C) (LSL(A, C) | LSR(A, 17-(C))) #define ROL_32(A, C) MASK_OUT_ABOVE_32(LSL_32(A, C) | LSR_32(A, 32-(C))) #define ROL_33(A, C) (LSL_32(A, C) | LSR_32(A, 33-(C))) #define ROR_8(A, C) MASK_OUT_ABOVE_8(LSR(A, C) | LSL(A, 8-(C))) #define ROR_9(A, C) (LSR(A, C) | LSL(A, 9-(C))) #define ROR_16(A, C) MASK_OUT_ABOVE_16(LSR(A, C) | LSL(A, 16-(C))) #define ROR_17(A, C) (LSR(A, C) | LSL(A, 17-(C))) #define ROR_32(A, C) MASK_OUT_ABOVE_32(LSR_32(A, C) | LSL_32(A, 32-(C))) #define ROR_33(A, C) (LSR_32(A, C) | LSL_32(A, 33-(C))) /* ------------------------------ CPU Access ------------------------------ */ /* Access the CPU registers */ #define CPU_TYPE m68ki_cpu.cpu_type #define REG_DA m68ki_cpu.dar /* easy access to data and address regs */ #define REG_D m68ki_cpu.dar #define REG_A (m68ki_cpu.dar+8) #define REG_PPC m68ki_cpu.ppc #define REG_PC m68ki_cpu.pc #define REG_SP_BASE m68ki_cpu.sp #define REG_USP m68ki_cpu.sp[0] #define REG_ISP m68ki_cpu.sp[4] #define REG_MSP m68ki_cpu.sp[6] #define REG_SP m68ki_cpu.dar[15] #define REG_VBR m68ki_cpu.vbr #define REG_SFC m68ki_cpu.sfc #define REG_DFC m68ki_cpu.dfc #define REG_CACR m68ki_cpu.cacr #define REG_CAAR m68ki_cpu.caar #define REG_IR m68ki_cpu.ir #define REG_FP m68ki_cpu.fpr #define REG_FPCR m68ki_cpu.fpcr #define REG_FPSR m68ki_cpu.fpsr #define REG_FPIAR m68ki_cpu.fpiar #define FLAG_T1 m68ki_cpu.t1_flag #define FLAG_T0 m68ki_cpu.t0_flag #define FLAG_S m68ki_cpu.s_flag #define FLAG_M m68ki_cpu.m_flag #define FLAG_X m68ki_cpu.x_flag #define FLAG_N m68ki_cpu.n_flag #define FLAG_Z m68ki_cpu.not_z_flag #define FLAG_V m68ki_cpu.v_flag #define FLAG_C m68ki_cpu.c_flag #define FLAG_INT_MASK m68ki_cpu.int_mask #define CPU_INT_LEVEL m68ki_cpu.int_level /* ASG: changed from CPU_INTS_PENDING */ #define CPU_STOPPED m68ki_cpu.stopped #define CPU_PREF_ADDR m68ki_cpu.pref_addr #define CPU_PREF_DATA m68ki_cpu.pref_data #define CPU_ADDRESS_MASK m68ki_cpu.address_mask #define CPU_SR_MASK m68ki_cpu.sr_mask #define CPU_INSTR_MODE m68ki_cpu.instr_mode #define CPU_RUN_MODE m68ki_cpu.run_mode #define CYC_INSTRUCTION m68ki_cpu.cyc_instruction #define CYC_EXCEPTION m68ki_cpu.cyc_exception #define CYC_BCC_NOTAKE_B m68ki_cpu.cyc_bcc_notake_b #define CYC_BCC_NOTAKE_W m68ki_cpu.cyc_bcc_notake_w #define CYC_DBCC_F_NOEXP m68ki_cpu.cyc_dbcc_f_noexp #define CYC_DBCC_F_EXP m68ki_cpu.cyc_dbcc_f_exp #define CYC_SCC_R_TRUE m68ki_cpu.cyc_scc_r_true #define CYC_MOVEM_W m68ki_cpu.cyc_movem_w #define CYC_MOVEM_L m68ki_cpu.cyc_movem_l #define CYC_SHIFT m68ki_cpu.cyc_shift #define CYC_RESET m68ki_cpu.cyc_reset #define CALLBACK_INT_ACK m68ki_cpu.int_ack_callback #define CALLBACK_BKPT_ACK m68ki_cpu.bkpt_ack_callback #define CALLBACK_RESET_INSTR m68ki_cpu.reset_instr_callback #define CALLBACK_CMPILD_INSTR m68ki_cpu.cmpild_instr_callback #define CALLBACK_RTE_INSTR m68ki_cpu.rte_instr_callback #define CALLBACK_TAS_INSTR m68ki_cpu.tas_instr_callback #define CALLBACK_PC_CHANGED m68ki_cpu.pc_changed_callback #define CALLBACK_SET_FC m68ki_cpu.set_fc_callback #define CALLBACK_INSTR_HOOK m68ki_cpu.instr_hook_callback /* ----------------------------- Configuration ---------------------------- */ /* These defines are dependant on the configuration defines in m68kconf.h */ /* Disable certain comparisons if we're not using all CPU types */ #if M68K_EMULATE_040 #define CPU_TYPE_IS_040_PLUS(A) ((A) & CPU_TYPE_040) #define CPU_TYPE_IS_040_LESS(A) 1 #else #define CPU_TYPE_IS_040_PLUS(A) 0 #define CPU_TYPE_IS_040_LESS(A) 1 #endif #if M68K_EMULATE_020 #define CPU_TYPE_IS_020_PLUS(A) ((A) & (CPU_TYPE_020 | CPU_TYPE_040)) #define CPU_TYPE_IS_020_LESS(A) 1 #else #define CPU_TYPE_IS_020_PLUS(A) CPU_TYPE_IS_040_PLUS(A) #define CPU_TYPE_IS_020_LESS(A) CPU_TYPE_IS_040_LESS(A) #endif #if M68K_EMULATE_EC020 #define CPU_TYPE_IS_EC020_PLUS(A) ((A) & (CPU_TYPE_EC020 | CPU_TYPE_020 | CPU_TYPE_040)) #define CPU_TYPE_IS_EC020_LESS(A) ((A) & (CPU_TYPE_000 | CPU_TYPE_008 | CPU_TYPE_010 | CPU_TYPE_EC020)) #else #define CPU_TYPE_IS_EC020_PLUS(A) CPU_TYPE_IS_020_PLUS(A) #define CPU_TYPE_IS_EC020_LESS(A) CPU_TYPE_IS_020_LESS(A) #endif #if M68K_EMULATE_010 #define CPU_TYPE_IS_010(A) ((A) == CPU_TYPE_010) #define CPU_TYPE_IS_010_PLUS(A) ((A) & (CPU_TYPE_010 | CPU_TYPE_EC020 | CPU_TYPE_020 | CPU_TYPE_040)) #define CPU_TYPE_IS_010_LESS(A) ((A) & (CPU_TYPE_000 | CPU_TYPE_008 | CPU_TYPE_010)) #else #define CPU_TYPE_IS_010(A) 0 #define CPU_TYPE_IS_010_PLUS(A) CPU_TYPE_IS_EC020_PLUS(A) #define CPU_TYPE_IS_010_LESS(A) CPU_TYPE_IS_EC020_LESS(A) #endif #if M68K_EMULATE_020 || M68K_EMULATE_EC020 #define CPU_TYPE_IS_020_VARIANT(A) ((A) & (CPU_TYPE_EC020 | CPU_TYPE_020)) #else #define CPU_TYPE_IS_020_VARIANT(A) 0 #endif #if M68K_EMULATE_040 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_010 #define CPU_TYPE_IS_000(A) ((A) == CPU_TYPE_000 || (A) == CPU_TYPE_008) #else #define CPU_TYPE_IS_000(A) 1 #endif #if !M68K_SEPARATE_READS #define m68k_read_immediate_16(A) m68ki_read_program_16(A) #define m68k_read_immediate_32(A) m68ki_read_program_32(A) #define m68k_read_pcrelative_8(A) m68ki_read_program_8(A) #define m68k_read_pcrelative_16(A) m68ki_read_program_16(A) #define m68k_read_pcrelative_32(A) m68ki_read_program_32(A) #endif /* M68K_SEPARATE_READS */ /* Enable or disable callback functions */ #if M68K_EMULATE_INT_ACK #if M68K_EMULATE_INT_ACK == OPT_SPECIFY_HANDLER #define m68ki_int_ack(A) M68K_INT_ACK_CALLBACK(A) #else #define m68ki_int_ack(A) CALLBACK_INT_ACK(A) #endif #else /* Default action is to used autovector mode, which is most common */ #define m68ki_int_ack(A) M68K_INT_ACK_AUTOVECTOR #endif /* M68K_EMULATE_INT_ACK */ #if M68K_EMULATE_BKPT_ACK #if M68K_EMULATE_BKPT_ACK == OPT_SPECIFY_HANDLER #define m68ki_bkpt_ack(A) M68K_BKPT_ACK_CALLBACK(A) #else #define m68ki_bkpt_ack(A) CALLBACK_BKPT_ACK(A) #endif #else #define m68ki_bkpt_ack(A) #endif /* M68K_EMULATE_BKPT_ACK */ #if M68K_EMULATE_RESET #if M68K_EMULATE_RESET == OPT_SPECIFY_HANDLER #define m68ki_output_reset() M68K_RESET_CALLBACK() #else #define m68ki_output_reset() CALLBACK_RESET_INSTR() #endif #else #define m68ki_output_reset() #endif /* M68K_EMULATE_RESET */ #if M68K_CMPILD_HAS_CALLBACK #if M68K_CMPILD_HAS_CALLBACK == OPT_SPECIFY_HANDLER #define m68ki_cmpild_callback(v,r) M68K_CMPILD_CALLBACK(v,r) #else #define m68ki_cmpild_callback(v,r) CALLBACK_CMPILD_INSTR(v,r) #endif #else #define m68ki_cmpild_callback(v,r) #endif /* M68K_CMPILD_HAS_CALLBACK */ #if M68K_RTE_HAS_CALLBACK #if M68K_RTE_HAS_CALLBACK == OPT_SPECIFY_HANDLER #define m68ki_rte_callback() M68K_RTE_CALLBACK() #else #define m68ki_rte_callback() CALLBACK_RTE_INSTR() #endif #else #define m68ki_rte_callback() #endif /* M68K_RTE_HAS_CALLBACK */ #if M68K_TAS_HAS_CALLBACK #if M68K_TAS_HAS_CALLBACK == OPT_SPECIFY_HANDLER #define m68ki_tas_callback() M68K_TAS_CALLBACK() #else #define m68ki_tas_callback() CALLBACK_TAS_INSTR() #endif #else #define m68ki_tas_callback() 0 #endif /* M68K_TAS_HAS_CALLBACK */ #if M68K_INSTRUCTION_HOOK #if M68K_INSTRUCTION_HOOK == OPT_SPECIFY_HANDLER #define m68ki_instr_hook(pc) M68K_INSTRUCTION_CALLBACK(pc) #else #define m68ki_instr_hook(pc) CALLBACK_INSTR_HOOK(pc) #endif #else #define m68ki_instr_hook(pc) #endif /* M68K_INSTRUCTION_HOOK */ #if M68K_MONITOR_PC #if M68K_MONITOR_PC == OPT_SPECIFY_HANDLER #define m68ki_pc_changed(A) M68K_SET_PC_CALLBACK(ADDRESS_68K(A)) #else #define m68ki_pc_changed(A) CALLBACK_PC_CHANGED(ADDRESS_68K(A)) #endif #else #define m68ki_pc_changed(A) #endif /* M68K_MONITOR_PC */ /* Enable or disable function code emulation */ #if M68K_EMULATE_FC #if M68K_EMULATE_FC == OPT_SPECIFY_HANDLER #define m68ki_set_fc(A) M68K_SET_FC_CALLBACK(A) #else #define m68ki_set_fc(A) CALLBACK_SET_FC(A) #endif #define m68ki_use_data_space() m68ki_address_space = FUNCTION_CODE_USER_DATA #define m68ki_use_program_space() m68ki_address_space = FUNCTION_CODE_USER_PROGRAM #define m68ki_get_address_space() m68ki_address_space #else #define m68ki_set_fc(A) #define m68ki_use_data_space() #define m68ki_use_program_space() #define m68ki_get_address_space() FUNCTION_CODE_USER_DATA #endif /* M68K_EMULATE_FC */ /* Enable or disable trace emulation */ #if M68K_EMULATE_TRACE /* Initiates trace checking before each instruction (t1) */ #define m68ki_trace_t1() m68ki_tracing = FLAG_T1 /* adds t0 to trace checking if we encounter change of flow */ #define m68ki_trace_t0() m68ki_tracing |= FLAG_T0 /* Clear all tracing */ #define m68ki_clear_trace() m68ki_tracing = 0 /* Cause a trace exception if we are tracing */ #define m68ki_exception_if_trace() if(m68ki_tracing) m68ki_exception_trace() #else #define m68ki_trace_t1() #define m68ki_trace_t0() #define m68ki_clear_trace() #define m68ki_exception_if_trace() #endif /* M68K_EMULATE_TRACE */ /* Address error */ #if M68K_EMULATE_ADDRESS_ERROR #include <setjmp.h> extern jmp_buf m68ki_aerr_trap; extern int emulate_address_error; #define m68ki_set_address_error_trap() \ if(setjmp(m68ki_aerr_trap) != 0) \ { \ m68ki_exception_address_error(); \ } #define m68ki_check_address_error(ADDR, WRITE_MODE, FC) \ if((ADDR)&1) \ { \ if (emulate_address_error) \ { \ m68ki_aerr_address = ADDR; \ m68ki_aerr_write_mode = WRITE_MODE; \ m68ki_aerr_fc = FC; \ longjmp(m68ki_aerr_trap, 1); \ } \ } #define m68ki_check_address_error_010_less(ADDR, WRITE_MODE, FC) \ if (CPU_TYPE_IS_010_LESS(CPU_TYPE)) \ { \ m68ki_check_address_error(ADDR, WRITE_MODE, FC) \ } #else #define m68ki_set_address_error_trap() #define m68ki_check_address_error(ADDR, WRITE_MODE, FC) #define m68ki_check_address_error_010_less(ADDR, WRITE_MODE, FC) #endif /* M68K_ADDRESS_ERROR */ /* Logging */ #if M68K_LOG_ENABLE #include <stdio.h> extern FILE* M68K_LOG_FILEHANDLE extern const char *const m68ki_cpu_names[]; #define M68K_DO_LOG(A) if(M68K_LOG_FILEHANDLE) fprintf A #if M68K_LOG_1010_1111 #define M68K_DO_LOG_EMU(A) if(M68K_LOG_FILEHANDLE) fprintf A #else #define M68K_DO_LOG_EMU(A) #endif #else #define M68K_DO_LOG(A) #define M68K_DO_LOG_EMU(A) #endif #if M68K_CHECK_INFINITE_LOOP #define m68ki_check_infinite_loop() if(REG_PC == REG_PPC) USE_ALL_CYCLES() #else #define m68ki_check_infinite_loop() #endif /* M68K_CHECK_INFINITE_LOOP */ /* -------------------------- EA / Operand Access ------------------------- */ /* * The general instruction format follows this pattern: * .... XXX. .... .YYY * where XXX is register X and YYY is register Y */ /* Data Register Isolation */ #define DX (REG_D[(REG_IR >> 9) & 7]) #define DY (REG_D[REG_IR & 7]) /* Address Register Isolation */ #define AX (REG_A[(REG_IR >> 9) & 7]) #define AY (REG_A[REG_IR & 7]) /* Effective Address Calculations */ #define EA_AY_AI_8() AY /* address register indirect */ #define EA_AY_AI_16() EA_AY_AI_8() #define EA_AY_AI_32() EA_AY_AI_8() #define EA_AY_PI_8() (AY++) /* postincrement (size = byte) */ #define EA_AY_PI_16() ((AY+=2)-2) /* postincrement (size = word) */ #define EA_AY_PI_32() ((AY+=4)-4) /* postincrement (size = long) */ #define EA_AY_PD_8() (--AY) /* predecrement (size = byte) */ #define EA_AY_PD_16() (AY-=2) /* predecrement (size = word) */ #define EA_AY_PD_32() (AY-=4) /* predecrement (size = long) */ #define EA_AY_DI_8() (AY+MAKE_INT_16(m68ki_read_imm_16())) /* displacement */ #define EA_AY_DI_16() EA_AY_DI_8() #define EA_AY_DI_32() EA_AY_DI_8() #define EA_AY_IX_8() m68ki_get_ea_ix(AY) /* indirect + index */ #define EA_AY_IX_16() EA_AY_IX_8() #define EA_AY_IX_32() EA_AY_IX_8() #define EA_AX_AI_8() AX #define EA_AX_AI_16() EA_AX_AI_8() #define EA_AX_AI_32() EA_AX_AI_8() #define EA_AX_PI_8() (AX++) #define EA_AX_PI_16() ((AX+=2)-2) #define EA_AX_PI_32() ((AX+=4)-4) #define EA_AX_PD_8() (--AX) #define EA_AX_PD_16() (AX-=2) #define EA_AX_PD_32() (AX-=4) #define EA_AX_DI_8() (AX+MAKE_INT_16(m68ki_read_imm_16())) #define EA_AX_DI_16() EA_AX_DI_8() #define EA_AX_DI_32() EA_AX_DI_8() #define EA_AX_IX_8() m68ki_get_ea_ix(AX) #define EA_AX_IX_16() EA_AX_IX_8() #define EA_AX_IX_32() EA_AX_IX_8() #define EA_A7_PI_8() ((REG_A[7]+=2)-2) #define EA_A7_PD_8() (REG_A[7]-=2) #define EA_AW_8() MAKE_INT_16(m68ki_read_imm_16()) /* absolute word */ #define EA_AW_16() EA_AW_8() #define EA_AW_32() EA_AW_8() #define EA_AL_8() m68ki_read_imm_32() /* absolute long */ #define EA_AL_16() EA_AL_8() #define EA_AL_32() EA_AL_8() #define EA_PCDI_8() m68ki_get_ea_pcdi() /* pc indirect + displacement */ #define EA_PCDI_16() EA_PCDI_8() #define EA_PCDI_32() EA_PCDI_8() #define EA_PCIX_8() m68ki_get_ea_pcix() /* pc indirect + index */ #define EA_PCIX_16() EA_PCIX_8() #define EA_PCIX_32() EA_PCIX_8() #define OPER_I_8() m68ki_read_imm_8() #define OPER_I_16() m68ki_read_imm_16() #define OPER_I_32() m68ki_read_imm_32() /* --------------------------- Status Register ---------------------------- */ /* Flag Calculation Macros */ #define CFLAG_8(A) (A) #define CFLAG_16(A) ((A)>>8) #if M68K_INT_GT_32_BIT #define CFLAG_ADD_32(S, D, R) ((R)>>24) #define CFLAG_SUB_32(S, D, R) ((R)>>24) #else #define CFLAG_ADD_32(S, D, R) (((S & D) | (~R & (S | D)))>>23) #define CFLAG_SUB_32(S, D, R) (((S & R) | (~D & (S | R)))>>23) #endif /* M68K_INT_GT_32_BIT */ #define VFLAG_ADD_8(S, D, R) ((S^R) & (D^R)) #define VFLAG_ADD_16(S, D, R) (((S^R) & (D^R))>>8) #define VFLAG_ADD_32(S, D, R) (((S^R) & (D^R))>>24) #define VFLAG_SUB_8(S, D, R) ((S^D) & (R^D)) #define VFLAG_SUB_16(S, D, R) (((S^D) & (R^D))>>8) #define VFLAG_SUB_32(S, D, R) (((S^D) & (R^D))>>24) #define NFLAG_8(A) (A) #define NFLAG_16(A) ((A)>>8) #define NFLAG_32(A) ((A)>>24) #define NFLAG_64(A) ((A)>>56) #define ZFLAG_8(A) MASK_OUT_ABOVE_8(A) #define ZFLAG_16(A) MASK_OUT_ABOVE_16(A) #define ZFLAG_32(A) MASK_OUT_ABOVE_32(A) /* Flag values */ #define NFLAG_SET 0x80 #define NFLAG_CLEAR 0 #define CFLAG_SET 0x100 #define CFLAG_CLEAR 0 #define XFLAG_SET 0x100 #define XFLAG_CLEAR 0 #define VFLAG_SET 0x80 #define VFLAG_CLEAR 0 #define ZFLAG_SET 0 #define ZFLAG_CLEAR 0xffffffff #define SFLAG_SET 4 #define SFLAG_CLEAR 0 #define MFLAG_SET 2 #define MFLAG_CLEAR 0 /* Turn flag values into 1 or 0 */ #define XFLAG_AS_1() ((FLAG_X>>8)&1) #define NFLAG_AS_1() ((FLAG_N>>7)&1) #define VFLAG_AS_1() ((FLAG_V>>7)&1) #define ZFLAG_AS_1() (!FLAG_Z) #define CFLAG_AS_1() ((FLAG_C>>8)&1) /* Conditions */ #define COND_CS() (FLAG_C&0x100) #define COND_CC() (!COND_CS()) #define COND_VS() (FLAG_V&0x80) #define COND_VC() (!COND_VS()) #define COND_NE() FLAG_Z #define COND_EQ() (!COND_NE()) #define COND_MI() (FLAG_N&0x80) #define COND_PL() (!COND_MI()) #define COND_LT() ((FLAG_N^FLAG_V)&0x80) #define COND_GE() (!COND_LT()) #define COND_HI() (COND_CC() && COND_NE()) #define COND_LS() (COND_CS() || COND_EQ()) #define COND_GT() (COND_GE() && COND_NE()) #define COND_LE() (COND_LT() || COND_EQ()) /* Reversed conditions */ #define COND_NOT_CS() COND_CC() #define COND_NOT_CC() COND_CS() #define COND_NOT_VS() COND_VC() #define COND_NOT_VC() COND_VS() #define COND_NOT_NE() COND_EQ() #define COND_NOT_EQ() COND_NE() #define COND_NOT_MI() COND_PL() #define COND_NOT_PL() COND_MI() #define COND_NOT_LT() COND_GE() #define COND_NOT_GE() COND_LT() #define COND_NOT_HI() COND_LS() #define COND_NOT_LS() COND_HI() #define COND_NOT_GT() COND_LE() #define COND_NOT_LE() COND_GT() /* Not real conditions, but here for convenience */ #define COND_XS() (FLAG_X&0x100) #define COND_XC() (!COND_XS) /* Get the condition code register */ #define m68ki_get_ccr() ((COND_XS() >> 4) | \ (COND_MI() >> 4) | \ (COND_EQ() << 2) | \ (COND_VS() >> 6) | \ (COND_CS() >> 8)) /* Get the status register */ #define m68ki_get_sr() ( FLAG_T1 | \ FLAG_T0 | \ (FLAG_S << 11) | \ (FLAG_M << 11) | \ FLAG_INT_MASK | \ m68ki_get_ccr()) /* ---------------------------- Cycle Counting ---------------------------- */ /* #define ADD_CYCLES(A) m68ki_remaining_cycles += (A) #define USE_CYCLES(A) m68ki_remaining_cycles -= (A) #define SET_CYCLES(A) m68ki_remaining_cycles = A #define GET_CYCLES() m68ki_remaining_cycles #define USE_ALL_CYCLES() m68ki_remaining_cycles = 0 */ #define USE_CYCLES(A) mcycles_68k += (A) /* ----------------------------- Read / Write ----------------------------- */ /* Read from the current address space */ #define m68ki_read_8(A) m68ki_read_8_fc (A, FLAG_S | m68ki_get_address_space()) #define m68ki_read_16(A) m68ki_read_16_fc(A, FLAG_S | m68ki_get_address_space()) #define m68ki_read_32(A) m68ki_read_32_fc(A, FLAG_S | m68ki_get_address_space()) /* Write to the current data space */ #define m68ki_write_8(A, V) m68ki_write_8_fc (A, FLAG_S | FUNCTION_CODE_USER_DATA, V) #define m68ki_write_16(A, V) m68ki_write_16_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA, V) #define m68ki_write_32(A, V) m68ki_write_32_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA, V) #if M68K_SIMULATE_PD_WRITES #define m68ki_write_32_pd(A, V) m68ki_write_32_pd_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA, V) #else #define m68ki_write_32_pd(A, V) m68ki_write_32_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA, V) #endif /* map read immediate 8 to read immediate 16 */ #define m68ki_read_imm_8() MASK_OUT_ABOVE_8(m68ki_read_imm_16()) /* Map PC-relative reads */ #define m68ki_read_pcrel_8(A) m68k_read_pcrelative_8(A) #define m68ki_read_pcrel_16(A) m68k_read_pcrelative_16(A) #define m68ki_read_pcrel_32(A) m68k_read_pcrelative_32(A) /* Read from the program space */ #define m68ki_read_program_8(A) m68ki_read_8_fc(A, FLAG_S | FUNCTION_CODE_USER_PROGRAM) #define m68ki_read_program_16(A) m68ki_read_16_fc(A, FLAG_S | FUNCTION_CODE_USER_PROGRAM) #define m68ki_read_program_32(A) m68ki_read_32_fc(A, FLAG_S | FUNCTION_CODE_USER_PROGRAM) /* Read from the data space */ #define m68ki_read_data_8(A) m68ki_read_8_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA) #define m68ki_read_data_16(A) m68ki_read_16_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA) #define m68ki_read_data_32(A) m68ki_read_32_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA) /* ======================================================================== */ /* =============================== PROTOTYPES ============================= */ /* ======================================================================== */ typedef union { uint64 i; double f; } fp_reg; typedef struct { uint cpu_type; /* CPU Type: 68000, 68008, 68010, 68EC020, or 68020 */ uint dar[16]; /* Data and Address Registers */ uint ppc; /* Previous program counter */ uint pc; /* Program Counter */ uint sp[7]; /* User, Interrupt, and Master Stack Pointers */ uint vbr; /* Vector Base Register (m68010+) */ uint sfc; /* Source Function Code Register (m68010+) */ uint dfc; /* Destination Function Code Register (m68010+) */ uint cacr; /* Cache Control Register (m68020, unemulated) */ uint caar; /* Cache Address Register (m68020, unemulated) */ uint ir; /* Instruction Register */ fp_reg fpr[8]; /* FPU Data Register (m68040) */ uint fpiar; /* FPU Instruction Address Register (m68040) */ uint fpsr; /* FPU Status Register (m68040) */ uint fpcr; /* FPU Control Register (m68040) */ uint t1_flag; /* Trace 1 */ uint t0_flag; /* Trace 0 */ uint s_flag; /* Supervisor */ uint m_flag; /* Master/Interrupt state */ uint x_flag; /* Extend */ uint n_flag; /* Negative */ uint not_z_flag; /* Zero, inverted for speedups */ uint v_flag; /* Overflow */ uint c_flag; /* Carry */ uint int_mask; /* I0-I2 */ uint int_level; /* State of interrupt pins IPL0-IPL2 -- ASG: changed from ints_pending */ uint stopped; /* Stopped state */ uint pref_addr; /* Last prefetch address */ uint pref_data; /* Data in the prefetch queue */ uint address_mask; /* Available address pins */ uint sr_mask; /* Implemented status register bits */ uint instr_mode; /* Stores whether we are in instruction mode or group 0/1 exception mode */ uint run_mode; /* Stores whether we are processing a reset, bus error, address error, or something else */ /* Clocks required for instructions / exceptions */ uint cyc_bcc_notake_b; uint cyc_bcc_notake_w; uint cyc_dbcc_f_noexp; uint cyc_dbcc_f_exp; uint cyc_scc_r_true; uint cyc_movem_w; uint cyc_movem_l; uint cyc_shift; uint cyc_reset; const uint8* cyc_instruction; const uint16* cyc_exception; /* Callbacks to host */ int (*int_ack_callback)(int int_line); /* Interrupt Acknowledge */ void (*bkpt_ack_callback)(unsigned int data); /* Breakpoint Acknowledge */ void (*reset_instr_callback)(void); /* Called when a RESET instruction is encountered */ void (*cmpild_instr_callback)(unsigned int, int); /* Called when a CMPI.L #v, Dn instruction is encountered */ void (*rte_instr_callback)(void); /* Called when a RTE instruction is encountered */ int (*tas_instr_callback)(void); /* Called when a TAS instruction is encountered, allows / disallows writeback */ void (*pc_changed_callback)(unsigned int new_pc); /* Called when the PC changes by a large amount */ void (*set_fc_callback)(unsigned int new_fc); /* Called when the CPU function code changes */ void (*instr_hook_callback)(unsigned int pc); /* Called every instruction cycle prior to execution */ } m68ki_cpu_core; extern unsigned int mcycles_68k; extern m68ki_cpu_core m68ki_cpu; #if 0 extern sint m68ki_remaining_cycles; #endif #if M68K_EMULATE_TRACE extern uint m68ki_tracing; #endif extern const uint8 m68ki_shift_8_table[]; extern const uint16 m68ki_shift_16_table[]; extern const uint m68ki_shift_32_table[]; extern uint16 m68ki_exception_cycle_table[][256]; #if M68K_EMULATE_FC extern uint m68ki_address_space; #endif extern const uint8 m68ki_ea_idx_cycle_table[]; extern uint m68ki_aerr_address; extern uint m68ki_aerr_write_mode; extern uint m68ki_aerr_fc; /* Read data immediately after the program counter */ INLINE uint m68ki_read_imm_16(void); INLINE uint m68ki_read_imm_32(void); /* Read data with specific function code */ INLINE uint m68ki_read_8_fc (uint address, uint fc); INLINE uint m68ki_read_16_fc (uint address, uint fc); INLINE uint m68ki_read_32_fc (uint address, uint fc); /* Write data with specific function code */ INLINE void m68ki_write_8_fc (uint address, uint fc, uint value); INLINE void m68ki_write_16_fc(uint address, uint fc, uint value); INLINE void m68ki_write_32_fc(uint address, uint fc, uint value); #if M68K_SIMULATE_PD_WRITES INLINE void m68ki_write_32_pd_fc(uint address, uint fc, uint value); #endif /* M68K_SIMULATE_PD_WRITES */ /* Indexed and PC-relative ea fetching */ INLINE uint m68ki_get_ea_pcdi(void); INLINE uint m68ki_get_ea_pcix(void); INLINE uint m68ki_get_ea_ix(uint An); /* Operand fetching */ INLINE uint OPER_AY_AI_8(void); INLINE uint OPER_AY_AI_16(void); INLINE uint OPER_AY_AI_32(void); INLINE uint OPER_AY_PI_8(void); INLINE uint OPER_AY_PI_16(void); INLINE uint OPER_AY_PI_32(void); INLINE uint OPER_AY_PD_8(void); INLINE uint OPER_AY_PD_16(void); INLINE uint OPER_AY_PD_32(void); INLINE uint OPER_AY_DI_8(void); INLINE uint OPER_AY_DI_16(void); INLINE uint OPER_AY_DI_32(void); INLINE uint OPER_AY_IX_8(void); INLINE uint OPER_AY_IX_16(void); INLINE uint OPER_AY_IX_32(void); INLINE uint OPER_AX_AI_8(void); INLINE uint OPER_AX_AI_16(void); INLINE uint OPER_AX_AI_32(void); INLINE uint OPER_AX_PI_8(void); INLINE uint OPER_AX_PI_16(void); INLINE uint OPER_AX_PI_32(void); INLINE uint OPER_AX_PD_8(void); INLINE uint OPER_AX_PD_16(void); INLINE uint OPER_AX_PD_32(void); INLINE uint OPER_AX_DI_8(void); INLINE uint OPER_AX_DI_16(void); INLINE uint OPER_AX_DI_32(void); INLINE uint OPER_AX_IX_8(void); INLINE uint OPER_AX_IX_16(void); INLINE uint OPER_AX_IX_32(void); INLINE uint OPER_A7_PI_8(void); INLINE uint OPER_A7_PD_8(void); INLINE uint OPER_AW_8(void); INLINE uint OPER_AW_16(void); INLINE uint OPER_AW_32(void); INLINE uint OPER_AL_8(void); INLINE uint OPER_AL_16(void); INLINE uint OPER_AL_32(void); INLINE uint OPER_PCDI_8(void); INLINE uint OPER_PCDI_16(void); INLINE uint OPER_PCDI_32(void); INLINE uint OPER_PCIX_8(void); INLINE uint OPER_PCIX_16(void); INLINE uint OPER_PCIX_32(void); /* Stack operations */ INLINE void m68ki_push_16(uint value); INLINE void m68ki_push_32(uint value); INLINE uint m68ki_pull_16(void); INLINE uint m68ki_pull_32(void); /* Program flow operations */ INLINE void m68ki_jump(uint new_pc); INLINE void m68ki_jump_vector(uint vector); INLINE void m68ki_branch_8(uint offset); INLINE void m68ki_branch_16(uint offset); INLINE void m68ki_branch_32(uint offset); /* Status register operations. */ INLINE void m68ki_set_s_flag(uint value); /* Only bit 2 of value should be set (i.e. 4 or 0) */ INLINE void m68ki_set_sm_flag(uint value); /* only bits 1 and 2 of value should be set */ INLINE void m68ki_set_ccr(uint value); /* set the condition code register */ INLINE void m68ki_set_sr(uint value); /* set the status register */ INLINE void m68ki_set_sr_noint(uint value); /* set the status register */ /* Exception processing */ INLINE uint m68ki_init_exception(void); /* Initial exception processing */ INLINE void m68ki_stack_frame_3word(uint pc, uint sr); /* Stack various frame types */ INLINE void m68ki_stack_frame_buserr(uint sr); INLINE void m68ki_stack_frame_0000(uint pc, uint sr, uint vector); INLINE void m68ki_stack_frame_0001(uint pc, uint sr, uint vector); INLINE void m68ki_stack_frame_0010(uint sr, uint vector); INLINE void m68ki_stack_frame_1000(uint pc, uint sr, uint vector); INLINE void m68ki_stack_frame_1010(uint sr, uint vector, uint pc); INLINE void m68ki_stack_frame_1011(uint sr, uint vector, uint pc); INLINE void m68ki_exception_trap(uint vector); INLINE void m68ki_exception_trapN(uint vector); INLINE void m68ki_exception_trace(void); INLINE void m68ki_exception_privilege_violation(void); INLINE void m68ki_exception_1010(void); INLINE void m68ki_exception_1111(void); INLINE void m68ki_exception_illegal(void); INLINE void m68ki_exception_format_error(void); INLINE void m68ki_exception_address_error(void); INLINE void m68ki_exception_interrupt(uint int_level); INLINE void m68ki_check_interrupts(void); /* ASG: check for interrupts */ /* quick disassembly (used for logging) */ char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type); /* ======================================================================== */ /* =========================== UTILITY FUNCTIONS ========================== */ /* ======================================================================== */ /* ---------------------------- Read Immediate ---------------------------- */ /* Handles all immediate reads, does address error check, function code setting, * and prefetching if they are enabled in m68kconf.h */ INLINE uint m68ki_read_imm_16(void) { m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ #if M68K_EMULATE_PREFETCH if(MASK_OUT_BELOW_2(REG_PC) != CPU_PREF_ADDR) { CPU_PREF_ADDR = MASK_OUT_BELOW_2(REG_PC); CPU_PREF_DATA = m68k_read_immediate_32(CPU_PREF_ADDR); } REG_PC += 2; return MASK_OUT_ABOVE_16(CPU_PREF_DATA >> ((2-((REG_PC-2)&2))<<3)); #else REG_PC += 2; return m68k_read_immediate_16(REG_PC-2); #endif /* M68K_EMULATE_PREFETCH */ } INLINE uint m68ki_read_imm_32(void) { #if M68K_EMULATE_PREFETCH uint temp_val; m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ if(MASK_OUT_BELOW_2(REG_PC) != CPU_PREF_ADDR) { CPU_PREF_ADDR = MASK_OUT_BELOW_2(REG_PC); CPU_PREF_DATA = m68k_read_immediate_32(CPU_PREF_ADDR); } temp_val = CPU_PREF_DATA; REG_PC += 2; if(MASK_OUT_BELOW_2(REG_PC) != CPU_PREF_ADDR) { CPU_PREF_ADDR = MASK_OUT_BELOW_2(REG_PC); CPU_PREF_DATA = m68k_read_immediate_32(CPU_PREF_ADDR); temp_val = MASK_OUT_ABOVE_32((temp_val << 16) | (CPU_PREF_DATA >> 16)); } REG_PC += 2; return temp_val; #else m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ REG_PC += 4; return m68k_read_immediate_32(REG_PC-4); #endif /* M68K_EMULATE_PREFETCH */ } /* ------------------------- Top level read/write ------------------------- */ /* Handles all memory accesses (except for immediate reads if they are * configured to use separate functions in m68kconf.h). * All memory accesses must go through these top level functions. * These functions will also check for address error and set the function * code if they are enabled in m68kconf.h. */ INLINE uint m68ki_read_8_fc(uint address, uint fc) { m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->read8) return (*temp->read8)(ADDRESS_68K(address)); else return READ_BYTE(temp->base, (address) & 0xffff); } INLINE uint m68ki_read_16_fc(uint address, uint fc) { m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error_010_less(address, MODE_READ, fc); /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->read16) return (*temp->read16)(ADDRESS_68K(address)); else return *(uint16 *)(temp->base + ((address) & 0xffff)); } INLINE uint m68ki_read_32_fc(uint address, uint fc) { m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error_010_less(address, MODE_READ, fc); /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->read16) return ((*temp->read16)(ADDRESS_68K(address)) << 16) | ((*temp->read16)(ADDRESS_68K(address + 2))); else return m68k_read_immediate_32(address); } INLINE void m68ki_write_8_fc(uint address, uint fc, uint value) { m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->write8) (*temp->write8)(ADDRESS_68K(address),value); else WRITE_BYTE(temp->base, (address) & 0xffff, value); } INLINE void m68ki_write_16_fc(uint address, uint fc, uint value) { m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->write16) (*temp->write16)(ADDRESS_68K(address),value); else *(uint16 *)(temp->base + ((address) & 0xffff)) = value; } INLINE void m68ki_write_32_fc(uint address, uint fc, uint value) { m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->write16) (*temp->write16)(ADDRESS_68K(address),value>>16); else *(uint16 *)(temp->base + ((address) & 0xffff)) = value >> 16; temp = &m68k_memory_map[((address + 2)>>16)&0xff]; if (temp->write16) (*temp->write16)(ADDRESS_68K(address+2),value&0xffff); else *(uint16 *)(temp->base + ((address + 2) & 0xffff)) = value; } #if M68K_SIMULATE_PD_WRITES INLINE void m68ki_write_32_pd_fc(uint address, uint fc, uint value) { m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */ m68k_write_memory_32_pd(ADDRESS_68K(address), value); } #endif /* --------------------- Effective Address Calculation -------------------- */ /* The program counter relative addressing modes cause operands to be * retrieved from program space, not data space. */ INLINE uint m68ki_get_ea_pcdi(void) { uint old_pc = REG_PC; m68ki_use_program_space(); /* auto-disable */ return old_pc + MAKE_INT_16(m68ki_read_imm_16()); } INLINE uint m68ki_get_ea_pcix(void) { m68ki_use_program_space(); /* auto-disable */ return m68ki_get_ea_ix(REG_PC); } /* Indexed addressing modes are encoded as follows: * * Base instruction format: * F E D C B A 9 8 7 6 | 5 4 3 | 2 1 0 * x x x x x x x x x x | 1 1 0 | BASE REGISTER (An) * * Base instruction format for destination EA in move instructions: * F E D C | B A 9 | 8 7 6 | 5 4 3 2 1 0 * x x x x | BASE REG | 1 1 0 | X X X X X X (An) * * Brief extension format: * F | E D C | B | A 9 | 8 | 7 6 5 4 3 2 1 0 * D/A | REGISTER | W/L | SCALE | 0 | DISPLACEMENT * * Full extension format: * F E D C B A 9 8 7 6 5 4 3 2 1 0 * D/A | REGISTER | W/L | SCALE | 1 | BS | IS | BD SIZE | 0 | I/IS * BASE DISPLACEMENT (0, 16, 32 bit) (bd) * OUTER DISPLACEMENT (0, 16, 32 bit) (od) * * D/A: 0 = Dn, 1 = An (Xn) * W/L: 0 = W (sign extend), 1 = L (.SIZE) * SCALE: 00=1, 01=2, 10=4, 11=8 (*SCALE) * BS: 0=add base reg, 1=suppress base reg (An suppressed) * IS: 0=add index, 1=suppress index (Xn suppressed) * BD SIZE: 00=reserved, 01=NULL, 10=Word, 11=Long (size of bd) * * IS I/IS Operation * 0 000 No Memory Indirect * 0 001 indir prex with null outer * 0 010 indir prex with word outer * 0 011 indir prex with long outer * 0 100 reserved * 0 101 indir postx with null outer * 0 110 indir postx with word outer * 0 111 indir postx with long outer * 1 000 no memory indirect * 1 001 mem indir with null outer * 1 010 mem indir with word outer * 1 011 mem indir with long outer * 1 100-111 reserved */ INLINE uint m68ki_get_ea_ix(uint An) { /* An = base register */ uint extension = m68ki_read_imm_16(); uint Xn = 0; /* Index register */ if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) { /* Calculate index */ Xn = REG_DA[extension>>12]; /* Xn */ if(!BIT_B(extension)) /* W/L */ Xn = MAKE_INT_16(Xn); /* Add base register and displacement and return */ return An + Xn + MAKE_INT_8(extension); } #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 uint bd = 0; /* Base Displacement */ uint od = 0; /* Outer Displacement */ /* Brief extension format */ if(!BIT_8(extension)) { /* Calculate index */ Xn = REG_DA[extension>>12]; /* Xn */ if(!BIT_B(extension)) /* W/L */ Xn = MAKE_INT_16(Xn); /* Add scale if proper CPU type */ if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) Xn <<= (extension>>9) & 3; /* SCALE */ /* Add base register and displacement and return */ return An + Xn + MAKE_INT_8(extension); } /* Full extension format */ USE_CYCLES(m68ki_ea_idx_cycle_table[extension&0x3f]); /* Check if base register is present */ if(BIT_7(extension)) /* BS */ An = 0; /* An */ /* Check if index is present */ if(!BIT_6(extension)) /* IS */ { Xn = REG_DA[extension>>12]; /* Xn */ if(!BIT_B(extension)) /* W/L */ Xn = MAKE_INT_16(Xn); Xn <<= (extension>>9) & 3; /* SCALE */ } /* Check if base displacement is present */ if(BIT_5(extension)) /* BD SIZE */ bd = BIT_4(extension) ? m68ki_read_imm_32() : MAKE_INT_16(m68ki_read_imm_16()); /* If no indirect action, we are done */ if(!(extension&7)) /* No Memory Indirect */ return An + bd + Xn; /* Check if outer displacement is present */ if(BIT_1(extension)) /* I/IS: od */ od = BIT_0(extension) ? m68ki_read_imm_32() : MAKE_INT_16(m68ki_read_imm_16()); /* Postindex */ if(BIT_2(extension)) /* I/IS: 0 = preindex, 1 = postindex */ return m68ki_read_32(An + bd) + Xn + od; /* Preindex */ return m68ki_read_32(An + bd + Xn) + od; #endif } /* Fetch operands */ INLINE uint OPER_AY_AI_8(void) {uint ea = EA_AY_AI_8(); return m68ki_read_8(ea); } INLINE uint OPER_AY_AI_16(void) {uint ea = EA_AY_AI_16(); return m68ki_read_16(ea);} INLINE uint OPER_AY_AI_32(void) {uint ea = EA_AY_AI_32(); return m68ki_read_32(ea);} INLINE uint OPER_AY_PI_8(void) {uint ea = EA_AY_PI_8(); return m68ki_read_8(ea); } INLINE uint OPER_AY_PI_16(void) {uint ea = EA_AY_PI_16(); return m68ki_read_16(ea);} INLINE uint OPER_AY_PI_32(void) {uint ea = EA_AY_PI_32(); return m68ki_read_32(ea);} INLINE uint OPER_AY_PD_8(void) {uint ea = EA_AY_PD_8(); return m68ki_read_8(ea); } INLINE uint OPER_AY_PD_16(void) {uint ea = EA_AY_PD_16(); return m68ki_read_16(ea);} INLINE uint OPER_AY_PD_32(void) {uint ea = EA_AY_PD_32(); return m68ki_read_32(ea);} INLINE uint OPER_AY_DI_8(void) {uint ea = EA_AY_DI_8(); return m68ki_read_8(ea); } INLINE uint OPER_AY_DI_16(void) {uint ea = EA_AY_DI_16(); return m68ki_read_16(ea);} INLINE uint OPER_AY_DI_32(void) {uint ea = EA_AY_DI_32(); return m68ki_read_32(ea);} INLINE uint OPER_AY_IX_8(void) {uint ea = EA_AY_IX_8(); return m68ki_read_8(ea); } INLINE uint OPER_AY_IX_16(void) {uint ea = EA_AY_IX_16(); return m68ki_read_16(ea);} INLINE uint OPER_AY_IX_32(void) {uint ea = EA_AY_IX_32(); return m68ki_read_32(ea);} INLINE uint OPER_AX_AI_8(void) {uint ea = EA_AX_AI_8(); return m68ki_read_8(ea); } INLINE uint OPER_AX_AI_16(void) {uint ea = EA_AX_AI_16(); return m68ki_read_16(ea);} INLINE uint OPER_AX_AI_32(void) {uint ea = EA_AX_AI_32(); return m68ki_read_32(ea);} INLINE uint OPER_AX_PI_8(void) {uint ea = EA_AX_PI_8(); return m68ki_read_8(ea); } INLINE uint OPER_AX_PI_16(void) {uint ea = EA_AX_PI_16(); return m68ki_read_16(ea);} INLINE uint OPER_AX_PI_32(void) {uint ea = EA_AX_PI_32(); return m68ki_read_32(ea);} INLINE uint OPER_AX_PD_8(void) {uint ea = EA_AX_PD_8(); return m68ki_read_8(ea); } INLINE uint OPER_AX_PD_16(void) {uint ea = EA_AX_PD_16(); return m68ki_read_16(ea);} INLINE uint OPER_AX_PD_32(void) {uint ea = EA_AX_PD_32(); return m68ki_read_32(ea);} INLINE uint OPER_AX_DI_8(void) {uint ea = EA_AX_DI_8(); return m68ki_read_8(ea); } INLINE uint OPER_AX_DI_16(void) {uint ea = EA_AX_DI_16(); return m68ki_read_16(ea);} INLINE uint OPER_AX_DI_32(void) {uint ea = EA_AX_DI_32(); return m68ki_read_32(ea);} INLINE uint OPER_AX_IX_8(void) {uint ea = EA_AX_IX_8(); return m68ki_read_8(ea); } INLINE uint OPER_AX_IX_16(void) {uint ea = EA_AX_IX_16(); return m68ki_read_16(ea);} INLINE uint OPER_AX_IX_32(void) {uint ea = EA_AX_IX_32(); return m68ki_read_32(ea);} INLINE uint OPER_A7_PI_8(void) {uint ea = EA_A7_PI_8(); return m68ki_read_8(ea); } INLINE uint OPER_A7_PD_8(void) {uint ea = EA_A7_PD_8(); return m68ki_read_8(ea); } INLINE uint OPER_AW_8(void) {uint ea = EA_AW_8(); return m68ki_read_8(ea); } INLINE uint OPER_AW_16(void) {uint ea = EA_AW_16(); return m68ki_read_16(ea);} INLINE uint OPER_AW_32(void) {uint ea = EA_AW_32(); return m68ki_read_32(ea);} INLINE uint OPER_AL_8(void) {uint ea = EA_AL_8(); return m68ki_read_8(ea); } INLINE uint OPER_AL_16(void) {uint ea = EA_AL_16(); return m68ki_read_16(ea);} INLINE uint OPER_AL_32(void) {uint ea = EA_AL_32(); return m68ki_read_32(ea);} INLINE uint OPER_PCDI_8(void) {uint ea = EA_PCDI_8(); return m68ki_read_pcrel_8(ea); } INLINE uint OPER_PCDI_16(void) {uint ea = EA_PCDI_16(); return m68ki_read_pcrel_16(ea);} INLINE uint OPER_PCDI_32(void) {uint ea = EA_PCDI_32(); return m68ki_read_pcrel_32(ea);} INLINE uint OPER_PCIX_8(void) {uint ea = EA_PCIX_8(); return m68ki_read_pcrel_8(ea); } INLINE uint OPER_PCIX_16(void) {uint ea = EA_PCIX_16(); return m68ki_read_pcrel_16(ea);} INLINE uint OPER_PCIX_32(void) {uint ea = EA_PCIX_32(); return m68ki_read_pcrel_32(ea);} /* ---------------------------- Stack Functions --------------------------- */ /* Push/pull data from the stack */ INLINE void m68ki_push_16(uint value) { REG_SP = MASK_OUT_ABOVE_32(REG_SP - 2); m68ki_write_16(REG_SP, value); } INLINE void m68ki_push_32(uint value) { REG_SP = MASK_OUT_ABOVE_32(REG_SP - 4); m68ki_write_32(REG_SP, value); } INLINE uint m68ki_pull_16(void) { REG_SP = MASK_OUT_ABOVE_32(REG_SP + 2); return m68ki_read_16(REG_SP-2); } INLINE uint m68ki_pull_32(void) { REG_SP = MASK_OUT_ABOVE_32(REG_SP + 4); return m68ki_read_32(REG_SP-4); } /* Increment/decrement the stack as if doing a push/pull but * don't do any memory access. */ INLINE void m68ki_fake_push_16(void) { REG_SP = MASK_OUT_ABOVE_32(REG_SP - 2); } INLINE void m68ki_fake_push_32(void) { REG_SP = MASK_OUT_ABOVE_32(REG_SP - 4); } INLINE void m68ki_fake_pull_16(void) { REG_SP = MASK_OUT_ABOVE_32(REG_SP + 2); } INLINE void m68ki_fake_pull_32(void) { REG_SP = MASK_OUT_ABOVE_32(REG_SP + 4); } /* ----------------------------- Program Flow ----------------------------- */ /* Jump to a new program location or vector. * These functions will also call the pc_changed callback if it was enabled * in m68kconf.h. */ INLINE void m68ki_jump(uint new_pc) { REG_PC = new_pc; m68ki_pc_changed(REG_PC); } INLINE void m68ki_jump_vector(uint vector) { #if M68K_EMULATE_040 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_010 REG_PC = (vector<<2) + REG_VBR; REG_PC = m68ki_read_data_32(REG_PC); #else REG_PC = m68ki_read_data_32(vector<<2); m68ki_pc_changed(REG_PC); #endif } /* Branch to a new memory location. * The 32-bit branch will call pc_changed if it was enabled in m68kconf.h. * So far I've found no problems with not calling pc_changed for 8 or 16 * bit branches. */ INLINE void m68ki_branch_8(uint offset) { REG_PC += MAKE_INT_8(offset); } INLINE void m68ki_branch_16(uint offset) { REG_PC += MAKE_INT_16(offset); } INLINE void m68ki_branch_32(uint offset) { REG_PC += offset; m68ki_pc_changed(REG_PC); } /* ---------------------------- Status Register --------------------------- */ /* Set the S flag and change the active stack pointer. * Note that value MUST be 4 or 0. */ INLINE void m68ki_set_s_flag(uint value) { /* Backup the old stack pointer */ REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)] = REG_SP; /* Set the S flag */ FLAG_S = value; /* Set the new stack pointer */ REG_SP = REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)]; } /* Set the S and M flags and change the active stack pointer. * Note that value MUST be 0, 2, 4, or 6 (bit2 = S, bit1 = M). */ INLINE void m68ki_set_sm_flag(uint value) { /* Backup the old stack pointer */ REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)] = REG_SP; /* Set the S and M flags */ FLAG_S = value & SFLAG_SET; FLAG_M = value & MFLAG_SET; /* Set the new stack pointer */ REG_SP = REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)]; } /* Set the S and M flags. Don't touch the stack pointer. */ INLINE void m68ki_set_sm_flag_nosp(uint value) { /* Set the S and M flags */ FLAG_S = value & SFLAG_SET; FLAG_M = value & MFLAG_SET; } /* Set the condition code register */ INLINE void m68ki_set_ccr(uint value) { FLAG_X = BIT_4(value) << 4; FLAG_N = BIT_3(value) << 4; FLAG_Z = !BIT_2(value); FLAG_V = BIT_1(value) << 6; FLAG_C = BIT_0(value) << 8; } /* Set the status register but don't check for interrupts */ INLINE void m68ki_set_sr_noint(uint value) { /* Mask out the "unimplemented" bits */ value &= CPU_SR_MASK; /* Now set the status register */ FLAG_T1 = BIT_F(value); FLAG_T0 = BIT_E(value); FLAG_INT_MASK = value & 0x0700; m68ki_set_ccr(value); m68ki_set_sm_flag((value >> 11) & 6); } /* Set the status register but don't check for interrupts nor * change the stack pointer */ INLINE void m68ki_set_sr_noint_nosp(uint value) { /* Mask out the "unimplemented" bits */ value &= CPU_SR_MASK; /* Now set the status register */ FLAG_T1 = BIT_F(value); FLAG_T0 = BIT_E(value); FLAG_INT_MASK = value & 0x0700; m68ki_set_ccr(value); m68ki_set_sm_flag_nosp((value >> 11) & 6); } /* Set the status register and check for interrupts */ INLINE void m68ki_set_sr(uint value) { m68ki_set_sr_noint(value); m68ki_check_interrupts(); } /* ------------------------- Exception Processing ------------------------- */ /* Initiate exception processing */ INLINE uint m68ki_init_exception(void) { /* Save the old status register */ uint sr = m68ki_get_sr(); /* Turn off trace flag, clear pending traces */ FLAG_T1 = FLAG_T0 = 0; m68ki_clear_trace(); /* Enter supervisor mode */ m68ki_set_s_flag(SFLAG_SET); return sr; } /* 3 word stack frame (68000 only) */ INLINE void m68ki_stack_frame_3word(uint pc, uint sr) { m68ki_push_32(pc); m68ki_push_16(sr); } /* Format 0 stack frame. * This is the standard stack frame for 68010+. */ INLINE void m68ki_stack_frame_0000(uint pc, uint sr, uint vector) { /* Stack a 3-word frame if we are 68000 */ if(CPU_TYPE == CPU_TYPE_000 || CPU_TYPE == CPU_TYPE_008) { m68ki_stack_frame_3word(pc, sr); return; } m68ki_push_16(vector<<2); m68ki_push_32(pc); m68ki_push_16(sr); } /* Format 1 stack frame (68020). * For 68020, this is the 4 word throwaway frame. */ INLINE void m68ki_stack_frame_0001(uint pc, uint sr, uint vector) { m68ki_push_16(0x1000 | (vector<<2)); m68ki_push_32(pc); m68ki_push_16(sr); } /* Format 2 stack frame. * This is used only by 68020 for trap exceptions. */ INLINE void m68ki_stack_frame_0010(uint sr, uint vector) { m68ki_push_32(REG_PC-2); m68ki_push_16(0x2000 | (vector<<2)); m68ki_push_32(REG_PC); m68ki_push_16(sr); } /* Bus error stack frame (68000 only). */ INLINE void m68ki_stack_frame_buserr(uint sr) { m68ki_push_32(REG_PC); m68ki_push_16(sr); m68ki_push_16(REG_IR); m68ki_push_32(m68ki_aerr_address); /* access address */ /* 0 0 0 0 0 0 0 0 0 0 0 R/W I/N FC * R/W 0 = write, 1 = read * I/N 0 = instruction, 1 = not * FC 3-bit function code */ m68ki_push_16(m68ki_aerr_write_mode | CPU_INSTR_MODE | m68ki_aerr_fc); } /* Format 8 stack frame (68010). * 68010 only. This is the 29 word bus/address error frame. */ void m68ki_stack_frame_1000(uint pc, uint sr, uint vector) { /* VERSION * NUMBER * INTERNAL INFORMATION, 16 WORDS */ m68ki_fake_push_32(); m68ki_fake_push_32(); m68ki_fake_push_32(); m68ki_fake_push_32(); m68ki_fake_push_32(); m68ki_fake_push_32(); m68ki_fake_push_32(); m68ki_fake_push_32(); /* INSTRUCTION INPUT BUFFER */ m68ki_push_16(0); /* UNUSED, RESERVED (not written) */ m68ki_fake_push_16(); /* DATA INPUT BUFFER */ m68ki_push_16(0); /* UNUSED, RESERVED (not written) */ m68ki_fake_push_16(); /* DATA OUTPUT BUFFER */ m68ki_push_16(0); /* UNUSED, RESERVED (not written) */ m68ki_fake_push_16(); /* FAULT ADDRESS */ m68ki_push_32(0); /* SPECIAL STATUS WORD */ m68ki_push_16(0); /* 1000, VECTOR OFFSET */ m68ki_push_16(0x8000 | (vector<<2)); /* PROGRAM COUNTER */ m68ki_push_32(pc); /* STATUS REGISTER */ m68ki_push_16(sr); } /* Format A stack frame (short bus fault). * This is used only by 68020 for bus fault and address error * if the error happens at an instruction boundary. * PC stacked is address of next instruction. */ void m68ki_stack_frame_1010(uint sr, uint vector, uint pc) { /* INTERNAL REGISTER */ m68ki_push_16(0); /* INTERNAL REGISTER */ m68ki_push_16(0); /* DATA OUTPUT BUFFER (2 words) */ m68ki_push_32(0); /* INTERNAL REGISTER */ m68ki_push_16(0); /* INTERNAL REGISTER */ m68ki_push_16(0); /* DATA CYCLE FAULT ADDRESS (2 words) */ m68ki_push_32(0); /* INSTRUCTION PIPE STAGE B */ m68ki_push_16(0); /* INSTRUCTION PIPE STAGE C */ m68ki_push_16(0); /* SPECIAL STATUS REGISTER */ m68ki_push_16(0); /* INTERNAL REGISTER */ m68ki_push_16(0); /* 1010, VECTOR OFFSET */ m68ki_push_16(0xa000 | (vector<<2)); /* PROGRAM COUNTER */ m68ki_push_32(pc); /* STATUS REGISTER */ m68ki_push_16(sr); } /* Format B stack frame (long bus fault). * This is used only by 68020 for bus fault and address error * if the error happens during instruction execution. * PC stacked is address of instruction in progress. */ void m68ki_stack_frame_1011(uint sr, uint vector, uint pc) { /* INTERNAL REGISTERS (18 words) */ m68ki_push_32(0); m68ki_push_32(0); m68ki_push_32(0); m68ki_push_32(0); m68ki_push_32(0); m68ki_push_32(0); m68ki_push_32(0); m68ki_push_32(0); m68ki_push_32(0); /* VERSION# (4 bits), INTERNAL INFORMATION */ m68ki_push_16(0); /* INTERNAL REGISTERS (3 words) */ m68ki_push_32(0); m68ki_push_16(0); /* DATA INTPUT BUFFER (2 words) */ m68ki_push_32(0); /* INTERNAL REGISTERS (2 words) */ m68ki_push_32(0); /* STAGE B ADDRESS (2 words) */ m68ki_push_32(0); /* INTERNAL REGISTER (4 words) */ m68ki_push_32(0); m68ki_push_32(0); /* DATA OUTPUT BUFFER (2 words) */ m68ki_push_32(0); /* INTERNAL REGISTER */ m68ki_push_16(0); /* INTERNAL REGISTER */ m68ki_push_16(0); /* DATA CYCLE FAULT ADDRESS (2 words) */ m68ki_push_32(0); /* INSTRUCTION PIPE STAGE B */ m68ki_push_16(0); /* INSTRUCTION PIPE STAGE C */ m68ki_push_16(0); /* SPECIAL STATUS REGISTER */ m68ki_push_16(0); /* INTERNAL REGISTER */ m68ki_push_16(0); /* 1011, VECTOR OFFSET */ m68ki_push_16(0xb000 | (vector<<2)); /* PROGRAM COUNTER */ m68ki_push_32(pc); /* STATUS REGISTER */ m68ki_push_16(sr); } /* Used for Group 2 exceptions. * These stack a type 2 frame on the 020. */ INLINE void m68ki_exception_trap(uint vector) { uint sr = m68ki_init_exception(); if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) m68ki_stack_frame_0000(REG_PC, sr, vector); else m68ki_stack_frame_0010(sr, vector); m68ki_jump_vector(vector); /* Use up some clock cycles */ USE_CYCLES(CYC_EXCEPTION[vector]); } /* Trap#n stacks a 0 frame but behaves like group2 otherwise */ INLINE void m68ki_exception_trapN(uint vector) { uint sr = m68ki_init_exception(); m68ki_stack_frame_0000(REG_PC, sr, vector); m68ki_jump_vector(vector); /* Use up some clock cycles */ USE_CYCLES(CYC_EXCEPTION[vector]); } /* Exception for trace mode */ INLINE void m68ki_exception_trace(void) { uint sr = m68ki_init_exception(); if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) { #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON if(CPU_TYPE_IS_000(CPU_TYPE)) { CPU_INSTR_MODE = INSTRUCTION_NO; } #endif /* M68K_EMULATE_ADDRESS_ERROR */ m68ki_stack_frame_0000(REG_PC, sr, EXCEPTION_TRACE); } else m68ki_stack_frame_0010(sr, EXCEPTION_TRACE); m68ki_jump_vector(EXCEPTION_TRACE); /* Trace nullifies a STOP instruction */ CPU_STOPPED &= ~STOP_LEVEL_STOP; /* Use up some clock cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_TRACE]); } /* Exception for privilege violation */ INLINE void m68ki_exception_privilege_violation(void) { uint sr = m68ki_init_exception(); #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON if(CPU_TYPE_IS_000(CPU_TYPE)) { CPU_INSTR_MODE = INSTRUCTION_NO; } #endif /* M68K_EMULATE_ADDRESS_ERROR */ m68ki_stack_frame_0000(REG_PC-2, sr, EXCEPTION_PRIVILEGE_VIOLATION); m68ki_jump_vector(EXCEPTION_PRIVILEGE_VIOLATION); /* Use up some clock cycles and undo the instruction's cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_PRIVILEGE_VIOLATION] - CYC_INSTRUCTION[REG_IR]); } /* Exception for A-Line instructions */ INLINE void m68ki_exception_1010(void) { uint sr; #if M68K_LOG_1010_1111 == OPT_ON M68K_DO_LOG_EMU((M68K_LOG_FILEHANDLE "%s at %08x: called 1010 instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC-2), REG_IR, m68ki_disassemble_quick(ADDRESS_68K(REG_PC-2)))); #endif sr = m68ki_init_exception(); m68ki_stack_frame_0000(REG_PC-2, sr, EXCEPTION_1010); m68ki_jump_vector(EXCEPTION_1010); /* Use up some clock cycles and undo the instruction's cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_1010] - CYC_INSTRUCTION[REG_IR]); } /* Exception for F-Line instructions */ INLINE void m68ki_exception_1111(void) { uint sr; #if M68K_LOG_1010_1111 == OPT_ON M68K_DO_LOG_EMU((M68K_LOG_FILEHANDLE "%s at %08x: called 1111 instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC-2), REG_IR, m68ki_disassemble_quick(ADDRESS_68K(REG_PC-2)))); #endif sr = m68ki_init_exception(); m68ki_stack_frame_0000(REG_PC-2, sr, EXCEPTION_1111); m68ki_jump_vector(EXCEPTION_1111); /* Use up some clock cycles and undo the instruction's cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_1111] - CYC_INSTRUCTION[REG_IR]); } /* Exception for illegal instructions */ INLINE void m68ki_exception_illegal(void) { uint sr; M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: illegal instruction %04x (%s)\n", m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC-2), REG_IR, m68ki_disassemble_quick(ADDRESS_68K(REG_PC-2)))); sr = m68ki_init_exception(); #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON if(CPU_TYPE_IS_000(CPU_TYPE)) { CPU_INSTR_MODE = INSTRUCTION_NO; } #endif /* M68K_EMULATE_ADDRESS_ERROR */ m68ki_stack_frame_0000(REG_PC-2, sr, EXCEPTION_ILLEGAL_INSTRUCTION); m68ki_jump_vector(EXCEPTION_ILLEGAL_INSTRUCTION); /* Use up some clock cycles and undo the instruction's cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_ILLEGAL_INSTRUCTION] - CYC_INSTRUCTION[REG_IR]); } /* Exception for format errror in RTE */ INLINE void m68ki_exception_format_error(void) { uint sr = m68ki_init_exception(); m68ki_stack_frame_0000(REG_PC, sr, EXCEPTION_FORMAT_ERROR); m68ki_jump_vector(EXCEPTION_FORMAT_ERROR); /* Use up some clock cycles and undo the instruction's cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_FORMAT_ERROR] - CYC_INSTRUCTION[REG_IR]); } /* Exception for address error */ INLINE void m68ki_exception_address_error(void) { uint sr = m68ki_init_exception(); /* If we were processing a bus error, address error, or reset, * this is a catastrophic failure. * Halt the CPU */ if(CPU_RUN_MODE == RUN_MODE_BERR_AERR_RESET) { CPU_STOPPED = STOP_LEVEL_HALT; return; } CPU_RUN_MODE = RUN_MODE_BERR_AERR_RESET; /* Note: This is implemented for 68000 only! */ m68ki_stack_frame_buserr(sr); m68ki_jump_vector(EXCEPTION_ADDRESS_ERROR); /* Use up some clock cycles and undo the instruction's cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_ADDRESS_ERROR] - CYC_INSTRUCTION[REG_IR]); } /* Service an interrupt request and start exception processing */ INLINE void m68ki_exception_interrupt(uint int_level) { #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON if(CPU_TYPE_IS_000(CPU_TYPE)) { CPU_INSTR_MODE = INSTRUCTION_NO; } #endif /* M68K_EMULATE_ADDRESS_ERROR */ /* Turn off the stopped state */ CPU_STOPPED &= ~STOP_LEVEL_STOP; /* If we are halted, don't do anything */ if(CPU_STOPPED) return; /* Acknowledge the interrupt */ m68ki_int_ack(int_level); /* Always use the autovectors. */ uint vector = EXCEPTION_INTERRUPT_AUTOVECTOR+int_level; /* Start exception processing */ uint sr = m68ki_init_exception(); /* Set the interrupt mask to the level of the one being serviced */ FLAG_INT_MASK = int_level<<8; /* Get the new PC */ #if M68K_EMULATE_040 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_010 uint new_pc = m68ki_read_data_32((vector<<2) + REG_VBR); #else uint new_pc = m68ki_read_data_32(vector<<2); #endif /* If vector is uninitialized, call the uninitialized interrupt vector */ if(new_pc == 0) new_pc = m68ki_read_data_32((EXCEPTION_UNINITIALIZED_INTERRUPT<<2) + REG_VBR); /* Generate a stack frame */ m68ki_stack_frame_0000(REG_PC, sr, vector); #if M68K_EMULATE_040 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_010 if(FLAG_M && CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) { /* Create throwaway frame */ m68ki_set_sm_flag(FLAG_S); /* clear M */ sr |= 0x2000; /* Same as SR in master stack frame except S is forced high */ m68ki_stack_frame_0001(REG_PC, sr, vector); } #endif m68ki_jump(new_pc); /* Update cycle count now */ USE_CYCLES(CYC_EXCEPTION[vector]); } /* ASG: Check for interrupts */ INLINE void m68ki_check_interrupts(void) { if(CPU_INT_LEVEL > FLAG_INT_MASK) m68ki_exception_interrupt(CPU_INT_LEVEL>>8); } /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */ #endif /* M68KCPU__HEADER */
zyking1987-genplus-droid
genplusgx/m68k/m68kcpu.h
C
gpl2
69,142
/* ======================================================================== */ /* ========================= LICENSING & COPYRIGHT ======================== */ /* ======================================================================== */ /* * MUSASHI * Version 3.32 * * A portable Motorola M680x0 processor emulation engine. * Copyright Karl Stenerud. All rights reserved. * * This code may be freely used for non-commercial purposes as long as this * copyright notice remains unaltered in the source code and any binary files * containing this code in compiled form. * * All other licensing terms must be negotiated with the author * (Karl Stenerud). * * The latest version of this code can be obtained at: * http://kstenerud.cjb.net */ #ifndef M68KCONF__HEADER #define M68KCONF__HEADER /* Configuration switches. * Use OPT_SPECIFY_HANDLER for configuration options that allow callbacks. * OPT_SPECIFY_HANDLER causes the core to link directly to the function * or macro you specify, rather than using callback functions whose pointer * must be passed in using m68k_set_xxx_callback(). */ #define OPT_OFF 0 #define OPT_ON 1 #define OPT_SPECIFY_HANDLER 2 /* ======================================================================== */ /* ============================== MAME STUFF ============================== */ /* ======================================================================== */ /* If you're compiling this for MAME, only change M68K_COMPILE_FOR_MAME * to OPT_ON and use m68kmame.h to configure the 68k core. */ #ifndef M68K_COMPILE_FOR_MAME #define M68K_COMPILE_FOR_MAME OPT_OFF #endif /* M68K_COMPILE_FOR_MAME */ #if M68K_COMPILE_FOR_MAME == OPT_OFF /* ======================================================================== */ /* ============================= CONFIGURATION ============================ */ /* ======================================================================== */ /* Turn ON if you want to use the following M68K variants */ #define M68K_EMULATE_008 OPT_OFF #define M68K_EMULATE_010 OPT_OFF #define M68K_EMULATE_EC020 OPT_OFF #define M68K_EMULATE_020 OPT_OFF #define M68K_EMULATE_040 OPT_OFF /* If ON, the CPU will call m68k_read_immediate_xx() for immediate addressing * and m68k_read_pcrelative_xx() for PC-relative addressing. * If off, all read requests from the CPU will be redirected to m68k_read_xx() */ #define M68K_SEPARATE_READS OPT_ON /* If ON, the CPU will call m68k_write_32_pd() when it executes move.l with a * predecrement destination EA mode instead of m68k_write_32(). * To simulate real 68k behavior, m68k_write_32_pd() must first write the high * word to [address+2], and then write the low word to [address]. */ #define M68K_SIMULATE_PD_WRITES OPT_OFF /* If ON, CPU will call the interrupt acknowledge callback when it services an * interrupt. * If off, all interrupts will be autovectored and all interrupt requests will * auto-clear when the interrupt is serviced. */ #define M68K_EMULATE_INT_ACK OPT_SPECIFY_HANDLER #define M68K_INT_ACK_CALLBACK(A) vdp_68k_irq_ack(A) /* If ON, CPU will call the breakpoint acknowledge callback when it encounters * a breakpoint instruction and it is running a 68010+. */ #define M68K_EMULATE_BKPT_ACK OPT_OFF #define M68K_BKPT_ACK_CALLBACK() your_bkpt_ack_handler_function() /* If ON, the CPU will monitor the trace flags and take trace exceptions */ #define M68K_EMULATE_TRACE OPT_OFF /* If ON, CPU will call the output reset callback when it encounters a reset * instruction. */ #define M68K_EMULATE_RESET OPT_OFF #define M68K_RESET_CALLBACK() your_reset_handler_function() /* If ON, CPU will call the callback when it encounters a cmpi.l #v, dn * instruction. */ #define M68K_CMPILD_HAS_CALLBACK OPT_OFF #define M68K_CMPILD_CALLBACK(v,r) your_cmpild_handler_function(v,r) /* If ON, CPU will call the callback when it encounters a rte * instruction. */ #define M68K_RTE_HAS_CALLBACK OPT_OFF #define M68K_RTE_CALLBACK() your_rte_handler_function() /* If ON, CPU will call the callback when it encounters a tas * instruction. */ #define M68K_TAS_HAS_CALLBACK OPT_OFF #define M68K_TAS_CALLBACK() your_tas_handler_function() /* If ON, CPU will call the set fc callback on every memory access to * differentiate between user/supervisor, program/data access like a real * 68000 would. This should be enabled and the callback should be set if you * want to properly emulate the m68010 or higher. (moves uses function codes * to read/write data from different address spaces) */ #define M68K_EMULATE_FC OPT_OFF #define M68K_SET_FC_CALLBACK(A) your_set_fc_handler_function(A) /* If ON, CPU will call the pc changed callback when it changes the PC by a * large value. This allows host programs to be nicer when it comes to * fetching immediate data and instructions on a banked memory system. */ #define M68K_MONITOR_PC OPT_OFF #define M68K_SET_PC_CALLBACK(A) your_pc_changed_handler_function(A) /* If ON, CPU will call the instruction hook callback before every * instruction. */ #define M68K_INSTRUCTION_HOOK OPT_OFF #define M68K_INSTRUCTION_CALLBACK() your_instruction_hook_function() /* If ON, the CPU will emulate the 4-byte prefetch queue of a real 68000 */ #define M68K_EMULATE_PREFETCH OPT_OFF /* If ON, the CPU will generate address error exceptions if it tries to * access a word or longword at an odd address. * NOTE: This is only emulated properly for 68000 mode. */ #define M68K_EMULATE_ADDRESS_ERROR OPT_OFF /* If ON, branch instructions will check for infinite loop and * freeze current CPU execution . * Unnecessary checking might be disabled to improve instruction * emulation speed since infinite loops are going to "lock" the CPU * execution anyway. */ #define M68K_CHECK_INFINITE_LOOP OPT_OFF /* Turn ON to enable logging of illegal instruction calls. * M68K_LOG_FILEHANDLE must be #defined to a stdio file stream. * Turn on M68K_LOG_1010_1111 to log all 1010 and 1111 calls. */ #define M68K_LOG_ENABLE OPT_OFF #define M68K_LOG_1010_1111 OPT_OFF #define M68K_LOG_FILEHANDLE some_file_handle /* ----------------------------- COMPATIBILITY ---------------------------- */ /* The following options set optimizations that violate the current ANSI * standard, but will be compliant under the forthcoming C9X standard. */ /* If ON, the enulation core will use 64-bit integers to speed up some * operations. */ #define M68K_USE_64_BIT OPT_OFF /* Set to your compiler's static inline keyword to enable it, or * set it to blank to disable it. * If you define INLINE in the makefile, it will override this value. * NOTE: not enabling inline functions will SEVERELY slow down emulation. */ #ifndef INLINE #define INLINE static __inline__ #endif /* INLINE */ #endif /* M68K_COMPILE_FOR_MAME */ /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */ #endif /* M68KCONF__HEADER */
zyking1987-genplus-droid
genplusgx/m68k/m68kconf.h
C
gpl2
7,605
/* * Compute exact number of CPU cycles taken * by DIVU and DIVS on a 68000 processor. * * Copyright (c) 2005 by Jorge Cwik, pasti@fxatari.com * * Added MULU and MULS accurate timings (Eke-Eke) * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* The routines below take dividend and divisor as parameters. They return 0 if division by zero, or exact number of cycles otherwise. The number of cycles returned assumes a register operand. Effective address time must be added if memory operand. For 68000 only (not 68010, 68012, 68020, etc). Probably valid for 68008 after adding the extra prefetch cycle. Best and worst cases for register operand: (Note the difference with the documented range.) DIVU: Overflow (always): 10 cycles. Worst case: 136 cycles. Best case: 76 cycles. DIVS: Absolute overflow: 16-18 cycles. Signed overflow is not detected prematurely. Worst case: 156 cycles. Best case without signed overflow: 122 cycles. Best case with signed overflow: 120 cycles */ #include <stdlib.h> // Change this depending on architecture // This code assumes long is 32 bits and short is 16 bits typedef unsigned long DWORD; typedef unsigned short WORD; typedef signed long LONG; typedef signed short SHORT; // // DIVU // Unsigned division // INLINE unsigned getDivu68kCycles( DWORD dividend, WORD divisor) { int i; //if( (WORD) divisor == 0) // return 0; // Overflow //if( (dividend >> 16) >= divisor) // return (mcycles = 5) * 2; unsigned mcycles = 38; DWORD hdivisor = ((DWORD) divisor) << 16; for( i = 0; i < 15; i++) { DWORD temp; temp = dividend; dividend <<= 1; // If carry from shift if( (LONG) temp < 0) { dividend -= hdivisor; } else { mcycles += 2; if( dividend >= hdivisor) { dividend -= hdivisor; mcycles--; } } } return mcycles * 14; } // // DIVS // Signed division // INLINE unsigned getDivs68kCycles( LONG dividend, SHORT divisor) { //if( (SHORT) divisor == 0) // return 0; unsigned mcycles = 6; if( dividend < 0) mcycles++; // Check for absolute overflow if( ((DWORD) abs( dividend) >> 16) >= (WORD) abs( divisor)) { return (mcycles + 2) * 14; } // Absolute quotient unsigned aquot = (DWORD) abs( dividend) / (WORD) abs( divisor); mcycles += 55; if( divisor >= 0) { if( dividend >= 0) mcycles--; else mcycles++; } // Count 15 msbits in absolute of quotient int i; for( i = 0; i < 15; i++) { if( (SHORT) aquot >= 0) mcycles++; aquot <<= 1; } return mcycles * 14; } // // MULU // Unsigned multiplication // INLINE unsigned getMulu68kCycles( WORD source) { unsigned mcycles = 266; /* count number of bits set to 1 */ while (source) { if (source & 1) { mcycles += 14; } source >>= 1; } /* 38 + 2*N */ return mcycles; } // // MULS // Signed multiplication // INLINE unsigned getMuls68kCycles( SHORT source) { unsigned mcycles = 266; /* detect 01 or 10 patterns */ LONG temp = source << 1; temp = (temp ^ source) & 0xFFFF; /* count number of bits set to 1 */ while (temp) { if (temp & 1) { mcycles += 14; } temp >>= 1; } /* 38 + 2*N */ return mcycles; }
zyking1987-genplus-droid
genplusgx/m68k/m68kCycleAccurate.h
C
gpl2
4,196
/* ======================================================================== */ /* ========================= LICENSING & COPYRIGHT ======================== */ /* ======================================================================== */ #if 0 static const char copyright_notice[] = "MUSASHI\n" "Version 3.32 (2007-12-15)\n" "A portable Motorola M680x0 processor emulation engine.\n" "Copyright Karl Stenerud. All rights reserved.\n" "\n" "This code may be freely used for non-commercial purpooses as long as this\n" "copyright notice remains unaltered in the source code and any binary files\n" "containing this code in compiled form.\n" "\n" "All other licensing terms must be negotiated with the author\n" "(Karl Stenerud).\n" "\n" "The latest version of this code can be obtained at:\n" "http://kstenerud.cjb.net\n" ; #endif /* ======================================================================== */ /* ================================= NOTES ================================ */ /* ======================================================================== */ /* ======================================================================== */ /* ================================ INCLUDES ============================== */ /* ======================================================================== */ #include "m68kops.h" #include "m68kcpu.h" #if M68K_EMULATE_040 #include "m68kfpu.c" extern void m68040_fpu_op0(void); extern void m68040_fpu_op1(void); #endif /* M68K_EMULATE_040 */ /* ======================================================================== */ /* ================================= DATA ================================= */ /* ======================================================================== */ #if 0 int m68ki_initial_cycles; int m68ki_remaining_cycles = 0; /* Number of clocks remaining */ #endif #if M68K_EMULATE_TRACE uint m68ki_tracing = 0; #endif /* M68K_EMULATE_TRACE */ #if M68K_EMULATE_FC uint m68ki_address_space; #endif /* M68K_EMULATE_FC */ #ifdef M68K_LOG_ENABLE const char *const m68ki_cpu_names[] = { "Invalid CPU", "M68000", "M68008", "Invalid CPU", "M68010", "Invalid CPU", "Invalid CPU", "Invalid CPU", "M68EC020", "Invalid CPU", "Invalid CPU", "Invalid CPU", "Invalid CPU", "Invalid CPU", "Invalid CPU", "Invalid CPU", "M68020" }; #endif /* M68K_LOG_ENABLE */ /* The CPU core */ m68ki_cpu_core m68ki_cpu; #if M68K_EMULATE_ADDRESS_ERROR #include <setjmp.h> jmp_buf m68ki_aerr_trap; int emulate_address_error = 0; #endif /* M68K_EMULATE_ADDRESS_ERROR */ uint m68ki_aerr_address; uint m68ki_aerr_write_mode; uint m68ki_aerr_fc; /* Used by shift & rotate instructions */ const uint8 m68ki_shift_8_table[65] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; const uint16 m68ki_shift_16_table[65] = { 0x0000, 0x8000, 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80, 0xffc0, 0xffe0, 0xfff0, 0xfff8, 0xfffc, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; const uint m68ki_shift_32_table[65] = { 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; /* Number of clock cycles to use for exception processing. * I used 4 for any vectors that are undocumented for processing times. */ uint16 m68ki_exception_cycle_table[NUM_CPU_TYPES][256] = { { /* 000 */ 40, /* 0: Reset - Initial Stack Pointer */ 4, /* 1: Reset - Initial Program Counter */ 50, /* 2: Bus Error (unemulated) */ 50, /* 3: Address Error (unemulated) */ 34, /* 4: Illegal Instruction */ 38, /* 5: Divide by Zero -- ASG: changed from 42 */ 40, /* 6: CHK -- ASG: chanaged from 44 */ 34, /* 7: TRAPV */ 34, /* 8: Privilege Violation */ 34, /* 9: Trace */ 4, /* 10: 1010 */ 4, /* 11: 1111 */ 4, /* 12: RESERVED */ 4, /* 13: Coprocessor Protocol Violation (unemulated) */ 4, /* 14: Format Error */ 44, /* 15: Uninitialized Interrupt */ 4, /* 16: RESERVED */ 4, /* 17: RESERVED */ 4, /* 18: RESERVED */ 4, /* 19: RESERVED */ 4, /* 20: RESERVED */ 4, /* 21: RESERVED */ 4, /* 22: RESERVED */ 4, /* 23: RESERVED */ 44, /* 24: Spurious Interrupt */ 44, /* 25: Level 1 Interrupt Autovector */ 44, /* 26: Level 2 Interrupt Autovector */ 44, /* 27: Level 3 Interrupt Autovector */ 44, /* 28: Level 4 Interrupt Autovector */ 44, /* 29: Level 5 Interrupt Autovector */ 44, /* 30: Level 6 Interrupt Autovector */ 44, /* 31: Level 7 Interrupt Autovector */ 34, /* 32: TRAP #0 -- ASG: chanaged from 38 */ 34, /* 33: TRAP #1 */ 34, /* 34: TRAP #2 */ 34, /* 35: TRAP #3 */ 34, /* 36: TRAP #4 */ 34, /* 37: TRAP #5 */ 34, /* 38: TRAP #6 */ 34, /* 39: TRAP #7 */ 34, /* 40: TRAP #8 */ 34, /* 41: TRAP #9 */ 34, /* 42: TRAP #10 */ 34, /* 43: TRAP #11 */ 34, /* 44: TRAP #12 */ 34, /* 45: TRAP #13 */ 34, /* 46: TRAP #14 */ 34, /* 47: TRAP #15 */ 4, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ 4, /* 49: FP Inexact Result (unemulated) */ 4, /* 50: FP Divide by Zero (unemulated) */ 4, /* 51: FP Underflow (unemulated) */ 4, /* 52: FP Operand Error (unemulated) */ 4, /* 53: FP Overflow (unemulated) */ 4, /* 54: FP Signaling NAN (unemulated) */ 4, /* 55: FP Unimplemented Data Type (unemulated) */ 4, /* 56: MMU Configuration Error (unemulated) */ 4, /* 57: MMU Illegal Operation Error (unemulated) */ 4, /* 58: MMU Access Level Violation Error (unemulated) */ 4, /* 59: RESERVED */ 4, /* 60: RESERVED */ 4, /* 61: RESERVED */ 4, /* 62: RESERVED */ 4, /* 63: RESERVED */ /* 64-255: User Defined */ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 }, #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 { /* 010 */ 40, /* 0: Reset - Initial Stack Pointer */ 4, /* 1: Reset - Initial Program Counter */ 126, /* 2: Bus Error (unemulated) */ 126, /* 3: Address Error (unemulated) */ 38, /* 4: Illegal Instruction */ 44, /* 5: Divide by Zero */ 44, /* 6: CHK */ 34, /* 7: TRAPV */ 38, /* 8: Privilege Violation */ 38, /* 9: Trace */ 4, /* 10: 1010 */ 4, /* 11: 1111 */ 4, /* 12: RESERVED */ 4, /* 13: Coprocessor Protocol Violation (unemulated) */ 4, /* 14: Format Error */ 44, /* 15: Uninitialized Interrupt */ 4, /* 16: RESERVED */ 4, /* 17: RESERVED */ 4, /* 18: RESERVED */ 4, /* 19: RESERVED */ 4, /* 20: RESERVED */ 4, /* 21: RESERVED */ 4, /* 22: RESERVED */ 4, /* 23: RESERVED */ 46, /* 24: Spurious Interrupt */ 46, /* 25: Level 1 Interrupt Autovector */ 46, /* 26: Level 2 Interrupt Autovector */ 46, /* 27: Level 3 Interrupt Autovector */ 46, /* 28: Level 4 Interrupt Autovector */ 46, /* 29: Level 5 Interrupt Autovector */ 46, /* 30: Level 6 Interrupt Autovector */ 46, /* 31: Level 7 Interrupt Autovector */ 38, /* 32: TRAP #0 */ 38, /* 33: TRAP #1 */ 38, /* 34: TRAP #2 */ 38, /* 35: TRAP #3 */ 38, /* 36: TRAP #4 */ 38, /* 37: TRAP #5 */ 38, /* 38: TRAP #6 */ 38, /* 39: TRAP #7 */ 38, /* 40: TRAP #8 */ 38, /* 41: TRAP #9 */ 38, /* 42: TRAP #10 */ 38, /* 43: TRAP #11 */ 38, /* 44: TRAP #12 */ 38, /* 45: TRAP #13 */ 38, /* 46: TRAP #14 */ 38, /* 47: TRAP #15 */ 4, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ 4, /* 49: FP Inexact Result (unemulated) */ 4, /* 50: FP Divide by Zero (unemulated) */ 4, /* 51: FP Underflow (unemulated) */ 4, /* 52: FP Operand Error (unemulated) */ 4, /* 53: FP Overflow (unemulated) */ 4, /* 54: FP Signaling NAN (unemulated) */ 4, /* 55: FP Unimplemented Data Type (unemulated) */ 4, /* 56: MMU Configuration Error (unemulated) */ 4, /* 57: MMU Illegal Operation Error (unemulated) */ 4, /* 58: MMU Access Level Violation Error (unemulated) */ 4, /* 59: RESERVED */ 4, /* 60: RESERVED */ 4, /* 61: RESERVED */ 4, /* 62: RESERVED */ 4, /* 63: RESERVED */ /* 64-255: User Defined */ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 }, { /* 020 */ 4, /* 0: Reset - Initial Stack Pointer */ 4, /* 1: Reset - Initial Program Counter */ 50, /* 2: Bus Error (unemulated) */ 50, /* 3: Address Error (unemulated) */ 20, /* 4: Illegal Instruction */ 38, /* 5: Divide by Zero */ 40, /* 6: CHK */ 20, /* 7: TRAPV */ 34, /* 8: Privilege Violation */ 25, /* 9: Trace */ 20, /* 10: 1010 */ 20, /* 11: 1111 */ 4, /* 12: RESERVED */ 4, /* 13: Coprocessor Protocol Violation (unemulated) */ 4, /* 14: Format Error */ 30, /* 15: Uninitialized Interrupt */ 4, /* 16: RESERVED */ 4, /* 17: RESERVED */ 4, /* 18: RESERVED */ 4, /* 19: RESERVED */ 4, /* 20: RESERVED */ 4, /* 21: RESERVED */ 4, /* 22: RESERVED */ 4, /* 23: RESERVED */ 30, /* 24: Spurious Interrupt */ 30, /* 25: Level 1 Interrupt Autovector */ 30, /* 26: Level 2 Interrupt Autovector */ 30, /* 27: Level 3 Interrupt Autovector */ 30, /* 28: Level 4 Interrupt Autovector */ 30, /* 29: Level 5 Interrupt Autovector */ 30, /* 30: Level 6 Interrupt Autovector */ 30, /* 31: Level 7 Interrupt Autovector */ 20, /* 32: TRAP #0 */ 20, /* 33: TRAP #1 */ 20, /* 34: TRAP #2 */ 20, /* 35: TRAP #3 */ 20, /* 36: TRAP #4 */ 20, /* 37: TRAP #5 */ 20, /* 38: TRAP #6 */ 20, /* 39: TRAP #7 */ 20, /* 40: TRAP #8 */ 20, /* 41: TRAP #9 */ 20, /* 42: TRAP #10 */ 20, /* 43: TRAP #11 */ 20, /* 44: TRAP #12 */ 20, /* 45: TRAP #13 */ 20, /* 46: TRAP #14 */ 20, /* 47: TRAP #15 */ 4, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ 4, /* 49: FP Inexact Result (unemulated) */ 4, /* 50: FP Divide by Zero (unemulated) */ 4, /* 51: FP Underflow (unemulated) */ 4, /* 52: FP Operand Error (unemulated) */ 4, /* 53: FP Overflow (unemulated) */ 4, /* 54: FP Signaling NAN (unemulated) */ 4, /* 55: FP Unimplemented Data Type (unemulated) */ 4, /* 56: MMU Configuration Error (unemulated) */ 4, /* 57: MMU Illegal Operation Error (unemulated) */ 4, /* 58: MMU Access Level Violation Error (unemulated) */ 4, /* 59: RESERVED */ 4, /* 60: RESERVED */ 4, /* 61: RESERVED */ 4, /* 62: RESERVED */ 4, /* 63: RESERVED */ /* 64-255: User Defined */ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 }, { /* 040 */ // TODO: these values are not correct 4, /* 0: Reset - Initial Stack Pointer */ 4, /* 1: Reset - Initial Program Counter */ 50, /* 2: Bus Error (unemulated) */ 50, /* 3: Address Error (unemulated) */ 20, /* 4: Illegal Instruction */ 38, /* 5: Divide by Zero */ 40, /* 6: CHK */ 20, /* 7: TRAPV */ 34, /* 8: Privilege Violation */ 25, /* 9: Trace */ 20, /* 10: 1010 */ 20, /* 11: 1111 */ 4, /* 12: RESERVED */ 4, /* 13: Coprocessor Protocol Violation (unemulated) */ 4, /* 14: Format Error */ 30, /* 15: Uninitialized Interrupt */ 4, /* 16: RESERVED */ 4, /* 17: RESERVED */ 4, /* 18: RESERVED */ 4, /* 19: RESERVED */ 4, /* 20: RESERVED */ 4, /* 21: RESERVED */ 4, /* 22: RESERVED */ 4, /* 23: RESERVED */ 30, /* 24: Spurious Interrupt */ 30, /* 25: Level 1 Interrupt Autovector */ 30, /* 26: Level 2 Interrupt Autovector */ 30, /* 27: Level 3 Interrupt Autovector */ 30, /* 28: Level 4 Interrupt Autovector */ 30, /* 29: Level 5 Interrupt Autovector */ 30, /* 30: Level 6 Interrupt Autovector */ 30, /* 31: Level 7 Interrupt Autovector */ 20, /* 32: TRAP #0 */ 20, /* 33: TRAP #1 */ 20, /* 34: TRAP #2 */ 20, /* 35: TRAP #3 */ 20, /* 36: TRAP #4 */ 20, /* 37: TRAP #5 */ 20, /* 38: TRAP #6 */ 20, /* 39: TRAP #7 */ 20, /* 40: TRAP #8 */ 20, /* 41: TRAP #9 */ 20, /* 42: TRAP #10 */ 20, /* 43: TRAP #11 */ 20, /* 44: TRAP #12 */ 20, /* 45: TRAP #13 */ 20, /* 46: TRAP #14 */ 20, /* 47: TRAP #15 */ 4, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ 4, /* 49: FP Inexact Result (unemulated) */ 4, /* 50: FP Divide by Zero (unemulated) */ 4, /* 51: FP Underflow (unemulated) */ 4, /* 52: FP Operand Error (unemulated) */ 4, /* 53: FP Overflow (unemulated) */ 4, /* 54: FP Signaling NAN (unemulated) */ 4, /* 55: FP Unimplemented Data Type (unemulated) */ 4, /* 56: MMU Configuration Error (unemulated) */ 4, /* 57: MMU Illegal Operation Error (unemulated) */ 4, /* 58: MMU Access Level Violation Error (unemulated) */ 4, /* 59: RESERVED */ 4, /* 60: RESERVED */ 4, /* 61: RESERVED */ 4, /* 62: RESERVED */ 4, /* 63: RESERVED */ /* 64-255: User Defined */ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 } #endif }; #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 const uint8 m68ki_ea_idx_cycle_table[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ..01.000 no memory indirect, base NULL */ 5, /* ..01..01 memory indirect, base NULL, outer NULL */ 7, /* ..01..10 memory indirect, base NULL, outer 16 */ 7, /* ..01..11 memory indirect, base NULL, outer 32 */ 0, 5, 7, 7, 0, 5, 7, 7, 0, 5, 7, 7, 2, /* ..10.000 no memory indirect, base 16 */ 7, /* ..10..01 memory indirect, base 16, outer NULL */ 9, /* ..10..10 memory indirect, base 16, outer 16 */ 9, /* ..10..11 memory indirect, base 16, outer 32 */ 0, 7, 9, 9, 0, 7, 9, 9, 0, 7, 9, 9, 6, /* ..11.000 no memory indirect, base 32 */ 11, /* ..11..01 memory indirect, base 32, outer NULL */ 13, /* ..11..10 memory indirect, base 32, outer 16 */ 13, /* ..11..11 memory indirect, base 32, outer 32 */ 0, 11, 13, 13, 0, 11, 13, 13, 0, 11, 13, 13 }; #endif /* ======================================================================== */ /* =============================== CALLBACKS ============================== */ /* ======================================================================== */ /* Default callbacks used if the callback hasn't been set yet, or if the * callback is set to NULL */ /* Interrupt acknowledge */ static int default_int_ack_callback_data; static int default_int_ack_callback(int int_level) { default_int_ack_callback_data = int_level; CPU_INT_LEVEL = 0; return M68K_INT_ACK_AUTOVECTOR; } /* Breakpoint acknowledge */ static unsigned int default_bkpt_ack_callback_data; static void default_bkpt_ack_callback(unsigned int data) { default_bkpt_ack_callback_data = data; } /* Called when a reset instruction is executed */ static void default_reset_instr_callback(void) { } /* Called when a cmpi.l #v, dn instruction is executed */ static void default_cmpild_instr_callback(unsigned int val, int reg) { } /* Called when a rte instruction is executed */ static void default_rte_instr_callback(void) { } /* Called when a tas instruction is executed */ static int default_tas_instr_callback(void) { return 1; // allow writeback } /* Called when the program counter changed by a large value */ static unsigned int default_pc_changed_callback_data; static void default_pc_changed_callback(unsigned int new_pc) { default_pc_changed_callback_data = new_pc; } /* Called every time there's bus activity (read/write to/from memory */ static unsigned int default_set_fc_callback_data; static void default_set_fc_callback(unsigned int new_fc) { default_set_fc_callback_data = new_fc; } /* Called every instruction cycle prior to execution */ static void default_instr_hook_callback(unsigned int pc) { } /* ======================================================================== */ /* ================================= API ================================== */ /* ======================================================================== */ /* Access the internals of the CPU */ unsigned int m68k_get_reg(void* context, m68k_register_t regnum) { m68ki_cpu_core* cpu = context != NULL ?(m68ki_cpu_core*)context : &m68ki_cpu; switch(regnum) { case M68K_REG_D0: return cpu->dar[0]; case M68K_REG_D1: return cpu->dar[1]; case M68K_REG_D2: return cpu->dar[2]; case M68K_REG_D3: return cpu->dar[3]; case M68K_REG_D4: return cpu->dar[4]; case M68K_REG_D5: return cpu->dar[5]; case M68K_REG_D6: return cpu->dar[6]; case M68K_REG_D7: return cpu->dar[7]; case M68K_REG_A0: return cpu->dar[8]; case M68K_REG_A1: return cpu->dar[9]; case M68K_REG_A2: return cpu->dar[10]; case M68K_REG_A3: return cpu->dar[11]; case M68K_REG_A4: return cpu->dar[12]; case M68K_REG_A5: return cpu->dar[13]; case M68K_REG_A6: return cpu->dar[14]; case M68K_REG_A7: return cpu->dar[15]; case M68K_REG_PC: return MASK_OUT_ABOVE_32(cpu->pc); case M68K_REG_SR: return cpu->t1_flag | cpu->t0_flag | (cpu->s_flag << 11) | (cpu->m_flag << 11) | cpu->int_mask | ((cpu->x_flag & XFLAG_SET) >> 4) | ((cpu->n_flag & NFLAG_SET) >> 4) | ((!cpu->not_z_flag) << 2) | ((cpu->v_flag & VFLAG_SET) >> 6) | ((cpu->c_flag & CFLAG_SET) >> 8); case M68K_REG_SP: return cpu->dar[15]; case M68K_REG_USP: return cpu->s_flag ? cpu->sp[0] : cpu->dar[15]; case M68K_REG_ISP: return cpu->s_flag && !cpu->m_flag ? cpu->dar[15] : cpu->sp[4]; case M68K_REG_MSP: return cpu->s_flag && cpu->m_flag ? cpu->dar[15] : cpu->sp[6]; case M68K_REG_SFC: return cpu->sfc; case M68K_REG_DFC: return cpu->dfc; case M68K_REG_VBR: return cpu->vbr; case M68K_REG_CACR: return cpu->cacr; case M68K_REG_CAAR: return cpu->caar; case M68K_REG_PREF_ADDR: return cpu->pref_addr; case M68K_REG_PREF_DATA: return cpu->pref_data; case M68K_REG_PPC: return MASK_OUT_ABOVE_32(cpu->ppc); case M68K_REG_IR: return cpu->ir; case M68K_REG_CPU_TYPE: switch(cpu->cpu_type) { case CPU_TYPE_000: return (unsigned int)M68K_CPU_TYPE_68000; case CPU_TYPE_008: return (unsigned int)M68K_CPU_TYPE_68008; case CPU_TYPE_010: return (unsigned int)M68K_CPU_TYPE_68010; case CPU_TYPE_EC020: return (unsigned int)M68K_CPU_TYPE_68EC020; case CPU_TYPE_020: return (unsigned int)M68K_CPU_TYPE_68020; case CPU_TYPE_040: return (unsigned int)M68K_CPU_TYPE_68040; } return M68K_CPU_TYPE_INVALID; default: return 0; } return 0; } void m68k_set_reg(m68k_register_t regnum, unsigned int value) { switch(regnum) { case M68K_REG_D0: REG_D[0] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_D1: REG_D[1] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_D2: REG_D[2] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_D3: REG_D[3] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_D4: REG_D[4] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_D5: REG_D[5] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_D6: REG_D[6] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_D7: REG_D[7] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A0: REG_A[0] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A1: REG_A[1] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A2: REG_A[2] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A3: REG_A[3] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A4: REG_A[4] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A5: REG_A[5] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A6: REG_A[6] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_A7: REG_A[7] = MASK_OUT_ABOVE_32(value); return; case M68K_REG_PC: m68ki_jump(MASK_OUT_ABOVE_32(value)); return; case M68K_REG_SR: m68ki_set_sr(value); return; case M68K_REG_SP: REG_SP = MASK_OUT_ABOVE_32(value); return; case M68K_REG_USP: if(FLAG_S) REG_USP = MASK_OUT_ABOVE_32(value); else REG_SP = MASK_OUT_ABOVE_32(value); return; case M68K_REG_ISP: if(FLAG_S && !FLAG_M) REG_SP = MASK_OUT_ABOVE_32(value); else REG_ISP = MASK_OUT_ABOVE_32(value); return; case M68K_REG_MSP: if(FLAG_S && FLAG_M) REG_SP = MASK_OUT_ABOVE_32(value); else REG_MSP = MASK_OUT_ABOVE_32(value); return; case M68K_REG_VBR: REG_VBR = MASK_OUT_ABOVE_32(value); return; case M68K_REG_SFC: REG_SFC = value & 7; return; case M68K_REG_DFC: REG_DFC = value & 7; return; case M68K_REG_CACR: REG_CACR = MASK_OUT_ABOVE_32(value); return; case M68K_REG_CAAR: REG_CAAR = MASK_OUT_ABOVE_32(value); return; case M68K_REG_PPC: REG_PPC = MASK_OUT_ABOVE_32(value); return; case M68K_REG_IR: REG_IR = MASK_OUT_ABOVE_16(value); return; case M68K_REG_PREF_ADDR: CPU_PREF_ADDR = MASK_OUT_ABOVE_32(value); return; case M68K_REG_CPU_TYPE: m68k_set_cpu_type(value); return; default: return; } } /* Set the callbacks */ void m68k_set_int_ack_callback(int (*callback)(int int_level)) { CALLBACK_INT_ACK = callback ? callback : default_int_ack_callback; } void m68k_set_bkpt_ack_callback(void (*callback)(unsigned int data)) { CALLBACK_BKPT_ACK = callback ? callback : default_bkpt_ack_callback; } void m68k_set_reset_instr_callback(void (*callback)(void)) { CALLBACK_RESET_INSTR = callback ? callback : default_reset_instr_callback; } void m68k_set_cmpild_instr_callback(void (*callback)(unsigned int, int)) { CALLBACK_CMPILD_INSTR = callback ? callback : default_cmpild_instr_callback; } void m68k_set_rte_instr_callback(void (*callback)(void)) { CALLBACK_RTE_INSTR = callback ? callback : default_rte_instr_callback; } void m68k_set_tas_instr_callback(int (*callback)(void)) { CALLBACK_TAS_INSTR = callback ? callback : default_tas_instr_callback; } void m68k_set_pc_changed_callback(void (*callback)(unsigned int new_pc)) { CALLBACK_PC_CHANGED = callback ? callback : default_pc_changed_callback; } void m68k_set_fc_callback(void (*callback)(unsigned int new_fc)) { CALLBACK_SET_FC = callback ? callback : default_set_fc_callback; } void m68k_set_instr_hook_callback(void (*callback)(unsigned int pc)) { CALLBACK_INSTR_HOOK = callback ? callback : default_instr_hook_callback; } #include <stdio.h> /* Set the CPU type. */ void m68k_set_cpu_type(unsigned int cpu_type) { switch(cpu_type) { case M68K_CPU_TYPE_68000: CPU_TYPE = CPU_TYPE_000; CPU_ADDRESS_MASK = 0x00ffffff; CPU_SR_MASK = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ CYC_INSTRUCTION = m68ki_cycles[0]; CYC_EXCEPTION = m68ki_exception_cycle_table[0]; CYC_BCC_NOTAKE_B = -2 * 7; CYC_BCC_NOTAKE_W = 2 * 7; CYC_DBCC_F_NOEXP = -2 * 7; CYC_DBCC_F_EXP = 2 * 7; CYC_SCC_R_TRUE = 2 * 7; CYC_MOVEM_W = 4 * 7; CYC_MOVEM_L = 8 * 7; CYC_SHIFT = 2 * 7; CYC_RESET = 132 * 7; return; #if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 case M68K_CPU_TYPE_68008: CPU_TYPE = CPU_TYPE_008; CPU_ADDRESS_MASK = 0x003fffff; CPU_SR_MASK = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ CYC_INSTRUCTION = m68ki_cycles[0]; CYC_EXCEPTION = m68ki_exception_cycle_table[0]; CYC_BCC_NOTAKE_B = -2; CYC_BCC_NOTAKE_W = 2; CYC_DBCC_F_NOEXP = -2; CYC_DBCC_F_EXP = 2; CYC_SCC_R_TRUE = 2; CYC_MOVEM_W = 2; CYC_MOVEM_L = 3; CYC_SHIFT = 1; CYC_RESET = 132; return; case M68K_CPU_TYPE_68010: CPU_TYPE = CPU_TYPE_010; CPU_ADDRESS_MASK = 0x00ffffff; CPU_SR_MASK = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ CYC_INSTRUCTION = m68ki_cycles[1]; CYC_EXCEPTION = m68ki_exception_cycle_table[1]; CYC_BCC_NOTAKE_B = -4; CYC_BCC_NOTAKE_W = 0; CYC_DBCC_F_NOEXP = 0; CYC_DBCC_F_EXP = 6; CYC_SCC_R_TRUE = 0; CYC_MOVEM_W = 2; CYC_MOVEM_L = 3; CYC_SHIFT = 1; CYC_RESET = 130; return; case M68K_CPU_TYPE_68EC020: CPU_TYPE = CPU_TYPE_EC020; CPU_ADDRESS_MASK = 0x00ffffff; CPU_SR_MASK = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ CYC_INSTRUCTION = m68ki_cycles[2]; CYC_EXCEPTION = m68ki_exception_cycle_table[2]; CYC_BCC_NOTAKE_B = -2; CYC_BCC_NOTAKE_W = 0; CYC_DBCC_F_NOEXP = 0; CYC_DBCC_F_EXP = 4; CYC_SCC_R_TRUE = 0; CYC_MOVEM_W = 2; CYC_MOVEM_L = 2; CYC_SHIFT = 0; CYC_RESET = 518; return; case M68K_CPU_TYPE_68020: CPU_TYPE = CPU_TYPE_020; CPU_ADDRESS_MASK = 0xffffffff; CPU_SR_MASK = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ CYC_INSTRUCTION = m68ki_cycles[2]; CYC_EXCEPTION = m68ki_exception_cycle_table[2]; CYC_BCC_NOTAKE_B = -2; CYC_BCC_NOTAKE_W = 0; CYC_DBCC_F_NOEXP = 0; CYC_DBCC_F_EXP = 4; CYC_SCC_R_TRUE = 0; CYC_MOVEM_W = 2; CYC_MOVEM_L = 2; CYC_SHIFT = 0; CYC_RESET = 518; return; case M68K_CPU_TYPE_68040: // TODO: these values are not correct CPU_TYPE = CPU_TYPE_040; CPU_ADDRESS_MASK = 0xffffffff; CPU_SR_MASK = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ CYC_INSTRUCTION = m68ki_cycles[2]; CYC_EXCEPTION = m68ki_exception_cycle_table[2]; CYC_BCC_NOTAKE_B = -2; CYC_BCC_NOTAKE_W = 0; CYC_DBCC_F_NOEXP = 0; CYC_DBCC_F_EXP = 4; CYC_SCC_R_TRUE = 0; CYC_MOVEM_W = 2; CYC_MOVEM_L = 2; CYC_SHIFT = 0; CYC_RESET = 518; return; #endif } } #if 0 /* Execute a single instruction */ INLINE int m68k_execute(void) { /* Set our pool of clock cycles available */ SET_CYCLES(0); /* Set tracing accodring to T1. (T0 is done inside instruction) */ m68ki_trace_t1(); /* auto-disable (see m68kcpu.h) */ /* Set the address space for reads */ m68ki_use_data_space(); /* auto-disable (see m68kcpu.h) */ /* Call external hook to peek at CPU */ m68ki_instr_hook(REG_PC); /* auto-disable (see m68kcpu.h) */ /* Record previous program counter */ REG_PPC = REG_PC; /* Read an instruction and call its handler */ REG_IR = m68ki_read_imm_16(); m68ki_instruction_jump_table[REG_IR](); USE_CYCLES(CYC_INSTRUCTION[REG_IR]); /* Trace m68k_exception, if necessary */ m68ki_exception_if_trace(); /* auto-disable (see m68kcpu.h) */ /* return how many clocks we used */ return GET_CYCLES(); } #endif /* ASG: rewrote so that the int_level is a mask of the IPL0/IPL1/IPL2 bits */ /* KS: Modified so that IPL* bits match with mask positions in the SR * and cleaned out remenants of the interrupt controller. */ void m68k_set_irq(unsigned int int_level) { uint old_level = CPU_INT_LEVEL; CPU_INT_LEVEL = int_level << 8; /* A transition from < 7 to 7 always interrupts (NMI) */ /* Note: Level 7 can also level trigger like a normal IRQ */ if(old_level != 0x0700 && CPU_INT_LEVEL == 0x0700) m68ki_exception_interrupt(7); /* Edge triggered level 7 (NMI) */ else m68ki_check_interrupts(); /* Level triggered (IRQ) */ } #ifdef LOGVDP extern uint16 v_counter; extern void error(char *format, ...); #endif extern uint8 m68k_irq_state; void m68k_run (unsigned int cycles) { /* Return point if we had an address error */ m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */ while (mcycles_68k < cycles) { /* check IRQ triggering */ if (m68k_irq_state & 0x10) { m68k_irq_state &= ~0x10; CPU_INT_LEVEL = (m68k_irq_state & 6) << 8; /* IRQ was triggered during previous instruction */ if (m68k_irq_state & 0x20) { /* one instruction latency */ REG_IR = m68ki_read_imm_16(); m68ki_instruction_jump_table[REG_IR](); USE_CYCLES(CYC_INSTRUCTION[REG_IR]); } #ifdef LOGVDP error("[%d(%d)][%d(%d)] IRQ Level = %d(0x%02x) (%x)\n", v_counter, mcycles_68k/3420, mcycles_68k, mcycles_68k%3420,CPU_INT_LEVEL>>8,FLAG_INT_MASK,m68k_get_reg (NULL, M68K_REG_PC)); #endif /* update internal interrupt level */ m68ki_check_interrupts(); if (mcycles_68k >= cycles) return; } /* Make sure we're not stopped */ if(CPU_STOPPED) { mcycles_68k = cycles; return; } /* execute a single instruction */ REG_IR = m68ki_read_imm_16(); m68ki_instruction_jump_table[REG_IR](); USE_CYCLES(CYC_INSTRUCTION[REG_IR]); } } #if 0 int m68k_cycles_run(void) { return m68ki_initial_cycles - GET_CYCLES(); } int m68k_cycles_remaining(void) { return GET_CYCLES(); } /* Change the timeslice */ void m68k_modify_timeslice(int cycles) { m68ki_initial_cycles += cycles; ADD_CYCLES(cycles); } void m68k_end_timeslice(void) { m68ki_initial_cycles = GET_CYCLES(); SET_CYCLES(0); } #endif void m68k_init(void) { static uint emulation_initialized = 0; /* The first call to this function initializes the opcode handler jump table */ if(!emulation_initialized) { m68ki_build_opcode_table(); emulation_initialized = 1; } m68k_set_int_ack_callback(NULL); m68k_set_bkpt_ack_callback(NULL); m68k_set_reset_instr_callback(NULL); m68k_set_cmpild_instr_callback(NULL); m68k_set_rte_instr_callback(NULL); m68k_set_tas_instr_callback(NULL); m68k_set_pc_changed_callback(NULL); m68k_set_fc_callback(NULL); m68k_set_instr_hook_callback(NULL); } /* Pulse the RESET line on the CPU */ void m68k_pulse_reset(void) { /* Clear all stop levels and eat up all remaining cycles */ CPU_STOPPED = 0; #if 0 SET_CYCLES(0); #endif CPU_RUN_MODE = RUN_MODE_BERR_AERR_RESET; /* Turn off tracing */ FLAG_T1 = FLAG_T0 = 0; m68ki_clear_trace(); /* Interrupt mask to level 7 */ FLAG_INT_MASK = 0x0700; CPU_INT_LEVEL = 0; /* Reset VBR */ REG_VBR = 0; /* Go to supervisor mode */ m68ki_set_sm_flag(SFLAG_SET | MFLAG_CLEAR); /* Invalidate the prefetch queue */ #if M68K_EMULATE_PREFETCH /* Set to arbitrary number since our first fetch is from 0 */ CPU_PREF_ADDR = 0x1000; #endif /* M68K_EMULATE_PREFETCH */ /* Read the initial stack pointer and program counter */ m68ki_jump(0); REG_SP = m68ki_read_imm_32(); REG_PC = m68ki_read_imm_32(); m68ki_jump(REG_PC); CPU_RUN_MODE = RUN_MODE_NORMAL; USE_CYCLES(CYC_EXCEPTION[EXCEPTION_RESET]); } /* Pulse the HALT line on the CPU */ void m68k_pulse_halt(void) { CPU_STOPPED |= STOP_LEVEL_HALT; } /* Get and set the current CPU context */ /* This is to allow for multiple CPUs */ unsigned int m68k_context_size() { return sizeof(m68ki_cpu_core); } unsigned int m68k_get_context(void* dst) { if(dst) *(m68ki_cpu_core*)dst = m68ki_cpu; return sizeof(m68ki_cpu_core); } void m68k_set_context(void* src) { if(src) m68ki_cpu = *(m68ki_cpu_core*)src; } /* ======================================================================== */ /* ============================== MAME STUFF ============================== */ /* ======================================================================== */ #if M68K_COMPILE_FOR_MAME == OPT_ON static struct { uint16 sr; uint8 stopped; uint8 halted; } m68k_substate; static void m68k_prepare_substate(void) { m68k_substate.sr = m68ki_get_sr(); m68k_substate.stopped = (CPU_STOPPED & STOP_LEVEL_STOP) != 0; m68k_substate.halted = (CPU_STOPPED & STOP_LEVEL_HALT) != 0; } static void m68k_post_load(void) { m68ki_set_sr_noint_nosp(m68k_substate.sr); CPU_STOPPED = m68k_substate.stopped ? STOP_LEVEL_STOP : 0 | m68k_substate.halted ? STOP_LEVEL_HALT : 0; m68ki_jump(REG_PC); } void m68k_state_register(const char *type, int index) { /* Note, D covers A because the dar array is common, REG_A=REG_D+8 */ state_save_register_item_array(type, index, REG_D); state_save_register_item(type, index, REG_PPC); state_save_register_item(type, index, REG_PC); state_save_register_item(type, index, REG_USP); state_save_register_item(type, index, REG_ISP); state_save_register_item(type, index, REG_MSP); state_save_register_item(type, index, REG_VBR); state_save_register_item(type, index, REG_SFC); state_save_register_item(type, index, REG_DFC); state_save_register_item(type, index, REG_CACR); state_save_register_item(type, index, REG_CAAR); state_save_register_item(type, index, m68k_substate.sr); state_save_register_item(type, index, CPU_INT_LEVEL); state_save_register_item(type, index, m68k_substate.stopped); state_save_register_item(type, index, m68k_substate.halted); state_save_register_item(type, index, CPU_PREF_ADDR); state_save_register_item(type, index, CPU_PREF_DATA); state_save_register_func_presave(m68k_prepare_substate); state_save_register_func_postload(m68k_post_load); } #endif /* M68K_COMPILE_FOR_MAME */ /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */
zyking1987-genplus-droid
genplusgx/m68k/m68kcpu.c
C
gpl2
46,759
#ifndef M68KOPS__HEADER #define M68KOPS__HEADER /* ======================================================================== */ /* ============================ OPCODE HANDLERS =========================== */ /* ======================================================================== */ #if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 #define NUM_CPU_TYPES 4 #else #define NUM_CPU_TYPES 1 #endif /* Build the opcode handler table */ void m68ki_build_opcode_table(void); extern void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */ extern unsigned char m68ki_cycles[][0x10000]; /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */ #endif /* M68KOPS__HEADER */
zyking1987-genplus-droid
genplusgx/m68k/m68kops.h
C
gpl2
943
char GG_ROM[256]; // "/dev_usb000/genplus/cart/ggenie.bin" char AR_ROM[256]; // "/dev_usb000/genplus/cart/areplay.bin" char SK_ROM[256]; // "/dev_usb000/genplus/cart/sk.bin" char SK_UPMEM[256]; // "/dev_usb000/genplus/cart/sk2chip.bin"
zyking1987-genplus-droid
genplusgx/config.c
C
gpl2
258
/**************************************************************************** * config.c * * Genesis Plus GX configuration file support * * Eke-Eke (2008) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ #ifndef ___CONFIG_H_ #define ___CONFIG_H_ #define CONFIG_VERSION "GENPLUS-GX 1.4.1" #define MAX_INPUTS 8 #define MAXPATHLEN 256 #define RAND_MAX 32767 #define strnicmp strncasecmp /* Genesis controller keys */ #define MAX_KEYS 8 // We can't include full arrays. We'll have to define this in a .c file somewhere.:) extern char GG_ROM[256]; // "/dev_usb000/genplus/cart/ggenie.bin" extern char AR_ROM[256]; // "/dev_usb000/genplus/cart/areplay.bin" extern char SK_ROM[256]; // "/dev_usb000/genplus/cart/sk.bin" extern char SK_UPMEM[256]; // "/dev_usb000/genplus/cart/sk2chip.bin" /* Key configuration structure */ typedef struct { uint8 device; uint8 port; uint8 padtype; } t_input_config; /**************************************************************************** * Config Option * ****************************************************************************/ typedef struct { char version[16]; uint8 hq_fm; uint8 psgBoostNoise; int32 psg_preamp; int32 fm_preamp; uint8 filter; int16 lp_range; int16 low_freq; int16 high_freq; float lg; float mg; float hg; float rolloff; uint8 dac_bits; uint8 region_detect; uint8 force_dtack; uint8 addr_error; uint8 tmss; uint8 bios_enabled; uint8 lock_on; uint8 hot_swap; uint8 romtype; int16 xshift; int16 yshift; int16 xscale; int16 yscale; uint8 tv_mode; uint8 aspect; uint8 overscan; uint8 render; uint8 ntsc; uint8 bilinear; #ifdef HW_RVL uint8 trap; float gamma; #endif uint8 gun_cursor[2]; uint8 invert_mouse; uint16 pad_keymap[4][MAX_KEYS]; uint32 wpad_keymap[4*3][MAX_KEYS]; t_input_config input[MAX_INPUTS]; uint8 s_default; uint8 s_device; int8 sram_auto; int8 state_auto; int8 bg_color; int16 screen_w; uint8 ask_confirm; float bgm_volume; float sfx_volume; } t_config; /* Global data */ t_config config; extern void config_save(void); extern void config_default(void); extern int ps3_update_input(void); #define osd_input_Update ps3_update_input #endif /* _CONFIG_H_ */
zyking1987-genplus-droid
genplusgx/config.h
C
gpl2
3,164
/*************************************************************************************** * Genesis Plus * 68k bus controller * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ****************************************************************************************/ #ifndef _MEM68K_H_ #define _MEM68K_H_ /* unused areas */ extern unsigned int m68k_read_bus_8(unsigned int address); extern unsigned int m68k_read_bus_16(unsigned int address); extern void m68k_unused_8_w(unsigned int address, unsigned int data); extern void m68k_unused_16_w(unsigned int address, unsigned int data); /* illegal areas */ extern unsigned int m68k_lockup_r_8(unsigned int address); extern unsigned int m68k_lockup_r_16(unsigned int address); extern void m68k_lockup_w_8(unsigned int address, unsigned int data); extern void m68k_lockup_w_16(unsigned int address, unsigned int data); /* eeprom */ extern unsigned int eeprom_read_byte(unsigned int address); extern unsigned int eeprom_read_word(unsigned int address); extern void eeprom_write_byte(unsigned int address, unsigned int data); extern void eeprom_write_word(unsigned int address, unsigned int data); /* Z80 bus */ extern unsigned int z80_read_byte(unsigned int address); extern unsigned int z80_read_word(unsigned int address); extern void z80_write_byte(unsigned int address, unsigned int data); extern void z80_write_word(unsigned int address, unsigned int data); /* I/O & Control registers */ extern unsigned int ctrl_io_read_byte(unsigned int address); extern unsigned int ctrl_io_read_word(unsigned int address); extern void ctrl_io_write_byte(unsigned int address, unsigned int data); extern void ctrl_io_write_word(unsigned int address, unsigned int data); /* VDP */ extern unsigned int vdp_read_byte(unsigned int address); extern unsigned int vdp_read_word(unsigned int address); extern void vdp_write_byte(unsigned int address, unsigned int data); extern void vdp_write_word(unsigned int address, unsigned int data); /* PICO */ extern unsigned int pico_read_byte(unsigned int address); extern unsigned int pico_read_word(unsigned int address); #endif /* _MEM68K_H_ */
zyking1987-genplus-droid
genplusgx/mem68k.h
C
gpl2
3,044
/*************************************************************************************** * Genesis Plus * Z80 bank access to 68k bus * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ****************************************************************************************/ #include "shared.h" /* Handlers for access to unused addresses and those which make the machine lock up. */ unsigned int zbank_unused_r(unsigned int address) { #ifdef LOGERROR error("Z80 bank unused read %06X (%x)\n", address, Z80.pc.d); #endif return (address & 1) ? 0x00 : 0xFF; } void zbank_unused_w(unsigned int address, unsigned int data) { #ifdef LOGERROR error("Z80 bank unused write %06X = %02X\n", address, data); #endif } unsigned int zbank_lockup_r(unsigned int address) { #ifdef LOGERROR error("Z80 bank lockup read %06X (%x)\n", address, Z80.pc.d); #endif if (!config.force_dtack) { mcycles_z80 = 0xFFFFFFFF; zstate = 0; } return 0xFF; } void zbank_lockup_w(unsigned int address, unsigned int data) { #ifdef LOGERROR error("Z80 bank lockup write %06X = %02X (%x)\n", address, data, Z80.pc.d); #endif if (!config.force_dtack) { mcycles_z80 = 0xFFFFFFFF; zstate = 0; } } /* I/O & Control registers */ unsigned int zbank_read_ctrl_io(unsigned int address) { switch ((address >> 8) & 0xFF) { case 0x00: /* I/O chip */ { if (!(address & 0xE0)) { return (io_68k_read((address >> 1) & 0x0F)); } return zbank_unused_r(address); } case 0x11: /* BUSACK */ { if (address & 1) { return zbank_unused_r(address); } return 0xFF; } case 0x30: /* TIME */ { if (cart.hw.time_r) { unsigned int data = cart.hw.time_r(address); if (address & 1) { return (data & 0xFF); } return (data >> 8); } return zbank_unused_r(address); } case 0x41: /* OS ROM */ { if (address & 1) { return (gen_bankswitch_r() | 0xFE); } return zbank_unused_r(address); } case 0x10: /* MEMORY MODE */ case 0x12: /* RESET */ case 0x20: /* MEGA-CD */ case 0x40: /* TMSS */ case 0x44: /* RADICA */ case 0x50: /* SVP REGISTERS */ { return zbank_unused_r(address); } default: /* Invalid address */ { return zbank_lockup_r(address); } } } void zbank_write_ctrl_io(unsigned int address, unsigned int data) { switch ((address >> 8) & 0xFF) { case 0x00: /* I/O chip */ { /* get /LWR only */ if ((address & 0xE1) == 0x01) { io_68k_write((address >> 1) & 0x0F, data); return; } zbank_unused_w(address, data); return; } case 0x11: /* BUSREQ */ { if (!(address & 1)) { gen_zbusreq_w(data & 1, mcycles_z80); return; } zbank_unused_w(address, data); return; } case 0x12: /* RESET */ { if (!(address & 1)) { gen_zreset_w(data & 1, mcycles_z80); return; } zbank_unused_w(address, data); return; } case 0x30: /* TIME */ { cart.hw.time_w(address, data); return; } case 0x41: /* OS ROM */ { if (address & 1) { gen_bankswitch_w(data & 1); return; } zbank_unused_w(address, data); return; } case 0x10: /* MEMORY MODE */ case 0x20: /* MEGA-CD */ case 0x40: /* TMSS */ case 0x44: /* RADICA */ case 0x50: /* SVP REGISTERS */ { zbank_unused_w(address, data); return; } default: /* Invalid address */ { zbank_lockup_w(address, data); return; } } } /* VDP */ unsigned int zbank_read_vdp(unsigned int address) { switch (address & 0xFD) { case 0x00: /* DATA */ { return (vdp_68k_data_r() >> 8); } case 0x01: /* DATA */ { return (vdp_68k_data_r() & 0xFF); } case 0x04: /* CTRL */ { return (((vdp_ctrl_r(mcycles_z80) >> 8) & 3) | 0xFC); } case 0x05: /* CTRL */ { return (vdp_ctrl_r(mcycles_z80) & 0xFF); } case 0x08: /* HVC */ case 0x0C: { return (vdp_hvc_r(mcycles_z80) >> 8); } case 0x09: /* HVC */ case 0x0D: { return (vdp_hvc_r(mcycles_z80) & 0xFF); } case 0x18: /* Unused */ case 0x19: case 0x1C: case 0x1D: { return zbank_unused_r(address); } default: /* Invalid address */ { return zbank_lockup_r(address); } } } void zbank_write_vdp(unsigned int address, unsigned int data) { switch (address & 0xFC) { case 0x00: /* Data port */ { vdp_68k_data_w(data << 8 | data); return; } case 0x04: /* Control port */ { vdp_68k_ctrl_w(data << 8 | data); return; } case 0x10: /* PSG */ case 0x14: { if (address & 1) { psg_write(mcycles_z80, data); return; } zbank_unused_w(address, data); return; } case 0x18: /* Unused */ { zbank_unused_w(address, data); return; } case 0x1C: /* TEST register */ { vdp_test_w(data << 8 | data); return; } default: /* Invalid address */ { zbank_lockup_w(address, data); return; } } }
zyking1987-genplus-droid
genplusgx/membnk.c
C
gpl2
6,602
/*************************************************************************************** * Genesis Plus * Video Display Processor (Mode 4 & Mode 5 rendering) * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ****************************************************************************************/ #ifndef _RENDER_H_ #define _RENDER_H_ /* Global variables */ extern uint8 object_count; /* Function prototypes */ extern void render_init(void); extern void render_reset(void); extern void render_line(int line); extern void blank_line(int line, int offset, int width); extern void remap_line(int line); extern void window_clip(unsigned int data, unsigned int sw); extern void render_bg_m4(int line, int width); extern void render_bg_m5(int line, int width); extern void render_bg_m5_vs(int line, int width); extern void render_bg_m5_im2(int line, int width); extern void render_bg_m5_im2_vs(int line, int width); extern void render_obj_m4(int max_width); extern void render_obj_m5(int max_width); extern void render_obj_m5_ste(int max_width); extern void render_obj_m5_im2(int max_width); extern void render_obj_m5_im2_ste(int max_width); extern void parse_satb_m4(int line); extern void parse_satb_m5(int line); extern void update_bg_pattern_cache_m4(int index); extern void update_bg_pattern_cache_m5(int index); #ifdef NGC extern void color_update(int index, unsigned int data); #endif /* Function pointers */ extern void (*render_bg)(int line, int width); extern void (*render_obj)(int max_width); extern void (*parse_satb)(int line); extern void (*update_bg_pattern_cache)(int index); #ifndef NGC extern void (*color_update)(int index, unsigned int data); #endif #endif /* _RENDER_H_ */
zyking1987-genplus-droid
genplusgx/vdp_render.h
C
gpl2
2,608
#ifndef _SHARED_H_ #define _SHARED_H_ #include <stdio.h> #include <math.h> #include <zlib.h> #include <string.h> #include "types.h" #include "macros.h" #include "config.h" //PS3 #include "m68k/m68k.h" #include "z80/z80.h" #include "system.h" #include "genesis.h" #include "vdp_ctrl.h" #include "vdp_render.h" #include "mem68k.h" #include "memz80.h" #include "membnk.h" #include "io_ctrl.h" #include "input_hw/input.h" #include "input_hw/gamepad.h" #include "state.h" #include "sound/sound.h" #include "sound/sn76489.h" #include "sound/ym2612.h" #include "loadrom.h" #include "cart_hw/sms_cart.h" #include "cart_hw/md_cart.h" #include "cart_hw/eeprom.h" #include "cart_hw/sram.h" #include "cart_hw/ggenie.h" #include "cart_hw/areplay.h" #include "cart_hw/svp/svp.h" #include "unzip.h" //#include "osd.h" #endif /* _SHARED_H_ */
zyking1987-genplus-droid
genplusgx/shared.h
C
gpl2
869
/*************************************************************************************** * Genesis Plus * Internal hardware & Bus controllers * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ****************************************************************************************/ #ifndef _GENESIS_H_ #define _GENESIS_H_ /* Global variables */ extern uint8 tmss[4]; extern uint8 bios_rom[0x800]; extern uint8 work_ram[0x10000]; extern uint8 zram[0x2000]; extern uint32 zbank; extern uint8 zstate; extern uint8 pico_current; extern uint8 pico_page[7]; /* Function prototypes */ extern void gen_init(void); extern void gen_reset(int hard_reset); extern void gen_shutdown(void); extern void gen_tmss_w(unsigned int offset, unsigned int data); extern void gen_bankswitch_w(unsigned int data); extern unsigned int gen_bankswitch_r(void); extern void gen_zbusreq_w(unsigned int state, unsigned int cycles); extern void gen_zreset_w(unsigned int state, unsigned int cycles); extern void gen_zbank_w(unsigned int state); extern int z80_irq_callback(int param); #endif /* _GEN_H_ */
zyking1987-genplus-droid
genplusgx/genesis.h
C
gpl2
1,977
# fceuDroid Makefile # - for eclipse to auto build all: ndk-build -j8 #V=1 #APP_OPTIM=debug NDK_DEBUG=1 clean: ndk-build clean headers: javah -classpath bin ca.halsafar.genesisdroid.Emulator mv ca_halsafar_genesisdroid_Emulator.h ./jni/EmulatorBridge.h install: adb install GENPlusDroidRelease.apk uninstall: adb uninstall ca.halsafar.genesisdroid zipalign: rm -f GENPlusDroidRelease.apk zipalign -v 4 GENPlusDroid-unaligned.apk GENPlusDroidRelease.apk test_shader: cgc -ogles -profile glslf $(FILE) push_shader: adb push $(FILE) /sdcard/NESDroid/shaders/
zyking1987-genplus-droid
Makefile
Makefile
gpl2
584
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import ca.halsafar.genesisdroid.PreferenceFacade; import android.app.Activity; import android.content.Context; import android.util.Log; // Mimic the C++ side for compatibility public enum EmulatorButtons { BUTTON_INDEX_A, BUTTON_INDEX_B, BUTTON_INDEX_C, BUTTON_INDEX_X, BUTTON_INDEX_Y, BUTTON_INDEX_Z, BUTTON_INDEX_START, BUTTON_INDEX_REWIND, BUTTON_INDEX_FORWARD, BUTTON_INDEX_LEFT, BUTTON_INDEX_UP, BUTTON_INDEX_RIGHT, BUTTON_INDEX_DOWN, BUTTON_INDEX_COUNT; private static String LOG_TAG = "EmulatorButtons"; public static void resetInput(final Activity activity, final Context context) { float screenWidth = PreferenceFacade.getRealScreenWidth(activity, context); float screenHeight = PreferenceFacade.getRealScreenHeight(activity, context); Log.d(LOG_TAG, "resetInput(" + screenWidth + ", " + screenHeight + ")"); float maxSize = (screenWidth > screenHeight ? screenWidth : screenHeight); float dpadWidth = maxSize * 0.20f; // tablet, reduce dpad defaults if (android.os.Build.VERSION.SDK_INT >= 11) { dpadWidth = maxSize * 0.10f; } float dpadHeight = dpadWidth; float dPadX = 0 + maxSize * 0.01f; float dPadY = screenHeight - dpadHeight - (maxSize * 0.01f); float buttonsWidth = maxSize * 0.085f; float buttonsHeight = maxSize * 0.085f; float buttonSep = maxSize * 0.010f; // tablet, reduce button defaults if (android.os.Build.VERSION.SDK_INT >= 11) { buttonsWidth = maxSize * 0.045f; buttonsHeight = maxSize * 0.045f; buttonSep = maxSize * 0.015f; } float aButtonX = screenWidth - (buttonsWidth * 3) - buttonSep * 3; float aButtonY = screenHeight - buttonsHeight - (buttonsHeight / 4); float bButtonX = aButtonX + buttonsWidth + buttonSep; float bButtonY = aButtonY - (buttonsHeight / 3); float cButtonX = bButtonX + buttonsWidth + buttonSep; float cButtonY = bButtonY - (buttonsHeight / 3); float xButtonX = aButtonX; float xButtonY = aButtonY - buttonsHeight - buttonSep; float yButtonX = bButtonX; float yButtonY = bButtonY - buttonsHeight - buttonSep; float zButtonX = cButtonX; float zButtonY = cButtonY - buttonsHeight - buttonSep; float startButtonWidth = maxSize * 0.075f; float startButtonHeight = maxSize * 0.04f; float startButtonX = (screenWidth / 2) - (startButtonWidth / 2); float startButtonY = screenHeight - startButtonHeight - (maxSize * 0.01f); float ffButtonWidth = maxSize * 0.05f; float ffButtonHeight = maxSize * 0.025f; float ffButtonX = screenWidth - (ffButtonWidth*2 + (maxSize * 0.015f)); float ffButtonY = 0 + ffButtonHeight + (maxSize * 0.015f); float rrButtonWidth = maxSize * 0.05f; float rrButtonHeight = maxSize * 0.025f; float rrButtonX = 0 + rrButtonWidth + (maxSize * 0.015f); float rrButtonY = 0 + rrButtonHeight + (maxSize * 0.015f); // default textures String aTex = "Textures/ButtonA.png"; String bTex = "Textures/ButtonB.png"; String cTex = "Textures/ButtonC.png"; String xTex = "Textures/ButtonX.png"; String yTex = "Textures/ButtonY.png"; String zTex = "Textures/ButtonZ.png"; String startTex = "Textures/StartButton.png"; String rewindTex = "Textures/Rewind.png"; String forwardTex = "Textures/FastForward.png"; String dPadTex = "Textures/DirectionalPad.png"; // default button codes - using Xperia Play int aCode = 23; // X int bCode = 99; // Square int cCode = 4; // CIRCLE int xCode = 100; // Triangle int yCode = 102; // L! int zCode = 103; // R1 int startCode = 108; // Startt int rewindCode = 0; // L1 int forwardCode = 0; // R1 int leftCode = 21; int upCode = 19; int rightCode = 22; int downCode = 20; InputPreferences.clearButtons(context); InputPreferences.setButton(context, cButtonX, cButtonY, buttonsWidth, buttonsHeight, cCode, cTex, EmulatorButtons.BUTTON_INDEX_C.ordinal()); InputPreferences.setButton(context, bButtonX, bButtonY, buttonsWidth, buttonsHeight, bCode, bTex, EmulatorButtons.BUTTON_INDEX_B.ordinal()); InputPreferences.setButton(context, aButtonX, aButtonY, buttonsWidth, buttonsHeight, aCode, aTex, EmulatorButtons.BUTTON_INDEX_A.ordinal()); InputPreferences.setButton(context, xButtonX, xButtonY, buttonsWidth, buttonsHeight, xCode, xTex, EmulatorButtons.BUTTON_INDEX_X.ordinal()); InputPreferences.setButton(context, yButtonX, yButtonY, buttonsWidth, buttonsHeight, yCode, yTex, EmulatorButtons.BUTTON_INDEX_Y.ordinal()); InputPreferences.setButton(context, zButtonX, zButtonY, buttonsWidth, buttonsHeight, zCode, zTex, EmulatorButtons.BUTTON_INDEX_Z.ordinal()); InputPreferences.setButton(context, startButtonX, startButtonY, startButtonWidth, startButtonHeight, startCode, startTex, EmulatorButtons.BUTTON_INDEX_START.ordinal()); InputPreferences.setButton(context, ffButtonX, ffButtonY, ffButtonWidth, ffButtonHeight, forwardCode, forwardTex, EmulatorButtons.BUTTON_INDEX_FORWARD.ordinal()); InputPreferences.setButton(context, rrButtonX, rrButtonY, rrButtonWidth, rrButtonHeight, rewindCode, rewindTex, EmulatorButtons.BUTTON_INDEX_REWIND.ordinal()); // set the pseudo buttons for movements InputPreferences.setButton(context, 0, 0, 0, 0, leftCode, null, EmulatorButtons.BUTTON_INDEX_LEFT.ordinal()); InputPreferences.setButton(context, 0, 0, 0, 0, upCode, null, EmulatorButtons.BUTTON_INDEX_UP.ordinal()); InputPreferences.setButton(context, 0, 0, 0, 0, rightCode, null, EmulatorButtons.BUTTON_INDEX_RIGHT.ordinal()); InputPreferences.setButton(context, 0, 0, 0, 0, downCode, null, EmulatorButtons.BUTTON_INDEX_DOWN.ordinal()); InputPreferences.setAnalog(context, dPadX, dPadY, dpadWidth, dpadHeight, leftCode, upCode, rightCode, downCode, dPadTex, 0); } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/EmulatorButtons.java
Java
gpl2
7,691
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import android.app.ListActivity; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.graphics.Color; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; class KeyBinding { String name; int key; boolean adjusting; public String toString() { return "Key: " + name + " | Code: " + key; } } class KeyBindingAdapter extends ArrayAdapter<KeyBinding> { // used to keep selected position in ListView private int selectedPos = -1; // init value for not-selected public KeyBindingAdapter(Context context, int textViewResourceId, KeyBinding[] objects) { super(context, textViewResourceId, objects); } public void setSelectedPosition(int pos) { selectedPos = pos; // inform the view of this change notifyDataSetChanged(); } public int getSelectedPosition(){ return selectedPos; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; // only inflate the view if it's null if (v == null) { LayoutInflater vi = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.custom_key_view, null); } // get text view TextView label = (TextView)v.findViewById(R.id.txtExample); // change the row color based on selected state String extra = ""; if(selectedPos == position) { label.setBackgroundColor(R.color.orange); v.setBackgroundColor(Color.RED); extra = " (Press any button to set new key) "; } else { label.setBackgroundColor(R.color.black); v.setBackgroundColor(Color.BLACK); } label.setText(this.getItem(position).toString() + extra); return(v); } } public class KeyboardConfigActivity extends ListActivity { private static final String LOG_TAG = "KeyboardConfigActivity"; private int _modPos = -1; private int _modKeyCode = -1; private ListView _view = null; private KeyBindingAdapter _adapter; public void onCreate(Bundle state) { super.onCreate(state); // reset input, first load bug... SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (prefs.getBoolean(PreferenceFacade.PREF_USE_DEFAULT_INPUT, true)) { EmulatorButtons.resetInput(this, getApplicationContext()); Editor edit = prefs.edit(); edit.putBoolean(PreferenceFacade.PREF_USE_DEFAULT_INPUT, false); edit.commit(); } reloadButtons(); _view = getListView(); _view.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Log.d(LOG_TAG, "onItemClick(" + parent + ", " + view + ", " + position + ", " + id + ")"); _modPos = position; int pos = parent.getPositionForView(view); _adapter.setSelectedPosition(pos); } }); InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showInputMethodPicker(); } @Override public void onDestroy() { Log.d(LOG_TAG, "onDestroy()"); super.onDestroy(); } public void reloadButtons() { int numButtons = EmulatorButtons.BUTTON_INDEX_COUNT.ordinal(); KeyBinding names[] = new KeyBinding[numButtons]; for (EmulatorButtons button : EmulatorButtons.values()) { if (button.ordinal() != numButtons) { int keyCode = InputPreferences.getButtonCode(getApplicationContext(), button.ordinal()); names[button.ordinal()] = new KeyBinding(); names[button.ordinal()].name = button.name(); names[button.ordinal()].key = keyCode; names[button.ordinal()].adjusting = false; } } /*Toast.makeText(getApplicationContext(), "States Array lentgh is : " + names.length, Toast.LENGTH_LONG).show();*/ _adapter = new KeyBindingAdapter(this, R.layout.custom_key_view, names); setListAdapter(_adapter); } @Override public boolean dispatchKeyEvent(KeyEvent event) { Log.d(LOG_TAG, "dispatchKeyEvent(" + event + ")"); if(event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN || event.getKeyCode() == KeyEvent.KEYCODE_MENU) { return super.dispatchKeyEvent(event); } if (_modPos >= 0) { Log.d(LOG_TAG, "NewButton: " + event.getKeyCode()); _modKeyCode = event.getKeyCode(); InputPreferences.setButton(getApplicationContext(), _modKeyCode, _modPos); reloadButtons(); _modPos = -1; _modKeyCode = -1; _adapter.setSelectedPosition(-1); //_adjustingView.setBackgroundColor(color.black); return true; } return super.dispatchKeyEvent(event); } /*@Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.d(LOG_TAG, "onKeyDown(" + event + ")"); if(keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_MENU) { return false; } if (_modPos >= 0) { Log.d(LOG_TAG, "NewButton: " + keyCode); _modKeyCode = keyCode; InputPreferences.setButton(getApplicationContext(), _modKeyCode, _modPos); reloadButtons(); _modPos = -1; _modKeyCode = -1; _adapter.setSelectedPosition(-1); //_adjustingView.setBackgroundColor(color.black); return true; } return super.onKeyDown(keyCode, event); }*/ @Override public boolean onCreateOptionsMenu(Menu myMenu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.keyboard_config_menu, myMenu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { /*case R.id.menuCustomKeysShowKeyboard: InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputMgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); return true;*/ default: return super.onOptionsItemSelected(item); } } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/KeyboardConfigActivity.java
Java
gpl2
8,466
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.preference.PreferenceManager; import android.util.Log; /** * Wrapped used to help manage the android shared preferences * * @author halsafar */ public class InputPreferences { private static final String LOG_TAG = "InputPreferences"; private static final String PREF_NUM_ANALOGS = "input_numAnalogs"; private static final String PREF_NUM_BUTTONS = "input_numButtons"; private static final String PREF_BUTTON_PREFIX = "input_button"; private static final String PREF_ANALOG_PREFIX = "input_analog"; // // GENERIC // private static String buildKey(String prefix, int index) { return prefix + "_" + index + "_"; } private static int getIntPref(final Context context, String prefix, String value, int index) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getInt(buildKey(prefix, index) + value, 0); } private static float getFloatPref(final Context context, String prefix, String value, int index) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getFloat(buildKey(prefix, index) + value, 0.0f); } private static String getStringPref(final Context context, String prefix, String value, int index) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getString(buildKey(prefix, index) + value, null); } private static int getNumInput(final Context context, final String key) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int n = prefs.getInt(key, 0); return n; } // // BUTTONS // public static int getNumButtons(final Context context) { //return getNumInput(context, PREF_NUM_BUTTONS); return EmulatorButtons.BUTTON_INDEX_COUNT.ordinal(); } public static void setButton(Context context, String textureFile, int buttonIndex) { float x = getButtonX(context, buttonIndex); float y = getButtonY(context, buttonIndex); float w = getButtonWidth(context, buttonIndex); float h = getButtonHeight(context, buttonIndex); int keycode = getButtonCode(context, buttonIndex); setButton(context, x, y, w, h, keycode, textureFile, buttonIndex); } public static void setButton(Context context, int keycode, int buttonIndex) { float x = getButtonX(context, buttonIndex); float y = getButtonY(context, buttonIndex); float w = getButtonWidth(context, buttonIndex); float h = getButtonHeight(context, buttonIndex); String textureFile = getButtonTexture(context, buttonIndex); setButton(context, x, y, w, h, keycode, textureFile, buttonIndex); } public static void setButton(Context context, float x, float y, float w, float h, int buttonIndex) { int keycode = getButtonCode(context, buttonIndex); String textureFile = getButtonTexture(context, buttonIndex); setButton(context, x, y, w, h, keycode, textureFile, buttonIndex); } public static void setButton(Context context, float x, float y, float w, float h, int keycode, String textureFile, int buttonIndex) { Log.d(LOG_TAG, "setButton(" + x + ", " + y + ", " + w + ", " + h + ", " + keycode + ", " + textureFile + ", " + buttonIndex); int numButtons = getNumButtons(context); String buttonKey = buildKey(PREF_BUTTON_PREFIX, buttonIndex); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = prefs.edit(); if (!prefs.contains(buttonKey)) { edit.putInt(PREF_NUM_BUTTONS, numButtons + 1); } edit.putBoolean(buttonKey, true); edit.putFloat(buttonKey + "x", x); edit.putFloat(buttonKey + "y", y); edit.putFloat(buttonKey + "w", w); edit.putFloat(buttonKey + "h", h); edit.putInt(buttonKey + "code", keycode); edit.putInt(buttonKey + "map", buttonIndex); edit.putString(buttonKey + "texture", textureFile); edit.commit(); } public static float getButtonX(final Context context, int buttonIndex) { return getFloatPref(context, PREF_BUTTON_PREFIX, "x", buttonIndex); } public static float getButtonY(final Context context, int buttonIndex) { return getFloatPref(context, PREF_BUTTON_PREFIX, "y", buttonIndex); } public static float getButtonWidth(final Context context, int buttonIndex) { return getFloatPref(context, PREF_BUTTON_PREFIX, "w", buttonIndex); } public static float getButtonHeight(final Context context, int buttonIndex) { return getFloatPref(context, PREF_BUTTON_PREFIX, "h", buttonIndex); } public static int getButtonCode(final Context context, int buttonIndex) { return getIntPref(context, PREF_BUTTON_PREFIX, "code", buttonIndex); } public static int getButtonMap(final Context context, int buttonIndex) { return getIntPref(context, PREF_BUTTON_PREFIX, "map", buttonIndex); } public static String getButtonTexture(final Context context, int index) { return getStringPref(context, PREF_BUTTON_PREFIX, "texture", index); } public static void clearButtons(final Context context) { int numButtons = getNumButtons(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = prefs.edit(); for (int i = 0; i < numButtons; i++) { String key = buildKey(PREF_BUTTON_PREFIX, i); edit.remove(key); edit.remove(key + "x"); edit.remove(key + "y"); edit.remove(key + "w"); edit.remove(key + "h"); edit.remove(key + "code"); edit.remove(key + "map"); edit.remove(key + "texture"); } edit.putInt(PREF_NUM_BUTTONS, 0); edit.commit(); } // // ANALOGS - DPADS // public static int getNumAnalogs(Context context) { return getNumInput(context, PREF_NUM_ANALOGS); } public static void setAnalog(Context context, String textureFile, int buttonIndex) { float x = getAnalogX(context, buttonIndex); float y = getAnalogY(context, buttonIndex); float w = getAnalogWidth(context, buttonIndex); float h = getAnalogHeight(context, buttonIndex); int leftcode = getAnalogLeftCode(context, buttonIndex); int upcode = getAnalogUpCode(context, buttonIndex); int rightcode = getAnalogRightCode(context, buttonIndex); int downcode = getAnalogDownCode(context, buttonIndex); setAnalog(context, x, y, w, h, leftcode, upcode, rightcode, downcode, textureFile, buttonIndex); } public static void setAnalog(Context context, float x, float y, float w, float h, int buttonIndex) { int leftcode = getAnalogLeftCode(context, buttonIndex); int upcode = getAnalogUpCode(context, buttonIndex); int rightcode = getAnalogRightCode(context, buttonIndex); int downcode = getAnalogDownCode(context, buttonIndex); String textureFile = getAnalogTexture(context, buttonIndex); setAnalog(context, x, y, w, h, leftcode, upcode, rightcode, downcode, textureFile, buttonIndex); } public static void setAnalog(Context context, float x, float y, float w, float h, int keycodeLeft, int keycodeUp, int keycodeRight, int keycodeDown, final String textureFile, int index) { Log.d(LOG_TAG, "setAnalog(" + x + ", " + y + ", " + w + ", " + h + ", " + keycodeLeft + ", " + keycodeUp + ", " + keycodeRight + ", " + keycodeDown + ", " + textureFile + ", " + index); int num = getNumAnalogs(context); String buttonKey = buildKey(PREF_ANALOG_PREFIX, index); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = prefs.edit(); if (!prefs.contains(buttonKey)) { edit.putInt(PREF_NUM_ANALOGS, num + 1); } edit.putBoolean(buttonKey, true); edit.putFloat(buttonKey + "x", x); edit.putFloat(buttonKey + "y", y); edit.putFloat(buttonKey + "w", w); edit.putFloat(buttonKey + "h", h); edit.putInt(buttonKey + "codeLeft", keycodeLeft); edit.putInt(buttonKey + "codeUp", keycodeUp); edit.putInt(buttonKey + "codeRight", keycodeRight); edit.putInt(buttonKey + "codeDown", keycodeDown); edit.putInt(buttonKey + "map", index); edit.putString(buttonKey + "texture", textureFile); edit.commit(); } public static float getAnalogX(final Context context, int buttonIndex) { return getFloatPref(context, PREF_ANALOG_PREFIX, "x", buttonIndex); } public static float getAnalogY(final Context context, int buttonIndex) { return getFloatPref(context, PREF_ANALOG_PREFIX, "y", buttonIndex); } public static float getAnalogWidth(final Context context, int buttonIndex) { return getFloatPref(context, PREF_ANALOG_PREFIX, "w", buttonIndex); } public static float getAnalogHeight(final Context context, int buttonIndex) { return getFloatPref(context, PREF_ANALOG_PREFIX, "h", buttonIndex); } public static int getAnalogLeftCode(final Context context, int buttonIndex) { return getIntPref(context, PREF_ANALOG_PREFIX, "codeLeft", buttonIndex); } public static int getAnalogUpCode(final Context context, int buttonIndex) { return getIntPref(context, PREF_ANALOG_PREFIX, "codeUp", buttonIndex); } public static int getAnalogRightCode(final Context context, int buttonIndex) { return getIntPref(context, PREF_ANALOG_PREFIX, "codeRight", buttonIndex); } public static int getAnalogDownCode(final Context context, int buttonIndex) { return getIntPref(context, PREF_ANALOG_PREFIX, "codeDown", buttonIndex); } public static int getAnalogMap(final Context context, int buttonIndex) { return getIntPref(context, PREF_ANALOG_PREFIX, "map", buttonIndex); } public static String getAnalogTexture(final Context context, int index) { return getStringPref(context, PREF_ANALOG_PREFIX, "texture", index); } public static void clearAnalogs(final Context context) { int num = getNumAnalogs(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = prefs.edit(); for (int i = 0; i < num; i++) { String key = buildKey(PREF_ANALOG_PREFIX, i); edit.remove(key); edit.remove(key + "x"); edit.remove(key + "y"); edit.remove(key + "w"); edit.remove(key + "h"); edit.remove(key + "code"); edit.remove(key + "map"); edit.remove(key + "texture"); } edit.putInt(PREF_NUM_ANALOGS, 0); edit.commit(); } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/InputPreferences.java
Java
gpl2
12,875
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; /** * MAJOR TODO - remove app specific stuff in PreferenceFacade */ /** * Emulator bridge to native side. * All Java to Native communication happens through this one class. * See jni/EmulatorBridge.cpp to see the implementation * @author halsafar * */ public class Emulator { // load our native library static { System.loadLibrary("gnupng"); System.loadLibrary("zip"); System.loadLibrary("emu"); } // lock instantiation private Emulator() { } public static native int init(final String apkAbsolutePath); public static native int setPaths(final String externalStoragePath, final String romPath, final String stateSavePath, final String sramPath, final String cheatPath); public static native int initGraphics(); public static native int initAudioBuffer(final int sizeInSamples); public static native int loadRom(final String fileName); public static native boolean isRomLoaded(); public static native void onTouchDown(final int finger, final float x, final float y, final float radius); public static native void onTouchUp(final int finger, final float x, final float y, final float radius); public static native void onTouchMove(final int finger, final float x, final float y, final float radius); public static native void onKeyDown(int keyCode); public static native void onKeyUp(int keyCode); public static native int mixAudioBuffer(short[] buf); public static native void setAudioSampleRate(final int rate); public static native void setAudioEnabled(final boolean b); public static native void setSensitivity(final float x, final float y); public static native void setButton(final int buttonIndex, final float x, final float y, final float width, final float height, int keycode, boolean visible); public static native void setAnalog(final float x, final float y, final float width, final float height, int leftcode, int upcode, int rightcode, int downcode, boolean visible); public static native void setShaderFile(final String shaderFile); public static native void setSmoothFiltering(boolean b); public static native void setViewport(final int width, final int height); public static native void saveState(final int i); public static native void loadState(final int i); public static native void selectState(final int i); public static native void setEnableRewind(final boolean enableRewind); public static native void resetGame(); public static native void unzipFile(final String zipFileName, final String extractFileName, final String outLocation); public static native void setAspectRatio(final float ratio); public static native void setFrameSkip(final int i); public static native void setGameGenie(final boolean b); public static native void destroy(); public static native void step(); public static native void draw(); }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/Emulator.java
Java
gpl2
3,178
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import android.app.Activity; import android.content.Context; import android.graphics.PixelFormat; import android.graphics.Rect; import android.opengl.GLSurfaceView; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.Window; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.opengles.GL10; import ca.halsafar.audio.AudioPlayer; import ca.halsafar.genesisdroid.Emulator; /** * EmulatorView, the OpenGL rendering context and thread. * Calls the emulation step in native code * Mixes audio samples to AudioTrack * Performs vsync * * @author halsafar * */ class EmulatorView extends GLSurfaceView { private static String LOG_TAG = "EmulatorView"; private static final boolean DEBUG = false; public static int TitleBarHeight = 0; public static int MenuBarHeight = 0; public static int TotalOuterHeight = 0; protected static boolean _hasFocus; private static Activity _activity; public EmulatorView(Activity activity, Context context) { super(context); _activity = activity; init(false, 0, 0); // setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS); setDebugFlags(0); setFocusableInTouchMode(true); requestFocus(); } public EmulatorView(Activity activity, Context context, boolean translucent, int depth, int stencil) { super(context); _activity = activity; init(translucent, depth, stencil); // setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS); setDebugFlags(0); setFocusableInTouchMode(true); requestFocus(); } private void init(boolean translucent, int depth, int stencil) { /* * By default, GLSurfaceView() creates a RGB_565 opaque surface. If we * want a translucent one, we should change the surface's format here, * using PixelFormat.TRANSLUCENT for GL Surfaces is interpreted as any * 32-bit surface with alpha by SurfaceFlinger. */ if (translucent) { this.getHolder().setFormat(PixelFormat.TRANSLUCENT); } /* * Setup the context factory for 2.0 rendering. See ContextFactory * class definition below */ setEGLContextFactory(new ContextFactory()); /* * We need to choose an EGLConfig that matches the format of our * surface exactly. This is going to be done in our custom config * chooser. See ConfigChooser class definition below. */ setEGLConfigChooser(translucent ? new ConfigChooser(8, 8, 8, 8, depth, stencil) : new ConfigChooser(5, 6, 5, 0, depth, stencil)); /* Set the renderer responsible for frame rendering */ setRenderer(new Renderer()); // setRenderMode(RENDERMODE_WHEN_DIRTY); setKeepScreenOn(true); setClickable(false); } private static class ContextFactory implements GLSurfaceView.EGLContextFactory { private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098; public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) { Log.w(LOG_TAG, "creating OpenGL ES 2.0 context"); checkEglError("Before eglCreateContext", egl); int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list); checkEglError("After eglCreateContext", egl); return context; } public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) { egl.eglDestroyContext(display, context); } } private static void checkEglError(String prompt, EGL10 egl) { int error; while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS) { Log.e(LOG_TAG, String.format("%s: EGL error: 0x%x", prompt, error)); } } private static class ConfigChooser implements GLSurfaceView.EGLConfigChooser { public ConfigChooser(int r, int g, int b, int a, int depth, int stencil) { mRedSize = r; mGreenSize = g; mBlueSize = b; mAlphaSize = a; mDepthSize = depth; mStencilSize = stencil; } /* * This EGL config specification is used to specify 2.0 rendering. We * use a minimum size of 4 bits for red/green/blue, but will perform * actual matching in chooseConfig() below. */ private static int EGL_OPENGL_ES2_BIT = 4; private static int[] s_configAttribs2 = { EGL10.EGL_RED_SIZE, 4, EGL10.EGL_GREEN_SIZE, 4, EGL10.EGL_BLUE_SIZE, 4, EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_NONE }; public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { /* * Get the number of minimally matching EGL configurations */ int[] num_config = new int[1]; egl.eglChooseConfig(display, s_configAttribs2, null, 0, num_config); int numConfigs = num_config[0]; if (numConfigs <= 0) { throw new IllegalArgumentException( "No configs match configSpec"); } /* * Allocate then read the array of minimally matching EGL configs */ EGLConfig[] configs = new EGLConfig[numConfigs]; egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config); if (DEBUG) { printConfigs(egl, display, configs); } /* * Now return the "best" one */ return chooseConfig(egl, display, configs); } public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) { for (EGLConfig config : configs) { int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0); int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0); // We need at least mDepthSize and mStencilSize bits if (d < mDepthSize || s < mStencilSize) continue; // We want an *exact* match for red/green/blue/alpha int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0); int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0); int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0); int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0); if (r == mRedSize && g == mGreenSize && b == mBlueSize && a == mAlphaSize) return config; } return null; } private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue) { if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) { return mValue[0]; } return defaultValue; } private void printConfigs(EGL10 egl, EGLDisplay display, EGLConfig[] configs) { int numConfigs = configs.length; Log.w(LOG_TAG, String.format("%d configurations", numConfigs)); for (int i = 0; i < numConfigs; i++) { Log.w(LOG_TAG, String.format("Configuration %d:\n", i)); printConfig(egl, display, configs[i]); } } private void printConfig(EGL10 egl, EGLDisplay display, EGLConfig config) { int[] attributes = { EGL10.EGL_BUFFER_SIZE, EGL10.EGL_ALPHA_SIZE, EGL10.EGL_BLUE_SIZE, EGL10.EGL_GREEN_SIZE, EGL10.EGL_RED_SIZE, EGL10.EGL_DEPTH_SIZE, EGL10.EGL_STENCIL_SIZE, EGL10.EGL_CONFIG_CAVEAT, EGL10.EGL_CONFIG_ID, EGL10.EGL_LEVEL, EGL10.EGL_MAX_PBUFFER_HEIGHT, EGL10.EGL_MAX_PBUFFER_PIXELS, EGL10.EGL_MAX_PBUFFER_WIDTH, EGL10.EGL_NATIVE_RENDERABLE, EGL10.EGL_NATIVE_VISUAL_ID, EGL10.EGL_NATIVE_VISUAL_TYPE, 0x3030, // EGL10.EGL_PRESERVED_RESOURCES, EGL10.EGL_SAMPLES, EGL10.EGL_SAMPLE_BUFFERS, EGL10.EGL_SURFACE_TYPE, EGL10.EGL_TRANSPARENT_TYPE, EGL10.EGL_TRANSPARENT_RED_VALUE, EGL10.EGL_TRANSPARENT_GREEN_VALUE, EGL10.EGL_TRANSPARENT_BLUE_VALUE, 0x3039, // EGL10.EGL_BIND_TO_TEXTURE_RGB, 0x303A, // EGL10.EGL_BIND_TO_TEXTURE_RGBA, 0x303B, // EGL10.EGL_MIN_SWAP_INTERVAL, 0x303C, // EGL10.EGL_MAX_SWAP_INTERVAL, EGL10.EGL_LUMINANCE_SIZE, EGL10.EGL_ALPHA_MASK_SIZE, EGL10.EGL_COLOR_BUFFER_TYPE, EGL10.EGL_RENDERABLE_TYPE, 0x3042 // EGL10.EGL_CONFORMANT }; String[] names = { "EGL_BUFFER_SIZE", "EGL_ALPHA_SIZE", "EGL_BLUE_SIZE", "EGL_GREEN_SIZE", "EGL_RED_SIZE", "EGL_DEPTH_SIZE", "EGL_STENCIL_SIZE", "EGL_CONFIG_CAVEAT", "EGL_CONFIG_ID", "EGL_LEVEL", "EGL_MAX_PBUFFER_HEIGHT", "EGL_MAX_PBUFFER_PIXELS", "EGL_MAX_PBUFFER_WIDTH", "EGL_NATIVE_RENDERABLE", "EGL_NATIVE_VISUAL_ID", "EGL_NATIVE_VISUAL_TYPE", "EGL_PRESERVED_RESOURCES", "EGL_SAMPLES", "EGL_SAMPLE_BUFFERS", "EGL_SURFACE_TYPE", "EGL_TRANSPARENT_TYPE", "EGL_TRANSPARENT_RED_VALUE", "EGL_TRANSPARENT_GREEN_VALUE", "EGL_TRANSPARENT_BLUE_VALUE", "EGL_BIND_TO_TEXTURE_RGB", "EGL_BIND_TO_TEXTURE_RGBA", "EGL_MIN_SWAP_INTERVAL", "EGL_MAX_SWAP_INTERVAL", "EGL_LUMINANCE_SIZE", "EGL_ALPHA_MASK_SIZE", "EGL_COLOR_BUFFER_TYPE", "EGL_RENDERABLE_TYPE", "EGL_CONFORMANT" }; int[] value = new int[1]; for (int i = 0; i < attributes.length; i++) { int attribute = attributes[i]; String name = names[i]; if (egl.eglGetConfigAttrib(display, config, attribute, value)) { Log.w(LOG_TAG, String.format(" %s: %d\n", name, value[0])); } else { // Log.w(TAG, String.format(" %s: failed\n", name)); while (egl.eglGetError() != EGL10.EGL_SUCCESS) ; } } } // Subclasses can adjust these values: protected int mRedSize; protected int mGreenSize; protected int mBlueSize; protected int mAlphaSize; protected int mDepthSize; protected int mStencilSize; private int[] mValue = new int[1]; } @Override public boolean dispatchTouchEvent(final MotionEvent event) { // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY); // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LOWEST); // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LESS_FAVORABLE); int actionMasked = event.getActionMasked(); if (actionMasked == MotionEvent.ACTION_POINTER_DOWN || actionMasked == MotionEvent.ACTION_DOWN) { int pointerIndex = event.getActionIndex(); Emulator.onTouchDown(event.getPointerId(pointerIndex), event.getX(pointerIndex), event.getY(pointerIndex) - EmulatorView.TotalOuterHeight, event.getSize(pointerIndex)); } else if (actionMasked == MotionEvent.ACTION_POINTER_UP || actionMasked == MotionEvent.ACTION_UP || actionMasked == MotionEvent.ACTION_CANCEL) { int pointerIndex = event.getActionIndex(); Emulator.onTouchUp(event.getPointerId(pointerIndex), event.getX(pointerIndex), event.getY(pointerIndex) - EmulatorView.TotalOuterHeight, event.getSize(pointerIndex)); } else if (actionMasked == MotionEvent.ACTION_MOVE) { final int count = event.getPointerCount(); for (int pointerIndex = 0; pointerIndex < count; pointerIndex++) { Emulator.onTouchMove(event.getPointerId(pointerIndex), (int) event.getX(pointerIndex), (int) event.getY(pointerIndex) - EmulatorView.TotalOuterHeight, event.getSize(pointerIndex)); } } return true; } /*public boolean dispatchKeyEvent(KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN || event.getKeyCode() == KeyEvent.KEYCODE_MENU) return super.dispatchKeyEvent(event); if (event.getAction() == KeyEvent.ACTION_DOWN) { Log.d(LOG_TAG, "onKeyDown(" + event.getKeyCode() + ", " + event + ")"); Emulator.onKeyDown(event.getKeyCode()); return true; } else if (event.getAction() == KeyEvent.ACTION_UP) { Log.d(LOG_TAG, "onKeyUp(" + event.getKeyCode() + ", " + event + ")"); Emulator.onKeyUp(event.getKeyCode()); return true; } return super.dispatchKeyEvent(event); }*/ @Override public boolean onKeyUp(int keyCode, KeyEvent event) { //Log.d(LOG_TAG, "onKeyUp(" + keyCode + ", " + event + ")"); if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_MENU) return super.onKeyUp(keyCode, event); Emulator.onKeyUp(event.getKeyCode()); return true; //return super.onKeyUp(keyCode, event); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { //Log.d(LOG_TAG, "onKeyDown(" + keyCode + ", " + event + ")"); if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_MENU) return super.onKeyDown(keyCode, event); Emulator.onKeyDown(event.getKeyCode()); return true; //return super.onKeyDown(keyCode, event); } @Override public void onWindowFocusChanged(boolean hasFocus) { // Log.d(LOG_TAG, "onWindowFocusChanged(" + hasFocus + ")"); _hasFocus = hasFocus; } private class Renderer implements GLSurfaceView.Renderer { short[] tempBuf = new short[PreferenceFacade.AUDIO_MIX_SAMPLES_MAX]; public void onDrawFrame(GL10 gl) { // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_AUDIO); // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_DISPLAY); // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_FOREGROUND); // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_MORE_FAVORABLE); // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY); if (!_hasFocus) { Emulator.draw(); return; } Emulator.step(); Emulator.draw(); int readAmount = Emulator.mixAudioBuffer(tempBuf); if (readAmount <= 0) { return; } //Log.d(LOG_TAG, "AudioMix Samples: " + readAmount); AudioPlayer.play(tempBuf, readAmount); } public void onSurfaceChanged(GL10 gl, int width, int height) { Log.d(LOG_TAG, "onSurfaceChanged(" + width + ", " + height + ")"); Emulator.setViewport(width, height); } public void onSurfaceCreated(GL10 gl, EGLConfig config) { Log.d(LOG_TAG, "onSurfaceCreated()"); // init graphics Emulator.initGraphics(); // load prefs PreferenceFacade.loadGraphicsPrefs(_activity, EmulatorView.this.getContext()); // calculate height of anything on the phone other than the game window // mostly for tablets! Rect rect = new Rect(); Window window = _activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rect); int MenuBarHeight = rect.top; int contentViewTop = window.findViewById( Window.ID_ANDROID_CONTENT) .getTop(); int TitleBarHeight = contentViewTop - MenuBarHeight; TotalOuterHeight = MenuBarHeight + TitleBarHeight; } } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/EmulatorView.java
Java
gpl2
21,281
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import java.io.File; import java.util.Map; import ca.halsafar.downloader.Decompress; import ca.halsafar.downloader.DecompressListener; import ca.halsafar.downloader.DownloadFile; import ca.halsafar.downloader.DownloadListener; import ca.halsafar.filechooser.FileChooser; import android.app.AlertDialog; import android.app.ProgressDialog; import android.app.AlertDialog.Builder; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.os.Environment; import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceManager; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceActivity; import android.util.Log; import android.view.KeyEvent; import android.widget.Toast; /** * Settings activity. Allows easy access to any/all desired settings * and manages to auto save them * * @author halsafar * */ public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener, DownloadListener, DecompressListener { private static final String LOG_TAG = "SettingsActivity"; private ProgressDialog _progressDialog = null; private String _dirKeyChanging = PreferenceFacade.PREF_DIR_ROMS; @Override protected void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate()"); super.onCreate(savedInstanceState); addPreferencesFromResource(R.layout.settings); // add onclick for input setup button Preference customPref = (Preference) findPreference("bntInputPref"); customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { try { Intent intent = new Intent(SettingsActivity.this, InputConfigActivity.class); final int result = PreferenceFacade.MENU_INPUT_CONFIG; startActivityForResult(intent, result); } catch (Exception e) { Log.e(LOG_TAG, "EXCEPTION: " + e.toString()); } return true; } }); // add onclick for reset input customPref = (Preference) findPreference("bntDefaultEmpty"); customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); Editor edit = prefs.edit(); edit.putBoolean(PreferenceFacade.PREF_USE_DEFAULT_INPUT, true); edit.commit(); // safe to reset input anytime, nice for people who are editing input EmulatorButtons.resetInput(SettingsActivity.this, getApplicationContext()); return true; } }); // add on click for custom keys customPref = (Preference) findPreference("bntCustomKeys"); customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { try { Intent intent = new Intent(SettingsActivity.this, KeyboardConfigActivity.class); final int result = PreferenceFacade.MENU_CUSTOM_KEYS; startActivityForResult(intent, result); } catch (Exception e) { Log.e(LOG_TAG, "EXCEPTION: " + e.toString()); } return true; } }); // add onclick for select shader customPref = (Preference) findPreference("selectShaderPref"); customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // spawn the file chooser Intent myIntent = new Intent(SettingsActivity.this, FileChooser.class); myIntent.putExtra(FileChooser.EXTRA_START_DIR, PreferenceFacade.getShaderDir(getApplicationContext())); myIntent.putExtra(FileChooser.EXTRA_EXTENSIONS, PreferenceFacade.DEFAULT_SHADER_EXTENSIONS); final int result = PreferenceFacade.MENU_SHADER_SELECT; startActivityForResult(myIntent, result); return true; } }); // add onclick for reset to default shader customPref = (Preference) findPreference("resetShaderPref"); customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Editor edit = prefs.edit(); edit.putString(PreferenceFacade.PREF_SHADER_FILE, null); edit.commit(); return true; } }); // add onclick for download shaders customPref = (Preference) findPreference("downloadShaderPref"); customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { _progressDialog = new ProgressDialog(SettingsActivity.this); _progressDialog.setMessage("Downloading Shaders..."); _progressDialog.setIndeterminate(false); _progressDialog.setMax(100); _progressDialog .setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); String outFile = PreferenceFacade.getShaderDir(getApplicationContext()) + "/shaders.zip"; DownloadFile downloadFile = new DownloadFile(outFile, getApplicationContext(), _progressDialog, SettingsActivity.this); downloadFile.execute("https://sites.google.com/site/shinhalsafar/files/shaders.zip"); _progressDialog.show(); return true; } }); // add on click warning for game genie CheckBoxPreference checkPref = (CheckBoxPreference) findPreference(PreferenceFacade.PREF_ENABLE_GAME_GENIE); if (checkPref != null) { checkPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { boolean checkValue = ((CheckBoxPreference)preference).isChecked(); if (checkValue) { // check for gg rom String romFile = Environment.getExternalStorageDirectory() + PreferenceFacade.DEFAULT_DIR + "/gg.rom"; File f = new File(romFile); if (!f.exists()) { Builder dialog = new AlertDialog.Builder(SettingsActivity.this) .setTitle("Game Genie Not Found") .setMessage("Game Genie not found, place game genie image at: " + romFile) .setPositiveButton("Ok", null); dialog.show(); ((CheckBoxPreference)preference).setChecked(false); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); boolean enableAutosave = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_AUTO_SAVE, false); if (enableAutosave) { Toast.makeText(getApplicationContext(), "Cannot auto load with game genie enabled, will still auto save." , Toast.LENGTH_LONG).show(); } } return false; } }); } // add onclick for reset to default shader checkPref = (CheckBoxPreference) findPreference(PreferenceFacade.PREF_ENABLE_AUTO_SAVE); checkPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { boolean checkValue = ((CheckBoxPreference)preference).isChecked(); if (checkValue) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); boolean enableGameGenie = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_GAME_GENIE, false); if (enableGameGenie) { Toast.makeText(getApplicationContext(), "Cannot auto load with game genie enabled, will still auto save." , Toast.LENGTH_LONG).show(); } } return false; } }); // set on click for directories customPref = (Preference) findPreference(PreferenceFacade.PREF_DIR_ROMS); customPref.setSummary(PreferenceFacade.getRomDir(getApplicationContext())); customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // spawn the file chooser Intent myIntent = new Intent(SettingsActivity.this, FileChooser.class); myIntent.putExtra(FileChooser.EXTRA_SELECT_DIR, "true"); myIntent.putExtra(FileChooser.EXTRA_START_DIR, PreferenceFacade.getRomDir(getApplicationContext())); myIntent.putExtra(FileChooser.EXTRA_EXTENSIONS, ""); final int result = PreferenceFacade.MENU_DIR_SELECT; startActivityForResult(myIntent, result); _dirKeyChanging = PreferenceFacade.PREF_DIR_ROMS; return true; } }); // add preference change listener to update the summaries getPreferenceScreen().getSharedPreferences() .registerOnSharedPreferenceChangeListener(this); } @Override public void onStart() { super.onStart(); // @HACK - to display current value SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); Map<String, ?> allPrefs = prefs.getAll(); for (String key : allPrefs.keySet()) { Preference pref = findPreference(key); if (pref instanceof ListPreference) { ListPreference listPref = (ListPreference) pref; pref.setSummary(listPref.getEntry()); } } } public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Preference pref = findPreference(key); if (pref instanceof ListPreference) { ListPreference listPref = (ListPreference) pref; pref.setSummary(listPref.getEntry()); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(LOG_TAG, "onActivityResult()"); if (requestCode == PreferenceFacade.MENU_INPUT_CONFIG) { Log.d(LOG_TAG, "onActivityResult(INPUT_CONFIG)"); } else if (requestCode == PreferenceFacade.MENU_DIR_SELECT) { Log.d(LOG_TAG, "onActivityResult(DIR_SELECT)"); String directory = data.getStringExtra(FileChooser.PAYLOAD_SELECTED_DIR); if (directory != null) { Log.d(LOG_TAG, "NewDir: " + directory + " @ Key: " + _dirKeyChanging); } if (_dirKeyChanging != null) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); // mod summary Preference dirPref = findPreference(_dirKeyChanging); dirPref.setSummary(directory); Editor edit = prefs.edit(); edit.putString(_dirKeyChanging, directory); edit.commit(); } } else if (requestCode == PreferenceFacade.MENU_SHADER_SELECT) { String shaderFile = data .getStringExtra(FileChooser.PAYLOAD_FILENAME); Log.d(LOG_TAG, "onActivityResult(SHADER_SELECT: " + shaderFile + ")"); Preference customPref = (Preference) findPreference("selectShaderPref"); customPref.setSummary(shaderFile); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Editor edit = prefs.edit(); edit.putString(PreferenceFacade.PREF_SHADER_FILE, shaderFile); edit.commit(); } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.d(LOG_TAG, "onKeyDown(" + keyCode + ")"); if (keyCode == KeyEvent.KEYCODE_BACK) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); return true; } return super.onKeyDown(keyCode, event); } public void onDownloadAlreadyUpdated(String filename) { _progressDialog.setProgress(_progressDialog.getMax()); Decompress unzip = new Decompress(filename, PreferenceFacade.getShaderDir(getApplicationContext()), _progressDialog, this); unzip.execute(); // mark up to date Preference customPref = (Preference) findPreference("downloadShaderPref"); customPref.setSummary("Already up to date!"); } public void onDownloadSuccess(String filename, Long sizeBytes) { // TODO Auto-generated method stub Decompress unzip = new Decompress(filename, PreferenceFacade.getShaderDir(getApplicationContext()), _progressDialog, this); unzip.execute(); Preference customPref = (Preference) findPreference("downloadShaderPref"); customPref.setSummary("Updated Successfully!"); } public void onDownloadFail(String filename) { Builder dialog = new AlertDialog.Builder(SettingsActivity.this) .setTitle("Download Shader Error") .setMessage("There was an error trying to download shaders, check your internet connection!") .setPositiveButton("Ok", null); dialog.show(); Preference customPref = (Preference) findPreference("downloadShaderPref"); customPref.setSummary("Download failed..."); } public void onDecompressSuccess(String filename, Integer numFiles) { // TODO Auto-generated method stub } public void onDecompressFail(String filename) { // TODO Auto-generated method stub Preference customPref = (Preference) findPreference("downloadShaderPref"); customPref.setSummary("Cannot decompress shaders...!"); } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/SettingsActivity.java
Java
gpl2
17,770
/** * GENPlusDroid * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class WelcomeActivity extends Activity { private static final String LOG_TAG = "WelcomeActivity"; @Override public void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.welcome); Button tmp = (Button)findViewById(R.id.btnWelcomeDone); tmp.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(WelcomeActivity.this, MainActivity.class); startActivity(intent); finish(); } }); tmp = (Button)findViewById(R.id.btnWelcomeExit); tmp.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); } }); } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/WelcomeActivity.java
Java
gpl2
1,453
package ca.halsafar.genesisdroid; import ca.halsafar.audio.AudioPlayer; import ca.halsafar.genesisdroid.PreferenceFacade; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.graphics.Rect; import android.os.Environment; import android.preference.PreferenceManager; import android.util.Log; import android.view.Window; import android.view.WindowManager; public class PreferenceFacade { private static final String LOG_TAG = "PreferenceFacade"; // pref defaults public static final boolean DEFAULT_AUDIO_SETTING = true; public static final boolean DEFAULT_KEEP_NES_ASPECT_RATIO = true; public static final String DEFAULT_SOUND_SAMPLE_RATE = "22050"; public static final int DEFAULT_X_SENSITIVTY = 30; public static final int DEFAULT_Y_SENSITIVTY = 35; public static final int DEFAULT_AUDIO_STRETCH = 8; // default dirs public static final String DEFAULT_DIR = "/GENPlusDroid"; public static final String DEFAULT_DIR_ROMS = DEFAULT_DIR + "/roms"; public static final String DEFAULT_DIR_STATES = DEFAULT_DIR + "/states"; public static final String DEFAULT_DIR_SRAM = DEFAULT_DIR + "/sram"; public static final String DEFAULT_DIR_CHEATS = DEFAULT_DIR + "/cheats"; public static final String DEFAULT_DIR_SHADERS = DEFAULT_DIR + "/shaders"; public static final String DEFAULT_DIR_TEMPFILES = DEFAULT_DIR + "/temp"; public static final String DEFAULT_ROM_EXTENSIONS = "smd|gen|bin|sms|zip"; public static final String DEFAULT_SHADER_EXTENSIONS = "glsl"; public static final String PREF_DIR_ROMS = "prefRomDir"; public static final String PREF_DIR_STATES = "prefStatesDir"; public static final String PREF_DIR_SRAM = "prefSramDir"; public static final String PREF_DIR_CHEATS = "prefCheatsDir"; public static final String PREF_DIR_SHADERS = "prefCheatsDir"; public static final String PREF_DIR_TEMP = "prefTempDir"; // menu keys public static final int MENU_ROM_SELECT = 1; public static final int MENU_SETTINGS = 2; public static final int MENU_INPUT_CONFIG = 3; public static final int MENU_SHADER_SELECT = 4; public static final int MENU_CUSTOM_KEYS = 5; public static final int MENU_DIR_SELECT = 6; // input keys public static final String PREF_SHOW_TOUCH_INPUT = "prefShowTouchInput"; public static final String PREF_X_SENSITIVITY = "xAxisSensitivity"; public static final String PREF_Y_SENSITIVITY = "yAxisSensitivity"; public static final String PREF_USE_DEFAULT_INPUT = "useDefaultInput"; public static final String PREF_FIRST_SHADER_SELECT = "prefFirstShader"; // graphics settings public static final String PREF_MAINTAIN_ASPECT_RATIO = "aspectRatio"; public static final String PREF_SHADER_FILE = "prefShaderFile"; public static final String PREF_GRAPHICS_FILTER = "graphicsFilter"; // audio public static final String PREF_ENABLE_AUDIO = "audio"; public static final String PREF_SOUND_SAMPLE_RATE = "soundSampleRate"; public static final int AUDIO_MIX_SAMPLES_MAX = 2048; // emulator settings public static final String PREF_FRAME_SKIP = "frameSkip"; public static final String PREF_ENABLE_GAME_GENIE = "useGameGenie"; public static final String PREF_ENABLE_AUTO_SAVE = "enableAutosave"; public static final String PREF_ENABLE_REWIND = "enableRewind"; public static final String PREF_ENABLE_FORWARD = "enableForward"; public static final String PREF_REWIND_COUNT = "rewindCount"; public static final String PREF_REWIND_FREQUENCY = "rewindFrequency"; public static final int PREF_AUTO_SAVE_SLOT = 10; // application settings public static final String PREF_FIRST_RUN = "genplus_1_7"; public static String getRomDir(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String dir = prefs.getString(PREF_DIR_ROMS, Environment.getExternalStorageDirectory() + DEFAULT_DIR_ROMS); return dir; } public static String getStateDir(final Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String dir = prefs.getString(PREF_DIR_STATES, Environment.getExternalStorageDirectory() + DEFAULT_DIR_STATES); return dir; } public static String getSramDir(final Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String dir = prefs.getString(PREF_DIR_SRAM, Environment.getExternalStorageDirectory() + DEFAULT_DIR_SRAM); return dir; } public static String getCheatsDir(final Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String dir = prefs.getString(PREF_DIR_CHEATS, Environment.getExternalStorageDirectory() + DEFAULT_DIR_CHEATS); return dir; } public static String getShaderDir(final Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String dir = prefs.getString(PREF_DIR_SHADERS, Environment.getExternalStorageDirectory() + DEFAULT_DIR_SHADERS); return dir; } public static String getTempDir(final Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String dir = prefs.getString(PREF_DIR_TEMP, Environment.getExternalStorageDirectory() + DEFAULT_DIR_TEMPFILES); return dir; } public static int getRealScreenHeight(final Activity activity, final Context context) { Rect rect = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rect); //int screenWidth = Math.max(rect.right, rect.bottom); int screenHeight = Math.min(rect.right, rect.bottom) - rect.top; return screenHeight; } public static int getRealScreenWidth(final Activity activity, final Context context) { Rect rect = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rect); int screenWidth = Math.max(rect.right, rect.bottom) - rect.top; /*View foo = window.findViewById(Window.ID_ANDROID_CONTENT); Log.d(LOG_TAG, "foo.top="+foo.getTop() + "\tbottom="+foo.getBottom()); //int screenHeight = Math.min(rect.right, rect.bottom); Display display = activity.getWindowManager().getDefaultDisplay(); Log.d(LOG_TAG, "display.width=" + display.getWidth()); Log.d(LOG_TAG, "display.height=" + display.getHeight());*/ return screenWidth; } protected static void loadPrefs(final Activity activity, final Context context) { // load up default prefs SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean useAudio = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_AUDIO, PreferenceFacade.DEFAULT_AUDIO_SETTING); float xAxisSens = prefs.getInt(PreferenceFacade.PREF_X_SENSITIVITY, PreferenceFacade.DEFAULT_X_SENSITIVTY) / 100.0f; float yAxisSens = prefs.getInt(PreferenceFacade.PREF_Y_SENSITIVITY, PreferenceFacade.DEFAULT_Y_SENSITIVTY) / 100.0f; int sampleRate = Integer.parseInt(prefs.getString(PreferenceFacade.PREF_SOUND_SAMPLE_RATE, PreferenceFacade.DEFAULT_SOUND_SAMPLE_RATE)); int frameSkip = Integer.parseInt(prefs.getString(PreferenceFacade.PREF_FRAME_SKIP, "1")); boolean useGameGenie = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_GAME_GENIE, false); boolean enableRewind = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_REWIND, false); //boolean enableForward = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_FORWARD, false); float audioStretchPercent = (prefs.getInt("audioStretchPercent", PreferenceFacade.DEFAULT_AUDIO_STRETCH) / 100.0f); // emulator settings Emulator.setFrameSkip(frameSkip); Emulator.setGameGenie(useGameGenie); Emulator.setEnableRewind(enableRewind); // audio Emulator.setAudioEnabled(useAudio); if (useAudio) { Emulator.setAudioSampleRate((int)(sampleRate)); AudioPlayer.create((int)(sampleRate * (1.0 -audioStretchPercent)), 16, 2); AudioPlayer.resume(); Emulator.initAudioBuffer(AudioPlayer.getMaxBufferSize()); } else { Emulator.setAudioSampleRate(0); AudioPlayer.destroy(); } Emulator.setSensitivity(xAxisSens, yAxisSens); // set directories String romDir = getRomDir(context); String stateDir = getStateDir(context); String sramDir = getSramDir(context); String cheatsDir = getCheatsDir(context); String shadersDir = getShaderDir(context); String tempDir = getTempDir(context); Log.d(LOG_TAG, "Directories: \n\t" + "Roms: " + romDir + "\n\t" + "States: " + stateDir + "\n\t" + "SRAM: " + sramDir + "\n\t" + "Cheats: " + cheatsDir + "\n\t" + "Shaders: " + shadersDir + "\n\t" + "Temp: " + tempDir); } /** * Do not call without proper opengl context thread * ie. Only from GLSurfaceView pipe */ public static void loadGraphicsPrefs(final Activity activity, final Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean keepAspect = prefs.getBoolean(PreferenceFacade.PREF_MAINTAIN_ASPECT_RATIO, PreferenceFacade.DEFAULT_KEEP_NES_ASPECT_RATIO); // aspect ratio if (keepAspect) { Emulator.setAspectRatio(4.0f/3.0f); } else { WindowManager mWinMgr = (WindowManager)context.getSystemService(Activity.WINDOW_SERVICE); float screenWidth = mWinMgr.getDefaultDisplay().getWidth(); float screenHeight = mWinMgr.getDefaultDisplay().getHeight(); Emulator.setAspectRatio(screenWidth / screenHeight); } // linear or point filtering boolean smooth = Boolean.parseBoolean(prefs.getString(PreferenceFacade.PREF_GRAPHICS_FILTER, "true")); Emulator.setSmoothFiltering(smooth); // shader String shaderFileName = prefs.getString(PreferenceFacade.PREF_SHADER_FILE, null); if (shaderFileName != null) { Log.d(LOG_TAG, "Shader: " + shaderFileName); Emulator.setShaderFile(shaderFileName); } else { Log.d(LOG_TAG, "NULL SHADER"); Emulator.setShaderFile(null); } Log.d(LOG_TAG, "keepAspect: " + keepAspect + "\n" + "shaderFile: " + shaderFileName + "\n"); } public static void loadInputs(Activity activity, Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean enableRewind = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_REWIND, false); boolean enableForward = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_FORWARD, false); boolean showTouchInput = prefs.getBoolean(PreferenceFacade.PREF_SHOW_TOUCH_INPUT, true); // check if we have defaults already boolean useDefaultInput = true; if (prefs.contains(PreferenceFacade.PREF_USE_DEFAULT_INPUT)) { useDefaultInput = prefs.getBoolean(PreferenceFacade.PREF_USE_DEFAULT_INPUT, true); } if (useDefaultInput) { Log.d(LOG_TAG, "Setting default input!"); EmulatorButtons.resetInput(activity, context); Editor edit = prefs.edit(); edit.putBoolean(PreferenceFacade.PREF_USE_DEFAULT_INPUT, false); edit.commit(); } // load analog float padx = InputPreferences.getAnalogX(context, 0); float pady = InputPreferences.getAnalogY(context, 0); float padw = InputPreferences.getAnalogWidth(context, 0); float padh = InputPreferences.getAnalogHeight(context, 0); int padcodel = InputPreferences.getAnalogLeftCode(context, 0); int padcodeu = InputPreferences.getAnalogUpCode(context, 0); int padcoder = InputPreferences.getAnalogRightCode(context, 0); int padcoded = InputPreferences.getAnalogDownCode(context, 0); //int padmap = InputPreferences.getButtonMap(context, 0); Emulator.setAnalog(padx, pady, padw, padh, padcodel, padcodeu, padcoder, padcoded, showTouchInput); // load all buttons int numButtons = InputPreferences.getNumButtons(context); for (int i = 0; i < numButtons; i++) { float x = InputPreferences.getButtonX(context, i); float y = InputPreferences.getButtonY(context, i); float w = InputPreferences.getButtonWidth(context, i); float h = InputPreferences.getButtonHeight(context, i); int code = InputPreferences.getButtonCode(context, i); int map = InputPreferences.getButtonMap(context, i); if (i == EmulatorButtons.BUTTON_INDEX_FORWARD.ordinal()) { Emulator.setButton(map, x, y, w, h, code, showTouchInput && enableForward); } else if (i == EmulatorButtons.BUTTON_INDEX_REWIND.ordinal()) { Emulator.setButton(map, x, y, w, h, code, showTouchInput && enableRewind); } else { Emulator.setButton(map, x, y, w, h, code, showTouchInput); } } } public static void DoAutoSave(Context context) { // check for auto save SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); boolean autoSave = preferences.getBoolean(PreferenceFacade.PREF_ENABLE_AUTO_SAVE, false); if (autoSave) { Emulator.saveState(PreferenceFacade.PREF_AUTO_SAVE_SLOT); } } public static void DoAutoLoad(Context context) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); boolean autoSave = preferences.getBoolean(PreferenceFacade.PREF_ENABLE_AUTO_SAVE, false); boolean gameGenie = preferences.getBoolean(PreferenceFacade.PREF_ENABLE_GAME_GENIE, false); if (autoSave && !gameGenie) { Emulator.loadState(PreferenceFacade.PREF_AUTO_SAVE_SLOT); } } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/PreferenceFacade.java
Java
gpl2
16,034
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import java.io.IOException; import java.io.InputStream; import ca.halsafar.genesisdroid.R; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.GestureDetector; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Toast; public class InputConfigActivity extends Activity implements GestureDetector.OnGestureListener { private static final String LOG_TAG = "InputConfigActivity"; private RectF _gameRect; private RectF _rects[]; private RectF _analogRects[]; private Bitmap _bitmaps[]; private Bitmap _analogBitmaps[]; private Paint _paintGameRect; private Paint _paint; private RectF _trackRect; private RectF _resizingRect; private boolean _resizeReady = false; private GestureDetector _gestures; private float _screenWidth; private float _screenHeight; private int _buttonCount = 0; private int _analogCount = 0; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Context context = getApplicationContext(); // number of buttons created _buttonCount = InputPreferences.getNumButtons(context); _analogCount = InputPreferences.getNumAnalogs(context); Log.d(LOG_TAG, "onCreate() Parsing NumButtons: " + _buttonCount + ", NumAnalogs: " + _analogCount); // handle to prefs SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); // init _analogRects = _rects = new RectF[_buttonCount]; _bitmaps = new Bitmap[_buttonCount]; _analogRects = new RectF[_analogCount]; _analogBitmaps = new Bitmap[_analogCount]; _screenWidth = PreferenceFacade.getRealScreenWidth(this, context); _screenHeight = PreferenceFacade.getRealScreenHeight(this, context); // create the game window rect float ratio = 4.0f / 3.0f; if (!prefs.getBoolean(PreferenceFacade.PREF_MAINTAIN_ASPECT_RATIO, true)) { ratio = _screenWidth / _screenHeight; } float rectHeight = _screenHeight; float rectWidth = rectHeight * ratio; float rectX = (_screenWidth / 2.0f) - (rectWidth / 2.0f); float rectY = 0; _gameRect = new RectF(rectX, rectY, rectX + rectWidth, rectY + rectHeight); // load the resources AssetManager mngr = getAssets(); // analogs for (int i = 0; i < _analogCount; i++) { float dPadX = InputPreferences.getAnalogX(context, i); float dPadY = InputPreferences.getAnalogY(context, i); float dPadWidth = InputPreferences.getAnalogWidth(context, i); float dPadHeight = InputPreferences.getAnalogHeight(context, i); String textureFile = InputPreferences.getAnalogTexture(context, i); try { if (textureFile != null) { InputStream is = mngr.open(textureFile); _analogBitmaps[i] = BitmapFactory.decodeStream(is); is.close(); } } catch (IOException e) { e.printStackTrace(); } _analogRects[i] = new RectF(dPadX, dPadY, dPadX + dPadWidth, dPadY + dPadHeight); } // buttons for (int i = 0; i < _buttonCount; i++) { float x = InputPreferences.getButtonX(context, i); float y = InputPreferences.getButtonY(context, i); float w = InputPreferences.getButtonWidth(context, i); float h = InputPreferences.getButtonHeight(context, i); //int code = InputPreferences.getButtonCode(context, i); int map = InputPreferences.getButtonMap(context, i); String textureFile = InputPreferences.getButtonTexture(context, i); try { if (textureFile != null) { InputStream is = mngr.open(textureFile); _bitmaps[map] = BitmapFactory.decodeStream(is); is.close(); } } catch (IOException e) { e.printStackTrace(); } _rects[map] = new RectF(x, y, x + w, y + h); } // paint _paint = new Paint(); _paint.setColor(Color.GREEN); _paint.setStyle(Paint.Style.STROKE); _paint.setStrokeWidth(3); _paintGameRect = new Paint(); _paintGameRect.setColor(Color.DKGRAY); _paintGameRect.setStyle(Paint.Style.FILL); // set renderer View _view = new InputSetupView(this); setContentView(_view); _gestures = new GestureDetector(this); Builder dialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.app_name) + " Input Config") .setMessage("- Drag controls around to move them\n"+ "- Touch and hold to enter resize mode\n" + "- In resize mode drag edges to resize\n" + "- Press 'Back' or select another control to exit resize mode\n" + "- Saves when you leave this screen") .setNeutralButton("Ok", null); dialog.show(); } @Override public void onPause() { super.onPause(); saveInput(); finish(); } @Override public void onStop() { super.onStop(); saveInput(); finish(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.d(LOG_TAG, "onKeyDown(" + keyCode + ")"); if (keyCode == KeyEvent.KEYCODE_BACK) { // check for resizing abort, quick exit too if (_resizingRect != null) { _resizingRect = null; return true; } // exit, save positions, pass good result to parent Intent intent = new Intent(); setResult(RESULT_OK, intent); // save input saveInput(); finish(); return true; } return super.onKeyDown(keyCode, event); } @Override public boolean onTouchEvent(final MotionEvent event) { int actionMasked = event.getActionMasked(); if (actionMasked == MotionEvent.ACTION_POINTER_DOWN || actionMasked == MotionEvent.ACTION_DOWN) { RectF rect = handleTouchDown(event); if (rect == null || rect != _resizingRect) { _trackRect = rect; _resizingRect = null; } } else if (actionMasked == MotionEvent.ACTION_POINTER_UP || actionMasked == MotionEvent.ACTION_UP || actionMasked == MotionEvent.ACTION_CANCEL) { _trackRect = null; if (_resizingRect != null) { _resizeReady = true; } } else if (actionMasked == MotionEvent.ACTION_MOVE) { handleOnMove(event); } return _gestures.onTouchEvent(event); } private void saveInput() { Context context = getApplicationContext(); for (int i = 0; i < _buttonCount; i++) { InputPreferences.setButton(context, _rects[i].left, _rects[i].top, _rects[i].right - _rects[i].left, _rects[i].bottom - _rects[i].top, i); } for (int i = 0; i < _analogCount; i++) { InputPreferences.setAnalog(context, _analogRects[i].left, _analogRects[i].top, _analogRects[i].right - _analogRects[i].left, _analogRects[i].bottom - _analogRects[i].top, i); } // turn off auto default! SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = prefs.edit(); edit.putBoolean(PreferenceFacade.PREF_USE_DEFAULT_INPUT, false); edit.commit(); } public RectF handleLongClick(MotionEvent event) { float x = event.getX(); float y = event.getY(); for (int i = 0; i < _buttonCount; i++) { RectF rect = _rects[i]; if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) { Toast.makeText(this, "Press back or touch a different object to leave resize mode", Toast.LENGTH_LONG).show(); return rect; } } for (int i = 0; i < _analogCount; i++) { RectF rect = _analogRects[i]; if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) { Toast.makeText(this, "Press back or touch a different object to leave resize mode", Toast.LENGTH_LONG).show(); return rect; } } return null; } public void handleOnMove(final MotionEvent event) { // only do 1 or the other if (_resizingRect != null) { if (_resizeReady) { // calculate aspect float width = _resizingRect.right - _resizingRect.left; float height = _resizingRect.bottom - _resizingRect.top; float aspect = width / height; float halfWidth = width / 2; // @TODO - fix this... must be square dpad float xDist = (event.getX() - _resizingRect.left) / (halfWidth); float yDist = (event.getY() - _resizingRect.top) / halfWidth; if (xDist > 0.75) { float xDelta = event.getX() - _resizingRect.right; float yDelta = xDelta * aspect; // cap on width if ((event.getX() - _resizingRect.left) > (_screenWidth * 0.05)) { _resizingRect.right = event.getX(); if (yDist > 0.5) { _resizingRect.bottom += yDelta; } else if (yDist < 0.5) { _resizingRect.top -= yDelta; } } } if (xDist < 0.25) { float xDelta = _resizingRect.left - event.getX(); float yDelta = xDelta * aspect; // cap on width if ((_resizingRect.right - event.getX()) > (_screenWidth * 0.05)) { _resizingRect.left = event.getX(); if (yDist > 0.5) { _resizingRect.bottom += yDelta; } else if (yDist < 0.5) { _resizingRect.top -= yDelta; } } } } } else if (_trackRect != null) { float width = _trackRect.right - _trackRect.left; float height = _trackRect.bottom - _trackRect.top; float x = event.getX() - width / 2; float y = event.getY() - height / 2; _trackRect.left = x; _trackRect.top = y; _trackRect.right = x + width; _trackRect.bottom = y + height; } } public RectF handleTouchDown(final MotionEvent event) { float x = event.getX(); float y = event.getY(); for (int i = 0; i < _buttonCount; i++) { RectF rect = _rects[i]; if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) { return rect; } } for (int i = 0; i < _analogCount; i++) { RectF rect = _analogRects[i]; if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) { return rect; } } return null; } public boolean onDown(MotionEvent e) { // TODO Auto-generated method stub return false; } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // TODO Auto-generated method stub return false; } public void onLongPress(MotionEvent e) { Log.d(LOG_TAG, "LongPress(" + e + ")"); _resizingRect = handleLongClick(e); _resizeReady = false; } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } public void onShowPress(MotionEvent e) { // TODO Auto-generated method stub } public boolean onSingleTapUp(MotionEvent e) { // TODO Auto-generated method stub return false; } class InputSetupView extends SurfaceView implements SurfaceHolder.Callback { private TutorialThread _thread; public InputSetupView(Context context) { super(context); getHolder().addCallback(this); _thread = new TutorialThread(getHolder(), this); } //@Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { // TODO Auto-generated method stub } //@Override public void surfaceCreated(SurfaceHolder holder) { _thread.setRunning(true); _thread.start(); } //@Override public void surfaceDestroyed(SurfaceHolder holder) { // simply copied from sample application LunarLander: // we have to tell thread to shut down & wait for it to finish, or else // it might touch the Surface after we return and explode boolean retry = true; _thread.setRunning(false); while (retry) { try { _thread.join(); retry = false; } catch (InterruptedException e) { // we will try it again and again... } } } @Override public void onDraw(Canvas canvas) { // render them canvas.drawColor(Color.BLACK); canvas.drawRect(_gameRect, _paintGameRect); for (int i = 0; i < _buttonCount; i++) { if (_bitmaps[i] != null) { canvas.drawBitmap(_bitmaps[i], null, _rects[i], null); } if (_resizingRect == _rects[i]) { canvas.drawRect(_rects[i], _paint); } } for (int i = 0; i < _analogCount; i++) { if (_analogBitmaps[i] != null) { canvas.drawBitmap(_analogBitmaps[i], null, _analogRects[i], null); } if (_resizingRect == _analogRects[i]) { canvas.drawRect(_analogRects[i], _paint); } } } } class TutorialThread extends Thread { private SurfaceHolder _surfaceHolder; private InputSetupView _panel; private boolean _run = false; public TutorialThread(SurfaceHolder surfaceHolder, InputSetupView panel) { _surfaceHolder = surfaceHolder; _panel = panel; } public void setRunning(boolean run) { _run = run; } @Override public void run() { Canvas c; while (_run) { c = null; try { c = _surfaceHolder.lockCanvas(null); synchronized (_surfaceHolder) { _panel.onDraw(c); } } finally { // do this in a finally so that if an exception is thrown // during the above, we don't leave the Surface in an // inconsistent state if (c != null) { _surfaceHolder.unlockCanvasAndPost(c); } } } } } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/InputConfigActivity.java
Java
gpl2
20,421
/** * GENPlusDroid * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import android.app.Activity; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.text.Html; import android.text.method.LinkMovementMethod; import android.text.util.Linkify; import android.util.Log; import android.widget.TextView; public class AboutActivity extends Activity { private static final String LOG_TAG = "AboutActivity"; @Override public void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.about); TextView txt = (TextView) findViewById(R.id.txtVersion); txt.setText("Version: " + getVersion()); TextView email = (TextView) findViewById(R.id.aboutEmail); Linkify.addLinks(email, Linkify.EMAIL_ADDRESSES); TextView website = (TextView) findViewById(R.id.aboutWebsite); CharSequence text = "<a href=\""+getString(R.string.website)+"\">Website</a>"; website.setText(Html.fromHtml(text.toString())); website.setMovementMethod(LinkMovementMethod.getInstance()); TextView issues = (TextView) findViewById(R.id.aboutIssues); text = "<a href=\""+getString(R.string.issueTracker)+"\">Report Issues</a>"; issues.setText(Html.fromHtml(text.toString())); issues.setMovementMethod(LinkMovementMethod.getInstance()); TextView poweredBy = (TextView) findViewById(R.id.aboutPoweredBy); text = "<a href=\"http://code.google.com/p/genplus-gx/\">Powered By: GENPLUS</a>"; poweredBy.setText(Html.fromHtml(text.toString())); poweredBy.setMovementMethod(LinkMovementMethod.getInstance()); TextView seeAlso = (TextView) findViewById(R.id.aboutSeeAlso); text = "See Also: <a href=\"market://search?q=pname:ca.halsafar.genesisdroid\">NESDroid</a>"; seeAlso.setText(Html.fromHtml(text.toString())); seeAlso.setMovementMethod(LinkMovementMethod.getInstance()); } private String getVersion() { String version = "ERROR"; try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA); version = pInfo.versionName; } catch (NameNotFoundException e1) { Log.e(LOG_TAG, "VersionName not found", e1); } return version; } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/AboutActivity.java
Java
gpl2
2,876
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import ca.halsafar.audio.AudioPlayer; import ca.halsafar.filechooser.FileChooser; import ca.halsafar.genesisdroid.Emulator; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.preference.PreferenceManager; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; /** * Manages the activity exclusive to dealing with rendering and update step * aspects of emulation. * * @author halsafar * */ public class EmulatorActivity extends Activity { private static final String LOG_TAG = "EmulatorActivity"; private EmulatorView _view; private int _currentSaveState = 0; @Override public void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate()"); super.onCreate(savedInstanceState); // reset input here so we have the emulation layout PreferenceFacade.loadInputs(this, getApplicationContext()); // start displaying _view = new EmulatorView(this, getApplication()); setContentView(_view); } @Override public boolean onCreateOptionsMenu(Menu myMenu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.emulator, myMenu); return true; } @Override public void onResume() { super.onResume(); Log.d(LOG_TAG, "onResume()"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); boolean audio = prefs.getBoolean(PreferenceFacade.PREF_ENABLE_AUDIO, true); if (audio) { AudioPlayer.resume(); } _view.onResume(); // help android out a bit... seems to be slow at releasing sometimes System.gc(); } @Override public void onPause() { Log.d(LOG_TAG, "onPause()"); super.onPause(); AudioPlayer.pause(); _view.onPause(); PreferenceFacade.DoAutoSave(getApplicationContext()); } @Override public void onDestroy() { super.onDestroy(); } @Override public void onStop() { Log.d(LOG_TAG, "onStop()"); super.onStop(); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { /* * case R.id.menuShowKeyboard: InputMethodManager inputMgr = * (InputMethodManager * )getSystemService(Context.INPUT_METHOD_SERVICE); * inputMgr.showSoftInput(_view, InputMethodManager.SHOW_FORCED); * //inputMgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, * InputMethodManager.HIDE_IMPLICIT_ONLY); return true; */ /* * case R.id.menuExit: Intent intent = new Intent(); * setResult(RESULT_OK, intent); * * this.finish(); * * return true; */ case R.id.menuMenu: this.finish(); return true; case R.id.menuSettings: spawnSettings(); return true; case R.id.menuLoadROM: spawnFileChooser(); return true; case R.id.menuSelectState: return true; case R.id.menuLoadState: Emulator.loadState(_currentSaveState); return true; case R.id.menuSaveState: Emulator.saveState(_currentSaveState); return true; case R.id.menuResetGame: Emulator.resetGame(); return true; case R.id.menuSelectShader: Intent myIntent = new Intent(EmulatorActivity.this, FileChooser.class); myIntent.putExtra(FileChooser.EXTRA_START_DIR, PreferenceFacade.getShaderDir(getApplicationContext())); myIntent.putExtra(FileChooser.EXTRA_EXTENSIONS, PreferenceFacade.DEFAULT_SHADER_EXTENSIONS); final int result = PreferenceFacade.MENU_SHADER_SELECT; startActivityForResult(myIntent, result); return true; case R.id.menuResetShader: _view.queueEvent(new Runnable() { public void run() { SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); Editor edit = prefs.edit(); edit.putString(PreferenceFacade.PREF_SHADER_FILE, null); edit.commit(); Emulator.setShaderFile(null); } }); return true; case R.id.menuState0: _currentSaveState = 0; return true; case R.id.menuState1: _currentSaveState = 1; return true; case R.id.menuState2: _currentSaveState = 2; return true; case R.id.menuState3: _currentSaveState = 3; return true; case R.id.menuState4: _currentSaveState = 4; return true; case R.id.menuState5: _currentSaveState = 5; return true; case R.id.menuState6: _currentSaveState = 6; return true; case R.id.menuState7: _currentSaveState = 7; return true; case R.id.menuState8: _currentSaveState = 8; return true; case R.id.menuState9: _currentSaveState = 9; return true; default: return super.onOptionsItemSelected(item); } } protected void spawnFileChooser() { // spawn the file chooser Context context = getApplicationContext(); Intent myIntent = new Intent(EmulatorActivity.this, FileChooser.class); myIntent.putExtra(FileChooser.EXTRA_START_DIR, PreferenceFacade.getRomDir(context)); myIntent.putExtra(FileChooser.EXTRA_EXTENSIONS, PreferenceFacade.DEFAULT_ROM_EXTENSIONS); myIntent.putExtra(FileChooser.EXTRA_TEMP_DIR, PreferenceFacade.getTempDir(context)); final int result = PreferenceFacade.MENU_ROM_SELECT; startActivityForResult(myIntent, result); } protected void spawnSettings() { // spawn the file chooser Intent myIntent = new Intent(EmulatorActivity.this, SettingsActivity.class); final int result = PreferenceFacade.MENU_SETTINGS; startActivityForResult(myIntent, result); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(LOG_TAG, "onActivityResult(" + requestCode + ", " + resultCode + ")"); if (requestCode == PreferenceFacade.MENU_SETTINGS) { _view.queueEvent(new Runnable() { public void run() { PreferenceFacade.loadPrefs(EmulatorActivity.this, getApplicationContext()); PreferenceFacade.loadInputs(EmulatorActivity.this, getApplicationContext()); } }); } else if (requestCode == PreferenceFacade.MENU_ROM_SELECT) { String romFile = data.getStringExtra("Filename"); if (romFile != null) { if (Emulator.loadRom(romFile) != 0) { finish(); } PreferenceFacade.DoAutoLoad(getApplicationContext()); } } else if (requestCode == PreferenceFacade.MENU_SHADER_SELECT) { String shaderFile = data .getStringExtra(FileChooser.PAYLOAD_FILENAME); Log.d(LOG_TAG, "Shader Selected: " + shaderFile); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Editor edit = prefs.edit(); edit.putString(PreferenceFacade.PREF_SHADER_FILE, shaderFile); edit.commit(); Emulator.setShaderFile(shaderFile); } } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/EmulatorActivity.java
Java
gpl2
9,489
/** * ANDROID EMUFRAMEWORK * * SEE LICENSE FILE FOR LICENSE INFO * * Copyright 2011 Stephen Damm (Halsafar) * All rights reserved. * shinhalsafar@gmail.com */ package ca.halsafar.genesisdroid; import java.io.File; import ca.halsafar.audio.AudioPlayer; import ca.halsafar.filechooser.FileChooser; import ca.halsafar.genesisdroid.Emulator; import ca.halsafar.genesisdroid.PreferenceFacade; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.SharedPreferences.Editor; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.os.Environment; import android.preference.PreferenceManager; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.Toast; /** * MainMenu Activity * @author halsafar * */ public class MainActivity extends Activity { private static final String LOG_TAG = "MainActivity"; //private boolean _useAudio = false; private boolean _init = false; @Override public void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate()"); super.onCreate(savedInstanceState); System.gc(); init(); } private boolean verifyExternalStorage() { // check for sd card first boolean mExternalStorageAvailable = false; boolean mExternalStorageWriteable = false; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // rw access mExternalStorageAvailable = mExternalStorageWriteable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // r access mExternalStorageAvailable = true; mExternalStorageWriteable = false; } else { // no access mExternalStorageAvailable = mExternalStorageWriteable = false; } // if we do not have storage warn user with dialog if (!mExternalStorageAvailable || !mExternalStorageWriteable) { Builder dialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.app_name) + " Error") .setMessage("External Storage not mounted, are you in disk mode?") .setPositiveButton("Retry", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { init(); } }) .setNeutralButton("Exit", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); dialog.show(); return false; } return true; } private void init() { if (verifyExternalStorage() && !_init) { // always try and make application dirs String extStorageDirectory = Environment.getExternalStorageDirectory().toString(); File myNewFolder = new File(extStorageDirectory + PreferenceFacade.DEFAULT_DIR); if (!myNewFolder.exists()) { myNewFolder.mkdir(); } myNewFolder = new File(extStorageDirectory + PreferenceFacade.DEFAULT_DIR_ROMS); if (!myNewFolder.exists()) { myNewFolder.mkdir(); } myNewFolder = new File(extStorageDirectory + PreferenceFacade.DEFAULT_DIR_STATES); if (!myNewFolder.exists()) { myNewFolder.mkdir(); } myNewFolder = new File(extStorageDirectory + PreferenceFacade.DEFAULT_DIR_SRAM); if (!myNewFolder.exists()) { myNewFolder.mkdir(); } myNewFolder = new File(extStorageDirectory + PreferenceFacade.DEFAULT_DIR_SHADERS); if (!myNewFolder.exists()) { myNewFolder.mkdir(); } myNewFolder = new File(extStorageDirectory + PreferenceFacade.DEFAULT_DIR_TEMPFILES); if (!myNewFolder.exists()) { myNewFolder.mkdir(); } // do first run welcome screen SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); boolean firstRun = preferences.getBoolean(PreferenceFacade.PREF_FIRST_RUN, true); if (firstRun) { // remove first run flag Editor edit = preferences.edit(); edit.putBoolean(PreferenceFacade.PREF_FIRST_RUN, false); // default input edit.putBoolean(PreferenceFacade.PREF_USE_DEFAULT_INPUT, true); edit.commit(); // start welcome activity Intent intent = new Intent(MainActivity.this, WelcomeActivity.class); startActivity(intent); // might as well exit, user probably bringing us down anyway finish(); return; } // generate APK path for the native side ApplicationInfo appInfo = null; PackageManager packMgmr = this.getPackageManager(); try { appInfo = packMgmr.getApplicationInfo(getString(R.string.package_name), 0); } catch (NameNotFoundException e) { e.printStackTrace(); throw new RuntimeException("Unable to locate assets, aborting..."); } String _apkPath = appInfo.sourceDir; // init the emulator Emulator.init(_apkPath); // set the paths Emulator.setPaths(extStorageDirectory + PreferenceFacade.DEFAULT_DIR, extStorageDirectory + PreferenceFacade.DEFAULT_DIR_ROMS, extStorageDirectory + PreferenceFacade.DEFAULT_DIR_STATES, extStorageDirectory + PreferenceFacade.DEFAULT_DIR_SRAM, extStorageDirectory + PreferenceFacade.DEFAULT_DIR_CHEATS); // load up prefs now, never again unless they change //PreferenceFacade.loadPrefs(this, getApplicationContext()); // load gui Log.d(LOG_TAG, "Done init()"); setContentView(R.layout.main); initGUIEvent(); // set title super.setTitle(getString(R.string.app_name)); _init = true; Log.d(LOG_TAG, "Done onCreate()"); } } private void initGUIEvent() { Button tmpButton = (Button) findViewById(R.id.buttonLoadRom); tmpButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { spawnFileChooser(); } }); tmpButton = (Button) findViewById(R.id.buttonResume); tmpButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { if (Emulator.isRomLoaded()) { spawnEmulatorActivity(); } else { Toast.makeText(getApplicationContext(), "No ROM loaded...", Toast.LENGTH_SHORT); } } }); tmpButton = (Button) findViewById(R.id.buttonSettings); tmpButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { spawnSettings(); } }); tmpButton = (Button) findViewById(R.id.buttonExit); tmpButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { finish(); } }); tmpButton = (Button) findViewById(R.id.buttonAbout); tmpButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent aboutIntent = new Intent(MainActivity.this, AboutActivity.class); startActivity(aboutIntent); } }); } @Override public void onPause() { Log.d(LOG_TAG, "onPause()"); super.onPause(); } @Override public void onStop() { Log.d(LOG_TAG, "onStop()"); super.onStop(); } @Override public void onDestroy() { Log.d(LOG_TAG, "onDestroy()"); super.onDestroy(); AudioPlayer.destroy(); Emulator.destroy(); // check for auto save PreferenceFacade.DoAutoSave(getApplicationContext()); // clean temp dir or all files, just files for now // @TODO - full clean File tempFolder = new File(Environment.getExternalStorageDirectory().toString() + PreferenceFacade.DEFAULT_DIR_TEMPFILES + "/"); if (tempFolder.exists()) { String[] children = tempFolder.list(); for (int i=0; i<children.length; i++) { File tempFile = new File(tempFolder.getAbsoluteFile(), children[i]); if (tempFile.exists()) { tempFile.delete(); } } } _init = false; // garbage collect... help android out a bit System.gc(); } protected void spawnEmulatorActivity() { Intent myIntent = new Intent(MainActivity.this, EmulatorActivity.class); startActivity(myIntent); } protected void spawnFileChooser() { // spawn the file chooser Context context = getApplicationContext(); Intent myIntent = new Intent(MainActivity.this, FileChooser.class); myIntent.putExtra(FileChooser.EXTRA_START_DIR, PreferenceFacade.getRomDir(context)); myIntent.putExtra(FileChooser.EXTRA_EXTENSIONS, PreferenceFacade.DEFAULT_ROM_EXTENSIONS); myIntent.putExtra(FileChooser.EXTRA_TEMP_DIR, PreferenceFacade.getTempDir(context)); final int result=PreferenceFacade.MENU_ROM_SELECT; startActivityForResult(myIntent, result); } protected void spawnSettings() { // spawn the file chooser Intent myIntent = new Intent(MainActivity.this, SettingsActivity.class); final int result=PreferenceFacade.MENU_SETTINGS; startActivityForResult(myIntent, result); } @Override protected void onActivityResult(int requestCode,int resultCode,Intent data) { Log.d(LOG_TAG, "onActivityResult(" + requestCode + ", " + resultCode + ")"); if (resultCode == RESULT_CANCELED) { this.finish(); } else if (requestCode == PreferenceFacade.MENU_SETTINGS) { //PreferenceFacade.loadPrefs(this, getApplicationContext()); } else if (requestCode == PreferenceFacade.MENU_ROM_SELECT) { String romFile=data.getStringExtra(FileChooser.PAYLOAD_FILENAME); if (romFile != null) { PreferenceFacade.loadPrefs(this, getApplicationContext()); if (Emulator.loadRom(romFile) == 0) { // AutoLoad PreferenceFacade.DoAutoLoad(getApplicationContext()); spawnEmulatorActivity(); } } else { Toast.makeText(getApplicationContext(), "No rom selected!", Toast.LENGTH_SHORT).show(); } } super.onActivityResult(requestCode, resultCode, data); } }
zyking1987-genplus-droid
src/ca/halsafar/genesisdroid/MainActivity.java
Java
gpl2
14,797
package ca.halsafar.filechooser; import java.io.File; import java.io.FileInputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Stack; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import ca.halsafar.downloader.DecompressListener; import ca.halsafar.genesisdroid.Emulator; import ca.halsafar.genesisdroid.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.Button; import android.widget.ListView; import android.widget.Toast; /** * FileChooser for viewing any file * * Tutorial for doing this can be found at: * http://www.dreamincode.net/forums/topic/190013-creating-simple-file-chooser/ * * Modifies by halsafar to control backing out of the activity, pass in start dir and extensions * - also added fast scroll and proper sectioning * @author http://www.dreamincode.net/forums/topic/190013-creating-simple-file-chooser/ * */ public class FileChooser extends Activity implements DecompressListener { private static final String LOG_TAG = "FileChooser"; public static final String EXTRA_START_DIR = "StartDir"; public static final String EXTRA_EXTENSIONS = "Extensions"; public static final String EXTRA_TEMP_DIR = "TempDir"; public static final String EXTRA_SELECT_DIR = "SelectDir"; public static final String PAYLOAD_FILENAME = "Filename"; public static final String PAYLOAD_SELECTED_DIR = "DirSelected"; private File currentDir; private FileArrayAdapter adapter; private String _startDir; private String _extensions; private String _tempDir; private String _selectDir; private Stack<String> _dirStack; private ListView _view; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //LayoutInflater inflater = (LayoutInflater)(getApplicationContext()).getSystemService(Context.LAYOUT_INFLATER_SERVICE); //_view = inflater.inflate(R.layout.file_choose, this.getParent(), false); setContentView(R.layout.file_choose); _view = (ListView)findViewById(R.id.fileChooserView); _startDir = getIntent().getStringExtra(EXTRA_START_DIR); _extensions = getIntent().getStringExtra(EXTRA_EXTENSIONS); _tempDir = getIntent().getStringExtra(EXTRA_TEMP_DIR); _selectDir = getIntent().getStringExtra(EXTRA_SELECT_DIR); // clamp start dir and remove the / if (_startDir == null) { _startDir = Environment.getExternalStorageDirectory().getAbsolutePath(); } else if (_startDir.endsWith("/")) { _startDir = _startDir.substring(0, _startDir.length() - 1); } // push the start dir onto the stack _dirStack = new Stack<String>(); _dirStack.push(_startDir); // clamp extentions to all or extra specified if (_extensions == null) { _extensions = ".*"; } // clamp temp dir if (_tempDir == null) { _tempDir = Environment.getExternalStorageDirectory().getAbsolutePath(); } // regular filesystem dir currentDir = new File(_startDir); fill(currentDir); // are we dir selecting?, add button if (_selectDir == null) { // hide button Button b = (Button)findViewById(R.id.fileChooserSubmit); b.setVisibility(Button.GONE); } else { // add on click submit Button b = (Button)findViewById(R.id.fileChooserSubmit); b.setOnClickListener(new OnClickListener() { public void onClick(View v) { String s = _dirStack.peek(); Toast.makeText(FileChooser.this, "Selected: " + s, Toast.LENGTH_SHORT).show(); Intent intent=new Intent(); intent.putExtra(FileChooser.PAYLOAD_SELECTED_DIR, s); setResult(RESULT_OK, intent); finish(); } }); } } private void fill(File f) { File[]dirs = f.listFiles(); this.setTitle("Current Dir: "+f.getAbsolutePath()); List<Option>dir = new ArrayList<Option>(); List<Option>fls = new ArrayList<Option>(); try { for(File ff: dirs) { if(ff.isDirectory()) { dir.add(new Option(ff.getName() + "/","Folder",ff.getAbsolutePath())); } else { int dotIndex = ff.getName().lastIndexOf('.'); if (dotIndex > 0) { String extension = ff.getName().substring(dotIndex+1).toLowerCase(); if (extension.matches(_extensions)) { fls.add(new Option(ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath())); } } } } } catch(Exception e) { } Collections.sort(dir); Collections.sort(fls); dir.addAll(fls); //if(!f.getName().equalsIgnoreCase(Environment.getExternalStorageDirectory().getAbsolutePath())) //if (!f.getAbsolutePath().equalsIgnoreCase(_startDir)) { dir.add(0,new Option("..", "Parent Directory", f.getParent())); } adapter = new FileArrayAdapter(FileChooser.this,R.layout.file_view,dir); _view.setAdapter(adapter); _view.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int pos = arg0.getPositionForView(arg1); // TODO Auto-generated method stub //super.onListItemClick(l, v, position, id); Option o = adapter.getItem(pos); if(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")) { if (o.getPath() != null) { currentDir = new File(o.getPath()); fill(currentDir); _dirStack.push(o.getPath()); } } else { // check for startDir as zip file String path = o.getPath(); int dotIndex = path.lastIndexOf('.'); String ext = null; if (dotIndex >= 0) { ext = path.substring(dotIndex+1).toLowerCase(); } if (ext.matches("zip")) { // treat this like a zip file system fillFromZip(path); } else { onFileClick(o); } } } }); } private void fillFromZip(String zipFile) { Log.d(LOG_TAG, "fillFromZip(" + zipFile + ")"); try { FileInputStream fin = new FileInputStream(zipFile); ZipInputStream zin = new ZipInputStream(fin); ZipEntry ze = null; this.setTitle("Current Dir: "+zipFile); List<Option>dir = new ArrayList<Option>(); List<Option>fls = new ArrayList<Option>(); while ((ze = zin.getNextEntry()) != null) { if (ze.isDirectory()) { //_dirChecker(ze.getName()); } else { fls.add(new Option(ze.getName(), "File Size: "+ze.getSize(), zipFile )); } } zin.close(); Collections.sort(dir); Collections.sort(fls); dir.addAll(fls); adapter = new FileArrayAdapter(FileChooser.this,R.layout.file_view,dir); _view.setAdapter(adapter); _view.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int pos = arg0.getPositionForView(arg1); Option o = adapter.getItem(pos); Emulator.unzipFile(o.getPath(), o.getName(), _tempDir + "/" + o.getName()); Option newO = new Option(o.getName(), o.getData(), _tempDir + "/" + o.getName()); onFileClick(newO); } }); } catch (Exception e) { Log.e("Decompress", "unzip", e); } } private void onFileClick(Option o) { Toast.makeText(this, "File Clicked: "+o.getName(), Toast.LENGTH_SHORT).show(); Intent intent=new Intent(); intent.putExtra(FileChooser.PAYLOAD_FILENAME, o.getPath()); setResult(RESULT_OK, intent); finish(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { //moveTaskToBack(true); if (_dirStack.size() > 1) { _dirStack.pop(); File file = new File(_dirStack.peek()); currentDir = file; fill(currentDir); } else { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } // backing up to far /*if (currentDir.getPath().equals(_startDir)) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } else { Option o = adapter.getItem(0); currentDir = new File(o.getPath()); fill(currentDir); }*/ return true; } return super.onKeyDown(keyCode, event); } public void onDecompressSuccess(String filename, Integer numFiles) { Log.d(LOG_TAG, "onDecompressSuccess(" + filename + ", " + numFiles + ")"); } public void onDecompressFail(String filename) { Log.d(LOG_TAG, "onDecompressFail(" + filename + ")"); } }
zyking1987-genplus-droid
src/ca/halsafar/filechooser/FileChooser.java
Java
gpl2
12,545
package ca.halsafar.filechooser; /** * Based on: * @author http://www.dreamincode.net/forums/topic/190013-creating-simple-file-chooser/ * */ public class Option implements Comparable<Option>{ private String name; private String data; private String path; public Option(String n,String d,String p) { name = n; data = d; path = p; } public String getName() { return name; } public String getData() { return data; } public String getPath() { return path; } public int compareTo(Option o) { if(this.name != null) return this.name.toLowerCase().compareTo(o.getName().toLowerCase()); else throw new IllegalArgumentException(); } }
zyking1987-genplus-droid
src/ca/halsafar/filechooser/Option.java
Java
gpl2
830
package ca.halsafar.filechooser; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Set; import ca.halsafar.genesisdroid.R; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.SectionIndexer; import android.widget.TextView; /** * Based on tutorial from: * @author http://www.dreamincode.net/forums/topic/190013-creating-simple-file-chooser/ * */ public class FileArrayAdapter extends ArrayAdapter<Option> implements SectionIndexer { HashMap<String, Integer> alphaIndexer; String[] sections; private Context c; private int id; private List<Option>items; public FileArrayAdapter(Context context, int textViewResourceId, List<Option> objects) { super(context, textViewResourceId, objects); c = context; id = textViewResourceId; items = objects; initAlphaIndexer(); } private void initAlphaIndexer() { alphaIndexer = new HashMap<String, Integer>(); int size = items.size(); for (int x = 0; x < size; x++) { Option o = items.get(x); // get the first letter of the store String ch = o.getName().substring(0, 1); // convert to uppercase otherwise lowercase a -z will be sorted after upper A-Z ch = ch.toUpperCase(); // HashMap will prevent duplicates if (!alphaIndexer.containsKey(ch)) { alphaIndexer.put(ch, x); } } Set<String> sectionLetters = alphaIndexer.keySet(); // create a list from the set to sort ArrayList<String> sectionList = new ArrayList<String>(sectionLetters); Collections.sort(sectionList); sections = new String[sectionList.size()]; sectionList.toArray(sections); } public Option getItem(int i) { return items.get(i); } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final Option o = items.get(position); if (o != null) { TextView t1 = (TextView) v.findViewById(R.id.TextView01); TextView t2 = (TextView) v.findViewById(R.id.TextView02); if(t1!=null) { t1.setText(o.getName()); } if(t2!=null) { t2.setText(o.getData()); } } return v; } public int getPositionForSection(int section) { // TODO - find out why this happens but sometimes it asks for an invalid section if (section >= sections.length) { return 0; } return alphaIndexer.get(sections[section]); } public int getSectionForPosition(int position) { /*int prevIndex = 0; for(int i = 0; i < sections.length; i++) { if(getPositionForSection(i) > position && prevIndex <= position) { prevIndex = i; break; } prevIndex = i; } return prevIndex;*/ /*String ch = items.get(position).getName().substring(0, 1); for (int i = 0; i < sections.length; i++) { if (sections[i].equals(ch)) { return i; } } return -1; */ return 1; } public Object[] getSections() { return sections; } }
zyking1987-genplus-droid
src/ca/halsafar/filechooser/FileArrayAdapter.java
Java
gpl2
4,205
package ca.halsafar.widgets; import ca.halsafar.genesisdroid.R; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.preference.DialogPreference; import android.widget.SeekBar; import android.widget.TextView; import android.widget.SeekBar.OnSeekBarChangeListener; public final class SeekBarPreference extends DialogPreference implements OnSeekBarChangeListener { // Namespaces to read attributes private static final String PREFERENCE_NS = "http://schemas.android.com/apk/res/ca.halsafar.genesisdroid"; private static final String ANDROID_NS = "http://schemas.android.com/apk/res/android"; // Attribute names private static final String ATTR_DEFAULT_VALUE = "defaultValue"; private static final String ATTR_MIN_VALUE = "minValue"; private static final String ATTR_MAX_VALUE = "maxValue"; // Default values for defaults private static final int DEFAULT_CURRENT_VALUE = 50; private static final int DEFAULT_MIN_VALUE = 0; private static final int DEFAULT_MAX_VALUE = 100; // Real defaults private final int mDefaultValue; private final int mMaxValue; private final int mMinValue; // Current value private int mCurrentValue; // View elements private SeekBar mSeekBar; private TextView mValueText; //private String mOrgTitle; public SeekBarPreference(Context context, AttributeSet attrs) { super(context, attrs); // Read parameters from attributes mMinValue = attrs.getAttributeIntValue(PREFERENCE_NS, ATTR_MIN_VALUE, DEFAULT_MIN_VALUE); mMaxValue = attrs.getAttributeIntValue(PREFERENCE_NS, ATTR_MAX_VALUE, DEFAULT_MAX_VALUE); mDefaultValue = attrs.getAttributeIntValue(ANDROID_NS, ATTR_DEFAULT_VALUE, DEFAULT_CURRENT_VALUE); } @Override protected View onCreateView(ViewGroup parent) { return super.onCreateView(parent); } @Override protected View onCreateDialogView() { // Get current value from preferences mCurrentValue = getPersistedInt(mDefaultValue); // Inflate layout LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.dialog_slider, null); // Setup minimum and maximum text labels ((TextView) view.findViewById(R.id.min_value)).setText(Integer .toString(mMinValue)); ((TextView) view.findViewById(R.id.max_value)).setText(Integer .toString(mMaxValue)); // Setup SeekBar mSeekBar = (SeekBar) view.findViewById(R.id.seek_bar); mSeekBar.setMax(mMaxValue - mMinValue); mSeekBar.setProgress(mCurrentValue - mMinValue); mSeekBar.setOnSeekBarChangeListener(this); // Setup text label for current value mValueText = (TextView) view.findViewById(R.id.current_value); mValueText.setText(Integer.toString(mCurrentValue)); return view; } @Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); // Return if change was cancelled if (!positiveResult) { return; } // Persist current value if needed if (shouldPersist()) { persistInt(mCurrentValue); } // Notify activity about changes (to update preference summary line) notifyChanged(); } @Override public CharSequence getSummary() { // Format summary string with current value String summary = super.getSummary().toString(); int value = getPersistedInt(mDefaultValue); return String.format(summary, value); } public void onProgressChanged(SeekBar seek, int value, boolean fromTouch) { // Update current value mCurrentValue = value + mMinValue; // Update label with current value mValueText.setText(Integer.toString(mCurrentValue)); } public void onStartTrackingTouch(SeekBar seek) { // Not used } public void onStopTrackingTouch(SeekBar seek) { // Not used } }
zyking1987-genplus-droid
src/ca/halsafar/widgets/SeekBarPreference.java
Java
gpl2
4,772