From f61242a17bd4ca346e19123247f405af2c6b3a75 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 16 Feb 2020 13:39:46 +0100 Subject: [PATCH] fix irq frequency in example machine (was way too fast and overlapped) --- src/main/kotlin/razorvine/c64emu/c64Main.kt | 4 ++-- .../razorvine/examplemachines/ehBasicMain.kt | 4 ++-- .../razorvine/examplemachines/machineMain.kt | 4 ++-- src/main/resources/vmdemo.asm | 18 ++++++++++++------ src/main/resources/vmdemo.prg | Bin 1096 -> 1096 bytes 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/razorvine/c64emu/c64Main.kt b/src/main/kotlin/razorvine/c64emu/c64Main.kt index 9f8ccda..b312dcd 100644 --- a/src/main/kotlin/razorvine/c64emu/c64Main.kt +++ b/src/main/kotlin/razorvine/c64emu/c64Main.kt @@ -241,11 +241,11 @@ class C64Machine(title: String) : IVirtualMachine { debugWindow.updateCpu(cpu, bus) }.start() + // we synchronise cpu cycles to the vertical blank of the Vic chip + // this should result in ~1 Mhz cpu speed val timer = java.util.Timer("cpu-cycle", true) timer.scheduleAtFixedRate(0, 1000L/VicII.framerate) { if (!paused) { - // we synchronise cpu cycles to the vertical blank of the Vic chip - // this should result in ~1 Mhz cpu speed try { while (vic.vsync) step() while (!vic.vsync) step() diff --git a/src/main/kotlin/razorvine/examplemachines/ehBasicMain.kt b/src/main/kotlin/razorvine/examplemachines/ehBasicMain.kt index 0e45c04..e89ff6f 100644 --- a/src/main/kotlin/razorvine/examplemachines/ehBasicMain.kt +++ b/src/main/kotlin/razorvine/examplemachines/ehBasicMain.kt @@ -53,7 +53,7 @@ class EhBasicMachine(title: String) { Thread.sleep(200) } else { try { - repeat(400) { step() } + repeat(500) { step() } } catch (rx: RuntimeException) { JOptionPane.showMessageDialog(hostDisplay, "Run time error: $rx", "Error during execution", JOptionPane.ERROR_MESSAGE) break @@ -61,7 +61,7 @@ class EhBasicMachine(title: String) { JOptionPane.showMessageDialog(hostDisplay, "Run time error: $ex", "Error during execution", JOptionPane.ERROR_MESSAGE) break } - Thread.sleep(1) + Thread.sleep(2) } } } diff --git a/src/main/kotlin/razorvine/examplemachines/machineMain.kt b/src/main/kotlin/razorvine/examplemachines/machineMain.kt index 800bf8b..84de2cc 100644 --- a/src/main/kotlin/razorvine/examplemachines/machineMain.kt +++ b/src/main/kotlin/razorvine/examplemachines/machineMain.kt @@ -79,7 +79,7 @@ class VirtualMachine(title: String) : IVirtualMachine { Thread.sleep(200) } else { try { - repeat(400) { step() } + repeat(500) { step() } } catch (rx: RuntimeException) { JOptionPane.showMessageDialog(hostDisplay, "Run time error: $rx", "Error during execution", JOptionPane.ERROR_MESSAGE) break @@ -87,7 +87,7 @@ class VirtualMachine(title: String) : IVirtualMachine { JOptionPane.showMessageDialog(hostDisplay, "Run time error: $ex", "Error during execution", JOptionPane.ERROR_MESSAGE) break } - Thread.sleep(1) + Thread.sleep(10) } } } diff --git a/src/main/resources/vmdemo.asm b/src/main/resources/vmdemo.asm index 6442a0e..ef3ec97 100644 --- a/src/main/resources/vmdemo.asm +++ b/src/main/resources/vmdemo.asm @@ -10,6 +10,7 @@ SCREEN_WIDTH=640 * = $1000 + irq_timer_cycles = 10000 ; every time this number of cycles passed, an IRQ occurs start sei @@ -20,11 +21,11 @@ start sta IRQVEC lda #>irq sta IRQVEC+1 - lda #<2000 - sta TIMER+1 ; every 2000 clock cycles an irq - lda #>2000 + lda #irq_timer_cycles sta TIMER+2 - lda #0 + lda #irq_timer_cycles >> 16 sta TIMER+3 lda #1 sta TIMER+0 @@ -40,7 +41,7 @@ start jsr print jmp + -_title1 .text "**** COMMODORE 64 BASIC V2 ****", 10, 10, " 64K RAM SYSTEM 38911 BASIC BYTES FREE", 10, 10, "READY.",10,0 +_title1 .text "**** COMMODORE 64 BASIC V9 ****", 10, 10, " 64K RAM SYSTEM 98765 BASIC BYTES FREE", 10, 10, "READY.",10,0 _text2 .text 10,"Nah, only joking, this is not a weird C-64.",10,"This is a working fantasy 8-bit 6502 machine though!",10 .text "Type some stuff on the keyboard, use the mouse (with Left button/Right button)", 10, "to draw/erase pixels.",10,10,0 _text3 .text "Mouse drawing and keyboard scanning: done in main program loop.",10 @@ -92,6 +93,7 @@ irq pha tya pha + ; we don't check for BRK flag because we're lazy lda DISPLAY+0 pha @@ -104,6 +106,7 @@ irq lda #<_time_msg ldy #>_time_msg jsr textout + ; read the clock now ; YEAR lda RTC+0 @@ -112,6 +115,7 @@ irq lda #DecTenThousands jsr textout + lda #'-' sta DISPLAY+2 inc DISPLAY+0 @@ -130,6 +134,7 @@ irq lda #DecTens jsr textout + lda #'/' sta DISPLAY+2 inc DISPLAY+0 @@ -157,6 +162,7 @@ irq lda #DecTens jsr textout + lda #'.' sta DISPLAY+2 inc DISPLAY+0 @@ -184,7 +190,7 @@ _time_msg .text "The current date and time is: ",0 ; ----- routines -delay ldx #50 +delay ldx #100 - ldy #0 - nop dey diff --git a/src/main/resources/vmdemo.prg b/src/main/resources/vmdemo.prg index 1930bc92262b42caeec02bdec8fc18d5e843904c..574a9cfe49eafeba344290811259f8b98d2220c0 100644 GIT binary patch delta 73 zcmX@Xae_mfL7-yM|5+>Ld;k4kDb)M_|4M;g#!D;JCyHCkSt@7&0T-8onTfYTkfX0c caAa_ZtFMBBrG>ef>BfRSCdQP_|Cu})0UACTQvd(} delta 73 zcmX@Xae_mfL7-yM|5+>Ld;k4kDb)M_|H=!!jF(ojPZYP7Gg8n30xm8EGZSxxAV*(? d;K<+*S6>AMV+%_|!;J-fOpHdG|1)_q0suF@8La>S