Skip to content

Commit 61b7a18

Browse files
committed
Randomize memory content to mimic real hardware
1 parent 1269537 commit 61b7a18

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/systems/x65.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "firmware/src/ria/cgia/font_8.h"
66

7+
#include <stdlib.h>
78
#include <string.h> // memcpy, memset
89

910
#ifndef CHIPS_ASSERT
@@ -26,6 +27,10 @@ void x65_init(x65_t* sys, const x65_desc_t* desc) {
2627
}
2728

2829
memset(sys, 0, sizeof(x65_t));
30+
for (int i = 0; i < X65_RAM_SIZE_BYTES; i++) {
31+
sys->ram[i] = rand() & 0xFF; // fill RAM with random data
32+
}
33+
2934
sys->valid = true;
3035
sys->running = false;
3136
sys->joystick_type = desc->joystick_type;

src/systems/x65.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ typedef enum {
110110
#define X65_IO_TIMERS_BASE (0xFF88)
111111
#define X65_IO_RIA_BASE (0xFFC0)
112112

113+
#define X65_RAM_SIZE_BYTES (1 << 24) // 16 MBytes of RAM
114+
113115
// config parameters for x65_init()
114116
typedef struct {
115117
x65_joystick_type_t joystick_type; // default is X65_JOYSTICK_NONE
@@ -145,7 +147,7 @@ typedef struct {
145147
float sample_buffer[X65_MAX_AUDIO_SAMPLES];
146148
} audio;
147149

148-
uint8_t ram[1 << 24]; // 16 MBytes of general RAM
150+
alignas(64) uint8_t ram[X65_RAM_SIZE_BYTES];
149151
alignas(64) uint32_t fb[CGIA_FRAMEBUFFER_SIZE_BYTES / 4];
150152
} x65_t;
151153

0 commit comments

Comments
 (0)