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/bsk1.o)
+add_executable(pico1541 src/pico1541.c src/6502.c src/6522.c src/drive.c testbin/1541.o testbin/memento_mori.o)
pico_set_binary_type(pico1541 copy_to_ram)
target_link_libraries(pico1541 pico_runtime pico_multicore hardware_timer)
pico_add_extra_outputs(pico1541)
\ No newline at end of file
drive->current_idx = 0;
drive->lookahead_idx = 0;
- drive_cycle(drive, 0, false);
+ drive_cycle(drive);
}
void drive_step_up(drive_t *drive) {
}
}
-bool drive_cycle(drive_t *drive, uint8_t cycles, bool advance) {
+bool drive_advance(drive_t *drive, uint8_t cycles) {
bool byte_ready = false;
- if (advance) {
- for (uint8_t i = 0; i < cycles; i++) {
- uint8_t j = (i + drive->current_idx) & (DRIVE_LOOKAHEAD - 1);
- byte_ready |= drive->byte_ready[j];
- }
- drive->current_idx = (drive->current_idx + cycles) & (DRIVE_LOOKAHEAD - 1);
+
+ for (uint8_t i = 0; i < cycles; i++) {
+ uint8_t j = (i + drive->current_idx) & (DRIVE_LOOKAHEAD - 1);
+ byte_ready |= drive->byte_ready[j];
}
+ drive->current_idx = (drive->current_idx + cycles) & (DRIVE_LOOKAHEAD - 1);
+ return byte_ready;
+}
+
+void drive_cycle(drive_t *drive) {
while (drive->lookahead_idx != ((drive->current_idx - 1) & (DRIVE_LOOKAHEAD - 1))) {
uint8_t j = (drive->lookahead_idx + 1) & (DRIVE_LOOKAHEAD - 1);
uint8_t timer_next = drive->timer + BITRATE_PER_TRACK[drive->track];
drive->lookahead_idx = j;
drive->timer = timer_next;
}
-
- return byte_ready;
}
void drive_init(drive_t *drive);
void drive_step_up(drive_t *drive);
void drive_step_down(drive_t *drive);
-bool drive_cycle(drive_t *drive, uint8_t cycles, bool advance);
+bool drive_advance(drive_t *drive, uint8_t cycles);
+void drive_cycle(drive_t *drive);
#endif
\ No newline at end of file
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_Bloodsuckers_StillRising_BSK_StillRising_disk1_d64_start[174848];
+extern uint8_t _binary__Users_max_Downloads_MementoMori_GP_MementoMori_GP_Disk1_d64_start[174848];
uint32_t ts;
cpu_t cpu;
void drive_thread() {
drive_init(&drive);
- drive.image = _binary__Users_max_Downloads_Bloodsuckers_StillRising_BSK_StillRising_disk1_d64_start;
+ drive.image = _binary__Users_max_Downloads_MementoMori_GP_MementoMori_GP_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;
- }
+ while (multicore_fifo_pop_blocking_inline()) {
+ drive_cycle(&drive);
}
}
}
uint8_t cycles = cpu_step(&cpu);
- multicore_fifo_push_blocking_inline((uint32_t)cycles);
+ if (drive_advance(&drive, cycles) && (via2.pcr & 0b1110) == 0b1110) {
+ cpu.flags |= 1 << FLAG_V_BIT;
+ }
+ multicore_fifo_push_blocking_inline(1);
via_cycle(&via1, cycles);
via_cycle(&via2, cycles);