Merge pull request #2555 from sidneycadot/fix-sim65-memory-types

sim65: changing memory access types to uint8_t and uint16_t.
This commit is contained in:
Bob Andrews
2024-12-15 22:59:07 +01:00
committed by GitHub
2 changed files with 23 additions and 22 deletions

View File

@@ -45,8 +45,8 @@
/* THE memory */ /* The memory */
unsigned char Mem[0x10000]; uint8_t Mem[0x10000];
@@ -56,7 +56,7 @@ unsigned char Mem[0x10000];
void MemWriteByte (unsigned Addr, unsigned char Val) void MemWriteByte (uint16_t Addr, uint8_t Val)
/* Write a byte to a memory location */ /* Write a byte to a memory location */
{ {
Mem[Addr] = Val; Mem[Addr] = Val;
@@ -64,7 +64,7 @@ void MemWriteByte (unsigned Addr, unsigned char Val)
void MemWriteWord (unsigned Addr, unsigned Val) void MemWriteWord (uint16_t Addr, uint16_t Val)
/* Write a word to a memory location */ /* Write a word to a memory location */
{ {
MemWriteByte (Addr, Val & 0xFF); MemWriteByte (Addr, Val & 0xFF);
@@ -73,22 +73,30 @@ void MemWriteWord (unsigned Addr, unsigned Val)
unsigned MemReadWord (unsigned Addr) uint8_t MemReadByte (uint16_t Addr)
/* Read a byte from a memory location */
{
return Mem[Addr];
}
uint16_t MemReadWord (uint16_t Addr)
/* Read a word from a memory location */ /* Read a word from a memory location */
{ {
unsigned W = MemReadByte (Addr++); uint8_t W = MemReadByte (Addr++);
return (W | (MemReadByte (Addr) << 8)); return (W | (MemReadByte (Addr) << 8));
} }
unsigned MemReadZPWord (unsigned char Addr) uint16_t MemReadZPWord (uint8_t Addr)
/* Read a word from the zero page. This function differs from MemReadWord in that /* Read a word from the zero page. This function differs from MemReadWord in that
** the read will always be in the zero page, even in case of an address ** the read will always be in the zero page, even in case of an address
** overflow. ** overflow.
*/ */
{ {
unsigned W = MemReadByte (Addr++); uint8_t W = MemReadByte (Addr++);
return (W | (MemReadByte (Addr) << 8)); return (W | (MemReadByte (Addr) << 8));
} }

View File

@@ -36,9 +36,9 @@
#ifndef MEMORY_H #ifndef MEMORY_H
#define MEMORY_H #define MEMORY_H
#include "inline.h" #include <stdint.h>
extern unsigned char Mem[0x10000]; extern uint8_t Mem[0x10000];
/*****************************************************************************/ /*****************************************************************************/
/* Code */ /* Code */
@@ -46,26 +46,19 @@ extern unsigned char Mem[0x10000];
void MemWriteByte (unsigned Addr, unsigned char Val); void MemWriteByte (uint16_t Addr, uint8_t Val);
/* Write a byte to a memory location */ /* Write a byte to a memory location */
void MemWriteWord (unsigned Addr, unsigned Val); void MemWriteWord (uint16_t Addr, uint16_t Val);
/* Write a word to a memory location */ /* Write a word to a memory location */
#if defined(HAVE_INLINE) uint8_t MemReadByte (uint16_t Addr);
INLINE unsigned char MemReadByte (unsigned Addr)
/* Read a byte from a memory location */ /* Read a byte from a memory location */
{
return Mem[Addr];
}
#else
#define MemReadByte(Addr) Mem[Addr]
#endif
unsigned MemReadWord (unsigned Addr); uint16_t MemReadWord (uint16_t Addr);
/* Read a word from a memory location */ /* Read a word from a memory location */
unsigned MemReadZPWord (unsigned char Addr); uint16_t MemReadZPWord (uint8_t Addr);
/* Read a word from the zero page. This function differs from MemReadWord in that /* Read a word from the zero page. This function differs from MemReadWord in that
** the read will always be in the zero page, even in case of an address ** the read will always be in the zero page, even in case of an address
** overflow. ** overflow.