Skip to content

Commit ced8eb0

Browse files
committed
preliminary LED support (debug port for now; will be I/O line on hardware R2)
1 parent 055051a commit ced8eb0

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,9 @@ emulator_loop(void *param)
11031103
}
11041104
}
11051105

1106+
#if 0 // enable this for slow pasting
1107+
if (!(instruction_counter % 100000))
1108+
#endif
11061109
while (pasting_bas && RAM[NDX] < 10) {
11071110
uint32_t c;
11081111
int e = 0;

memory.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ uint8_t rom_bank;
2020
uint8_t *RAM;
2121
uint8_t ROM[ROM_SIZE];
2222

23+
bool led_status;
24+
2325
#define DEVICE_EMULATOR (0x9fb0)
2426

2527
void
@@ -204,6 +206,7 @@ emu_write(uint8_t reg, uint8_t value)
204206
case 3: echo_mode = value; break;
205207
case 4: save_on_exit = v; break;
206208
case 5: emu_recorder_set((gif_recorder_command_t) value); break;
209+
case 15: led_status = v; break;
207210
default: printf("WARN: Invalid register %x\n", DEVICE_EMULATOR + reg);
208211
}
209212
}

memory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <stdio.h>
1111
#include <SDL.h>
1212

13+
extern bool led_status;
14+
1315
uint8_t read6502(uint16_t address);
1416
uint8_t real_read6502(uint16_t address, bool debugOn, uint8_t bank);
1517

video.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,18 @@ video_update()
10561056
{
10571057
static bool cmd_down = false;
10581058

1059+
// if LED is on, stamp red 8x4 square into top right of framebuffer
1060+
if (led_status) {
1061+
for (int y = 0; y < 4; y++) {
1062+
for (int x = SCREEN_WIDTH - 8; x < SCREEN_WIDTH; x++) {
1063+
framebuffer[(y * SCREEN_WIDTH + x) * 4 + 0] = 0x00;
1064+
framebuffer[(y * SCREEN_WIDTH + x) * 4 + 1] = 0x00;
1065+
framebuffer[(y * SCREEN_WIDTH + x) * 4 + 2] = 0xff;
1066+
framebuffer[(y * SCREEN_WIDTH + x) * 4 + 3] = 0x00;
1067+
}
1068+
}
1069+
}
1070+
10591071
SDL_UpdateTexture(sdlTexture, NULL, framebuffer, SCREEN_WIDTH * 4);
10601072

10611073
if (record_gif > RECORD_GIF_PAUSED) {

0 commit comments

Comments
 (0)