Human68k CUI emulator with sound.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fake_ipl.s 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. ;
  2. ; Fake IOCS / IPL ROM
  3. ;
  4. ; The emulator starts execution at $000000
  5. ;
  6. ; Some constants
  7. BusErrVecAddr equ $000008
  8. AddrErrVecAddr equ $00000c
  9. ImproperOrderVecAddr equ $000010
  10. PrivilegeViolationVecAddr equ $000020
  11. TraceExceptionVecAddr equ $000024
  12. Trap0VecAddr equ $000080
  13. Trap1VecAddr equ $000084
  14. Trap2VecAddr equ $000088
  15. Trap3VecAddr equ $00008C
  16. Trap4VecAddr equ $000090
  17. Trap5VecAddr equ $000094
  18. Trap6VecAddr equ $000098
  19. Trap7VecAddr equ $00009c
  20. Trap8VecAddr equ $0000a0
  21. Trap15VecAddr equ $0000bc
  22. VdispVecAddr equ $000118
  23. CrtcVecAddr equ $000138
  24. DMA3IntVecAddr equ $0001a8
  25. DMA3ErrIntVecAddr equ $0001ac
  26. IOCSCallVecTable equ $000400
  27. IOCSWorkDMA3Mode equ $000c32
  28. IOCSWorkDMA3Err equ $000c33
  29. DefaultStackAddr equ $002000
  30. HumanStart equ $006800
  31. DMA3Regs equ $e840c0
  32. I8255ControlWord equ $e9a007
  33. ADPCMCommand equ $e92001
  34. FakeIOCSCallPort equ $ea0004
  35. .text
  36. IPLStart:
  37. .dc.l DefaultStackAddr ; Default stack top
  38. EntryPointPtr
  39. .dc.l EntryPoint ; PC at boot
  40. BootBusErrVec:
  41. .dc.l DefaultExceptionHandler
  42. BootAddressErrVec:
  43. .dc.l DefaultExceptionHandler
  44. BootImproperOrderVec:
  45. .dc.l DefaultExceptionHandler
  46. BootDivideBy0Vec:
  47. .dc.l $00000000
  48. BootCHKCmdVec:
  49. .dc.l $00000000
  50. BootTRAPVccVec:
  51. .dc.l $00000000
  52. BootPrivilegeViolationVec:
  53. .dc.l DefaultExceptionHandler
  54. BootTraceExceptionVec:
  55. .dc.l DefaultExceptionHandler
  56. BootLineAVec:
  57. .dc.l $00000000
  58. BootLineFVec:
  59. .dc.l $00000000
  60. EntryPoint: ; Boot entry point
  61. move.w #$2700,sr
  62. lea.l (DefaultStackAddr),a7
  63. reset
  64. bsr SetupExceptions
  65. bsr SetupTraps
  66. bsr SetupInterrupts
  67. bsr SetupIOCSCalls
  68. jmp HumanStart ; Go to DOS
  69. ;
  70. ; Exceptions
  71. ;
  72. SetupExceptions:
  73. lea.l (DefaultExceptionHandler), a1
  74. move.l a1, (BusErrVecAddr)
  75. lea.l (DefaultExceptionHandler), a1
  76. move.l a1, (AddrErrVecAddr)
  77. lea.l (DefaultExceptionHandler), a1
  78. move.l a1, (ImproperOrderVecAddr)
  79. lea.l (DefaultExceptionHandler), a1
  80. move.l a1, (PrivilegeViolationVecAddr)
  81. lea.l (DefaultExceptionHandler), a1
  82. move.l a1, (TraceExceptionVecAddr)
  83. rts
  84. DefaultExceptionHandler:
  85. stop #$2000
  86. bra DefaultExceptionHandler
  87. rte
  88. ;
  89. ; IOCS Calls
  90. ;
  91. SetupIOCSCalls:
  92. ; Set all 256 IOCS call handlers to the fake handler
  93. lea.l (IOCSCallVecTable),a1
  94. move.w #$00ff,d1
  95. @@:
  96. lea.l (FakeIOCSCallHandler), a2
  97. move.l a2,(a1)+ ; Fill all 256 DOS calls with the fake handler
  98. dbra.w d1,@b
  99. rts
  100. FakeTrap15Handler:
  101. movem.l a1,-(sp)
  102. and.w #$00ff, d0
  103. add.w d0, d0
  104. add.w d0, d0
  105. lea.l (IOCSCallVecTable), a1
  106. add.l d0, a1
  107. jsr (a1)
  108. movem.l (sp)+,a1
  109. rte
  110. FakeIOCSCallHandler:
  111. move.w d0, (FakeIOCSCallPort)
  112. rts
  113. ;
  114. ; Traps
  115. ;
  116. SetupTraps:
  117. lea.l (DefaultTrapHandler), a1
  118. move.l a1, (Trap0VecAddr)
  119. lea.l (DefaultTrapHandler), a1
  120. move.l a1, (Trap1VecAddr)
  121. lea.l (DefaultTrapHandler), a1
  122. move.l a1, (Trap2VecAddr)
  123. lea.l (DefaultTrapHandler), a1
  124. move.l a1, (Trap3VecAddr)
  125. lea.l (DefaultTrapHandler), a1
  126. move.l a1, (Trap4VecAddr)
  127. lea.l (DefaultTrapHandler), a1
  128. move.l a1, (Trap5VecAddr)
  129. lea.l (DefaultTrapHandler), a1
  130. move.l a1, (Trap6VecAddr)
  131. lea.l (DefaultTrapHandler), a1
  132. move.l a1, (Trap7VecAddr)
  133. lea.l (DefaultTrapHandler), a1
  134. move.l a1, (Trap8VecAddr)
  135. lea.l (FakeTrap15Handler), a1
  136. move.l a1, (Trap15VecAddr)
  137. rts
  138. DefaultTrapHandler:
  139. rte
  140. ;
  141. ; Interrupts
  142. ;
  143. SetupInterrupts:
  144. lea.l (DefaultIntHandler), a1
  145. move.l a1, (VdispVecAddr)
  146. lea.l (DefaultIntHandler), a1
  147. move.l a1, (CrtcVecAddr)
  148. lea.l (DMA3Interrupt), a1
  149. move.l a1, (DMA3IntVecAddr)
  150. lea.l (DMA3Interrupt), a1
  151. move.l a1, (DMA3ErrIntVecAddr)
  152. rts
  153. DefaultIntHandler:
  154. rte
  155. DMA3Interrupt:
  156. move.l a0,-(a7)
  157. lea.l (DMA3Regs),a0
  158. move.b ($0001,a0),(IOCSWorkDMA3Err)
  159. tst.b (IOCSWorkDMA3Mode)
  160. bmi.s @f
  161. move.b #$01,(I8255ControlWord)
  162. move.b #$03,(I8255ControlWord)
  163. move.b #$01,(ADPCMCommand)
  164. @@:
  165. tst.b (a0)
  166. st.b (a0)
  167. clr.b (IOCSWorkDMA3Mode)
  168. movea.l (a7)+,a0
  169. rte