vitorsilverio / vsgb

A simple gameboy emulator
10 stars 2 forks source link

Test 02-interrupts #3

Closed vitorsilverio closed 5 years ago

vitorsilverio commented 5 years ago

Based on test http://gbdev.gg8.se/files/roms/blargg-gb-tests/cpu_instrs.zip

; Tests DI, EI, and HALT (STOP proved untestable)

.include "shell.inc"

main:
     wreg IE,$04

     set_test 2,"EI"
     ei
     ld   bc,0
     push bc
     pop  bc
     inc  b
     wreg IF,$04
interrupt_addr:
     dec  b
     jp   nz,test_failed
     ld   hl,sp-2
     ldi  a,(hl)
     cp   <interrupt_addr
     jp   nz,test_failed
     ld   a,(hl)
     cp   >interrupt_addr
     jp   nz,test_failed
     lda  IF
     and  $04
     jp   nz,test_failed

     set_test 3,"DI"
     di
     ld   bc,0
     push bc
     pop  bc
     wreg IF,$04
     ld   hl,sp-2
     ldi  a,(hl)
     or   (hl)
     jp   nz,test_failed
     lda  IF
     and  $04
     jp   z,test_failed

     set_test 4,"Timer doesn't work"
     wreg TAC,$05
     wreg TIMA,0
     wreg IF,0
     delay 500
     lda  IF
     delay 500
     and  $04
     jp   nz,test_failed
     delay 500
     lda  IF
     and  $04
     jp   z,test_failed
     pop  af

     set_test 5,"HALT"
     wreg TAC,$05
     wreg TIMA,0
     wreg IF,0
     halt      ; timer interrupt will exit halt
     nop       ; avoids DMG bug
     lda  IF
     and  $04
     jp   z,test_failed

     jp   tests_passed

.bank 0 slot 0
.org $50
     inc a
     ret
vitorsilverio commented 5 years ago

Just freezes

vitorsilverio commented 5 years ago

Halt stops the program

vitorsilverio commented 5 years ago

The timer interrupt routine is:

inc a
ret
vitorsilverio commented 5 years ago

Found the issue, never left the halt status

vitorsilverio commented 5 years ago

Fixed by 7f4ea10d4b7e9f241e45b7af59b18161504005c3 image