Difference between revisions of "Spice86"

From Stunts Wiki
Line 9: Line 9:
 
seg012.asm-3514-    mov    dx, 2E9Ch      ; Frequency for the PIT. 1193182 / 0x2e9c ~= 99.998 Hz
 
seg012.asm-3514-    mov    dx, 2E9Ch      ; Frequency for the PIT. 1193182 / 0x2e9c ~= 99.998 Hz
 
[...]
 
[...]
seg012.asm-3555-    mov    al, 0B6h
+
seg012.asm-3555-    mov    al, 0B6h       ; Set up channel 2 (PC Speaker). Unrelated, included for reference.
seg012.asm:3556:    out    43h, al        ; Sets channel 2 (PC Speaker) to opmode = 3 (square wave)
+
seg012.asm:3556:    out    43h, al        ; Set channel 2 to opmode = 3 (square wave)
 
[...]
 
[...]
seg012.asm-3580-    out    21h, al        ; Interrupt controller, 8259A.
 
seg012.asm-3581-    sti
 
 
seg012.asm-3582-    mov    al, dl
 
seg012.asm-3582-    mov    al, dl
 
seg012.asm:3583:    out    40h, al        ; Timer 8253-5 (AT: 8254.2).
 
seg012.asm:3583:    out    40h, al        ; Timer 8253-5 (AT: 8254.2).
Line 21: Line 19:
 
seg012.asm-3621-    out    21h, al        ; Interrupt controller, 8259A.
 
seg012.asm-3621-    out    21h, al        ; Interrupt controller, 8259A.
 
seg012.asm-3622-    sti
 
seg012.asm-3622-    sti
seg012.asm-3623-    mov    al, 0          ; Reset frequency to ~18 Hz
+
seg012.asm-3623-    mov    al, 0          ; Reset frequency to 1193182 / 65536 ~= 18.2 Hz
 
seg012.asm:3624:    out    40h, al        ; Timer 8253-5 (AT: 8254.2).
 
seg012.asm:3624:    out    40h, al        ; Timer 8253-5 (AT: 8254.2).
 
seg012.asm:3625:    out    40h, al        ; Timer 8253-5 (AT: 8254.2).
 
seg012.asm:3625:    out    40h, al        ; Timer 8253-5 (AT: 8254.2).

Revision as of 15:40, 1 March 2025

Spice86 is an experimental emulator, whose support for Stunts is being worked on as of 2025. At present (2025-03-01) it can start the game, but no sound is played (start with -a /ns to avoid wasting cycles on that) Additionally, one must give the parameter --InstructionsPerSecond 5000000.

The reason for this workaround is that Stunts activates interrupts in the middle of the int 8 handler (see here), so another int 8 can could be triggered in between. This interrupt corresponds to the programmable interrupt timer, which Stunts sets at 100 Hz. So if the int 8 handler needs more than 1/100 seconds to run, disaster ensues. This probably never happens on real CPUs, but might occur if the emulator's simulated CPU is too slow with respect to the simulated PIT.

Here a dump the relevant snippets, which should eventually go elsewhere

seg012.asm-3514-    mov     dx, 2E9Ch      ; Frequency for the PIT. 1193182 / 0x2e9c ~= 99.998 Hz
[...]
seg012.asm-3555-    mov     al, 0B6h        ; Set up channel 2 (PC Speaker). Unrelated, included for reference.
seg012.asm:3556:    out     43h, al         ; Set channel 2 to opmode = 3 (square wave)
[...]
seg012.asm-3582-    mov     al, dl
seg012.asm:3583:    out     40h, al         ; Timer 8253-5 (AT: 8254.2).
seg012.asm-3584-    mov     al, dh
seg012.asm:3585:    out     40h, al         ; Timer 8253-5 (AT: 8254.2).
--
seg012.asm-3621-    out     21h, al         ; Interrupt controller, 8259A.
seg012.asm-3622-    sti
seg012.asm-3623-    mov     al, 0           ; Reset frequency to 1193182 / 65536 ~= 18.2 Hz
seg012.asm:3624:    out     40h, al         ; Timer 8253-5 (AT: 8254.2).
seg012.asm:3625:    out     40h, al         ; Timer 8253-5 (AT: 8254.2).

Relevant docs