main.code.asm 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ; Main starting point
  2. Main proc
  3. ld a,i
  4. ld (SaveI),a
  5. ld (SaveSP),sp
  6. call SetupIM2
  7. ; This is a prerequisite for all others
  8. call TestCycPerFrame
  9. ; First battery of tests: Interrupt Ack timing
  10. call TestAckTiming
  11. ; Second battery of tests: VRAM access timing
  12. call TestVRAMTiming
  13. xor a
  14. ;jp Finish
  15. ; Fall through instead
  16. endp
  17. ; Clean up and exit (A=exit code)
  18. Finish proc
  19. di
  20. ld sp,(SaveSP)
  21. ld (DAC+2),a ; Save exit code
  22. in a,(99h) ; Ensure we're in phase with the VDP port
  23. ex (sp),hl ; Delay (1/2)
  24. ld a,0
  25. out (99h),a ; Select status register 0
  26. ex (sp),hl ; Delay (2/2)
  27. ld a,128+15
  28. out (99h),a ; In V9938, write to register 15
  29. ; In MSX1 type VDPs, this is written to register 7
  30. ; so we need to restore it
  31. ex (sp),hl ; Delay (1/2)
  32. ld a,(RG0SAV+7)
  33. out (99h),a ; Retrieve saved value
  34. ex (sp),hl ; Delay (2/2)
  35. ld a,128+7
  36. out (99h),a ; Restore register 7
  37. ei
  38. im 1
  39. xor a
  40. ld (DAC+3),a
  41. ld l,a
  42. ld h,a
  43. ld (DAC),hl
  44. ld (DAC+4),hl
  45. ld (DAC+6),hl
  46. ld a,2
  47. ld (VALTYP),a
  48. ld a,(SaveI)
  49. ld i,a
  50. ret
  51. endp