More simplifications

This commit is contained in:
Sergio Martin 2024-01-19 19:46:45 +01:00
parent d7f6144209
commit 9d941ede99
3 changed files with 11 additions and 38 deletions

View File

@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
// Macros
#define GET_OPERAND( addr ) page [addr]
#define GET_OPERAND16( addr ) GET_LE16( &page [addr] )
#define GET_OPERAND16( addr ) *(uint16_t*)( &page [addr] )
#define ADD_PAGE (pc++, data += 0x100 * GET_OPERAND( pc ));
#define GET_ADDR() GET_OPERAND16( pc )
@ -836,7 +836,7 @@ loop:
CALC_STATUS( temp );
sp = (sp - 3) | 0x100;
WRITE_LOW( sp, temp | st_b | st_r );
pc = GET_LE16( &code_map [0xFFFE >> page_bits] [0xFFFE] );
pc = *(uint16_t*)( &code_map [0xFFFE >> page_bits] [0xFFFE] );
status |= st_i;
goto i_flag_changed;
}

View File

@ -21,6 +21,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
int const cache_line_size = 128; // tile cache is kept aligned to this boundary
inline void set_be32( void* p, unsigned long n ) {
((unsigned char*) p) [0] = (unsigned char) (n >> 24);
((unsigned char*) p) [1] = (unsigned char) (n >> 16);
((unsigned char*) p) [2] = (unsigned char) (n >> 8);
((unsigned char*) p) [3] = (unsigned char) n;
}
#define SET_BE32( addr, data ) set_be32( addr, data )
Nes_Ppu_Impl::Nes_Ppu_Impl()
{
impl = NULL;

View File

@ -1,36 +0,0 @@
#pragma once
// CPU Byte Order Utilities
// Nes_Emu 0.7.0
inline unsigned get_be16( void const* p ) {
return ((unsigned char*) p) [0] * 0x100u +
((unsigned char*) p) [1];
}
inline unsigned long get_be32( void const* p ) {
return ((unsigned char*) p) [0] * 0x01000000ul +
((unsigned char*) p) [1] * 0x00010000ul +
((unsigned char*) p) [2] * 0x00000100ul +
((unsigned char*) p) [3];
}
inline void set_be16( void* p, unsigned n ) {
((unsigned char*) p) [0] = (unsigned char) (n >> 8);
((unsigned char*) p) [1] = (unsigned char) n;
}
inline void set_be32( void* p, unsigned long n ) {
((unsigned char*) p) [0] = (unsigned char) (n >> 24);
((unsigned char*) p) [1] = (unsigned char) (n >> 16);
((unsigned char*) p) [2] = (unsigned char) (n >> 8);
((unsigned char*) p) [3] = (unsigned char) n;
}
#define GET_LE16( addr ) (*(uint16_t*) (addr))
#define SET_LE16( addr, data ) (void) (*(uint16_t*) (addr) = (data))
#define SET_LE32( addr, data ) (void) (*(uint32_t*) (addr) = (data))
#ifndef GET_BE16
#define GET_BE16( addr ) get_be16( addr )
#define GET_BE32( addr ) get_be32( addr )
#define SET_BE16( addr, data ) set_be16( addr, data )
#define SET_BE32( addr, data ) set_be32( addr, data )
#endif