skiselev / 8088_bios

BIOS for Intel 8088 based computers
GNU General Public License v3.0
513 stars 61 forks source link

3-Demon compatibility #44

Closed jinshin closed 11 months ago

jinshin commented 1 year ago

Hi! I'm really not sure if that could be considered as bug. There's a game, called 3-Demon, that shows garbled sprites when run on Book8088 with your BIOS (and stolen one with wiped copyrights as well) I've done some reversing, and found that it's timer proc, installed on 1Ch, doesn't save DS, AX and DX registers. Modifying code to save those fixed the glitch. I was wondering why the author didn't save registers and found that in original 5160 BIOS those are preserved

TIMER_INT   PROC    FAR
    STI             ; INTERRUPTS BACK ON
    PUSH    DS
    PUSH    AX
    PUSH    DX          ; SAVE MACHINE STATE
    CALL    DDS
    INC TIMER_LOW       ; INCREMENT TIME
    JNZ T4          ; TEST_DAY
    INC TIMER_HIGH      ; INCREMENT HIGH WORD OF TIME
T4:                 ; TEST_DAY
    CMP TIMER_HIGH,018H     ; TEST FOR COUNT EQUALING 24 HOURS
    JNZ T5          ; DISKETTE_CTL
    CMP TIMER_LOW,0B0H
    JNZ T5          ; DISKETTE_CTL

;------  TIMER HAS GONE 24 HOURS

    SUB AX,AX
    MOV TIMER_HIGH,AX
    MOV TIMER_LOW,AX
    MOV TIMER_OFL,1

;------ TEST FOR DISKETTE TIME OUT

T5:                 ; DISKETTE_CTL
    DEC MOTOR_COUNT
    JNZ T6          ; RETURN IF COUNT NOT OUT
    AND MOTOR_STATUS,0F0H   ; TURN OFF MOTOR RUNNING BITS
    MOV AL,0CH
    MOV DX,03F2H        ; FDC CTL PORT
    OUT DX,AL           ; TURN OFF THE MOTOR
T6:                 ; TIMER_RET
    INT 1CH         ; TRANSFER CONTROL TO A USER ROUTINE
    MOV AL,EOI
    OUT 020H,AL         ; END OF INTERRUPT TO 8259
    POP DX
    POP AX
    POP DS          ; RESET MACHINE STATE
    IRET                ; RETURN FROM INTERRUPT
TIMER_INT   ENDP 

Maybe you could consider adding DX push/pop to your BIOS int_08 routine to fix that incompatibility?

Best, Serhii

skiselev commented 11 months ago

Thanks for the reporting! I moved PUSH DX/POP DX instructions, so that DX register is restored after calling INT 1Ch. Please test