Dandaman955

Nightmare

Dec 3rd, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sub_3EBA:                        ; CODE XREF: ROM:00003EA8p
  2.         ori #$700,sr                 ; Enable interrupts.
  3.         lea ($C00000).l,a5           ; Load the VDP data port into a5.
  4.         lea 4(a5),a6                 ; Load the VDP control port into a6.
  5.         move.w  (a6),d0                  ; TODO IMPORTANT!
  6.         lea ($FF0000).l,a0           ; Load the start of RAM into a0.
  7.         move.w  #$FFF,d0                 ; Set to clear $4000 bytes.
  8.  
  9. loc_3ED4:                        ; CODE XREF: sub_3EBA+1Cj
  10.         clr.l   (a0)+                    ; Clear 4 bytes.
  11.         dbf d0,loc_3ED4              ; Repeat $1000 times.
  12.         lea loc_4278(pc),a0          ; Load the Sega screen VDP setup array address to a0 TODO - Check if it's exclusively for the SS.
  13.         moveq   #$12,d2                  ; Set to write $13 registers.
  14.  
  15. loc_3EE0:                        ; CODE XREF: sub_3EBA+28j
  16.         move.w  (a0)+,(a6)               ; Write the first register into the VDP.
  17.         dbf d2,loc_3EE0              ; Repeat for the others.
  18.         move.l  #$C0000000,($C00004).l   ; Set the VDP to CRAM write.
  19.         moveq   #0,d0                    ; Clear d0.
  20.         moveq   #$1F,d1                  ; Set to clear 64 palettes.
  21.  
  22. loc_3EF4:                        ; CODE XREF: sub_3EBA+3Cj
  23.         move.l  d0,(a5)                  ; Clear the first two palettes.
  24.         dbf d0,loc_3EF4              ; Repeat for the rest.
  25.         move.l  #$40000010,(a6)          ; Set the VDP to VSRAM write.
  26.         moveq   #0,d0                    ; Clear d0.
  27.         move.l  d0,(a5)                  ; Clear 4 bytes of VSRAM.
  28.         move.w  #$8F01,(a6)              ; Set the VDP auto increment to $01.
  29.         move.l  #$93FF94FF,(a6)          ; Set the DMA data length to $FFFF.
  30.         move.w  #$9780,(a6)              ; Set the VDP to DMA fill.
  31.         move.l  #$40000080,(a6)          ; Set to VRAM DMA.
  32.         move.w  #0,(a5)                  ; Clear VRAM.
  33.  
  34. loc_3F1C:                        ; CODE XREF: sub_3EBA+68j
  35.         btst    #1,1(a6)                 ; Is DMA still running?
  36.         bne.s   loc_3F1C                 ; If it is, branch.
  37.         move.w  #$8F02,(a6)               ; Set the VDP auto increment back to $02.
  38.         lea loc_42D6(pc),a0          ; Load the Nemesis-compressed art into a0.               TODO IMPORTANT
  39.         lea ($FF1000).l,a4           ; Load the RAM address to decompress the mappings to.
  40.         bsr.w   NemDectoRAM              ; Decompress into a4.
  41.         lea ($C00000).l,a5           ; Load the VDP data port into a5.
  42.         lea 4(a5),a6                 ; Load the VDP control port into a6.
  43.         move.w  #$187,d2                 ; Set to clear $620 bytes of RAM.
  44.         lea ($FF2000).l,a0           ; Load TODO.
  45.  
  46. loc_3F4A:                        ; CODE XREF: sub_3EBA+92j
  47.         clr.l   (a0)+                    ; Clear 4 bytes of RAM.
  48.         dbf d2,loc_3F4A              ; Repeat for the remaining bytes.
  49.         moveq   #1,d4                    ; Load the first map tile for the Sega art.
  50.         move.l  #$800000,d0              ; Increment value to move down a set of tiles.
  51.         move.l  #$461C0003,d1            ; Move the VDP command to d1.
  52.         moveq   #1,d5                    ; Set to repeat again for the next palette line.
  53.  
  54. loc_3F60:                        ; CODE XREF: sub_3EBA+BEj
  55.         moveq   #1,d3                    ; Set to draw 2 tiles down.
  56.  
  57. loc_3F62:                        ; CODE XREF: sub_3EBA+B6j
  58.         move.l  d1,(a6)                  ; Set the VDP to VRAM write, $C61C (Plane A's mappings).
  59.         moveq   #$B,d2                   ; Set to draw $C tiles across.
  60.  
  61. loc_3F66:                        ; CODE XREF: sub_3EBA+B0j
  62.         move.w  d4,(a5)                  ; Load the first tile onto the screen.
  63.         addq.w  #1,d4                    ; Load the next tile into d4.
  64.         dbf d2,loc_3F66              ; Repeat for the entire horizontal set of tiles.
  65.         add.l   d0,d1                    ; Increment down to the next set of tiles.
  66.         dbf d3,loc_3F62              ; Repeat for the entire vertical set of tiles.
  67.         ori.w   #$2000,d4                ; Load the next (1st) palette line.
  68.         dbf d5,loc_3F60              ; Repeat until finished.
  69.         lea ($FFFF8400).w,a1         ; Load the palette buffer into a1.
  70.         move.l  #$EEE,d1                 ; Set the first two colours to black and white.
  71.         moveq   #1,d3                    ; Set to loop for the next palette line.
  72.  
  73. loc_3F88:                        ; CODE XREF: sub_3EBA+D8j
  74.         move.l  d1,(a1)+                 ; Write the black and white colours to the palette buffer.
  75.         moveq   #6,d2                    ; Set to clear the rest of the palette line.
  76.  
  77. loc_3F8C:                        ; CODE XREF: sub_3EBA+D4j
  78.         clr.l   (a1)+                    ; Clear the next two colours.
  79.         dbf d2,loc_3F8C              ; Repeat until the first palette line is cleared.
  80.         dbf d3,loc_3F88              ; Do the exact same with with the second palette line.
  81.         move.w  #1,($FF3108).l           ; Set the pixel positioning routine as writing.
  82.         lea loc_429E(pc),a0          ;
  83.         lea ($FF3000).l,a1           ; TODO animated art buffer?
  84.         move.l  (a0)+,(a1)+              ;
  85.         move.l  (a0)+,(a1)+              ;
  86.             moveq   #-1,d1                   ; Set d1 to $FFFFFFFF.
  87.         moveq   #$1E,d2                  ; Set buffer size.
  88.  
  89. loc_3FB0:                        ; CODE XREF: sub_3EBA+FCj
  90.         move.w  d1,(a1)
  91.         lea 8(a1),a1                 ; Load the next space.
  92.         dbf d2,loc_3FB0              ; Repeat until finished.
  93.         clr.l   ($FFFFC420).w            ; TODO
  94.         andi    #$F8FF,sr                ; Disable interrupts.
  95.         move.w  #$8174,(a6)              ; Enable display, VBlank and DMA.
  96.  
  97. loc_3FC6:                        ; CODE XREF: sub_3EBA+15Cj
  98.         moveq   #$1F,d7                  ; Set buffer size to check.
  99.         lea ($FF3000).l,a6
  100.  
  101. loc_3FCE:                        ; CODE XREF: sub_3EBA+12Ej
  102.         tst.w   (a6)                     ; Is it a valid entry?
  103.         bmi.s   loc_3FE4                 ; If it isn't, skip
  104.         move.w  2(a6),d0                 ;
  105.         bpl.s   loc_3FE0
  106.         ext.w   d0
  107.         move.w  d0,2(a6)
  108.         bra.s   loc_3FE4
  109. ; ===========================================================================
  110.  
  111. loc_3FE0:                        ; CODE XREF: sub_3EBA+11Cj
  112.         bsr.w   sub_4138
  113.     ;            bra.s   *                        ; 3FE4
  114. loc_3FE4:                        ; CODE XREF: sub_3EBA+116j
  115.                              ; sub_3EBA+124j
  116.         lea 8(a6),a6                 ; Check the other entries.
  117.         dbf d7,loc_3FCE
  118. ; bra.s *
  119.         lea ($FF2000).l,a0           ; Load the plotted pixels buffer into a0.
  120.         bsr.w   sub_411E                 ; Dump onto the screen.
  121.         bset    #7,($FFFFC462).w         ; Set to CRAM write.
  122.         bsr.w   WaitforVBlank            ; Load black and white into palette line 0 and 1.
  123.    ;bra.s *
  124. loc_4000:               ; DATA XREF: ROM:00007E80o
  125.                              ; ROM:00007F50o
  126.         move.b  ($FFFFC421).w,d0
  127.         or.b    ($FFFFC423).w,d0
  128.         andi.b  #-$10,d0
  129.         bne.w   locret_411C
  130.         tst.w   ($FF3108).l              ; Have all the pixels been dumped?
  131.         bne.s   loc_3FC6                 ; If not, load the next pixel.
  132.  
  133.             lea ($FF1000).l,a0           ; Load the decompressed tiles into a0.
  134.         bsr.w   sub_411E                 ; Load into VRAM (Tiles are loaded over drawn pixels).
  135.         moveq   #$D,d7
  136.         move.w  #$111,d6
  137.         moveq   #0,d5
  138.  
  139. loc_402A:                        ; CODE XREF: sub_3EBA+19Cj
  140.         add.w   d6,d5
  141.         lea ($FFFF8404).w,a1
  142.         moveq   #$D,d2
  143.  
  144. loc_4032:                        ; CODE XREF: sub_3EBA+17Ej
  145.         move.w  d5,$20(a1)
  146.         move.w  d5,(a1)+
  147.         dbf d2,loc_4032
  148.         bset    #7,($FFFFC462).w
  149.         bsr.w   WaitforVBlank
  150.         move.b  ($FFFFC421).w,d0
  151.         or.b    ($FFFFC423).w,d0
  152.         andi.b  #-$10,d0
  153.         bne.w   locret_411C
  154.         dbf d7,loc_402A
  155.         lea ($FF310E).l,a1
  156.         move.w  #7,(a1)+
  157.         move.w  #$A,(a1)+
  158.         move.w  #$111,d4
  159.         lea ($FFFF8404).w,a5
  160.         moveq   #$D,d7
  161.  
  162. loc_4072:                        ; CODE XREF: sub_3EBA+23Ej
  163.         cmpi.w  #6,d7
  164.         bcs.s   loc_407E
  165.         sub.w   d4,(a5)
  166.         sub.w   d4,$20(a5)
  167.  
  168. loc_407E:                        ; CODE XREF: sub_3EBA+1BCj
  169.         lea Pal_SegaScreen(pc),a2
  170.         lea ($FF310E).l,a3
  171.         lea ($FFFF8408).w,a4
  172.         moveq   #1,d6
  173.  
  174. loc_408E:                        ; CODE XREF: sub_3EBA+20Aj
  175.         move.w  (a3),d5
  176.         subq.w  #1,d5
  177.         move.w  d5,(a3)+
  178.         movea.l a4,a1
  179.         moveq   #3,d2
  180.  
  181. loc_4098:                        ; CODE XREF: sub_3EBA+1FAj
  182.                     ; sub_3EBA+202j
  183.         addq.w  #1,d5
  184.         bmi.s   loc_40BA
  185.         cmpi.w  #8,d5
  186.         bcc.s   loc_40BA
  187.         move.w  d5,d0
  188.         add.w   d0,d0
  189.         move.w  d0,d1
  190.         add.w   d0,d0
  191.         add.w   d0,d1
  192.         movea.l a2,a0
  193.         adda.w  d1,a0
  194.         move.l  (a0)+,(a1)+
  195.         move.w  (a0)+,(a1)+
  196.         dbf d2,loc_4098
  197.         bra.s   loc_40C0
  198. ; ===========================================================================
  199.  
  200. loc_40BA:                        ; CODE XREF: sub_3EBA+1E0j
  201.                     ; sub_3EBA+1E6j
  202.         addq.w  #6,a1
  203.         dbf d2,loc_4098
  204.  
  205. loc_40C0:                        ; CODE XREF: sub_3EBA+1FEj
  206.         lea $20(a4),a4
  207.         dbf d6,loc_408E
  208.         bset    #7,($FFFFC462).w
  209.         bsr.w   WaitforVBlank
  210.         move.b  ($FFFFC421).w,d0
  211.         or.b    ($FFFFC423).w,d0
  212.         andi.b  #-$10,d0
  213.         bne.w   locret_411C
  214.         bset    #7,($FFFFC462).w
  215.         bsr.w   WaitforVBlank
  216.         move.b  ($FFFFC421).w,d0
  217.         or.b    ($FFFFC423).w,d0
  218.         andi.b  #-$10,d0
  219.         dbf d7,loc_4072
  220.         moveq   #$3B,d7 ; ";"
  221.  
  222. loc_40FE:                        ; CODE XREF: sub_3EBA+25Ej
  223.         bset    #7,($FFFFC462).w
  224.         bsr.w   WaitforVBlank
  225.         move.b  ($FFFFC421).w,d0
  226.         or.b    ($FFFFC423).w,d0
  227.         andi.b  #-$10,d0
  228.         bne.w   locret_411C
  229.         dbf d7,loc_40FE
  230.  
  231. locret_411C:                         ; CODE XREF: sub_3EBA+152j
  232.                     ; sub_3EBA+198j ...
  233.         rts
  234. ; End of function sub_3EBA
  235.  
  236.  
  237. ; ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ S U B  R O U T I N E ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  238.  
  239.  
  240. sub_411E:                        ; CODE XREF: sub_3EBA+138p
  241.                              ; sub_3EBA+164p
  242.         movea.l #$C00000,a1              ; Load the VDP control port into a1.
  243.         move.w  #$30F,d1                 ; Set to dump $620 bytes into RAM.
  244.         move.l  #$40000000,4(a1)         ; Set the VDP to VRAM write, $0000.
  245.  
  246. loc_4130:                        ; CODE XREF: sub_411E+14j
  247.         move.w  (a0)+,(a1)               ; Dump the first four pixels into VRAM.
  248.         dbf d1,loc_4130              ; Repeat until finished.
  249.         rts                              ; Return.
  250. ; End of function sub_411E
  251.  
  252.  
  253. ; ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ S U B  R O U T I N E ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  254.  
  255.  
  256. sub_4138:                        ; CODE XREF: sub_3EBA+126p
  257.         clr.b   ($FF3112).l
  258.         move.w  6(a6),d5
  259.         addq.w  #4,d5
  260.         andi.w  #$E,d5
  261.         moveq   #4,d6
  262.         bra.s   loc_417C
  263. ; ===========================================================================
  264.  
  265. loc_414C:                        ; CODE XREF: sub_4138+D2j
  266.         dbf d6,loc_4174
  267.         bclr    #7,($FF3112).l
  268.         beq.s   loc_4168
  269.         lea ($FF3100).l,a0
  270.         movea.l a6,a1
  271.         move.l  (a0)+,(a1)+
  272.         move.w  (a0)+,(a1)+
  273.         rts
  274. ; ===========================================================================
  275.  
  276. loc_4168:                        ; CODE XREF: sub_4138+20j
  277.         subq.w  #1,($FF3108).l
  278.         move.w  #-1,(a6)
  279.         rts
  280. ; ===========================================================================
  281.  
  282. loc_4174:                        ; CODE XREF: sub_4138+14j
  283.         subq.w  #2,d5
  284.         bcc.s   loc_417C
  285.         move.w  #$E,d5
  286.  
  287. loc_417C:                        ; CODE XREF: sub_4138+12j sub_4138+3Ej
  288.         bsr.w   sub_420E
  289.         swap    d5
  290.         swap    d6
  291.         swap    d7
  292.         moveq   #1,d0
  293.         moveq   #$F,d1
  294.         move.w  d2,d6
  295.         lsr.w   #1,d6
  296.         bcs.s   loc_4194
  297.         moveq   #$10,d0
  298.         moveq   #-$10,d1
  299.  
  300. loc_4194:                        ; CODE XREF: sub_4138+56j
  301.         move.w  d0,d5
  302.         move.w  d1,d7
  303.         move.w  d3,d0
  304.         lsl.w   #2,d0
  305.         add.w   d0,d6
  306.         add.w   d4,d6
  307.         lea ($FF1000).l,a0                ; bookmark
  308.         move.b  (a0,d6.w),d0
  309.         and.w   d7,d0
  310.         cmp.b   d5,d0
  311.         bne.s   loc_4204
  312.         lea ($FF2000).l,a1           ; Load the plotted pixel buffer to a1.
  313.         adda.w  d6,a1                    ; Get the correct offset to write to.
  314.         move.b  (a1),d0
  315.         and.w   d7,d0
  316.         cmp.w   d5,d0
  317.         beq.s   loc_4204
  318.         or.b    d5,(a1)
  319.         bset    #7,($FF3112).l
  320.         bne.s   loc_41E0
  321.         swap    d5
  322.         move.w  d5,6(a6)
  323.         lea ($FF3100).l,a1
  324.         move.w  d2,(a1)+
  325.         move.w  d3,(a1)+
  326.         move.w  d4,(a1)+
  327.         bra.s   loc_4206
  328. ; ===========================================================================
  329.  
  330. loc_41E0:                        ; CODE XREF: sub_4138+92j
  331.         lea ($FF2FF8).l,a1
  332.         addq.w  #1,($FF3108).l
  333.  
  334. loc_41EC:                        ; CODE XREF: sub_4138+BAj
  335.         lea 8(a1),a1
  336.         tst.w   (a1)
  337.         bpl.s   loc_41EC
  338.         move.w  d2,(a1)+
  339.         ori.w   #-$100,d3
  340.         move.w  d3,(a1)+
  341.         move.w  d4,(a1)+
  342.         swap    d5
  343.         move.w  d5,(a1)+
  344.         swap    d5
  345.  
  346. loc_4204:                        ; CODE XREF: sub_4138+76j sub_4138+86j
  347.         swap    d5
  348.  
  349. loc_4206:                        ; CODE XREF: sub_4138+A6j
  350.         swap    d6
  351.         swap    d7
  352.         bra.w   loc_414C
  353. ; End of function sub_4138
  354.  
  355.  
  356. ; ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ S U B  R O U T I N E ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  357.  
  358.  
  359. sub_420E:                        ; CODE XREF: sub_4138+44p
  360.         move.w  0(a6),d2
  361.         move.w  2(a6),d3
  362.         move.w  4(a6),d4
  363.         jmp loc_421E(pc,d5.w)
  364. ; End of function sub_420E
  365.  
  366. ; ===========================================================================
  367.  
  368. loc_421E:
  369.         bra.s   loc_4230
  370. ; ===========================================================================
  371.         bra.s   loc_4232
  372. ; ===========================================================================
  373.         bra.s   loc_4236
  374. ; ===========================================================================
  375.         bra.s   loc_4238
  376. ; ===========================================================================
  377.         bra.s   loc_423C
  378. ; ===========================================================================
  379.         bra.s   loc_423E
  380. ; ===========================================================================
  381.         bra.s   loc_4240
  382. ; ===========================================================================
  383.         bsr.s   sub_424C
  384.         bra.s   loc_4240
  385. ; ===========================================================================
  386.  
  387. loc_4230:                        ; CODE XREF: ROM:0000421Ej
  388.         bra.s   sub_424C
  389. ; ===========================================================================
  390.  
  391. loc_4232:                        ; CODE XREF: ROM:00004220j
  392.         bsr.s   sub_424C
  393.         bra.s   loc_425C
  394. ; ===========================================================================
  395.  
  396. loc_4236:                        ; CODE XREF: ROM:00004222j
  397.         bra.s   loc_425C
  398. ; ===========================================================================
  399.  
  400. loc_4238:                        ; CODE XREF: ROM:00004224j
  401.         bsr.s   sub_426C
  402.         bra.s   loc_425C
  403. ; ===========================================================================
  404.  
  405. loc_423C:                        ; CODE XREF: ROM:00004226j
  406.         bra.s   sub_426C
  407. ; ===========================================================================
  408.  
  409. loc_423E:                        ; CODE XREF: ROM:00004228j
  410.         bsr.s   sub_426C
  411.  
  412. loc_4240:                        ; CODE XREF: ROM:0000422Aj
  413.                              ; ROM:0000422Ej
  414.         subq.w  #1,d3
  415.         bcc.s   locret_424A
  416.         moveq   #7,d3
  417.         subi.w  #$180,d4
  418.  
  419. locret_424A:                         ; CODE XREF: ROM:00004242j
  420.         rts
  421.  
  422. ; ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ S U B  R O U T I N E ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  423.  
  424.  
  425. sub_424C:                        ; CODE XREF: ROM:0000422Cp
  426.                              ; ROM:00004230j ...
  427.         addq.w  #1,d2
  428.         cmpi.w  #8,d2
  429.         bcs.s   locret_425A
  430.         moveq   #0,d2
  431.         addi.w  #$20,d4 ; " "
  432.  
  433. locret_425A:                         ; CODE XREF: sub_424C+6j
  434.         rts
  435. ; End of function sub_424C
  436.  
  437. ; ===========================================================================
  438.  
  439. loc_425C:                        ; CODE XREF: ROM:00004234j
  440.                              ; ROM:00004236j ...
  441.         addq.w  #1,d3
  442.         cmpi.w  #8,d3
  443.         bcs.s   locret_426A
  444.         moveq   #0,d3
  445.         addi.w  #$180,d4
  446.  
  447. locret_426A:                         ; CODE XREF: ROM:00004262j
  448.         rts
  449.  
  450. ; ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ S U B  R O U T I N E ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  451.  
  452.  
  453. sub_426C:                        ; CODE XREF: ROM:00004238p
  454.                              ; ROM:0000423Cj ...
  455.         subq.w  #1,d2
  456.         bcc.s   locret_4276
  457.         moveq   #7,d2
  458.         subi.w  #$20,d4 ; " "
  459.  
  460. locret_4276:                         ; CODE XREF: sub_426C+2j
  461.         rts
  462. ; End of function sub_426C
  463.  
  464.  
  465.  
  466. ; FOR REFERENCE
  467. ;
  468.  
  469. loc_429E:
  470.                dc.l    $00010001
  471.                 dc.l    $00200002
Advertisement
Add Comment
Please, Sign In to add comment