Skip to content

Commit 6087205

Browse files
committed
Initial sdcard hbc-56 device support
1 parent fcde160 commit 6087205

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ target_link_libraries(${PROGRAM} PRIVATE
2020
pico-56-audio
2121
pico-56-boot-menu
2222
pico-56-interrupts
23+
pico-56-sdcard
2324
pico_stdlib
2425
pico_multicore
2526
hardware_pio

src/boot-menu/boot-menu.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,4 @@ void runBootMenu()
322322

323323
}
324324
free(fileList);
325-
326-
f_unmount(pSD->pcName);
327325
}

src/bus.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "audio.h"
1616
#include "nes-ctrl.h"
1717
#include "ps2-kbd.h"
18+
#include "sdcard.h"
1819

1920
#include "interrupts.h"
2021
#include "config.h"
@@ -50,6 +51,13 @@ static VrEmuTms9918* tms9918 = NULL;
5051
#define MICROSECONDS_PER_BURST 50
5152
#define TICKS_PER_BURST (int)(MICROSECONDS_PER_BURST * HBC56_CLOCK_FREQ_MHZ)
5253

54+
#define FOPEN_PORT 0x04
55+
#define FCLOSE_PORT 0x04
56+
#define FREAD_PORT 0x05
57+
#define FWRITE_PORT 0x05
58+
59+
FIL fil;
60+
5361
#define CPU_6502_WAI 0xcb
5462

5563
/*
@@ -235,6 +243,21 @@ void __not_in_flash_func(busWrite)(uint16_t addr, uint8_t val)
235243
audioWritePsg1(addr, val);
236244
break;
237245

246+
case FOPEN_PORT:
247+
{
248+
uint16_t addr = ram[val] | (ram[val + 1] << 8);
249+
char* strAddr = ram + addr;
250+
f_open(&fil, strAddr, FA_OPEN_ALWAYS | FA_WRITE | FA_READ);
251+
}
252+
break;
253+
254+
case FWRITE_PORT:
255+
{
256+
uint bw = 0;
257+
f_write(&fil, &val, 1, &bw);
258+
}
259+
break;
260+
238261
default:
239262
// unknown device
240263
break;
@@ -318,6 +341,21 @@ uint8_t __not_in_flash_func(busRead)(uint16_t addr, bool isDbg)
318341
case HBC56_AY38910_B_PORT | 0x02:
319342
return audioReadPsg1();
320343

344+
case FCLOSE_PORT:
345+
f_close(&fil);
346+
return 0;
347+
348+
case FREAD_PORT:
349+
{
350+
uint br = 0;
351+
uint8_t value = 0;
352+
if (f_read(&fil, &value, 1, &br) != FR_OK)
353+
{
354+
value = 0;
355+
}
356+
return value;
357+
}
358+
321359
default:
322360
return 0x00;
323361
}

0 commit comments

Comments
 (0)