mirror of
https://github.com/cc65/cc65.git
synced 2025-01-15 22:30:04 +00:00
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:
commit
f9e4a2a4d3
@ -45,8 +45,8 @@
|
||||
|
||||
|
||||
|
||||
/* THE memory */
|
||||
unsigned char Mem[0x10000];
|
||||
/* The memory */
|
||||
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 */
|
||||
{
|
||||
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 */
|
||||
{
|
||||
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 */
|
||||
{
|
||||
unsigned W = MemReadByte (Addr++);
|
||||
uint8_t W = MemReadByte (Addr++);
|
||||
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
|
||||
** the read will always be in the zero page, even in case of an address
|
||||
** overflow.
|
||||
*/
|
||||
{
|
||||
unsigned W = MemReadByte (Addr++);
|
||||
uint8_t W = MemReadByte (Addr++);
|
||||
return (W | (MemReadByte (Addr) << 8));
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@
|
||||
#ifndef MEMORY_H
|
||||
#define MEMORY_H
|
||||
|
||||
#include "inline.h"
|
||||
#include <stdint.h>
|
||||
|
||||
extern unsigned char Mem[0x10000];
|
||||
extern uint8_t Mem[0x10000];
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 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 */
|
||||
|
||||
void MemWriteWord (unsigned Addr, unsigned Val);
|
||||
void MemWriteWord (uint16_t Addr, uint16_t Val);
|
||||
/* Write a word to a memory location */
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE unsigned char MemReadByte (unsigned Addr)
|
||||
uint8_t MemReadByte (uint16_t Addr);
|
||||
/* 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 */
|
||||
|
||||
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
|
||||
** the read will always be in the zero page, even in case of an address
|
||||
** overflow.
|
||||
|
Loading…
x
Reference in New Issue
Block a user