mirror of
https://github.com/irmen/ksim65.git
synced 2025-02-07 18:30:48 +00:00
fix irq frequency in example machine (was way too fast and overlapped)
This commit is contained in:
parent
d940b9d136
commit
f61242a17b
@ -241,11 +241,11 @@ class C64Machine(title: String) : IVirtualMachine {
|
|||||||
debugWindow.updateCpu(cpu, bus)
|
debugWindow.updateCpu(cpu, bus)
|
||||||
}.start()
|
}.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)
|
val timer = java.util.Timer("cpu-cycle", true)
|
||||||
timer.scheduleAtFixedRate(0, 1000L/VicII.framerate) {
|
timer.scheduleAtFixedRate(0, 1000L/VicII.framerate) {
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
// we synchronise cpu cycles to the vertical blank of the Vic chip
|
|
||||||
// this should result in ~1 Mhz cpu speed
|
|
||||||
try {
|
try {
|
||||||
while (vic.vsync) step()
|
while (vic.vsync) step()
|
||||||
while (!vic.vsync) step()
|
while (!vic.vsync) step()
|
||||||
|
@ -53,7 +53,7 @@ class EhBasicMachine(title: String) {
|
|||||||
Thread.sleep(200)
|
Thread.sleep(200)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
repeat(400) { step() }
|
repeat(500) { step() }
|
||||||
} catch (rx: RuntimeException) {
|
} catch (rx: RuntimeException) {
|
||||||
JOptionPane.showMessageDialog(hostDisplay, "Run time error: $rx", "Error during execution", JOptionPane.ERROR_MESSAGE)
|
JOptionPane.showMessageDialog(hostDisplay, "Run time error: $rx", "Error during execution", JOptionPane.ERROR_MESSAGE)
|
||||||
break
|
break
|
||||||
@ -61,7 +61,7 @@ class EhBasicMachine(title: String) {
|
|||||||
JOptionPane.showMessageDialog(hostDisplay, "Run time error: $ex", "Error during execution", JOptionPane.ERROR_MESSAGE)
|
JOptionPane.showMessageDialog(hostDisplay, "Run time error: $ex", "Error during execution", JOptionPane.ERROR_MESSAGE)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
Thread.sleep(1)
|
Thread.sleep(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class VirtualMachine(title: String) : IVirtualMachine {
|
|||||||
Thread.sleep(200)
|
Thread.sleep(200)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
repeat(400) { step() }
|
repeat(500) { step() }
|
||||||
} catch (rx: RuntimeException) {
|
} catch (rx: RuntimeException) {
|
||||||
JOptionPane.showMessageDialog(hostDisplay, "Run time error: $rx", "Error during execution", JOptionPane.ERROR_MESSAGE)
|
JOptionPane.showMessageDialog(hostDisplay, "Run time error: $rx", "Error during execution", JOptionPane.ERROR_MESSAGE)
|
||||||
break
|
break
|
||||||
@ -87,7 +87,7 @@ class VirtualMachine(title: String) : IVirtualMachine {
|
|||||||
JOptionPane.showMessageDialog(hostDisplay, "Run time error: $ex", "Error during execution", JOptionPane.ERROR_MESSAGE)
|
JOptionPane.showMessageDialog(hostDisplay, "Run time error: $ex", "Error during execution", JOptionPane.ERROR_MESSAGE)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
Thread.sleep(1)
|
Thread.sleep(10)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
SCREEN_WIDTH=640
|
SCREEN_WIDTH=640
|
||||||
|
|
||||||
* = $1000
|
* = $1000
|
||||||
|
irq_timer_cycles = 10000 ; every time this number of cycles passed, an IRQ occurs
|
||||||
|
|
||||||
start
|
start
|
||||||
sei
|
sei
|
||||||
@ -20,11 +21,11 @@ start
|
|||||||
sta IRQVEC
|
sta IRQVEC
|
||||||
lda #>irq
|
lda #>irq
|
||||||
sta IRQVEC+1
|
sta IRQVEC+1
|
||||||
lda #<2000
|
lda #<irq_timer_cycles
|
||||||
sta TIMER+1 ; every 2000 clock cycles an irq
|
sta TIMER+1
|
||||||
lda #>2000
|
lda #>irq_timer_cycles
|
||||||
sta TIMER+2
|
sta TIMER+2
|
||||||
lda #0
|
lda #irq_timer_cycles >> 16
|
||||||
sta TIMER+3
|
sta TIMER+3
|
||||||
lda #1
|
lda #1
|
||||||
sta TIMER+0
|
sta TIMER+0
|
||||||
@ -40,7 +41,7 @@ start
|
|||||||
jsr print
|
jsr print
|
||||||
jmp +
|
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
|
_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
|
.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
|
_text3 .text "Mouse drawing and keyboard scanning: done in main program loop.",10
|
||||||
@ -92,6 +93,7 @@ irq
|
|||||||
pha
|
pha
|
||||||
tya
|
tya
|
||||||
pha
|
pha
|
||||||
|
|
||||||
; we don't check for BRK flag because we're lazy
|
; we don't check for BRK flag because we're lazy
|
||||||
lda DISPLAY+0
|
lda DISPLAY+0
|
||||||
pha
|
pha
|
||||||
@ -104,6 +106,7 @@ irq
|
|||||||
lda #<_time_msg
|
lda #<_time_msg
|
||||||
ldy #>_time_msg
|
ldy #>_time_msg
|
||||||
jsr textout
|
jsr textout
|
||||||
|
|
||||||
; read the clock now
|
; read the clock now
|
||||||
; YEAR
|
; YEAR
|
||||||
lda RTC+0
|
lda RTC+0
|
||||||
@ -112,6 +115,7 @@ irq
|
|||||||
lda #<DecTenThousands
|
lda #<DecTenThousands
|
||||||
ldy #>DecTenThousands
|
ldy #>DecTenThousands
|
||||||
jsr textout
|
jsr textout
|
||||||
|
|
||||||
lda #'-'
|
lda #'-'
|
||||||
sta DISPLAY+2
|
sta DISPLAY+2
|
||||||
inc DISPLAY+0
|
inc DISPLAY+0
|
||||||
@ -130,6 +134,7 @@ irq
|
|||||||
lda #<DecTens
|
lda #<DecTens
|
||||||
ldy #>DecTens
|
ldy #>DecTens
|
||||||
jsr textout
|
jsr textout
|
||||||
|
|
||||||
lda #'/'
|
lda #'/'
|
||||||
sta DISPLAY+2
|
sta DISPLAY+2
|
||||||
inc DISPLAY+0
|
inc DISPLAY+0
|
||||||
@ -157,6 +162,7 @@ irq
|
|||||||
lda #<DecTens
|
lda #<DecTens
|
||||||
ldy #>DecTens
|
ldy #>DecTens
|
||||||
jsr textout
|
jsr textout
|
||||||
|
|
||||||
lda #'.'
|
lda #'.'
|
||||||
sta DISPLAY+2
|
sta DISPLAY+2
|
||||||
inc DISPLAY+0
|
inc DISPLAY+0
|
||||||
@ -184,7 +190,7 @@ _time_msg .text "The current date and time is: ",0
|
|||||||
|
|
||||||
|
|
||||||
; ----- routines
|
; ----- routines
|
||||||
delay ldx #50
|
delay ldx #100
|
||||||
- ldy #0
|
- ldy #0
|
||||||
- nop
|
- nop
|
||||||
dey
|
dey
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user