]> Untitled Git - pico1541.git/commitdiff
Fix byte ready to CPU overflow flag sync main
authorMaxwell Beck <max@rastertail.net>
Mon, 30 Dec 2024 23:44:29 +0000 (17:44 -0600)
committerMaxwell Beck <max@rastertail.net>
Mon, 30 Dec 2024 23:44:29 +0000 (17:44 -0600)
CMakeLists.txt
src/drive.c
src/drive.h
src/pico1541.c

index 0f4a923d8b961d4f189e3ab9f64dd94a331d1d77..fdff7141db20907db4e1729b24f9d540cc1f4259 100644 (file)
@@ -5,7 +5,7 @@ include(pico_sdk_import.cmake)
 project(pico1541 VERSION 0.1.0)
 pico_sdk_init()
 
 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
 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
index 64b765aeba0197b95f429f107847eec9cda40ba6..5bc2e3b08c43f1d47d0a3adb2a083ccf75459be0 100644 (file)
@@ -47,7 +47,7 @@ void drive_init(drive_t *drive) {
        drive->current_idx = 0;
        drive->lookahead_idx = 0;
 
        drive->current_idx = 0;
        drive->lookahead_idx = 0;
 
-       drive_cycle(drive, 0, false);
+       drive_cycle(drive);
 }
 
 void drive_step_up(drive_t *drive) {
 }
 
 void drive_step_up(drive_t *drive) {
@@ -68,16 +68,19 @@ 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) {
        bool byte_ready = false;
        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];
        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];
@@ -194,6 +197,4 @@ bool drive_cycle(drive_t *drive, uint8_t cycles, bool advance) {
                drive->lookahead_idx = j;
                drive->timer = timer_next;
        }
                drive->lookahead_idx = j;
                drive->timer = timer_next;
        }
-
-       return byte_ready;
 }
 }
index e131c5c5ef2bf2fb5f5c38121d7af429a24dd277..aa72f605d789415a820ef9f6a2dca89b8a34128d 100644 (file)
@@ -42,6 +42,7 @@ typedef struct drive_s {
 void drive_init(drive_t *drive);
 void drive_step_up(drive_t *drive);
 void drive_step_down(drive_t *drive);
 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
 
 #endif
\ No newline at end of file
index 3489feeb3abde43fc6914fa3df50844ec8850e60..fec76a37c578a09777d5e5379863c2291e6db116 100644 (file)
@@ -18,7 +18,7 @@ const uint8_t DEVICE = 8;
 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];
 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;
 
 uint32_t ts;
 cpu_t cpu;
@@ -138,14 +138,11 @@ void atn_irq_callback(uint pin, uint32_t flags) {
 
 void drive_thread() {
        drive_init(&drive);
 
 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);
 
        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);
        }
 }
 
        }
 }
 
@@ -192,7 +189,10 @@ int main() {
                }
 
                uint8_t cycles = cpu_step(&cpu);
                }
 
                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);
 
                via_cycle(&via1, cycles);
                via_cycle(&via2, cycles);