Advertisement
Nightseeker

Mortal Kombat II (32X) code fragment

Mar 12th, 2020
1,232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                  t,r0
  2.     mov.l   r0,@r15         ; PC
  3.     mov ##$f0,r0
  4.     mov.l   r0,@(4,r15)     ; SR
  5.  
  6.     mov.l   ##_DMAOPERATION,r1
  7.     mov #0,r0
  8.     mov.l   r0,@r1          ; DMA off
  9.  
  10.     mov.l   ##_DMACHANNEL0,r1
  11.     mov #0,r0
  12.     mov.l   r0,@r1
  13.  
  14.     mov.l   ##%0100010011100000,r1
  15.     mov.l   r0,@r1          ; Channel control
  16.  
  17.     rte
  18.     nop
  19.  
  20. mars_reset
  21.     mov.l   ##_FRT,r1       ; System Reset
  22.     mov.b   @(_TOCR,r1),r0      ;
  23.     or  #$01,r0         ;
  24.     mov.b   r0,@(_TOCR,r1)      ;
  25. vresloop:
  26.     bra vresloop
  27.     nop
  28.  
  29.     littab
  30.  
  31. ;============================================================================
  32.     cnop    0,4
  33. M_vint:
  34.     PUSH_PR
  35.  
  36.     if PSYQ=1
  37.     trapa   #$21        ; Psyq
  38.     endif
  39.  
  40.     mov.l   ##_sysreg,r0
  41.     ldc r0,gbr
  42.  
  43.     mov.l   ##$f0,r0
  44.     ldc r0,sr       ;mask off all IRQS
  45.  
  46.     mov.w   r0,@(vintclr,gbr)   ; V interrupt clear
  47.     mov.l   ##_FRT,r1
  48.     mov.l   #$02,r0         ; Toggle FRT bit for future IRQs
  49.     mov.b   r0,@(_TOCR,r1)      ;  as required
  50.     mov.w   @(vintclr,gbr),r0   ; V interrupt clear
  51.     mov.b   @(_TOCR,r1),r0      ;  as required
  52.  
  53.     mov.l   ##Mframe,r0     ; INC frame counter
  54.     mov.l   @r0,r1
  55.     add #1,r1
  56.     mov.l   r1,@r0
  57.  
  58.     nop
  59.     nop
  60.     nop
  61.     nop
  62.     POP_PR
  63.     rts
  64.     nop
  65.  
  66. ;============================================================================
  67.     cnop    0,4
  68. M_hint:
  69.     mov.l   ##_sysreg,r0
  70.     ldc r0,gbr
  71.  
  72.     mov.w   r0,@(hintclr,gbr)   ; H interrupt clear
  73.     mov.l   ##_FRT,r1
  74.     mov.l   #$02,r0         ;toggle FRT bit for future IRQs
  75.     mov.b   r0,@(_TOCR,r1)      ;as required
  76.     mov.w   @(hintclr,gbr),r0   ; V interrupt clear
  77.     mov.b   @(_TOCR,r1),r0      ;as required
  78.  
  79.     nop
  80.     nop
  81.     nop
  82.     nop
  83.     nop
  84.     nop
  85.     rts
  86.     nop
  87.  
  88. ;============================================================================
  89.     cnop    0,4
  90. M_cmdint:
  91.     PUSH    r3
  92.  
  93.  
  94. ;    mov.l   ##_palette,r0       ; Set colour 0 to another colour
  95. ;    mov     ##$8888,r1
  96. ;    mov.w   r1,@r0
  97.  
  98.  
  99. ;    mov.l   ##_DMAOPERATION,r1
  100. ;    mov     #0,r0
  101. ;    mov.l   r0,@r1          ; DMA off
  102. ;
  103. ;    mov.l   ##_DMACHANNEL0,r1
  104. ;    mov     #0,r0
  105. ;    mov.l   r0,@r1
  106. ;    mov.l   ##%0100010011100000,r0
  107. ;    mov.l   r0,@r1          ; All Channel off
  108.  
  109.  
  110.  
  111.     mov.l   ##_SYSREG,r0        ; GBR = SYSREG base
  112.     ldc r0,gbr
  113.  
  114.  
  115.     mov.w   r0,@(cmdintclr,gbr) ; CMD interrupt clear
  116.     mov.l   ##_FRT,r1
  117.     mov.l   #$02,r0         ;toggle FRT bit for future IRQs
  118.     mov.b   r0,@(_TOCR,r1)      ;as required
  119.     mov.w   @(cmdintclr,gbr),r0 ; V interrupt clear
  120.     mov.b   @(_TOCR,r1),r0      ;as required
  121.  
  122.  
  123.  
  124.  
  125.  
  126.     mov.l   ##mstruct,r1        ; R1 = MSTRUCT ptr
  127.     mov.l   ##MSTRUCT_SIZE,r2   ; R2 = Bytes to receive
  128. .rlp
  129.     mov #M_OK,r0        ; I'm OK now
  130.     mov.w   r0,@(COMM2,gbr)
  131.  
  132. .waitb  mov.w   @(COMM0,gbr),r0     ; Wait for GENESIS to be BUSY
  133.     extu.w  r0,r0
  134.     cmp/eq  #M_BUSY,r0
  135.     bf  .waitb
  136.  
  137.     mov #M_BUSY,r0      ; I'm BUSY now
  138.     mov.w   r0,@(COMM2,gbr)
  139.  
  140. .waito  mov.w   @(COMM0,gbr),r0     ; Wait for GENESIS to be OK
  141.     extu.w  r0,r0
  142.     cmp/eq  #M_OK,r0
  143.     bf  .waito
  144.  
  145.     mov #5*2,r0         ; Enough left to rec all COMM ports?
  146.     cmp/ge  r0,r2
  147.     bf  .finishoff      ; No
  148.  
  149.     mov.w   @(COMM4,gbr),r0     ; Receive 5 words
  150.     mov.w   r0,@r1
  151.     add #2,r1
  152.     mov.w   @(COMM6,gbr),r0
  153.     mov.w   r0,@r1
  154.     add #2,r1
  155.     mov.w   @(COMM8,gbr),r0
  156.     mov.w   r0,@r1
  157.     add #2,r1
  158.     mov.w   @(COMM10,gbr),r0
  159.     mov.w   r0,@r1
  160.     add #2,r1
  161.     mov.w   @(COMM12,gbr),r0
  162.     mov.w   r0,@r1
  163.     add #2,r1
  164.  
  165.     mov #M_OK,r0        ; I'm OK now
  166.     mov.w   r0,@(COMM2,gbr)
  167.  
  168.     mov #5*2,r0
  169.     bra .rlp
  170.     sub r0,r2
  171.  
  172. .finishoff
  173.     tst r2,r2           ; Finished ?
  174.     bt  .exit           ; Yes
  175.  
  176.     mov.w   @(COMM4,gbr),r0
  177.     mov.w   r0,@r1
  178.     add #2,r1
  179.     dt  r2
  180.     dt  r2
  181.     bt  .exit
  182.     mov.w   @(COMM6,gbr),r0
  183.     mov.w   r0,@r1
  184.     add #2,r1
  185.     dt  r2
  186.     dt  r2
  187.     bt  .exit
  188.     mov.w   @(COMM8,gbr),r0
  189.     mov.w   r0,@r1
  190.     add #2,r1
  191.     dt  r2
  192.     dt  r2
  193.     bt  .exit
  194.     mov.w   @(COMM10,gbr),r0
  195.     mov.w   r0,@r1
  196.  
  197. .exit
  198.  
  199. ;    mov.l   ##_palette,r0       ; Set colour 0 to normal
  200. ;    mov     ##$0000,r1
  201. ;    mov.w   r1,@r0
  202.  
  203.  
  204. ;    mov.w   r0,@(cmdintclr,gbr)     ; CMD interrupt clear
  205. ;    mov.l   ##_FRT,r1
  206. ;    mov.l   #$02,r0         ;toggle FRT bit for future IRQs
  207. ;    mov.b   r0,@(_TOCR,r1)      ;as required
  208. ;    mov.w   @(cmdintclr,gbr),r0     ; V interrupt clear
  209. ;    mov.b   @(_TOCR,r1),r0      ;as required
  210.  
  211. ;    nop
  212. ;    nop
  213. ;    nop
  214.     nop
  215.     nop
  216.     nop
  217.  
  218.     POP r3
  219.     rts
  220.     nop
  221.  
  222.     littab
  223.  
  224. ;============================================================================
  225.     cnop    0,4
  226. M_pwmint:
  227.     mov.l   ##_sysreg,r0
  228.     ldc r0,gbr
  229.  
  230.     mov.w   r0,@(pwmintclr,gbr) ; PWM interrupt clear
  231.     mov.l   ##_FRT,r1
  232.     mov.l   #$02,r0         ;toggle FRT bit for future IRQs
  233.     mov.b   r0,@(_TOCR,r1)      ;as required
  234.     mov.w   @(pwmintclr,gbr),r0 ; V interrupt clear
  235.     mov.b   @(_TOCR,r1),r0      ;as required
  236.  
  237.     nop
  238.     nop
  239.     nop
  240.     nop
  241.     nop
  242.     nop
  243.     rts
  244.     nop
  245.  
  246. ;============================================================================
  247. ;               ERROR
  248. ;============================================================================
  249.  
  250. error0:
  251.  
  252.     if PSYQ=1
  253.     trapa   #$21
  254.     endif
  255.  
  256.     nop
  257.     bra error0
  258.     nop
  259.  
  260. ;============================================================================
  261. ;               TRAP INDICATORS
  262. ;============================================================================
  263.  
  264.     IF  MARS_TRAPS
  265.  
  266.     cnop    0,4
  267.  
  268. T_illegal:
  269.     mov.l   ##_palette,r0       ; YELLOW
  270.     mov ##$1234|$8000,r1
  271.     bra PrintPC
  272.     mov.w   r1,@r0
  273. T_cpu:
  274.     mov.l   ##_palette,r0       ; GREEN
  275.     mov ##$aa00|$8000,r1
  276.     bra PrintPC
  277.     mov.w   r1,@r0
  278. T_dma:
  279.     mov.l   ##_palette,r0       ; RED
  280.     mov ##$003f|$8000,r1
  281.     mov.w   r1,@r0
  282.  
  283. PrintPC:
  284.     POP r3
  285.     mov.l   ##SCREENBASE+(72*SCREENWIDTH)+8+(6*10),r2
  286.     JSR_R0  PrintLONG
  287.     nop
  288.     bsr WaitVbi
  289.     nop
  290.     bsr PageFlip
  291.     nop
  292. .lp1    bra .lp1
  293.     nop
  294.  
  295.     ENDIF
  296.  
  297.     littab
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement