diff -Nru osmose-0.8.5b/changes.txt osmose-0.9.1/changes.txt --- osmose-0.8.5b/changes.txt 2009-01-15 09:43:08.000000000 +0000 +++ osmose-0.9.1/changes.txt 2009-11-01 10:16:39.000000000 +0000 @@ -1,8 +1,44 @@ +Osmose-0-9-1 (No GUI) 13th public release +----------------------------------------- + +-Uses users home .osmose directory for saves and config file. +-Fix several code ambiguous parenthesis that make GCC complain.. +-Remove various debugging traces. +-Makefile few changes. +-Rewrite portable FPS calculation. +-Use a larger sound buffer since SDL 1.2.14 uses ALSA instead of OSS when + possible and is more CPU intensive. This caused a big CPU load. +-Bug fix in the save state system: + * Cpu flags and flags copy weren't saved. + * Memory mapping was restored by fake writes into mapping register, which + is wrong. Now pointed areas and bloc numbers are saved. Drawback : the + previous save are not compatible with this osmose version. +-Defaut P1 A/B are mapped on W/V Key. This avoid virtual desktop changing while + playing :) P2 A/B are now j/m + +Osmose-0-9-0b +------------- + OpenGL/GUI only release. + + +Osmose-0-8-7: +------------- +-Modify osmose behaviour to allow running it into GUI. + run() becomes run_frame(). +-Remove non portable auto frameskip and Precision Timer. + + + +Osmose-0-8-6: +------------- + +-Small modifications to avoid compilation warning on some platforms. + Osmose-0-8-5b 11th public (beta) release ---------------------------------------- --Use a lookup table instead of switch / if else for TextWriter (Faster). --FPS is now writen into emulated display instead of Window's Title so it can - be seen in fullscreen. +-Use a lookup table instead of switch / if else for TextWriter (Faster). +-FPS is now writen into emulated display instead of Window's Title so it can + be seen in fullscreen. -Add option -bilinear to force hardware bilinear filtering on the video output. The default is nearest neighbour. diff -Nru osmose-0.8.5b/cpu/Z80.cpp osmose-0.9.1/cpu/Z80.cpp --- osmose-0.8.5b/cpu/Z80.cpp 2006-11-27 17:42:06.000000000 +0000 +++ osmose-0.9.1/cpu/Z80.cpp 2009-10-25 07:57:19.000000000 +0000 @@ -1,683 +1,763 @@ -/***************************************************************************** -* -* File: Z80.h -* -* Project: Oldspark emulator. -* -* Description: This class implements Z80 cpu emulator. It's table driven, and all -* opcodes are supported. Not that undocumented flags are not totaly supported. -* In these files are defined almost all ALU, and Shift operations. Adress mode -* getters and setters are define in Z80.h as statics methods. -* -* Author: Vedder Bruno -* Date: 10/01/2006, Thailand, Laos Cambodia :-) -* -* URL: http://bcz.emu-france.com/ -*****************************************************************************/ - -#include "Z80.h" -#include -#include -#include - -// Precomputed parity, sign and zero flags table. -u8 Z80::PF_SF_ZF_[256] = { - ZF|PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, - SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, - SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, - SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, - SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, - SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, - SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, - SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF -}; - -// Precomputed parity table. -u8 Z80::PF_[256] = { - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, - PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF -}; - -u8 Z80::bitval[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; - -/* Constructor, initialise env reference. */ -Z80::Z80( Z80Environment &_env ): env( _env ) -{ -#ifdef OPCODES_STATS - NO_Prefix = new u32[256]; - CB_Prefix = new u32[256]; - DD_Prefix = new u32[256]; - ED_Prefix = new u32[256]; - FD_Prefix = new u32[256]; - DDCB_Prefix = new u32[256]; - FDCB_Prefix = new u32[256]; - - // Clear Statistics tables. - for( u16 i = 0; i < 256; i++ ) - { - NO_Prefix[i] = 0; - CB_Prefix[i] = 0; - DD_Prefix[i] = 0; - ED_Prefix[i] = 0; - FD_Prefix[i] = 0; - DDCB_Prefix[i] = 0; - FDCB_Prefix[i] = 0; - } +/***************************************************************************** +* +* File: Z80.h +* +* Project: Oldspark emulator. +* +* Description: This class implements Z80 cpu emulator. It's table driven, and all +* opcodes are supported. Not that undocumented flags are not totaly supported. +* In these files are defined almost all ALU, and Shift operations. Adress mode +* getters and setters are define in Z80.h as statics methods. +* +* Author: Vedder Bruno +* Date: 10/01/2006, Thailand, Laos Cambodia :-) +* +* URL: http://bcz.emu-france.com/ +*****************************************************************************/ + +#include "Z80.h" +#include +#include +#include + +// Precomputed parity, sign and zero flags table. +u8 Z80::PF_SF_ZF_[256] = { + ZF|PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, + SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, + SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, + SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, + SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, + SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, + SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, + SF|PF, SF, SF, SF|PF, SF, SF|PF, SF|PF, SF, SF, SF|PF, SF|PF, SF, SF|PF, SF, SF, SF|PF +}; + +// Precomputed parity table. +u8 Z80::PF_[256] = { + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + 0, PF, PF, 0, PF, 0, 0, PF, PF, 0, 0, PF, 0, PF, PF, 0, + PF, 0, 0, PF, 0, PF, PF, 0, 0, PF, PF, 0, PF, 0, 0, PF +}; + +u8 Z80::bitval[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; + +/* Constructor, initialise env reference. */ +Z80::Z80( Z80Environment &_env ): env( _env ) +{ +#ifdef OPCODES_STATS + NO_Prefix = new u32[256]; + CB_Prefix = new u32[256]; + DD_Prefix = new u32[256]; + ED_Prefix = new u32[256]; + FD_Prefix = new u32[256]; + DDCB_Prefix = new u32[256]; + FDCB_Prefix = new u32[256]; + + // Clear Statistics tables. + for( u16 i = 0; i < 256; i++ ) + { + NO_Prefix[i] = 0; + CB_Prefix[i] = 0; + DD_Prefix[i] = 0; + ED_Prefix[i] = 0; + FD_Prefix[i] = 0; + DDCB_Prefix[i] = 0; + FDCB_Prefix[i] = 0; + } +#endif + reset(); +} + +#ifdef OPCODES_STATS + void Z80::opcodes_stats() + { + printf( "No prefixed instructions\n" ); + for( u16 i = 0; i < 256; i++ ) + { + printf( "0x%.2x used %d times.\n", i, NO_Prefix[i] ); + } + + printf( "\nCB prefixed instructions\n" ); + for( u16 i = 0; i < 256; i++ ) + { + printf( "0xCB%.2x used %d times.\n", i, CB_Prefix[i] ); + } + + printf( "\nDD prefixed instructions\n" ); + for( u16 i = 0; i < 256; i++ ) + { + printf( "0xDD%.2x used %d times.\n", i, DD_Prefix[i] ); + } + + printf( "\nDDCB prefixed instructions\n" ); + for( u16 i = 0; i < 256; i++ ) + { + printf( "0xDDCB%.2x used %d times.\n", i, DDCB_Prefix[i] ); + } + + printf( "\nED prefixed instructions\n" ); + for( u16 i = 0; i < 256; i++ ) + { + printf( "0xED%.2x used %d times.\n", i, ED_Prefix[i] ); + } + + printf( "\nFD prefixed instructions\n" ); + for( u16 i = 0; i < 256; i++ ) + { + printf( "0xFD%.2x used %d times.\n", i, FD_Prefix[i] ); + } + + printf( "\nFDCB prefixed instructions\n" ); + for( u16 i = 0; i < 256; i++ ) + { + printf( "0xFDCB%.2x used %d times.\n", i, FDCB_Prefix[i] ); + } + } #endif - reset(); -} - -#ifdef OPCODES_STATS - void Z80::opcodes_stats() - { - printf( "No prefixed instructions\n" ); - for( u16 i = 0; i < 256; i++ ) - { - printf( "0x%.2x used %d times.\n", i, NO_Prefix[i] ); - } - - printf( "\nCB prefixed instructions\n" ); - for( u16 i = 0; i < 256; i++ ) - { - printf( "0xCB%.2x used %d times.\n", i, CB_Prefix[i] ); - } - - printf( "\nDD prefixed instructions\n" ); - for( u16 i = 0; i < 256; i++ ) - { - printf( "0xDD%.2x used %d times.\n", i, DD_Prefix[i] ); - } - - printf( "\nDDCB prefixed instructions\n" ); - for( u16 i = 0; i < 256; i++ ) - { - printf( "0xDDCB%.2x used %d times.\n", i, DDCB_Prefix[i] ); - } - - printf( "\nED prefixed instructions\n" ); - for( u16 i = 0; i < 256; i++ ) - { - printf( "0xED%.2x used %d times.\n", i, ED_Prefix[i] ); - } - - printf( "\nFD prefixed instructions\n" ); - for( u16 i = 0; i < 256; i++ ) - { - printf( "0xFD%.2x used %d times.\n", i, FD_Prefix[i] ); - } - - printf( "\nFDCB prefixed instructions\n" ); - for( u16 i = 0; i < 256; i++ ) - { - printf( "0xFDCB%.2x used %d times.\n", i, FDCB_Prefix[i] ); - } - } -#endif - -/* Destructor */ -Z80::~Z80(){} - -void Z80::reset() -{ - F = ZF; - A = B = C = D = E = H = L = I = R = Rbit7 =0x0; - A1 = B1 = C1 = D1 = E1 = H1 = L1 = 0x0; - IX = IY = PC = 0x0000; - SP = 0xF000; - IFF1 = IFF2 = cpuHalted = false; /* IRQ/HALT opcode flags */ - IM = 0; /* interrupt mode set to Zero. */ - cycleCount = 0; /* Reset CPU cycles counter. */ -} - -void Z80::dump( u16 addr ) -{ - printf( "%.4x : ", addr ); - for( int i = 0; i < 8; i++ ) - { - printf( "%.2x ", env.rd8(( addr + i ) &0xFFFF )); - } - printf( "\n" ); -} - -/** - * Basic Arithmetic CPU Operations: - */ -u8 Z80::inc8( u8 v ) -{ - v++; /* Inc value, wrap on 8 bits */ - F &= CF; /* Clear all used flags */ - F |= ( v &0x80 ); /* Save S flag (bit sign) */ - if( v == 0 ) F |= ZF; /* If v is zero Set Zero bit. */ - if( v == 0x80 ) F |= VF; /* Set Overflow flag */ - if( !( v &0xf )) F |= 0x10; /* Half flag if Carry from bit 3*/ -// F |= ( v &( YF | XF )); /* undocumented flag bits 5+3 */ - return ( v ); -} - - -u8 Z80::dec8( u8 v ) -{ - v--; /* Dec value, wrap on 8 bit */ - F = ( F &CF ) | NF; /* Clear all used flags set N */ - F |= ( v &SF ); /* Save S flag (bit sign) */ - if( v == 0 ) F |= ZF; /* If v is zero Set Zero bit. */ - if( v == 0x7f ) F |= VF; /* Set overflow flag */ - if(( v &0x0f ) == 0x0f ) F |= HF; /* Half carry */ -// F |= ( v &( YF | XF )); /* undocumented flag bits 5+3 */ - return ( v ); -} - -/* Add -> Never overflow if sign a != sign b */ -/* if sign a == sign b then (a^b)& 80 is 0 , so overflow possible */ -/* ~(a^b)& 80 gives opposite result that we AND with second condition to overflow:*/ -/* a & F sign != means overflow -> (a^F)&0x80 true mean overflow. */ -/* Luckily sign is stored in bit 7 in F, so we xor can A and F */ -u8 Z80::add8( u8 a, u8 b ) -{ - u16 tmp1 = (( a + b )); - F = ( tmp1 &0x80 ); /* Set sign */ - F |= ( tmp1 >> 8 ); /* Set Carry */ - tmp1 &= 0xff; /* 8bit wrap */ - if(( tmp1 ^ a ^ b ) &0x10 ) F |= HF; /* Set Half flag */ - if( ~( a ^ b ) &( a ^ F ) &0x80 ) F |= VF; /* Set VF flag F already has sign.*/ - if( tmp1 == 0 ) F |= ZF; /* Set Zero Flag */ -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - -u8 Z80::adc8( u8 a, u8 b ) -{ - u16 tmp1 = (( a + b ) + ( F &CF )); - F = ( tmp1 &0x80 ); /* Save sign */ - F |= (( tmp1 ) >> 8 ); /* Set Carry */ - tmp1 &= 0xff; /* 8bit wrap */ - if( tmp1 == 0 ) F |= ZF; /* Set Zero Flag */ - if((( a ^ b ^ tmp1 ) &0x10 ) != 0 ) F |= HF; /* Set Half flag */ - if( ~( a ^ b ) &( a ^ F ) &0x80 ) F |= VF; /* Set VF flag F already has sign.*/ -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - -u8 Z80::sbc8( u8 a, u8 b ) -{ - u16 tmp1 = a - b - ( F &CF ); - F = ( tmp1 &0x80 ) | NF; /* save sign, set NF */ - F |= (( tmp1 &0x100 ) >> 8 ); /* save carry */ - if((( a ^ b ^ tmp1 ) &0x10 ) != 0 ) F |= HF; - if((( b ^ a ) &( a ^ tmp1 ) &0x80 ) != 0 ) F |= VF; - tmp1 &= 0xff; - if( tmp1 == 0 ) F |= ZF; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - -u8 Z80::sub8( u8 a, u8 b ) -{ - u16 tmp1 = ( a - b ); - F = ( tmp1 &0x80 ) | NF; /* Save sign, set N flag */ - if( tmp1 == 0 ) F |= ZF; /* Set Zero Flag */ - F |= ( tmp1 &0x100 ) >> 8; /* Set Carry */ - if((( b ^ a ) &( a ^ tmp1 ) &0x80 ) != 0 ) F |= VF; /* Set overflow */ - if((( a ^ b ^ tmp1 ) &0x10 ) != 0 ) F |= HF; /* Set Half flag */ - tmp1 &= 0xff; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - - -u16 Z80::add16( u16 a, u16 b ) -{ - u32 res = a + b; - F &= SF | ZF | PF; - if( res > 0xFFFF ) F |= CF; - if((( a &0xFFF ) + ( b &0xFFF )) > 0xFFF ) F |= HF; - return ( res &0xFFFF ); -} - - -void Z80::sbcHL( u16 value ) -{ - u16 _HLD = getHL(); - u32 result = _HLD - value - ( F &1 ); - F = ((( _HLD ^ result ^ value ) >> 8 ) &0x10 ) | 0x02; - F |= (( result >> 16 ) &1 ) | (( result >> 8 ) &0x80 ); - F |= ((( result &0xffff ) != 0 ) ? 0 : 0x40 ); - F |= ((( value ^ _HLD ) &( _HLD ^ result ) &0x8000 ) >> 13 ); - H = ( result >> 8 ) &0xff; - L = result &0xff; - cycleCount += 15; -} - -void Z80::adcHL( u16 value ) -{ - u16 tmp1 = getHL(); - u32 result = tmp1 + value + ( F &1 ); - F = ((( tmp1 ^ result ^ value ) >> 8 ) &0x10 ); - F |= (( result >> 16 ) &1 ) | (( result >> 8 ) &0x80 ); - F |= ((( result &0xffff ) != 0 ) ? 0 : 0x40 ); - F |= ((( value ^ tmp1 ^ 0x8000 ) &( value ^ result ) &0x8000 ) >> 13 ); - H = ( result >> 8 ) &0xff; - L = result &0xff; - cycleCount += 15; - -} - -/* Acts like sub, but do not affect operands.*/ -void Z80::cp8( u8 a, u8 b ) -{ - sub8( a, b ); -} - -/** - * Basic Logical CPU Operations: - */ -u8 Z80::and8( u8 a, u8 b ) -{ - u8 tmp1 = ( a & b ); - F = HF; /* Set H, clear SZ H P/V N and C */ - F |= PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return ( tmp1 ); -} - -u8 Z80::xor8( u8 a, u8 b ) -{ - u8 tmp1 = ( a ^ b ); - F = PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - -u8 Z80::or8( u8 a, u8 b ) -{ - u8 tmp1 = ( a | b ); - F = PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - -/** - * Basic Shift CPU Operations: - */ -u8 Z80::rlc8( u8 v ) -{ - u8 tmp1 = ( v << 1 ); - F = ( v >> 7 ); /* All flags to zero, C = bit7 */ - tmp1 |= ( F &1 ); - F |= PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - - -u8 Z80::rrc8( u8 v ) -{ - u8 tmp1 = v >> 1; - F = ( v &1 ); /* Set Carry from bit0*/ - tmp1 |= ( F << 7 ); /* Set outgoing bit0 in bit7 */ - F |= PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - - -u8 Z80::rl8( u8 v ) -{ - u8 tmp1 = (( v << 1 ) | ( F &1 )); - F = v >> 7; /* F = bit7 */ - F |= PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - - -u8 Z80::rr8( u8 v ) -{ - u8 c = ( F & 1 ); - F = v & 1; /* bit0 -> Carry */ - u8 tmp1 = ( v >> 1 ) | ( c << 7 ); /* Old Carry -> bit7 */ - F |= PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - - -u8 Z80::sla8( u8 v ) -{ - F = ( v >> 7 ); - u8 tmp1 = ( v << 1 ); - F |= PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - -/* Undocumented 0xCB30 opcode. Support Undocumented flags. Tested. */ -u8 Z80::sll8( u8 v ) -{ - F = ( v >> 7 ); - u8 tmp1 = ( v << 1 ); - tmp1 |= 1; /* The only difference with sla8 */ - F |= PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - - -u8 Z80::sra8( u8 v ) -{ - F = ( v &1 ); /* Bit0 -> Carry */ - u8 tmp1 = ( v >> 1 ); - tmp1 |= ( v &0x80 ); /* Bit7 is keep unchanged */ - F |= PF_SF_ZF_[tmp1]; -// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ - return tmp1; -} - - -u8 Z80::srl8( u8 v ) -{ - F = v & 1; /* Bit0 -> Carry*/ - v >>= 1; /* Compute Value */ - F |= PF_SF_ZF_[v]; -// F |= ( v &( YF | XF )); /* undocumented flag bits 5+3 */ - return v; -} - -void Z80::rrd() -{ - u8 tmp1 = env.rd8( getHL()); - u8 tmp2 = tmp1; - tmp1 = ( tmp1 >> 4 ) | ( A << 4 ); - A = ( A &0xf0 ) | ( tmp2 &0xf ); - env.wr8( getHL(), tmp1 &0xff ); - F = F &1; - F |= PF_SF_ZF_[A]; -// F |= ( A &( YF | XF )); /* undocumented flag bits 5+3 */ - cycleCount += 18; -} - -void Z80::rld() -{ - u8 tmp1 = env.rd8( getHL()); - u8 tmp2 = tmp1; - tmp1 = ( tmp1 << 4 ) | ( A &0xf ); - A = ( A &0xf0 ) | ( tmp2 >> 4 ); - env.wr8( getHL(), tmp1 &0xff ); - F = F &1; - F |= PF_SF_ZF_[A]; -// F |= ( A &( YF | XF )); /* undocumented flag bits 5+3 */ - cycleCount += 18; -} - -/** - * Basic Bit CPU Operations: - */ -void Z80::bit( u8 bit, u8 v ) -{ - // Based on Sean Young documentation, "Z80-documented". - F = ( F & CF ) | HF; // Clear all bits except CF, HF (always set) from F. - if( !( v &( 1 << bit ))) F |= ( ZF | PF ); // ZF is set if tested bit is reset.PF is like ZF. - if(( bit == 7 ) && !( F &ZF )) F |= SF; // if tested bit is 7 is set, set SF -// if(( bit == 5 ) && !( F &ZF )) F |= YF; // if tested bit is 5 is set, set YF UNDOC Flag -// if(( bit == 3 ) && !( F &ZF )) F |= XF; // if tested bit is 3 is set, set XF UNDOC Flag -} - -u8 Z80::set( u8 bit, u8 v ) -{ - return ( v |= bitval[bit] ); -} - -u8 Z80::res( u8 bit, u8 v ) -{ - return ( v &= ~bitval[bit] ); -} - -/** - * Basic Stack CPU Operations: - */ -u16 Z80::pop() -{ - u16 tmp1 = env.rd16( SP ); - SP += 2; - return ( tmp1 ); -} - -void Z80::push( u16 val ) -{ - SP -= 2; - env.wr16( SP, val ); -} - -void Z80::rst( u16 ea ) -{ - cycleCount += 11; - push( PC ); - PC = ea; -} - -void Z80::setFlagAfterInput( u8 readed ) -{ - F = ( F & CF ); /* Save the Carry Flag */ - F |= PF_SF_ZF_[readed]; -} - -void Z80::invalid_opcode() -{ - PC--; - step(); // Execute opcode from standard opcode table. - cycleCount += 4; // Timing penality. - printf ("Inv Opc\n"); -} - -void Z80::invalid_prefixed_opcode() -{ - PC--; - step(); // Execute opcode from standard opcode table. - cycleCount += 8; // Timing penality. - printf ("Inv Opc\n"); -} - -void Z80::nop() -{ - cycleCount += 4; -} - -/* This method generates a Non Maskable interrupt */ -void Z80::nmi() -{ - cpuHalted = false; /* UnHalt the cpu. */ - IFF1 = false; /* Disable interrupt. */ - push( PC ); /* Make call 0x66 */ - PC = 0x0066; - cycleCount += 11; -} - -/* -This method generates a Non Maskable interrupt. If cpu accept interrupt -the method returns true, else, interrupt are disabled and the method returns false. - */ -bool Z80::interrupt( u8 data ) -{ - if( IFF1 ) + +/* Destructor */ +Z80::~Z80(){} + +void Z80::reset() +{ + F = ZF; + A = B = C = D = E = H = L = I = R = Rbit7 =0x0; + A1 = B1 = C1 = D1 = E1 = H1 = L1 = 0x0; + IX = IY = PC = 0x0000; + SP = 0xF000; + IFF1 = IFF2 = cpuHalted = false; /* IRQ/HALT opcode flags */ + IM = 0; /* interrupt mode set to Zero. */ + cycleCount = 0; /* Reset CPU cycles counter. */ +} + +void Z80::dump( u16 addr ) +{ + printf( "%.4x : ", addr ); + for( int i = 0; i < 8; i++ ) + { + printf( "%.2x ", env.rd8(( addr + i ) &0xFFFF )); + } + printf( "\n" ); +} + +/** + * Basic Arithmetic CPU Operations: + */ +u8 Z80::inc8( u8 v ) +{ + v++; /* Inc value, wrap on 8 bits */ + F &= CF; /* Clear all used flags */ + F |= ( v &0x80 ); /* Save S flag (bit sign) */ + if( v == 0 ) F |= ZF; /* If v is zero Set Zero bit. */ + if( v == 0x80 ) F |= VF; /* Set Overflow flag */ + if( !( v &0xf )) F |= 0x10; /* Half flag if Carry from bit 3*/ +// F |= ( v &( YF | XF )); /* undocumented flag bits 5+3 */ + return ( v ); +} + + +u8 Z80::dec8( u8 v ) +{ + v--; /* Dec value, wrap on 8 bit */ + F = ( F &CF ) | NF; /* Clear all used flags set N */ + F |= ( v &SF ); /* Save S flag (bit sign) */ + if( v == 0 ) F |= ZF; /* If v is zero Set Zero bit. */ + if( v == 0x7f ) F |= VF; /* Set overflow flag */ + if(( v &0x0f ) == 0x0f ) F |= HF; /* Half carry */ +// F |= ( v &( YF | XF )); /* undocumented flag bits 5+3 */ + return ( v ); +} + +/* Add -> Never overflow if sign a != sign b */ +/* if sign a == sign b then (a^b)& 80 is 0 , so overflow possible */ +/* ~(a^b)& 80 gives opposite result that we AND with second condition to overflow:*/ +/* a & F sign != means overflow -> (a^F)&0x80 true mean overflow. */ +/* Luckily sign is stored in bit 7 in F, so we xor can A and F */ +u8 Z80::add8( u8 a, u8 b ) +{ + u16 tmp1 = (( a + b )); + F = ( tmp1 &0x80 ); /* Set sign */ + F |= ( tmp1 >> 8 ); /* Set Carry */ + tmp1 &= 0xff; /* 8bit wrap */ + if(( tmp1 ^ a ^ b ) &0x10 ) F |= HF; /* Set Half flag */ + if( ~( a ^ b ) &( a ^ F ) &0x80 ) F |= VF; /* Set VF flag F already has sign.*/ + if( tmp1 == 0 ) F |= ZF; /* Set Zero Flag */ +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + +u8 Z80::adc8( u8 a, u8 b ) +{ + u16 tmp1 = (( a + b ) + ( F &CF )); + F = ( tmp1 &0x80 ); /* Save sign */ + F |= (( tmp1 ) >> 8 ); /* Set Carry */ + tmp1 &= 0xff; /* 8bit wrap */ + if( tmp1 == 0 ) F |= ZF; /* Set Zero Flag */ + if((( a ^ b ^ tmp1 ) &0x10 ) != 0 ) F |= HF; /* Set Half flag */ + if( ~( a ^ b ) &( a ^ F ) &0x80 ) F |= VF; /* Set VF flag F already has sign.*/ +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + +u8 Z80::sbc8( u8 a, u8 b ) +{ + u16 tmp1 = a - b - ( F &CF ); + F = ( tmp1 &0x80 ) | NF; /* save sign, set NF */ + F |= (( tmp1 &0x100 ) >> 8 ); /* save carry */ + if((( a ^ b ^ tmp1 ) &0x10 ) != 0 ) F |= HF; + if((( b ^ a ) &( a ^ tmp1 ) &0x80 ) != 0 ) F |= VF; + tmp1 &= 0xff; + if( tmp1 == 0 ) F |= ZF; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + +u8 Z80::sub8( u8 a, u8 b ) +{ + u16 tmp1 = ( a - b ); + F = ( tmp1 &0x80 ) | NF; /* Save sign, set N flag */ + if( tmp1 == 0 ) F |= ZF; /* Set Zero Flag */ + F |= ( tmp1 &0x100 ) >> 8; /* Set Carry */ + if((( b ^ a ) &( a ^ tmp1 ) &0x80 ) != 0 ) F |= VF; /* Set overflow */ + if((( a ^ b ^ tmp1 ) &0x10 ) != 0 ) F |= HF; /* Set Half flag */ + tmp1 &= 0xff; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + + +u16 Z80::add16( u16 a, u16 b ) +{ + u32 res = a + b; + F &= SF | ZF | PF; + if( res > 0xFFFF ) F |= CF; + if((( a &0xFFF ) + ( b &0xFFF )) > 0xFFF ) F |= HF; + return ( res &0xFFFF ); +} + + +void Z80::sbcHL( u16 value ) +{ + u16 _HLD = getHL(); + u32 result = _HLD - value - ( F &1 ); + F = ((( _HLD ^ result ^ value ) >> 8 ) &0x10 ) | 0x02; + F |= (( result >> 16 ) &1 ) | (( result >> 8 ) &0x80 ); + F |= ((( result &0xffff ) != 0 ) ? 0 : 0x40 ); + F |= ((( value ^ _HLD ) &( _HLD ^ result ) &0x8000 ) >> 13 ); + H = ( result >> 8 ) &0xff; + L = result &0xff; + cycleCount += 15; +} + +void Z80::adcHL( u16 value ) +{ + u16 tmp1 = getHL(); + u32 result = tmp1 + value + ( F &1 ); + F = ((( tmp1 ^ result ^ value ) >> 8 ) &0x10 ); + F |= (( result >> 16 ) &1 ) | (( result >> 8 ) &0x80 ); + F |= ((( result &0xffff ) != 0 ) ? 0 : 0x40 ); + F |= ((( value ^ tmp1 ^ 0x8000 ) &( value ^ result ) &0x8000 ) >> 13 ); + H = ( result >> 8 ) &0xff; + L = result &0xff; + cycleCount += 15; + +} + +/* Acts like sub, but do not affect operands.*/ +void Z80::cp8( u8 a, u8 b ) +{ + sub8( a, b ); +} + +/** + * Basic Logical CPU Operations: + */ +u8 Z80::and8( u8 a, u8 b ) +{ + u8 tmp1 = ( a & b ); + F = HF; /* Set H, clear SZ H P/V N and C */ + F |= PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return ( tmp1 ); +} + +u8 Z80::xor8( u8 a, u8 b ) +{ + u8 tmp1 = ( a ^ b ); + F = PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + +u8 Z80::or8( u8 a, u8 b ) +{ + u8 tmp1 = ( a | b ); + F = PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + +/** + * Basic Shift CPU Operations: + */ +u8 Z80::rlc8( u8 v ) +{ + u8 tmp1 = ( v << 1 ); + F = ( v >> 7 ); /* All flags to zero, C = bit7 */ + tmp1 |= ( F &1 ); + F |= PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + + +u8 Z80::rrc8( u8 v ) +{ + u8 tmp1 = v >> 1; + F = ( v &1 ); /* Set Carry from bit0*/ + tmp1 |= ( F << 7 ); /* Set outgoing bit0 in bit7 */ + F |= PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + + +u8 Z80::rl8( u8 v ) +{ + u8 tmp1 = (( v << 1 ) | ( F &1 )); + F = v >> 7; /* F = bit7 */ + F |= PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + + +u8 Z80::rr8( u8 v ) +{ + u8 c = ( F & 1 ); + F = v & 1; /* bit0 -> Carry */ + u8 tmp1 = ( v >> 1 ) | ( c << 7 ); /* Old Carry -> bit7 */ + F |= PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + + +u8 Z80::sla8( u8 v ) +{ + F = ( v >> 7 ); + u8 tmp1 = ( v << 1 ); + F |= PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + +/* Undocumented 0xCB30 opcode. Support Undocumented flags. Tested. */ +u8 Z80::sll8( u8 v ) +{ + F = ( v >> 7 ); + u8 tmp1 = ( v << 1 ); + tmp1 |= 1; /* The only difference with sla8 */ + F |= PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + + +u8 Z80::sra8( u8 v ) +{ + F = ( v &1 ); /* Bit0 -> Carry */ + u8 tmp1 = ( v >> 1 ); + tmp1 |= ( v &0x80 ); /* Bit7 is keep unchanged */ + F |= PF_SF_ZF_[tmp1]; +// F |= ( tmp1 &( YF | XF )); /* undocumented flag bits 5+3 */ + return tmp1; +} + + +u8 Z80::srl8( u8 v ) +{ + F = v & 1; /* Bit0 -> Carry*/ + v >>= 1; /* Compute Value */ + F |= PF_SF_ZF_[v]; +// F |= ( v &( YF | XF )); /* undocumented flag bits 5+3 */ + return v; +} + +void Z80::rrd() +{ + u8 tmp1 = env.rd8( getHL()); + u8 tmp2 = tmp1; + tmp1 = ( tmp1 >> 4 ) | ( A << 4 ); + A = ( A &0xf0 ) | ( tmp2 &0xf ); + env.wr8( getHL(), tmp1 &0xff ); + F = F &1; + F |= PF_SF_ZF_[A]; +// F |= ( A &( YF | XF )); /* undocumented flag bits 5+3 */ + cycleCount += 18; +} + +void Z80::rld() +{ + u8 tmp1 = env.rd8( getHL()); + u8 tmp2 = tmp1; + tmp1 = ( tmp1 << 4 ) | ( A &0xf ); + A = ( A &0xf0 ) | ( tmp2 >> 4 ); + env.wr8( getHL(), tmp1 &0xff ); + F = F &1; + F |= PF_SF_ZF_[A]; +// F |= ( A &( YF | XF )); /* undocumented flag bits 5+3 */ + cycleCount += 18; +} + +/** + * Basic Bit CPU Operations: + */ +void Z80::bit( u8 bit, u8 v ) +{ + // Based on Sean Young documentation, "Z80-documented". + F = ( F & CF ) | HF; // Clear all bits except CF, HF (always set) from F. + if( !( v &( 1 << bit ))) F |= ( ZF | PF ); // ZF is set if tested bit is reset.PF is like ZF. + if(( bit == 7 ) && !( F &ZF )) F |= SF; // if tested bit is 7 is set, set SF +// if(( bit == 5 ) && !( F &ZF )) F |= YF; // if tested bit is 5 is set, set YF UNDOC Flag +// if(( bit == 3 ) && !( F &ZF )) F |= XF; // if tested bit is 3 is set, set XF UNDOC Flag +} + +u8 Z80::set( u8 bit, u8 v ) +{ + return ( v |= bitval[bit] ); +} + +u8 Z80::res( u8 bit, u8 v ) +{ + return ( v &= ~bitval[bit] ); +} + +/** + * Basic Stack CPU Operations: + */ +u16 Z80::pop() +{ + u16 tmp1 = env.rd16( SP ); + SP += 2; + return ( tmp1 ); +} + +void Z80::push( u16 val ) +{ + SP -= 2; + env.wr16( SP, val ); +} + +void Z80::rst( u16 ea ) +{ + cycleCount += 11; + push( PC ); + PC = ea; +} + +void Z80::setFlagAfterInput( u8 readed ) +{ + F = ( F & CF ); /* Save the Carry Flag */ + F |= PF_SF_ZF_[readed]; +} + +void Z80::invalid_opcode() +{ + PC--; + step(); // Execute opcode from standard opcode table. + cycleCount += 4; // Timing penality. + printf ("Inv Opc\n"); +} + +void Z80::invalid_prefixed_opcode() +{ + PC--; + step(); // Execute opcode from standard opcode table. + cycleCount += 8; // Timing penality. + printf ("Inv Opc\n"); +} + +void Z80::nop() +{ + cycleCount += 4; +} + +/* This method generates a Non Maskable interrupt */ +void Z80::nmi() +{ + cpuHalted = false; /* UnHalt the cpu. */ + IFF1 = false; /* Disable interrupt. */ + push( PC ); /* Make call 0x66 */ + PC = 0x0066; + cycleCount += 11; +} + +/* +This method generates a Non Maskable interrupt. If cpu accept interrupt +the method returns true, else, interrupt are disabled and the method returns false. + */ +bool Z80::interrupt( u8 data ) +{ + if( IFF1 ) { #ifdef BUILT_IN_DEBUGGER throwDebugEvent(DbgEvtCpuIrqAsserted, "CPU", "IRQ Asserted: CPU accepts it (DI)."); -#endif - /* Interrupts are enabled */ - cpuHalted = false; // UnHalt the CPU. - IFF1 = IFF2 = false; // Disable Maskable interrupt - switch( IM ) - { - case 0: - (this->*(Opc_std[data]))(); // Exec opcode pushed on the bus (data). - cycleCount += 13; - break; - case 1: - push( PC ); - PC = 0x38; - cycleCount += 13; - break; - case 2: - push( PC ); - PC = env.rd16((I << 8) | (data & 0xFE)); - cycleCount += 19; - break; - } - return true; - } - else - { +#endif + /* Interrupts are enabled */ + cpuHalted = false; // UnHalt the CPU. + IFF1 = IFF2 = false; // Disable Maskable interrupt + switch( IM ) + { + case 0: + (this->*(Opc_std[data]))(); // Exec opcode pushed on the bus (data). + cycleCount += 13; + break; + case 1: + push( PC ); + PC = 0x38; + cycleCount += 13; + break; + case 2: + push( PC ); + PC = env.rd16((I << 8) | (data & 0xFE)); + cycleCount += 19; + break; + } + return true; + } + else + { #ifdef BUILT_IN_DEBUGGER throwDebugEvent(DbgEvtCpuIrqAsserted, "CPU", "IRQ Asserted: CPU refuse it (DI)."); #endif - return false; - } -} - -/* Execute one single instruction. */ -void Z80::step() -{ - R++; - if( cpuHalted == true ) - { - cycleCount += 4; - } - else - { - //env.disasm(PC); - u8 instruction = env.rd8( PC++ ); - (this->*(Opc_std[instruction]))(); - #ifdef OPCODES_STATS - NO_Prefix[ instruction ]++; - #endif - } -} - -u32 Z80::run( u32 wanted_cycles ) -{ - u8 instruction; // Current Opcode - u32 tc = cycleCount + wanted_cycles; - - while( cycleCount < tc ) + return false; + } +} + +/* Execute one single instruction. */ +void Z80::step() +{ + R++; + if( cpuHalted == true ) + { + cycleCount += 4; + } + else + { + //env.disasm(PC); + u8 instruction = env.rd8( PC++ ); + (this->*(Opc_std[instruction]))(); + #ifdef OPCODES_STATS + NO_Prefix[ instruction ]++; + #endif + } +} + +u32 Z80::run( u32 wanted_cycles ) +{ + u8 instruction; // Current Opcode + u32 tc = cycleCount + wanted_cycles; + + while( cycleCount < tc ) { #ifdef BUILT_IN_DEBUGGER throwDebugEvent(DbgEvtCpuStep, "CPU", "CPU step."); -#endif - R++; - if( cpuHalted ) - { - /* Instead of looping doing NOP, compute How many nop to do */ - /* and adjust cycleCount and R accordingly. NOP is 4 cycles.*/ - /* cycleCount += 4; */ - u32 n = ((tc +3 - cycleCount) / 4); - R += n; - cycleCount += n * 4; - } - else - { - instruction = env.rd8( PC++ ); - (this->*(Opc_std[instruction]))(); - #ifdef OPCODES_STATS - NO_Prefix[ instruction ]++; - #endif - } - } - return cycleCount - tc; // overcycles ! -} - -bool Z80::saveState( ofstream &ofs ) +#endif + R++; + if( cpuHalted ) + { + /* Instead of looping doing NOP, compute How many nop to do */ + /* and adjust cycleCount and R accordingly. NOP is 4 cycles.*/ + /* cycleCount += 4; */ + u32 n = ((tc +3 - cycleCount) / 4); + R += n; + cycleCount += n * 4; + } + else + { + instruction = env.rd8( PC++ ); + (this->*(Opc_std[instruction]))(); + #ifdef OPCODES_STATS + NO_Prefix[ instruction ]++; + #endif + } + } + return cycleCount - tc; // overcycles ! +} + +void Z80::dumpSaveStateStructure(Z80SaveState &css) +{ + cout << "Save state structure dump:" << endl << endl; + cout << hex << "css.A = " << (unsigned short) css.A << endl; + cout << "css.F = " << (unsigned short)css.F << endl; + cout << "css.B = " << (unsigned short)css.B << endl; + cout << "css.C = " << (unsigned short)css.C << endl; + cout << "css.D = " << (unsigned short) css.D << endl; + cout << "css.E = " << (unsigned short)css.E << endl; + cout << "css.H = " << (unsigned short)css.H << endl; + cout << "css.L = " << (unsigned short)css.L << endl; + cout << "css.I = " << (unsigned short)css.I << endl; + cout << "css.R = " << (unsigned short)css.R << endl; + + cout << "css.A1 = " << (unsigned short)css.A1 << endl; + cout << "css.F1 = " << (unsigned short)css.F1 << endl; + cout << "css.B1 = " << (unsigned short)css.B1 << endl; + cout << "css.C1 = " << (unsigned short)css.C1 << endl; + cout << "css.D1 = " << (unsigned short)css.D1 << endl; + cout << "css.E1 = " << (unsigned short)css.E1 << endl; + cout << "css.H1 = " << (unsigned short)css.H1 << endl; + cout << "css.L1 = " << (unsigned short)css.L1 << endl; + cout << "css.Rbit7 = " << (unsigned short)css.Rbit7 << endl; + + cout << "css.IM = " << (unsigned short)css.IM << endl; + cout << "css.PC = " << (unsigned short)css.PC << endl; + cout << "css.IX = " << (unsigned short)css.IX << endl; + cout << "css.IY = " << (unsigned short)css.IY << endl; + cout << "css.SP = " << (unsigned short)css.SP << endl; + cout << "css.IFF1 = " << css.IFF1 << endl; + cout << "css.IFF2 = " << css.IFF2 << dec << endl; + cout << "css.cpuHalted = " << (unsigned int) css.cpuHalted << endl; + cout << "css.cycleCount = " << (unsigned int) css.cycleCount << endl << endl; +} + + +void Z80::dumpValues() +{ + cout << "CPU register dump:" << endl << endl; + cout << hex << "A = " << (unsigned short) A << endl; + cout << "F = " << (unsigned short)F << endl; + cout << "B = " << (unsigned short)B << endl; + cout << "C = " << (unsigned short)C << endl; + cout << "D = " << (unsigned short)D << endl; + cout << "E = " << (unsigned short)E << endl; + cout << "H = " << (unsigned short)H << endl; + cout << "L = " << (unsigned short)L << endl; + cout << "I = " << (unsigned short)I << endl; + cout << "R = " << (unsigned short)R << endl; + + cout << "A1 = " << (unsigned short)A1 << endl; + cout << "F1 = " << (unsigned short)F1 << endl; + cout << "B1 = " << (unsigned short)B1 << endl; + cout << "C1 = " << (unsigned short)C1 << endl; + cout << "D1 = " << (unsigned short)D1 << endl; + cout << "E1 = " << (unsigned short)E1 << endl; + cout << "H1 = " << (unsigned short)H1 << endl; + cout << "L1 = " << (unsigned short)L1 << endl; + cout << "Rbit7 = " << (unsigned short)Rbit7 << endl; + + cout << "IM = " << (unsigned short)IM << endl; + cout << "PC = " << (unsigned short)PC << endl; + cout << "IX = " << (unsigned short)IX << endl; + cout << "IY = " << (unsigned short)IY << endl; + cout << "SP = " << (unsigned short)SP << endl; + cout << "IFF1 = " << (unsigned short)IFF1 << endl; + cout << "IFF2 = " << (unsigned short)IFF2 << dec << endl; + cout << "cpuHalted = " << (unsigned int)cpuHalted << endl; + cout << "cycleCount = " << (unsigned int)cycleCount << endl << endl; +} + +bool Z80::saveState( ofstream &ofs ) { Z80SaveState css; - - css.A = A; - css.B = B; - css.C = C; - css.D = D; - css.E = E; - css.H = H; - css.L = L; - css.I = I; - css.R = R; - css.A1 = A1; - css.B1 = B1; - css.C1 = C1; - css.D1 = D1; - css.E1 = E1; - css.H1 = H1; - css.L1 = L1; - css.Rbit7 = Rbit7; - css.IM = IM; - css.PC = PC; - css.IX = IX; - css.IY = IY; - css.SP = SP; - css.IFF1 = IFF1; - css.IFF2 = IFF2; - css.cpuHalted = cpuHalted; + + css.A = A; + css.F = F; + css.B = B; + css.C = C; + css.D = D; + css.E = E; + css.H = H; + css.L = L; + css.I = I; + css.R = R; + css.A1 = A1; + css.F1 = F1; + css.B1 = B1; + css.C1 = C1; + css.D1 = D1; + css.E1 = E1; + css.H1 = H1; + css.L1 = L1; + css.Rbit7 = Rbit7; + css.IM = IM; + css.PC = PC; + css.IX = IX; + css.IY = IY; + css.SP = SP; + css.IFF1 = IFF1; + css.IFF2 = IFF2; + css.cpuHalted = cpuHalted; css.cycleCount = cycleCount; ofs.write((char *)&css, sizeof(css)); + //dumpValues(); + //dumpSaveStateStructure(css); return ofs.good(); -} - -bool Z80::loadState( ifstream &ifs ) -{ +} + +bool Z80::loadState( ifstream &ifs ) +{ Z80SaveState css; bool ret = false; ifs.read((char *)&css, sizeof(css)); ret = ifs.good(); + //dumpSaveStateStructure(css); + /* Don't restore the values if read fails ! */ - if (!ret) return false; + if (!ret) return false; - A = css.A; - B = css.B; - C = css.C; - D = css.D; - E = css.E; - H = css.H; - L = css.L; - I = css.I; - R = css.R; - A1 = css.A1; - B1 = css.B1; - C1 = css.C1; - D1 = css.D1; - E1 = css.E1; - H1 = css.H1; - L1 = css.L1; - Rbit7 =css.Rbit7; - IM = css.IM; - PC = css.PC; - IX = css.IX; - IY = css.IY; - SP = css.SP; - IFF1 = css.IFF1; - IFF2 = css.IFF2; - cpuHalted = css.cpuHalted; + A = css.A; + F = css.F; + B = css.B; + C = css.C; + D = css.D; + E = css.E; + H = css.H; + L = css.L; + I = css.I; + R = css.R; + A1 = css.A1; + F1 = css.F1; + B1 = css.B1; + C1 = css.C1; + D1 = css.D1; + E1 = css.E1; + H1 = css.H1; + L1 = css.L1; + Rbit7 =css.Rbit7; + IM = css.IM; + PC = css.PC; + IX = css.IX; + IY = css.IY; + SP = css.SP; + IFF1 = css.IFF1; + IFF2 = css.IFF2; + cpuHalted = css.cpuHalted; cycleCount = css.cycleCount; + //dumpValues(); return true; -} +} diff -Nru osmose-0.8.5b/cpu/Z80.h osmose-0.9.1/cpu/Z80.h --- osmose-0.8.5b/cpu/Z80.h 2006-11-27 11:22:32.000000000 +0000 +++ osmose-0.9.1/cpu/Z80.h 2009-10-24 18:04:36.000000000 +0000 @@ -1,1575 +1,1579 @@ -/***************************************************************************** -* -* File: Z80.h -* -* Project: Oldspark emulator. -* -* Description: This class defines Z80 cpu emulator. It's table driven, and all -* opcodes are supported. Not that undocumented flags are not totaly supported. -* -* -* Author: Vedder Bruno -* Date: 10/01/2006, Thailand, Laos Cambodia :-) -* -* URL: http://bcz.emu-france.com/ -*****************************************************************************/ - -#ifndef Z80_H_ -#define Z80_H_ -#include "../BasicTypes.h" +/***************************************************************************** +* +* File: Z80.h +* +* Project: Oldspark emulator. +* +* Description: This class defines Z80 cpu emulator. It's table driven, and all +* opcodes are supported. Not that undocumented flags are not totaly supported. +* +* +* Author: Vedder Bruno +* Date: 10/01/2006, Thailand, Laos Cambodia :-) +* +* URL: http://bcz.emu-france.com/ +*****************************************************************************/ + +#ifndef Z80_H_ +#define Z80_H_ +#include "../BasicTypes.h" #include "../DebugEventThrower.h" #include "../Definitions.h" #include "../SaveState.h" - -// Enable opcode 'hit statistics.' -//#define OPCODES_STATS - -/* Flag related constants */ -#define SF 0x80 /* Sign */ -#define ZF 0x40 /* Zero */ -#define YF 0x20 /* Undoc flag */ -#define HF 0x10 /* Half carry */ -#define XF 0x08 /* Undoc flag */ -#define VF 0x04 /* Overflow */ -#define PF 0x04 /* Parity */ -#define NF 0x02 /* Add substract*/ -#define CF 0x01 /* Carry */ - -/* Save state data structure. */ -typedef struct -{ - u8 A,F,B,C,D,E,H,L,I,R; /* Generals registers. */ - u8 A1,F1,B1,C1,D1,E1,H1,L1; /* Alternat ' registers. */ - u8 Rbit7; /* Use to store bit 7 of R */ - u8 IM; /* Interrupt mode */ - u16 PC,IX,IY,SP; /* PC,Stack, indexes registers. */ - bool IFF1,IFF2; /* NMI/IRQ interrupt flip flop. */ - bool cpuHalted; /* CPU state vs Halt instruction.*/ - u32 cycleCount; /* Increase when running CPU. */ + +// Enable opcode 'hit statistics.' +//#define OPCODES_STATS + +/* Flag related constants */ +#define SF 0x80 /* Sign */ +#define ZF 0x40 /* Zero */ +#define YF 0x20 /* Undoc flag */ +#define HF 0x10 /* Half carry */ +#define XF 0x08 /* Undoc flag */ +#define VF 0x04 /* Overflow */ +#define PF 0x04 /* Parity */ +#define NF 0x02 /* Add substract*/ +#define CF 0x01 /* Carry */ + +/* Save state data structure. */ +typedef struct +{ + u8 A,F,B,C,D,E,H,L,I,R; /* Generals registers. */ + u8 A1,F1,B1,C1,D1,E1,H1,L1; /* Alternat ' registers. */ + u8 Rbit7; /* Use to store bit 7 of R */ + u8 IM; /* Interrupt mode */ + u16 PC,IX,IY,SP; /* PC,Stack, indexes registers. */ + bool IFF1,IFF2; /* NMI/IRQ interrupt flip flop. */ + bool cpuHalted; /* CPU state vs Halt instruction.*/ + u32 cycleCount; /* Increase when running CPU. */ } Z80SaveState; - -/* - This class, from Alessandro Scotti (Tickle emulator) Z80environment, must be - derived, with implementation for each virtual methods. It will be used by Z80 CPU core to - access RAM/ROM, IO etc... -*/ -class Z80Environment -{ - public: - /* Constructor. */ - Z80Environment() - { - } - - /* Destructor. */ - virtual ~Z80Environment() - { - } - - /* 8 bits read operation. */ - virtual u8 rd8( u16 addr ) - { - return 0xFF; - } - - /* 8 bits write operation. */ - virtual void wr8( u16 addr, u8 value ) - { - } - - /* 16 bits read operation. */ - u16 rd16( u16 addr ) - { - u8 a,b; - a = rd8(addr); - b = rd8((addr+1)& 0xFFFF); - return ((b<<8) | a); - } - - /* 16 bits write operation. */ - void wr16( u16 addr, u16 value ) - { - wr8((addr+1)& 0xFFFF, value >> 8); - wr8(addr, value & 0xFF); - } - - /* 8 bits read IO operation. */ - virtual u8 in( u16 port ) - { - return 0xFF; - } - - /* 8 bits write IO operation. */ - virtual void out( u16 port, u8 value ) - { - } - - /* Called immediately after a RETI is executed. */ - virtual void onReturnFromInterrupt() - { - } - - /* - Called after EI or RETN if interrupts are enabled. - This function allows the environment to supply a pending interrupt - if needed. - */ - virtual void onInterruptsEnabled() { - } -}; - -class Z80 : public DebugEventThrower, public ImplementsSaveState -{ - public: - Z80Environment& env; /* Z80Environment reference. */ - u8 A,F,B,C,D,E,H,L,I,R; /* Generals registers. */ - u8 A1,F1,B1,C1,D1,E1,H1,L1; /* Alternat ' registers. */ - u8 Rbit7; /* Use to store bit 7 of R */ - u8 IM; /* Interrupt mode */ - u16 PC,IX,IY,SP; /* PC,Stack, indexes registers. */ - u16 IXd, IYd; /* Used for XY+d adressing mode. */ - bool IFF1,IFF2; /* NMI/IRQ interrupt flip flop. */ - bool cpuHalted; /* CPU state vs Halt instruction.*/ - u32 cycleCount; /* Increase when running CPU. */ - Z80 ( Z80Environment & ); /* Constructor with Z80Environment reference*/ - ~Z80(); /* Destructor. */ - void reset(); /* Reset Z80.*/ - void nmi(); /* Generate CPU NMI.*/ - bool interrupt(u8 data); /* Generate CPU interrupt.*/ - u32 run(u32 cycles); /* Execute n cycles. */ - void step(); /* Execute one instruction */ - void setCycles(u32 c) { cycleCount = c;} - u32 getCycles() { return cycleCount;} - u8 getInterruptMode() {return IM;} + +/* + This class, from Alessandro Scotti (Tickle emulator) Z80environment, must be + derived, with implementation for each virtual methods. It will be used by Z80 CPU core to + access RAM/ROM, IO etc... +*/ +class Z80Environment +{ + public: + /* Constructor. */ + Z80Environment() + { + } + + /* Destructor. */ + virtual ~Z80Environment() + { + } + + /* 8 bits read operation. */ + virtual u8 rd8( u16 addr ) + { + return 0xFF; + } + + /* 8 bits write operation. */ + virtual void wr8( u16 addr, u8 value ) + { + } + + /* 16 bits read operation. */ + u16 rd16( u16 addr ) + { + u8 a,b; + a = rd8(addr); + b = rd8((addr+1)& 0xFFFF); + return ((b<<8) | a); + } + + /* 16 bits write operation. */ + void wr16( u16 addr, u16 value ) + { + wr8((addr+1)& 0xFFFF, value >> 8); + wr8(addr, value & 0xFF); + } + + /* 8 bits read IO operation. */ + virtual u8 in( u16 port ) + { + return 0xFF; + } + + /* 8 bits write IO operation. */ + virtual void out( u16 port, u8 value ) + { + } + + /* Called immediately after a RETI is executed. */ + virtual void onReturnFromInterrupt() + { + } + + /* + Called after EI or RETN if interrupts are enabled. + This function allows the environment to supply a pending interrupt + if needed. + */ + virtual void onInterruptsEnabled() { + } +}; + +class Z80 : public DebugEventThrower, public ImplementsSaveState +{ + public: + Z80Environment& env; /* Z80Environment reference. */ + u8 A,F,B,C,D,E,H,L,I,R; /* Generals registers. */ + u8 A1,F1,B1,C1,D1,E1,H1,L1; /* Alternat ' registers. */ + u8 Rbit7; /* Use to store bit 7 of R */ + u8 IM; /* Interrupt mode */ + u16 PC,IX,IY,SP; /* PC,Stack, indexes registers. */ + u16 IXd, IYd; /* Used for XY+d adressing mode. */ + bool IFF1,IFF2; /* NMI/IRQ interrupt flip flop. */ + bool cpuHalted; /* CPU state vs Halt instruction.*/ + u32 cycleCount; /* Increase when running CPU. */ + Z80 ( Z80Environment & ); /* Constructor with Z80Environment reference*/ + ~Z80(); /* Destructor. */ + void reset(); /* Reset Z80.*/ + void nmi(); /* Generate CPU NMI.*/ + bool interrupt(u8 data); /* Generate CPU interrupt.*/ + u32 run(u32 cycles); /* Execute n cycles. */ + void step(); /* Execute one instruction */ + void setCycles(u32 c) { cycleCount = c;} + u32 getCycles() { return cycleCount;} + u8 getInterruptMode() {return IM;} /* Implemetntation of ImplementsSaveState. */ bool saveState( ofstream &ofs); - bool loadState( ifstream &ifs); + bool loadState( ifstream &ifs); + + + /* + * Internal Register Manipulation Functions. + * Get 16 reg from its 8 bits composant registers. + */ + u16 getAF() { return ( (A << 8) | F);} + u16 getBC() { return ( (B << 8) | C);} + u16 getDE() { return ( (D << 8) | E);} + u16 getHL() { return ( (H << 8) | L);} + u16 getIX() { return ( IX );} + u16 getIY() { return ( IY );} + u16 getPC() { return ( PC );} + u16 getSP() { return ( SP );} + u8 getI() { return ( I );} + u8 getR() { return ( R );} + +#ifdef OPCODES_STATS + u32 *NO_Prefix; + u32 *CB_Prefix; + u32 *DD_Prefix; + u32 *ED_Prefix; + u32 *FD_Prefix; + u32 *DDCB_Prefix; + u32 *FDCB_Prefix; + void opcodes_stats(); +#endif + private: + + void dumpSaveStateStructure(Z80SaveState &); /* For debug purpose.*/ + void dumpValues(); /* Dump CPU regs etc.*/ + + void exec_cb(); /* Execute opcode prefixed 0xCB. */ + void exec_dd(); /* Execute opcode prefixed 0xDD. */ + void exec_ddcb(); /* Execute opcode prefixed 0xDDCB. */ + void exec_ed(); /* Execute opcode prefixed 0xED. */ + void exec_fd(); /* Execute opcode prefixed 0xFD. */ + void exec_fdcb(); /* Execute opcode prefixed 0xFDCB. */ + bool checkInterrupt(); + void dump(u16 addr); + + /* + * Internal Register Manipulation Functions. + * Set 8 bits composant registers from 16 bit value. + */ + void setAF (u16 v) {A = v>>8; F = v & 0xFF;} + void setBC (u16 v) {B = v>>8; C = v & 0xFF;} + void setDE (u16 v) {D = v>>8; E = v & 0xFF;} + void setHL (u16 v) {H = v>>8; L = v & 0xFF;} + + /* + * Internal indirect 8 bits regs Addressing. + * Set/Get Indirect 8 bits values. + */ + u8 getBCi() { return env.rd8(getBC());} /* read u8 in (BC) */ + void setBCi(u8 val) { env.wr8(getBC(),val);} /* write u8 in (BC) */ + u8 getDEi() { return env.rd8(getDE());} /* read u8 in (DE) */ + void setDEi(u8 val) { env.wr8(getDE(),val);} /* write u8 in (DE) */ + u8 getHLi() { return env.rd8(getHL());} /* read u8 in (HL) */ + void setHLi(u8 val) { env.wr8(getHL(),val);} /* write u8 in (HL) */ + + /* 8 bit read/write throught (IX+d) and (IY+d). Warning: PC is not incremented ! */ + u8 getIXdi() {return env.rd8((u16)(IX + (s8)env.rd8(PC)));} + void setIXdi(u8 val) { env.wr8((u16)(IX + (s8)env.rd8(PC)),val);} + u8 getIYdi() {return env.rd8((u16)(IY + (s8)env.rd8(PC)));} + void setIYdi(u8 val) { env.wr8((u16)(IY + (s8)env.rd8(PC)),val);} + void setNNi16(u16 val16b) {env.wr16(env.rd16(PC),val16b);} + u16 getNNi16() { return env.rd16(env.rd16(PC));} + void setNNi8(u8 val8b) { env.wr8(env.rd16(PC),val8b); } + u8 getNNi8() { return env.rd8(env.rd16(PC));} + + + /** + * Basic Arithmetic CPU Operations: + */ + u8 inc8(u8 v); /* increment 8bits value. */ + u8 dec8(u8 v); /* decrement 8bits value. */ + u8 add8(u8 a,u8 b); /* add 8 bits values. */ + u8 adc8(u8 a,u8 b); /* add with carry 8 bits values. */ + u8 sbc8(u8 a,u8 b); /* sub with carry 8 bits values. */ + u8 sub8(u8 a,u8 b); /* sub 8 bits values. */ + u16 add16(u16 a,u16 b); /* add 16 bits values. */ + void sbcHL(u16 v); /* SBC HL, REG */ + void adcHL(u16 v); /* ADC HL, REG */ + void rrd(); /* RRD */ + void rld(); /* RLD */ + void cp8(u8 a, u8 b); /* Compare 8bits values. */ + + /** + * Basic Logical CPU Operations: + */ + u8 and8(u8 a,u8 b); /* and 8 bits values. */ + u8 or8(u8 a,u8 b); /* or 8 bits values. */ + u8 xor8(u8 a,u8 b); /* xor 8 bits values. */ + + /** + * Basic Shift CPU Operations: + */ + u8 rlc8(u8 v); /* (<<1) 8 bits value. */ + u8 rrc8(u8 v); /* (>>1) 8 bits value.*/ + u8 rl8(u8 v); /* (<<1) 8 bits value.*/ + u8 rr8(u8 v); /* (>>1) 8 bits value.*/ + u8 sla8(u8 v); /* .*/ + u8 sra8(u8 v); /* .*/ + u8 sll8(u8 v); /* .*/ + u8 srl8(u8 v); /* .*/ + + /** + * Basic Bit CPU Operations: + */ + void bit(u8 bit,u8 v); /* test bit in 8 bits value.*/ + u8 set(u8 bit,u8 v); /* set bit in 8 bits value.*/ + u8 res(u8 bit,u8 v); /* reset bit in 8 bits value.*/ + + /** + * Basic Stack CPU Operations: + */ + u16 pop(); /* Pop 16 bits value.*/ + void push(u16 v); /* Push 16 bits value*/ + void rst(u16 ea); /* rst operation.*/ + void setFlagAfterInput(u8 r); + void invalid_opcode(); + void invalid_prefixed_opcode(); + void nop() ; + + /** + * CPU opcode callbacks: + */ + void Opc_std_00(); + void Opc_std_01(); + void Opc_std_02(); + void Opc_std_03(); + void Opc_std_04(); + void Opc_std_05(); + void Opc_std_06(); + void Opc_std_07(); + void Opc_std_08(); + void Opc_std_09(); + void Opc_std_0a(); + void Opc_std_0b(); + void Opc_std_0c(); + void Opc_std_0d(); + void Opc_std_0e(); + void Opc_std_0f(); + void Opc_std_10(); + void Opc_std_11(); + void Opc_std_12(); + void Opc_std_13(); + void Opc_std_14(); + void Opc_std_15(); + void Opc_std_16(); + void Opc_std_17(); + void Opc_std_18(); + void Opc_std_19(); + void Opc_std_1a(); + void Opc_std_1b(); + void Opc_std_1c(); + void Opc_std_1d(); + void Opc_std_1e(); + void Opc_std_1f(); + void Opc_std_20(); + void Opc_std_21(); + void Opc_std_22(); + void Opc_std_23(); + void Opc_std_24(); + void Opc_std_25(); + void Opc_std_26(); + void Opc_std_27(); + void Opc_std_28(); + void Opc_std_29(); + void Opc_std_2a(); + void Opc_std_2b(); + void Opc_std_2c(); + void Opc_std_2d(); + void Opc_std_2e(); + void Opc_std_2f(); + void Opc_std_30(); + void Opc_std_31(); + void Opc_std_32(); + void Opc_std_33(); + void Opc_std_34(); + void Opc_std_35(); + void Opc_std_36(); + void Opc_std_37(); + void Opc_std_38(); + void Opc_std_39(); + void Opc_std_3a(); + void Opc_std_3b(); + void Opc_std_3c(); + void Opc_std_3d(); + void Opc_std_3e(); + void Opc_std_3f(); + void Opc_std_40(); + void Opc_std_41(); + void Opc_std_42(); + void Opc_std_43(); + void Opc_std_44(); + void Opc_std_45(); + void Opc_std_46(); + void Opc_std_47(); + void Opc_std_48(); + void Opc_std_49(); + void Opc_std_4a(); + void Opc_std_4b(); + void Opc_std_4c(); + void Opc_std_4d(); + void Opc_std_4e(); + void Opc_std_4f(); + void Opc_std_50(); + void Opc_std_51(); + void Opc_std_52(); + void Opc_std_53(); + void Opc_std_54(); + void Opc_std_55(); + void Opc_std_56(); + void Opc_std_57(); + void Opc_std_58(); + void Opc_std_59(); + void Opc_std_5a(); + void Opc_std_5b(); + void Opc_std_5c(); + void Opc_std_5d(); + void Opc_std_5e(); + void Opc_std_5f(); + void Opc_std_60(); + void Opc_std_61(); + void Opc_std_62(); + void Opc_std_63(); + void Opc_std_64(); + void Opc_std_65(); + void Opc_std_66(); + void Opc_std_67(); + void Opc_std_68(); + void Opc_std_69(); + void Opc_std_6a(); + void Opc_std_6b(); + void Opc_std_6c(); + void Opc_std_6d(); + void Opc_std_6e(); + void Opc_std_6f(); + void Opc_std_70(); + void Opc_std_71(); + void Opc_std_72(); + void Opc_std_73(); + void Opc_std_74(); + void Opc_std_75(); + void Opc_std_76(); + void Opc_std_77(); + void Opc_std_78(); + void Opc_std_79(); + void Opc_std_7a(); + void Opc_std_7b(); + void Opc_std_7c(); + void Opc_std_7d(); + void Opc_std_7e(); + void Opc_std_7f(); + void Opc_std_80(); + void Opc_std_81(); + void Opc_std_82(); + void Opc_std_83(); + void Opc_std_84(); + void Opc_std_85(); + void Opc_std_86(); + void Opc_std_87(); + void Opc_std_88(); + void Opc_std_89(); + void Opc_std_8a(); + void Opc_std_8b(); + void Opc_std_8c(); + void Opc_std_8d(); + void Opc_std_8e(); + void Opc_std_8f(); + void Opc_std_90(); + void Opc_std_91(); + void Opc_std_92(); + void Opc_std_93(); + void Opc_std_94(); + void Opc_std_95(); + void Opc_std_96(); + void Opc_std_97(); + void Opc_std_98(); + void Opc_std_99(); + void Opc_std_9a(); + void Opc_std_9b(); + void Opc_std_9c(); + void Opc_std_9d(); + void Opc_std_9e(); + void Opc_std_9f(); + void Opc_std_a0(); + void Opc_std_a1(); + void Opc_std_a2(); + void Opc_std_a3(); + void Opc_std_a4(); + void Opc_std_a5(); + void Opc_std_a6(); + void Opc_std_a7(); + void Opc_std_a8(); + void Opc_std_a9(); + void Opc_std_aa(); + void Opc_std_ab(); + void Opc_std_ac(); + void Opc_std_ad(); + void Opc_std_ae(); + void Opc_std_af(); + void Opc_std_b0(); + void Opc_std_b1(); + void Opc_std_b2(); + void Opc_std_b3(); + void Opc_std_b4(); + void Opc_std_b5(); + void Opc_std_b6(); + void Opc_std_b7(); + void Opc_std_b8(); + void Opc_std_b9(); + void Opc_std_ba(); + void Opc_std_bb(); + void Opc_std_bc(); + void Opc_std_bd(); + void Opc_std_be(); + void Opc_std_bf(); + void Opc_std_c0(); + void Opc_std_c1(); + void Opc_std_c2(); + void Opc_std_c3(); + void Opc_std_c4(); + void Opc_std_c5(); + void Opc_std_c6(); + void Opc_std_c7(); + void Opc_std_c8(); + void Opc_std_c9(); + void Opc_std_ca(); + void Opc_std_cb(); + void Opc_std_cc(); + void Opc_std_cd(); + void Opc_std_ce(); + void Opc_std_cf(); + void Opc_std_d0(); + void Opc_std_d1(); + void Opc_std_d2(); + void Opc_std_d3(); + void Opc_std_d4(); + void Opc_std_d5(); + void Opc_std_d6(); + void Opc_std_d7(); + void Opc_std_d8(); + void Opc_std_d9(); + void Opc_std_da(); + void Opc_std_db(); + void Opc_std_dc(); + void Opc_std_dd(); + void Opc_std_de(); + void Opc_std_df(); + void Opc_std_e0(); + void Opc_std_e1(); + void Opc_std_e2(); + void Opc_std_e3(); + void Opc_std_e4(); + void Opc_std_e5(); + void Opc_std_e6(); + void Opc_std_e7(); + void Opc_std_e8(); + void Opc_std_e9(); + void Opc_std_ea(); + void Opc_std_eb(); + void Opc_std_ec(); + void Opc_std_ed(); + void Opc_std_ee(); + void Opc_std_ef(); + void Opc_std_f0(); + void Opc_std_f1(); + void Opc_std_f2(); + void Opc_std_f3(); + void Opc_std_f4(); + void Opc_std_f5(); + void Opc_std_f6(); + void Opc_std_f7(); + void Opc_std_f8(); + void Opc_std_f9(); + void Opc_std_fa(); + void Opc_std_fb(); + void Opc_std_fc(); + void Opc_std_fd(); + void Opc_std_fe(); + void Opc_std_ff(); + + // Opcodes CBXX prototypes. + void Opc_cbxx_00(); + void Opc_cbxx_01(); + void Opc_cbxx_02(); + void Opc_cbxx_03(); + void Opc_cbxx_04(); + void Opc_cbxx_05(); + void Opc_cbxx_06(); + void Opc_cbxx_07(); + void Opc_cbxx_08(); + void Opc_cbxx_09(); + void Opc_cbxx_0a(); + void Opc_cbxx_0b(); + void Opc_cbxx_0c(); + void Opc_cbxx_0d(); + void Opc_cbxx_0e(); + void Opc_cbxx_0f(); + void Opc_cbxx_10(); + void Opc_cbxx_11(); + void Opc_cbxx_12(); + void Opc_cbxx_13(); + void Opc_cbxx_14(); + void Opc_cbxx_15(); + void Opc_cbxx_16(); + void Opc_cbxx_17(); + void Opc_cbxx_18(); + void Opc_cbxx_19(); + void Opc_cbxx_1a(); + void Opc_cbxx_1b(); + void Opc_cbxx_1c(); + void Opc_cbxx_1d(); + void Opc_cbxx_1e(); + void Opc_cbxx_1f(); + void Opc_cbxx_20(); + void Opc_cbxx_21(); + void Opc_cbxx_22(); + void Opc_cbxx_23(); + void Opc_cbxx_24(); + void Opc_cbxx_25(); + void Opc_cbxx_26(); + void Opc_cbxx_27(); + void Opc_cbxx_28(); + void Opc_cbxx_29(); + void Opc_cbxx_2a(); + void Opc_cbxx_2b(); + void Opc_cbxx_2c(); + void Opc_cbxx_2d(); + void Opc_cbxx_2e(); + void Opc_cbxx_2f(); + void Opc_cbxx_30(); + void Opc_cbxx_31(); + void Opc_cbxx_32(); + void Opc_cbxx_33(); + void Opc_cbxx_34(); + void Opc_cbxx_35(); + void Opc_cbxx_36(); + void Opc_cbxx_37(); + void Opc_cbxx_38(); + void Opc_cbxx_39(); + void Opc_cbxx_3a(); + void Opc_cbxx_3b(); + void Opc_cbxx_3c(); + void Opc_cbxx_3d(); + void Opc_cbxx_3e(); + void Opc_cbxx_3f(); + void Opc_cbxx_40(); + void Opc_cbxx_41(); + void Opc_cbxx_42(); + void Opc_cbxx_43(); + void Opc_cbxx_44(); + void Opc_cbxx_45(); + void Opc_cbxx_46(); + void Opc_cbxx_47(); + void Opc_cbxx_48(); + void Opc_cbxx_49(); + void Opc_cbxx_4a(); + void Opc_cbxx_4b(); + void Opc_cbxx_4c(); + void Opc_cbxx_4d(); + void Opc_cbxx_4e(); + void Opc_cbxx_4f(); + void Opc_cbxx_50(); + void Opc_cbxx_51(); + void Opc_cbxx_52(); + void Opc_cbxx_53(); + void Opc_cbxx_54(); + void Opc_cbxx_55(); + void Opc_cbxx_56(); + void Opc_cbxx_57(); + void Opc_cbxx_58(); + void Opc_cbxx_59(); + void Opc_cbxx_5a(); + void Opc_cbxx_5b(); + void Opc_cbxx_5c(); + void Opc_cbxx_5d(); + void Opc_cbxx_5e(); + void Opc_cbxx_5f(); + void Opc_cbxx_60(); + void Opc_cbxx_61(); + void Opc_cbxx_62(); + void Opc_cbxx_63(); + void Opc_cbxx_64(); + void Opc_cbxx_65(); + void Opc_cbxx_66(); + void Opc_cbxx_67(); + void Opc_cbxx_68(); + void Opc_cbxx_69(); + void Opc_cbxx_6a(); + void Opc_cbxx_6b(); + void Opc_cbxx_6c(); + void Opc_cbxx_6d(); + void Opc_cbxx_6e(); + void Opc_cbxx_6f(); + void Opc_cbxx_70(); + void Opc_cbxx_71(); + void Opc_cbxx_72(); + void Opc_cbxx_73(); + void Opc_cbxx_74(); + void Opc_cbxx_75(); + void Opc_cbxx_76(); + void Opc_cbxx_77(); + void Opc_cbxx_78(); + void Opc_cbxx_79(); + void Opc_cbxx_7a(); + void Opc_cbxx_7b(); + void Opc_cbxx_7c(); + void Opc_cbxx_7d(); + void Opc_cbxx_7e(); + void Opc_cbxx_7f(); + void Opc_cbxx_80(); + void Opc_cbxx_81(); + void Opc_cbxx_82(); + void Opc_cbxx_83(); + void Opc_cbxx_84(); + void Opc_cbxx_85(); + void Opc_cbxx_86(); + void Opc_cbxx_87(); + void Opc_cbxx_88(); + void Opc_cbxx_89(); + void Opc_cbxx_8a(); + void Opc_cbxx_8b(); + void Opc_cbxx_8c(); + void Opc_cbxx_8d(); + void Opc_cbxx_8e(); + void Opc_cbxx_8f(); + void Opc_cbxx_90(); + void Opc_cbxx_91(); + void Opc_cbxx_92(); + void Opc_cbxx_93(); + void Opc_cbxx_94(); + void Opc_cbxx_95(); + void Opc_cbxx_96(); + void Opc_cbxx_97(); + void Opc_cbxx_98(); + void Opc_cbxx_99(); + void Opc_cbxx_9a(); + void Opc_cbxx_9b(); + void Opc_cbxx_9c(); + void Opc_cbxx_9d(); + void Opc_cbxx_9e(); + void Opc_cbxx_9f(); + void Opc_cbxx_a0(); + void Opc_cbxx_a1(); + void Opc_cbxx_a2(); + void Opc_cbxx_a3(); + void Opc_cbxx_a4(); + void Opc_cbxx_a5(); + void Opc_cbxx_a6(); + void Opc_cbxx_a7(); + void Opc_cbxx_a8(); + void Opc_cbxx_a9(); + void Opc_cbxx_aa(); + void Opc_cbxx_ab(); + void Opc_cbxx_ac(); + void Opc_cbxx_ad(); + void Opc_cbxx_ae(); + void Opc_cbxx_af(); + void Opc_cbxx_b0(); + void Opc_cbxx_b1(); + void Opc_cbxx_b2(); + void Opc_cbxx_b3(); + void Opc_cbxx_b4(); + void Opc_cbxx_b5(); + void Opc_cbxx_b6(); + void Opc_cbxx_b7(); + void Opc_cbxx_b8(); + void Opc_cbxx_b9(); + void Opc_cbxx_ba(); + void Opc_cbxx_bb(); + void Opc_cbxx_bc(); + void Opc_cbxx_bd(); + void Opc_cbxx_be(); + void Opc_cbxx_bf(); + void Opc_cbxx_c0(); + void Opc_cbxx_c1(); + void Opc_cbxx_c2(); + void Opc_cbxx_c3(); + void Opc_cbxx_c4(); + void Opc_cbxx_c5(); + void Opc_cbxx_c6(); + void Opc_cbxx_c7(); + void Opc_cbxx_c8(); + void Opc_cbxx_c9(); + void Opc_cbxx_ca(); + void Opc_cbxx_cb(); + void Opc_cbxx_cc(); + void Opc_cbxx_cd(); + void Opc_cbxx_ce(); + void Opc_cbxx_cf(); + void Opc_cbxx_d0(); + void Opc_cbxx_d1(); + void Opc_cbxx_d2(); + void Opc_cbxx_d3(); + void Opc_cbxx_d4(); + void Opc_cbxx_d5(); + void Opc_cbxx_d6(); + void Opc_cbxx_d7(); + void Opc_cbxx_d8(); + void Opc_cbxx_d9(); + void Opc_cbxx_da(); + void Opc_cbxx_db(); + void Opc_cbxx_dc(); + void Opc_cbxx_dd(); + void Opc_cbxx_de(); + void Opc_cbxx_df(); + void Opc_cbxx_e0(); + void Opc_cbxx_e1(); + void Opc_cbxx_e2(); + void Opc_cbxx_e3(); + void Opc_cbxx_e4(); + void Opc_cbxx_e5(); + void Opc_cbxx_e6(); + void Opc_cbxx_e7(); + void Opc_cbxx_e8(); + void Opc_cbxx_e9(); + void Opc_cbxx_ea(); + void Opc_cbxx_eb(); + void Opc_cbxx_ec(); + void Opc_cbxx_ed(); + void Opc_cbxx_ee(); + void Opc_cbxx_ef(); + void Opc_cbxx_f0(); + void Opc_cbxx_f1(); + void Opc_cbxx_f2(); + void Opc_cbxx_f3(); + void Opc_cbxx_f4(); + void Opc_cbxx_f5(); + void Opc_cbxx_f6(); + void Opc_cbxx_f7(); + void Opc_cbxx_f8(); + void Opc_cbxx_f9(); + void Opc_cbxx_fa(); + void Opc_cbxx_fb(); + void Opc_cbxx_fc(); + void Opc_cbxx_fd(); + void Opc_cbxx_fe(); + void Opc_cbxx_ff(); + + // Opcodes DDXX prototypes. + void Opc_ddxx_09(); + void Opc_ddxx_19(); + void Opc_ddxx_21(); + void Opc_ddxx_22(); + void Opc_ddxx_23(); + void Opc_ddxx_24(); + void Opc_ddxx_25(); + void Opc_ddxx_26(); + void Opc_ddxx_29(); + void Opc_ddxx_2a(); + void Opc_ddxx_2b(); + void Opc_ddxx_2c(); + void Opc_ddxx_2d(); + void Opc_ddxx_2e(); + void Opc_ddxx_34(); + void Opc_ddxx_35(); + void Opc_ddxx_36(); + void Opc_ddxx_39(); + void Opc_ddxx_44(); + void Opc_ddxx_45(); + void Opc_ddxx_46(); + void Opc_ddxx_4c(); + void Opc_ddxx_4d(); + void Opc_ddxx_4e(); + void Opc_ddxx_54(); + void Opc_ddxx_55(); + void Opc_ddxx_56(); + void Opc_ddxx_5c(); + void Opc_ddxx_5d(); + void Opc_ddxx_5e(); + void Opc_ddxx_60(); + void Opc_ddxx_61(); + void Opc_ddxx_62(); + void Opc_ddxx_63(); + void Opc_ddxx_64(); + void Opc_ddxx_65(); + void Opc_ddxx_66(); + void Opc_ddxx_67(); + void Opc_ddxx_68(); + void Opc_ddxx_69(); + void Opc_ddxx_6a(); + void Opc_ddxx_6b(); + void Opc_ddxx_6c(); + void Opc_ddxx_6d(); + void Opc_ddxx_6e(); + void Opc_ddxx_6f(); + void Opc_ddxx_70(); + void Opc_ddxx_71(); + void Opc_ddxx_72(); + void Opc_ddxx_73(); + void Opc_ddxx_74(); + void Opc_ddxx_75(); + void Opc_ddxx_77(); + void Opc_ddxx_7c(); + void Opc_ddxx_7d(); + void Opc_ddxx_7e(); + void Opc_ddxx_84(); + void Opc_ddxx_85(); + void Opc_ddxx_86(); + void Opc_ddxx_8c(); + void Opc_ddxx_8d(); + void Opc_ddxx_8e(); + void Opc_ddxx_94(); + void Opc_ddxx_95(); + void Opc_ddxx_96(); + void Opc_ddxx_9c(); + void Opc_ddxx_9d(); + void Opc_ddxx_9e(); + void Opc_ddxx_a4(); + void Opc_ddxx_a5(); + void Opc_ddxx_a6(); + void Opc_ddxx_ac(); + void Opc_ddxx_ad(); + void Opc_ddxx_ae(); + void Opc_ddxx_b4(); + void Opc_ddxx_b5(); + void Opc_ddxx_b6(); + void Opc_ddxx_bc(); + void Opc_ddxx_bd(); + void Opc_ddxx_be(); + void Opc_ddxx_e1(); + void Opc_ddxx_e3(); + void Opc_ddxx_e5(); + void Opc_ddxx_e9(); + void Opc_ddxx_f9(); + + // Opcodes DDCB prototypes. + void Opc_ddcb_00(); + void Opc_ddcb_01(); + void Opc_ddcb_02(); + void Opc_ddcb_03(); + void Opc_ddcb_04(); + void Opc_ddcb_05(); + void Opc_ddcb_06(); + void Opc_ddcb_07(); + void Opc_ddcb_08(); + void Opc_ddcb_09(); + void Opc_ddcb_0a(); + void Opc_ddcb_0b(); + void Opc_ddcb_0c(); + void Opc_ddcb_0d(); + void Opc_ddcb_0e(); + void Opc_ddcb_0f(); + void Opc_ddcb_10(); + void Opc_ddcb_11(); + void Opc_ddcb_12(); + void Opc_ddcb_13(); + void Opc_ddcb_14(); + void Opc_ddcb_15(); + void Opc_ddcb_16(); + void Opc_ddcb_17(); + void Opc_ddcb_18(); + void Opc_ddcb_19(); + void Opc_ddcb_1a(); + void Opc_ddcb_1b(); + void Opc_ddcb_1c(); + void Opc_ddcb_1d(); + void Opc_ddcb_1e(); + void Opc_ddcb_1f(); + void Opc_ddcb_20(); + void Opc_ddcb_21(); + void Opc_ddcb_22(); + void Opc_ddcb_23(); + void Opc_ddcb_24(); + void Opc_ddcb_25(); + void Opc_ddcb_26(); + void Opc_ddcb_27(); + void Opc_ddcb_28(); + void Opc_ddcb_29(); + void Opc_ddcb_2a(); + void Opc_ddcb_2b(); + void Opc_ddcb_2c(); + void Opc_ddcb_2d(); + void Opc_ddcb_2e(); + void Opc_ddcb_2f(); + void Opc_ddcb_30(); + void Opc_ddcb_31(); + void Opc_ddcb_32(); + void Opc_ddcb_33(); + void Opc_ddcb_34(); + void Opc_ddcb_35(); + void Opc_ddcb_36(); + void Opc_ddcb_37(); + void Opc_ddcb_38(); + void Opc_ddcb_39(); + void Opc_ddcb_3a(); + void Opc_ddcb_3b(); + void Opc_ddcb_3c(); + void Opc_ddcb_3d(); + void Opc_ddcb_3e(); + void Opc_ddcb_3f(); + void Opc_ddcb_40(); + void Opc_ddcb_41(); + void Opc_ddcb_42(); + void Opc_ddcb_43(); + void Opc_ddcb_44(); + void Opc_ddcb_45(); + void Opc_ddcb_46(); + void Opc_ddcb_47(); + void Opc_ddcb_48(); + void Opc_ddcb_49(); + void Opc_ddcb_4a(); + void Opc_ddcb_4b(); + void Opc_ddcb_4c(); + void Opc_ddcb_4d(); + void Opc_ddcb_4e(); + void Opc_ddcb_4f(); + void Opc_ddcb_50(); + void Opc_ddcb_51(); + void Opc_ddcb_52(); + void Opc_ddcb_53(); + void Opc_ddcb_54(); + void Opc_ddcb_55(); + void Opc_ddcb_56(); + void Opc_ddcb_57(); + void Opc_ddcb_58(); + void Opc_ddcb_59(); + void Opc_ddcb_5a(); + void Opc_ddcb_5b(); + void Opc_ddcb_5c(); + void Opc_ddcb_5d(); + void Opc_ddcb_5e(); + void Opc_ddcb_5f(); + void Opc_ddcb_60(); + void Opc_ddcb_61(); + void Opc_ddcb_62(); + void Opc_ddcb_63(); + void Opc_ddcb_64(); + void Opc_ddcb_65(); + void Opc_ddcb_66(); + void Opc_ddcb_67(); + void Opc_ddcb_68(); + void Opc_ddcb_69(); + void Opc_ddcb_6a(); + void Opc_ddcb_6b(); + void Opc_ddcb_6c(); + void Opc_ddcb_6d(); + void Opc_ddcb_6e(); + void Opc_ddcb_6f(); + void Opc_ddcb_70(); + void Opc_ddcb_71(); + void Opc_ddcb_72(); + void Opc_ddcb_73(); + void Opc_ddcb_74(); + void Opc_ddcb_75(); + void Opc_ddcb_76(); + void Opc_ddcb_77(); + void Opc_ddcb_78(); + void Opc_ddcb_79(); + void Opc_ddcb_7a(); + void Opc_ddcb_7b(); + void Opc_ddcb_7c(); + void Opc_ddcb_7d(); + void Opc_ddcb_7e(); + void Opc_ddcb_7f(); + void Opc_ddcb_80(); + void Opc_ddcb_81(); + void Opc_ddcb_82(); + void Opc_ddcb_83(); + void Opc_ddcb_84(); + void Opc_ddcb_85(); + void Opc_ddcb_86(); + void Opc_ddcb_87(); + void Opc_ddcb_88(); + void Opc_ddcb_89(); + void Opc_ddcb_8a(); + void Opc_ddcb_8b(); + void Opc_ddcb_8c(); + void Opc_ddcb_8d(); + void Opc_ddcb_8e(); + void Opc_ddcb_8f(); + void Opc_ddcb_90(); + void Opc_ddcb_91(); + void Opc_ddcb_92(); + void Opc_ddcb_93(); + void Opc_ddcb_94(); + void Opc_ddcb_95(); + void Opc_ddcb_96(); + void Opc_ddcb_97(); + void Opc_ddcb_98(); + void Opc_ddcb_99(); + void Opc_ddcb_9a(); + void Opc_ddcb_9b(); + void Opc_ddcb_9c(); + void Opc_ddcb_9d(); + void Opc_ddcb_9e(); + void Opc_ddcb_9f(); + void Opc_ddcb_a0(); + void Opc_ddcb_a1(); + void Opc_ddcb_a2(); + void Opc_ddcb_a3(); + void Opc_ddcb_a4(); + void Opc_ddcb_a5(); + void Opc_ddcb_a6(); + void Opc_ddcb_a7(); + void Opc_ddcb_a8(); + void Opc_ddcb_a9(); + void Opc_ddcb_aa(); + void Opc_ddcb_ab(); + void Opc_ddcb_ac(); + void Opc_ddcb_ad(); + void Opc_ddcb_ae(); + void Opc_ddcb_af(); + void Opc_ddcb_b0(); + void Opc_ddcb_b1(); + void Opc_ddcb_b2(); + void Opc_ddcb_b3(); + void Opc_ddcb_b4(); + void Opc_ddcb_b5(); + void Opc_ddcb_b6(); + void Opc_ddcb_b7(); + void Opc_ddcb_b8(); + void Opc_ddcb_b9(); + void Opc_ddcb_ba(); + void Opc_ddcb_bb(); + void Opc_ddcb_bc(); + void Opc_ddcb_bd(); + void Opc_ddcb_be(); + void Opc_ddcb_bf(); + void Opc_ddcb_c0(); + void Opc_ddcb_c1(); + void Opc_ddcb_c2(); + void Opc_ddcb_c3(); + void Opc_ddcb_c4(); + void Opc_ddcb_c5(); + void Opc_ddcb_c6(); + void Opc_ddcb_c7(); + void Opc_ddcb_c8(); + void Opc_ddcb_c9(); + void Opc_ddcb_ca(); + void Opc_ddcb_cb(); + void Opc_ddcb_cc(); + void Opc_ddcb_cd(); + void Opc_ddcb_ce(); + void Opc_ddcb_cf(); + void Opc_ddcb_d0(); + void Opc_ddcb_d1(); + void Opc_ddcb_d2(); + void Opc_ddcb_d3(); + void Opc_ddcb_d4(); + void Opc_ddcb_d5(); + void Opc_ddcb_d6(); + void Opc_ddcb_d7(); + void Opc_ddcb_d8(); + void Opc_ddcb_d9(); + void Opc_ddcb_da(); + void Opc_ddcb_db(); + void Opc_ddcb_dc(); + void Opc_ddcb_dd(); + void Opc_ddcb_de(); + void Opc_ddcb_df(); + void Opc_ddcb_e0(); + void Opc_ddcb_e1(); + void Opc_ddcb_e2(); + void Opc_ddcb_e3(); + void Opc_ddcb_e4(); + void Opc_ddcb_e5(); + void Opc_ddcb_e6(); + void Opc_ddcb_e7(); + void Opc_ddcb_e8(); + void Opc_ddcb_e9(); + void Opc_ddcb_ea(); + void Opc_ddcb_eb(); + void Opc_ddcb_ec(); + void Opc_ddcb_ed(); + void Opc_ddcb_ee(); + void Opc_ddcb_ef(); + void Opc_ddcb_f0(); + void Opc_ddcb_f1(); + void Opc_ddcb_f2(); + void Opc_ddcb_f3(); + void Opc_ddcb_f4(); + void Opc_ddcb_f5(); + void Opc_ddcb_f6(); + void Opc_ddcb_f7(); + void Opc_ddcb_f8(); + void Opc_ddcb_f9(); + void Opc_ddcb_fa(); + void Opc_ddcb_fb(); + void Opc_ddcb_fc(); + void Opc_ddcb_fd(); + void Opc_ddcb_fe(); + void Opc_ddcb_ff(); + + // Opcodes EDxx prototypes. + void Opc_edxx_40(); + void Opc_edxx_41(); + void Opc_edxx_42(); + void Opc_edxx_43(); + void Opc_edxx_44(); + void Opc_edxx_45(); + void Opc_edxx_46(); + void Opc_edxx_47(); + void Opc_edxx_48(); + void Opc_edxx_49(); + void Opc_edxx_4a(); + void Opc_edxx_4b(); + void Opc_edxx_4c(); + void Opc_edxx_4d(); + void Opc_edxx_4e(); + void Opc_edxx_4f(); + void Opc_edxx_50(); + void Opc_edxx_51(); + void Opc_edxx_52(); + void Opc_edxx_53(); + void Opc_edxx_54(); + void Opc_edxx_55(); + void Opc_edxx_56(); + void Opc_edxx_57(); + void Opc_edxx_58(); + void Opc_edxx_59(); + void Opc_edxx_5a(); + void Opc_edxx_5b(); + void Opc_edxx_5c(); + void Opc_edxx_5d(); + void Opc_edxx_5e(); + void Opc_edxx_5f(); + void Opc_edxx_60(); + void Opc_edxx_61(); + void Opc_edxx_62(); + void Opc_edxx_63(); + void Opc_edxx_64(); + void Opc_edxx_65(); + void Opc_edxx_66(); + void Opc_edxx_67(); + void Opc_edxx_68(); + void Opc_edxx_69(); + void Opc_edxx_6a(); + void Opc_edxx_6b(); + void Opc_edxx_6c(); + void Opc_edxx_6d(); + void Opc_edxx_6e(); + void Opc_edxx_6f(); + void Opc_edxx_70(); + void Opc_edxx_71(); + void Opc_edxx_72(); + void Opc_edxx_73(); + void Opc_edxx_74(); + void Opc_edxx_75(); + void Opc_edxx_76(); + void Opc_edxx_78(); + void Opc_edxx_79(); + void Opc_edxx_7a(); + void Opc_edxx_7b(); + void Opc_edxx_7c(); + void Opc_edxx_7d(); + void Opc_edxx_7e(); + void Opc_edxx_a0(); + void Opc_edxx_a1(); + void Opc_edxx_a2(); + void Opc_edxx_a3(); + void Opc_edxx_a8(); + void Opc_edxx_a9(); + void Opc_edxx_aa(); + void Opc_edxx_ab(); + void Opc_edxx_b0(); + void Opc_edxx_b1(); + void Opc_edxx_b2(); + void Opc_edxx_b3(); + void Opc_edxx_b8(); + void Opc_edxx_b9(); + void Opc_edxx_ba(); + void Opc_edxx_bb(); + + // Opcodes FDXX prototypes. + void Opc_fdxx_09(); + void Opc_fdxx_19(); + void Opc_fdxx_21(); + void Opc_fdxx_22(); + void Opc_fdxx_23(); + void Opc_fdxx_24(); + void Opc_fdxx_25(); + void Opc_fdxx_26(); + void Opc_fdxx_29(); + void Opc_fdxx_2a(); + void Opc_fdxx_2b(); + void Opc_fdxx_2c(); + void Opc_fdxx_2d(); + void Opc_fdxx_2e(); + void Opc_fdxx_34(); + void Opc_fdxx_35(); + void Opc_fdxx_36(); + void Opc_fdxx_39(); + void Opc_fdxx_44(); + void Opc_fdxx_45(); + void Opc_fdxx_46(); + void Opc_fdxx_4c(); + void Opc_fdxx_4d(); + void Opc_fdxx_4e(); + void Opc_fdxx_54(); + void Opc_fdxx_55(); + void Opc_fdxx_56(); + void Opc_fdxx_5c(); + void Opc_fdxx_5d(); + void Opc_fdxx_5e(); + void Opc_fdxx_60(); + void Opc_fdxx_61(); + void Opc_fdxx_62(); + void Opc_fdxx_63(); + void Opc_fdxx_64(); + void Opc_fdxx_65(); + void Opc_fdxx_66(); + void Opc_fdxx_67(); + void Opc_fdxx_68(); + void Opc_fdxx_69(); + void Opc_fdxx_6a(); + void Opc_fdxx_6b(); + void Opc_fdxx_6c(); + void Opc_fdxx_6d(); + void Opc_fdxx_6e(); + void Opc_fdxx_6f(); + void Opc_fdxx_70(); + void Opc_fdxx_71(); + void Opc_fdxx_72(); + void Opc_fdxx_73(); + void Opc_fdxx_74(); + void Opc_fdxx_75(); + void Opc_fdxx_77(); + void Opc_fdxx_7c(); + void Opc_fdxx_7d(); + void Opc_fdxx_7e(); + void Opc_fdxx_84(); + void Opc_fdxx_85(); + void Opc_fdxx_86(); + void Opc_fdxx_8c(); + void Opc_fdxx_8d(); + void Opc_fdxx_8e(); + void Opc_fdxx_94(); + void Opc_fdxx_95(); + void Opc_fdxx_96(); + void Opc_fdxx_9c(); + void Opc_fdxx_9d(); + void Opc_fdxx_9e(); + void Opc_fdxx_a4(); + void Opc_fdxx_a5(); + void Opc_fdxx_a6(); + void Opc_fdxx_ac(); + void Opc_fdxx_ad(); + void Opc_fdxx_ae(); + void Opc_fdxx_b4(); + void Opc_fdxx_b5(); + void Opc_fdxx_b6(); + void Opc_fdxx_bc(); + void Opc_fdxx_bd(); + void Opc_fdxx_be(); + void Opc_fdxx_e1(); + void Opc_fdxx_e3(); + void Opc_fdxx_e5(); + void Opc_fdxx_e9(); + void Opc_fdxx_f9(); + + // Opcodes FDCB prototypes. + void Opc_fdcb_00(); + void Opc_fdcb_01(); + void Opc_fdcb_02(); + void Opc_fdcb_03(); + void Opc_fdcb_04(); + void Opc_fdcb_05(); + void Opc_fdcb_06(); + void Opc_fdcb_07(); + void Opc_fdcb_08(); + void Opc_fdcb_09(); + void Opc_fdcb_0a(); + void Opc_fdcb_0b(); + void Opc_fdcb_0c(); + void Opc_fdcb_0d(); + void Opc_fdcb_0e(); + void Opc_fdcb_0f(); + void Opc_fdcb_10(); + void Opc_fdcb_11(); + void Opc_fdcb_12(); + void Opc_fdcb_13(); + void Opc_fdcb_14(); + void Opc_fdcb_15(); + void Opc_fdcb_16(); + void Opc_fdcb_17(); + void Opc_fdcb_18(); + void Opc_fdcb_19(); + void Opc_fdcb_1a(); + void Opc_fdcb_1b(); + void Opc_fdcb_1c(); + void Opc_fdcb_1d(); + void Opc_fdcb_1e(); + void Opc_fdcb_1f(); + void Opc_fdcb_20(); + void Opc_fdcb_21(); + void Opc_fdcb_22(); + void Opc_fdcb_23(); + void Opc_fdcb_24(); + void Opc_fdcb_25(); + void Opc_fdcb_26(); + void Opc_fdcb_27(); + void Opc_fdcb_28(); + void Opc_fdcb_29(); + void Opc_fdcb_2a(); + void Opc_fdcb_2b(); + void Opc_fdcb_2c(); + void Opc_fdcb_2d(); + void Opc_fdcb_2e(); + void Opc_fdcb_2f(); + void Opc_fdcb_30(); + void Opc_fdcb_31(); + void Opc_fdcb_32(); + void Opc_fdcb_33(); + void Opc_fdcb_34(); + void Opc_fdcb_35(); + void Opc_fdcb_36(); + void Opc_fdcb_37(); + void Opc_fdcb_38(); + void Opc_fdcb_39(); + void Opc_fdcb_3a(); + void Opc_fdcb_3b(); + void Opc_fdcb_3c(); + void Opc_fdcb_3d(); + void Opc_fdcb_3e(); + void Opc_fdcb_3f(); + void Opc_fdcb_40(); + void Opc_fdcb_41(); + void Opc_fdcb_42(); + void Opc_fdcb_43(); + void Opc_fdcb_44(); + void Opc_fdcb_45(); + void Opc_fdcb_46(); + void Opc_fdcb_47(); + void Opc_fdcb_48(); + void Opc_fdcb_49(); + void Opc_fdcb_4a(); + void Opc_fdcb_4b(); + void Opc_fdcb_4c(); + void Opc_fdcb_4d(); + void Opc_fdcb_4e(); + void Opc_fdcb_4f(); + void Opc_fdcb_50(); + void Opc_fdcb_51(); + void Opc_fdcb_52(); + void Opc_fdcb_53(); + void Opc_fdcb_54(); + void Opc_fdcb_55(); + void Opc_fdcb_56(); + void Opc_fdcb_57(); + void Opc_fdcb_58(); + void Opc_fdcb_59(); + void Opc_fdcb_5a(); + void Opc_fdcb_5b(); + void Opc_fdcb_5c(); + void Opc_fdcb_5d(); + void Opc_fdcb_5e(); + void Opc_fdcb_5f(); + void Opc_fdcb_60(); + void Opc_fdcb_61(); + void Opc_fdcb_62(); + void Opc_fdcb_63(); + void Opc_fdcb_64(); + void Opc_fdcb_65(); + void Opc_fdcb_66(); + void Opc_fdcb_67(); + void Opc_fdcb_68(); + void Opc_fdcb_69(); + void Opc_fdcb_6a(); + void Opc_fdcb_6b(); + void Opc_fdcb_6c(); + void Opc_fdcb_6d(); + void Opc_fdcb_6e(); + void Opc_fdcb_6f(); + void Opc_fdcb_70(); + void Opc_fdcb_71(); + void Opc_fdcb_72(); + void Opc_fdcb_73(); + void Opc_fdcb_74(); + void Opc_fdcb_75(); + void Opc_fdcb_76(); + void Opc_fdcb_77(); + void Opc_fdcb_78(); + void Opc_fdcb_79(); + void Opc_fdcb_7a(); + void Opc_fdcb_7b(); + void Opc_fdcb_7c(); + void Opc_fdcb_7d(); + void Opc_fdcb_7e(); + void Opc_fdcb_7f(); + void Opc_fdcb_80(); + void Opc_fdcb_81(); + void Opc_fdcb_82(); + void Opc_fdcb_83(); + void Opc_fdcb_84(); + void Opc_fdcb_85(); + void Opc_fdcb_86(); + void Opc_fdcb_87(); + void Opc_fdcb_88(); + void Opc_fdcb_89(); + void Opc_fdcb_8a(); + void Opc_fdcb_8b(); + void Opc_fdcb_8c(); + void Opc_fdcb_8d(); + void Opc_fdcb_8e(); + void Opc_fdcb_8f(); + void Opc_fdcb_90(); + void Opc_fdcb_91(); + void Opc_fdcb_92(); + void Opc_fdcb_93(); + void Opc_fdcb_94(); + void Opc_fdcb_95(); + void Opc_fdcb_96(); + void Opc_fdcb_97(); + void Opc_fdcb_98(); + void Opc_fdcb_99(); + void Opc_fdcb_9a(); + void Opc_fdcb_9b(); + void Opc_fdcb_9c(); + void Opc_fdcb_9d(); + void Opc_fdcb_9e(); + void Opc_fdcb_9f(); + void Opc_fdcb_a0(); + void Opc_fdcb_a1(); + void Opc_fdcb_a2(); + void Opc_fdcb_a3(); + void Opc_fdcb_a4(); + void Opc_fdcb_a5(); + void Opc_fdcb_a6(); + void Opc_fdcb_a7(); + void Opc_fdcb_a8(); + void Opc_fdcb_a9(); + void Opc_fdcb_aa(); + void Opc_fdcb_ab(); + void Opc_fdcb_ac(); + void Opc_fdcb_ad(); + void Opc_fdcb_ae(); + void Opc_fdcb_af(); + void Opc_fdcb_b0(); + void Opc_fdcb_b1(); + void Opc_fdcb_b2(); + void Opc_fdcb_b3(); + void Opc_fdcb_b4(); + void Opc_fdcb_b5(); + void Opc_fdcb_b6(); + void Opc_fdcb_b7(); + void Opc_fdcb_b8(); + void Opc_fdcb_b9(); + void Opc_fdcb_ba(); + void Opc_fdcb_bb(); + void Opc_fdcb_bc(); + void Opc_fdcb_bd(); + void Opc_fdcb_be(); + void Opc_fdcb_bf(); + void Opc_fdcb_c0(); + void Opc_fdcb_c1(); + void Opc_fdcb_c2(); + void Opc_fdcb_c3(); + void Opc_fdcb_c4(); + void Opc_fdcb_c5(); + void Opc_fdcb_c6(); + void Opc_fdcb_c7(); + void Opc_fdcb_c8(); + void Opc_fdcb_c9(); + void Opc_fdcb_ca(); + void Opc_fdcb_cb(); + void Opc_fdcb_cc(); + void Opc_fdcb_cd(); + void Opc_fdcb_ce(); + void Opc_fdcb_cf(); + void Opc_fdcb_d0(); + void Opc_fdcb_d1(); + void Opc_fdcb_d2(); + void Opc_fdcb_d3(); + void Opc_fdcb_d4(); + void Opc_fdcb_d5(); + void Opc_fdcb_d6(); + void Opc_fdcb_d7(); + void Opc_fdcb_d8(); + void Opc_fdcb_d9(); + void Opc_fdcb_da(); + void Opc_fdcb_db(); + void Opc_fdcb_dc(); + void Opc_fdcb_dd(); + void Opc_fdcb_de(); + void Opc_fdcb_df(); + void Opc_fdcb_e0(); + void Opc_fdcb_e1(); + void Opc_fdcb_e2(); + void Opc_fdcb_e3(); + void Opc_fdcb_e4(); + void Opc_fdcb_e5(); + void Opc_fdcb_e6(); + void Opc_fdcb_e7(); + void Opc_fdcb_e8(); + void Opc_fdcb_e9(); + void Opc_fdcb_ea(); + void Opc_fdcb_eb(); + void Opc_fdcb_ec(); + void Opc_fdcb_ed(); + void Opc_fdcb_ee(); + void Opc_fdcb_ef(); + void Opc_fdcb_f0(); + void Opc_fdcb_f1(); + void Opc_fdcb_f2(); + void Opc_fdcb_f3(); + void Opc_fdcb_f4(); + void Opc_fdcb_f5(); + void Opc_fdcb_f6(); + void Opc_fdcb_f7(); + void Opc_fdcb_f8(); + void Opc_fdcb_f9(); + void Opc_fdcb_fa(); + void Opc_fdcb_fb(); + void Opc_fdcb_fc(); + void Opc_fdcb_fd(); + void Opc_fdcb_fe(); + void Opc_fdcb_ff(); + + /* Pre computed variables. */ + static u8 bitval[8]; + static u8 PF_SF_ZF_[256]; + static u8 PF_[256]; + + /* Jump tables. */ + typedef void (Z80::* Opc_handler)(); + static Opc_handler Opc_std[256]; + static Opc_handler Opc_cbxx[256]; + static Opc_handler Opc_ddxx[256]; + static Opc_handler Opc_ddcb[256]; + static Opc_handler Opc_edxx[256]; + static Opc_handler Opc_fdxx[256]; + static Opc_handler Opc_fdcb[256]; +}; - /* - * Internal Register Manipulation Functions. - * Get 16 reg from its 8 bits composant registers. - */ - u16 getAF() { return ( (A << 8) | F);} - u16 getBC() { return ( (B << 8) | C);} - u16 getDE() { return ( (D << 8) | E);} - u16 getHL() { return ( (H << 8) | L);} - u16 getIX() { return ( IX );} - u16 getIY() { return ( IY );} - u16 getPC() { return ( PC );} - u16 getSP() { return ( SP );} - u8 getI() { return ( I );} - u8 getR() { return ( R );} - -#ifdef OPCODES_STATS - u32 *NO_Prefix; - u32 *CB_Prefix; - u32 *DD_Prefix; - u32 *ED_Prefix; - u32 *FD_Prefix; - u32 *DDCB_Prefix; - u32 *FDCB_Prefix; - void opcodes_stats(); -#endif - private: - void exec_cb(); /* Execute opcode prefixed 0xCB. */ - void exec_dd(); /* Execute opcode prefixed 0xDD. */ - void exec_ddcb(); /* Execute opcode prefixed 0xDDCB. */ - void exec_ed(); /* Execute opcode prefixed 0xED. */ - void exec_fd(); /* Execute opcode prefixed 0xFD. */ - void exec_fdcb(); /* Execute opcode prefixed 0xFDCB. */ - bool checkInterrupt(); - void dump(u16 addr); - - /* - * Internal Register Manipulation Functions. - * Set 8 bits composant registers from 16 bit value. - */ - void setAF (u16 v) {A = v>>8; F = v & 0xFF;} - void setBC (u16 v) {B = v>>8; C = v & 0xFF;} - void setDE (u16 v) {D = v>>8; E = v & 0xFF;} - void setHL (u16 v) {H = v>>8; L = v & 0xFF;} - - /* - * Internal indirect 8 bits regs Addressing. - * Set/Get Indirect 8 bits values. - */ - u8 getBCi() { return env.rd8(getBC());} /* read u8 in (BC) */ - void setBCi(u8 val) { env.wr8(getBC(),val);} /* write u8 in (BC) */ - u8 getDEi() { return env.rd8(getDE());} /* read u8 in (DE) */ - void setDEi(u8 val) { env.wr8(getDE(),val);} /* write u8 in (DE) */ - u8 getHLi() { return env.rd8(getHL());} /* read u8 in (HL) */ - void setHLi(u8 val) { env.wr8(getHL(),val);} /* write u8 in (HL) */ - - /* 8 bit read/write throught (IX+d) and (IY+d). Warning: PC is not incremented ! */ - u8 getIXdi() {return env.rd8((u16)(IX + (s8)env.rd8(PC)));} - void setIXdi(u8 val) { env.wr8((u16)(IX + (s8)env.rd8(PC)),val);} - u8 getIYdi() {return env.rd8((u16)(IY + (s8)env.rd8(PC)));} - void setIYdi(u8 val) { env.wr8((u16)(IY + (s8)env.rd8(PC)),val);} - void setNNi16(u16 val16b) {env.wr16(env.rd16(PC),val16b);} - u16 getNNi16() { return env.rd16(env.rd16(PC));} - void setNNi8(u8 val8b) { env.wr8(env.rd16(PC),val8b); } - u8 getNNi8() { return env.rd8(env.rd16(PC));} - - - /** - * Basic Arithmetic CPU Operations: - */ - u8 inc8(u8 v); /* increment 8bits value. */ - u8 dec8(u8 v); /* decrement 8bits value. */ - u8 add8(u8 a,u8 b); /* add 8 bits values. */ - u8 adc8(u8 a,u8 b); /* add with carry 8 bits values. */ - u8 sbc8(u8 a,u8 b); /* sub with carry 8 bits values. */ - u8 sub8(u8 a,u8 b); /* sub 8 bits values. */ - u16 add16(u16 a,u16 b); /* add 16 bits values. */ - void sbcHL(u16 v); /* SBC HL, REG */ - void adcHL(u16 v); /* ADC HL, REG */ - void rrd(); /* RRD */ - void rld(); /* RLD */ - void cp8(u8 a, u8 b); /* Compare 8bits values. */ - - /** - * Basic Logical CPU Operations: - */ - u8 and8(u8 a,u8 b); /* and 8 bits values. */ - u8 or8(u8 a,u8 b); /* or 8 bits values. */ - u8 xor8(u8 a,u8 b); /* xor 8 bits values. */ - - /** - * Basic Shift CPU Operations: - */ - u8 rlc8(u8 v); /* (<<1) 8 bits value. */ - u8 rrc8(u8 v); /* (>>1) 8 bits value.*/ - u8 rl8(u8 v); /* (<<1) 8 bits value.*/ - u8 rr8(u8 v); /* (>>1) 8 bits value.*/ - u8 sla8(u8 v); /* .*/ - u8 sra8(u8 v); /* .*/ - u8 sll8(u8 v); /* .*/ - u8 srl8(u8 v); /* .*/ - - /** - * Basic Bit CPU Operations: - */ - void bit(u8 bit,u8 v); /* test bit in 8 bits value.*/ - u8 set(u8 bit,u8 v); /* set bit in 8 bits value.*/ - u8 res(u8 bit,u8 v); /* reset bit in 8 bits value.*/ - - /** - * Basic Stack CPU Operations: - */ - u16 pop(); /* Pop 16 bits value.*/ - void push(u16 v); /* Push 16 bits value*/ - void rst(u16 ea); /* rst operation.*/ - void setFlagAfterInput(u8 r); - void invalid_opcode(); - void invalid_prefixed_opcode(); - void nop() ; - - /** - * CPU opcode callbacks: - */ - void Opc_std_00(); - void Opc_std_01(); - void Opc_std_02(); - void Opc_std_03(); - void Opc_std_04(); - void Opc_std_05(); - void Opc_std_06(); - void Opc_std_07(); - void Opc_std_08(); - void Opc_std_09(); - void Opc_std_0a(); - void Opc_std_0b(); - void Opc_std_0c(); - void Opc_std_0d(); - void Opc_std_0e(); - void Opc_std_0f(); - void Opc_std_10(); - void Opc_std_11(); - void Opc_std_12(); - void Opc_std_13(); - void Opc_std_14(); - void Opc_std_15(); - void Opc_std_16(); - void Opc_std_17(); - void Opc_std_18(); - void Opc_std_19(); - void Opc_std_1a(); - void Opc_std_1b(); - void Opc_std_1c(); - void Opc_std_1d(); - void Opc_std_1e(); - void Opc_std_1f(); - void Opc_std_20(); - void Opc_std_21(); - void Opc_std_22(); - void Opc_std_23(); - void Opc_std_24(); - void Opc_std_25(); - void Opc_std_26(); - void Opc_std_27(); - void Opc_std_28(); - void Opc_std_29(); - void Opc_std_2a(); - void Opc_std_2b(); - void Opc_std_2c(); - void Opc_std_2d(); - void Opc_std_2e(); - void Opc_std_2f(); - void Opc_std_30(); - void Opc_std_31(); - void Opc_std_32(); - void Opc_std_33(); - void Opc_std_34(); - void Opc_std_35(); - void Opc_std_36(); - void Opc_std_37(); - void Opc_std_38(); - void Opc_std_39(); - void Opc_std_3a(); - void Opc_std_3b(); - void Opc_std_3c(); - void Opc_std_3d(); - void Opc_std_3e(); - void Opc_std_3f(); - void Opc_std_40(); - void Opc_std_41(); - void Opc_std_42(); - void Opc_std_43(); - void Opc_std_44(); - void Opc_std_45(); - void Opc_std_46(); - void Opc_std_47(); - void Opc_std_48(); - void Opc_std_49(); - void Opc_std_4a(); - void Opc_std_4b(); - void Opc_std_4c(); - void Opc_std_4d(); - void Opc_std_4e(); - void Opc_std_4f(); - void Opc_std_50(); - void Opc_std_51(); - void Opc_std_52(); - void Opc_std_53(); - void Opc_std_54(); - void Opc_std_55(); - void Opc_std_56(); - void Opc_std_57(); - void Opc_std_58(); - void Opc_std_59(); - void Opc_std_5a(); - void Opc_std_5b(); - void Opc_std_5c(); - void Opc_std_5d(); - void Opc_std_5e(); - void Opc_std_5f(); - void Opc_std_60(); - void Opc_std_61(); - void Opc_std_62(); - void Opc_std_63(); - void Opc_std_64(); - void Opc_std_65(); - void Opc_std_66(); - void Opc_std_67(); - void Opc_std_68(); - void Opc_std_69(); - void Opc_std_6a(); - void Opc_std_6b(); - void Opc_std_6c(); - void Opc_std_6d(); - void Opc_std_6e(); - void Opc_std_6f(); - void Opc_std_70(); - void Opc_std_71(); - void Opc_std_72(); - void Opc_std_73(); - void Opc_std_74(); - void Opc_std_75(); - void Opc_std_76(); - void Opc_std_77(); - void Opc_std_78(); - void Opc_std_79(); - void Opc_std_7a(); - void Opc_std_7b(); - void Opc_std_7c(); - void Opc_std_7d(); - void Opc_std_7e(); - void Opc_std_7f(); - void Opc_std_80(); - void Opc_std_81(); - void Opc_std_82(); - void Opc_std_83(); - void Opc_std_84(); - void Opc_std_85(); - void Opc_std_86(); - void Opc_std_87(); - void Opc_std_88(); - void Opc_std_89(); - void Opc_std_8a(); - void Opc_std_8b(); - void Opc_std_8c(); - void Opc_std_8d(); - void Opc_std_8e(); - void Opc_std_8f(); - void Opc_std_90(); - void Opc_std_91(); - void Opc_std_92(); - void Opc_std_93(); - void Opc_std_94(); - void Opc_std_95(); - void Opc_std_96(); - void Opc_std_97(); - void Opc_std_98(); - void Opc_std_99(); - void Opc_std_9a(); - void Opc_std_9b(); - void Opc_std_9c(); - void Opc_std_9d(); - void Opc_std_9e(); - void Opc_std_9f(); - void Opc_std_a0(); - void Opc_std_a1(); - void Opc_std_a2(); - void Opc_std_a3(); - void Opc_std_a4(); - void Opc_std_a5(); - void Opc_std_a6(); - void Opc_std_a7(); - void Opc_std_a8(); - void Opc_std_a9(); - void Opc_std_aa(); - void Opc_std_ab(); - void Opc_std_ac(); - void Opc_std_ad(); - void Opc_std_ae(); - void Opc_std_af(); - void Opc_std_b0(); - void Opc_std_b1(); - void Opc_std_b2(); - void Opc_std_b3(); - void Opc_std_b4(); - void Opc_std_b5(); - void Opc_std_b6(); - void Opc_std_b7(); - void Opc_std_b8(); - void Opc_std_b9(); - void Opc_std_ba(); - void Opc_std_bb(); - void Opc_std_bc(); - void Opc_std_bd(); - void Opc_std_be(); - void Opc_std_bf(); - void Opc_std_c0(); - void Opc_std_c1(); - void Opc_std_c2(); - void Opc_std_c3(); - void Opc_std_c4(); - void Opc_std_c5(); - void Opc_std_c6(); - void Opc_std_c7(); - void Opc_std_c8(); - void Opc_std_c9(); - void Opc_std_ca(); - void Opc_std_cb(); - void Opc_std_cc(); - void Opc_std_cd(); - void Opc_std_ce(); - void Opc_std_cf(); - void Opc_std_d0(); - void Opc_std_d1(); - void Opc_std_d2(); - void Opc_std_d3(); - void Opc_std_d4(); - void Opc_std_d5(); - void Opc_std_d6(); - void Opc_std_d7(); - void Opc_std_d8(); - void Opc_std_d9(); - void Opc_std_da(); - void Opc_std_db(); - void Opc_std_dc(); - void Opc_std_dd(); - void Opc_std_de(); - void Opc_std_df(); - void Opc_std_e0(); - void Opc_std_e1(); - void Opc_std_e2(); - void Opc_std_e3(); - void Opc_std_e4(); - void Opc_std_e5(); - void Opc_std_e6(); - void Opc_std_e7(); - void Opc_std_e8(); - void Opc_std_e9(); - void Opc_std_ea(); - void Opc_std_eb(); - void Opc_std_ec(); - void Opc_std_ed(); - void Opc_std_ee(); - void Opc_std_ef(); - void Opc_std_f0(); - void Opc_std_f1(); - void Opc_std_f2(); - void Opc_std_f3(); - void Opc_std_f4(); - void Opc_std_f5(); - void Opc_std_f6(); - void Opc_std_f7(); - void Opc_std_f8(); - void Opc_std_f9(); - void Opc_std_fa(); - void Opc_std_fb(); - void Opc_std_fc(); - void Opc_std_fd(); - void Opc_std_fe(); - void Opc_std_ff(); - - // Opcodes CBXX prototypes. - void Opc_cbxx_00(); - void Opc_cbxx_01(); - void Opc_cbxx_02(); - void Opc_cbxx_03(); - void Opc_cbxx_04(); - void Opc_cbxx_05(); - void Opc_cbxx_06(); - void Opc_cbxx_07(); - void Opc_cbxx_08(); - void Opc_cbxx_09(); - void Opc_cbxx_0a(); - void Opc_cbxx_0b(); - void Opc_cbxx_0c(); - void Opc_cbxx_0d(); - void Opc_cbxx_0e(); - void Opc_cbxx_0f(); - void Opc_cbxx_10(); - void Opc_cbxx_11(); - void Opc_cbxx_12(); - void Opc_cbxx_13(); - void Opc_cbxx_14(); - void Opc_cbxx_15(); - void Opc_cbxx_16(); - void Opc_cbxx_17(); - void Opc_cbxx_18(); - void Opc_cbxx_19(); - void Opc_cbxx_1a(); - void Opc_cbxx_1b(); - void Opc_cbxx_1c(); - void Opc_cbxx_1d(); - void Opc_cbxx_1e(); - void Opc_cbxx_1f(); - void Opc_cbxx_20(); - void Opc_cbxx_21(); - void Opc_cbxx_22(); - void Opc_cbxx_23(); - void Opc_cbxx_24(); - void Opc_cbxx_25(); - void Opc_cbxx_26(); - void Opc_cbxx_27(); - void Opc_cbxx_28(); - void Opc_cbxx_29(); - void Opc_cbxx_2a(); - void Opc_cbxx_2b(); - void Opc_cbxx_2c(); - void Opc_cbxx_2d(); - void Opc_cbxx_2e(); - void Opc_cbxx_2f(); - void Opc_cbxx_30(); - void Opc_cbxx_31(); - void Opc_cbxx_32(); - void Opc_cbxx_33(); - void Opc_cbxx_34(); - void Opc_cbxx_35(); - void Opc_cbxx_36(); - void Opc_cbxx_37(); - void Opc_cbxx_38(); - void Opc_cbxx_39(); - void Opc_cbxx_3a(); - void Opc_cbxx_3b(); - void Opc_cbxx_3c(); - void Opc_cbxx_3d(); - void Opc_cbxx_3e(); - void Opc_cbxx_3f(); - void Opc_cbxx_40(); - void Opc_cbxx_41(); - void Opc_cbxx_42(); - void Opc_cbxx_43(); - void Opc_cbxx_44(); - void Opc_cbxx_45(); - void Opc_cbxx_46(); - void Opc_cbxx_47(); - void Opc_cbxx_48(); - void Opc_cbxx_49(); - void Opc_cbxx_4a(); - void Opc_cbxx_4b(); - void Opc_cbxx_4c(); - void Opc_cbxx_4d(); - void Opc_cbxx_4e(); - void Opc_cbxx_4f(); - void Opc_cbxx_50(); - void Opc_cbxx_51(); - void Opc_cbxx_52(); - void Opc_cbxx_53(); - void Opc_cbxx_54(); - void Opc_cbxx_55(); - void Opc_cbxx_56(); - void Opc_cbxx_57(); - void Opc_cbxx_58(); - void Opc_cbxx_59(); - void Opc_cbxx_5a(); - void Opc_cbxx_5b(); - void Opc_cbxx_5c(); - void Opc_cbxx_5d(); - void Opc_cbxx_5e(); - void Opc_cbxx_5f(); - void Opc_cbxx_60(); - void Opc_cbxx_61(); - void Opc_cbxx_62(); - void Opc_cbxx_63(); - void Opc_cbxx_64(); - void Opc_cbxx_65(); - void Opc_cbxx_66(); - void Opc_cbxx_67(); - void Opc_cbxx_68(); - void Opc_cbxx_69(); - void Opc_cbxx_6a(); - void Opc_cbxx_6b(); - void Opc_cbxx_6c(); - void Opc_cbxx_6d(); - void Opc_cbxx_6e(); - void Opc_cbxx_6f(); - void Opc_cbxx_70(); - void Opc_cbxx_71(); - void Opc_cbxx_72(); - void Opc_cbxx_73(); - void Opc_cbxx_74(); - void Opc_cbxx_75(); - void Opc_cbxx_76(); - void Opc_cbxx_77(); - void Opc_cbxx_78(); - void Opc_cbxx_79(); - void Opc_cbxx_7a(); - void Opc_cbxx_7b(); - void Opc_cbxx_7c(); - void Opc_cbxx_7d(); - void Opc_cbxx_7e(); - void Opc_cbxx_7f(); - void Opc_cbxx_80(); - void Opc_cbxx_81(); - void Opc_cbxx_82(); - void Opc_cbxx_83(); - void Opc_cbxx_84(); - void Opc_cbxx_85(); - void Opc_cbxx_86(); - void Opc_cbxx_87(); - void Opc_cbxx_88(); - void Opc_cbxx_89(); - void Opc_cbxx_8a(); - void Opc_cbxx_8b(); - void Opc_cbxx_8c(); - void Opc_cbxx_8d(); - void Opc_cbxx_8e(); - void Opc_cbxx_8f(); - void Opc_cbxx_90(); - void Opc_cbxx_91(); - void Opc_cbxx_92(); - void Opc_cbxx_93(); - void Opc_cbxx_94(); - void Opc_cbxx_95(); - void Opc_cbxx_96(); - void Opc_cbxx_97(); - void Opc_cbxx_98(); - void Opc_cbxx_99(); - void Opc_cbxx_9a(); - void Opc_cbxx_9b(); - void Opc_cbxx_9c(); - void Opc_cbxx_9d(); - void Opc_cbxx_9e(); - void Opc_cbxx_9f(); - void Opc_cbxx_a0(); - void Opc_cbxx_a1(); - void Opc_cbxx_a2(); - void Opc_cbxx_a3(); - void Opc_cbxx_a4(); - void Opc_cbxx_a5(); - void Opc_cbxx_a6(); - void Opc_cbxx_a7(); - void Opc_cbxx_a8(); - void Opc_cbxx_a9(); - void Opc_cbxx_aa(); - void Opc_cbxx_ab(); - void Opc_cbxx_ac(); - void Opc_cbxx_ad(); - void Opc_cbxx_ae(); - void Opc_cbxx_af(); - void Opc_cbxx_b0(); - void Opc_cbxx_b1(); - void Opc_cbxx_b2(); - void Opc_cbxx_b3(); - void Opc_cbxx_b4(); - void Opc_cbxx_b5(); - void Opc_cbxx_b6(); - void Opc_cbxx_b7(); - void Opc_cbxx_b8(); - void Opc_cbxx_b9(); - void Opc_cbxx_ba(); - void Opc_cbxx_bb(); - void Opc_cbxx_bc(); - void Opc_cbxx_bd(); - void Opc_cbxx_be(); - void Opc_cbxx_bf(); - void Opc_cbxx_c0(); - void Opc_cbxx_c1(); - void Opc_cbxx_c2(); - void Opc_cbxx_c3(); - void Opc_cbxx_c4(); - void Opc_cbxx_c5(); - void Opc_cbxx_c6(); - void Opc_cbxx_c7(); - void Opc_cbxx_c8(); - void Opc_cbxx_c9(); - void Opc_cbxx_ca(); - void Opc_cbxx_cb(); - void Opc_cbxx_cc(); - void Opc_cbxx_cd(); - void Opc_cbxx_ce(); - void Opc_cbxx_cf(); - void Opc_cbxx_d0(); - void Opc_cbxx_d1(); - void Opc_cbxx_d2(); - void Opc_cbxx_d3(); - void Opc_cbxx_d4(); - void Opc_cbxx_d5(); - void Opc_cbxx_d6(); - void Opc_cbxx_d7(); - void Opc_cbxx_d8(); - void Opc_cbxx_d9(); - void Opc_cbxx_da(); - void Opc_cbxx_db(); - void Opc_cbxx_dc(); - void Opc_cbxx_dd(); - void Opc_cbxx_de(); - void Opc_cbxx_df(); - void Opc_cbxx_e0(); - void Opc_cbxx_e1(); - void Opc_cbxx_e2(); - void Opc_cbxx_e3(); - void Opc_cbxx_e4(); - void Opc_cbxx_e5(); - void Opc_cbxx_e6(); - void Opc_cbxx_e7(); - void Opc_cbxx_e8(); - void Opc_cbxx_e9(); - void Opc_cbxx_ea(); - void Opc_cbxx_eb(); - void Opc_cbxx_ec(); - void Opc_cbxx_ed(); - void Opc_cbxx_ee(); - void Opc_cbxx_ef(); - void Opc_cbxx_f0(); - void Opc_cbxx_f1(); - void Opc_cbxx_f2(); - void Opc_cbxx_f3(); - void Opc_cbxx_f4(); - void Opc_cbxx_f5(); - void Opc_cbxx_f6(); - void Opc_cbxx_f7(); - void Opc_cbxx_f8(); - void Opc_cbxx_f9(); - void Opc_cbxx_fa(); - void Opc_cbxx_fb(); - void Opc_cbxx_fc(); - void Opc_cbxx_fd(); - void Opc_cbxx_fe(); - void Opc_cbxx_ff(); - - // Opcodes DDXX prototypes. - void Opc_ddxx_09(); - void Opc_ddxx_19(); - void Opc_ddxx_21(); - void Opc_ddxx_22(); - void Opc_ddxx_23(); - void Opc_ddxx_24(); - void Opc_ddxx_25(); - void Opc_ddxx_26(); - void Opc_ddxx_29(); - void Opc_ddxx_2a(); - void Opc_ddxx_2b(); - void Opc_ddxx_2c(); - void Opc_ddxx_2d(); - void Opc_ddxx_2e(); - void Opc_ddxx_34(); - void Opc_ddxx_35(); - void Opc_ddxx_36(); - void Opc_ddxx_39(); - void Opc_ddxx_44(); - void Opc_ddxx_45(); - void Opc_ddxx_46(); - void Opc_ddxx_4c(); - void Opc_ddxx_4d(); - void Opc_ddxx_4e(); - void Opc_ddxx_54(); - void Opc_ddxx_55(); - void Opc_ddxx_56(); - void Opc_ddxx_5c(); - void Opc_ddxx_5d(); - void Opc_ddxx_5e(); - void Opc_ddxx_60(); - void Opc_ddxx_61(); - void Opc_ddxx_62(); - void Opc_ddxx_63(); - void Opc_ddxx_64(); - void Opc_ddxx_65(); - void Opc_ddxx_66(); - void Opc_ddxx_67(); - void Opc_ddxx_68(); - void Opc_ddxx_69(); - void Opc_ddxx_6a(); - void Opc_ddxx_6b(); - void Opc_ddxx_6c(); - void Opc_ddxx_6d(); - void Opc_ddxx_6e(); - void Opc_ddxx_6f(); - void Opc_ddxx_70(); - void Opc_ddxx_71(); - void Opc_ddxx_72(); - void Opc_ddxx_73(); - void Opc_ddxx_74(); - void Opc_ddxx_75(); - void Opc_ddxx_77(); - void Opc_ddxx_7c(); - void Opc_ddxx_7d(); - void Opc_ddxx_7e(); - void Opc_ddxx_84(); - void Opc_ddxx_85(); - void Opc_ddxx_86(); - void Opc_ddxx_8c(); - void Opc_ddxx_8d(); - void Opc_ddxx_8e(); - void Opc_ddxx_94(); - void Opc_ddxx_95(); - void Opc_ddxx_96(); - void Opc_ddxx_9c(); - void Opc_ddxx_9d(); - void Opc_ddxx_9e(); - void Opc_ddxx_a4(); - void Opc_ddxx_a5(); - void Opc_ddxx_a6(); - void Opc_ddxx_ac(); - void Opc_ddxx_ad(); - void Opc_ddxx_ae(); - void Opc_ddxx_b4(); - void Opc_ddxx_b5(); - void Opc_ddxx_b6(); - void Opc_ddxx_bc(); - void Opc_ddxx_bd(); - void Opc_ddxx_be(); - void Opc_ddxx_e1(); - void Opc_ddxx_e3(); - void Opc_ddxx_e5(); - void Opc_ddxx_e9(); - void Opc_ddxx_f9(); - - // Opcodes DDCB prototypes. - void Opc_ddcb_00(); - void Opc_ddcb_01(); - void Opc_ddcb_02(); - void Opc_ddcb_03(); - void Opc_ddcb_04(); - void Opc_ddcb_05(); - void Opc_ddcb_06(); - void Opc_ddcb_07(); - void Opc_ddcb_08(); - void Opc_ddcb_09(); - void Opc_ddcb_0a(); - void Opc_ddcb_0b(); - void Opc_ddcb_0c(); - void Opc_ddcb_0d(); - void Opc_ddcb_0e(); - void Opc_ddcb_0f(); - void Opc_ddcb_10(); - void Opc_ddcb_11(); - void Opc_ddcb_12(); - void Opc_ddcb_13(); - void Opc_ddcb_14(); - void Opc_ddcb_15(); - void Opc_ddcb_16(); - void Opc_ddcb_17(); - void Opc_ddcb_18(); - void Opc_ddcb_19(); - void Opc_ddcb_1a(); - void Opc_ddcb_1b(); - void Opc_ddcb_1c(); - void Opc_ddcb_1d(); - void Opc_ddcb_1e(); - void Opc_ddcb_1f(); - void Opc_ddcb_20(); - void Opc_ddcb_21(); - void Opc_ddcb_22(); - void Opc_ddcb_23(); - void Opc_ddcb_24(); - void Opc_ddcb_25(); - void Opc_ddcb_26(); - void Opc_ddcb_27(); - void Opc_ddcb_28(); - void Opc_ddcb_29(); - void Opc_ddcb_2a(); - void Opc_ddcb_2b(); - void Opc_ddcb_2c(); - void Opc_ddcb_2d(); - void Opc_ddcb_2e(); - void Opc_ddcb_2f(); - void Opc_ddcb_30(); - void Opc_ddcb_31(); - void Opc_ddcb_32(); - void Opc_ddcb_33(); - void Opc_ddcb_34(); - void Opc_ddcb_35(); - void Opc_ddcb_36(); - void Opc_ddcb_37(); - void Opc_ddcb_38(); - void Opc_ddcb_39(); - void Opc_ddcb_3a(); - void Opc_ddcb_3b(); - void Opc_ddcb_3c(); - void Opc_ddcb_3d(); - void Opc_ddcb_3e(); - void Opc_ddcb_3f(); - void Opc_ddcb_40(); - void Opc_ddcb_41(); - void Opc_ddcb_42(); - void Opc_ddcb_43(); - void Opc_ddcb_44(); - void Opc_ddcb_45(); - void Opc_ddcb_46(); - void Opc_ddcb_47(); - void Opc_ddcb_48(); - void Opc_ddcb_49(); - void Opc_ddcb_4a(); - void Opc_ddcb_4b(); - void Opc_ddcb_4c(); - void Opc_ddcb_4d(); - void Opc_ddcb_4e(); - void Opc_ddcb_4f(); - void Opc_ddcb_50(); - void Opc_ddcb_51(); - void Opc_ddcb_52(); - void Opc_ddcb_53(); - void Opc_ddcb_54(); - void Opc_ddcb_55(); - void Opc_ddcb_56(); - void Opc_ddcb_57(); - void Opc_ddcb_58(); - void Opc_ddcb_59(); - void Opc_ddcb_5a(); - void Opc_ddcb_5b(); - void Opc_ddcb_5c(); - void Opc_ddcb_5d(); - void Opc_ddcb_5e(); - void Opc_ddcb_5f(); - void Opc_ddcb_60(); - void Opc_ddcb_61(); - void Opc_ddcb_62(); - void Opc_ddcb_63(); - void Opc_ddcb_64(); - void Opc_ddcb_65(); - void Opc_ddcb_66(); - void Opc_ddcb_67(); - void Opc_ddcb_68(); - void Opc_ddcb_69(); - void Opc_ddcb_6a(); - void Opc_ddcb_6b(); - void Opc_ddcb_6c(); - void Opc_ddcb_6d(); - void Opc_ddcb_6e(); - void Opc_ddcb_6f(); - void Opc_ddcb_70(); - void Opc_ddcb_71(); - void Opc_ddcb_72(); - void Opc_ddcb_73(); - void Opc_ddcb_74(); - void Opc_ddcb_75(); - void Opc_ddcb_76(); - void Opc_ddcb_77(); - void Opc_ddcb_78(); - void Opc_ddcb_79(); - void Opc_ddcb_7a(); - void Opc_ddcb_7b(); - void Opc_ddcb_7c(); - void Opc_ddcb_7d(); - void Opc_ddcb_7e(); - void Opc_ddcb_7f(); - void Opc_ddcb_80(); - void Opc_ddcb_81(); - void Opc_ddcb_82(); - void Opc_ddcb_83(); - void Opc_ddcb_84(); - void Opc_ddcb_85(); - void Opc_ddcb_86(); - void Opc_ddcb_87(); - void Opc_ddcb_88(); - void Opc_ddcb_89(); - void Opc_ddcb_8a(); - void Opc_ddcb_8b(); - void Opc_ddcb_8c(); - void Opc_ddcb_8d(); - void Opc_ddcb_8e(); - void Opc_ddcb_8f(); - void Opc_ddcb_90(); - void Opc_ddcb_91(); - void Opc_ddcb_92(); - void Opc_ddcb_93(); - void Opc_ddcb_94(); - void Opc_ddcb_95(); - void Opc_ddcb_96(); - void Opc_ddcb_97(); - void Opc_ddcb_98(); - void Opc_ddcb_99(); - void Opc_ddcb_9a(); - void Opc_ddcb_9b(); - void Opc_ddcb_9c(); - void Opc_ddcb_9d(); - void Opc_ddcb_9e(); - void Opc_ddcb_9f(); - void Opc_ddcb_a0(); - void Opc_ddcb_a1(); - void Opc_ddcb_a2(); - void Opc_ddcb_a3(); - void Opc_ddcb_a4(); - void Opc_ddcb_a5(); - void Opc_ddcb_a6(); - void Opc_ddcb_a7(); - void Opc_ddcb_a8(); - void Opc_ddcb_a9(); - void Opc_ddcb_aa(); - void Opc_ddcb_ab(); - void Opc_ddcb_ac(); - void Opc_ddcb_ad(); - void Opc_ddcb_ae(); - void Opc_ddcb_af(); - void Opc_ddcb_b0(); - void Opc_ddcb_b1(); - void Opc_ddcb_b2(); - void Opc_ddcb_b3(); - void Opc_ddcb_b4(); - void Opc_ddcb_b5(); - void Opc_ddcb_b6(); - void Opc_ddcb_b7(); - void Opc_ddcb_b8(); - void Opc_ddcb_b9(); - void Opc_ddcb_ba(); - void Opc_ddcb_bb(); - void Opc_ddcb_bc(); - void Opc_ddcb_bd(); - void Opc_ddcb_be(); - void Opc_ddcb_bf(); - void Opc_ddcb_c0(); - void Opc_ddcb_c1(); - void Opc_ddcb_c2(); - void Opc_ddcb_c3(); - void Opc_ddcb_c4(); - void Opc_ddcb_c5(); - void Opc_ddcb_c6(); - void Opc_ddcb_c7(); - void Opc_ddcb_c8(); - void Opc_ddcb_c9(); - void Opc_ddcb_ca(); - void Opc_ddcb_cb(); - void Opc_ddcb_cc(); - void Opc_ddcb_cd(); - void Opc_ddcb_ce(); - void Opc_ddcb_cf(); - void Opc_ddcb_d0(); - void Opc_ddcb_d1(); - void Opc_ddcb_d2(); - void Opc_ddcb_d3(); - void Opc_ddcb_d4(); - void Opc_ddcb_d5(); - void Opc_ddcb_d6(); - void Opc_ddcb_d7(); - void Opc_ddcb_d8(); - void Opc_ddcb_d9(); - void Opc_ddcb_da(); - void Opc_ddcb_db(); - void Opc_ddcb_dc(); - void Opc_ddcb_dd(); - void Opc_ddcb_de(); - void Opc_ddcb_df(); - void Opc_ddcb_e0(); - void Opc_ddcb_e1(); - void Opc_ddcb_e2(); - void Opc_ddcb_e3(); - void Opc_ddcb_e4(); - void Opc_ddcb_e5(); - void Opc_ddcb_e6(); - void Opc_ddcb_e7(); - void Opc_ddcb_e8(); - void Opc_ddcb_e9(); - void Opc_ddcb_ea(); - void Opc_ddcb_eb(); - void Opc_ddcb_ec(); - void Opc_ddcb_ed(); - void Opc_ddcb_ee(); - void Opc_ddcb_ef(); - void Opc_ddcb_f0(); - void Opc_ddcb_f1(); - void Opc_ddcb_f2(); - void Opc_ddcb_f3(); - void Opc_ddcb_f4(); - void Opc_ddcb_f5(); - void Opc_ddcb_f6(); - void Opc_ddcb_f7(); - void Opc_ddcb_f8(); - void Opc_ddcb_f9(); - void Opc_ddcb_fa(); - void Opc_ddcb_fb(); - void Opc_ddcb_fc(); - void Opc_ddcb_fd(); - void Opc_ddcb_fe(); - void Opc_ddcb_ff(); - - // Opcodes EDxx prototypes. - void Opc_edxx_40(); - void Opc_edxx_41(); - void Opc_edxx_42(); - void Opc_edxx_43(); - void Opc_edxx_44(); - void Opc_edxx_45(); - void Opc_edxx_46(); - void Opc_edxx_47(); - void Opc_edxx_48(); - void Opc_edxx_49(); - void Opc_edxx_4a(); - void Opc_edxx_4b(); - void Opc_edxx_4c(); - void Opc_edxx_4d(); - void Opc_edxx_4e(); - void Opc_edxx_4f(); - void Opc_edxx_50(); - void Opc_edxx_51(); - void Opc_edxx_52(); - void Opc_edxx_53(); - void Opc_edxx_54(); - void Opc_edxx_55(); - void Opc_edxx_56(); - void Opc_edxx_57(); - void Opc_edxx_58(); - void Opc_edxx_59(); - void Opc_edxx_5a(); - void Opc_edxx_5b(); - void Opc_edxx_5c(); - void Opc_edxx_5d(); - void Opc_edxx_5e(); - void Opc_edxx_5f(); - void Opc_edxx_60(); - void Opc_edxx_61(); - void Opc_edxx_62(); - void Opc_edxx_63(); - void Opc_edxx_64(); - void Opc_edxx_65(); - void Opc_edxx_66(); - void Opc_edxx_67(); - void Opc_edxx_68(); - void Opc_edxx_69(); - void Opc_edxx_6a(); - void Opc_edxx_6b(); - void Opc_edxx_6c(); - void Opc_edxx_6d(); - void Opc_edxx_6e(); - void Opc_edxx_6f(); - void Opc_edxx_70(); - void Opc_edxx_71(); - void Opc_edxx_72(); - void Opc_edxx_73(); - void Opc_edxx_74(); - void Opc_edxx_75(); - void Opc_edxx_76(); - void Opc_edxx_78(); - void Opc_edxx_79(); - void Opc_edxx_7a(); - void Opc_edxx_7b(); - void Opc_edxx_7c(); - void Opc_edxx_7d(); - void Opc_edxx_7e(); - void Opc_edxx_a0(); - void Opc_edxx_a1(); - void Opc_edxx_a2(); - void Opc_edxx_a3(); - void Opc_edxx_a8(); - void Opc_edxx_a9(); - void Opc_edxx_aa(); - void Opc_edxx_ab(); - void Opc_edxx_b0(); - void Opc_edxx_b1(); - void Opc_edxx_b2(); - void Opc_edxx_b3(); - void Opc_edxx_b8(); - void Opc_edxx_b9(); - void Opc_edxx_ba(); - void Opc_edxx_bb(); - - // Opcodes FDXX prototypes. - void Opc_fdxx_09(); - void Opc_fdxx_19(); - void Opc_fdxx_21(); - void Opc_fdxx_22(); - void Opc_fdxx_23(); - void Opc_fdxx_24(); - void Opc_fdxx_25(); - void Opc_fdxx_26(); - void Opc_fdxx_29(); - void Opc_fdxx_2a(); - void Opc_fdxx_2b(); - void Opc_fdxx_2c(); - void Opc_fdxx_2d(); - void Opc_fdxx_2e(); - void Opc_fdxx_34(); - void Opc_fdxx_35(); - void Opc_fdxx_36(); - void Opc_fdxx_39(); - void Opc_fdxx_44(); - void Opc_fdxx_45(); - void Opc_fdxx_46(); - void Opc_fdxx_4c(); - void Opc_fdxx_4d(); - void Opc_fdxx_4e(); - void Opc_fdxx_54(); - void Opc_fdxx_55(); - void Opc_fdxx_56(); - void Opc_fdxx_5c(); - void Opc_fdxx_5d(); - void Opc_fdxx_5e(); - void Opc_fdxx_60(); - void Opc_fdxx_61(); - void Opc_fdxx_62(); - void Opc_fdxx_63(); - void Opc_fdxx_64(); - void Opc_fdxx_65(); - void Opc_fdxx_66(); - void Opc_fdxx_67(); - void Opc_fdxx_68(); - void Opc_fdxx_69(); - void Opc_fdxx_6a(); - void Opc_fdxx_6b(); - void Opc_fdxx_6c(); - void Opc_fdxx_6d(); - void Opc_fdxx_6e(); - void Opc_fdxx_6f(); - void Opc_fdxx_70(); - void Opc_fdxx_71(); - void Opc_fdxx_72(); - void Opc_fdxx_73(); - void Opc_fdxx_74(); - void Opc_fdxx_75(); - void Opc_fdxx_77(); - void Opc_fdxx_7c(); - void Opc_fdxx_7d(); - void Opc_fdxx_7e(); - void Opc_fdxx_84(); - void Opc_fdxx_85(); - void Opc_fdxx_86(); - void Opc_fdxx_8c(); - void Opc_fdxx_8d(); - void Opc_fdxx_8e(); - void Opc_fdxx_94(); - void Opc_fdxx_95(); - void Opc_fdxx_96(); - void Opc_fdxx_9c(); - void Opc_fdxx_9d(); - void Opc_fdxx_9e(); - void Opc_fdxx_a4(); - void Opc_fdxx_a5(); - void Opc_fdxx_a6(); - void Opc_fdxx_ac(); - void Opc_fdxx_ad(); - void Opc_fdxx_ae(); - void Opc_fdxx_b4(); - void Opc_fdxx_b5(); - void Opc_fdxx_b6(); - void Opc_fdxx_bc(); - void Opc_fdxx_bd(); - void Opc_fdxx_be(); - void Opc_fdxx_e1(); - void Opc_fdxx_e3(); - void Opc_fdxx_e5(); - void Opc_fdxx_e9(); - void Opc_fdxx_f9(); - - // Opcodes FDCB prototypes. - void Opc_fdcb_00(); - void Opc_fdcb_01(); - void Opc_fdcb_02(); - void Opc_fdcb_03(); - void Opc_fdcb_04(); - void Opc_fdcb_05(); - void Opc_fdcb_06(); - void Opc_fdcb_07(); - void Opc_fdcb_08(); - void Opc_fdcb_09(); - void Opc_fdcb_0a(); - void Opc_fdcb_0b(); - void Opc_fdcb_0c(); - void Opc_fdcb_0d(); - void Opc_fdcb_0e(); - void Opc_fdcb_0f(); - void Opc_fdcb_10(); - void Opc_fdcb_11(); - void Opc_fdcb_12(); - void Opc_fdcb_13(); - void Opc_fdcb_14(); - void Opc_fdcb_15(); - void Opc_fdcb_16(); - void Opc_fdcb_17(); - void Opc_fdcb_18(); - void Opc_fdcb_19(); - void Opc_fdcb_1a(); - void Opc_fdcb_1b(); - void Opc_fdcb_1c(); - void Opc_fdcb_1d(); - void Opc_fdcb_1e(); - void Opc_fdcb_1f(); - void Opc_fdcb_20(); - void Opc_fdcb_21(); - void Opc_fdcb_22(); - void Opc_fdcb_23(); - void Opc_fdcb_24(); - void Opc_fdcb_25(); - void Opc_fdcb_26(); - void Opc_fdcb_27(); - void Opc_fdcb_28(); - void Opc_fdcb_29(); - void Opc_fdcb_2a(); - void Opc_fdcb_2b(); - void Opc_fdcb_2c(); - void Opc_fdcb_2d(); - void Opc_fdcb_2e(); - void Opc_fdcb_2f(); - void Opc_fdcb_30(); - void Opc_fdcb_31(); - void Opc_fdcb_32(); - void Opc_fdcb_33(); - void Opc_fdcb_34(); - void Opc_fdcb_35(); - void Opc_fdcb_36(); - void Opc_fdcb_37(); - void Opc_fdcb_38(); - void Opc_fdcb_39(); - void Opc_fdcb_3a(); - void Opc_fdcb_3b(); - void Opc_fdcb_3c(); - void Opc_fdcb_3d(); - void Opc_fdcb_3e(); - void Opc_fdcb_3f(); - void Opc_fdcb_40(); - void Opc_fdcb_41(); - void Opc_fdcb_42(); - void Opc_fdcb_43(); - void Opc_fdcb_44(); - void Opc_fdcb_45(); - void Opc_fdcb_46(); - void Opc_fdcb_47(); - void Opc_fdcb_48(); - void Opc_fdcb_49(); - void Opc_fdcb_4a(); - void Opc_fdcb_4b(); - void Opc_fdcb_4c(); - void Opc_fdcb_4d(); - void Opc_fdcb_4e(); - void Opc_fdcb_4f(); - void Opc_fdcb_50(); - void Opc_fdcb_51(); - void Opc_fdcb_52(); - void Opc_fdcb_53(); - void Opc_fdcb_54(); - void Opc_fdcb_55(); - void Opc_fdcb_56(); - void Opc_fdcb_57(); - void Opc_fdcb_58(); - void Opc_fdcb_59(); - void Opc_fdcb_5a(); - void Opc_fdcb_5b(); - void Opc_fdcb_5c(); - void Opc_fdcb_5d(); - void Opc_fdcb_5e(); - void Opc_fdcb_5f(); - void Opc_fdcb_60(); - void Opc_fdcb_61(); - void Opc_fdcb_62(); - void Opc_fdcb_63(); - void Opc_fdcb_64(); - void Opc_fdcb_65(); - void Opc_fdcb_66(); - void Opc_fdcb_67(); - void Opc_fdcb_68(); - void Opc_fdcb_69(); - void Opc_fdcb_6a(); - void Opc_fdcb_6b(); - void Opc_fdcb_6c(); - void Opc_fdcb_6d(); - void Opc_fdcb_6e(); - void Opc_fdcb_6f(); - void Opc_fdcb_70(); - void Opc_fdcb_71(); - void Opc_fdcb_72(); - void Opc_fdcb_73(); - void Opc_fdcb_74(); - void Opc_fdcb_75(); - void Opc_fdcb_76(); - void Opc_fdcb_77(); - void Opc_fdcb_78(); - void Opc_fdcb_79(); - void Opc_fdcb_7a(); - void Opc_fdcb_7b(); - void Opc_fdcb_7c(); - void Opc_fdcb_7d(); - void Opc_fdcb_7e(); - void Opc_fdcb_7f(); - void Opc_fdcb_80(); - void Opc_fdcb_81(); - void Opc_fdcb_82(); - void Opc_fdcb_83(); - void Opc_fdcb_84(); - void Opc_fdcb_85(); - void Opc_fdcb_86(); - void Opc_fdcb_87(); - void Opc_fdcb_88(); - void Opc_fdcb_89(); - void Opc_fdcb_8a(); - void Opc_fdcb_8b(); - void Opc_fdcb_8c(); - void Opc_fdcb_8d(); - void Opc_fdcb_8e(); - void Opc_fdcb_8f(); - void Opc_fdcb_90(); - void Opc_fdcb_91(); - void Opc_fdcb_92(); - void Opc_fdcb_93(); - void Opc_fdcb_94(); - void Opc_fdcb_95(); - void Opc_fdcb_96(); - void Opc_fdcb_97(); - void Opc_fdcb_98(); - void Opc_fdcb_99(); - void Opc_fdcb_9a(); - void Opc_fdcb_9b(); - void Opc_fdcb_9c(); - void Opc_fdcb_9d(); - void Opc_fdcb_9e(); - void Opc_fdcb_9f(); - void Opc_fdcb_a0(); - void Opc_fdcb_a1(); - void Opc_fdcb_a2(); - void Opc_fdcb_a3(); - void Opc_fdcb_a4(); - void Opc_fdcb_a5(); - void Opc_fdcb_a6(); - void Opc_fdcb_a7(); - void Opc_fdcb_a8(); - void Opc_fdcb_a9(); - void Opc_fdcb_aa(); - void Opc_fdcb_ab(); - void Opc_fdcb_ac(); - void Opc_fdcb_ad(); - void Opc_fdcb_ae(); - void Opc_fdcb_af(); - void Opc_fdcb_b0(); - void Opc_fdcb_b1(); - void Opc_fdcb_b2(); - void Opc_fdcb_b3(); - void Opc_fdcb_b4(); - void Opc_fdcb_b5(); - void Opc_fdcb_b6(); - void Opc_fdcb_b7(); - void Opc_fdcb_b8(); - void Opc_fdcb_b9(); - void Opc_fdcb_ba(); - void Opc_fdcb_bb(); - void Opc_fdcb_bc(); - void Opc_fdcb_bd(); - void Opc_fdcb_be(); - void Opc_fdcb_bf(); - void Opc_fdcb_c0(); - void Opc_fdcb_c1(); - void Opc_fdcb_c2(); - void Opc_fdcb_c3(); - void Opc_fdcb_c4(); - void Opc_fdcb_c5(); - void Opc_fdcb_c6(); - void Opc_fdcb_c7(); - void Opc_fdcb_c8(); - void Opc_fdcb_c9(); - void Opc_fdcb_ca(); - void Opc_fdcb_cb(); - void Opc_fdcb_cc(); - void Opc_fdcb_cd(); - void Opc_fdcb_ce(); - void Opc_fdcb_cf(); - void Opc_fdcb_d0(); - void Opc_fdcb_d1(); - void Opc_fdcb_d2(); - void Opc_fdcb_d3(); - void Opc_fdcb_d4(); - void Opc_fdcb_d5(); - void Opc_fdcb_d6(); - void Opc_fdcb_d7(); - void Opc_fdcb_d8(); - void Opc_fdcb_d9(); - void Opc_fdcb_da(); - void Opc_fdcb_db(); - void Opc_fdcb_dc(); - void Opc_fdcb_dd(); - void Opc_fdcb_de(); - void Opc_fdcb_df(); - void Opc_fdcb_e0(); - void Opc_fdcb_e1(); - void Opc_fdcb_e2(); - void Opc_fdcb_e3(); - void Opc_fdcb_e4(); - void Opc_fdcb_e5(); - void Opc_fdcb_e6(); - void Opc_fdcb_e7(); - void Opc_fdcb_e8(); - void Opc_fdcb_e9(); - void Opc_fdcb_ea(); - void Opc_fdcb_eb(); - void Opc_fdcb_ec(); - void Opc_fdcb_ed(); - void Opc_fdcb_ee(); - void Opc_fdcb_ef(); - void Opc_fdcb_f0(); - void Opc_fdcb_f1(); - void Opc_fdcb_f2(); - void Opc_fdcb_f3(); - void Opc_fdcb_f4(); - void Opc_fdcb_f5(); - void Opc_fdcb_f6(); - void Opc_fdcb_f7(); - void Opc_fdcb_f8(); - void Opc_fdcb_f9(); - void Opc_fdcb_fa(); - void Opc_fdcb_fb(); - void Opc_fdcb_fc(); - void Opc_fdcb_fd(); - void Opc_fdcb_fe(); - void Opc_fdcb_ff(); - - /* Pre computed variables. */ - static u8 bitval[8]; - static u8 PF_SF_ZF_[256]; - static u8 PF_[256]; - - /* Jump tables. */ - typedef void (Z80::* Opc_handler)(); - static Opc_handler Opc_std[256]; - static Opc_handler Opc_cbxx[256]; - static Opc_handler Opc_ddxx[256]; - static Opc_handler Opc_ddcb[256]; - static Opc_handler Opc_edxx[256]; - static Opc_handler Opc_fdxx[256]; - static Opc_handler Opc_fdcb[256]; -}; - - -#endif +#endif diff -Nru osmose-0.8.5b/debian/changelog osmose-0.9.1/debian/changelog --- osmose-0.8.5b/debian/changelog 2017-03-09 02:23:25.000000000 +0000 +++ osmose-0.9.1/debian/changelog 2017-03-09 02:23:25.000000000 +0000 @@ -1,4 +1,11 @@ -osmose (0.8.5b-0ubuntu1~ppa2) jaunty; urgency=low +osmose (0.9.1-0ubuntu1~ppa1) karmic; urgency=low + + * New upstream release. + * Dropped gcc4.3_fix.patch + + -- Khashayar Naderehvandi Sun, 01 Nov 2009 18:27:49 +0100 + +osmose (0.8.5b-0ubuntu1~ppa2) karmic; urgency=low * Added zlib1g-dev to build dependencies * Tweaked the man page a little diff -Nru osmose-0.8.5b/debian/patches/gcc4.3_fix.patch osmose-0.9.1/debian/patches/gcc4.3_fix.patch --- osmose-0.8.5b/debian/patches/gcc4.3_fix.patch 2017-03-09 02:23:25.000000000 +0000 +++ osmose-0.9.1/debian/patches/gcc4.3_fix.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -diff -Naur osmose-0.8.2/MemoryMapper.cpp osmose-0.8.2-patched/MemoryMapper.cpp ---- osmose-0.8.2/MemoryMapper.cpp 2006-11-27 18:56:30.000000000 +0100 -+++ osmose-0.8.2-patched/MemoryMapper.cpp 2009-01-04 20:50:51.000000000 +0100 -@@ -16,6 +16,8 @@ - #include "Options.h" - #include "RomSpecificOption.h" - #include -+#include -+#include - - extern Options opt; - -diff -Naur osmose-0.8.2/Options.cpp osmose-0.8.2-patched/Options.cpp ---- osmose-0.8.2/Options.cpp 2006-11-24 11:35:30.000000000 +0100 -+++ osmose-0.8.2-patched/Options.cpp 2009-01-04 20:55:07.000000000 +0100 -@@ -14,6 +14,7 @@ - *****************************************************************************/ - #include "Options.h" - #include "MemoryMapper.h" -+#include - - void Options::reset() - { -diff -Naur osmose-0.8.2/PrecisionTimer.cpp osmose-0.8.2-patched/PrecisionTimer.cpp ---- osmose-0.8.2/PrecisionTimer.cpp 2006-11-06 12:08:38.000000000 +0100 -+++ osmose-0.8.2-patched/PrecisionTimer.cpp 2009-01-04 20:53:47.000000000 +0100 -@@ -12,6 +12,7 @@ - * URL: http://bcz.emu-france.com/ - *****************************************************************************/ - #include "PrecisionTimer.h" -+#include - - #define rdtsc(val) __asm__ __volatile__ ("rdtsc" : "=A" (val)) - -diff -Naur osmose-0.8.2/WaveWriter.cpp osmose-0.8.2-patched/WaveWriter.cpp ---- osmose-0.8.2/WaveWriter.cpp 2006-11-06 12:08:38.000000000 +0100 -+++ osmose-0.8.2-patched/WaveWriter.cpp 2009-01-04 20:53:02.000000000 +0100 -@@ -13,6 +13,7 @@ - * URL: http://bcz.emu-france.com/ - *****************************************************************************/ - #include "WaveWriter.h" -+#include - - /*----------------------------------------------------------------------*/ - /* Constructor: Initialise structures ChunkFormat, Data Format, and */ diff -Nru osmose-0.8.5b/Definitions.h osmose-0.9.1/Definitions.h --- osmose-0.8.5b/Definitions.h 2007-06-08 09:01:58.000000000 +0000 +++ osmose-0.9.1/Definitions.h 2009-10-31 18:32:59.000000000 +0000 @@ -16,7 +16,7 @@ #define DELAY_BETWEEN_FRAME 50 /* SDL Sound buffer size for samples. */ -#define SAMPLE_SIZE 512 // Sample duration is 23ms +#define SAMPLE_SIZE 1024 // Sample duration is 23ms /**/ #define SND_TOGGLE 0.4026717557251908 // rest of 367.5/262. diff -Nru osmose-0.8.5b/FIFOSoundBuffer.h osmose-0.9.1/FIFOSoundBuffer.h --- osmose-0.8.5b/FIFOSoundBuffer.h 2006-11-06 11:08:38.000000000 +0000 +++ osmose-0.9.1/FIFOSoundBuffer.h 2009-10-29 19:25:59.000000000 +0000 @@ -17,7 +17,7 @@ class FIFOSoundBuffer { -public: +public: /* Constructor. */ FIFOSoundBuffer(u32 size); diff -Nru osmose-0.8.5b/main.cpp osmose-0.9.1/main.cpp --- osmose-0.8.5b/main.cpp 2009-01-11 16:49:46.000000000 +0000 +++ osmose-0.9.1/main.cpp 2009-10-24 17:38:58.000000000 +0000 @@ -34,6 +34,7 @@ #include "OsmoseCore.h" #include "Options.h" #include "Version.h" +#include "Definitions.h" using namespace std; @@ -42,9 +43,11 @@ void usage(); int parseCommandLine(int a, char *rv[]); void splashText(); +unsigned int timer_callback(unsigned int i, void *p); Options opt; // SMS Machine related options. EmulatorOptions emu_opt; // Emulator related options. +SDL_sem *semaphore; // Semaphore used for FPS synchronisation. /*--------------------------------------------------------------------*/ /* This is the main method of osmose. It check args number, correct */ @@ -53,7 +56,15 @@ int main(int argc,char *argv[]) { int ret; - + unsigned int frame = 0; + bool quit = false; + SDL_Event event; + SDL_TimerID t_id; // SDL Timer used for 60hz synchro. + + unsigned int start_time; + unsigned int stop_time; + static char fps_string[16]; + // Reset default options. emu_opt.reset(); opt.reset(); @@ -75,13 +86,81 @@ if (ret) { OsmoseCore core(argv[ret]); - core.run(); - } + semaphore = SDL_CreateSemaphore(0); + t_id = SDL_AddTimer(DELAY_BETWEEN_FRAME, timer_callback, NULL); + cout << "Starting emulation." << endl; + + start_time = SDL_GetTicks(); + + float on_fly_start = start_time; + float on_fly_stop; + SDL_WM_SetCaption(__OSMOSE_VERSION__,__OSMOSE_VERSION__); // Window title, Iconified widows title */ + + //TW->ADDTEXT(__OSMOSE_VERSION__,120); + while(!quit) + { + if (frame % 3 == 0) + { + SDL_SemWait(semaphore); + } + /* Handle SDL Events */ + while( SDL_PollEvent( &event ) ) + { + if ((event.type == SDL_KEYDOWN) && ( event.key.keysym.sym == SDLK_ESCAPE)) quit = true; + if (event.type == SDL_QUIT) quit = true; + if (event.type == SDL_VIDEORESIZE) core.Reshape(event.resize.w,event.resize.h); + else core.handleSDLKeyboardEvent(event); + } + core.run_frame(); + frame++; + + if (emu_opt.display_fps == true) + { + if ((frame & 63) == 0) + { + on_fly_stop = SDL_GetTicks(); + float instant_fps = ( 1000.0 / (float)((on_fly_stop - on_fly_start) / 64.0)); + sprintf(fps_string, "%.2f fps", instant_fps); + SDL_WM_SetCaption(fps_string, fps_string); + on_fly_start = on_fly_stop; + } + } + } + + stop_time = SDL_GetTicks(); + + SDL_CloseAudio(); + core.save_bbr(); + //// WE MAY BE RECORDING SOUND WHEN LEAVING EMULATION. IF IT'S THE CASE, CLOSE SOUND_SHOT FILE. + //IF (SOUND_SHOT_TOGGLE == TRUE && EMU_OPT.SOUND == TRUE) + //{ + //WAVW->CLOSE(); + //} + SDL_Quit(); + + // Now show statistics: + float emu_time = (float)((float)(stop_time - start_time) / 1000.0); + float a_fps; + + if (emu_time > 0) + { + a_fps = frame / emu_time; + } + else + { + a_fps = 0; + } + + cout << "Total rendered frames : " << frame << endl; + cout << "Total emulation time : " << emu_time << " seconds." << endl; + cout << "Average frame per second : " << a_fps << " frames per second." < +#include +#include extern Options opt; @@ -23,7 +25,7 @@ /* Class constructor. It immediatly load a given rom, and updates */ /* Memory mapper variables. */ /*--------------------------------------------------------------------*/ -MemoryMapper::MemoryMapper(const char *rom_file, const char *uhd) +MemoryMapper::MemoryMapper(const char *rom_file, const char *userHomeDirectory) { save_bbr = false; string n = string(rom_file); @@ -119,7 +121,7 @@ // Are there any battery backed memory save ? #ifdef __USE_UNIX98 - sprintf(full_name,"./osmose_files/bbr/%s%s", rom_name.c_str(),".bbr"); + sprintf(full_name,"%sbbr/%s%s", userHomeDirectory, rom_name.c_str(),".bbr"); #endif #ifdef __WIN32 sprintf(full_name,".\\bbr\\%s.bbr", rom_name.c_str()); @@ -172,30 +174,69 @@ // Init Read map and Write map. read_map[0] = &cartridge[0x0000]; // 0x0000-0x1FFF + rd_area_type[0] = Cartridge; + block_in_rd_area[0] = 0; + read_map[1] = &cartridge[0x2000]; // 0x2000-0x3FFF + rd_area_type[1] = Cartridge; + block_in_rd_area[1] = 1; read_map[2] = &cartridge[0x4000]; // 0x4000-0x5FFF + rd_area_type[2] = Cartridge; + block_in_rd_area[2] = 2; + read_map[3] = &cartridge[0x6000]; // 0x6000-0x7FFF + rd_area_type[3] = Cartridge; + block_in_rd_area[3] = 3; read_map[4] = &cartridge[0x8000]; // 0x8000-0x9FFF + rd_area_type[4] = Cartridge; + block_in_rd_area[4] = 4; + read_map[5] = &cartridge[0xA000]; // 0xA000-0xBFFF + rd_area_type[5] = Cartridge; + block_in_rd_area[5] = 5; read_map[6] = &ram[0]; // 0xC000-0xDFFF + rd_area_type[6] = Ram; + block_in_rd_area[6] = 0; + read_map[7] = &ram[0]; // 0xE000-0xFFFF mirror of 0xC000-0xDFFF - + rd_area_type[7] = Ram; + block_in_rd_area[7] = 0; write_map[0] = &null_rom[0]; // 0x0000-0x1FFF + wr_area_type[0] = Null; + block_in_wr_area[0] = 0; + write_map[1] = &null_rom[0]; // 0x2000-0x3FFF - + wr_area_type[1] = Null; + block_in_wr_area[1] = 0; + write_map[2] = &null_rom[0]; // 0x4000-0x5FFF + wr_area_type[2] = Null; + block_in_wr_area[2] = 0; + write_map[3] = &null_rom[0]; // 0x6000-0x7FFF - + wr_area_type[3] = Null; + block_in_wr_area[3] = 0; + write_map[4] = &null_rom[0]; // 0x8000-0x9FFF + wr_area_type[4] = Null; + block_in_wr_area[4] = 0; + write_map[5] = &null_rom[0]; // 0xA000-0xBFFF - + wr_area_type[5] = Null; + block_in_wr_area[5] = 0; + write_map[6] = &ram[0]; // 0xC000-0xDFFF + wr_area_type[6] = Ram; + block_in_wr_area[6] = 0; + write_map[7] = &ram[0]; // 0xE000-0xFFFF mirror of 0xC000-0xDFFF - + wr_area_type[7] = Ram; + block_in_wr_area[7] = 0; + // Init pagin registers From FFFC-FFFF. paging_regs[0] = 0; paging_regs[1] = 0; @@ -345,7 +386,7 @@ /*------------------------------------------------------------*/ /* This method handle every write operations done by the CPU */ -/* accordingly to codemaster memory mapper. */ +/* accordingly to korean memory mapper. */ /* It handles bank switching, RAM/ROM writes. */ /* write at 0xA000 changes rom banking page 2. */ /* */ @@ -364,10 +405,22 @@ /* Keep copy of 0xA000 paging reg, swap banks.*/ paging_regs[0] = value; + read_map[4] = &cartridge[(page<<14)]; + rd_area_type[4] = Cartridge; + block_in_rd_area[4] = page * 2; + read_map[5] = &cartridge[(page<<14)+0x2000]; + rd_area_type[5] = Cartridge; + block_in_rd_area[5] = page * 2 + 1; + write_map[4] = null_rom; + wr_area_type[4] = Null; + block_in_wr_area[4] = 0; + write_map[5] = null_rom; + wr_area_type[5] = Null; + block_in_wr_area[5] = 0; } } @@ -408,24 +461,49 @@ switch(reg) { // 0xFFFC is written. - case 0: - if(value & 8) // If true, An additionnal 16 Ko ram is mapped at 0x8000-BFFF + case 0: + if(value & 8) // If true, An additionnal 32 Ko ram is mapped at 0x8000-BFFF { // If value & bit 4 is true, we map second 16 Bank. // else, it's the first. save_bbr = true; // Save flag for BBR. + read_map[4] = &sram[(value & 4) ? 0x4000 : 0x0000]; + rd_area_type[4] = SRam; + block_in_rd_area[4] = (value & 4) ? 2 : 0; + read_map[5] = &sram[(value & 4) ? 0x6000 : 0x2000]; + rd_area_type[5] = SRam; + block_in_rd_area[5] = (value & 4) ? 3 : 1; + write_map[4] = &sram[(value & 4) ? 0x4000 : 0x0000]; + wr_area_type[4] = SRam; + block_in_wr_area[4] = (value & 4) ? 2 : 0; + write_map[5] = &sram[(value & 4) ? 0x6000 : 0x2000]; + wr_area_type[5] = SRam; + block_in_wr_area[5] = (value & 4) ? 3 : 1; } else { // We are mapping rom from 0xFFFF register. - read_map[4] = &cartridge[((paging_regs[3] % bank16Ko_nbr) << 14) + 0x0000]; - read_map[5] = &cartridge[((paging_regs[3] % bank16Ko_nbr) << 14) + 0x2000]; + int bloc = paging_regs[3] % bank16Ko_nbr; + + read_map[4] = &cartridge[(bloc << 14) + 0x0000]; + rd_area_type[4] = Cartridge; + block_in_rd_area[4] = bloc *2; + + read_map[5] = &cartridge[(bloc << 14) + 0x2000]; + rd_area_type[5] = Cartridge; + block_in_rd_area[5] = bloc *2 + 1; + write_map[4] = null_rom; + wr_area_type[4] = Null; + block_in_wr_area[4] = 0; + write_map[5] = null_rom; + wr_area_type[5] = Null; + block_in_wr_area[5] = 0; } break; @@ -435,27 +513,45 @@ cout << "Mapping page0 on rom bank " << (unsigned int)(page) << endl; #endif read_map[0] = &cartridge[(page<<14)]; + rd_area_type[0] = Cartridge; + block_in_rd_area[0] = page *2; + + read_map[1] = &cartridge[(page<<14)+0x2000]; + rd_area_type[1] = Cartridge; + block_in_rd_area[1] = page *2 +1; break; // 0xFFFE is written. case 2: #ifdef P_VERBOSE cout << "Mapping page1 on rom bank " << (unsigned int)(page) << endl; -#endif +#endif read_map[2] = &cartridge[(page<<14)]; + rd_area_type[2] = Cartridge; + block_in_rd_area[2] = page *2; + + read_map[3] = &cartridge[(page<<14)+0x2000]; + rd_area_type[3] = Cartridge; + block_in_rd_area[3] = page *2 +1; break; // 0xFFFF is written. case 3: + if(!(paging_regs[0] & 0x08)) { #ifdef P_VERBOSE cout << "Mapping page2 on rom bank " << (unsigned int)(page) << endl; #endif read_map[4] = &cartridge[(page<<14)]; + rd_area_type[4] = Cartridge; + block_in_rd_area[4] = page *2; + read_map[5] = &cartridge[(page<<14)+0x2000]; + rd_area_type[5] = Cartridge; + block_in_rd_area[5] = page *2 +1; } break; } @@ -473,9 +569,20 @@ /* Keep a copy of 0x8000, swap banks. */ paging_regs[0] = value; read_map[4] = &cartridge[(page<<14)]; + rd_area_type[4] = Cartridge; + block_in_rd_area[4] = page *2; + read_map[5] = &cartridge[(page<<14)+0x2000]; + rd_area_type[5] = Cartridge; + block_in_rd_area[5] = page *2 +1; + write_map[4] = null_rom; + wr_area_type[4] = Null; + block_in_wr_area[4] = 0; + write_map[5] = null_rom; + wr_area_type[5] = Null; + block_in_wr_area[5] = 0; } /*------------------------------------------------------------*/ @@ -876,6 +983,20 @@ mss.mapperType = mapperType; for (int i=0; i < 4; i++) mss.paging_regs[i] = paging_regs[i]; + // Save area types and bloc of the memory mapping for reading. + for (int i=0; i < 8; i++) mss.rd_area_type[i] = rd_area_type[i]; + for (int i=0; i < 8; i++) mss.block_in_rd_area[i] = block_in_rd_area[i]; + + // Save area types and bloc of the memory mapping for writing. + for (int i=0; i < 8; i++) mss.wr_area_type[i] = wr_area_type[i]; + for (int i=0; i < 8; i++) mss.block_in_wr_area[i] = block_in_wr_area[i]; + +// cout << "Saved Mapper Type =" << (unsigned int)mapperType << endl; +// cout << "Saved paging_regs[0] =" << (unsigned int)paging_regs[0] << endl; +// cout << "Saved paging_regs[1] =" << (unsigned int)paging_regs[1] << endl; +// cout << "Saved paging_regs[2] =" << (unsigned int)paging_regs[2] << endl; +// cout << "Saved paging_regs[3] =" << (unsigned int)paging_regs[3] << endl; + /* Save 8Ko Ram from 0xC000-0xDFFF. */ ofs.write((char *)&ram[0], 0x2000); if (!ofs.good()) return false; @@ -893,40 +1014,95 @@ bool MemoryMapper::loadState( ifstream &ifs) { MemoryMapperSaveState mss; - + /* Load 8Ko Ram from 0xC000-0xDFFF. */ ifs.read((char *)&ram[0], 0x2000); if (!ifs.good()) return false; /* Load 32Ko Battery Backed Memory. */ - ifs.read((char *)&sram[0], 0x8000); + ifs.read((char *)&sram[0], 0x8000); if (!ifs.good()) return false; /* Load Paging Registers. */ - ifs.read((char *)&mss, sizeof(mss)); + ifs.read((char *)&mss, sizeof(mss)); if (!ifs.good()) return false; mapperType = mss.mapperType; for (int i=0; i < 4; i++) paging_regs[i] = mss.paging_regs[i]; - /* Force mapping registers to regenerate bank swapping. */ - switch (mapperType) - { - case SegaMapper: - wr8(0xFFFC, paging_regs[0]); - wr8(0xFFFD, paging_regs[1]); - wr8(0xFFFE, paging_regs[2]); - wr8(0xFFFF, paging_regs[3]); - break; - - case CodemasterMapper: - wr8(0x8000, paging_regs[0]); - break; + // Load area types and bloc of the memory mapping for reading. + for (int i=0; i < 8; i++) rd_area_type[i] = mss.rd_area_type[i]; + for (int i=0; i < 8; i++) block_in_rd_area[i] = mss.block_in_rd_area[i]; + + // Load area types and bloc of the memory mapping for writing. + for (int i=0; i < 8; i++) wr_area_type[i] = mss.wr_area_type[i]; + for (int i=0; i < 8; i++) block_in_wr_area[i] = mss.block_in_wr_area[i]; - case KoreanMapper: - wr8(0xA000, paging_regs[0]); - break; - } + // Now rebuild read_maps pointers. + for (int i=0; i < 8; i++) + { + unsigned char *base_ptr = NULL; + switch(rd_area_type[i]) + { + case Cartridge: + base_ptr = cartridge; + break; + + case Ram: + base_ptr = ram; + break; + + case SRam: + base_ptr = sram; + break; + + case Null: + // Everything is readable ! + cout << "Warning : Wrong area_type for read_map !" << endl;; + break; + + default: + cout << "Warning : Unknown area_type for read_map !" << endl; + break; + } + read_map[i] = base_ptr + (block_in_rd_area[i] * 0x2000); + } + + // Now rebuild write_maps pointers. + for (int i=0; i < 8; i++) + { + unsigned char *base_ptr = NULL; + switch(wr_area_type[i]) + { + case Cartridge: + // Cartridge are read only ! + cout << "Warning : Wrong area_type for write_map !" << endl; + break; + + case Ram: + base_ptr = ram; + break; + + case SRam: + base_ptr = sram; + break; + + case Null: + base_ptr = null_rom; + break; + + default: + cout << "Warning : Unknown area_type for write_map !" << endl; + break; + } + write_map[i] = base_ptr + (block_in_wr_area[i] * 0x2000); + } + +// cout << "Loaded Mapper Type =" << (unsigned int)mapperType << endl; +// cout << "Loaded paging_regs[0] =" << (unsigned int)paging_regs[0] << endl; +// cout << "Loaded paging_regs[1] =" << (unsigned int)paging_regs[1] << endl; +// cout << "Loaded paging_regs[2] =" << (unsigned int)paging_regs[2] << endl; +// cout << "Loaded paging_regs[3] =" << (unsigned int)paging_regs[3] << endl; return true; } diff -Nru osmose-0.8.5b/MemoryMapper.h osmose-0.9.1/MemoryMapper.h --- osmose-0.8.5b/MemoryMapper.h 2006-11-27 17:52:42.000000000 +0000 +++ osmose-0.9.1/MemoryMapper.h 2009-10-25 14:54:31.000000000 +0000 @@ -1,98 +1,129 @@ -/***************************************************************************** -* -* File: MemoryMapper.h -* -* Project: Osmose emulator. -* -* Description: This class will handle emulator read/write and bank -* switching during emulation. -* -* Author: Vedder Bruno -* Date: 02/10/2004, 18h00 -* -* URL: http://bcz.emu-france.com/ -*****************************************************************************/ -#ifndef MEMORY_MAPPER_H -#define MEMORY_MAPPER_H -#include -#include -#include -#include "unzip/unzip.h" -#include "Options.h" +/***************************************************************************** +* +* File: MemoryMapper.h +* +* Project: Osmose emulator. +* +* Description: This class will handle emulator read/write and bank +* switching during emulation. +* +* Author: Vedder Bruno +* Date: 02/10/2004, 18h00 +* +* URL: http://bcz.emu-france.com/ +*****************************************************************************/ +#ifndef MEMORY_MAPPER_H +#define MEMORY_MAPPER_H +#include +#include +#include +#include "unzip/unzip.h" +#include "Options.h" #include "Definitions.h" #include "DebugEventThrower.h" #include "SaveState.h" - -extern Options opt; - -using namespace std; - + +extern Options opt; + +using namespace std; + enum Mapper { - SegaMapper, + SegaMapper =0, CodemasterMapper, KoreanMapper }; -typedef struct +/* Enumeration of adressing space areas types that could be read/written. */ +enum Area_type { + Cartridge, + Ram, + SRam, + Null // Rom write attemps are redirected to null. +}; - unsigned char paging_regs[4]; +/*---------------------------------------------------------------------------*/ +/* Structure to save Memory mapper state. */ +/* It's necessary to save paging registers, but it's Also required to save */ +/* the bank mapping, instead of doing fake wr8 on adress 0xFFFC-0xFFFF to */ +/* get the correct mapping (order dependant for FFFC). As RAM pointer are */ +/* not identical from different process, we save the area type of memory */ +/* plus the bloc (8Ko) number inside the area. */ +/* e.g: read_map[0] pointing to cartridge 0x2000 will be saved as : */ +/* rd_area_type = Cartridge, block_in_rd_area = 1 */ +/*---------------------------------------------------------------------------*/ +typedef struct +{ + unsigned char paging_regs[4]; // Paging registers. + Area_type rd_area_type[8]; + unsigned int block_in_rd_area[8]; + Area_type wr_area_type[8]; + unsigned int block_in_wr_area[8]; Mapper mapperType; } MemoryMapperSaveState; - -class MemoryMapper : public DebugEventThrower, public ImplementsSaveState -{ -public: - - MemoryMapper(const char *rom_file, const char *dud); - void save_battery_backed_memory(string f); - void reset(); - void dump(unsigned char bnk_nbr); - void dump_page(unsigned char page); - void dump_mem(unsigned add, unsigned short nb_line); - void dump_smem(unsigned add, unsigned short nb_line); - void wr8(unsigned address, unsigned char value); - unsigned char rd8(unsigned address); - unsigned char getRSR(); - unsigned char getFFFD(); - unsigned char getFFFE(); - unsigned char getFFFF(); - string getROMName(); + + + +class MemoryMapper : public DebugEventThrower, public ImplementsSaveState +{ +public: + + MemoryMapper(const char *rom_file, const char *dud); + void save_battery_backed_memory(string f); + void reset(); + void dump(unsigned char bnk_nbr); + void dump_page(unsigned char page); + void dump_mem(unsigned add, unsigned short nb_line); + void dump_smem(unsigned add, unsigned short nb_line); + void wr8(unsigned address, unsigned char value); + unsigned char rd8(unsigned address); + unsigned char getRSR(); + unsigned char getFFFD(); + unsigned char getFFFE(); + unsigned char getFFFF(); + string getROMName(); void setMapperType (Mapper map); /* Implemetntation of ImplementsSaveState. */ bool saveState( ofstream &ofs); bool loadState( ifstream &ifs); - -private: - bool have_bbr; // Battery backed ram flag presence - string rom_name; // Rom name without extension. - unsigned rom_size; // ROM size in bytes - unsigned bank_nbr; // How much 8k block in our rom - unsigned bank16Ko_nbr; // How much 16k bank in our rom - unsigned char *null_rom; // Ptr on Garbage (use for ROM writes). - unsigned char *sram; // Ptr on Optionnal SRAM - unsigned char *ram; // Central RAM - unsigned char *cartridge; // Ptr on ROM cartridge. - unsigned char paging_regs[4]; // Paging registers. - unsigned char *read_map[8]; // 8ko bank ptr for CPU reads. - unsigned char *write_map[8]; // 8ko bank ptr for CPU reads. - bool save_bbr; // Flag for Battery Backed Memory. +private: + + bool have_bbr; // Battery backed ram flag presence + string rom_name; // Rom name without extension. + unsigned rom_size; // ROM size in bytes + unsigned bank_nbr; // How much 8k block in our rom + unsigned bank16Ko_nbr; // How much 16k bank in our rom + unsigned char *null_rom; // Ptr on Garbage (use for ROM writes). + unsigned char *sram; // Ptr on Optionnal SRAM + unsigned char *ram; // Central RAM + unsigned char *cartridge; // Ptr on ROM cartridge. + unsigned char paging_regs[4]; // Paging registers. + + unsigned char *write_map[8]; // 8ko bank ptr for CPU writes. + Area_type wr_area_type[8]; // actual wr_map area type. + unsigned int block_in_wr_area[8]; // 8ko block inside the area. + + unsigned char *read_map[8]; // 8ko bank ptr for CPU reads. + Area_type rd_area_type[8]; // actual read_map area type. + unsigned int block_in_rd_area[8]; // 8ko block inside the area. + + bool save_bbr; // Flag for Battery Backed Memory. Mapper mapperType; - - unsigned int LoadZippedRom(const char *rom_file); - unsigned int LoadSMSRom(const char *rom_file); + + unsigned int LoadZippedRom(const char *rom_file); + unsigned int LoadSMSRom(const char *rom_file); void DumpMappingPtr(); void wr8_sega_mapper(unsigned int add, unsigned char data); - void wr8_codemaster_mapper(unsigned int add, unsigned char data); + void wr8_codemaster_mapper(unsigned int add, unsigned char data); void wr8_korean_mapper(unsigned int add, unsigned char data); - void write_standard_paging_reg(int reg, unsigned char value); - void write_codemaster_paging_reg(unsigned char value); + void write_standard_paging_reg(int reg, unsigned char value); + void write_codemaster_paging_reg(unsigned char value); void DisplayROMSize(); unsigned int getCRC32(unsigned char *buffer, unsigned int len); - void (MemoryMapper::*wr8_method)(unsigned int add, unsigned char data); -}; -#endif + void (MemoryMapper::*wr8_method)(unsigned int add, unsigned char data); +}; +#endif diff -Nru osmose-0.8.5b/Options.cpp osmose-0.9.1/Options.cpp --- osmose-0.8.5b/Options.cpp 2009-01-11 16:30:40.000000000 +0000 +++ osmose-0.9.1/Options.cpp 2009-01-18 08:52:03.000000000 +0000 @@ -14,6 +14,7 @@ *****************************************************************************/ #include "Options.h" #include "MemoryMapper.h" +#include void Options::reset() { diff -Nru osmose-0.8.5b/OsmoseConfiguration.cpp osmose-0.9.1/OsmoseConfiguration.cpp --- osmose-0.8.5b/OsmoseConfiguration.cpp 2009-01-15 15:09:22.000000000 +0000 +++ osmose-0.9.1/OsmoseConfiguration.cpp 2009-11-01 10:01:20.000000000 +0000 @@ -15,9 +15,10 @@ #include "OsmoseConfiguration.h" #ifdef __USE_UNIX98 -#include // For passwd structure -#include // For getlogin, ... -#include // For mkdir, chown, ... +#include // For passwd structure +#include // For getlogin, ... +#include // For mkdir, chown, ... +#include #endif #ifdef __WIN32 #include @@ -25,379 +26,370 @@ OsmoseConfiguration::OsmoseConfiguration(const char *filename) { - bool ret = false; - string default_filename; + bool ret = false; - // Try to load config from file. -#ifdef __USE_UNIX98 // Unices - passwd * password; - char * Temp = getlogin(); - - if ( Temp != NULL ) - { - password = getpwnam(Temp); - } - else - { - password = getpwuid(geteuid()); - } - - if ( password != NULL) - { - user_home_folder = password->pw_dir; - //User = password->pw_name; // Good to know - default_filename = user_home_folder + "/.osmose/osmose.ini"; - } -#endif - ret = loadConfigurationFromFile(filename); - if (ret != true) - { - // If unsuccessful, setup default configuration. - reset(); - } + // Try to load config from the given file. + ret = loadConfigurationFromFile(filename); + if (ret != true) + { + // If unsuccessful, setup default configuration. + reset(); + } } OsmoseConfiguration::OsmoseConfiguration() { - // Here we should attempt to read default configuration file first, - // And create one if there aren't. + // Here we should attempt to read default configuration file first, + // And create one if there isn't. + + // The folder where it will we be created, and where it will be read by default depends on the OS we are using. + // I'll give here the code to be used under Linux/Unix/BSD, and Windows... - // The folder where it will we be created, and where it will be read by default depends on the OS we are using. - // I'll give here the code to be used under Linux/Unix/BSD, and Windows... - string default_filename; #ifdef _WIN32 - default_filename = "osmose.ini"; + default_filename = "osmose.ini"; #endif + #ifdef __USE_UNIX98 // Unices - default_filename = "./osmose_files/osmose.ini"; + user_home_folder = string (getenv("HOME")); + user_home_folder = user_home_folder + "/.osmose/"; + default_filename = user_home_folder + "osmose.ini"; #endif - // Try to load config from file. - bool ret = false; - ret = loadConfigurationFromFile(default_filename.c_str()); - if (ret != true) - { - // If unsuccessful, setup default configuration. - // And don't forget to create a default config file... - reset(); + // Try to load config from file. + bool ret = false; - // Default config creation + ret = loadConfigurationFromFile(default_filename.c_str()); + if (ret != true) + { + // If unsuccessful, setup default configuration. + // And don't forget to create a default config file... + reset(); + + // Default config creation #ifdef __USE_UNIX98 // Unices. - // Create Osmose directory. - int md = 0; - md = mkdir( string("./osmose_files").c_str(), S_IRWXU | S_IRWXG | S_IXOTH); - if (md == -1) - { - cout << "Unable to create ./osmose_files/ directory." << endl; - } + // Create Osmose directory. + int md = 0; + string fullname = user_home_folder; + md = mkdir(fullname.c_str(), S_IRWXU | S_IRWXG | S_IXOTH); + if (md == -1) + { + cout << "Unable to create '" << fullname << "' directory." << endl; + } - // Create bbr subdirectory. - md = mkdir( string("./osmose_files/bbr").c_str(), S_IRWXU | S_IRWXG | S_IXOTH); - if (md == -1) - { - cout << "Unable to create bbr subdirectory." << endl; - } + // Create bbr subdirectory. + fullname = user_home_folder +"bbr"; + md = mkdir( fullname.c_str(), S_IRWXU | S_IRWXG | S_IXOTH); + if (md == -1) + { + cout << "Unable to create '" << fullname << "' directory." << endl; + } - // Create snd subdirectory. - md = mkdir( string("./osmose_files/snd").c_str(), S_IRWXU | S_IRWXG | S_IXOTH); - if (md == -1) - { - cout << "Unable to create snd subdirectory." << endl; - } + // Create snd subdirectory. + fullname = user_home_folder +"snd"; + md = mkdir( fullname.c_str(), S_IRWXU | S_IRWXG | S_IXOTH); + if (md == -1) + { + cout << "Unable to create '" << fullname << "' directory." << endl; + } - // Create screen subdirectory. - md = mkdir( string("./osmose_files/screen").c_str(), S_IRWXU | S_IRWXG | S_IXOTH); - if (md == -1) - { - cout << "Unable to create screen subdirectory." << endl; - } + // Create screen subdirectory. + fullname = user_home_folder +"screen"; + md = mkdir( fullname.c_str(), S_IRWXU | S_IRWXG | S_IXOTH); + if (md == -1) + { + cout << "Unable to create '" << fullname << "' directory." << endl; + } + + // Create tiles subdirectory. + fullname = user_home_folder +"tiles"; + md = mkdir( fullname.c_str(), S_IRWXU | S_IRWXG | S_IXOTH); + if (md == -1) + { + cout << "Unable to create '" << fullname << "' directory." << endl; + } + + // Create Save State subdirectory. + fullname = user_home_folder +"saves"; + md = mkdir( fullname.c_str(), S_IRWXU | S_IRWXG | S_IXOTH); + if (md == -1) + { + cout << "Unable to create '" << fullname << "' directory." << endl; + } - // Create tile subdirectory. - md = mkdir( string("./osmose_files/tiles").c_str(), S_IRWXU | S_IRWXG | S_IXOTH); - if (md == -1) - { - cout << "Unable to create tiles subdirectory." << endl; - } - - // Create Save State subdirectory. - md = mkdir( string("./osmose_files/saves").c_str(), S_IRWXU | S_IRWXG | S_IXOTH); - if (md == -1) - { - cout << "Unable to create saves subdirectory." << endl; - } - #endif // __USE_UNIX98 #ifdef __WIN32 - bool md = CreateDirectory(".\\screen", NULL); - if (!md){cout << "Unable to create screen subdirectory." << endl;} - md = CreateDirectory(".\\tiles", NULL); - if (!md){cout << "Unable to create tiles subdirectory." << endl;} - md = CreateDirectory(".\\snd", NULL); - if (!md){cout << "Unable to create snd subdirectory." << endl;} - md = CreateDirectory(".\\bbr", NULL); - if (!md){cout << "Unable to create bbr subdirectory." << endl;} - md = CreateDirectory(".\\saves", NULL); - if (!md){cout << "Unable to create saves subdirectory." << endl;} - + bool md = CreateDirectory(".\\screen", NULL); + if (!md){cout << "Unable to create screen subdirectory." << endl;} + md = CreateDirectory(".\\tiles", NULL); + if (!md){cout << "Unable to create tiles subdirectory." << endl;} + md = CreateDirectory(".\\snd", NULL); + if (!md){cout << "Unable to create snd subdirectory." << endl;} + md = CreateDirectory(".\\bbr", NULL); + if (!md){cout << "Unable to create bbr subdirectory." << endl;} + md = CreateDirectory(".\\saves", NULL); + if (!md){cout << "Unable to create saves subdirectory." << endl;} #endif - ofstream file(default_filename.c_str(), ios::out); - if (file.is_open() == false ) - { - cerr << "Unable to create '" << default_filename << "' init file. Default configuration loaded." << endl; - } - else // Default ini file creation - { - file << "#########################################################################\n"; - file << "#\n"; - file << "# This is an example of Osmose .ini file.\n"; - file << "# It can be use to modify osmose keyboard configuration.\n"; - file << "# Lines beginning with '#' are considered as comment and\n"; - file << "# will be ignored.\n"; - file << "#\n"; - file << "# For retrieving key correspondance osmose looks for these\n"; - file << "# tags:\n"; - file << "#\n"; - file << "# SCREENSHOT\n"; - file << "# SOUNDSHOT\n"; - file << "# QUIT\n"; - file << "# TILESHOT\n"; - file << "# DEBUGGER\n"; - file << "# PAUSE\n"; - file << "# PAD1_UP\n"; - file << "# PAD1_DOWN\n"; - file << "# PAD1_LEFT\n"; - file << "# PAD1_RIGHT\n"; - file << "# PAD1_BUTTON_A\n"; - file << "# PAD1_BUTTON_B\n"; - file << "# PAD2_UP\n"; - file << "# PAD2_DOWN\n"; - file << "# PAD2_LEFT\n"; - file << "# PAD2_RIGHT\n"; - file << "# PAD2_BUTTON_A\n"; - file << "# PAD2_BUTTON_B\n"; - file << "# GAMEGEAR_START\n"; - file << "#\n"; - file << "# If a tag is found, it looks for a valid key definition.\n"; - file << "# The list of valid keys are listed in comment at the end of\n"; - file << "# this file. All definition begins w ith'SDLK'.n \n"; - file << "# Note that missing tags will result in disabled key. You can\n"; - file << "# disallow screenshot in emulation by commenting the line with\n"; - file << "# SCREENSHOT tag.\n"; - file << "#\n"; - file << "#########################################################################\n\n"; - - file << "# Configuration Starts Here !\n\n"; - - file << "#\n"; - file << "# General emulation keys:\n"; - file << "#\n\n"; - - file << "SCREENSHOT = SDLK_F2\n"; - file << "SOUNDSHOT = SDLK_F1\n"; - file << "QUIT = SDLK_ESCAPE\n"; - file << "TILESHOT = SDLK_F3\n"; - - file << "DEBUGGER = SDLK_d\n"; - file << "PAUSE = SDLK_p\n\n"; - - file << "#\n"; - file << "# First Player PAD:\n"; - file << "#\n\n"; - - file << "PAD1_UP = SDLK_UP\n"; - file << "PAD1_DOWN = SDLK_DOWN\n"; - file << "PAD1_LEFT = SDLK_LEFT\n"; - file << "PAD1_RIGHT = SDLK_RIGHT\n"; - file << "PAD1_BUTTON_A = SDLK_LCTRL\n"; - file << "PAD1_BUTTON_B = SDLK_LALT\n\n"; - - file << "#\n"; - file << "# Second Player PAD:\n"; - file << "#\n\n"; - - file << "PAD2_UP = SDLK_KP5\n"; - file << "PAD2_DOWN = SDLK_KP2\n"; - file << "PAD2_LEFT = SDLK_KP1\n"; - file << "PAD2_RIGHT = SDLK_KP3\n"; - file << "PAD2_BUTTON_A = SDLK_n\n"; - file << "PAD2_BUTTON_B = SDLK_b\n\n"; - - file << "#\n"; - file << "# GAME GEAR Specific:\n"; - file << "#\n\n"; - file << "GAMEGEAR_START = SDLK_RETURN\n\n"; - - file << "# Configuration Ends Here !\n\n\n\n\n\n\n"; - - file << "#########################################################################\n"; - file << "#\n"; - file << "# You can remove this list, it's just provided to help user to\n"; - file << "# configure osmose emulator.\n"; - file << "#\n"; - file << "# Valid Key definitions:\n"; - file << "# ----------------------\n"; - file << "#\n"; - file << "# SDLK_BACKSPACE\n"; - file << "# SDLK_TAB\n"; - file << "# SDLK_CLEAR\n"; - file << "# SDLK_RETURN\n"; - file << "# SDLK_PAUSE\n"; - file << "# SDLK_ESCAPE\n"; - file << "# SDLK_SPACE\n"; - file << "# SDLK_EXCLAIM\n"; - file << "# SDLK_QUOTEDBL\n"; - file << "# SDLK_HASH\n"; - file << "# SDLK_DOLLAR\n"; - file << "# SDLK_AMPERSAND\n"; - file << "# SDLK_QUOTE\n"; - file << "# SDLK_LEFTPAREN\n"; - file << "# SDLK_RIGHTPAREN\n"; - file << "# SDLK_ASTERISK\n"; - file << "# SDLK_PLUS\n"; - file << "# SDLK_COMMA\n"; - file << "# SDLK_MINUS\n"; - file << "# SDLK_PERIOD\n"; - file << "# SDLK_SLASH\n"; - file << "# SDLK_0\n"; - file << "# SDLK_1\n"; - file << "# SDLK_2\n"; - file << "# SDLK_3\n"; - file << "# SDLK_4\n"; - file << "# SDLK_5\n"; - file << "# SDLK_6\n"; - file << "# SDLK_7\n"; - file << "# SDLK_8\n"; - file << "# SDLK_9\n"; - file << "# SDLK_COLON\n"; - file << "# SDLK_SEMICOLON\n"; - file << "# SDLK_LESS\n"; - file << "# SDLK_EQUALS\n"; - file << "# SDLK_GREATER\n"; - file << "# SDLK_QUESTION\n"; - file << "# SDLK_AT\n"; - file << "#\n"; - file << "# -Don't use uppercase letters\n"; - file << "#\n"; - file << "# SDLK_LEFTBRACKET\n"; - file << "# SDLK_BACKSLASH\n"; - file << "# SDLK_RIGHTBRACKET\n"; - file << "# SDLK_CARET\n"; - file << "# SDLK_UNDERSCORE\n"; - file << "# SDLK_BACKQUOTE\n"; - file << "# SDLK_a\n"; - file << "# SDLK_b\n"; - file << "# SDLK_c\n"; - file << "# SDLK_d\n"; - file << "# SDLK_e\n"; - file << "# SDLK_f\n"; - file << "# SDLK_g\n"; - file << "# SDLK_h\n"; - file << "# SDLK_i\n"; - file << "# SDLK_j\n"; - file << "# SDLK_k\n"; - file << "# SDLK_l\n"; - file << "# SDLK_m\n"; - file << "# SDLK_n\n"; - file << "# SDLK_o\n"; - file << "# SDLK_p\n"; - file << "# SDLK_q\n"; - file << "# SDLK_r\n"; - file << "# SDLK_s\n"; - file << "# SDLK_t\n"; - file << "# SDLK_u\n"; - file << "# SDLK_v\n"; - file << "# SDLK_w\n"; - file << "# SDLK_x\n"; - file << "# SDLK_y\n"; - file << "# SDLK_z\n"; - file << "# SDLK_DELETE\n"; - file << "#\n\n"; - - file << "# -Numeric keypad\n"; - file << "#\n"; - file << "# SDLK_KP0\n"; - file << "# SDLK_KP1\n"; - file << "# SDLK_KP2\n"; - file << "# SDLK_KP3\n"; - file << "# SDLK_KP4\n"; - file << "# SDLK_KP5\n"; - file << "# SDLK_KP6\n"; - file << "# SDLK_KP7\n"; - file << "# SDLK_KP8\n"; - file << "# SDLK_KP9\n"; - file << "# SDLK_KP_PERIOD\n"; - file << "# SDLK_KP_DIVIDE\n"; - file << "# SDLK_KP_MULTIPLY\n"; - file << "# SDLK_KP_MINUS\n"; - file << "# SDLK_KP_PLUS\n"; - file << "# SDLK_KP_ENTER\n"; - file << "# SDLK_KP_EQUALS\n"; - file << "#\n"; - file << "# -Arrows + Home/End p\n"; - file << "#\n"; - file << "# SDLK_UP\n"; - file << "# SDLK_DOWN\n"; - file << "# SDLK_RIGHT\n"; - file << "# SDLK_LEFT\n"; - file << "# SDLK_INSERT\n"; - file << "# SDLK_HOME\n"; - file << "# SDLK_END\n"; - file << "# SDLK_PAGEUP\n"; - file << "# SDLK_PAGEDOWN\n"; - file << "#\n"; - file << "# -Function keys\n"; - file << "#\n"; - file << "# SDLK_F1\n"; - file << "# SDLK_F2\n"; - file << "# SDLK_F3\n"; - file << "# SDLK_F4\n"; - file << "# SDLK_F5\n"; - file << "# SDLK_F6\n"; - file << "# SDLK_F7\n"; - file << "# SDLK_F8\n"; - file << "# SDLK_F9\n"; - file << "# SDLK_F10\n"; - file << "# SDLK_F11\n"; - file << "# SDLK_F12\n"; - file << "# SDLK_F13\n"; - file << "# SDLK_F14\n"; - file << "# SDLK_F15\n"; - file << "#\n"; - file << "# -Key state modifier\n"; - file << "#\n"; - file << "# SDLK_NUMLOCK\n"; - file << "# SDLK_CAPSLOCK\n"; - file << "# SDLK_SCROLLOCK\n"; - file << "# SDLK_RSHIFT\n"; - file << "# SDLK_LSHIFT\n"; - file << "# SDLK_RCTRL\n"; - file << "# SDLK_LCTRL\n"; - file << "# SDLK_RALT\n"; - file << "# SDLK_LALT\n"; - file << "# SDLK_RMETA\n"; - file << "# SDLK_LMETA\n"; - file << "# SDLK_LSUPER\n"; - file << "# SDLK_RSUPER\n"; - file << "# SDLK_COMPOSE\n"; - file << "#\n"; - file << "# -Miscellaneous functions\n"; - file << "#\n"; - file << "# SDLK_HELP\n"; - file << "# SDLK_PRINT\n"; - file << "# SDLK_SYSREQ\n"; - file << "# SDLK_BREAK\n"; - file << "# SDLK_MENU\n"; - file << "# SDLK_EURO\n"; - file << "# SDLK_UNDO\n"; - file << "#\n"; - file << "#########################################################################\n"; - - } // End of default ini file creation + ofstream file(default_filename.c_str(), ios::out); + if (file.is_open() == false ) + { + cerr << "Unable to create '" << default_filename << "' init file. Default configuration loaded." << endl; + } + else // Default ini file creation + { + file << "#########################################################################\n"; + file << "#\n"; + file << "# This is an example of Osmose .ini file.\n"; + file << "# It can be use to modify osmose keyboard configuration.\n"; + file << "# Lines beginning with '#' are considered as comment and\n"; + file << "# will be ignored.\n"; + file << "#\n"; + file << "# For retrieving key correspondance osmose looks for these\n"; + file << "# tags:\n"; + file << "#\n"; + file << "# SCREENSHOT\n"; + file << "# SOUNDSHOT\n"; + file << "# QUIT\n"; + file << "# TILESHOT\n"; + file << "# DEBUGGER\n"; + file << "# PAUSE\n"; + file << "# PAD1_UP\n"; + file << "# PAD1_DOWN\n"; + file << "# PAD1_LEFT\n"; + file << "# PAD1_RIGHT\n"; + file << "# PAD1_BUTTON_A\n"; + file << "# PAD1_BUTTON_B\n"; + file << "# PAD2_UP\n"; + file << "# PAD2_DOWN\n"; + file << "# PAD2_LEFT\n"; + file << "# PAD2_RIGHT\n"; + file << "# PAD2_BUTTON_A\n"; + file << "# PAD2_BUTTON_B\n"; + file << "# GAMEGEAR_START\n"; + file << "#\n"; + file << "# If a tag is found, it looks for a valid key definition.\n"; + file << "# The list of valid keys are listed in comment at the end of\n"; + file << "# this file. All definition begins w ith'SDLK'.n \n"; + file << "# Note that missing tags will result in disabled key. You can\n"; + file << "# disallow screenshot in emulation by commenting the line with\n"; + file << "# SCREENSHOT tag.\n"; + file << "#\n"; + file << "#########################################################################\n\n"; + + file << "# Configuration Starts Here !\n\n"; + + file << "#\n"; + file << "# General emulation keys:\n"; + file << "#\n\n"; + + file << "SCREENSHOT = SDLK_F2\n"; + file << "SOUNDSHOT = SDLK_F1\n"; + file << "QUIT = SDLK_ESCAPE\n"; + file << "TILESHOT = SDLK_F3\n"; + + file << "DEBUGGER = SDLK_d\n"; + file << "PAUSE = SDLK_p\n\n"; + + file << "#\n"; + file << "# First Player PAD:\n"; + file << "#\n\n"; + + file << "PAD1_UP = SDLK_UP\n"; + file << "PAD1_DOWN = SDLK_DOWN\n"; + file << "PAD1_LEFT = SDLK_LEFT\n"; + file << "PAD1_RIGHT = SDLK_RIGHT\n"; + file << "PAD1_BUTTON_A = SDLK_w\n"; + file << "PAD1_BUTTON_B = SDLK_v\n\n"; + + file << "#\n"; + file << "# Second Player PAD:\n"; + file << "#\n\n"; + + file << "PAD2_UP = SDLK_KP5\n"; + file << "PAD2_DOWN = SDLK_KP2\n"; + file << "PAD2_LEFT = SDLK_KP1\n"; + file << "PAD2_RIGHT = SDLK_KP3\n"; + file << "PAD2_BUTTON_A = SDLK_j\n"; + file << "PAD2_BUTTON_B = SDLK_m\n\n"; + + file << "#\n"; + file << "# GAME GEAR Specific:\n"; + file << "#\n\n"; + file << "GAMEGEAR_START = SDLK_RETURN\n\n"; + + file << "# Configuration Ends Here !\n\n\n\n\n\n\n"; + + file << "#########################################################################\n"; + file << "#\n"; + file << "# You can remove this list, it's just provided to help user to\n"; + file << "# configure osmose emulator.\n"; + file << "#\n"; + file << "# Valid Key definitions:\n"; + file << "# ----------------------\n"; + file << "#\n"; + file << "# SDLK_BACKSPACE\n"; + file << "# SDLK_TAB\n"; + file << "# SDLK_CLEAR\n"; + file << "# SDLK_RETURN\n"; + file << "# SDLK_PAUSE\n"; + file << "# SDLK_ESCAPE\n"; + file << "# SDLK_SPACE\n"; + file << "# SDLK_EXCLAIM\n"; + file << "# SDLK_QUOTEDBL\n"; + file << "# SDLK_HASH\n"; + file << "# SDLK_DOLLAR\n"; + file << "# SDLK_AMPERSAND\n"; + file << "# SDLK_QUOTE\n"; + file << "# SDLK_LEFTPAREN\n"; + file << "# SDLK_RIGHTPAREN\n"; + file << "# SDLK_ASTERISK\n"; + file << "# SDLK_PLUS\n"; + file << "# SDLK_COMMA\n"; + file << "# SDLK_MINUS\n"; + file << "# SDLK_PERIOD\n"; + file << "# SDLK_SLASH\n"; + file << "# SDLK_0\n"; + file << "# SDLK_1\n"; + file << "# SDLK_2\n"; + file << "# SDLK_3\n"; + file << "# SDLK_4\n"; + file << "# SDLK_5\n"; + file << "# SDLK_6\n"; + file << "# SDLK_7\n"; + file << "# SDLK_8\n"; + file << "# SDLK_9\n"; + file << "# SDLK_COLON\n"; + file << "# SDLK_SEMICOLON\n"; + file << "# SDLK_LESS\n"; + file << "# SDLK_EQUALS\n"; + file << "# SDLK_GREATER\n"; + file << "# SDLK_QUESTION\n"; + file << "# SDLK_AT\n"; + file << "#\n"; + file << "# -Don't use uppercase letters\n"; + file << "#\n"; + file << "# SDLK_LEFTBRACKET\n"; + file << "# SDLK_BACKSLASH\n"; + file << "# SDLK_RIGHTBRACKET\n"; + file << "# SDLK_CARET\n"; + file << "# SDLK_UNDERSCORE\n"; + file << "# SDLK_BACKQUOTE\n"; + file << "# SDLK_a\n"; + file << "# SDLK_b\n"; + file << "# SDLK_c\n"; + file << "# SDLK_d\n"; + file << "# SDLK_e\n"; + file << "# SDLK_f\n"; + file << "# SDLK_g\n"; + file << "# SDLK_h\n"; + file << "# SDLK_i\n"; + file << "# SDLK_j\n"; + file << "# SDLK_k\n"; + file << "# SDLK_l\n"; + file << "# SDLK_m\n"; + file << "# SDLK_n\n"; + file << "# SDLK_o\n"; + file << "# SDLK_p\n"; + file << "# SDLK_q\n"; + file << "# SDLK_r\n"; + file << "# SDLK_s\n"; + file << "# SDLK_t\n"; + file << "# SDLK_u\n"; + file << "# SDLK_v\n"; + file << "# SDLK_w\n"; + file << "# SDLK_x\n"; + file << "# SDLK_y\n"; + file << "# SDLK_z\n"; + file << "# SDLK_DELETE\n"; + file << "#\n\n"; + + file << "# -Numeric keypad\n"; + file << "#\n"; + file << "# SDLK_KP0\n"; + file << "# SDLK_KP1\n"; + file << "# SDLK_KP2\n"; + file << "# SDLK_KP3\n"; + file << "# SDLK_KP4\n"; + file << "# SDLK_KP5\n"; + file << "# SDLK_KP6\n"; + file << "# SDLK_KP7\n"; + file << "# SDLK_KP8\n"; + file << "# SDLK_KP9\n"; + file << "# SDLK_KP_PERIOD\n"; + file << "# SDLK_KP_DIVIDE\n"; + file << "# SDLK_KP_MULTIPLY\n"; + file << "# SDLK_KP_MINUS\n"; + file << "# SDLK_KP_PLUS\n"; + file << "# SDLK_KP_ENTER\n"; + file << "# SDLK_KP_EQUALS\n"; + file << "#\n"; + file << "# -Arrows + Home/End p\n"; + file << "#\n"; + file << "# SDLK_UP\n"; + file << "# SDLK_DOWN\n"; + file << "# SDLK_RIGHT\n"; + file << "# SDLK_LEFT\n"; + file << "# SDLK_INSERT\n"; + file << "# SDLK_HOME\n"; + file << "# SDLK_END\n"; + file << "# SDLK_PAGEUP\n"; + file << "# SDLK_PAGEDOWN\n"; + file << "#\n"; + file << "# -Function keys\n"; + file << "#\n"; + file << "# SDLK_F1\n"; + file << "# SDLK_F2\n"; + file << "# SDLK_F3\n"; + file << "# SDLK_F4\n"; + file << "# SDLK_F5\n"; + file << "# SDLK_F6\n"; + file << "# SDLK_F7\n"; + file << "# SDLK_F8\n"; + file << "# SDLK_F9\n"; + file << "# SDLK_F10\n"; + file << "# SDLK_F11\n"; + file << "# SDLK_F12\n"; + file << "# SDLK_F13\n"; + file << "# SDLK_F14\n"; + file << "# SDLK_F15\n"; + file << "#\n"; + file << "# -Key state modifier\n"; + file << "#\n"; + file << "# SDLK_NUMLOCK\n"; + file << "# SDLK_CAPSLOCK\n"; + file << "# SDLK_SCROLLOCK\n"; + file << "# SDLK_RSHIFT\n"; + file << "# SDLK_LSHIFT\n"; + file << "# SDLK_RCTRL\n"; + file << "# SDLK_LCTRL\n"; + file << "# SDLK_RALT\n"; + file << "# SDLK_LALT\n"; + file << "# SDLK_RMETA\n"; + file << "# SDLK_LMETA\n"; + file << "# SDLK_LSUPER\n"; + file << "# SDLK_RSUPER\n"; + file << "# SDLK_COMPOSE\n"; + file << "#\n"; + file << "# -Miscellaneous functions\n"; + file << "#\n"; + file << "# SDLK_HELP\n"; + file << "# SDLK_PRINT\n"; + file << "# SDLK_SYSREQ\n"; + file << "# SDLK_BREAK\n"; + file << "# SDLK_MENU\n"; + file << "# SDLK_EURO\n"; + file << "# SDLK_UNDO\n"; + file << "#\n"; + file << "#########################################################################\n"; - file.close(); - } + } // End of default ini file creation + file.close(); + } + else + { + cout << "Load config file : " << default_filename << endl; + } } /*--------------------------------------------------------------------*/ @@ -405,25 +397,25 @@ /*--------------------------------------------------------------------*/ void OsmoseConfiguration::reset() { - P1_UP_KEY = SDLK_UP; - P1_DOWN_KEY = SDLK_DOWN; - P1_LEFT_KEY = SDLK_LEFT; - P1_RIGHT_KEY = SDLK_RIGHT; - P1_A_KEY = SDLK_LCTRL; - P1_B_KEY = SDLK_LALT; - P2_UP_KEY = SDLK_KP5; - P2_DOWN_KEY = SDLK_KP2; - P2_LEFT_KEY = SDLK_KP1; - P2_RIGHT_KEY = SDLK_KP3; - P2_A_KEY = SDLK_n; - P2_B_KEY = SDLK_b; - GG_START_KEY = SDLK_RETURN; - TILESHOT_KEY = SDLK_F3; - SCREENSHOT_KEY = SDLK_F2; - SOUNDSHOT_KEY = SDLK_F1; - PAUSE_KEY = SDLK_p; - QUIT_KEY = SDLK_ESCAPE; - DEBUGGER_KEY = SDLK_d; + P1_UP_KEY = SDLK_UP; + P1_DOWN_KEY = SDLK_DOWN; + P1_LEFT_KEY = SDLK_LEFT; + P1_RIGHT_KEY = SDLK_RIGHT; + P1_A_KEY = SDLK_w; + P1_B_KEY = SDLK_v; + P2_UP_KEY = SDLK_KP5; + P2_DOWN_KEY = SDLK_KP2; + P2_LEFT_KEY = SDLK_KP1; + P2_RIGHT_KEY = SDLK_KP3; + P2_A_KEY = SDLK_j; + P2_B_KEY = SDLK_m; + GG_START_KEY = SDLK_RETURN; + TILESHOT_KEY = SDLK_F3; + SCREENSHOT_KEY = SDLK_F2; + SOUNDSHOT_KEY = SDLK_F1; + PAUSE_KEY = SDLK_p; + QUIT_KEY = SDLK_ESCAPE; + DEBUGGER_KEY = SDLK_d; } /*--------------------------------------------------------------------*/ @@ -434,48 +426,48 @@ /*--------------------------------------------------------------------*/ bool OsmoseConfiguration::loadConfigurationFromFile(const char *f) { - bool ret = false; + bool ret = false; + + // Reset all keys. + P1_UP_KEY = 0; + P1_DOWN_KEY = 0; + P1_LEFT_KEY = 0; + P1_RIGHT_KEY = 0; + P1_A_KEY = 0; + P1_B_KEY = 0; + P2_UP_KEY = 0; + P2_DOWN_KEY = 0; + P2_LEFT_KEY = 0; + P2_RIGHT_KEY = 0; + P2_A_KEY = 0; + P2_B_KEY = 0; + GG_START_KEY = 0; + SCREENSHOT_KEY = 0; + TILESHOT_KEY = 0; + SOUNDSHOT_KEY = 0; + PAUSE_KEY = 0; + QUIT_KEY = 0; + DEBUGGER_KEY = 0; - // Reset all keys. - P1_UP_KEY = 0; - P1_DOWN_KEY = 0; - P1_LEFT_KEY = 0; - P1_RIGHT_KEY = 0; - P1_A_KEY = 0; - P1_B_KEY = 0; - P2_UP_KEY = 0; - P2_DOWN_KEY = 0; - P2_LEFT_KEY = 0; - P2_RIGHT_KEY = 0; - P2_A_KEY = 0; - P2_B_KEY = 0; - GG_START_KEY = 0; - SCREENSHOT_KEY = 0; - TILESHOT_KEY = 0; - SOUNDSHOT_KEY = 0; - PAUSE_KEY = 0; - QUIT_KEY = 0; - DEBUGGER_KEY = 0; - - ifstream file(f, ios::in); - if (file.is_open() == false ) - { - cerr << "Unable to open '" << f << "' init file. Default configuration loaded." << endl; - return false; - } - - ret = true; - - while (!file.eof()) - { - string rd; - char buffer[256]; - file.getline(buffer, 256); - rd = string(buffer, 256); - analyseLine(rd); - } - file.close(); - return ret; + ifstream file(f, ios::in); + if (file.is_open() == false ) + { + cerr << "Unable to open '" << f << "' init file. Default configuration loaded." << endl; + return false; + } + + ret = true; + + while (!file.eof()) + { + string rd; + char buffer[256]; + file.getline(buffer, 256); + rd = string(buffer, 256); + analyseLine(rd); + } + file.close(); + return ret; } /*--------------------------------------------------------------------*/ @@ -484,20 +476,20 @@ /*--------------------------------------------------------------------*/ int OsmoseConfiguration::findSDLKeySym(string wrd) { - int ret = -1; - int i = 0; - bool found = false; - - while (key_list[i].key_value != -1) - { - if (key_list[i].key_name == wrd) - { - found = true; - ret = key_list[i].key_value; - } - i++; - } - return ret; + int ret = -1; + int i = 0; + bool found = false; + + while (key_list[i].key_value != -1) + { + if (key_list[i].key_name == wrd) + { + found = true; + ret = key_list[i].key_value; + } + i++; + } + return ret; } /*--------------------------------------------------------------------*/ @@ -507,103 +499,103 @@ /*--------------------------------------------------------------------*/ void OsmoseConfiguration::analyseLine(string rd) { - unsigned int r; - unsigned int comment_pos; - string kn; - int ks; + unsigned int r; + unsigned int comment_pos; + string kn; + int ks; #define KEY_NBR 19 - string k_list[] = {"PAD1_UP","PAD1_DOWN","PAD1_LEFT","PAD1_RIGHT","PAD1_BUTTON_A","PAD1_BUTTON_B", - "PAD2_UP","PAD2_DOWN","PAD2_LEFT","PAD2_RIGHT","PAD2_BUTTON_A","PAD2_BUTTON_B", - "PAUSE","QUIT","SCREENSHOT","TILESHOT","DEBUGGER","SOUNDSHOT","GAMEGEAR_START"}; - - for (int i = 0; i < KEY_NBR; i++) - { - r = rd.find(k_list[i], 0); - comment_pos = rd.find("#", 0); - - // Comment before TAG, skip this line. - if ((r !=string::npos) && (comment_pos !=string::npos) && (comment_pos < r)) - return; - if (r != string::npos) + string k_list[] = {"PAD1_UP","PAD1_DOWN","PAD1_LEFT","PAD1_RIGHT","PAD1_BUTTON_A","PAD1_BUTTON_B", + "PAD2_UP","PAD2_DOWN","PAD2_LEFT","PAD2_RIGHT","PAD2_BUTTON_A","PAD2_BUTTON_B", + "PAUSE","QUIT","SCREENSHOT","TILESHOT","DEBUGGER","SOUNDSHOT","GAMEGEAR_START"}; + + for (int i = 0; i < KEY_NBR; i++) { - int ind = 0; - unsigned int p; - // We have found a known tag. - while(key_list[ind].key_value != -1) - { - p = rd.find(key_list[ind].key_name, 0); - if (p != string::npos) + r = rd.find(k_list[i], 0); + comment_pos = rd.find("#", 0); + + // Comment before TAG, skip this line. + if ((r !=string::npos) && (comment_pos !=string::npos) && (comment_pos < r)) + return; + if (r != string::npos) { + int ind = 0; + unsigned int p; + // We have found a known tag. + while(key_list[ind].key_value != -1) + { + p = rd.find(key_list[ind].key_name, 0); + if (p != string::npos) + { #ifdef CONFIGURATION_VERBOSE - cout << k_list[i] << " is associated to keysym " << (int)key_list[ind].key_value << endl; + cout << k_list[i] << " is associated to keysym " << (int)key_list[ind].key_value << endl; #endif - ks = key_list[ind].key_value; - switch(i) - { - case 0: - P1_UP_KEY = ks; - break; - case 1: - P1_DOWN_KEY = ks; - break; - case 2: - P1_LEFT_KEY = ks; - break; - case 3: - P1_RIGHT_KEY = ks; - break; - case 4: - P1_A_KEY = ks; - break; - case 5: - P1_B_KEY = ks; - break; - case 6: - P2_UP_KEY = ks; - break; - case 7: - P2_DOWN_KEY = ks; - break; - case 8: - P2_LEFT_KEY = ks; - break; - case 9: - P2_RIGHT_KEY = ks; - break; - case 10: - P2_A_KEY = ks; - break; - case 11: - P2_B_KEY = ks; - break; - case 12: - PAUSE_KEY = ks; - break; - case 13: - QUIT_KEY = ks; - break; - case 14: - SCREENSHOT_KEY = ks; - break; - case 15: - TILESHOT_KEY = ks; - break; - case 16: - DEBUGGER_KEY = ks; - break; - case 17: - SOUNDSHOT_KEY = ks; - break; - case 18: - GG_START_KEY = ks; - break; - - } + ks = key_list[ind].key_value; + switch(i) + { + case 0: + P1_UP_KEY = ks; + break; + case 1: + P1_DOWN_KEY = ks; + break; + case 2: + P1_LEFT_KEY = ks; + break; + case 3: + P1_RIGHT_KEY = ks; + break; + case 4: + P1_A_KEY = ks; + break; + case 5: + P1_B_KEY = ks; + break; + case 6: + P2_UP_KEY = ks; + break; + case 7: + P2_DOWN_KEY = ks; + break; + case 8: + P2_LEFT_KEY = ks; + break; + case 9: + P2_RIGHT_KEY = ks; + break; + case 10: + P2_A_KEY = ks; + break; + case 11: + P2_B_KEY = ks; + break; + case 12: + PAUSE_KEY = ks; + break; + case 13: + QUIT_KEY = ks; + break; + case 14: + SCREENSHOT_KEY = ks; + break; + case 15: + TILESHOT_KEY = ks; + break; + case 16: + DEBUGGER_KEY = ks; + break; + case 17: + SOUNDSHOT_KEY = ks; + break; + case 18: + GG_START_KEY = ks; + break; + + } + } + ind++; + } } - ind++; - } } - } } diff -Nru osmose-0.8.5b/OsmoseConfiguration.h osmose-0.9.1/OsmoseConfiguration.h --- osmose-0.8.5b/OsmoseConfiguration.h 2006-11-06 11:08:38.000000000 +0000 +++ osmose-0.9.1/OsmoseConfiguration.h 2009-11-01 09:18:50.000000000 +0000 @@ -24,11 +24,11 @@ using namespace std; -typedef struct SdlKeyEntry +typedef struct { string key_name; int key_value; -}; +} SdlKeyEntry; extern SdlKeyEntry key_list[]; @@ -60,15 +60,22 @@ int QUIT_KEY; int DEBUGGER_KEY; - // The folder where Osmose can read/write config, screenshots, soundshots, tileshots, ... - string user_home_folder; - + const string & getUserHomeFolder() { return user_home_folder;} + private: bool loadConfigurationFromFile(const char *f); int findSDLKeySym(string wrd); void analyseLine(string l); void reset(); + + // Used path Paths + string default_filename; + + // The folder where Osmose can read/write config, screenshots, soundshots, tileshots, ... + string user_home_folder; + + }; #endif diff -Nru osmose-0.8.5b/OsmoseCore.cpp osmose-0.9.1/OsmoseCore.cpp --- osmose-0.8.5b/OsmoseCore.cpp 2009-01-15 15:05:16.000000000 +0000 +++ osmose-0.9.1/OsmoseCore.cpp 2009-11-01 09:54:01.000000000 +0000 @@ -14,11 +14,10 @@ *****************************************************************************/ #include "OsmoseCore.h" -SDL_sem *timer; // Semaphore used for FPS synchronisation. + SN76489 *p; -// These methods are not from OsmoseCore -unsigned int timer_callback(unsigned int i, void *p); +// This method is not from OsmoseCore void sndCallback(void *ud, unsigned char *s, int len); /*--------------------------------------------------------------------*/ @@ -26,11 +25,9 @@ /*--------------------------------------------------------------------*/ OsmoseCore::OsmoseCore(const char *rom_f) { - quit = false; nmi = false; sound_shot_toggle = false; - frame_skip_increment = .70; - frame_skip_counter =0.0; + snd_started = false; screenshotNbr = 0; tileshotNbr = 0; soundshotNbr = 0; @@ -54,7 +51,7 @@ tw = new TextWriter(); /* Note: After instantiation, opt.MachineType contains SMS or GAMEGEAR type. */ - mem = new MemoryMapper(rom_filename, oc->user_home_folder.c_str()); + mem = new MemoryMapper(rom_filename, oc->getUserHomeFolder().c_str()); if (opt.mapperType == CodemasterMapper) mem->setMapperType(CodemasterMapper); if (opt.mapperType == KoreanMapper) mem->setMapperType(KoreanMapper); @@ -81,15 +78,8 @@ env->setVDP(v); env->setCPU(cpu); wavW = NULL; - pt = new PrecisionTimer(); game_name = mem->getROMName(); - // Timer quiet, then calibrate for 3 seconds. - pt->setVerbose(false); - pt->calibrate(3); - pt->setMeasureMode(CUMULATIVE); - pt->setCumulativeBufferSize(64); - #ifdef BUILT_IN_DEBUGGER dbg = new SmsDebugger(); v->attachDebugEventListener(dbg); @@ -136,9 +126,6 @@ { setupSDLAudio(); } - - timer = SDL_CreateSemaphore(0); - t_id = SDL_AddTimer(DELAY_BETWEEN_FRAME, timer_callback, NULL); } /*--------------------------------------------------------------------*/ @@ -148,9 +135,9 @@ { ostringstream msg; int k = e.key.keysym.sym; - + if(e.type == SDL_KEYDOWN) - { + { if ( k == oc->PAUSE_KEY) { nmi = true; @@ -226,12 +213,6 @@ /* Key released event.*/ if(e.type == SDL_KEYUP) { - if ( k == oc->QUIT_KEY) - { - quit = true; - return; - } - if (k == oc->SOUNDSHOT_KEY) { if (emu_opt.sound == true) @@ -249,7 +230,7 @@ char snd_shot_filename[256]; // We weren't recording sound, record it now, so create WaveWriter. #ifdef __USE_UNIX98 - sprintf(snd_shot_filename,"./osmose_files/snd/%s(%d).wav",game_name.c_str(), soundshotNbr); + sprintf(snd_shot_filename,"%ssnd/%s(%d).wav", oc->getUserHomeFolder().c_str(),game_name.c_str(), soundshotNbr); #else sprintf(snd_shot_filename,".\\snd\\%s(%d).wav", game_name.c_str(), soundshotNbr); #endif @@ -268,185 +249,79 @@ } /*--------------------------------------------------------------------*/ -/* This method is the main emulation loop. */ -/* Note about frame variable: */ +/* This method runs one frame. */ +/* Note about frame variable: */ /* This variable is the total number of frame (displayed or not !) */ /* emulated by Osmose. This value is use for speed synchronisation at */ /* 60 Fps. That's why the value is incremented even if the frame isn't*/ /* rendered. */ /*--------------------------------------------------------------------*/ -void OsmoseCore::run() +void OsmoseCore::run_frame() { bool drawline = true; - bool snd_started = false; bool played = false; float snd_update = 0; int scanline_number; - unsigned int frame = 0; - unsigned int skipped_frame = 0 ; unsigned int over_cycles = 0; - char fpsString[128]; - - - sprintf (fpsString,"0.0fps"); - tw->addText(__OSMOSE_VERSION__,120); - scanline_number = (opt.ntsc == true) ? 262 : 313; // NTSC or PAL - - cout << "Starting emulation." << endl; - while(!quit) - { - if (frame % 3 == 0) - { - SDL_SemWait(timer); - } - - /* Handle SDL Events */ - while( SDL_PollEvent( &event ) ) - { - if (event.type == SDL_QUIT) quit = true; - if (event.type == SDL_VIDEORESIZE) Reshape(event.resize.w,event.resize.h); - else handleSDLKeyboardEvent(event); - } - - if (nmi == true) - { - cpu->nmi(); - nmi = false; - } - - // Here we decide if we should draw the frame, depending on frame skipping. - frame_skip_counter += frame_skip_increment; - if (frame_skip_counter >= 1.0) - { - frame_skip_counter -= 1.0; - drawline = true; - } - else - { - drawline = false; - } - // Start measuring frame rendering. - if (drawline == true) - { - pt->start(); - } + scanline_number = (opt.ntsc == true) ? 262 : 313; // NTSC or PAL - for (v->line=0; v->line < scanline_number; v->line++) - { - over_cycles = cpu->run(CPU_CYCLES_PER_LINE - over_cycles); - if (emu_opt.sound == true) - { - snd_update+=(float)SND_TOGGLE; // Needed to call update_sound_buffer 367.5/frame - played = p->run(1); - if (sound_shot_toggle == true && played==true) - { - wavW->writeData(p->getLastSample()); - } - - if (snd_update > 1.0f) - { - played = p->run(1); - if (played == true) - { - snd_update = snd_update - (float)1.0f; - } - if (sound_shot_toggle == true && played==true) - { - wavW->writeData(p->getLastSample()); - } - } - } - v->update(buffer, drawline); - } // For i = 0 to scanline_number - - tw->update(buffer, drawline); - - if (snd_started == false && emu_opt.sound == true) - { - // Start playing only if sound buffer is full. - // This avoid playing silence on emulator startup. - if (!p->getFIFOSoundBuffer()->spaceAvailable()) - { - snd_started = true; - SDL_PauseAudio(0); // start playing ! - } - } + if (nmi == true) + { + cpu->nmi(); + nmi = false; + } - if (drawline == true) + for (v->line=0; v->line < scanline_number; v->line++) + { + over_cycles = cpu->run(CPU_CYCLES_PER_LINE - over_cycles); + if (emu_opt.sound == true) { - bool r; + snd_update+=(float)SND_TOGGLE; // Needed to call update_sound_buffer 367.5/frame + played = p->run(1); + if (sound_shot_toggle == true && played==true) + { + wavW->writeData(p->getLastSample()); + } - // Update screen. - if (emu_opt.display_fps == true) tw->writeText(buffer, fpsString, 190, 180); - drawGLFrame(); - - // Stop measuring frame rendering. - // Here we are calculating auto frame_skip. - // Compute average render time of 16 rendered frames. - // compute instant fps. if >= 60.0 ok, no frame skip needed. - // Else set frame skip to get instant fps - 5% frame per seconds. - r = pt->stop(); - if (r == true) - { - double val, tfps; - - val = pt->getDuration(); // Average duration of n (rendered) frames. - tfps = (1.0/ val); // Theorical FPS, based on average render. - if (emu_opt.display_fps == true) - { - sprintf (fpsString,"%2.1ffps", tfps); - } - if (tfps >= 60.0) + if (snd_update > 1.0f) + { + played = p->run(1); + if (played == true) { - frame_skip_increment = 1.0; + snd_update = snd_update - (float)1.0f; } - else + if (sound_shot_toggle == true && played==true) { - frame_skip_increment = (tfps * 0.95/60.0); + wavW->writeData(p->getLastSample()); } - } - } - else - { - skipped_frame++; + } } - frame++; -#ifdef AUTO_SCREENSHOT - if (frame == 30*60) captureScreen(); -#endif - // Trackball, Paddle need to be updated in time. - input->updateDevice(); + v->update(buffer, drawline); + } // For i = 0 to scanline_number - // To avoid overflow of cycles_ that cause cpu to halt. - //cout << "OverCycles per frame : " << dec << (cpu->getCycles() - 59736) << endl; - cpu->setCycles(0); - } // While (!quit) - - SDL_CloseAudio(); -#ifdef OPCODES_STATS - cpu->opcodes_stats(); -#endif - save_bbr(); + tw->update(buffer, drawline); -#ifndef BUILT_IN_DEBUGGER - cout << endl << "Emulation statistics:" << endl; - cout << "---------------------" << endl; - cout << "Total frames : " << dec << frame << endl; - cout << "Rendered frames : " << dec << (frame - skipped_frame) << endl; - cout << "Skipped frames : " << dec << skipped_frame<< endl; - cout << "Emulation time : " << (float)(SDL_GetTicks()/1000.0) << " sec." << endl; - cout << "Aver. frame rate: " << (float)((frame - skipped_frame)/(float)(SDL_GetTicks()/1000)) << " fps." << endl << endl; -#endif + if (snd_started == false && emu_opt.sound == true) + { + // Start playing only if sound buffer is full. + // This avoid playing silence on emulator startup. + if (!p->getFIFOSoundBuffer()->spaceAvailable()) + { + snd_started = true; + SDL_PauseAudio(0); // start playing ! + } + } + + // To avoid infinite loop with cycleCounter overflow. + cpu->setCycles(0); + drawGLFrame(); - // We may be recording sound when leaving emulation. If it's the case, close sound_shot file. - if (sound_shot_toggle == true && emu_opt.sound == true) - { - wavW->close(); - } - SDL_Quit(); + // Trackball, Paddle need to be updated in time. + input->updateDevice(); } + /*--------------------------------------------------------------------*/ /* This method will save as bitmap, vdp graphics tiles. */ /* First, a 128x224 SDL_Surface is allocated. */ @@ -482,7 +357,7 @@ // Save it ! #ifdef __USE_UNIX98 - sprintf(sName,"./osmose_files/tiles/gfx_%s(%d).bmp", game_name.c_str(), tileshotNbr); + sprintf(sName,"%stiles/gfx_%s(%d).bmp", oc->getUserHomeFolder().c_str(), game_name.c_str(), tileshotNbr); #else sprintf(sName,".\\tiles\\gfx_%s(%d).bmp", game_name.c_str(), tileshotNbr); #endif @@ -539,21 +414,6 @@ } /*--------------------------------------------------------------------*/ -/* This method is used to synchronise emulator at good FPS. Each */ -/* DELAY_BETWEEN_FRAME milliseconds, the semaphore is freed. Then, the*/ -/* main loop can continue it's execution. Note that DELAY_.. is 50ms. */ -/* This is done to avoid problems due to timer granularity. Timer<20ms*/ -/* aren't very accurate. So instead of drawing frame, waiting 16ms for*/ -/* three times, we draw 3 frames, and wait 50ms. 50ms is large enough */ -/* to get good synchronisation. */ -/*--------------------------------------------------------------------*/ -unsigned int timer_callback(unsigned int i, void *p) -{ - SDL_SemPost(timer); - return DELAY_BETWEEN_FRAME; -} - -/*--------------------------------------------------------------------*/ /* This method setup our default sound. */ /*--------------------------------------------------------------------*/ void OsmoseCore::setupAudioFormat() @@ -588,7 +448,6 @@ // On exit, call SDL_Quit(). atexit (SDL_Quit); - SDL_WM_SetCaption(__OSMOSE_VERSION__,__OSMOSE_VERSION__); /* Window title, Iconified widows title */ SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 6 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ); @@ -643,6 +502,7 @@ if (r >= 0) { cout << "Audio device successfully opened." << endl; + SDL_PauseAudio(1); // Set audio to pause. } else { @@ -676,7 +536,7 @@ SDL_BlitSurface(buffer, &src_rect, surface, NULL); #ifdef __USE_UNIX98 - sprintf(sName,"./osmose_files/screen/%s(%d).bmp", game_name.c_str(), screenshotNbr); + sprintf(sName,"%sscreen/%s(%d).bmp", oc->getUserHomeFolder().c_str(), game_name.c_str(), screenshotNbr); #else sprintf(sName,".\\screen\\%s(%d).bmp", game_name.c_str(), screenshotNbr); #endif @@ -708,7 +568,7 @@ { ostringstream save_state_name; #ifdef __USE_UNIX98 - save_state_name << "./osmose_files/saves/" << mem->getROMName() << "_slot_" << saveStateSlotNbr <<".sta"; + save_state_name << oc->getUserHomeFolder() << "saves/" << mem->getROMName() << "_slot_" << saveStateSlotNbr <<".sta"; #else save_state_name << ".\\saves\\" << mem->getROMName() << "_slot_" << saveStateSlotNbr <<".sta"; #endif @@ -716,7 +576,7 @@ ofstream output_file((char *)save_state_name.str().c_str(), ios::out | ios::binary ); if (output_file.is_open() == false ) - { + { cout << "Cant create file :"<< save_state_name.str() << endl; return false; } @@ -733,6 +593,7 @@ /* Write SN76489 data. */ if (!p->saveState( output_file ) ) {cout << "PSG save fail." << endl; return false;} output_file.close(); + return true; } @@ -740,7 +601,7 @@ { ostringstream load_state_name; #ifdef __USE_UNIX98 - load_state_name << "./osmose_files/saves/" << mem->getROMName() << "_slot_" << saveStateSlotNbr <<".sta"; + load_state_name << oc->getUserHomeFolder() <<"saves/" << mem->getROMName() << "_slot_" << saveStateSlotNbr <<".sta"; #else load_state_name << ".\\saves\\" << mem->getROMName() << "_slot_" << saveStateSlotNbr <<".sta"; #endif @@ -774,7 +635,7 @@ char full_name[256]; #ifdef __USE_UNIX98 - sprintf(full_name,"./osmose_files/bbr/%s.bbr", game_name.c_str()); + sprintf(full_name,"%sbbr/%s.bbr", oc->getUserHomeFolder().c_str(), game_name.c_str()); #else sprintf(full_name,".\\bbr\\%s.bbr", game_name.c_str()); #endif @@ -787,7 +648,7 @@ /*--------------------------------------------------------------------*/ void OsmoseCore::initOpenGL(int Width, int Height) { - cout << "OpenGL initialisation." << endl; + //cout << "OpenGL initialisation." << endl; glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_TEXTURE_2D); glGenTextures(1,textureName); @@ -843,7 +704,7 @@ glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, textureName[0]); - glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer->pixels); + glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer->pixels); glBegin(GL_QUADS); glTexCoord2f(0,0); @@ -870,12 +731,12 @@ void OsmoseCore::Reshape(int w, int h) { sdl_window_width = w; - sdl_window_height = h; + sdl_window_height = h; glDeleteTextures(1,textureName); SDL_ShowCursor(SDL_DISABLE); if ( (screen=SDL_SetVideoMode(sdl_window_width, sdl_window_height,16, SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_SWSURFACE | SDL_RESIZABLE)) == NULL ) { cerr << "Couldn't set video mode: %s" << endl << SDL_GetError() << endl;; exit(2); - } - initOpenGL(w, h); + } + initOpenGL(w, h); } diff -Nru osmose-0.8.5b/OsmoseCore.h osmose-0.9.1/OsmoseCore.h --- osmose-0.8.5b/OsmoseCore.h 2009-01-15 14:46:36.000000000 +0000 +++ osmose-0.9.1/OsmoseCore.h 2009-11-01 09:21:26.000000000 +0000 @@ -18,12 +18,12 @@ #include #include #include -#include - -/* On Windows : GL_UNSIGNED_SHORT_5_6_5 is defined in as extension in glext.h*/ -#ifdef __WIN32__ -#include -#endif +#include + +/* On Windows : GL_UNSIGNED_SHORT_5_6_5 is defined in as extension in glext.h*/ +#ifdef __WIN32__ +#include +#endif #include #include @@ -39,7 +39,6 @@ #include "./z80_disasm/Z80Dasm.h" #include "Bits.h" #include "WaveWriter.h" -#include "PrecisionTimer.h" #include "OsmoseConfiguration.h" #include "TextWriter.h" #include "Version.h" @@ -66,7 +65,10 @@ public: OsmoseCore(const char *rom_f); // Constructor. - void run(); // Enter Osmose main loop. + void run_frame(); // Run one Frame. + void save_bbr(); // Save Battery Backed Ram. + void handleSDLKeyboardEvent(SDL_Event e); + void Reshape(int x, int y); private: @@ -75,52 +77,33 @@ SDL_Surface *screen; // Surface for rendered filtered image 256x192 or 512x384. SDL_Surface *buffer; // SMS screen, without modification 256x192. string game_name; // Used as prefix for screenshot, sound shot and save states. - VDP *v; // Video Display Processor object. - PrecisionTimer *pt; // Use for profiling purpose, not for emulation. + VDP *v; // Video Display Processor object. MemoryMapper *mem; // Memory mapper Object. SmsEnvironment *env; // Z80 Cpu environment. IOMapper *iom; // Input/Output mapper Object. InputDevice *input; // Pad or Paddle or trackball. - Z80 *cpu; // Alessandro Scotti Z80 core. + Z80 *cpu; // Our Z80 core. WaveWriter *wavW; // Sound ripper. TextWriter *tw; // Text Writer. - SDL_Event event; // SDL event used for keyboard handling. - SDL_TimerID t_id; // SDL Timer used for 60hz synchro. float gain; // gain level. #ifdef BUILT_IN_DEBUGGER - unsigned int old_cycles; // Used for cycle count. - Z80Dasm *dasm; // Z80 disasembler object. - SmsDebugger *dbg; // Sms Debugger. - bool exec_f; // Continue cpu exec Flag. + unsigned int old_cycles; // Used for cycle count. + Z80Dasm *dasm; // Z80 disasembler object. + SmsDebugger *dbg; // Sms Debugger. + bool exec_f; // Continue cpu exec Flag. #endif - // Note on frame_skip_increment and frame_skip counter: - // In order to have correct emulation speed, Osmose implements - // an auto-frame-skip feature. The Algorithm is quite simple: - // Each time a frame should be rendered, Osmose sums frame_skip_counter - // and frame_skip increment. If frame_skip_counter is >=0 a frame is - // rendered. Else, aframe is skipped. This means that for: - // frame_skip_increment = 1.0 every frames are rendered (60fps). - // frame_skip_increment = 0.5 half frames are rendered (30fps). - // frame_skip_increment = 0.8 implies 48fps frame rate. - // Values >1.0 are sensless, and implies 60fps. - - float frame_skip_increment; // frame skip limit - float frame_skip_counter; // frame skip counter. - - - bool nmi; // nmi flag, used with keyboard pause. - bool quit; // quit flag, keyboard esc is pressed. + bool nmi; // nmi flag, used with keyboard pause. bool sound_shot_toggle; // Flag, for start/stop recording sound. int screenshotNbr; // Screenshot number appended to save. int tileshotNbr; // Tile rip number appended to save. int soundshotNbr; // Sound rip number appended to save. int saveStateSlotNbr; // Which slot will be use for save state. - const char *rom_filename; // Pointer to argv[1]. + const char *rom_filename; // Pointer to argv[1]. + + bool snd_started; - void save_bbr(); - void handleSDLKeyboardEvent(SDL_Event e); void captureScreen(); void captureTiles(VDP *vd); void displayTiles(SDL_Surface *s, VDP *vd, int tile, int x, int y); @@ -135,7 +118,6 @@ int sdl_window_height; GLuint textureName[1]; void initOpenGL(int x, int y); - void Reshape(int x, int y); void drawGLFrame(); void prepare2DViewport(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y); }; diff -Nru osmose-0.8.5b/PrecisionTimer.cpp osmose-0.9.1/PrecisionTimer.cpp --- osmose-0.8.5b/PrecisionTimer.cpp 2006-11-06 11:08:38.000000000 +0000 +++ osmose-0.9.1/PrecisionTimer.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,237 +0,0 @@ -/***************************************************************************** -* -* File: PrecisionTimer.cpp -* Project: Osmose emulator. -* -* Description: This class handle accurate timer measure, using rdtsc pentium -* instruction. This code compile with gcc, under Linux, and windows. See in -* PrecisionTimer.h for more information about Sleep(millis)/sleep(sec) issues. -* -* Author: Vedder Bruno -* Date: 19/04/2004 -* URL: http://bcz.emu-france.com/ -*****************************************************************************/ -#include "PrecisionTimer.h" - -#define rdtsc(val) __asm__ __volatile__ ("rdtsc" : "=A" (val)) - -/*--------------------------------------------------------------------*/ -/* Default Constructor initialise values to -1; */ -/*--------------------------------------------------------------------*/ -PrecisionTimer::PrecisionTimer() -{ - T0 = (unsigned long long)-1; - T1 = (unsigned long long)-1; - tick_per_second = (unsigned long long)-1; - mode = ONE_SHOT; - values_number = VALUES_BUFFER_SIZE; - cumulative_buffer = NULL; - cumul_buffer_index = 0; - average_duration = 0.0; - verbose = true; -} - -/*--------------------------------------------------------------------*/ -/* Calibration Process. s is in second. The longer is the calibration */ -/* more accurate is the measure. */ -/*--------------------------------------------------------------------*/ -void PrecisionTimer::calibrate(int s) -{ - unsigned long long start; - unsigned long long stop; - if (verbose) - { - cout << "Calibrating:" << dec<< s << " seconds." << endl; - } - rdtsc(start); - PORTABLE_SLEEP_FUNC; - rdtsc(stop); - tick_per_second = (unsigned long long) ( stop - start ); - tick_per_second = (tick_per_second / s); - if (verbose) - { - cout << "tick_per_second is: " << dec << tick_per_second << endl; - cout << "CPU seems to run at " << dec <<(tick_per_second / 1000000.0) << "Mhz." << endl; - } -} - -/*--------------------------------------------------------------------*/ -/* Execute rdtsc pentium instruction store result into T0. */ -/*--------------------------------------------------------------------*/ -void PrecisionTimer::start() -{ - rdtsc(T0); -} - -/*--------------------------------------------------------------------*/ -/* Execute rdtsc pentium instruction store result into T1. */ -/* This method returns true if a value is available from measure: */ -/* -Always true in ONE_SHOT mode */ -/* -True when CUMULATIVE mode has enought value to compute average */ -/* duration else false. */ -/*--------------------------------------------------------------------*/ -bool PrecisionTimer::stop() -{ - bool ret = false; - - rdtsc(T1); - if (mode == CUMULATIVE) - { - cumulative_buffer[cumul_buffer_index] = getOneShotDuration(); - cumul_buffer_index++; - - // We have enough values: display average length. - if (cumul_buffer_index == values_number) - { - double total_duration = 0.0; - - for (unsigned int i =0; i < values_number; i++) - { - total_duration += cumulative_buffer[i]; - } - - average_duration = total_duration / values_number; - if (verbose) - { - cout << "Average length = " << dec << average_duration << " ("<< dec << values_number << " values)." < -#ifndef _RDTSC_TIMER_H -#define _RDTSC_TIMER_H -#ifdef linux - #define PORTABLE_SLEEP_FUNC sleep( s ); - #include -#else - #define PORTABLE_SLEEP_FUNC Sleep( s * 1000 ); - #include -#endif - -// Measurment mode. -#define ONE_SHOT 0 -#define CUMULATIVE 1 -#define VALUES_BUFFER_SIZE 1024 - -class PrecisionTimer -{ - public: - - PrecisionTimer(); // Constructor. - unsigned long long getT0(); // Get tick nbr from boot at T0. - unsigned long long getT1(); // Get tick nbr from boot at T1. - void setVerbose(bool v); // Silent or verbose mode. - void calibrate(int cal_s); // Compute tick per seconds. - void start(); // Start measure. - bool stop(); // Stop measure. - unsigned long long getDeltaT1_T0(); // Get T1 - T0 tick nbr. - unsigned long long getTickPerSecond(); // Get number of tick per seconds. - void setMeasureMode(int mode); // CUMUL/ ONE SHOT measure. - void setCumulativeBufferSize(unsigned int buf_size); // Resize cumulative buffer size. - double getDuration(); // T1- T0 in seconds. - void reset(); // Reset Timer. - - private: - - int mode; // Cumulative or one shot. - bool verbose; // Quiet or silence mode. - double *cumulative_buffer; // Delay cumulative buffer. - double average_duration; // average length. - unsigned int values_number; // total number of values in cumul mode. - unsigned int cumul_buffer_index; // index in array of values. - unsigned long long tick_per_second; // Self explanatory. - unsigned long long T0; // Self explanatory. - unsigned long long T1; // Self explanatory. - double getOneShotDuration(); -}; -#endif diff -Nru osmose-0.8.5b/readme.txt osmose-0.9.1/readme.txt --- osmose-0.8.5b/readme.txt 2009-01-15 14:58:00.000000000 +0000 +++ osmose-0.9.1/readme.txt 2009-11-01 10:15:20.000000000 +0000 @@ -6,7 +6,7 @@ | ___|.--------.--.--.| |.---.-.| |_.-----.----. | ___|| | | || || _ || _| _ | _| |_______||__|__|__|_____||__||___._||____|_____|__| - Version 0.8.5b - 11th public release, written by Bruno Vedder. + Version 0.9.1 - 13th public release, written by Bruno Vedder. Osmose means: @@ -17,45 +17,41 @@ In brief it's an Sega Master System / Game Gear emulator encapsulated into C++ classes :-) - - -PLEASE NOTE: Osmose 0.8.5b is a beta release. The new OpenGL renderer has NOT been -tested on large number of configuration. If you notice problems or successfull test -please report it ! -13 Jan 2009: Osmose-0-8-5b 11th public release. +01 November 2009: Osmose-0-9-1 13th public release. -------------------------------------------------- Osmose is another Sega Master System / Gamegear emulator. The emulator is released as open source project, under GPL license. For more information just read the file 'license.txt'. -The emulator relies on SDL library and Zlib and Gilles Vollant unzip package and +The emulator relies on SDL library and Zlib and Gilles Vollant unzip package and OpenGL 3D graphic library. What's new: ----------- --Use a lookup table instead of switch / if else for TextWriter (Faster). --FPS is now writen into emulated display instead of Window's Title so it can - be seen in fullscreen. --Osmose now uses OPENGL for render for a serious speedup (80% on my machine). - Bilinear filtering cost almost nothing now, whatever is osmose window size. - Note that it's now possible to resize the window. Vsync is now done by openGl - and animation is very smooth. --Some filters are removed. --Emulator is less verbose now. It does not say what it doesn't do anymore :) - Few changes in emulation statistics presentation. - --ZLIB is now installed by default on most linux distribution so Osmose does not - keep zlib source code into it's source tree, and uses the libz shared object. - +-Uses users home .osmose directory for saves and config file. +-Fix several code ambiguous parenthesis that make GCC complain.. +-Remove various debugging traces. +-Makefile few changes. +-Rewrite portable FPS calculation. +-Use a larger sound buffer since SDL 1.2.14 uses ALSA instead of OSS when + possible and is more CPU intensive. This caused a big CPU load. +-Bug fix in the save state system: + * Cpu flags and flags copy weren't saved. + * Memory mapping was restored by fake writes into mapping register, which + is wrong. Now pointed areas and bloc numbers are saved. Drawback : the + previous save are not compatible with this osmose version. +-Defaut P1 A/B are mapped on W/V Key. This avoid virtual desktop changing while + playing :) P2 A/B are now j/m + Features: -------- -SMS: Good compatibility. At this stage, the emulator can run* 96% of commercial - games and public demos, except games that relies on codemaster mapper, which work - but does not have proper video mode emulated. + games and public demos, except games that relies on codemaster mapper, which + work but does not have proper video mode emulated. -Game Gear: Good compatibility. At this stage, the emulator can run 98.0%* of game gear ROMS. -SN76489 Sound is supported, but needs more work on noise register. @@ -130,15 +126,15 @@ PAD1 DOWN : DOWN PAD1 LEFT : LEFT PAD1 RIGHT: RIGHT -PAD1 A : LEFT ALT -PAD1 B : LEFT CONTROL +PAD1 A : w +PAD1 B : v PAD2 UP : NUMPAD 5 PAD2 DOWN : NUMPAD 2 PAD2 LEFT : NUMPAD 1 PAD2 RIGHT: NUMPAD 3 -PAD2 A : n -PAD2 B : b +PAD2 A : j +PAD2 B : m ENTER : Game Gear start button. @@ -153,18 +149,18 @@ If you dislike Osmose's keyboard configuration, you can change it, by providing a file with new configuration. When run, osmose will create a osmose.ini file with default configuration. Under Linux/Unix this file -is created in ./osmose of user directory. You can specify other configuration +is created in .osmose of user directory. You can specify other configuration file with '-inifile my_config.txt' option Sound shots, tiles rip and screenshots, Battery backed ram: --------------------------------------- -Osmose save these files in the corresponding folders: -./snd -./tiles -./screen -./bbr -./saves +Osmose save these files in the corresponding folders under user home directory: +.osmose/snd +.osmose/tiles +.osmose/screen +.osmose/bbr +.osmose/saves If the emulator doesn't find osmose.ini, it will generate a new one, with these four folders. Without these folders no save are possible. If Osmose @@ -176,8 +172,8 @@ Building Osmose from sources: ----------------------------- -Assuming your system is correctly configured, with : -SDL, zlib, and OpenGL (header + shared object) +Assuming your system is correctly configured, with : +SDL, zlib, and OpenGL (header + shared object) just type: make from the source directory. @@ -187,8 +183,8 @@ -Bertram, for the Osmose's Frontend, based on wxWidgets, and bug reports. --Alessandro Scotti, for it's Z80 CPU core used in earlier version of Osmose. - Osmose now uses it's own cpu core. +-Alessandro Scotti, for it's Z80 CPU core used in earlier version of Osmose. + Osmose now uses it's own cpu core. Web site: http://ascotti.org/programming/tickle/tickle.htm -Charles MacDonald, for his excellent technical documentation on the SMS @@ -201,7 +197,7 @@ -Zlib home page for their excellent library. Web site: http://www.gzip.org/zlib --Gilles Vollant for it's unzip package based on zlib. +-Gilles Vollant for his unzip package based on zlib. -emu-france.com for free and publicity free web hosting. Web site: http://emu-france.com diff -Nru osmose-0.8.5b/unzip/ChangeLogUnzip osmose-0.9.1/unzip/ChangeLogUnzip --- osmose-0.8.5b/unzip/ChangeLogUnzip 2006-11-06 11:08:38.000000000 +0000 +++ osmose-0.9.1/unzip/ChangeLogUnzip 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -Change in 1.00: (10 sept 03) -- rename to 1.00 -- cosmetic code change - -Change in 0.22: (19 May 03) -- crypting support (unless you define NOCRYPT) -- append file in existing zipfile - -Change in 0.21: (10 Mar 03) -- bug fixes - -Change in 0.17: (27 Jan 02) -- bug fixes - -Change in 0.16: (19 Jan 02) -- Support of ioapi for virtualize zip file access - -Change in 0.15: (19 Mar 98) -- fix memory leak in minizip.c - -Change in 0.14: (10 Mar 98) -- fix bugs in minizip.c sample for zipping big file -- fix problem in month in date handling -- fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for - comment handling - -Change in 0.13: (6 Mar 98) -- fix bugs in zip.c -- add real minizip sample - -Change in 0.12: (4 Mar 98) -- add zip.c and zip.h for creates .zip file -- fix change_file_date in miniunz.c for Unix (Jean-loup Gailly) -- fix miniunz.c for file without specific record for directory - -Change in 0.11: (3 Mar 98) -- fix bug in unzGetCurrentFileInfo for get extra field and comment -- enhance miniunz sample, remove the bad unztst.c sample - -Change in 0.10: (2 Mar 98) -- fix bug in unzReadCurrentFile -- rename unzip* to unz* function and structure -- remove Windows-like hungary notation variable name -- modify some structure in unzip.h -- add somes comment in source -- remove unzipGetcCurrentFile function -- replace ZUNZEXPORT by ZEXPORT -- add unzGetLocalExtrafield for get the local extrafield info -- add a new sample, miniunz.c - -Change in 0.4: (25 Feb 98) -- suppress the type unzipFileInZip. - Only on file in the zipfile can be open at the same time -- fix somes typo in code -- added tm_unz structure in unzip_file_info (date/time in readable format) diff -Nru osmose-0.8.5b/unzip/Makefile.win osmose-0.9.1/unzip/Makefile.win --- osmose-0.8.5b/unzip/Makefile.win 2006-11-06 11:08:38.000000000 +0000 +++ osmose-0.9.1/unzip/Makefile.win 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -# Project: unziper -# Makefile created by Dev-C++ 4.9.9.2 - -CPP = g++.exe -CC = gcc.exe -WINDRES = windres.exe -RES = -OBJ = ioapi.o unzip.o $(RES) -LINKOBJ = ioapi.o unzip.o $(RES) -LIBS = -L"C:/Dev-Cpp/lib" ./Zlib-basic.a -INCS = -I"C:/Dev-Cpp/include" -CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -BIN = unziper.a -CXXFLAGS = $(CXXINCS) -CFLAGS = $(INCS) -RM = rm -f - -.PHONY: all all-before all-after clean clean-custom - -all: all-before unziper.a all-after - - -clean: clean-custom - ${RM} $(OBJ) $(BIN) - -$(BIN): $(LINKOBJ) - ar r $(BIN) $(LINKOBJ) - ranlib $(BIN) - -ioapi.o: ioapi.c - $(CC) -c ioapi.c -o ioapi.o $(CFLAGS) - -unzip.o: unzip.c - $(CC) -c unzip.c -o unzip.o $(CFLAGS) diff -Nru osmose-0.8.5b/unzip/unziper.dev osmose-0.9.1/unzip/unziper.dev --- osmose-0.8.5b/unzip/unziper.dev 2006-11-06 11:08:38.000000000 +0000 +++ osmose-0.9.1/unzip/unziper.dev 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -[Project] -FileName=unziper.dev -Name=unziper -UnitCount=5 -Type=2 -Ver=1 -ObjFiles= -Includes= -Libs= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Compiler=_@@_ -CppCompiler= -Linker=./Zlib-basic.a_@@_ -IsCpp=0 -Icon= -ExeOutput= -ObjectOutput= -OverrideOutput=0 -OverrideOutputName=unziper.a -HostApplication= -Folders= -CommandLine= -UseCustomMakefile=0 -CustomMakefile= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=0000000000000000000000 - -[Unit1] -FileName=crypt.h -CompileCpp=0 -Folder=unziper -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=ioapi.c -CompileCpp=0 -Folder=unziper -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit3] -FileName=ioapi.h -CompileCpp=0 -Folder=unziper -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit5] -FileName=unzip.h -CompileCpp=0 -Folder=unziper -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit6] -FileName=unzip.h -CompileCpp=0 -Folder=unziper -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -AutoIncBuildNr=0 - -[Unit4] -FileName=unzip.c -CompileCpp=0 -Folder=unziper -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - diff -Nru osmose-0.8.5b/unzip/unziper.layout osmose-0.9.1/unzip/unziper.layout --- osmose-0.8.5b/unzip/unziper.layout 2006-11-06 11:08:38.000000000 +0000 +++ osmose-0.9.1/unzip/unziper.layout 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -[Editor_3] -CursorCol=28 -CursorRow=12 -TopLine=2 -LeftChar=1 -Open=0 -Top=0 -[Editors] -Order=0,1 -Focused=1 -[Editor_0] -Open=1 -Top=0 -CursorCol=1 -CursorRow=1 -TopLine=1 -LeftChar=1 -[Editor_1] -Open=1 -Top=1 -CursorCol=3 -CursorRow=7 -TopLine=1 -LeftChar=1 -[Editor_2] -Open=0 -Top=0 -[Editor_4] -Open=0 -Top=0 diff -Nru osmose-0.8.5b/VDP.cpp osmose-0.9.1/VDP.cpp --- osmose-0.8.5b/VDP.cpp 2006-11-27 18:24:10.000000000 +0000 +++ osmose-0.9.1/VDP.cpp 2009-10-27 18:18:44.000000000 +0000 @@ -37,7 +37,7 @@ 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; -// Pre calculated Vertical count values, for 192 line NTSC video. +// Pre calculated Vertical count values, for 192 line pal/secam video. unsigned char vcount_palsecam_192[313] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, @@ -153,10 +153,10 @@ { unsigned char r, g, b; - r = (data & 0xF) << 1; - g = ((data >> 4) & 0xF)<<2; - b = ((data >> 8) & 0xF)<<1; - + r = (data & 0xF) << 1; + g = ((data >> 4) & 0xF)<<2; + b = ((data >> 8) & 0xF)<<1; + return (unsigned short)(r << 11) | (g <<5) | (b); } @@ -563,7 +563,7 @@ if (attrib & BIT2) { // Verticaly flipped tile. - c = (7 - ((current_line & 7) )<<2) + (currentTile<<5); + c = ((7 - (current_line & 7))<<2) + (currentTile<<5); } else { @@ -584,7 +584,7 @@ case 0: // Tile not flipped for ( i = 0; i<8; i++) { - col_index = (p >>7)&1 | ((p >> 15)<<1)&2 | ((p >> 23)<<2)&4 | ((p >> 31)<<3); + col_index = ((p >>7)&1) | (((p >> 15)<<1)&2) | (((p >> 23)<<2)&4) | ((p >> 31)<<3); if(attrib & BIT3) col_index|=0x10; // Then use sprite palete dst[x] = colors[col_index]; if ((attrib & BIT4) && (col_index != 0x10) && (col_index !=0x0)) @@ -773,7 +773,7 @@ c += 4; for (int i=start_spr[r]; i>7)&1 | ((p >> 15)<<1)&2 | ((p >> 23)<<2)&4 | ((p >> 31)<<3); + col_index = ((p >>7)&1) | (((p >> 15)<<1)&2) | (((p >> 23)<<2)&4) | ((p >> 31)<<3); col_index|=0x10; // Always use sprite palete if(col_index != 0x10) { diff -Nru osmose-0.8.5b/VDP_GG.cpp osmose-0.9.1/VDP_GG.cpp --- osmose-0.8.5b/VDP_GG.cpp 2006-11-27 18:22:00.000000000 +0000 +++ osmose-0.9.1/VDP_GG.cpp 2009-10-23 08:34:50.000000000 +0000 @@ -79,7 +79,6 @@ int current_line; unsigned int p; - // scr ptr in our SDL_Surface points line to be drawn. scr = (unsigned short*) s->pixels + (256 * line); @@ -158,7 +157,7 @@ if (attrib & BIT2) { // Verticaly flipped tile. - c = (7 - ((current_line & 7) )<<2) + (currentTile<<5); + c = ((7 - (current_line & 7))<<2) + (currentTile<<5); } else { @@ -179,7 +178,7 @@ case 0: // Tile not flipped for ( i = 0; i<8; i++) { - col_index = (p >>7)&1 | ((p >> 15)<<1)&2 | ((p >> 23)<<2)&4 | ((p >> 31)<<3); + col_index = ((p >>7)&1) | (((p >> 15)<<1)&2) | (((p >> 23)<<2)&4) | ((p >> 31)<<3); if(attrib & BIT3) col_index|=0x10; // Then use sprite palete dst[x] = colors[col_index]; if ((attrib & BIT4) && (col_index != 0x10) && (col_index !=0x0)) diff -Nru osmose-0.8.5b/Version.h osmose-0.9.1/Version.h --- osmose-0.8.5b/Version.h 2009-01-12 19:49:44.000000000 +0000 +++ osmose-0.9.1/Version.h 2009-10-15 18:19:21.000000000 +0000 @@ -2,8 +2,8 @@ #define VERSION_H // These for definitions should be coherent ! -#define __OSMOSE_VERSION__ "OsmOse 0.8.5 beta" +#define __OSMOSE_VERSION__ "OsmOse 0.9.1" #define MAJOR 0 -#define MIDDLE 8 -#define MINOR 5 +#define MIDDLE 9 +#define MINOR 1 #endif diff -Nru osmose-0.8.5b/WaveWriter.cpp osmose-0.9.1/WaveWriter.cpp --- osmose-0.8.5b/WaveWriter.cpp 2006-11-06 11:08:38.000000000 +0000 +++ osmose-0.9.1/WaveWriter.cpp 2009-01-18 08:53:36.000000000 +0000 @@ -13,6 +13,7 @@ * URL: http://bcz.emu-france.com/ *****************************************************************************/ #include "WaveWriter.h" +#include /*----------------------------------------------------------------------*/ /* Constructor: Initialise structures ChunkFormat, Data Format, and */