Skip to content

Commit c897ba5

Browse files
committed
Impove accurate DSK/Hawk
Can now boot WIPL and LOAD again. Might even be getting slightly futher, because I added interrupts.
1 parent 14898fd commit c897ba5

File tree

6 files changed

+383
-186
lines changed

6 files changed

+383
-186
lines changed

centurion.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -817,15 +817,18 @@ int main(int argc, char *argv[])
817817
if (cpu6_halted())
818818
halt_system();
819819
/* Service DMA */
820-
if (hawk_dma == 1) {
821-
if (dma_read_cycle(hawk_read_next()))
822-
hawk_dma_done();
823-
}
824-
if (hawk_dma == 2) {
825-
if (dma_write_active())
826-
hawk_write_next(dma_write_cycle());
827-
else
828-
hawk_dma_done();
820+
if (hawk_dma) {
821+
while(dma_write_active()) {
822+
// Advance time to next scheduler event
823+
int64_t next = scheduler_next();
824+
if (next == -1) {
825+
fprintf(stderr, "DMA stalled\n");
826+
exit(-1);
827+
}
828+
cpu_timestamp_ns = next;
829+
run_scheduler(cpu_timestamp_ns, trace & TRACE_SCHEDULER);
830+
}
831+
hawk_dma_done();
829832
}
830833
/* Floppy controller command host to controller */
831834
if (fd_dma == 1) {

cpu6.c

+11
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ uint16_t cpu6_dma_count(void) {
102102
return ~dma_count;
103103
}
104104

105+
void cpu6_dma_write(uint8_t byte) {
106+
/* DMA is done when it incs to 0 */
107+
if (dma_enable == 0 || ++dma_count == 0) {
108+
dma_enable = 0;
109+
return;
110+
}
111+
if (dma_enable) {
112+
mem_write8(dma_addr++, byte);
113+
}
114+
}
115+
105116
/*
106117
* When packed into C, the flags live in the upper 4 bits of the low byte
107118
*/

cpu6.h

+2
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ extern void cpu_assert_irq(unsigned ipl);
5050
extern void cpu_deassert_irq(unsigned ipl);
5151
extern void advance_time(uint64_t nanoseconds);
5252
extern uint16_t cpu6_dma_count(void);
53+
extern void cpu6_dma_write(uint8_t);
54+
extern uint8_t cpu6_dma_read(void);

0 commit comments

Comments
 (0)