project(pico1541 VERSION 0.1.0)
pico_sdk_init()
-add_executable(pico1541 src/pico1541.c src/6502.c src/6522.c src/drive.c testbin/1541.o testbin/testimage.o)
+add_executable(pico1541 src/pico1541.c src/6502.c src/6522.c src/drive.c testbin/1541.o testbin/bsk1.o)
pico_set_binary_type(pico1541 copy_to_ram)
-target_link_libraries(pico1541 pico_runtime hardware_timer)
+target_link_libraries(pico1541 pico_runtime pico_multicore hardware_timer)
pico_add_extra_outputs(pico1541)
\ No newline at end of file
extern const uint8_t GCR_CONV[16];
typedef struct drive_s {
- bool spinning;
+ volatile bool spinning;
uint8_t timer;
uint8_t *image;
- uint8_t track;
- uint8_t halftrack;
- uint32_t image_ptr;
- uint8_t sector;
+ volatile uint8_t track;
+ volatile uint8_t halftrack;
+ volatile uint32_t image_ptr;
+ volatile uint8_t sector;
uint8_t byte;
uint16_t gcr_word;
uint8_t current_idx;
uint8_t lookahead_idx;
- uint16_t unlatched[DRIVE_LOOKAHEAD];
- uint16_t latched[DRIVE_LOOKAHEAD];
- bool sync[DRIVE_LOOKAHEAD];
- bool byte_ready[DRIVE_LOOKAHEAD];
+ volatile uint16_t unlatched[DRIVE_LOOKAHEAD];
+ volatile uint16_t latched[DRIVE_LOOKAHEAD];
+ volatile bool sync[DRIVE_LOOKAHEAD];
+ volatile bool byte_ready[DRIVE_LOOKAHEAD];
} drive_t;
void drive_init(drive_t *drive);
#include <hardware/clocks.h>
#include <hardware/gpio.h>
#include <hardware/timer.h>
+#include <pico/multicore.h>
#include "6502.h"
#include "6522.h"
static uint8_t ram[2048];
extern uint8_t _binary__Users_max_Documents_c64_roms_dos1541_start[16384];
-extern uint8_t _binary__Users_max_Downloads_blackbird_1_2_Blackbird_1_2_d64_start[174848];
-// extern uint8_t _binary__Users_max_Downloads_3sira_still_human_by_arise_3sira_by_arise_A_d64_start[174848];
+// extern uint8_t _binary__Users_max_Downloads_blackbird_1_2_Blackbird_1_2_d64_start[174848];
+extern uint8_t _binary__Users_max_Downloads_Bloodsuckers_StillRising_BSK_StillRising_disk1_d64_start[174848];
-static uint32_t ts;
-static cpu_t cpu;
+uint32_t ts;
+cpu_t cpu;
static via_t via1;
static via_t via2;
-static drive_t drive;
+drive_t drive;
int8_t track_step;
}
}
+void drive_thread() {
+ drive_init(&drive);
+ drive.image = _binary__Users_max_Downloads_Bloodsuckers_StillRising_BSK_StillRising_disk1_d64_start;
+ multicore_fifo_push_blocking(1);
+
+ while (true) {
+ uint32_t cycles = multicore_fifo_pop_blocking_inline();
+ if (drive_cycle(&drive, cycles, true) && (via2.pcr & 0b1110) == 0b1110) {
+ cpu.flags |= 1 << FLAG_V_BIT;
+ }
+ }
+}
+
int main() {
set_sys_clock_khz(250000, true);
+ multicore_launch_core1(drive_thread);
gpio_init(GPIO_CLK);
gpio_init(GPIO_DATA);
gpio_set_irq_enabled_with_callback(GPIO_ATN, GPIO_IRQ_EDGE_RISE | GPIO_IRQ_EDGE_FALL, true, &atn_irq_callback);
track_step = 0;
- drive_init(&drive);
- drive.image = _binary__Users_max_Downloads_blackbird_1_2_Blackbird_1_2_d64_start;
+ multicore_fifo_pop_blocking();
cpu_reset(&cpu);
via_init(&via1);
ts = time_us_32();
uint16_t osc2 = 0xffff;
while (!cpu.jammed) {
- if (ts + 100 < time_us_32()) {
+ if (ts < time_us_32()) {
break;
}
uint8_t cycles = cpu_step(&cpu);
+ multicore_fifo_push_blocking_inline((uint32_t)cycles);
via_cycle(&via1, cycles);
via_cycle(&via2, cycles);
cpu.irq = via_irq(&via1) | via_irq(&via2);
- if (drive_cycle(&drive, cycles, true) && (via2.pcr & 0b1110) == 0b1110) {
- cpu.flags |= 1 << FLAG_V_BIT;
- }
-
ts += cycles;
while (ts > time_us_32()) {}
}
- gpio_put(GPIO_LED, 1);
-
return 0;
}