Path: blob/main/misc/emulator/xnes/snes9x/fxinst.cpp
28515 views
/***********************************************************************************1Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.23(c) Copyright 1996 - 2002 Gary Henderson ([email protected]),4Jerremy Koot ([email protected])56(c) Copyright 2002 - 2004 Matthew Kendora78(c) Copyright 2002 - 2005 Peter Bortas ([email protected])910(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)1112(c) Copyright 2001 - 2006 John Weidman ([email protected])1314(c) Copyright 2002 - 2006 funkyass ([email protected]),15Kris Bleakley ([email protected])1617(c) Copyright 2002 - 2010 Brad Jorsch ([email protected]),18Nach ([email protected]),1920(c) Copyright 2002 - 2011 zones ([email protected])2122(c) Copyright 2006 - 2007 nitsuja2324(c) Copyright 2009 - 2011 BearOso,25OV2262728BS-X C emulator code29(c) Copyright 2005 - 2006 Dreamer Nom,30zones3132C4 x86 assembler and some C emulation code33(c) Copyright 2000 - 2003 _Demo_ ([email protected]),34Nach,35zsKnight ([email protected])3637C4 C++ code38(c) Copyright 2003 - 2006 Brad Jorsch,39Nach4041DSP-1 emulator code42(c) Copyright 1998 - 2006 _Demo_,43Andreas Naive ([email protected]),44Gary Henderson,45Ivar ([email protected]),46John Weidman,47Kris Bleakley,48Matthew Kendora,49Nach,50neviksti ([email protected])5152DSP-2 emulator code53(c) Copyright 2003 John Weidman,54Kris Bleakley,55Lord Nightmare ([email protected]),56Matthew Kendora,57neviksti5859DSP-3 emulator code60(c) Copyright 2003 - 2006 John Weidman,61Kris Bleakley,62Lancer,63z80 gaiden6465DSP-4 emulator code66(c) Copyright 2004 - 2006 Dreamer Nom,67John Weidman,68Kris Bleakley,69Nach,70z80 gaiden7172OBC1 emulator code73(c) Copyright 2001 - 2004 zsKnight,74pagefault ([email protected]),75Kris Bleakley76Ported from x86 assembler to C by sanmaiwashi7778SPC7110 and RTC C++ emulator code used in 1.39-1.5179(c) Copyright 2002 Matthew Kendora with research by80zsKnight,81John Weidman,82Dark Force8384SPC7110 and RTC C++ emulator code used in 1.52+85(c) Copyright 2009 byuu,86neviksti8788S-DD1 C emulator code89(c) Copyright 2003 Brad Jorsch with research by90Andreas Naive,91John Weidman9293S-RTC C emulator code94(c) Copyright 2001 - 2006 byuu,95John Weidman9697ST010 C++ emulator code98(c) Copyright 2003 Feather,99John Weidman,100Kris Bleakley,101Matthew Kendora102103Super FX x86 assembler emulator code104(c) Copyright 1998 - 2003 _Demo_,105pagefault,106zsKnight107108Super FX C emulator code109(c) Copyright 1997 - 1999 Ivar,110Gary Henderson,111John Weidman112113Sound emulator code used in 1.5-1.51114(c) Copyright 1998 - 2003 Brad Martin115(c) Copyright 1998 - 2006 Charles Bilyue'116117Sound emulator code used in 1.52+118(c) Copyright 2004 - 2007 Shay Green ([email protected])119120SH assembler code partly based on x86 assembler code121(c) Copyright 2002 - 2004 Marcus Comstedt ([email protected])1221232xSaI filter124(c) Copyright 1999 - 2001 Derek Liauw Kie Fa125126HQ2x, HQ3x, HQ4x filters127(c) Copyright 2003 Maxim Stepin ([email protected])128129NTSC filter130(c) Copyright 2006 - 2007 Shay Green131132GTK+ GUI code133(c) Copyright 2004 - 2011 BearOso134135Win32 GUI code136(c) Copyright 2003 - 2006 blip,137funkyass,138Matthew Kendora,139Nach,140nitsuja141(c) Copyright 2009 - 2011 OV2142143Mac OS GUI code144(c) Copyright 1998 - 2001 John Stiles145(c) Copyright 2001 - 2011 zones146147148Specific ports contains the works of other authors. See headers in149individual files.150151152Snes9x homepage: http://www.snes9x.com/153154Permission to use, copy, modify and/or distribute Snes9x in both binary155and source form, for non-commercial purposes, is hereby granted without156fee, providing that this license information and copyright notice appear157with all copies and any derived work.158159This software is provided 'as-is', without any express or implied160warranty. In no event shall the authors be held liable for any damages161arising from the use of this software or it's derivatives.162163Snes9x is freeware for PERSONAL USE only. Commercial users should164seek permission of the copyright holders first. Commercial use includes,165but is not limited to, charging money for Snes9x or software derived from166Snes9x, including Snes9x or derivatives in commercial game bundles, and/or167using Snes9x as a promotion for your commercial product.168169The copyright holders request that bug fixes and improvements to the code170should be forwarded to them so everyone can benefit from the modifications171in future versions.172173Super NES and Super Nintendo Entertainment System are trademarks of174Nintendo Co., Limited and its subsidiary companies.175***********************************************************************************/176177178#include "snes9x.h"179#include "fxinst.h"180#include "fxemu.h"181182// Set this define if you wish the plot instruction to check for y-pos limits (I don't think it's nessecary)183#define CHECK_LIMITS184185186/*187Codes used:188rn = a GSU register (r0 - r15)189#n = 4 bit immediate value190#pp = 8 bit immediate value191(yy) = 8 bit word address (0x0000 - 0x01fe)192#xx = 16 bit immediate value193(xx) = 16 bit address (0x0000 - 0xffff)194*/195196// 00 - stop - stop GSU execution (and maybe generate an IRQ)197static void fx_stop (void)198{199CF(G);200GSU.vCounter = 0;201GSU.vInstCount = GSU.vCounter;202203// Check if we need to generate an IRQ204if (!(GSU.pvRegisters[GSU_CFGR] & 0x80))205SF(IRQ);206207GSU.vPlotOptionReg = 0;208GSU.vPipe = 1;209CLRFLAGS;210R15++;211}212213// 01 - nop - no operation214static void fx_nop (void)215{216CLRFLAGS;217R15++;218}219220// 02 - cache - reintialize GSU cache221static void fx_cache (void)222{223uint32 c = R15 & 0xfff0;224225if (GSU.vCacheBaseReg != c || !GSU.bCacheActive)226{227fx_flushCache();228GSU.vCacheBaseReg = c;229GSU.bCacheActive = TRUE;230231#if 0232if (c < (0x10000 - 512))233{234const uint8 *t = &ROM(c);235memcpy(GSU.pvCache, t, 512);236}237else238{239const uint8 *t1, t2;240uint32 i = 0x10000 - c;241t1 = &ROM(c);242t2 = &ROM(0);243memcpy(GSU.pvCache, t1, i);244memcpy(&GSU.pvCache[i], t2, 512 - i);245}246#endif247}248249CLRFLAGS;250R15++;251}252253// 03 - lsr - logic shift right254static void fx_lsr (void)255{256uint32 v;257GSU.vCarry = SREG & 1;258v = USEX16(SREG) >> 1;259R15++;260DREG = v;261GSU.vSign = v;262GSU.vZero = v;263TESTR14;264CLRFLAGS;265}266267// 04 - rol - rotate left268static void fx_rol (void)269{270uint32 v = USEX16((SREG << 1) + GSU.vCarry);271GSU.vCarry = (SREG >> 15) & 1;272R15++;273DREG = v;274GSU.vSign = v;275GSU.vZero = v;276TESTR14;277CLRFLAGS;278}279280// 05 - bra - branch always281static void fx_bra (void)282{283uint8 v = PIPE;284R15++;285FETCHPIPE;286R15 += SEX8(v);287}288289// Branch on condition290#define BRA_COND(cond) \291uint8 v = PIPE; \292R15++; \293FETCHPIPE; \294if (cond) \295R15 += SEX8(v); \296else \297R15++298299#define TEST_S (GSU.vSign & 0x8000)300#define TEST_Z (USEX16(GSU.vZero) == 0)301#define TEST_OV (GSU.vOverflow >= 0x8000 || GSU.vOverflow < -0x8000)302#define TEST_CY (GSU.vCarry & 1)303304// 06 - blt - branch on less than305static void fx_blt (void)306{307BRA_COND((TEST_S != 0) != (TEST_OV != 0));308}309310// 07 - bge - branch on greater or equals311static void fx_bge (void)312{313BRA_COND((TEST_S != 0) == (TEST_OV != 0));314}315316// 08 - bne - branch on not equal317static void fx_bne (void)318{319BRA_COND(!TEST_Z);320}321322// 09 - beq - branch on equal323static void fx_beq (void)324{325BRA_COND(TEST_Z);326}327328// 0a - bpl - branch on plus329static void fx_bpl (void)330{331BRA_COND(!TEST_S);332}333334// 0b - bmi - branch on minus335static void fx_bmi (void)336{337BRA_COND(TEST_S);338}339340// 0c - bcc - branch on carry clear341static void fx_bcc (void)342{343BRA_COND(!TEST_CY);344}345346// 0d - bcs - branch on carry set347static void fx_bcs (void)348{349BRA_COND(TEST_CY);350}351352// 0e - bvc - branch on overflow clear353static void fx_bvc (void)354{355BRA_COND(!TEST_OV);356}357358// 0f - bvs - branch on overflow set359static void fx_bvs (void)360{361BRA_COND(TEST_OV);362}363364// 10-1f - to rn - set register n as destination register365// 10-1f (B) - move rn - move one register to another (if B flag is set)366#define FX_TO(reg) \367if (TF(B)) \368{ \369GSU.avReg[(reg)] = SREG; \370CLRFLAGS; \371} \372else \373GSU.pvDreg = &GSU.avReg[reg]; \374R15++375376#define FX_TO_R14(reg) \377if (TF(B)) \378{ \379GSU.avReg[(reg)] = SREG; \380CLRFLAGS; \381READR14; \382} \383else \384GSU.pvDreg = &GSU.avReg[reg]; \385R15++386387#define FX_TO_R15(reg) \388if (TF(B)) \389{ \390GSU.avReg[(reg)] = SREG; \391CLRFLAGS; \392} \393else \394{ \395GSU.pvDreg = &GSU.avReg[reg]; \396R15++; \397}398399static void fx_to_r0 (void)400{401FX_TO(0);402}403404static void fx_to_r1 (void)405{406FX_TO(1);407}408409static void fx_to_r2 (void)410{411FX_TO(2);412}413414static void fx_to_r3 (void)415{416FX_TO(3);417}418419static void fx_to_r4 (void)420{421FX_TO(4);422}423424static void fx_to_r5 (void)425{426FX_TO(5);427}428429static void fx_to_r6 (void)430{431FX_TO(6);432}433434static void fx_to_r7 (void)435{436FX_TO(7);437}438439static void fx_to_r8 (void)440{441FX_TO(8);442}443444static void fx_to_r9 (void)445{446FX_TO(9);447}448449static void fx_to_r10 (void)450{451FX_TO(10);452}453454static void fx_to_r11 (void)455{456FX_TO(11);457}458459static void fx_to_r12 (void)460{461FX_TO(12);462}463464static void fx_to_r13 (void)465{466FX_TO(13);467}468469static void fx_to_r14 (void)470{471FX_TO_R14(14);472}473474static void fx_to_r15 (void)475{476FX_TO_R15(15);477}478479// 20-2f - to rn - set register n as source and destination register480#define FX_WITH(reg) \481SF(B); \482GSU.pvSreg = GSU.pvDreg = &GSU.avReg[reg]; \483R15++484485static void fx_with_r0 (void)486{487FX_WITH(0);488}489490static void fx_with_r1 (void)491{492FX_WITH(1);493}494495static void fx_with_r2 (void)496{497FX_WITH(2);498}499500static void fx_with_r3 (void)501{502FX_WITH(3);503}504505static void fx_with_r4 (void)506{507FX_WITH(4);508}509510static void fx_with_r5 (void)511{512FX_WITH(5);513}514515static void fx_with_r6 (void)516{517FX_WITH(6);518}519520static void fx_with_r7 (void)521{522FX_WITH(7);523}524525static void fx_with_r8 (void)526{527FX_WITH(8);528}529530static void fx_with_r9 (void)531{532FX_WITH(9);533}534535static void fx_with_r10 (void)536{537FX_WITH(10);538}539540static void fx_with_r11 (void)541{542FX_WITH(11);543}544545static void fx_with_r12 (void)546{547FX_WITH(12);548}549550static void fx_with_r13 (void)551{552FX_WITH(13);553}554555static void fx_with_r14 (void)556{557FX_WITH(14);558}559560static void fx_with_r15 (void)561{562FX_WITH(15);563}564565// 30-3b - stw (rn) - store word566#define FX_STW(reg) \567GSU.vLastRamAdr = GSU.avReg[reg]; \568RAM(GSU.avReg[reg]) = (uint8) SREG; \569RAM(GSU.avReg[reg] ^ 1) = (uint8) (SREG >> 8); \570CLRFLAGS; \571R15++572573static void fx_stw_r0 (void)574{575FX_STW(0);576}577578static void fx_stw_r1 (void)579{580FX_STW(1);581}582583static void fx_stw_r2 (void)584{585FX_STW(2);586}587588static void fx_stw_r3 (void)589{590FX_STW(3);591}592593static void fx_stw_r4 (void)594{595FX_STW(4);596}597598static void fx_stw_r5 (void)599{600FX_STW(5);601}602603static void fx_stw_r6 (void)604{605FX_STW(6);606}607608static void fx_stw_r7 (void)609{610FX_STW(7);611}612613static void fx_stw_r8 (void)614{615FX_STW(8);616}617618static void fx_stw_r9 (void)619{620FX_STW(9);621}622623static void fx_stw_r10 (void)624{625FX_STW(10);626}627628static void fx_stw_r11 (void)629{630FX_STW(11);631}632633// 30-3b (ALT1) - stb (rn) - store byte634#define FX_STB(reg) \635GSU.vLastRamAdr = GSU.avReg[reg]; \636RAM(GSU.avReg[reg]) = (uint8) SREG; \637CLRFLAGS; \638R15++639640static void fx_stb_r0 (void)641{642FX_STB(0);643}644645static void fx_stb_r1 (void)646{647FX_STB(1);648}649650static void fx_stb_r2 (void)651{652FX_STB(2);653}654655static void fx_stb_r3 (void)656{657FX_STB(3);658}659660static void fx_stb_r4 (void)661{662FX_STB(4);663}664665static void fx_stb_r5 (void)666{667FX_STB(5);668}669670static void fx_stb_r6 (void)671{672FX_STB(6);673}674675static void fx_stb_r7 (void)676{677FX_STB(7);678}679680static void fx_stb_r8 (void)681{682FX_STB(8);683}684685static void fx_stb_r9 (void)686{687FX_STB(9);688}689690static void fx_stb_r10 (void)691{692FX_STB(10);693}694695static void fx_stb_r11 (void)696{697FX_STB(11);698}699700// 3c - loop - decrement loop counter, and branch on not zero701static void fx_loop (void)702{703GSU.vSign = GSU.vZero = --R12;704if ((uint16) R12 != 0)705R15 = R13;706else707R15++;708CLRFLAGS;709}710711// 3d - alt1 - set alt1 mode712static void fx_alt1 (void)713{714SF(ALT1);715CF(B);716R15++;717}718719// 3e - alt2 - set alt2 mode720static void fx_alt2 (void)721{722SF(ALT2);723CF(B);724R15++;725}726727// 3f - alt3 - set alt3 mode728static void fx_alt3 (void)729{730SF(ALT1);731SF(ALT2);732CF(B);733R15++;734}735736// 40-4b - ldw (rn) - load word from RAM737#define FX_LDW(reg) \738uint32 v; \739GSU.vLastRamAdr = GSU.avReg[reg]; \740v = (uint32) RAM(GSU.avReg[reg]); \741v |= ((uint32) RAM(GSU.avReg[reg] ^ 1)) << 8; \742R15++; \743DREG = v; \744TESTR14; \745CLRFLAGS746747static void fx_ldw_r0 (void)748{749FX_LDW(0);750}751752static void fx_ldw_r1 (void)753{754FX_LDW(1);755}756757static void fx_ldw_r2 (void)758{759FX_LDW(2);760}761762static void fx_ldw_r3 (void)763{764FX_LDW(3);765}766767static void fx_ldw_r4 (void)768{769FX_LDW(4);770}771772static void fx_ldw_r5 (void)773{774FX_LDW(5);775}776777static void fx_ldw_r6 (void)778{779FX_LDW(6);780}781782static void fx_ldw_r7 (void)783{784FX_LDW(7);785}786787static void fx_ldw_r8 (void)788{789FX_LDW(8);790}791792static void fx_ldw_r9 (void)793{794FX_LDW(9);795}796797static void fx_ldw_r10 (void)798{799FX_LDW(10);800}801802static void fx_ldw_r11 (void)803{804FX_LDW(11);805}806807// 40-4b (ALT1) - ldb (rn) - load byte808#define FX_LDB(reg) \809uint32 v; \810GSU.vLastRamAdr = GSU.avReg[reg]; \811v = (uint32) RAM(GSU.avReg[reg]); \812R15++; \813DREG = v; \814TESTR14; \815CLRFLAGS816817static void fx_ldb_r0 (void)818{819FX_LDB(0);820}821822static void fx_ldb_r1 (void)823{824FX_LDB(1);825}826827static void fx_ldb_r2 (void)828{829FX_LDB(2);830}831832static void fx_ldb_r3 (void)833{834FX_LDB(3);835}836837static void fx_ldb_r4 (void)838{839FX_LDB(4);840}841842static void fx_ldb_r5 (void)843{844FX_LDB(5);845}846847static void fx_ldb_r6 (void)848{849FX_LDB(6);850}851852static void fx_ldb_r7 (void)853{854FX_LDB(7);855}856857static void fx_ldb_r8 (void)858{859FX_LDB(8);860}861862static void fx_ldb_r9 (void)863{864FX_LDB(9);865}866867static void fx_ldb_r10 (void)868{869FX_LDB(10);870}871872static void fx_ldb_r11 (void)873{874FX_LDB(11);875}876877// 4c - plot - plot pixel with R1, R2 as x, y and the color register as the color878static void fx_plot_2bit (void)879{880uint32 x = USEX8(R1);881uint32 y = USEX8(R2);882uint8 *a;883uint8 v, c;884885R15++;886CLRFLAGS;887R1++;888889#ifdef CHECK_LIMITS890if (y >= GSU.vScreenHeight)891return;892#endif893894if (GSU.vPlotOptionReg & 0x02)895c = (x ^ y) & 1 ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg;896else897c = (uint8) GSU.vColorReg;898899if (!(GSU.vPlotOptionReg & 0x01) && !(c & 0xf))900return;901902a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);903v = 128 >> (x & 7);904905if (c & 0x01)906a[0] |= v;907else908a[0] &= ~v;909910if (c & 0x02)911a[1] |= v;912else913a[1] &= ~v;914}915916// 4c (ALT1) - rpix - read color of the pixel with R1, R2 as x, y917static void fx_rpix_2bit (void)918{919uint32 x = USEX8(R1);920uint32 y = USEX8(R2);921uint8 *a;922uint8 v;923924R15++;925CLRFLAGS;926927#ifdef CHECK_LIMITS928if (y >= GSU.vScreenHeight)929return;930#endif931932a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);933v = 128 >> (x & 7);934935DREG = 0;936DREG |= ((uint32) ((a[0] & v) != 0)) << 0;937DREG |= ((uint32) ((a[1] & v) != 0)) << 1;938TESTR14;939}940941// 4c - plot - plot pixel with R1, R2 as x, y and the color register as the color942static void fx_plot_4bit (void)943{944uint32 x = USEX8(R1);945uint32 y = USEX8(R2);946uint8 *a;947uint8 v, c;948949R15++;950CLRFLAGS;951R1++;952953#ifdef CHECK_LIMITS954if (y >= GSU.vScreenHeight)955return;956#endif957958if (GSU.vPlotOptionReg & 0x02)959c = (x ^ y) & 1 ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg;960else961c = (uint8) GSU.vColorReg;962963if (!(GSU.vPlotOptionReg & 0x01) && !(c & 0xf))964return;965966a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);967v = 128 >> (x & 7);968969if (c & 0x01)970a[0x00] |= v;971else972a[0x00] &= ~v;973974if (c & 0x02)975a[0x01] |= v;976else977a[0x01] &= ~v;978979if (c & 0x04)980a[0x10] |= v;981else982a[0x10] &= ~v;983984if (c & 0x08)985a[0x11] |= v;986else987a[0x11] &= ~v;988}989990// 4c (ALT1) - rpix - read color of the pixel with R1, R2 as x, y991static void fx_rpix_4bit (void)992{993uint32 x = USEX8(R1);994uint32 y = USEX8(R2);995uint8 *a;996uint8 v;997998R15++;999CLRFLAGS;10001001#ifdef CHECK_LIMITS1002if (y >= GSU.vScreenHeight)1003return;1004#endif10051006a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);1007v = 128 >> (x & 7);10081009DREG = 0;1010DREG |= ((uint32) ((a[0x00] & v) != 0)) << 0;1011DREG |= ((uint32) ((a[0x01] & v) != 0)) << 1;1012DREG |= ((uint32) ((a[0x10] & v) != 0)) << 2;1013DREG |= ((uint32) ((a[0x11] & v) != 0)) << 3;1014TESTR14;1015}10161017// 4c - plot - plot pixel with R1, R2 as x, y and the color register as the color1018static void fx_plot_8bit (void)1019{1020uint32 x = USEX8(R1);1021uint32 y = USEX8(R2);1022uint8 *a;1023uint8 v, c;10241025R15++;1026CLRFLAGS;1027R1++;10281029#ifdef CHECK_LIMITS1030if (y >= GSU.vScreenHeight)1031return;1032#endif10331034c = (uint8) GSU.vColorReg;1035if (!(GSU.vPlotOptionReg & 0x10))1036{1037if (!(GSU.vPlotOptionReg & 0x01) && !(c & 0xf))1038return;1039}1040else1041if (!(GSU.vPlotOptionReg & 0x01) && !c)1042return;10431044a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);1045v = 128 >> (x & 7);10461047if (c & 0x01)1048a[0x00] |= v;1049else1050a[0x00] &= ~v;10511052if (c & 0x02)1053a[0x01] |= v;1054else1055a[0x01] &= ~v;10561057if (c & 0x04)1058a[0x10] |= v;1059else1060a[0x10] &= ~v;10611062if (c & 0x08)1063a[0x11] |= v;1064else1065a[0x11] &= ~v;10661067if (c & 0x10)1068a[0x20] |= v;1069else1070a[0x20] &= ~v;10711072if (c & 0x20)1073a[0x21] |= v;1074else1075a[0x21] &= ~v;10761077if (c & 0x40)1078a[0x30] |= v;1079else1080a[0x30] &= ~v;10811082if (c & 0x80)1083a[0x31] |= v;1084else1085a[0x31] &= ~v;1086}10871088// 4c (ALT1) - rpix - read color of the pixel with R1, R2 as x, y1089static void fx_rpix_8bit (void)1090{1091uint32 x = USEX8(R1);1092uint32 y = USEX8(R2);1093uint8 *a;1094uint8 v;10951096R15++;1097CLRFLAGS;10981099#ifdef CHECK_LIMITS1100if (y >= GSU.vScreenHeight)1101return;1102#endif11031104a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1);1105v = 128 >> (x & 7);11061107DREG = 0;1108DREG |= ((uint32) ((a[0x00] & v) != 0)) << 0;1109DREG |= ((uint32) ((a[0x01] & v) != 0)) << 1;1110DREG |= ((uint32) ((a[0x10] & v) != 0)) << 2;1111DREG |= ((uint32) ((a[0x11] & v) != 0)) << 3;1112DREG |= ((uint32) ((a[0x20] & v) != 0)) << 4;1113DREG |= ((uint32) ((a[0x21] & v) != 0)) << 5;1114DREG |= ((uint32) ((a[0x30] & v) != 0)) << 6;1115DREG |= ((uint32) ((a[0x31] & v) != 0)) << 7;1116GSU.vZero = DREG;1117TESTR14;1118}11191120// 4c - plot - plot pixel with R1, R2 as x, y and the color register as the color1121static void fx_plot_obj (void)1122{1123#ifdef DEBUGGER1124fprintf(stderr, "ERROR fx_plot_obj called\n");1125#endif1126}11271128// 4c (ALT1) - rpix - read color of the pixel with R1, R2 as x, y1129static void fx_rpix_obj (void)1130{1131#ifdef DEBUGGER1132fprintf(stderr, "ERROR fx_rpix_obj called\n");1133#endif1134}11351136// 4d - swap - swap upper and lower byte of a register1137static void fx_swap (void)1138{1139uint8 c = (uint8) SREG;1140uint8 d = (uint8) (SREG >> 8);1141uint32 v = (((uint32) c) << 8) | ((uint32) d);1142R15++;1143DREG = v;1144GSU.vSign = v;1145GSU.vZero = v;1146TESTR14;1147CLRFLAGS;1148}11491150// 4e - color - copy source register to color register1151static void fx_color (void)1152{1153uint8 c = (uint8) SREG;11541155if (GSU.vPlotOptionReg & 0x04)1156c = (c & 0xf0) | (c >> 4);1157if (GSU.vPlotOptionReg & 0x08)1158{1159GSU.vColorReg &= 0xf0;1160GSU.vColorReg |= c & 0x0f;1161}1162else1163GSU.vColorReg = USEX8(c);11641165CLRFLAGS;1166R15++;1167}11681169// 4e (ALT1) - cmode - set plot option register1170static void fx_cmode (void)1171{1172GSU.vPlotOptionReg = SREG;11731174if (GSU.vPlotOptionReg & 0x10)1175GSU.vScreenHeight = 256; // OBJ Mode (for drawing into sprites)1176else1177GSU.vScreenHeight = GSU.vScreenRealHeight;11781179fx_computeScreenPointers();1180CLRFLAGS;1181R15++;1182}11831184// 4f - not - perform exclusive exor with 1 on all bits1185static void fx_not (void)1186{1187uint32 v = ~SREG;1188R15++;1189DREG = v;1190GSU.vSign = v;1191GSU.vZero = v;1192TESTR14;1193CLRFLAGS;1194}11951196// 50-5f - add rn - add, register + register1197#define FX_ADD(reg) \1198int32 s = SUSEX16(SREG) + SUSEX16(GSU.avReg[reg]); \1199GSU.vCarry = s >= 0x10000; \1200GSU.vOverflow = ~(SREG ^ GSU.avReg[reg]) & (GSU.avReg[reg] ^ s) & 0x8000; \1201GSU.vSign = s; \1202GSU.vZero = s; \1203R15++; \1204DREG = s; \1205TESTR14; \1206CLRFLAGS12071208static void fx_add_r0 (void)1209{1210FX_ADD(0);1211}12121213static void fx_add_r1 (void)1214{1215FX_ADD(1);1216}12171218static void fx_add_r2 (void)1219{1220FX_ADD(2);1221}12221223static void fx_add_r3 (void)1224{1225FX_ADD(3);1226}12271228static void fx_add_r4 (void)1229{1230FX_ADD(4);1231}12321233static void fx_add_r5 (void)1234{1235FX_ADD(5);1236}12371238static void fx_add_r6 (void)1239{1240FX_ADD(6);1241}12421243static void fx_add_r7 (void)1244{1245FX_ADD(7);1246}12471248static void fx_add_r8 (void)1249{1250FX_ADD(8);1251}12521253static void fx_add_r9 (void)1254{1255FX_ADD(9);1256}12571258static void fx_add_r10 (void)1259{1260FX_ADD(10);1261}12621263static void fx_add_r11 (void)1264{1265FX_ADD(11);1266}12671268static void fx_add_r12 (void)1269{1270FX_ADD(12);1271}12721273static void fx_add_r13 (void)1274{1275FX_ADD(13);1276}12771278static void fx_add_r14 (void)1279{1280FX_ADD(14);1281}12821283static void fx_add_r15 (void)1284{1285FX_ADD(15);1286}12871288// 50-5f (ALT1) - adc rn - add with carry, register + register1289#define FX_ADC(reg) \1290int32 s = SUSEX16(SREG) + SUSEX16(GSU.avReg[reg]) + SEX16(GSU.vCarry); \1291GSU.vCarry = s >= 0x10000; \1292GSU.vOverflow = ~(SREG ^ GSU.avReg[reg]) & (GSU.avReg[reg] ^ s) & 0x8000; \1293GSU.vSign = s; \1294GSU.vZero = s; \1295R15++; \1296DREG = s; \1297TESTR14; \1298CLRFLAGS12991300static void fx_adc_r0 (void)1301{1302FX_ADC(0);1303}13041305static void fx_adc_r1 (void)1306{1307FX_ADC(1);1308}13091310static void fx_adc_r2 (void)1311{1312FX_ADC(2);1313}13141315static void fx_adc_r3 (void)1316{1317FX_ADC(3);1318}13191320static void fx_adc_r4 (void)1321{1322FX_ADC(4);1323}13241325static void fx_adc_r5 (void)1326{1327FX_ADC(5);1328}13291330static void fx_adc_r6 (void)1331{1332FX_ADC(6);1333}13341335static void fx_adc_r7 (void)1336{1337FX_ADC(7);1338}13391340static void fx_adc_r8 (void)1341{1342FX_ADC(8);1343}13441345static void fx_adc_r9 (void)1346{1347FX_ADC(9);1348}13491350static void fx_adc_r10 (void)1351{1352FX_ADC(10);1353}13541355static void fx_adc_r11 (void)1356{1357FX_ADC(11);1358}13591360static void fx_adc_r12 (void)1361{1362FX_ADC(12);1363}13641365static void fx_adc_r13 (void)1366{1367FX_ADC(13);1368}13691370static void fx_adc_r14 (void)1371{1372FX_ADC(14);1373}13741375static void fx_adc_r15 (void)1376{1377FX_ADC(15);1378}13791380// 50-5f (ALT2) - add #n - add, register + immediate1381#define FX_ADD_I(imm) \1382int32 s = SUSEX16(SREG) + imm; \1383GSU.vCarry = s >= 0x10000; \1384GSU.vOverflow = ~(SREG ^ imm) & (imm ^ s) & 0x8000; \1385GSU.vSign = s; \1386GSU.vZero = s; \1387R15++; \1388DREG = s; \1389TESTR14; \1390CLRFLAGS13911392static void fx_add_i0 (void)1393{1394FX_ADD_I(0);1395}13961397static void fx_add_i1 (void)1398{1399FX_ADD_I(1);1400}14011402static void fx_add_i2 (void)1403{1404FX_ADD_I(2);1405}14061407static void fx_add_i3 (void)1408{1409FX_ADD_I(3);1410}14111412static void fx_add_i4 (void)1413{1414FX_ADD_I(4);1415}14161417static void fx_add_i5 (void)1418{1419FX_ADD_I(5);1420}14211422static void fx_add_i6 (void)1423{1424FX_ADD_I(6);1425}14261427static void fx_add_i7 (void)1428{1429FX_ADD_I(7);1430}14311432static void fx_add_i8 (void)1433{1434FX_ADD_I(8);1435}14361437static void fx_add_i9 (void)1438{1439FX_ADD_I(9);1440}14411442static void fx_add_i10 (void)1443{1444FX_ADD_I(10);1445}14461447static void fx_add_i11 (void)1448{1449FX_ADD_I(11);1450}14511452static void fx_add_i12 (void)1453{1454FX_ADD_I(12);1455}14561457static void fx_add_i13 (void)1458{1459FX_ADD_I(13);1460}14611462static void fx_add_i14 (void)1463{1464FX_ADD_I(14);1465}14661467static void fx_add_i15 (void)1468{1469FX_ADD_I(15);1470}14711472// 50-5f (ALT3) - adc #n - add with carry, register + immediate1473#define FX_ADC_I(imm) \1474int32 s = SUSEX16(SREG) + imm + SUSEX16(GSU.vCarry); \1475GSU.vCarry = s >= 0x10000; \1476GSU.vOverflow = ~(SREG ^ imm) & (imm ^ s) & 0x8000; \1477GSU.vSign = s; \1478GSU.vZero = s; \1479R15++; \1480DREG = s; \1481TESTR14; \1482CLRFLAGS14831484static void fx_adc_i0 (void)1485{1486FX_ADC_I(0);1487}14881489static void fx_adc_i1 (void)1490{1491FX_ADC_I(1);1492}14931494static void fx_adc_i2 (void)1495{1496FX_ADC_I(2);1497}14981499static void fx_adc_i3 (void)1500{1501FX_ADC_I(3);1502}15031504static void fx_adc_i4 (void)1505{1506FX_ADC_I(4);1507}15081509static void fx_adc_i5 (void)1510{1511FX_ADC_I(5);1512}15131514static void fx_adc_i6 (void)1515{1516FX_ADC_I(6);1517}15181519static void fx_adc_i7 (void)1520{1521FX_ADC_I(7);1522}15231524static void fx_adc_i8 (void)1525{1526FX_ADC_I(8);1527}15281529static void fx_adc_i9 (void)1530{1531FX_ADC_I(9);1532}15331534static void fx_adc_i10 (void)1535{1536FX_ADC_I(10);1537}15381539static void fx_adc_i11 (void)1540{1541FX_ADC_I(11);1542}15431544static void fx_adc_i12 (void)1545{1546FX_ADC_I(12);1547}15481549static void fx_adc_i13 (void)1550{1551FX_ADC_I(13);1552}15531554static void fx_adc_i14 (void)1555{1556FX_ADC_I(14);1557}15581559static void fx_adc_i15 (void)1560{1561FX_ADC_I(15);1562}15631564// 60-6f - sub rn - subtract, register - register1565#define FX_SUB(reg) \1566int32 s = SUSEX16(SREG) - SUSEX16(GSU.avReg[reg]); \1567GSU.vCarry = s >= 0; \1568GSU.vOverflow = (SREG ^ GSU.avReg[reg]) & (SREG ^ s) & 0x8000; \1569GSU.vSign = s; \1570GSU.vZero = s; \1571R15++; \1572DREG = s; \1573TESTR14; \1574CLRFLAGS15751576static void fx_sub_r0 (void)1577{1578FX_SUB(0);1579}15801581static void fx_sub_r1 (void)1582{1583FX_SUB(1);1584}15851586static void fx_sub_r2 (void)1587{1588FX_SUB(2);1589}15901591static void fx_sub_r3 (void)1592{1593FX_SUB(3);1594}15951596static void fx_sub_r4 (void)1597{1598FX_SUB(4);1599}16001601static void fx_sub_r5 (void)1602{1603FX_SUB(5);1604}16051606static void fx_sub_r6 (void)1607{1608FX_SUB(6);1609}16101611static void fx_sub_r7 (void)1612{1613FX_SUB(7);1614}16151616static void fx_sub_r8 (void)1617{1618FX_SUB(8);1619}16201621static void fx_sub_r9 (void)1622{1623FX_SUB(9);1624}16251626static void fx_sub_r10 (void)1627{1628FX_SUB(10);1629}16301631static void fx_sub_r11 (void)1632{1633FX_SUB(11);1634}16351636static void fx_sub_r12 (void)1637{1638FX_SUB(12);1639}16401641static void fx_sub_r13 (void)1642{1643FX_SUB(13);1644}16451646static void fx_sub_r14 (void)1647{1648FX_SUB(14);1649}16501651static void fx_sub_r15 (void)1652{1653FX_SUB(15);1654}16551656// 60-6f (ALT1) - sbc rn - subtract with carry, register - register1657#define FX_SBC(reg) \1658int32 s = SUSEX16(SREG) - SUSEX16(GSU.avReg[reg]) - (SUSEX16(GSU.vCarry ^ 1)); \1659GSU.vCarry = s >= 0; \1660GSU.vOverflow = (SREG ^ GSU.avReg[reg]) & (SREG ^ s) & 0x8000; \1661GSU.vSign = s; \1662GSU.vZero = s; \1663R15++; \1664DREG = s; \1665TESTR14; \1666CLRFLAGS16671668static void fx_sbc_r0 (void)1669{1670FX_SBC(0);1671}16721673static void fx_sbc_r1 (void)1674{1675FX_SBC(1);1676}16771678static void fx_sbc_r2 (void)1679{1680FX_SBC(2);1681}16821683static void fx_sbc_r3 (void)1684{1685FX_SBC(3);1686}16871688static void fx_sbc_r4 (void)1689{1690FX_SBC(4);1691}16921693static void fx_sbc_r5 (void)1694{1695FX_SBC(5);1696}16971698static void fx_sbc_r6 (void)1699{1700FX_SBC(6);1701}17021703static void fx_sbc_r7 (void)1704{1705FX_SBC(7);1706}17071708static void fx_sbc_r8 (void)1709{1710FX_SBC(8);1711}17121713static void fx_sbc_r9 (void)1714{1715FX_SBC(9);1716}17171718static void fx_sbc_r10 (void)1719{1720FX_SBC(10);1721}17221723static void fx_sbc_r11 (void)1724{1725FX_SBC(11);1726}17271728static void fx_sbc_r12 (void)1729{1730FX_SBC(12);1731}17321733static void fx_sbc_r13 (void)1734{1735FX_SBC(13);1736}17371738static void fx_sbc_r14 (void)1739{1740FX_SBC(14);1741}17421743static void fx_sbc_r15 (void)1744{1745FX_SBC(15);1746}17471748// 60-6f (ALT2) - sub #n - subtract, register - immediate1749#define FX_SUB_I(imm) \1750int32 s = SUSEX16(SREG) - imm; \1751GSU.vCarry = s >= 0; \1752GSU.vOverflow = (SREG ^ imm) & (SREG ^ s) & 0x8000; \1753GSU.vSign = s; \1754GSU.vZero = s; \1755R15++; \1756DREG = s; \1757TESTR14; \1758CLRFLAGS17591760static void fx_sub_i0 (void)1761{1762FX_SUB_I(0);1763}17641765static void fx_sub_i1 (void)1766{1767FX_SUB_I(1);1768}17691770static void fx_sub_i2 (void)1771{1772FX_SUB_I(2);1773}17741775static void fx_sub_i3 (void)1776{1777FX_SUB_I(3);1778}17791780static void fx_sub_i4 (void)1781{1782FX_SUB_I(4);1783}17841785static void fx_sub_i5 (void)1786{1787FX_SUB_I(5);1788}17891790static void fx_sub_i6 (void)1791{1792FX_SUB_I(6);1793}17941795static void fx_sub_i7 (void)1796{1797FX_SUB_I(7);1798}17991800static void fx_sub_i8 (void)1801{1802FX_SUB_I(8);1803}18041805static void fx_sub_i9 (void)1806{1807FX_SUB_I(9);1808}18091810static void fx_sub_i10 (void)1811{1812FX_SUB_I(10);1813}18141815static void fx_sub_i11 (void)1816{1817FX_SUB_I(11);1818}18191820static void fx_sub_i12 (void)1821{1822FX_SUB_I(12);1823}18241825static void fx_sub_i13 (void)1826{1827FX_SUB_I(13);1828}18291830static void fx_sub_i14 (void)1831{1832FX_SUB_I(14);1833}18341835static void fx_sub_i15 (void)1836{1837FX_SUB_I(15);1838}18391840// 60-6f (ALT3) - cmp rn - compare, register, register1841#define FX_CMP(reg) \1842int32 s = SUSEX16(SREG) - SUSEX16(GSU.avReg[reg]); \1843GSU.vCarry = s >= 0; \1844GSU.vOverflow = (SREG ^ GSU.avReg[reg]) & (SREG ^ s) & 0x8000; \1845GSU.vSign = s; \1846GSU.vZero = s; \1847R15++; \1848CLRFLAGS18491850static void fx_cmp_r0 (void)1851{1852FX_CMP(0);1853}18541855static void fx_cmp_r1 (void)1856{1857FX_CMP(1);1858}18591860static void fx_cmp_r2 (void)1861{1862FX_CMP(2);1863}18641865static void fx_cmp_r3 (void)1866{1867FX_CMP(3);1868}18691870static void fx_cmp_r4 (void)1871{1872FX_CMP(4);1873}18741875static void fx_cmp_r5 (void)1876{1877FX_CMP(5);1878}18791880static void fx_cmp_r6 (void)1881{1882FX_CMP(6);1883}18841885static void fx_cmp_r7 (void)1886{1887FX_CMP(7);1888}18891890static void fx_cmp_r8 (void)1891{1892FX_CMP(8);1893}18941895static void fx_cmp_r9 (void)1896{1897FX_CMP(9);1898}18991900static void fx_cmp_r10 (void)1901{1902FX_CMP(10);1903}19041905static void fx_cmp_r11 (void)1906{1907FX_CMP(11);1908}19091910static void fx_cmp_r12 (void)1911{1912FX_CMP(12);1913}19141915static void fx_cmp_r13 (void)1916{1917FX_CMP(13);1918}19191920static void fx_cmp_r14 (void)1921{1922FX_CMP(14);1923}19241925static void fx_cmp_r15 (void)1926{1927FX_CMP(15);1928}19291930// 70 - merge - R7 as upper byte, R8 as lower byte (used for texture-mapping)1931static void fx_merge (void)1932{1933uint32 v = (R7 & 0xff00) | ((R8 & 0xff00) >> 8);1934R15++;1935DREG = v;1936GSU.vOverflow = (v & 0xc0c0) << 16;1937GSU.vZero = !(v & 0xf0f0);1938GSU.vSign = ((v | (v << 8)) & 0x8000);1939GSU.vCarry = (v & 0xe0e0) != 0;1940TESTR14;1941CLRFLAGS;1942}19431944// 71-7f - and rn - reister & register1945#define FX_AND(reg) \1946uint32 v = SREG & GSU.avReg[reg]; \1947R15++; \1948DREG = v; \1949GSU.vSign = v; \1950GSU.vZero = v; \1951TESTR14; \1952CLRFLAGS19531954static void fx_and_r1 (void)1955{1956FX_AND(1);1957}19581959static void fx_and_r2 (void)1960{1961FX_AND(2);1962}19631964static void fx_and_r3 (void)1965{1966FX_AND(3);1967}19681969static void fx_and_r4 (void)1970{1971FX_AND(4);1972}19731974static void fx_and_r5 (void)1975{1976FX_AND(5);1977}19781979static void fx_and_r6 (void)1980{1981FX_AND(6);1982}19831984static void fx_and_r7 (void)1985{1986FX_AND(7);1987}19881989static void fx_and_r8 (void)1990{1991FX_AND(8);1992}19931994static void fx_and_r9 (void)1995{1996FX_AND(9);1997}19981999static void fx_and_r10 (void)2000{2001FX_AND(10);2002}20032004static void fx_and_r11 (void)2005{2006FX_AND(11);2007}20082009static void fx_and_r12 (void)2010{2011FX_AND(12);2012}20132014static void fx_and_r13 (void)2015{2016FX_AND(13);2017}20182019static void fx_and_r14 (void)2020{2021FX_AND(14);2022}20232024static void fx_and_r15 (void)2025{2026FX_AND(15);2027}20282029// 71-7f (ALT1) - bic rn - reister & ~register2030#define FX_BIC(reg) \2031uint32 v = SREG & ~GSU.avReg[reg]; \2032R15++; \2033DREG = v; \2034GSU.vSign = v; \2035GSU.vZero = v; \2036TESTR14; \2037CLRFLAGS20382039static void fx_bic_r1 (void)2040{2041FX_BIC(1);2042}20432044static void fx_bic_r2 (void)2045{2046FX_BIC(2);2047}20482049static void fx_bic_r3 (void)2050{2051FX_BIC(3);2052}20532054static void fx_bic_r4 (void)2055{2056FX_BIC(4);2057}20582059static void fx_bic_r5 (void)2060{2061FX_BIC(5);2062}20632064static void fx_bic_r6 (void)2065{2066FX_BIC(6);2067}20682069static void fx_bic_r7 (void)2070{2071FX_BIC(7);2072}20732074static void fx_bic_r8 (void)2075{2076FX_BIC(8);2077}20782079static void fx_bic_r9 (void)2080{2081FX_BIC(9);2082}20832084static void fx_bic_r10 (void)2085{2086FX_BIC(10);2087}20882089static void fx_bic_r11 (void)2090{2091FX_BIC(11);2092}20932094static void fx_bic_r12 (void)2095{2096FX_BIC(12);2097}20982099static void fx_bic_r13 (void)2100{2101FX_BIC(13);2102}21032104static void fx_bic_r14 (void)2105{2106FX_BIC(14);2107}21082109static void fx_bic_r15 (void)2110{2111FX_BIC(15);2112}21132114// 71-7f (ALT2) - and #n - reister & immediate2115#define FX_AND_I(imm) \2116uint32 v = SREG & imm; \2117R15++; \2118DREG = v; \2119GSU.vSign = v; \2120GSU.vZero = v; \2121TESTR14; \2122CLRFLAGS21232124static void fx_and_i1 (void)2125{2126FX_AND_I(1);2127}21282129static void fx_and_i2 (void)2130{2131FX_AND_I(2);2132}21332134static void fx_and_i3 (void)2135{2136FX_AND_I(3);2137}21382139static void fx_and_i4 (void)2140{2141FX_AND_I(4);2142}21432144static void fx_and_i5 (void)2145{2146FX_AND_I(5);2147}21482149static void fx_and_i6 (void)2150{2151FX_AND_I(6);2152}21532154static void fx_and_i7 (void)2155{2156FX_AND_I(7);2157}21582159static void fx_and_i8 (void)2160{2161FX_AND_I(8);2162}21632164static void fx_and_i9 (void)2165{2166FX_AND_I(9);2167}21682169static void fx_and_i10 (void)2170{2171FX_AND_I(10);2172}21732174static void fx_and_i11 (void)2175{2176FX_AND_I(11);2177}21782179static void fx_and_i12 (void)2180{2181FX_AND_I(12);2182}21832184static void fx_and_i13 (void)2185{2186FX_AND_I(13);2187}21882189static void fx_and_i14 (void)2190{2191FX_AND_I(14);2192}21932194static void fx_and_i15 (void)2195{2196FX_AND_I(15);2197}21982199// 71-7f (ALT3) - bic #n - reister & ~immediate2200#define FX_BIC_I(imm) \2201uint32 v = SREG & ~imm; \2202R15++; \2203DREG = v; \2204GSU.vSign = v; \2205GSU.vZero = v; \2206TESTR14; \2207CLRFLAGS22082209static void fx_bic_i1 (void)2210{2211FX_BIC_I(1);2212}22132214static void fx_bic_i2 (void)2215{2216FX_BIC_I(2);2217}22182219static void fx_bic_i3 (void)2220{2221FX_BIC_I(3);2222}22232224static void fx_bic_i4 (void)2225{2226FX_BIC_I(4);2227}22282229static void fx_bic_i5 (void)2230{2231FX_BIC_I(5);2232}22332234static void fx_bic_i6 (void)2235{2236FX_BIC_I(6);2237}22382239static void fx_bic_i7 (void)2240{2241FX_BIC_I(7);2242}22432244static void fx_bic_i8 (void)2245{2246FX_BIC_I(8);2247}22482249static void fx_bic_i9 (void)2250{2251FX_BIC_I(9);2252}22532254static void fx_bic_i10 (void)2255{2256FX_BIC_I(10);2257}22582259static void fx_bic_i11 (void)2260{2261FX_BIC_I(11);2262}22632264static void fx_bic_i12 (void)2265{2266FX_BIC_I(12);2267}22682269static void fx_bic_i13 (void)2270{2271FX_BIC_I(13);2272}22732274static void fx_bic_i14 (void)2275{2276FX_BIC_I(14);2277}22782279static void fx_bic_i15 (void)2280{2281FX_BIC_I(15);2282}22832284// 80-8f - mult rn - 8 bit to 16 bit signed multiply, register * register2285#define FX_MULT(reg) \2286uint32 v = (uint32) (SEX8(SREG) * SEX8(GSU.avReg[reg])); \2287R15++; \2288DREG = v; \2289GSU.vSign = v; \2290GSU.vZero = v; \2291TESTR14; \2292CLRFLAGS22932294static void fx_mult_r0 (void)2295{2296FX_MULT(0);2297}22982299static void fx_mult_r1 (void)2300{2301FX_MULT(1);2302}23032304static void fx_mult_r2 (void)2305{2306FX_MULT(2);2307}23082309static void fx_mult_r3 (void)2310{2311FX_MULT(3);2312}23132314static void fx_mult_r4 (void)2315{2316FX_MULT(4);2317}23182319static void fx_mult_r5 (void)2320{2321FX_MULT(5);2322}23232324static void fx_mult_r6 (void)2325{2326FX_MULT(6);2327}23282329static void fx_mult_r7 (void)2330{2331FX_MULT(7);2332}23332334static void fx_mult_r8 (void)2335{2336FX_MULT(8);2337}23382339static void fx_mult_r9 (void)2340{2341FX_MULT(9);2342}23432344static void fx_mult_r10 (void)2345{2346FX_MULT(10);2347}23482349static void fx_mult_r11 (void)2350{2351FX_MULT(11);2352}23532354static void fx_mult_r12 (void)2355{2356FX_MULT(12);2357}23582359static void fx_mult_r13 (void)2360{2361FX_MULT(13);2362}23632364static void fx_mult_r14 (void)2365{2366FX_MULT(14);2367}23682369static void fx_mult_r15 (void)2370{2371FX_MULT(15);2372}23732374// 80-8f (ALT1) - umult rn - 8 bit to 16 bit unsigned multiply, register * register2375#define FX_UMULT(reg) \2376uint32 v = USEX8(SREG) * USEX8(GSU.avReg[reg]); \2377R15++; \2378DREG = v; \2379GSU.vSign = v; \2380GSU.vZero = v; \2381TESTR14; \2382CLRFLAGS23832384static void fx_umult_r0 (void)2385{2386FX_UMULT(0);2387}23882389static void fx_umult_r1 (void)2390{2391FX_UMULT(1);2392}23932394static void fx_umult_r2 (void)2395{2396FX_UMULT(2);2397}23982399static void fx_umult_r3 (void)2400{2401FX_UMULT(3);2402}24032404static void fx_umult_r4 (void)2405{2406FX_UMULT(4);2407}24082409static void fx_umult_r5 (void)2410{2411FX_UMULT(5);2412}24132414static void fx_umult_r6 (void)2415{2416FX_UMULT(6);2417}24182419static void fx_umult_r7 (void)2420{2421FX_UMULT(7);2422}24232424static void fx_umult_r8 (void)2425{2426FX_UMULT(8);2427}24282429static void fx_umult_r9 (void)2430{2431FX_UMULT(9);2432}24332434static void fx_umult_r10 (void)2435{2436FX_UMULT(10);2437}24382439static void fx_umult_r11 (void)2440{2441FX_UMULT(11);2442}24432444static void fx_umult_r12 (void)2445{2446FX_UMULT(12);2447}24482449static void fx_umult_r13 (void)2450{2451FX_UMULT(13);2452}24532454static void fx_umult_r14 (void)2455{2456FX_UMULT(14);2457}24582459static void fx_umult_r15 (void)2460{2461FX_UMULT(15);2462}24632464// 80-8f (ALT2) - mult #n - 8 bit to 16 bit signed multiply, register * immediate2465#define FX_MULT_I(imm) \2466uint32 v = (uint32) (SEX8(SREG) * ((int32) imm)); \2467R15++; \2468DREG = v; \2469GSU.vSign = v; \2470GSU.vZero = v; \2471TESTR14; \2472CLRFLAGS24732474static void fx_mult_i0 (void)2475{2476FX_MULT_I(0);2477}24782479static void fx_mult_i1 (void)2480{2481FX_MULT_I(1);2482}24832484static void fx_mult_i2 (void)2485{2486FX_MULT_I(2);2487}24882489static void fx_mult_i3 (void)2490{2491FX_MULT_I(3);2492}24932494static void fx_mult_i4 (void)2495{2496FX_MULT_I(4);2497}24982499static void fx_mult_i5 (void)2500{2501FX_MULT_I(5);2502}25032504static void fx_mult_i6 (void)2505{2506FX_MULT_I(6);2507}25082509static void fx_mult_i7 (void)2510{2511FX_MULT_I(7);2512}25132514static void fx_mult_i8 (void)2515{2516FX_MULT_I(8);2517}25182519static void fx_mult_i9 (void)2520{2521FX_MULT_I(9);2522}25232524static void fx_mult_i10 (void)2525{2526FX_MULT_I(10);2527}25282529static void fx_mult_i11 (void)2530{2531FX_MULT_I(11);2532}25332534static void fx_mult_i12 (void)2535{2536FX_MULT_I(12);2537}25382539static void fx_mult_i13 (void)2540{2541FX_MULT_I(13);2542}25432544static void fx_mult_i14 (void)2545{2546FX_MULT_I(14);2547}25482549static void fx_mult_i15 (void)2550{2551FX_MULT_I(15);2552}25532554// 80-8f (ALT3) - umult #n - 8 bit to 16 bit unsigned multiply, register * immediate2555#define FX_UMULT_I(imm) \2556uint32 v = USEX8(SREG) * ((uint32) imm); \2557R15++; \2558DREG = v; \2559GSU.vSign = v; \2560GSU.vZero = v; \2561TESTR14; \2562CLRFLAGS25632564static void fx_umult_i0 (void)2565{2566FX_UMULT_I(0);2567}25682569static void fx_umult_i1 (void)2570{2571FX_UMULT_I(1);2572}25732574static void fx_umult_i2 (void)2575{2576FX_UMULT_I(2);2577}25782579static void fx_umult_i3 (void)2580{2581FX_UMULT_I(3);2582}25832584static void fx_umult_i4 (void)2585{2586FX_UMULT_I(4);2587}25882589static void fx_umult_i5 (void)2590{2591FX_UMULT_I(5);2592}25932594static void fx_umult_i6 (void)2595{2596FX_UMULT_I(6);2597}25982599static void fx_umult_i7 (void)2600{2601FX_UMULT_I(7);2602}26032604static void fx_umult_i8 (void)2605{2606FX_UMULT_I(8);2607}26082609static void fx_umult_i9 (void)2610{2611FX_UMULT_I(9);2612}26132614static void fx_umult_i10 (void)2615{2616FX_UMULT_I(10);2617}26182619static void fx_umult_i11 (void)2620{2621FX_UMULT_I(11);2622}26232624static void fx_umult_i12 (void)2625{2626FX_UMULT_I(12);2627}26282629static void fx_umult_i13 (void)2630{2631FX_UMULT_I(13);2632}26332634static void fx_umult_i14 (void)2635{2636FX_UMULT_I(14);2637}26382639static void fx_umult_i15 (void)2640{2641FX_UMULT_I(15);2642}26432644// 90 - sbk - store word to last accessed RAM address2645static void fx_sbk (void)2646{2647RAM(GSU.vLastRamAdr) = (uint8) SREG;2648RAM(GSU.vLastRamAdr ^ 1) = (uint8) (SREG >> 8);2649CLRFLAGS;2650R15++;2651}26522653// 91-94 - link #n - R11 = R15 + immediate2654#define FX_LINK_I(lkn) \2655R11 = R15 + lkn; \2656CLRFLAGS; \2657R15++26582659static void fx_link_i1 (void)2660{2661FX_LINK_I(1);2662}26632664static void fx_link_i2 (void)2665{2666FX_LINK_I(2);2667}26682669static void fx_link_i3 (void)2670{2671FX_LINK_I(3);2672}26732674static void fx_link_i4 (void)2675{2676FX_LINK_I(4);2677}26782679// 95 - sex - sign extend 8 bit to 16 bit2680static void fx_sex (void)2681{2682uint32 v = (uint32) SEX8(SREG);2683R15++;2684DREG = v;2685GSU.vSign = v;2686GSU.vZero = v;2687TESTR14;2688CLRFLAGS;2689}26902691// 96 - asr - aritmetric shift right by one2692static void fx_asr (void)2693{2694uint32 v;2695GSU.vCarry = SREG & 1;2696v = (uint32) (SEX16(SREG) >> 1);2697R15++;2698DREG = v;2699GSU.vSign = v;2700GSU.vZero = v;2701TESTR14;2702CLRFLAGS;2703}27042705// 96 (ALT1) - div2 - aritmetric shift right by one2706static void fx_div2 (void)2707{2708uint32 v;2709int32 s = SEX16(SREG);2710GSU.vCarry = s & 1;2711if (s == -1)2712v = 0;2713else2714v = (uint32) (s >> 1);2715R15++;2716DREG = v;2717GSU.vSign = v;2718GSU.vZero = v;2719TESTR14;2720CLRFLAGS;2721}27222723// 97 - ror - rotate right by one2724static void fx_ror (void)2725{2726uint32 v = (USEX16(SREG) >> 1) | (GSU.vCarry << 15);2727GSU.vCarry = SREG & 1;2728R15++;2729DREG = v;2730GSU.vSign = v;2731GSU.vZero = v;2732TESTR14;2733CLRFLAGS;2734}27352736// 98-9d - jmp rn - jump to address of register2737#define FX_JMP(reg) \2738R15 = GSU.avReg[reg]; \2739CLRFLAGS27402741static void fx_jmp_r8 (void)2742{2743FX_JMP(8);2744}27452746static void fx_jmp_r9 (void)2747{2748FX_JMP(9);2749}27502751static void fx_jmp_r10 (void)2752{2753FX_JMP(10);2754}27552756static void fx_jmp_r11 (void)2757{2758FX_JMP(11);2759}27602761static void fx_jmp_r12 (void)2762{2763FX_JMP(12);2764}27652766static void fx_jmp_r13 (void)2767{2768FX_JMP(13);2769}27702771// 98-9d (ALT1) - ljmp rn - set program bank to source register and jump to address of register2772#define FX_LJMP(reg) \2773GSU.vPrgBankReg = GSU.avReg[reg] & 0x7f; \2774GSU.pvPrgBank = GSU.apvRomBank[GSU.vPrgBankReg]; \2775R15 = SREG; \2776GSU.bCacheActive = FALSE; \2777fx_cache(); \2778R15--27792780static void fx_ljmp_r8 (void)2781{2782FX_LJMP(8);2783}27842785static void fx_ljmp_r9 (void)2786{2787FX_LJMP(9);2788}27892790static void fx_ljmp_r10 (void)2791{2792FX_LJMP(10);2793}27942795static void fx_ljmp_r11 (void)2796{2797FX_LJMP(11);2798}27992800static void fx_ljmp_r12 (void)2801{2802FX_LJMP(12);2803}28042805static void fx_ljmp_r13 (void)2806{2807FX_LJMP(13);2808}28092810// 9e - lob - set upper byte to zero (keep low byte)2811static void fx_lob (void)2812{2813uint32 v = USEX8(SREG);2814R15++;2815DREG = v;2816GSU.vSign = v << 8;2817GSU.vZero = v << 8;2818TESTR14;2819CLRFLAGS;2820}28212822// 9f - fmult - 16 bit to 32 bit signed multiplication, upper 16 bits only2823static void fx_fmult (void)2824{2825uint32 v;2826uint32 c = (uint32) (SEX16(SREG) * SEX16(R6));2827v = c >> 16;2828R15++;2829DREG = v;2830GSU.vSign = v;2831GSU.vZero = v;2832GSU.vCarry = (c >> 15) & 1;2833TESTR14;2834CLRFLAGS;2835}28362837// 9f (ALT1) - lmult - 16 bit to 32 bit signed multiplication2838static void fx_lmult (void)2839{2840uint32 v;2841uint32 c = (uint32) (SEX16(SREG) * SEX16(R6));2842R4 = c;2843v = c >> 16;2844R15++;2845DREG = v;2846GSU.vSign = v;2847GSU.vZero = v;2848// XXX: R6 or R4?2849GSU.vCarry = (R4 >> 15) & 1; // should it be bit 15 of R4 instead ?2850TESTR14;2851CLRFLAGS;2852}28532854// a0-af - ibt rn, #pp - immediate byte transfer2855#define FX_IBT(reg) \2856uint8 v = PIPE; \2857R15++; \2858FETCHPIPE; \2859R15++; \2860GSU.avReg[reg] = SEX8(v); \2861CLRFLAGS28622863static void fx_ibt_r0 (void)2864{2865FX_IBT(0);2866}28672868static void fx_ibt_r1 (void)2869{2870FX_IBT(1);2871}28722873static void fx_ibt_r2 (void)2874{2875FX_IBT(2);2876}28772878static void fx_ibt_r3 (void)2879{2880FX_IBT(3);2881}28822883static void fx_ibt_r4 (void)2884{2885FX_IBT(4);2886}28872888static void fx_ibt_r5 (void)2889{2890FX_IBT(5);2891}28922893static void fx_ibt_r6 (void)2894{2895FX_IBT(6);2896}28972898static void fx_ibt_r7 (void)2899{2900FX_IBT(7);2901}29022903static void fx_ibt_r8 (void)2904{2905FX_IBT(8);2906}29072908static void fx_ibt_r9 (void)2909{2910FX_IBT(9);2911}29122913static void fx_ibt_r10 (void)2914{2915FX_IBT(10);2916}29172918static void fx_ibt_r11 (void)2919{2920FX_IBT(11);2921}29222923static void fx_ibt_r12 (void)2924{2925FX_IBT(12);2926}29272928static void fx_ibt_r13 (void)2929{2930FX_IBT(13);2931}29322933static void fx_ibt_r14 (void)2934{2935FX_IBT(14);2936READR14;2937}29382939static void fx_ibt_r15 (void)2940{2941FX_IBT(15);2942}29432944// a0-af (ALT1) - lms rn, (yy) - load word from RAM (short address)2945#define FX_LMS(reg) \2946GSU.vLastRamAdr = ((uint32) PIPE) << 1; \2947R15++; \2948FETCHPIPE; \2949R15++; \2950GSU.avReg[reg] = (uint32) RAM(GSU.vLastRamAdr); \2951GSU.avReg[reg] |= ((uint32) RAM(GSU.vLastRamAdr + 1)) << 8; \2952CLRFLAGS29532954static void fx_lms_r0 (void)2955{2956FX_LMS(0);2957}29582959static void fx_lms_r1 (void)2960{2961FX_LMS(1);2962}29632964static void fx_lms_r2 (void)2965{2966FX_LMS(2);2967}29682969static void fx_lms_r3 (void)2970{2971FX_LMS(3);2972}29732974static void fx_lms_r4 (void)2975{2976FX_LMS(4);2977}29782979static void fx_lms_r5 (void)2980{2981FX_LMS(5);2982}29832984static void fx_lms_r6 (void)2985{2986FX_LMS(6);2987}29882989static void fx_lms_r7 (void)2990{2991FX_LMS(7);2992}29932994static void fx_lms_r8 (void)2995{2996FX_LMS(8);2997}29982999static void fx_lms_r9 (void)3000{3001FX_LMS(9);3002}30033004static void fx_lms_r10 (void)3005{3006FX_LMS(10);3007}30083009static void fx_lms_r11 (void)3010{3011FX_LMS(11);3012}30133014static void fx_lms_r12 (void)3015{3016FX_LMS(12);3017}30183019static void fx_lms_r13 (void)3020{3021FX_LMS(13);3022}30233024static void fx_lms_r14 (void)3025{3026FX_LMS(14);3027READR14;3028}30293030static void fx_lms_r15 (void)3031{3032FX_LMS(15);3033}30343035// a0-af (ALT2) - sms (yy), rn - store word in RAM (short address)3036// XXX: If rn == r15, is the value of r15 before or after the extra byte is read ?3037#define FX_SMS(reg) \3038uint32 v = GSU.avReg[reg]; \3039GSU.vLastRamAdr = ((uint32) PIPE) << 1; \3040R15++; \3041FETCHPIPE; \3042RAM(GSU.vLastRamAdr) = (uint8) v; \3043RAM(GSU.vLastRamAdr + 1) = (uint8) (v >> 8); \3044CLRFLAGS; \3045R15++30463047static void fx_sms_r0 (void)3048{3049FX_SMS(0);3050}30513052static void fx_sms_r1 (void)3053{3054FX_SMS(1);3055}30563057static void fx_sms_r2 (void)3058{3059FX_SMS(2);3060}30613062static void fx_sms_r3 (void)3063{3064FX_SMS(3);3065}30663067static void fx_sms_r4 (void)3068{3069FX_SMS(4);3070}30713072static void fx_sms_r5 (void)3073{3074FX_SMS(5);3075}30763077static void fx_sms_r6 (void)3078{3079FX_SMS(6);3080}30813082static void fx_sms_r7 (void)3083{3084FX_SMS(7);3085}30863087static void fx_sms_r8 (void)3088{3089FX_SMS(8);3090}30913092static void fx_sms_r9 (void)3093{3094FX_SMS(9);3095}30963097static void fx_sms_r10 (void)3098{3099FX_SMS(10);3100}31013102static void fx_sms_r11 (void)3103{3104FX_SMS(11);3105}31063107static void fx_sms_r12 (void)3108{3109FX_SMS(12);3110}31113112static void fx_sms_r13 (void)3113{3114FX_SMS(13);3115}31163117static void fx_sms_r14 (void)3118{3119FX_SMS(14);3120}31213122static void fx_sms_r15 (void)3123{3124FX_SMS(15);3125}31263127// b0-bf - from rn - set source register3128// b0-bf (B) - moves rn - move register to register, and set flags, (if B flag is set)3129#define FX_FROM(reg) \3130if (TF(B)) \3131{ \3132uint32 v = GSU.avReg[reg]; \3133R15++; \3134DREG = v; \3135GSU.vOverflow = (v & 0x80) << 16; \3136GSU.vSign = v; \3137GSU.vZero = v; \3138TESTR14; \3139CLRFLAGS; \3140} \3141else \3142{ \3143GSU.pvSreg = &GSU.avReg[reg]; \3144R15++; \3145}31463147static void fx_from_r0 (void)3148{3149FX_FROM(0);3150}31513152static void fx_from_r1 (void)3153{3154FX_FROM(1);3155}31563157static void fx_from_r2 (void)3158{3159FX_FROM(2);3160}31613162static void fx_from_r3 (void)3163{3164FX_FROM(3);3165}31663167static void fx_from_r4 (void)3168{3169FX_FROM(4);3170}31713172static void fx_from_r5 (void)3173{3174FX_FROM(5);3175}31763177static void fx_from_r6 (void)3178{3179FX_FROM(6);3180}31813182static void fx_from_r7 (void)3183{3184FX_FROM(7);3185}31863187static void fx_from_r8 (void)3188{3189FX_FROM(8);3190}31913192static void fx_from_r9 (void)3193{3194FX_FROM(9);3195}31963197static void fx_from_r10 (void)3198{3199FX_FROM(10);3200}32013202static void fx_from_r11 (void)3203{3204FX_FROM(11);3205}32063207static void fx_from_r12 (void)3208{3209FX_FROM(12);3210}32113212static void fx_from_r13 (void)3213{3214FX_FROM(13);3215}32163217static void fx_from_r14 (void)3218{3219FX_FROM(14);3220}32213222static void fx_from_r15 (void)3223{3224FX_FROM(15);3225}32263227// c0 - hib - move high-byte to low-byte3228static void fx_hib (void)3229{3230uint32 v = USEX8(SREG >> 8);3231R15++;3232DREG = v;3233GSU.vSign = v << 8;3234GSU.vZero = v << 8;3235TESTR14;3236CLRFLAGS;3237}32383239// c1-cf - or rn3240#define FX_OR(reg) \3241uint32 v = SREG | GSU.avReg[reg]; \3242R15++; \3243DREG = v; \3244GSU.vSign = v; \3245GSU.vZero = v; \3246TESTR14; \3247CLRFLAGS32483249static void fx_or_r1 (void)3250{3251FX_OR(1);3252}32533254static void fx_or_r2 (void)3255{3256FX_OR(2);3257}32583259static void fx_or_r3 (void)3260{3261FX_OR(3);3262}32633264static void fx_or_r4 (void)3265{3266FX_OR(4);3267}32683269static void fx_or_r5 (void)3270{3271FX_OR(5);3272}32733274static void fx_or_r6 (void)3275{3276FX_OR(6);3277}32783279static void fx_or_r7 (void)3280{3281FX_OR(7);3282}32833284static void fx_or_r8 (void)3285{3286FX_OR(8);3287}32883289static void fx_or_r9 (void)3290{3291FX_OR(9);3292}32933294static void fx_or_r10 (void)3295{3296FX_OR(10);3297}32983299static void fx_or_r11 (void)3300{3301FX_OR(11);3302}33033304static void fx_or_r12 (void)3305{3306FX_OR(12);3307}33083309static void fx_or_r13 (void)3310{3311FX_OR(13);3312}33133314static void fx_or_r14 (void)3315{3316FX_OR(14);3317}33183319static void fx_or_r15 (void)3320{3321FX_OR(15);3322}33233324// c1-cf (ALT1) - xor rn3325#define FX_XOR(reg) \3326uint32 v = SREG ^ GSU.avReg[reg]; \3327R15++; \3328DREG = v; \3329GSU.vSign = v; \3330GSU.vZero = v; \3331TESTR14; \3332CLRFLAGS33333334static void fx_xor_r1 (void)3335{3336FX_XOR(1);3337}33383339static void fx_xor_r2 (void)3340{3341FX_XOR(2);3342}33433344static void fx_xor_r3 (void)3345{3346FX_XOR(3);3347}33483349static void fx_xor_r4 (void)3350{3351FX_XOR(4);3352}33533354static void fx_xor_r5 (void)3355{3356FX_XOR(5);3357}33583359static void fx_xor_r6 (void)3360{3361FX_XOR(6);3362}33633364static void fx_xor_r7 (void)3365{3366FX_XOR(7);3367}33683369static void fx_xor_r8 (void)3370{3371FX_XOR(8);3372}33733374static void fx_xor_r9 (void)3375{3376FX_XOR(9);3377}33783379static void fx_xor_r10 (void)3380{3381FX_XOR(10);3382}33833384static void fx_xor_r11 (void)3385{3386FX_XOR(11);3387}33883389static void fx_xor_r12 (void)3390{3391FX_XOR(12);3392}33933394static void fx_xor_r13 (void)3395{3396FX_XOR(13);3397}33983399static void fx_xor_r14 (void)3400{3401FX_XOR(14);3402}34033404static void fx_xor_r15 (void)3405{3406FX_XOR(15);3407}34083409// c1-cf (ALT2) - or #n3410#define FX_OR_I(imm) \3411uint32 v = SREG | imm; \3412R15++; \3413DREG = v; \3414GSU.vSign = v; \3415GSU.vZero = v; \3416TESTR14; \3417CLRFLAGS34183419static void fx_or_i1 (void)3420{3421FX_OR_I(1);3422}34233424static void fx_or_i2 (void)3425{3426FX_OR_I(2);3427}34283429static void fx_or_i3 (void)3430{3431FX_OR_I(3);3432}34333434static void fx_or_i4 (void)3435{3436FX_OR_I(4);3437}34383439static void fx_or_i5 (void)3440{3441FX_OR_I(5);3442}34433444static void fx_or_i6 (void)3445{3446FX_OR_I(6);3447}34483449static void fx_or_i7 (void)3450{3451FX_OR_I(7);3452}34533454static void fx_or_i8 (void)3455{3456FX_OR_I(8);3457}34583459static void fx_or_i9 (void)3460{3461FX_OR_I(9);3462}34633464static void fx_or_i10 (void)3465{3466FX_OR_I(10);3467}34683469static void fx_or_i11 (void)3470{3471FX_OR_I(11);3472}34733474static void fx_or_i12 (void)3475{3476FX_OR_I(12);3477}34783479static void fx_or_i13 (void)3480{3481FX_OR_I(13);3482}34833484static void fx_or_i14 (void)3485{3486FX_OR_I(14);3487}34883489static void fx_or_i15 (void)3490{3491FX_OR_I(15);3492}34933494// c1-cf (ALT3) - xor #n3495#define FX_XOR_I(imm) \3496uint32 v = SREG ^ imm; \3497R15++; \3498DREG = v; \3499GSU.vSign = v; \3500GSU.vZero = v; \3501TESTR14; \3502CLRFLAGS35033504static void fx_xor_i1 (void)3505{3506FX_XOR_I(1);3507}35083509static void fx_xor_i2 (void)3510{3511FX_XOR_I(2);3512}35133514static void fx_xor_i3 (void)3515{3516FX_XOR_I(3);3517}35183519static void fx_xor_i4 (void)3520{3521FX_XOR_I(4);3522}35233524static void fx_xor_i5 (void)3525{3526FX_XOR_I(5);3527}35283529static void fx_xor_i6 (void)3530{3531FX_XOR_I(6);3532}35333534static void fx_xor_i7 (void)3535{3536FX_XOR_I(7);3537}35383539static void fx_xor_i8 (void)3540{3541FX_XOR_I(8);3542}35433544static void fx_xor_i9 (void)3545{3546FX_XOR_I(9);3547}35483549static void fx_xor_i10 (void)3550{3551FX_XOR_I(10);3552}35533554static void fx_xor_i11 (void)3555{3556FX_XOR_I(11);3557}35583559static void fx_xor_i12 (void)3560{3561FX_XOR_I(12);3562}35633564static void fx_xor_i13 (void)3565{3566FX_XOR_I(13);3567}35683569static void fx_xor_i14 (void)3570{3571FX_XOR_I(14);3572}35733574static void fx_xor_i15 (void)3575{3576FX_XOR_I(15);3577}35783579// d0-de - inc rn - increase by one3580#define FX_INC(reg) \3581GSU.avReg[reg] += 1; \3582GSU.vSign = GSU.avReg[reg]; \3583GSU.vZero = GSU.avReg[reg]; \3584CLRFLAGS; \3585R15++35863587static void fx_inc_r0 (void)3588{3589FX_INC(0);3590}35913592static void fx_inc_r1 (void)3593{3594FX_INC(1);3595}35963597static void fx_inc_r2 (void)3598{3599FX_INC(2);3600}36013602static void fx_inc_r3 (void)3603{3604FX_INC(3);3605}36063607static void fx_inc_r4 (void)3608{3609FX_INC(4);3610}36113612static void fx_inc_r5 (void)3613{3614FX_INC(5);3615}36163617static void fx_inc_r6 (void)3618{3619FX_INC(6);3620}36213622static void fx_inc_r7 (void)3623{3624FX_INC(7);3625}36263627static void fx_inc_r8 (void)3628{3629FX_INC(8);3630}36313632static void fx_inc_r9 (void)3633{3634FX_INC(9);3635}36363637static void fx_inc_r10 (void)3638{3639FX_INC(10);3640}36413642static void fx_inc_r11 (void)3643{3644FX_INC(11);3645}36463647static void fx_inc_r12 (void)3648{3649FX_INC(12);3650}36513652static void fx_inc_r13 (void)3653{3654FX_INC(13);3655}36563657static void fx_inc_r14 (void)3658{3659FX_INC(14);3660READR14;3661}36623663// df - getc - transfer ROM buffer to color register3664static void fx_getc (void)3665{3666#ifndef FX_DO_ROMBUFFER3667uint8 c = ROM(R14);3668#else3669uint8 c = GSU.vRomBuffer;3670#endif36713672if (GSU.vPlotOptionReg & 0x04)3673c = (c & 0xf0) | (c >> 4);36743675if (GSU.vPlotOptionReg & 0x08)3676{3677GSU.vColorReg &= 0xf0;3678GSU.vColorReg |= c & 0x0f;3679}3680else3681GSU.vColorReg = USEX8(c);36823683CLRFLAGS;3684R15++;3685}36863687// df (ALT2) - ramb - set current RAM bank3688static void fx_ramb (void)3689{3690GSU.vRamBankReg = SREG & (FX_RAM_BANKS - 1);3691GSU.pvRamBank = GSU.apvRamBank[GSU.vRamBankReg & 0x3];3692CLRFLAGS;3693R15++;3694}36953696// df (ALT3) - romb - set current ROM bank3697static void fx_romb (void)3698{3699GSU.vRomBankReg = USEX8(SREG) & 0x7f;3700GSU.pvRomBank = GSU.apvRomBank[GSU.vRomBankReg];3701CLRFLAGS;3702R15++;3703}37043705// e0-ee - dec rn - decrement by one3706#define FX_DEC(reg) \3707GSU.avReg[reg] -= 1; \3708GSU.vSign = GSU.avReg[reg]; \3709GSU.vZero = GSU.avReg[reg]; \3710CLRFLAGS; \3711R15++37123713static void fx_dec_r0 (void)3714{3715FX_DEC(0);3716}37173718static void fx_dec_r1 (void)3719{3720FX_DEC(1);3721}37223723static void fx_dec_r2 (void)3724{3725FX_DEC(2);3726}37273728static void fx_dec_r3 (void)3729{3730FX_DEC(3);3731}37323733static void fx_dec_r4 (void)3734{3735FX_DEC(4);3736}37373738static void fx_dec_r5 (void)3739{3740FX_DEC(5);3741}37423743static void fx_dec_r6 (void)3744{3745FX_DEC(6);3746}37473748static void fx_dec_r7 (void)3749{3750FX_DEC(7);3751}37523753static void fx_dec_r8 (void)3754{3755FX_DEC(8);3756}37573758static void fx_dec_r9 (void)3759{3760FX_DEC(9);3761}37623763static void fx_dec_r10 (void)3764{3765FX_DEC(10);3766}37673768static void fx_dec_r11 (void)3769{3770FX_DEC(11);3771}37723773static void fx_dec_r12 (void)3774{3775FX_DEC(12);3776}37773778static void fx_dec_r13 (void)3779{3780FX_DEC(13);3781}37823783static void fx_dec_r14 (void)3784{3785FX_DEC(14);3786READR14;3787}37883789// ef - getb - get byte from ROM at address R143790static void fx_getb (void)3791{3792uint32 v;3793#ifndef FX_DO_ROMBUFFER3794v = (uint32) ROM(R14);3795#else3796v = (uint32) GSU.vRomBuffer;3797#endif3798R15++;3799DREG = v;3800TESTR14;3801CLRFLAGS;3802}38033804// ef (ALT1) - getbh - get high-byte from ROM at address R143805static void fx_getbh (void)3806{3807uint32 v;3808#ifndef FX_DO_ROMBUFFER3809uint32 c = (uint32) ROM(R14);3810#else3811uint32 c = USEX8(GSU.vRomBuffer);3812#endif3813v = USEX8(SREG) | (c << 8);3814R15++;3815DREG = v;3816TESTR14;3817CLRFLAGS;3818}38193820// ef (ALT2) - getbl - get low-byte from ROM at address R143821static void fx_getbl (void)3822{3823uint32 v;3824#ifndef FX_DO_ROMBUFFER3825uint32 c = (uint32) ROM(R14);3826#else3827uint32 c = USEX8(GSU.vRomBuffer);3828#endif3829v = (SREG & 0xff00) | c;3830R15++;3831DREG = v;3832TESTR14;3833CLRFLAGS;3834}38353836// ef (ALT3) - getbs - get sign extended byte from ROM at address R143837static void fx_getbs (void)3838{3839uint32 v;3840#ifndef FX_DO_ROMBUFFER3841int8 c;3842c = ROM(R14);3843v = SEX8(c);3844#else3845v = SEX8(GSU.vRomBuffer);3846#endif3847R15++;3848DREG = v;3849TESTR14;3850CLRFLAGS;3851}38523853// f0-ff - iwt rn, #xx - immediate word transfer to register3854#define FX_IWT(reg) \3855uint32 v = PIPE; \3856R15++; \3857FETCHPIPE; \3858R15++; \3859v |= USEX8(PIPE) << 8; \3860FETCHPIPE; \3861R15++; \3862GSU.avReg[reg] = v; \3863CLRFLAGS38643865static void fx_iwt_r0 (void)3866{3867FX_IWT(0);3868}38693870static void fx_iwt_r1 (void)3871{3872FX_IWT(1);3873}38743875static void fx_iwt_r2 (void)3876{3877FX_IWT(2);3878}38793880static void fx_iwt_r3 (void)3881{3882FX_IWT(3);3883}38843885static void fx_iwt_r4 (void)3886{3887FX_IWT(4);3888}38893890static void fx_iwt_r5 (void)3891{3892FX_IWT(5);3893}38943895static void fx_iwt_r6 (void)3896{3897FX_IWT(6);3898}38993900static void fx_iwt_r7 (void)3901{3902FX_IWT(7);3903}39043905static void fx_iwt_r8 (void)3906{3907FX_IWT(8);3908}39093910static void fx_iwt_r9 (void)3911{3912FX_IWT(9);3913}39143915static void fx_iwt_r10 (void)3916{3917FX_IWT(10);3918}39193920static void fx_iwt_r11 (void)3921{3922FX_IWT(11);3923}39243925static void fx_iwt_r12 (void)3926{3927FX_IWT(12);3928}39293930static void fx_iwt_r13 (void)3931{3932FX_IWT(13);3933}39343935static void fx_iwt_r14 (void)3936{3937FX_IWT(14);3938READR14;3939}39403941static void fx_iwt_r15 (void)3942{3943FX_IWT(15);3944}39453946// f0-ff (ALT1) - lm rn, (xx) - load word from RAM3947#define FX_LM(reg) \3948GSU.vLastRamAdr = PIPE; \3949R15++; \3950FETCHPIPE; \3951R15++; \3952GSU.vLastRamAdr |= USEX8(PIPE) << 8; \3953FETCHPIPE; \3954R15++; \3955GSU.avReg[reg] = RAM(GSU.vLastRamAdr); \3956GSU.avReg[reg] |= USEX8(RAM(GSU.vLastRamAdr ^ 1)) << 8; \3957CLRFLAGS39583959static void fx_lm_r0 (void)3960{3961FX_LM(0);3962}39633964static void fx_lm_r1 (void)3965{3966FX_LM(1);3967}39683969static void fx_lm_r2 (void)3970{3971FX_LM(2);3972}39733974static void fx_lm_r3 (void)3975{3976FX_LM(3);3977}39783979static void fx_lm_r4 (void)3980{3981FX_LM(4);3982}39833984static void fx_lm_r5 (void)3985{3986FX_LM(5);3987}39883989static void fx_lm_r6 (void)3990{3991FX_LM(6);3992}39933994static void fx_lm_r7 (void)3995{3996FX_LM(7);3997}39983999static void fx_lm_r8 (void)4000{4001FX_LM(8);4002}40034004static void fx_lm_r9 (void)4005{4006FX_LM(9);4007}40084009static void fx_lm_r10 (void)4010{4011FX_LM(10);4012}40134014static void fx_lm_r11 (void)4015{4016FX_LM(11);4017}40184019static void fx_lm_r12 (void)4020{4021FX_LM(12);4022}40234024static void fx_lm_r13 (void)4025{4026FX_LM(13);4027}40284029static void fx_lm_r14 (void)4030{4031FX_LM(14);4032READR14;4033}40344035static void fx_lm_r15 (void)4036{4037FX_LM(15);4038}40394040// f0-ff (ALT2) - sm (xx), rn - store word in RAM4041// XXX: If rn == r15, is the value of r15 before or after the extra bytes are read ?4042#define FX_SM(reg) \4043uint32 v = GSU.avReg[reg]; \4044GSU.vLastRamAdr = PIPE; \4045R15++; \4046FETCHPIPE; \4047R15++; \4048GSU.vLastRamAdr |= USEX8(PIPE) << 8; \4049FETCHPIPE; \4050RAM(GSU.vLastRamAdr) = (uint8) v; \4051RAM(GSU.vLastRamAdr ^ 1) = (uint8) (v >> 8); \4052CLRFLAGS; \4053R15++40544055static void fx_sm_r0 (void)4056{4057FX_SM(0);4058}40594060static void fx_sm_r1 (void)4061{4062FX_SM(1);4063}40644065static void fx_sm_r2 (void)4066{4067FX_SM(2);4068}40694070static void fx_sm_r3 (void)4071{4072FX_SM(3);4073}40744075static void fx_sm_r4 (void)4076{4077FX_SM(4);4078}40794080static void fx_sm_r5 (void)4081{4082FX_SM(5);4083}40844085static void fx_sm_r6 (void)4086{4087FX_SM(6);4088}40894090static void fx_sm_r7 (void)4091{4092FX_SM(7);4093}40944095static void fx_sm_r8 (void)4096{4097FX_SM(8);4098}40994100static void fx_sm_r9 (void)4101{4102FX_SM(9);4103}41044105static void fx_sm_r10 (void)4106{4107FX_SM(10);4108}41094110static void fx_sm_r11 (void)4111{4112FX_SM(11);4113}41144115static void fx_sm_r12 (void)4116{4117FX_SM(12);4118}41194120static void fx_sm_r13 (void)4121{4122FX_SM(13);4123}41244125static void fx_sm_r14 (void)4126{4127FX_SM(14);4128}41294130static void fx_sm_r15 (void)4131{4132FX_SM(15);4133}41344135// GSU executions functions41364137uint32 fx_run (uint32 nInstructions)4138{4139GSU.vCounter = nInstructions;4140READR14;4141while (TF(G) && (GSU.vCounter-- > 0))4142FX_STEP;4143#if 04144#ifndef FX_ADDRESS_CHECK4145GSU.vPipeAdr = USEX16(R15 - 1) | (USEX8(GSU.vPrgBankReg) << 16);4146#endif4147#endif41484149return (nInstructions - GSU.vInstCount);4150}41514152/*4153uint32 fx_run_to_breakpoint (uint32 nInstructions)4154{4155uint32 vCounter = 0;41564157while (TF(G) && vCounter < nInstructions)4158{4159vCounter++;4160FX_STEP;41614162if (USEX16(R15) == GSU.vBreakPoint)4163{4164GSU.vErrorCode = FX_BREAKPOINT;4165break;4166}4167}41684169#if 04170#ifndef FX_ADDRESS_CHECK4171GSU.vPipeAdr = USEX16(R15 - 1) | (USEX8(GSU.vPrgBankReg) << 16);4172#endif4173#endif41744175return (vCounter);4176}4177*/41784179/*4180uint32 fx_step_over (uint32 nInstructions)4181{4182uint32 vCounter = 0;41834184while (TF(G) && vCounter < nInstructions)4185{4186vCounter++;4187FX_STEP;41884189if (USEX16(R15) == GSU.vBreakPoint)4190{4191GSU.vErrorCode = FX_BREAKPOINT;4192break;4193}41944195if (USEX16(R15) == GSU.vStepPoint)4196break;4197}41984199#if 04200#ifndef FX_ADDRESS_CHECK4201GSU.vPipeAdr = USEX16(R15 - 1) | (USEX8(GSU.vPrgBankReg) << 16);4202#endif4203#endif42044205return (vCounter);4206}4207*/42084209// Special table for the different plot configurations42104211void (*fx_PlotTable[]) (void) =4212{4213&fx_plot_2bit, &fx_plot_4bit, &fx_plot_4bit, &fx_plot_8bit, &fx_plot_obj,4214&fx_rpix_2bit, &fx_rpix_4bit, &fx_rpix_4bit, &fx_rpix_8bit, &fx_rpix_obj4215};42164217// Opcode table42184219void (*fx_OpcodeTable[]) (void) =4220{4221// ALT0 Table42224223// 00 - 0f4224&fx_stop, &fx_nop, &fx_cache, &fx_lsr, &fx_rol, &fx_bra, &fx_bge, &fx_blt,4225&fx_bne, &fx_beq, &fx_bpl, &fx_bmi, &fx_bcc, &fx_bcs, &fx_bvc, &fx_bvs,4226// 10 - 1f4227&fx_to_r0, &fx_to_r1, &fx_to_r2, &fx_to_r3, &fx_to_r4, &fx_to_r5, &fx_to_r6, &fx_to_r7,4228&fx_to_r8, &fx_to_r9, &fx_to_r10, &fx_to_r11, &fx_to_r12, &fx_to_r13, &fx_to_r14, &fx_to_r15,4229// 20 - 2f4230&fx_with_r0, &fx_with_r1, &fx_with_r2, &fx_with_r3, &fx_with_r4, &fx_with_r5, &fx_with_r6, &fx_with_r7,4231&fx_with_r8, &fx_with_r9, &fx_with_r10, &fx_with_r11, &fx_with_r12, &fx_with_r13, &fx_with_r14, &fx_with_r15,4232// 30 - 3f4233&fx_stw_r0, &fx_stw_r1, &fx_stw_r2, &fx_stw_r3, &fx_stw_r4, &fx_stw_r5, &fx_stw_r6, &fx_stw_r7,4234&fx_stw_r8, &fx_stw_r9, &fx_stw_r10, &fx_stw_r11, &fx_loop, &fx_alt1, &fx_alt2, &fx_alt3,4235// 40 - 4f4236&fx_ldw_r0, &fx_ldw_r1, &fx_ldw_r2, &fx_ldw_r3, &fx_ldw_r4, &fx_ldw_r5, &fx_ldw_r6, &fx_ldw_r7,4237&fx_ldw_r8, &fx_ldw_r9, &fx_ldw_r10, &fx_ldw_r11, &fx_plot_2bit, &fx_swap, &fx_color, &fx_not,4238// 50 - 5f4239&fx_add_r0, &fx_add_r1, &fx_add_r2, &fx_add_r3, &fx_add_r4, &fx_add_r5, &fx_add_r6, &fx_add_r7,4240&fx_add_r8, &fx_add_r9, &fx_add_r10, &fx_add_r11, &fx_add_r12, &fx_add_r13, &fx_add_r14, &fx_add_r15,4241// 60 - 6f4242&fx_sub_r0, &fx_sub_r1, &fx_sub_r2, &fx_sub_r3, &fx_sub_r4, &fx_sub_r5, &fx_sub_r6, &fx_sub_r7,4243&fx_sub_r8, &fx_sub_r9, &fx_sub_r10, &fx_sub_r11, &fx_sub_r12, &fx_sub_r13, &fx_sub_r14, &fx_sub_r15,4244// 70 - 7f4245&fx_merge, &fx_and_r1, &fx_and_r2, &fx_and_r3, &fx_and_r4, &fx_and_r5, &fx_and_r6, &fx_and_r7,4246&fx_and_r8, &fx_and_r9, &fx_and_r10, &fx_and_r11, &fx_and_r12, &fx_and_r13, &fx_and_r14, &fx_and_r15,4247// 80 - 8f4248&fx_mult_r0, &fx_mult_r1, &fx_mult_r2, &fx_mult_r3, &fx_mult_r4, &fx_mult_r5, &fx_mult_r6, &fx_mult_r7,4249&fx_mult_r8, &fx_mult_r9, &fx_mult_r10, &fx_mult_r11, &fx_mult_r12, &fx_mult_r13, &fx_mult_r14, &fx_mult_r15,4250// 90 - 9f4251&fx_sbk, &fx_link_i1, &fx_link_i2, &fx_link_i3, &fx_link_i4, &fx_sex, &fx_asr, &fx_ror,4252&fx_jmp_r8, &fx_jmp_r9, &fx_jmp_r10, &fx_jmp_r11, &fx_jmp_r12, &fx_jmp_r13, &fx_lob, &fx_fmult,4253// a0 - af4254&fx_ibt_r0, &fx_ibt_r1, &fx_ibt_r2, &fx_ibt_r3, &fx_ibt_r4, &fx_ibt_r5, &fx_ibt_r6, &fx_ibt_r7,4255&fx_ibt_r8, &fx_ibt_r9, &fx_ibt_r10, &fx_ibt_r11, &fx_ibt_r12, &fx_ibt_r13, &fx_ibt_r14, &fx_ibt_r15,4256// b0 - bf4257&fx_from_r0, &fx_from_r1, &fx_from_r2, &fx_from_r3, &fx_from_r4, &fx_from_r5, &fx_from_r6, &fx_from_r7,4258&fx_from_r8, &fx_from_r9, &fx_from_r10, &fx_from_r11, &fx_from_r12, &fx_from_r13, &fx_from_r14, &fx_from_r15,4259// c0 - cf4260&fx_hib, &fx_or_r1, &fx_or_r2, &fx_or_r3, &fx_or_r4, &fx_or_r5, &fx_or_r6, &fx_or_r7,4261&fx_or_r8, &fx_or_r9, &fx_or_r10, &fx_or_r11, &fx_or_r12, &fx_or_r13, &fx_or_r14, &fx_or_r15,4262// d0 - df4263&fx_inc_r0, &fx_inc_r1, &fx_inc_r2, &fx_inc_r3, &fx_inc_r4, &fx_inc_r5, &fx_inc_r6, &fx_inc_r7,4264&fx_inc_r8, &fx_inc_r9, &fx_inc_r10, &fx_inc_r11, &fx_inc_r12, &fx_inc_r13, &fx_inc_r14, &fx_getc,4265// e0 - ef4266&fx_dec_r0, &fx_dec_r1, &fx_dec_r2, &fx_dec_r3, &fx_dec_r4, &fx_dec_r5, &fx_dec_r6, &fx_dec_r7,4267&fx_dec_r8, &fx_dec_r9, &fx_dec_r10, &fx_dec_r11, &fx_dec_r12, &fx_dec_r13, &fx_dec_r14, &fx_getb,4268// f0 - ff4269&fx_iwt_r0, &fx_iwt_r1, &fx_iwt_r2, &fx_iwt_r3, &fx_iwt_r4, &fx_iwt_r5, &fx_iwt_r6, &fx_iwt_r7,4270&fx_iwt_r8, &fx_iwt_r9, &fx_iwt_r10, &fx_iwt_r11, &fx_iwt_r12, &fx_iwt_r13, &fx_iwt_r14, &fx_iwt_r15,42714272// ALT1 Table42734274// 00 - 0f4275&fx_stop, &fx_nop, &fx_cache, &fx_lsr, &fx_rol, &fx_bra, &fx_bge, &fx_blt,4276&fx_bne, &fx_beq, &fx_bpl, &fx_bmi, &fx_bcc, &fx_bcs, &fx_bvc, &fx_bvs,4277// 10 - 1f4278&fx_to_r0, &fx_to_r1, &fx_to_r2, &fx_to_r3, &fx_to_r4, &fx_to_r5, &fx_to_r6, &fx_to_r7,4279&fx_to_r8, &fx_to_r9, &fx_to_r10, &fx_to_r11, &fx_to_r12, &fx_to_r13, &fx_to_r14, &fx_to_r15,4280// 20 - 2f4281&fx_with_r0, &fx_with_r1, &fx_with_r2, &fx_with_r3, &fx_with_r4, &fx_with_r5, &fx_with_r6, &fx_with_r7,4282&fx_with_r8, &fx_with_r9, &fx_with_r10, &fx_with_r11, &fx_with_r12, &fx_with_r13, &fx_with_r14, &fx_with_r15,4283// 30 - 3f4284&fx_stb_r0, &fx_stb_r1, &fx_stb_r2, &fx_stb_r3, &fx_stb_r4, &fx_stb_r5, &fx_stb_r6, &fx_stb_r7,4285&fx_stb_r8, &fx_stb_r9, &fx_stb_r10, &fx_stb_r11, &fx_loop, &fx_alt1, &fx_alt2, &fx_alt3,4286// 40 - 4f4287&fx_ldb_r0, &fx_ldb_r1, &fx_ldb_r2, &fx_ldb_r3, &fx_ldb_r4, &fx_ldb_r5, &fx_ldb_r6, &fx_ldb_r7,4288&fx_ldb_r8, &fx_ldb_r9, &fx_ldb_r10, &fx_ldb_r11, &fx_rpix_2bit, &fx_swap, &fx_cmode, &fx_not,4289// 50 - 5f4290&fx_adc_r0, &fx_adc_r1, &fx_adc_r2, &fx_adc_r3, &fx_adc_r4, &fx_adc_r5, &fx_adc_r6, &fx_adc_r7,4291&fx_adc_r8, &fx_adc_r9, &fx_adc_r10, &fx_adc_r11, &fx_adc_r12, &fx_adc_r13, &fx_adc_r14, &fx_adc_r15,4292// 60 - 6f4293&fx_sbc_r0, &fx_sbc_r1, &fx_sbc_r2, &fx_sbc_r3, &fx_sbc_r4, &fx_sbc_r5, &fx_sbc_r6, &fx_sbc_r7,4294&fx_sbc_r8, &fx_sbc_r9, &fx_sbc_r10, &fx_sbc_r11, &fx_sbc_r12, &fx_sbc_r13, &fx_sbc_r14, &fx_sbc_r15,4295// 70 - 7f4296&fx_merge, &fx_bic_r1, &fx_bic_r2, &fx_bic_r3, &fx_bic_r4, &fx_bic_r5, &fx_bic_r6, &fx_bic_r7,4297&fx_bic_r8, &fx_bic_r9, &fx_bic_r10, &fx_bic_r11, &fx_bic_r12, &fx_bic_r13, &fx_bic_r14, &fx_bic_r15,4298// 80 - 8f4299&fx_umult_r0, &fx_umult_r1, &fx_umult_r2, &fx_umult_r3, &fx_umult_r4, &fx_umult_r5, &fx_umult_r6, &fx_umult_r7,4300&fx_umult_r8, &fx_umult_r9, &fx_umult_r10, &fx_umult_r11, &fx_umult_r12, &fx_umult_r13, &fx_umult_r14, &fx_umult_r15,4301// 90 - 9f4302&fx_sbk, &fx_link_i1, &fx_link_i2, &fx_link_i3, &fx_link_i4, &fx_sex, &fx_div2, &fx_ror,4303&fx_ljmp_r8, &fx_ljmp_r9, &fx_ljmp_r10, &fx_ljmp_r11, &fx_ljmp_r12, &fx_ljmp_r13, &fx_lob, &fx_lmult,4304// a0 - af4305&fx_lms_r0, &fx_lms_r1, &fx_lms_r2, &fx_lms_r3, &fx_lms_r4, &fx_lms_r5, &fx_lms_r6, &fx_lms_r7,4306&fx_lms_r8, &fx_lms_r9, &fx_lms_r10, &fx_lms_r11, &fx_lms_r12, &fx_lms_r13, &fx_lms_r14, &fx_lms_r15,4307// b0 - bf4308&fx_from_r0, &fx_from_r1, &fx_from_r2, &fx_from_r3, &fx_from_r4, &fx_from_r5, &fx_from_r6, &fx_from_r7,4309&fx_from_r8, &fx_from_r9, &fx_from_r10, &fx_from_r11, &fx_from_r12, &fx_from_r13, &fx_from_r14, &fx_from_r15,4310// c0 - cf4311&fx_hib, &fx_xor_r1, &fx_xor_r2, &fx_xor_r3, &fx_xor_r4, &fx_xor_r5, &fx_xor_r6, &fx_xor_r7,4312&fx_xor_r8, &fx_xor_r9, &fx_xor_r10, &fx_xor_r11, &fx_xor_r12, &fx_xor_r13, &fx_xor_r14, &fx_xor_r15,4313// d0 - df4314&fx_inc_r0, &fx_inc_r1, &fx_inc_r2, &fx_inc_r3, &fx_inc_r4, &fx_inc_r5, &fx_inc_r6, &fx_inc_r7,4315&fx_inc_r8, &fx_inc_r9, &fx_inc_r10, &fx_inc_r11, &fx_inc_r12, &fx_inc_r13, &fx_inc_r14, &fx_getc,4316// e0 - ef4317&fx_dec_r0, &fx_dec_r1, &fx_dec_r2, &fx_dec_r3, &fx_dec_r4, &fx_dec_r5, &fx_dec_r6, &fx_dec_r7,4318&fx_dec_r8, &fx_dec_r9, &fx_dec_r10, &fx_dec_r11, &fx_dec_r12, &fx_dec_r13, &fx_dec_r14, &fx_getbh,4319// f0 - ff4320&fx_lm_r0, &fx_lm_r1, &fx_lm_r2, &fx_lm_r3, &fx_lm_r4, &fx_lm_r5, &fx_lm_r6, &fx_lm_r7,4321&fx_lm_r8, &fx_lm_r9, &fx_lm_r10, &fx_lm_r11, &fx_lm_r12, &fx_lm_r13, &fx_lm_r14, &fx_lm_r15,43224323// ALT2 Table43244325// 00 - 0f4326&fx_stop, &fx_nop, &fx_cache, &fx_lsr, &fx_rol, &fx_bra, &fx_bge, &fx_blt,4327&fx_bne, &fx_beq, &fx_bpl, &fx_bmi, &fx_bcc, &fx_bcs, &fx_bvc, &fx_bvs,4328// 10 - 1f4329&fx_to_r0, &fx_to_r1, &fx_to_r2, &fx_to_r3, &fx_to_r4, &fx_to_r5, &fx_to_r6, &fx_to_r7,4330&fx_to_r8, &fx_to_r9, &fx_to_r10, &fx_to_r11, &fx_to_r12, &fx_to_r13, &fx_to_r14, &fx_to_r15,4331// 20 - 2f4332&fx_with_r0, &fx_with_r1, &fx_with_r2, &fx_with_r3, &fx_with_r4, &fx_with_r5, &fx_with_r6, &fx_with_r7,4333&fx_with_r8, &fx_with_r9, &fx_with_r10, &fx_with_r11, &fx_with_r12, &fx_with_r13, &fx_with_r14, &fx_with_r15,4334// 30 - 3f4335&fx_stw_r0, &fx_stw_r1, &fx_stw_r2, &fx_stw_r3, &fx_stw_r4, &fx_stw_r5, &fx_stw_r6, &fx_stw_r7,4336&fx_stw_r8, &fx_stw_r9, &fx_stw_r10, &fx_stw_r11, &fx_loop, &fx_alt1, &fx_alt2, &fx_alt3,4337// 40 - 4f4338&fx_ldw_r0, &fx_ldw_r1, &fx_ldw_r2, &fx_ldw_r3, &fx_ldw_r4, &fx_ldw_r5, &fx_ldw_r6, &fx_ldw_r7,4339&fx_ldw_r8, &fx_ldw_r9, &fx_ldw_r10, &fx_ldw_r11, &fx_plot_2bit, &fx_swap, &fx_color, &fx_not,4340// 50 - 5f4341&fx_add_i0, &fx_add_i1, &fx_add_i2, &fx_add_i3, &fx_add_i4, &fx_add_i5, &fx_add_i6, &fx_add_i7,4342&fx_add_i8, &fx_add_i9, &fx_add_i10, &fx_add_i11, &fx_add_i12, &fx_add_i13, &fx_add_i14, &fx_add_i15,4343// 60 - 6f4344&fx_sub_i0, &fx_sub_i1, &fx_sub_i2, &fx_sub_i3, &fx_sub_i4, &fx_sub_i5, &fx_sub_i6, &fx_sub_i7,4345&fx_sub_i8, &fx_sub_i9, &fx_sub_i10, &fx_sub_i11, &fx_sub_i12, &fx_sub_i13, &fx_sub_i14, &fx_sub_i15,4346// 70 - 7f4347&fx_merge, &fx_and_i1, &fx_and_i2, &fx_and_i3, &fx_and_i4, &fx_and_i5, &fx_and_i6, &fx_and_i7,4348&fx_and_i8, &fx_and_i9, &fx_and_i10, &fx_and_i11, &fx_and_i12, &fx_and_i13, &fx_and_i14, &fx_and_i15,4349// 80 - 8f4350&fx_mult_i0, &fx_mult_i1, &fx_mult_i2, &fx_mult_i3, &fx_mult_i4, &fx_mult_i5, &fx_mult_i6, &fx_mult_i7,4351&fx_mult_i8, &fx_mult_i9, &fx_mult_i10, &fx_mult_i11, &fx_mult_i12, &fx_mult_i13, &fx_mult_i14, &fx_mult_i15,4352// 90 - 9f4353&fx_sbk, &fx_link_i1, &fx_link_i2, &fx_link_i3, &fx_link_i4, &fx_sex, &fx_asr, &fx_ror,4354&fx_jmp_r8, &fx_jmp_r9, &fx_jmp_r10, &fx_jmp_r11, &fx_jmp_r12, &fx_jmp_r13, &fx_lob, &fx_fmult,4355// a0 - af4356&fx_sms_r0, &fx_sms_r1, &fx_sms_r2, &fx_sms_r3, &fx_sms_r4, &fx_sms_r5, &fx_sms_r6, &fx_sms_r7,4357&fx_sms_r8, &fx_sms_r9, &fx_sms_r10, &fx_sms_r11, &fx_sms_r12, &fx_sms_r13, &fx_sms_r14, &fx_sms_r15,4358// b0 - bf4359&fx_from_r0, &fx_from_r1, &fx_from_r2, &fx_from_r3, &fx_from_r4, &fx_from_r5, &fx_from_r6, &fx_from_r7,4360&fx_from_r8, &fx_from_r9, &fx_from_r10, &fx_from_r11, &fx_from_r12, &fx_from_r13, &fx_from_r14, &fx_from_r15,4361// c0 - cf4362&fx_hib, &fx_or_i1, &fx_or_i2, &fx_or_i3, &fx_or_i4, &fx_or_i5, &fx_or_i6, &fx_or_i7,4363&fx_or_i8, &fx_or_i9, &fx_or_i10, &fx_or_i11, &fx_or_i12, &fx_or_i13, &fx_or_i14, &fx_or_i15,4364// d0 - df4365&fx_inc_r0, &fx_inc_r1, &fx_inc_r2, &fx_inc_r3, &fx_inc_r4, &fx_inc_r5, &fx_inc_r6, &fx_inc_r7,4366&fx_inc_r8, &fx_inc_r9, &fx_inc_r10, &fx_inc_r11, &fx_inc_r12, &fx_inc_r13, &fx_inc_r14, &fx_ramb,4367// e0 - ef4368&fx_dec_r0, &fx_dec_r1, &fx_dec_r2, &fx_dec_r3, &fx_dec_r4, &fx_dec_r5, &fx_dec_r6, &fx_dec_r7,4369&fx_dec_r8, &fx_dec_r9, &fx_dec_r10, &fx_dec_r11, &fx_dec_r12, &fx_dec_r13, &fx_dec_r14, &fx_getbl,4370// f0 - ff4371&fx_sm_r0, &fx_sm_r1, &fx_sm_r2, &fx_sm_r3, &fx_sm_r4, &fx_sm_r5, &fx_sm_r6, &fx_sm_r7,4372&fx_sm_r8, &fx_sm_r9, &fx_sm_r10, &fx_sm_r11, &fx_sm_r12, &fx_sm_r13, &fx_sm_r14, &fx_sm_r15,43734374// ALT3 Table43754376// 00 - 0f4377&fx_stop, &fx_nop, &fx_cache, &fx_lsr, &fx_rol, &fx_bra, &fx_bge, &fx_blt,4378&fx_bne, &fx_beq, &fx_bpl, &fx_bmi, &fx_bcc, &fx_bcs, &fx_bvc, &fx_bvs,4379// 10 - 1f4380&fx_to_r0, &fx_to_r1, &fx_to_r2, &fx_to_r3, &fx_to_r4, &fx_to_r5, &fx_to_r6, &fx_to_r7,4381&fx_to_r8, &fx_to_r9, &fx_to_r10, &fx_to_r11, &fx_to_r12, &fx_to_r13, &fx_to_r14, &fx_to_r15,4382// 20 - 2f4383&fx_with_r0, &fx_with_r1, &fx_with_r2, &fx_with_r3, &fx_with_r4, &fx_with_r5, &fx_with_r6, &fx_with_r7,4384&fx_with_r8, &fx_with_r9, &fx_with_r10, &fx_with_r11, &fx_with_r12, &fx_with_r13, &fx_with_r14, &fx_with_r15,4385// 30 - 3f4386&fx_stb_r0, &fx_stb_r1, &fx_stb_r2, &fx_stb_r3, &fx_stb_r4, &fx_stb_r5, &fx_stb_r6, &fx_stb_r7,4387&fx_stb_r8, &fx_stb_r9, &fx_stb_r10, &fx_stb_r11, &fx_loop, &fx_alt1, &fx_alt2, &fx_alt3,4388// 40 - 4f4389&fx_ldb_r0, &fx_ldb_r1, &fx_ldb_r2, &fx_ldb_r3, &fx_ldb_r4, &fx_ldb_r5, &fx_ldb_r6, &fx_ldb_r7,4390&fx_ldb_r8, &fx_ldb_r9, &fx_ldb_r10, &fx_ldb_r11, &fx_rpix_2bit, &fx_swap, &fx_cmode, &fx_not,4391// 50 - 5f4392&fx_adc_i0, &fx_adc_i1, &fx_adc_i2, &fx_adc_i3, &fx_adc_i4, &fx_adc_i5, &fx_adc_i6, &fx_adc_i7,4393&fx_adc_i8, &fx_adc_i9, &fx_adc_i10, &fx_adc_i11, &fx_adc_i12, &fx_adc_i13, &fx_adc_i14, &fx_adc_i15,4394// 60 - 6f4395&fx_cmp_r0, &fx_cmp_r1, &fx_cmp_r2, &fx_cmp_r3, &fx_cmp_r4, &fx_cmp_r5, &fx_cmp_r6, &fx_cmp_r7,4396&fx_cmp_r8, &fx_cmp_r9, &fx_cmp_r10, &fx_cmp_r11, &fx_cmp_r12, &fx_cmp_r13, &fx_cmp_r14, &fx_cmp_r15,4397// 70 - 7f4398&fx_merge, &fx_bic_i1, &fx_bic_i2, &fx_bic_i3, &fx_bic_i4, &fx_bic_i5, &fx_bic_i6, &fx_bic_i7,4399&fx_bic_i8, &fx_bic_i9, &fx_bic_i10, &fx_bic_i11, &fx_bic_i12, &fx_bic_i13, &fx_bic_i14, &fx_bic_i15,4400// 80 - 8f4401&fx_umult_i0, &fx_umult_i1, &fx_umult_i2, &fx_umult_i3, &fx_umult_i4, &fx_umult_i5, &fx_umult_i6, &fx_umult_i7,4402&fx_umult_i8, &fx_umult_i9, &fx_umult_i10, &fx_umult_i11, &fx_umult_i12, &fx_umult_i13, &fx_umult_i14, &fx_umult_i15,4403// 90 - 9f4404&fx_sbk, &fx_link_i1, &fx_link_i2, &fx_link_i3, &fx_link_i4, &fx_sex, &fx_div2, &fx_ror,4405&fx_ljmp_r8, &fx_ljmp_r9, &fx_ljmp_r10, &fx_ljmp_r11, &fx_ljmp_r12, &fx_ljmp_r13, &fx_lob, &fx_lmult,4406// a0 - af4407&fx_lms_r0, &fx_lms_r1, &fx_lms_r2, &fx_lms_r3, &fx_lms_r4, &fx_lms_r5, &fx_lms_r6, &fx_lms_r7,4408&fx_lms_r8, &fx_lms_r9, &fx_lms_r10, &fx_lms_r11, &fx_lms_r12, &fx_lms_r13, &fx_lms_r14, &fx_lms_r15,4409// b0 - bf4410&fx_from_r0, &fx_from_r1, &fx_from_r2, &fx_from_r3, &fx_from_r4, &fx_from_r5, &fx_from_r6, &fx_from_r7,4411&fx_from_r8, &fx_from_r9, &fx_from_r10, &fx_from_r11, &fx_from_r12, &fx_from_r13, &fx_from_r14, &fx_from_r15,4412// c0 - cf4413&fx_hib, &fx_xor_i1, &fx_xor_i2, &fx_xor_i3, &fx_xor_i4, &fx_xor_i5, &fx_xor_i6, &fx_xor_i7,4414&fx_xor_i8, &fx_xor_i9, &fx_xor_i10, &fx_xor_i11, &fx_xor_i12, &fx_xor_i13, &fx_xor_i14, &fx_xor_i15,4415// d0 - df4416&fx_inc_r0, &fx_inc_r1, &fx_inc_r2, &fx_inc_r3, &fx_inc_r4, &fx_inc_r5, &fx_inc_r6, &fx_inc_r7,4417&fx_inc_r8, &fx_inc_r9, &fx_inc_r10, &fx_inc_r11, &fx_inc_r12, &fx_inc_r13, &fx_inc_r14, &fx_romb,4418// e0 - ef4419&fx_dec_r0, &fx_dec_r1, &fx_dec_r2, &fx_dec_r3, &fx_dec_r4, &fx_dec_r5, &fx_dec_r6, &fx_dec_r7,4420&fx_dec_r8, &fx_dec_r9, &fx_dec_r10, &fx_dec_r11, &fx_dec_r12, &fx_dec_r13, &fx_dec_r14, &fx_getbs,4421// f0 - ff4422&fx_lm_r0, &fx_lm_r1, &fx_lm_r2, &fx_lm_r3, &fx_lm_r4, &fx_lm_r5, &fx_lm_r6, &fx_lm_r7,4423&fx_lm_r8, &fx_lm_r9, &fx_lm_r10, &fx_lm_r11, &fx_lm_r12, &fx_lm_r13, &fx_lm_r14, &fx_lm_r154424};442544264427