Advertisement
Dandaman955

TMSS Disassembly

Nov 1st, 2016
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. ;
  4. ; +-------------------------------------------------------------------------+
  5. ; |   This file has been generated by The Interactive Disassembler (IDA)    |
  6. ; |       Copyright (c) 2011 Hex-Rays, <support@hex-rays.com>       |
  7. ; +-------------------------------------------------------------------------+
  8. ;
  9. ; Input MD5   : D3293EBAAA7F4EB2A6766B68A0FB4609
  10. ; Input CRC32 : 3F888CF4
  11.  
  12. ; File Name   : ~/No/Really/FuckOff/ShitGophers/tmss.bin
  13. ; Format      : Binary file
  14. ; Base Address: 0000h Range: 0000h - 0800h Loaded length: 0800h
  15.  
  16. ; Processor:        68000
  17. ; Target Assembler: 680x0 Assembler in MRI compatible mode
  18. ; This file should be compiled with "as -M"
  19.  
  20. ; ===========================================================================
  21.  
  22. ; Segment type: Pure code
  23. ; segment "ROM"
  24. Vectors:    dc.l $FFFF00
  25.         dc.l CodeStart
  26.         dc.l Int
  27.         dc.l Int
  28.         dc.l Int,Int,Int,Int    ; 0
  29.         dc.l Int,Int,Int,Int    ; 4
  30.         dc.l Int,Int,Int,Int    ; 8
  31.         dc.l Int,Int,Int,Int    ; $C
  32.         dc.l Int,Int,Int,Int    ; $10
  33.         dc.l Int,Int,Int,Int    ; $14
  34.         dc.l Int,Int,Int,Int    ; $18
  35.         dc.l Int,Int,Int,Int    ; $1C
  36.         dc.l Int,Int,Int,Int    ; $20
  37.         dc.l Int,Int,Int,Int    ; $24
  38.         dc.l Int,Int,Int,Int    ; $28
  39.         dc.l Int,Int,Int,Int    ; $2C
  40.         dc.l Int,Int,Int,Int    ; $30
  41.         dc.l Int,Int,Int,Int    ; $34
  42.         dc.l Int,Int,Int,Int    ; $38
  43. SysName:    dc.b 'SEGA GENESIS    ' ; DATA XREF: ROM:000002EEr
  44.                     ; ROM:000002F4r ...
  45. Copyright:  dc.b '(C)SEGA 1990.MAY'
  46. LocalName:  dc.b 'GENESIS OS                                      '
  47. IntName:    dc.b 'GENESIS OS                                      '
  48. Serial:     dc.b 'OS 00000000-00'
  49. Checksum:   dc.w $5B74
  50. IO:     dc.b '                '
  51. StartROM:   dc.l         0      ; 0
  52. EndROM:     dc.l      $7FF      ; 0
  53. StartRAM:   dc.l $FF0000
  54. EndRAM:     dc.l $FFFFFF
  55.         dc.l $20202020
  56.         dc.l $20202020
  57.         dc.l $20202020
  58. Notes:      dc.b '                                                    '
  59. Region:     dc.b 'U               '
  60. ; ---------------------------------------------------------------------------
  61.  
  62. Int:                    ; CODE XREF: ROM:Intj
  63.                     ; DATA XREF: ROM:00000008o ...
  64.         bra.s   Int                      ; Loop indefinitely.
  65. ; ---------------------------------------------------------------------------
  66.  
  67. CodeStart:              ; DATA XREF: ROM:00000004o
  68.         lea SetupValues,a5           ; Load the initialisation values address.
  69.         movem.l (a5)+,d5-a4              ; Store to registers.
  70.         move.b  -$10FF(a1),d0            ; Get the version register value in d0.
  71.         andi.b  #$F,d0                   ; Get hardware version.
  72.         beq.s   BypassSecurity           ; If it's a non-TMSS model, branch.
  73.         move.l  #'SEGA',$2F00(a1)        ; Write the security code to the TMSS.
  74.  
  75. BypassSecurity:             ; CODE XREF: ROM:00000212j
  76.         move.w  (a4),d0                  ; Clear the VDP's command-pending flag.
  77.         moveq   #0,d0                    ; Clear d0.
  78.         movea.l d0,a6                    ; Clear a6.
  79.         move    a6,usp                   ; Set usp to 0.
  80.         moveq   #$17,d1                  ; Set to loop for $18 VDP registers.
  81.  
  82. InitLoop_VDP:               ; CODE XREF: ROM:0000022Cj
  83.         move.b  (a5)+,d5                 ; Load the command byte over the VDP register base.
  84.         move.w  d5,(a4)                  ; Write to the VDP.
  85.         add.w   d7,d5                    ; Increment to the next VDP register.
  86.         dbf d1,InitLoop_VDP          ; Repeat until fully written.
  87.         move.l  #$40000080,(a4)          ; Set the VDP to VRAM DMA (fill).
  88.         move.w  d0,(a3)                  ; Fill in VRAM.
  89.  
  90. ClearVRAM:              ; CODE XREF: ROM:0000023Ej
  91.         move.w  (a4),d4                  ; Get the VDP's status.
  92.         btst    #1,d4                    ; Is DMA running?
  93.         bne.s   ClearVRAM                ; If it is, branch.
  94.         move.l  #$81048F02,(a4)          ; Disable DMA, VBlank and the display. Set the VDP's auto-increment to $02.
  95.         move.l  #$C0000000,(a4)          ; Set the VDP to CRAM write.
  96.         moveq   #$1F,d3                  ; Set to repeat for 64 palettes.
  97.  
  98. ClearCRAM:              ; CODE XREF: ROM:00000250j
  99.         move.l  d0,(a3)                  ; Clear two palettes.
  100.         dbf d3,ClearCRAM             ; Repeat until fully cleared.
  101.         move.l  #$40000010,(a4)          ; Set the VDP to VSRAM write.
  102.         moveq   #$13,d4                  ; Set to repeat for $50 bytes.
  103.  
  104. ClearVSRAM:             ; CODE XREF: ROM:0000025Ej
  105.         move.l  d0,(a3)                  ; Clear 4 bytes of VSRAM.
  106.         dbf d4,ClearVSRAM            ; Repeat until fully cleared.
  107.         moveq   #3,d5                    ; Set to repeat for 4 values.
  108.  
  109. InitPSG:                ; CODE XREF: ROM:00000268j
  110.         move.b  (a5)+,$11(a3)            ; Load the first PSG channel mute value.
  111.         dbf d5,InitPSG               ; Repeat until fully written.
  112.         bra.s   Reg_Set                  ; Load the TMSS program.
  113. ; ---------------------------------------------------------------------------
  114. SetupValues:    dc.l     $8000      ; 0 ; DATA XREF: ROM:CodeStarto
  115.         dc.l $3FFF
  116.         dc.l $100
  117.         dc.l $A00000
  118.         dc.l $A11100
  119.         dc.l $A11200
  120.         dc.l $C00000
  121.         dc.l $C00004
  122. VDP_Regs:   dc.b   4,$14,$30,$3C,  7,$6C,  0,  0; 0
  123.         dc.b   0,  0,$FF,  0,$81,$37,  0,  1; 8
  124.         dc.b   1,  0,  0,$FF,$FF,  0,  0,$80; $10
  125. PSG_Setup:  dc.b $9F,$BF,$DF,$FF    ; 0
  126. ; ---------------------------------------------------------------------------
  127.  
  128. Reg_Set:                ; CODE XREF: ROM:0000026Cj
  129.         lea ($FFFFC000).w,a0         ; Set RAM location to stash code.
  130.         lea SetupValues_2,a1         ; Set up registers.
  131.         movem.l (a1)+,d4-d7/a2-a6        ; Copy to registers.
  132.         move.w  #$3F,d0                  ; Write loop count.
  133.  
  134. RAM_Fill:               ; CODE XREF: ROM:000002BCj
  135.         move.w  (a1)+,(a0)+          ; Stash remaining code in RAM.
  136.         dbf d0,RAM_Fill              ; Repeat until fully written.
  137.         jsr $FFFFC000            ; Run code.
  138.  
  139. InfiniteLoop:               ; CODE XREF: ROM:InfiniteLoopj
  140.         bra.s   InfiniteLoop             ; Loop indefinitely.
  141. ; ---------------------------------------------------------------------------
  142. SetupValues_2:  dc.l ' SEG'             ; DATA XREF: ROM:000002AEo
  143.                     ; Alternate text check (d4)
  144.         dc.l $45940003      ; VRAM Address for text (d5)
  145.         dc.l $F7        ; VDP write loop count (d6)
  146.         dc.l 'SEGA'             ; Normal text check (d7)
  147.         dc.l $A14000        ; SEGA security check (a2)
  148.         dc.l $A14101        ; TMSS read register (a3)
  149.         dc.l $C00004        ; VDP Control port (a4)
  150.         dc.l $C00000        ; VDP Data port (a5)
  151.         dc.l $A10001            ; Version register (a6).
  152. ; ---------------------------------------------------------------------------
  153. ; $FFFFC000 - Code is loaded into RAM.
  154.  
  155. SecCheck:
  156.         bset    #0,(a3)                  ; Read from cart.
  157.         cmp.l   (SysName).w,d7           ; Is the ASCII code 'SEGA' there?
  158.         beq.s   Match                    ; If there is, branch.
  159.         cmp.l   (SysName).w,d4           ; Is the ASCII code ' SEG' there>
  160.         bne.s   NoMatch                  ; If there isn't, branch.
  161.         cmpi.b  #'A',(SysName+4).w       ; Check for the remaining 'A'.
  162.         beq.s   Match                    ; If it's there, branch.
  163.  
  164. NoMatch:                ; CODE XREF: ROM:000002F8j
  165.         bclr    #0,(a3)                  ; Read from TMSS ROM.
  166.         move.b  (a6),d0                  ; Get version register value.
  167.         andi.b  #$F,d0                   ; Get hardware version bits.
  168.         beq.s   NoMatch_rts              ; If it's a non-TMSS model, don't write to the dedicated security address.
  169.         move.l  #0,(a2)                  ; Clear the security register.
  170.  
  171. NoMatch_rts:                ; CODE XREF: ROM:0000030Cj
  172.         rts                              ; Return; loop indefinitely.
  173. ; ---------------------------------------------------------------------------
  174.  
  175. Match:                  ; CODE XREF: ROM:000002F2j
  176.                     ; ROM:00000300j
  177.         bclr    #0,(a3)              ; Swap back to TMSS ROM.
  178.         jsr (PalLoad).l              ; Load the text palette.
  179.         move.l  #$4C200000,(a4)          ; Set the VRAM address to write to ($C20).
  180.  
  181. DataPortFill:               ; CODE XREF: ROM:00000328j
  182.         move.l  (a1)+,(a5)               ; Write the first 8 pixels into VRAM.
  183.         dbf d6,DataPortFill          ; Repeat until fully written.
  184.         jsr (WriteChar).l            ; Draw the copyright text.
  185.         move.w  #$8144,(a4)              ; Turn on the display.
  186.         move.w  #$3C,d0 ; '<'            ; Set amount of times to repeat the subroutine.
  187.         bsr.s   DelayBoot                ; Delay the screen.
  188.         move.w  #$8104,(a4)              ; Turn off the display.
  189.         move.b  (a6),d0                  ; Get the version register value.
  190.         andi.b  #$F,d0                   ; Get hardware version bits.
  191.         beq.s   BlankVerBit              ; If it's a non-TMSS model, ignore the security space write.
  192.         move.l  #0,(a2)                  ; Clear the security register.
  193.  
  194. BlankVerBit:                ; CODE XREF: ROM:00000346j
  195.         bset    #0,(a3)                  ; Read from the cart.
  196.         moveq   #0,d0                    ; Clear d0.
  197.         movea.l d0,a0                    ; Set to read from the start of the cart ROM.
  198.         movea.l (a0)+,sp                 ; Set the cart stack pointer as the stack pointer.
  199.         movea.l (a0)+,a0                 ; Load the entry point address into a0.
  200.         jmp (a0)                     ; Run the cartridge ROM.
  201.  
  202. ; =============== S U B R O U T I N E =======================================
  203.  
  204.  
  205. DelayBoot:              ; CODE XREF: ROM:0000033Ap
  206.                     ; DelayBoot+8j
  207.         move.w  #$95CE,d1                ; Set a delay of $95CE arbitrary units.
  208.  
  209. DelayBootLoop:              ; CODE XREF: DelayBoot:DelayBootLoopj
  210.         dbf d1,DelayBootLoop         ; Repeat until delay has passed.
  211.         dbf d0,DelayBoot             ; Loop the subroutine the amount of times stated.
  212.         rts                              ; Return.
  213. ; End of function DelayBoot
  214.  
  215. ; ---------------------------------------------------------------------------
  216.         dc.w 1
  217.         dc.w $EEE
  218.         dc.w $EE8
  219. Chars:      dc.l  $1111100,$11000110,$11000110,$11000110; 0
  220.         dc.l $11111110,$11000110,$11000110,    0; 4
  221.         dc.l $11111100,$11000110,$11000110,$11111100; 0
  222.         dc.l $11000110,$11000110,$11111100,    0; 4
  223.         dc.l $11111110,$11000110,$11000110,$11000000; 0
  224.         dc.l $11000110,$11000110,$11111110,    0; 4
  225.         dc.l $11111100,$11000110,$11000110,$11000110; 0
  226.         dc.l $11000110,$11000110,$11111100,    0; 4
  227.         dc.l $11111110,$11000000,$11000000,$11111100; 0
  228.         dc.l $11000000,$11000000,$11111110,    0; 4
  229.         dc.l $11111110,$11000000,$11000000,$11111100; 0
  230.         dc.l $11000000,$11000000,$11000000,    0; 4
  231.         dc.l $11111110,$11000110,$11000000,$11001110; 0
  232.         dc.l $11000110,$11000110,$11111110,    0; 4
  233.         dc.l $11000110,$11000110,$11000110,$11111110; 0
  234.         dc.l $11000110,$11000110,$11000110,    0; 4
  235.         dc.l   $111000,  $111000,  $111000,  $111000; 0
  236.         dc.l   $111000,  $111000,  $111000,    0; 4
  237.         dc.l      $110,     $110,     $110, $110; 0
  238.         dc.l      $110, $1100110, $1111110,    0; 4
  239.         dc.l $11000110,$11001100,$11111000,$11111000; 0
  240.         dc.l $11001100,$11000110,$11000110,    0; 4
  241.         dc.l  $1100000, $1100000, $1100000, $1100000; 0
  242.         dc.l  $1100000, $1100000, $1111110,    0; 4
  243.         dc.l $11000110,$11101110,$11111110,$11010110; 0
  244.         dc.l $11000110,$11000110,$11000110,    0; 4
  245.         dc.l $11000110,$11100110,$11110110,$11011110; 0
  246.         dc.l $11001110,$11000110,$11000110,    0; 4
  247.         dc.l $11111110,$11000110,$11000110,$11000110; 0
  248.         dc.l $11000110,$11000110,$11111110,    0; 4
  249.         dc.l $11111110,$11000110,$11000110,$11111110; 0
  250.         dc.l $11000000,$11000000,$11000000,    0; 4
  251.         dc.l $11111110,$11000110,$11000110,$11000110; 0
  252.         dc.l $11001110,$11001110,$11111110,    0; 4
  253.         dc.l $11111110,$11000110,$11000110,$11111100; 0
  254.         dc.l $11000110,$11000110,$11000110,    0; 4
  255.         dc.l $11111110,$11000110,$11000000,$11111110; 0
  256.         dc.l      $110,$11000110,$11111110,    0; 4
  257.         dc.l $11111110,  $111000,  $111000,  $111000; 0
  258.         dc.l   $111000,  $111000,  $111000,    0; 4
  259.         dc.l $11000110,$11000110,$11000110,$11000110; 0
  260.         dc.l $11000110,$11000110,$11111110,    0; 4
  261.         dc.l $11000110,$11000110,$11000110,$11000110; 0
  262.         dc.l  $1101100,  $111000,   $10000,    0; 4
  263.         dc.l $11000110,$11000110,$11000110,$11010110; 0
  264.         dc.l $11111110,$11101110,$11000110,    0; 4
  265.         dc.l $11000110,$11000110,$11101110, $1111100; 0
  266.         dc.l $11101110,$11000110,$11000110,    0; 4
  267.         dc.l $11000110,$11000110,$11000110, $1101100; 0
  268.         dc.l   $111000,  $111000,  $111000,    0; 4
  269.         dc.l $11111110,    $1110,   $11100,  $111000; 0
  270.         dc.l  $1110000,$11100000,$11111110,    0; 4
  271.         dc.l         0,        0,    0,    0; 0
  272.         dc.l         0, $1100000, $1100000,    0; 4
  273. UnusedSEGA: dc.l  $2222200,$22000220,$22000000, $2222200; 0
  274.         dc.l      $220,$22000220, $2222200,    0; 4
  275.         dc.l  $2222220,$22000000,$22000000,$22222200; 0
  276.         dc.l $22000000,$22000000, $2222220,    0; 4
  277.         dc.l  $2222200,$22000220,$22000000,$22002220; 0
  278.         dc.l $22000220,$22000220, $2222220,    0; 4
  279.         dc.l    $22000,  $222200,  $222200, $2200220; 0
  280.         dc.l  $2200220,$22000022,$22022222,    0; 4
  281. TMSS_Message:   dc.b '   produced by or� under license from�sega,enterprises ltd{',0
  282.  
  283. ; =============== S U B R O U T I N E =======================================
  284.  
  285.  
  286. PalLoad:                ; CODE XREF: ROM:0000031Ap
  287.         move.w  (a1)+,d0
  288.         move.l  #$C0020000,(a4)
  289.  
  290. WritePal:               ; CODE XREF: PalLoad+Aj
  291.         move.w  (a1)+,(a5)
  292.         dbf d0,WritePal
  293.         rts
  294. ; End of function PalLoad
  295.  
  296.  
  297. ; =============== S U B R O U T I N E =======================================
  298.  
  299.  
  300. WriteChar:              ; CODE XREF: ROM:0000032Cp
  301.                     ; WriteChar+16j
  302.         move.l  d5,(a4)                  ; Set the text's plane map address.
  303.  
  304. FindChar:               ; CODE XREF: WriteChar+Ej
  305.         moveq   #0,d1                    ; Clear d1.
  306.         move.b  (a1)+,d1                 ; Load the first character.
  307.         bmi.s   NewLine                  ; If it's a control code for a new line ($80+), branch.
  308.         bne.s   CharToDataPort           ; If it isn't a terminator ($00), write onto the screen.
  309.         rts                              ; Return.
  310. ; ---------------------------------------------------------------------------
  311.  
  312. CharToDataPort:             ; CODE XREF: WriteChar+8j
  313.         move.w  d1,(a5)                  ; Draw onto the screen.
  314.         bra.s   FindChar                 ; Repeat until the text is fully dumped.
  315. ; ---------------------------------------------------------------------------
  316.  
  317. NewLine:                ; CODE XREF: WriteChar+6j
  318.         addi.l  #$1000000,d5             ; Set to increment two lines down at this plane size.
  319.         bra.s   WriteChar                ; Set new VRAM address and continue writing text.
  320. ; End of function WriteChar
  321.  
  322. ; ---------------------------------------------------------------------------
  323.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; 0
  324.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; 8
  325.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; $10
  326.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; $18
  327.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; $20
  328.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; $28
  329.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; $30
  330.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; $38
  331.         dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; $40
  332.         dc.b $FF,$FF,$FF,$FF    ; $48
  333. ; end of 'ROM'
  334.  
  335.  
  336.         END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement